Commit 969e95fe authored by Laurent Peuch's avatar Laurent Peuch
Browse files

chore(format-source): pyupgrade the code

parent 9d9635c03b61
{"pattern": "logilab/common/cache.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/changelog.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/clcommands.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/compat.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/configuration.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/daemon.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/date.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/debugger.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/decorators.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/deprecation.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/fileutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/graph.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/interface.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/logging_ext.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/modutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/optik_ext.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/optparser.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/proc.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/pytest.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/registry.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/shellutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/sphinx_ext.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/sphinxutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/table.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/tasksqueue.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/testlib.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/textutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/tree.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/types.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/umessage.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/ureports/__init__.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/ureports/docbook_writer.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/ureports/html_writer.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/ureports/nodes.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/ureports/text_writer.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/urllib2ext.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/vcgutils.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/visitor.py", "tool": "pyupgrade"}
{"pattern": "logilab/common/xmlutils.py", "tool": "pyupgrade"}
{"pattern": "setup.py", "tool": "pyupgrade"}
{"pattern": "test/data/__pkginfo__.py", "tool": "pyupgrade"}
{"pattern": "test/data/deprecation.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/__init__.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/module.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/module2.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/noendingnewline.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/nonregr.py", "tool": "pyupgrade"}
{"pattern": "test/data/find_test/sub/momo.py", "tool": "pyupgrade"}
{"pattern": "test/data/lmfp/__init__.py", "tool": "pyupgrade"}
{"pattern": "test/data/lmfp/foo.py", "tool": "pyupgrade"}
{"pattern": "test/data/module.py", "tool": "pyupgrade"}
{"pattern": "test/data/module2.py", "tool": "pyupgrade"}
{"pattern": "test/data/noendingnewline.py", "tool": "pyupgrade"}
{"pattern": "test/data/nonregr.py", "tool": "pyupgrade"}
{"pattern": "test/data/regobjects.py", "tool": "pyupgrade"}
{"pattern": "test/data/regobjects2.py", "tool": "pyupgrade"}
{"pattern": "test/data/sub/momo.py", "tool": "pyupgrade"}
{"pattern": "test/test_cache.py", "tool": "pyupgrade"}
{"pattern": "test/test_changelog.py", "tool": "pyupgrade"}
{"pattern": "test/test_configuration.py", "tool": "pyupgrade"}
{"pattern": "test/test_date.py", "tool": "pyupgrade"}
{"pattern": "test/test_decorators.py", "tool": "pyupgrade"}
{"pattern": "test/test_deprecation.py", "tool": "pyupgrade"}
{"pattern": "test/test_fileutils.py", "tool": "pyupgrade"}
{"pattern": "test/test_graph.py", "tool": "pyupgrade"}
{"pattern": "test/test_interface.py", "tool": "pyupgrade"}
{"pattern": "test/test_modutils.py", "tool": "pyupgrade"}
{"pattern": "test/test_pytest.py", "tool": "pyupgrade"}
{"pattern": "test/test_registry.py", "tool": "pyupgrade"}
{"pattern": "test/test_shellutils.py", "tool": "pyupgrade"}
{"pattern": "test/test_table.py", "tool": "pyupgrade"}
{"pattern": "test/test_taskqueue.py", "tool": "pyupgrade"}
{"pattern": "test/test_testlib.py", "tool": "pyupgrade"}
{"pattern": "test/test_textutils.py", "tool": "pyupgrade"}
{"pattern": "test/test_tree.py", "tool": "pyupgrade"}
{"pattern": "test/test_umessage.py", "tool": "pyupgrade"}
{"pattern": "test/test_ureports_html.py", "tool": "pyupgrade"}
{"pattern": "test/test_ureports_text.py", "tool": "pyupgrade"}
{"pattern": "test/test_xmlutils.py", "tool": "pyupgrade"}
{"pattern": "test/utils.py", "tool": "pyupgrade"}
......@@ -15,6 +15,7 @@ recursive-include doc/html *
include docs/*
include __pkginfo__.py
prune debian
exclude .hg-format-source
prune docs/_build
exclude .hgrc
exclude .gitlab-ci.yml
......
......@@ -22,7 +22,6 @@ e.g called as "tool command [options] args..." where <options> and <args> are
command'specific
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
......@@ -107,7 +107,6 @@ Quick start: simplest usage
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
......@@ -16,7 +16,6 @@
# You should have received a copy of the GNU Lesser General Public License along
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
"""Date manipulation helper functions."""
from __future__ import division
__docformat__ = "restructuredtext en"
......
......@@ -27,7 +27,6 @@
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......@@ -70,9 +69,9 @@ else:
for index, line in enumerate(output.getvalue().splitlines()):
lineno = index + start_lineno
if lineno == curlineno:
annotated.append("%4s\t->\t%s" % (lineno, line))
annotated.append(f"{lineno:>4}\t->\t{line}")
else:
annotated.append("%4s\t\t%s" % (lineno, line))
annotated.append(f"{lineno:>4}\t\t{line}")
return "\n".join(annotated)
def colorize_source(source):
......@@ -119,7 +118,7 @@ class Debugger(Pdb):
# XXX try..except shouldn't be necessary
# read_history_file() can accept None
readline.read_history_file(self._histfile)
except IOError:
except OSError:
pass
def start(self):
......@@ -173,7 +172,7 @@ class Debugger(Pdb):
n = len(attr)
for word in words:
if word[:n] == attr and word != "__builtins__":
matches.append("%s.%s" % (expr, word))
matches.append(f"{expr}.{word}")
return matches
def get_class_members(self, klass):
......@@ -196,7 +195,7 @@ class Debugger(Pdb):
print(colorize("".join(source), start_lineno, self.curframe.f_lineno))
except KeyboardInterrupt:
pass
except IOError:
except OSError:
Pdb.do_list(self, arg)
else:
Pdb.do_list(self, arg)
......@@ -207,7 +206,7 @@ class Debugger(Pdb):
"""opens source file corresponding to the current stack level"""
filename = self.curframe.f_code.co_filename
lineno = self.curframe.f_lineno
cmd = "emacsclient --no-wait +%s %s" % (lineno, filename)
cmd = f"emacsclient --no-wait +{lineno} {filename}"
os.system(cmd)
do_o = do_open
......
......@@ -17,7 +17,6 @@
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
""" A few useful function/method decorators. """
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
......@@ -24,7 +24,6 @@ write_open_mode, ensure_fs_mode, export
:sort: path manipulation, file manipulation
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
......@@ -152,7 +152,7 @@ class DotBackend:
)
except OSError as e:
if e.errno == errno.ENOENT:
e.strerror = "File not found: {0}".format(self.renderer)
e.strerror = "File not found: {}".format(self.renderer)
raise
os.unlink(dot_sourcepath)
return outputfile
......
# -*- coding: utf-8 -*-
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......@@ -127,7 +126,7 @@ def get_handler(debug=False, syslog=False, logfile=None, rotation_parameters=Non
from logging.handlers import TimedRotatingFileHandler
handler = TimedRotatingFileHandler(logfile, **rotation_parameters)
except IOError:
except OSError:
handler = logging.StreamHandler()
return handler
......
# -*- coding: utf-8 -*-
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......
......@@ -46,7 +46,6 @@ It also defines three new types for optik/optparse command line parser :
argument of this type will be converted to a float value in bytes
according to byte units (b, kb, mb, gb, tb)
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
# -*- coding: utf-8 -*-
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......@@ -29,7 +28,6 @@ Example:
With mymod.build that defines two functions run and add_options
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......@@ -64,7 +62,7 @@ class OptionParser(optparse.OptionParser):
optparse.OptionParser.print_help(self)
print("\ncommands:")
for cmdname, (_, help) in self._commands.items():
print("% 10s - %s" % (cmdname, help))
print(f"{cmdname: 10} - {help}")
def parse_command(self, args):
if len(args) == 0:
......@@ -80,7 +78,7 @@ class OptionParser(optparse.OptionParser):
self.print_version()
sys.exit(0)
self.error("unknown command")
self.prog = "%s %s" % (self.prog, cmd)
self.prog = f"{self.prog} {cmd}"
mod_or_f, help = self._commands[cmd]
# optparse inserts self.description between usage and options help
self.description = help
......
......@@ -72,7 +72,7 @@ class ProcInfo(Node):
"""return the memory usage of the process in Ko"""
try:
return int(self.status()[VSIZE])
except IOError:
except OSError:
return 0
def lineage_memory_usage(self):
......
......@@ -93,7 +93,6 @@ you can filter the function with a simple python expression
* ``titi`` match ``rouge and not carre``
"""
from __future__ import print_function
import os
import re
......
......@@ -76,7 +76,6 @@ Exceptions
.. autoclass:: NoSelectableObject
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......@@ -469,7 +468,7 @@ class RegistrableInstance(RegistrableObject):
obj = super(RegistrableInstance, cls).__new__(cls)
if module is None:
warn(
"instantiate {0} with " "__module__=__name__".format(cls.__name__),
"instantiate {} with " "__module__=__name__".format(cls.__name__),
DeprecationWarning,
)
# XXX subclass must no override __new__
......
......@@ -19,7 +19,6 @@
scripts.
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
......
......@@ -17,7 +17,6 @@
# with logilab-common. If not, see <http://www.gnu.org/licenses/>.
"""Table management module."""
from __future__ import print_function
from types import CodeType
from typing import Any, List, Optional, Tuple, Union, Dict, Iterator
from _io import StringIO
......
# -*- coding: utf-8 -*-
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
......@@ -37,7 +36,6 @@ If no non-option arguments are present, prefixes used are 'test',
"""
from __future__ import print_function
__docformat__ = "restructuredtext en"
# modified copy of some functions from test/regrtest.py from PyXml
......
......@@ -48,7 +48,7 @@ class DocbookWriter(HTMLWriter):
else:
tag = "section"
self.section += 1
self.writeln(self._indent("<%s%s>" % (tag, self.handle_attrs(layout))))
self.writeln(self._indent("<{}{}>".format(tag, self.handle_attrs(layout))))
self.format_children(layout)
self.writeln(self._indent("</%s>" % tag))
self.section -= 1
......@@ -62,7 +62,7 @@ class DocbookWriter(HTMLWriter):
def visit_table(self, layout):
"""display a table as html"""
self.writeln(
self._indent(" <table%s><title>%s</title>" % (self.handle_attrs(layout), layout.title))
self._indent(" <table{}><title>{}</title>".format(self.handle_attrs(layout), layout.title))
)
self.writeln(self._indent(' <tgroup cols="%s">' % layout.cols))
for i in range(layout.cols):
......@@ -124,7 +124,7 @@ class DocbookWriter(HTMLWriter):
def visit_link(self, layout):
"""display links (using <ulink>)"""
self.write(
'<ulink url="%s"%s>%s</ulink>' % (layout.url, self.handle_attrs(layout), layout.label)
'<ulink url="{}"{}>{}</ulink>'.format(layout.url, self.handle_attrs(layout), layout.label)
)
def visit_verbatimtext(self, layout):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment