Skip to content

Commit

Permalink
Merge pull request #41 from floriandeboissieu/patch-1
Browse files Browse the repository at this point in the history
python script support
  • Loading branch information
neilflood committed Jul 9, 2020
2 parents b73dded + 32a7483 commit be79c19
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions fmask/cmdline/sentinel2Stacked.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@
raise fmaskerrors.FmaskInstallationError(msg)


def getCmdargs():
def getCmdargs(argv=None):
"""
Get command line arguments
If argv is given, it should be a list of pairs of parameter and arguments like in command line.
See getCmdargs(['-h']) for details on available parameters.
Example: getCmdargs(['--safedir', '<.SAFE directory>', '-o', '<output file>'])
If argv is None or not given, command line sys.args are used, see argparse.parse_args.
"""
parser = argparse.ArgumentParser()
parser.add_argument("--safedir", help=("Name of .SAFE directory, as unzipped from " +
Expand Down Expand Up @@ -114,7 +120,7 @@ def getCmdargs():
params.add_argument("--parallaxtest", default=False, action="store_true",
help="Turn on the parallax displacement test from Frantz (2018) (default will not use this test)")

cmdargs = parser.parse_args()
cmdargs = parser.parse_args(argv)

# Do some sanity checks on what was given
safeDirGiven = (cmdargs.safedir is not None)
Expand Down Expand Up @@ -282,11 +288,17 @@ def findGranuleXml(granuleDir):
return xmlfile


def mainRoutine():
def mainRoutine(argv=None):
"""
Main routine that calls fmask
If argv is given, it should be a list of pairs of parameter and arguments like in command line.
See mainRoutine(['-h']) for details on available parameters.
Example: mainRoutine(['--safedir', '<.SAFE directory>', '-o', '<output file>'])
If argv is None or not given, command line sys.args are used, see argparse.parse_args.
"""
cmdargs = getCmdargs()
cmdargs = getCmdargs(argv)
tempStack = False
if cmdargs.safedir is not None or cmdargs.granuledir is not None:
tempStack = True
Expand Down

0 comments on commit be79c19

Please sign in to comment.