comparison libervia/frontends/quick_frontend/quick_utils.py @ 4074:26b7ed2817da

refactoring: rename `sat_frontends` to `libervia.frontends`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 14:12:38 +0200
parents sat_frontends/quick_frontend/quick_utils.py@4b842c1fb686
children 0d7bb4df2343
comparison
equal deleted inserted replaced
4073:7c5654c54fed 4074:26b7ed2817da
1 #!/usr/bin/env python3
2
3
4 # Primitivus: a SAT frontend
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 from libervia.backend.core.i18n import _
21 from os.path import exists, splitext
22 from optparse import OptionParser
23
24
25 def get_new_path(path):
26 """ Check if path exists, and find a non existant path if needed """
27 idx = 2
28 if not exists(path):
29 return path
30 root, ext = splitext(path)
31 while True:
32 new_path = "%s_%d%s" % (root, idx, ext)
33 if not exists(new_path):
34 return new_path
35 idx += 1
36
37
38 def check_options():
39 """Check command line options"""
40 usage = _(
41 """
42 %prog [options]
43
44 %prog --help for options list
45 """
46 )
47 parser = OptionParser(usage=usage) # TODO: use argparse
48
49 parser.add_option("-p", "--profile", help=_("Select the profile to use"))
50
51 (options, args) = parser.parse_args()
52 if options.profile:
53 options.profile = options.profile
54 return options