Mercurial > libervia-backend
comparison sat_frontends/quick_frontend/quick_utils.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from os.path import exists, splitext | 21 from os.path import exists, splitext |
22 from optparse import OptionParser | 22 from optparse import OptionParser |
23 | 23 |
24 | |
24 def getNewPath(path): | 25 def getNewPath(path): |
25 """ Check if path exists, and find a non existant path if needed """ | 26 """ Check if path exists, and find a non existant path if needed """ |
26 idx = 2 | 27 idx = 2 |
27 if not exists(path): | 28 if not exists(path): |
28 return path | 29 return path |
29 root, ext = splitext(path) | 30 root, ext = splitext(path) |
30 while True: | 31 while True: |
31 new_path = "%s_%d%s" % (root, idx, ext) | 32 new_path = "%s_%d%s" % (root, idx, ext) |
32 if not exists(new_path): | 33 if not exists(new_path): |
33 return new_path | 34 return new_path |
34 idx+=1 | 35 idx += 1 |
36 | |
35 | 37 |
36 def check_options(): | 38 def check_options(): |
37 """Check command line options""" | 39 """Check command line options""" |
38 usage = _(""" | 40 usage = _( |
41 """ | |
39 %prog [options] | 42 %prog [options] |
40 | 43 |
41 %prog --help for options list | 44 %prog --help for options list |
42 """) | 45 """ |
43 parser = OptionParser(usage=usage) # TODO: use argparse | 46 ) |
47 parser = OptionParser(usage=usage) # TODO: use argparse | |
44 | 48 |
45 parser.add_option("-p", "--profile", help=_("Select the profile to use")) | 49 parser.add_option("-p", "--profile", help=_("Select the profile to use")) |
46 | 50 |
47 (options, args) = parser.parse_args() | 51 (options, args) = parser.parse_args() |
48 if options.profile: | 52 if options.profile: |
49 options.profile = options.profile.decode('utf-8') | 53 options.profile = options.profile.decode("utf-8") |
50 return options | 54 return options |
51 |