pep8 fixes

fixing typos


svn: r12934
This commit is contained in:
Raphael Ackermann
2009-08-09 17:09:32 +00:00
parent ce53145dfe
commit 65f72560d1
32 changed files with 153 additions and 149 deletions

View File

@@ -56,9 +56,9 @@ from ReportBase import CATEGORY_BOOK, CATEGORY_CODE, cl_report
#-------------------------------------------------------------------------
class ArgHandler(object):
"""
This class is responsible for the non GUI handling of commands
This class is responsible for the non GUI handling of commands.
The handler is passed a parser object, sanitizes it, and can execute the
actions requested working on a DbState
actions requested working on a DbState.
"""
def __init__(self, dbstate, parser, sessionmanager,
@@ -89,7 +89,7 @@ class ArgHandler(object):
def __error(self, string):
"""
Output an error. Uses errorfunc if given, otherwise a simple print
Output an error. Uses errorfunc if given, otherwise a simple print.
"""
if self.errorfunc:
self.errorfunc(string)
@@ -101,12 +101,12 @@ class ArgHandler(object):
#-------------------------------------------------------------------------
def sanitize_args(self, importlist, exportlist):
"""
check the lists with open, exports, imports, and actions options.
Check the lists with open, exports, imports, and actions options.
"""
for (value, format) in importlist:
self.__handle_import_option(value, format)
for (value, format) in exportlist:
self.__handle_export_option(value, format)
for (value, family_tree_format) in importlist:
self.__handle_import_option(value, family_tree_format)
for (value, family_tree_format) in exportlist:
self.__handle_export_option(value, family_tree_format)
def __handle_open_option(self, value):
"""
@@ -129,10 +129,10 @@ class ArgHandler(object):
"import into a family tree instead.") % value)
sys.exit(0)
def __handle_import_option(self, value, format):
def __handle_import_option(self, value, family_tree_format):
"""
Handle the "-i" or "--import" option.
Only Files supported by a plugin can be imported, so not Family Trees
Only Files supported by a plugin can be imported, so not Family Trees.
"""
fname = value
fullpath = os.path.abspath(os.path.expanduser(fname))
@@ -140,31 +140,31 @@ class ArgHandler(object):
self.__error(_('Error: Import file %s not found.') % fname)
sys.exit(0)
if format is None:
if family_tree_format is None:
# Guess the file format based on the file extension.
# This will get the lower case extension without a period,
# or an empty string.
format = os.path.splitext(fname)[-1][1:].lower()
family_tree_format = os.path.splitext(fname)[-1][1:].lower()
pmgr = PluginManager.get_instance()
plugin_found = False
for plugin in pmgr.get_import_plugins():
if format == plugin.get_extension():
if family_tree_format == plugin.get_extension():
plugin_found = True
if plugin_found:
self.imports.append((fname, format))
self.imports.append((fname, family_tree_format))
else:
self.__error(_('Error: Unrecognized type: "%(format)s" for '
'import file: %(filename)s') \
% {'format' : format,
% {'format' : family_tree_format,
'filename' : fname})
sys.exit(0)
def __handle_export_option(self, value, format):
def __handle_export_option(self, value, family_tree_format):
"""
Handle the "-e" or "--export" option.
Note: this can only happen in the CLI version
Note: this can only happen in the CLI version.
"""
if self.gui:
return
@@ -183,20 +183,20 @@ class ArgHandler(object):
else:
sys.exit(0)
if format is None:
if family_tree_format is None:
# Guess the file format based on the file extension.
# This will get the lower case extension without a period,
# or an empty string.
format = os.path.splitext(fname)[-1][1:].lower()
family_tree_format = os.path.splitext(fname)[-1][1:].lower()
pmgr = PluginManager.get_instance()
plugin_found = False
for plugin in pmgr.get_export_plugins():
if format == plugin.get_extension():
if family_tree_format == plugin.get_extension():
plugin_found = True
if plugin_found:
self.exports.append((fullpath, format))
self.exports.append((fullpath, family_tree_format))
else:
self.__error(_("ERROR: Unrecognized format for export file %s")
% fname)
@@ -231,7 +231,7 @@ class ArgHandler(object):
def handle_args_gui(self):
"""
method to handle the arguments that can be given for a GUI session.
Returns the filename of the family tree that should be openend if
Returns the filename of the family tree that should be opened if
user just passed a famtree or a filename
1/no options: a family tree can be given, if so, this name is tested
and returned. If a filename, it is imported in a new db
@@ -399,13 +399,13 @@ class ArgHandler(object):
# Import handler
#
#-------------------------------------------------------------------------
def cl_import(self, filename, format):
def cl_import(self, filename, family_tree_format):
"""
Command-line import routine. Try to import filename using the format.
Command-line import routine. Try to import filename using the family_tree_format.
"""
pmgr = PluginManager.get_instance()
for plugin in pmgr.get_import_plugins():
if format == plugin.get_extension():
if family_tree_format == plugin.get_extension():
import_function = plugin.get_import_function()
import_function(self.dbstate.db, filename, None)
@@ -420,14 +420,14 @@ class ArgHandler(object):
# Export handler
#
#-------------------------------------------------------------------------
def cl_export(self, filename, format):
def cl_export(self, filename, family_tree_format):
"""
Command-line export routine.
Try to write into filename using the format.
Try to write into filename using the family_tree_format.
"""
pmgr = PluginManager.get_instance()
for plugin in pmgr.get_export_plugins():
if format == plugin.get_extension():
if family_tree_format == plugin.get_extension():
export_function = plugin.get_export_function()
export_function(self.dbstate.db, filename)

View File

@@ -59,7 +59,7 @@ Application options
-O, --open=FAMILY_TREE Open family tree
-i, --import=FILENAME Import file
-e, --export=FILENAME Export file
-f, --format=FORMAT Specify format
-f, --format=FORMAT Specify family tree format
-a, --action=ACTION Specify action
-p, --options=OPTIONS_STRING Specify options
-d, --debug=LOGGER_NAME Enable debug logs
@@ -80,14 +80,14 @@ class ArgParser(object):
Possible:
1/ FAMTREE : Just the family tree (name or database dir)
2/ -O, --open=FAMTREE, Open of a family tree
3/ -i, --import=FILE, Import of any format understood by an importer, optionally
provide- f to indicate format
4/ -e, --export=FILE, export a family tree in required format, optionally provide
-f to indicate format
3/ -i, --import=FILE, Import a family tree of any format understood by an
importer, optionally provide- f to indicate format
4/ -e, --export=FILE, export a family tree in required format, optionally
provide -f to indicate format
5/ -f, --format=FORMAT : format after a -i or -e option
5/ -a, --action: An action (possible: 'check', 'summary', 'report',
6/ -a, --action: An action (possible: 'check', 'summary', 'report',
'tool')
6/ -u, --force-unlock: A locked database can be unlocked by giving this
7/ -u, --force-unlock: A locked database can be unlocked by giving this
argument when opening it
If the filename (no flags) is specified, the interactive session is
@@ -108,7 +108,7 @@ class ArgParser(object):
def __init__(self, args):
"""
pass the command line arguments on creation
Pass the command line arguments on creation.
"""
self.args = args
@@ -137,14 +137,15 @@ class ArgParser(object):
Possible:
1/ Just the family tree (name or database dir)
2/ -O, Open of a family tree
3/ -i, Import of any format understood by an importer, optionally
provide-f to indicate format
4/ -e, export a family tree in required format, optionally provide
2/ -O, --open: Open of a family tree
3/ -i, --import: Import a family tree of any format understood by an importer,
optionally provide-f to indicate format
4/ -e, --export: export a family tree in required format, optionally provide
-f to indicate format
5/ -a, --action: An action (possible: 'check', 'summary', 'report',
5/ -f, --format=FORMAT : format after a -i or -e option
6/ -a, --action: An action (possible: 'check', 'summary', 'report',
'tool')
6/ -u, --force-unlock: A locked database can be unlocked by giving this
7/ -u, --force-unlock: A locked database can be unlocked by giving this
argument when opening it
"""
@@ -179,17 +180,17 @@ class ArgParser(object):
if option in ( '-O', '--open'):
self.open = value
elif option in ( '-i', '--import'):
format = None
family_tree_format = None
if opt_ix < len(options) - 1 \
and options[opt_ix + 1][0] in ( '-f', '--format'):
format = options[opt_ix + 1][1]
self.imports.append((value, format))
family_tree_format = options[opt_ix + 1][1]
self.imports.append((value, family_tree_format))
elif option in ( '-e', '--export' ):
format = None
family_tree_format = None
if opt_ix < len(options) - 1 \
and options[opt_ix + 1][0] in ( '-f', '--format'):
format = options[opt_ix + 1][1]
self.exports.append((value, format))
family_tree_format = options[opt_ix + 1][1]
self.exports.append((value, family_tree_format))
elif option in ( '-a', '--action' ):
action = value
if action not in ( 'check', 'summary', 'report', 'tool' ):
@@ -258,7 +259,7 @@ class ArgParser(object):
def print_help(self):
"""
If the user gives the --help or -h option, print the output to terminal
If the user gives the --help or -h option, print the output to terminal.
"""
if self.help:
print _HELP