Commit a065bda4 authored by Pedro Alfonso Ramirez's avatar Pedro Alfonso Ramirez

Add unzip

parent b2c048f0
#!/bin/python
# Copyright (C) 2018 Adan Salazar <asalazargaribay@gmail.com>
#
#
# This file is part of GeoSentinel
#
#
# GeoSentinel is free software you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GeoSentinel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with StereoVision. If not, see <http://www.gnu.org/licenses/>.
"""
Example of unzip Sentinel files in a specific directory
"""
from argparse import ArgumentParser
from geosentinel.ui_utils import (find_files, unzip, SENTINEL_UNZIP_ARGUMENTS)
def main():
"""
Unzip all Sentinel files in the folder specified by the user and print the number files and the list of files.
Please run: python unzip_sentinel_files --help before usage
"""
parser = ArgumentParser(description="Unzip Sentinel files in the folder specified by the user",
parents=[SENTINEL_UNZIP_ARGUMENTS])
args = parser.parse_args()
list_files = find_files(args)
unzip(list_files,args)
#print list_files
if __name__ == "__main__":
main()
...@@ -73,6 +73,14 @@ SENTINEL_FIND_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel fil ...@@ -73,6 +73,14 @@ SENTINEL_FIND_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel fil
SENTINEL_FIND_ARGUMENTS.add_argument("plattform", help="sentinel-1 or sentinel-2") SENTINEL_FIND_ARGUMENTS.add_argument("plattform", help="sentinel-1 or sentinel-2")
SENTINEL_UNZIP_ARGUMENTS = ArgumentParser(add_help=False)
SENTINEL_UNZIP_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel files")
SENTINEL_UNZIP_ARGUMENTS.add_argument("plattform", help="sentinel-1 or sentinel-2")
SENTINEL_UNZIP_ARGUMENTS.add_argument("product_type", help="sentinel product type {SM_SLC, SM_GRDF, SM_GRDH, SM_GRDM, IW_SLC, IW_GRDH, IW_GDRM, EW_SLC, EW_GRDH, EW_GRDM, WV_SLC, WV_GRDM, MSIL1C, OPER_PRD }")
def find_files(args): def find_files(args):
...@@ -90,7 +98,13 @@ def find_files(args): ...@@ -90,7 +98,13 @@ def find_files(args):
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)] files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)]
return files return files
def unzip(list_files,args):
for image in list_files:
print"Unzziped... ",image
File = args.folder + "\\" +image
zip_ref = zipfile.ZipFile(File) # create zipfile object
zip_ref.extractall(args.folder) # extract file to dir
zip_ref.close() # close file
def check_existing_directory(folder) : def check_existing_directory(folder) :
......
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
from setuptools import setup from setuptools import setup
setup(name="stereo", setup(name="geosentinel",
version="1.0", version="1.0",
description=("Library and utilities for Stereo cameras calibration"), description=("Library and utilities for Sentinel products"),
author="Adan Salazar", author="Adan Salazar",
author_email="asalazargaribay@gmail.com", author_email="asalazargaribay@gmail.com",
packages=["geosentinel"], packages=["geosentinel"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment