Package Gnumed :: Package timelinelib :: Package config :: Module arguments
[frames] | no frames]

Source Code for Module Gnumed.timelinelib.config.arguments

 1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg 
 2  # 
 3  # This file is part of Timeline. 
 4  # 
 5  # Timeline is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  # 
10  # Timeline is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU General Public License 
16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>. 
17   
18   
19  from optparse import OptionParser 
20  import os.path 
21   
22  from timelinelib.meta.version import get_full_version 
23   
24  import wx 
25   
26   
27 -class ApplicationArguments(object):
28
29 - def __init__(self):
30 version_string = "%prog " + get_full_version() 31 self.option_parser = OptionParser( 32 usage="%prog [options] [filename]", 33 version=version_string) 34 self.option_parser.add_option( 35 "-c", "--config-file", dest="config_file_path", default=None, 36 help="Path to config file") 37 self.option_parser.add_option( 38 "--debug", 39 default=False, action="store_true", 40 help="Run Timeline with extra debug output")
41
42 - def parse_from(self, arguments):
43 (self.options, self.arguments) = self.option_parser.parse_args(arguments)
44
45 - def get_files(self):
46 return self.arguments
47
48 - def get_first_file(self):
49 try: 50 return self.arguments[0] 51 except IndexError: 52 return None
53
54 - def has_files(self):
55 return len(self.arguments) > 0
56
57 - def get_debug_flag(self):
58 return self.options.debug
59
60 - def get_config_file_path(self):
61 if self.options.config_file_path: 62 return self.options.config_file_path 63 else: 64 return os.path.join( 65 wx.StandardPaths.Get().GetUserConfigDir(), 66 ".thetimelineproj.cfg")
67