diff options
-rw-r--r-- | pylint/graph.py | 18 | ||||
-rw-r--r-- | pylint/lint.py | 14 | ||||
-rw-r--r-- | pylint/pyreverse/vcgutils.py | 6 | ||||
-rw-r--r-- | pylint/pyreverse/writer.py | 2 | ||||
-rw-r--r-- | pylint/reporters/text.py | 2 | ||||
-rw-r--r-- | pylint/utils.py | 23 |
6 files changed, 30 insertions, 35 deletions
diff --git a/pylint/graph.py b/pylint/graph.py index 9e4cab5bf..492f8fd06 100644 --- a/pylint/graph.py +++ b/pylint/graph.py @@ -36,7 +36,9 @@ def target_info_from_filename(filename): class DotBackend(object): """Dot File backend.""" def __init__(self, graphname, rankdir=None, size=None, ratio=None, - charset='utf-8', renderer='dot', additionnal_param={}): + charset='utf-8', renderer='dot', additional_param=None): + if additional_param is None: + additional_param = {} self.graphname = graphname self.renderer = renderer self.lines = [] @@ -52,7 +54,7 @@ class DotBackend(object): assert charset.lower() in ('utf-8', 'iso-8859-1', 'latin1'), \ 'unsupported charset %s' % charset self.emit('charset="%s"' % charset) - for param in additionnal_param.items(): + for param in additional_param.items(): self.emit('='.join(param)) def get_source(self): @@ -83,7 +85,7 @@ class DotBackend(object): else: dotfile = '%s.dot' % name if outputfile is not None: - storedir, basename, target = target_info_from_filename(outputfile) + storedir, _, target = target_info_from_filename(outputfile) if target != "dot": pdot, dot_sourcepath = tempfile.mkstemp(".dot", name) os.close(pdot) @@ -104,11 +106,13 @@ class DotBackend(object): else: use_shell = False if mapfile: - subprocess.call([self.renderer, '-Tcmapx', '-o', mapfile, '-T', target, dot_sourcepath, '-o', outputfile], + subprocess.call([self.renderer, '-Tcmapx', '-o', + mapfile, '-T', target, dot_sourcepath, + '-o', outputfile], shell=use_shell) else: - subprocess.call([self.renderer, '-T', target, - dot_sourcepath, '-o', outputfile], + subprocess.call([self.renderer, '-T', target, + dot_sourcepath, '-o', outputfile], shell=use_shell) os.unlink(dot_sourcepath) return outputfile @@ -123,7 +127,7 @@ class DotBackend(object): """ attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()] n_from, n_to = normalize_node_id(name1), normalize_node_id(name2) - self.emit('%s -> %s [%s];' % (n_from, n_to, ', '.join(sorted(attrs))) ) + self.emit('%s -> %s [%s];' % (n_from, n_to, ', '.join(sorted(attrs)))) def emit_node(self, name, **props): """emit a node with given properties. diff --git a/pylint/lint.py b/pylint/lint.py index 5760d0537..2ae33adc4 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -525,7 +525,7 @@ class PyLinter(configuration.OptionsManagerMixIn, warnings.warn('%s is deprecated, replace it by %s' % (optname, optname.split('-')[0]), DeprecationWarning) - value = utils.check_csv(None, optname, value) + value = utils._check_csv(value) if isinstance(value, (list, tuple)): for _id in value: meth(_id, ignore_unknown=True) @@ -665,7 +665,7 @@ class PyLinter(configuration.OptionsManagerMixIn, # found a "(dis|en)able-msg" pragma deprecated suppresssion self.add_message('deprecated-pragma', line=start[0], args=(opt, opt.replace('-msg', ''))) - for msgid in utils.splitstrip(value): + for msgid in utils._splitstrip(value): # Add the line where a control pragma was encountered. if opt in control_pragmas: self._pragma_lineno[msgid] = start[0] @@ -1279,11 +1279,11 @@ group are mutually exclusive.'), # run init hook, if present, before loading plugins if config_parser.has_option('MASTER', 'init-hook'): cb_init_hook('init-hook', - utils.unquote(config_parser.get('MASTER', - 'init-hook'))) + utils._unquote(config_parser.get('MASTER', + 'init-hook'))) # is there some additional plugins in the file configuration, in if config_parser.has_option('MASTER', 'load-plugins'): - plugins = utils.splitstrip( + plugins = utils._splitstrip( config_parser.get('MASTER', 'load-plugins')) linter.load_plugin_modules(plugins) # now we can load file config and command line, plugins (which can @@ -1341,7 +1341,7 @@ group are mutually exclusive.'), def cb_add_plugins(self, name, value): """callback for option preprocessing (i.e. before option parsing)""" - self._plugins.extend(utils.splitstrip(value)) + self._plugins.extend(utils._splitstrip(value)) def cb_error_mode(self, *args, **kwargs): """error mode: @@ -1366,7 +1366,7 @@ group are mutually exclusive.'), def cb_help_message(self, option, optname, value, parser): """optik callback for printing some help about a particular message""" - self.linter.msgs_store.help_message(utils.splitstrip(value)) + self.linter.msgs_store.help_message(utils._splitstrip(value)) sys.exit(0) def cb_full_documentation(self, option, optname, value, parser): diff --git a/pylint/pyreverse/vcgutils.py b/pylint/pyreverse/vcgutils.py index 256e649d2..b9ac7b41b 100644 --- a/pylint/pyreverse/vcgutils.py +++ b/pylint/pyreverse/vcgutils.py @@ -28,8 +28,6 @@ See vcg's documentation for explanation about the different values that maybe used for the functions parameters. """ -import string - ATTRS_VAL = { 'algos': ('dfs', 'tree', 'minbackward', 'left_to_right', 'right_to_left', @@ -161,7 +159,7 @@ class VCGPrinter: """ self._stream.write( '%s%sedge: {sourcename:"%s" targetname:"%s"' % ( - self._indent, edge_type, from_node, to_node)) + self._indent, edge_type, from_node, to_node)) self._write_attributes(EDGE_ATTRS, **args) self._stream.write('}\n') @@ -173,7 +171,7 @@ class VCGPrinter: """ for key, value in args.items(): try: - _type = attributes_dict[key] + _type = attributes_dict[key] except KeyError: raise Exception('''no such attribute %s possible attributes are %s''' % (key, attributes_dict.keys())) diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index 48cbe4ebe..4c7d69d62 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -105,7 +105,7 @@ class DotWriter(DiagramWriter): """initialize DotWriter and add options for layout. """ layout = dict(rankdir="BT") - self.printer = DotBackend(basename, additionnal_param=layout) + self.printer = DotBackend(basename, additional_param=layout) self.file_name = file_name def get_title(self, obj): diff --git a/pylint/reporters/text.py b/pylint/reporters/text.py index b66af3c50..22b060913 100644 --- a/pylint/reporters/text.py +++ b/pylint/reporters/text.py @@ -75,7 +75,7 @@ def _get_ansi_code(color=None, style=None): """ ansi_code = [] if style: - style_attrs = utils.splitstrip(style) + style_attrs = utils._splitstrip(style) for effect in style_attrs: ansi_code.append(ANSI_STYLES[effect]) if color: diff --git a/pylint/utils.py b/pylint/utils.py index c0829d86f..7d6e885fa 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -211,7 +211,7 @@ class MessageDefinition(object): desc += " It can't be emitted when using Python %s." % restr else: desc += " This message can't be emitted when using Python %s." % restr - desc = normalize_text(' '.join(desc.split()), indent=' ') + desc = _normalize_text(' '.join(desc.split()), indent=' ') if title != '%s': title = title.splitlines()[0] return ':%s: *%s*\n%s' % (msgid, title, desc) @@ -956,13 +956,13 @@ def deprecated_option(shortname=None, opt_type=None, help_msg=None): return option -def splitstrip(string, sep=','): +def _splitstrip(string, sep=','): """return a list of stripped string by splitting the string given as argument on `sep` (',' by default). Empty string are discarded. - >>> splitstrip('a, b, c , 4,,') + >>> _splitstrip('a, b, c , 4,,') ['a', 'b', 'c', '4'] - >>> splitstrip('a') + >>> _splitstrip('a') ['a'] >>> @@ -978,7 +978,7 @@ def splitstrip(string, sep=','): return [word.strip() for word in string.split(sep) if word.strip()] -def unquote(string): +def _unquote(string): """remove optional quotes (simple or double) from the string :type string: str or unicode @@ -996,20 +996,13 @@ def unquote(string): return string -def normalize_text(text, line_len=80, indent=''): +def _normalize_text(text, line_len=80, indent=''): """Wrap the text on the given line length.""" return '\n'.join(textwrap.wrap(text, width=line_len, initial_indent=indent, subsequent_indent=indent)) -def check_csv(option, opt, value): - """check a csv value by trying to split it - return the list of separated values - """ +def _check_csv(value): if isinstance(value, (list, tuple)): return value - try: - return splitstrip(value) - except ValueError: - raise OptionValueError( - "option %s: invalid csv value: %r" % (opt, value)) + return _splitstrip(value) |