From 82ac7f1348b42eb559e80689dba3605e6c5bc402 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Sun, 20 Oct 2024 21:46:35 +0100 Subject: [PATCH] format with ruff format --- src/exabgp/application/cli.py | 5 +- src/exabgp/application/decode.py | 2 +- src/exabgp/application/healthcheck.py | 202 +++++++++--------- src/exabgp/application/netlink.py | 2 +- src/exabgp/application/pipe.py | 2 +- src/exabgp/application/server.py | 11 +- src/exabgp/application/validate.py | 1 - src/exabgp/application/version.py | 1 + src/exabgp/bgp/message/keepalive.py | 2 +- src/exabgp/bgp/message/nop.py | 2 +- src/exabgp/bgp/message/notification.py | 110 +++++----- src/exabgp/bgp/message/open/__init__.py | 4 +- .../bgp/message/open/capability/addpath.py | 2 +- .../message/open/capability/capabilities.py | 12 +- .../bgp/message/open/capability/graceful.py | 4 +- .../bgp/message/open/capability/hostname.py | 1 - src/exabgp/bgp/message/open/capability/mp.py | 2 +- .../bgp/message/open/capability/nexthop.py | 4 +- .../bgp/message/open/capability/refresh.py | 2 +- .../bgp/message/open/capability/software.py | 3 +- src/exabgp/bgp/message/refresh.py | 2 +- src/exabgp/bgp/message/unknown.py | 2 +- src/exabgp/bgp/message/update/__init__.py | 2 +- .../bgp/message/update/attribute/aspath.py | 30 +-- .../bgp/message/update/attribute/attribute.py | 12 +- .../message/update/attribute/attributes.py | 2 +- .../update/attribute/bgpls/link/igpmetric.py | 2 +- .../update/attribute/bgpls/link/linkname.py | 2 +- .../update/attribute/bgpls/link/opaque.py | 2 +- .../update/attribute/bgpls/link/rterid.py | 2 +- .../update/attribute/bgpls/link/sradj.py | 2 +- .../update/attribute/bgpls/link/sradjlan.py | 2 +- .../update/attribute/bgpls/link/srlg.py | 2 +- .../update/attribute/bgpls/link/temetric.py | 1 + .../update/attribute/bgpls/linkstate.py | 8 +- .../update/attribute/bgpls/node/isisarea.py | 4 +- .../update/attribute/bgpls/node/lterid.py | 6 +- .../update/attribute/bgpls/node/nodename.py | 6 +- .../update/attribute/bgpls/node/opaque.py | 6 +- .../update/attribute/bgpls/node/sralgo.py | 4 +- .../update/attribute/bgpls/node/srcap.py | 4 +- .../attribute/bgpls/prefix/igpextags.py | 2 +- .../update/attribute/bgpls/prefix/igptags.py | 2 +- .../update/attribute/bgpls/prefix/opaque.py | 2 +- .../update/attribute/bgpls/prefix/ospfaddr.py | 2 +- .../attribute/bgpls/prefix/prefixmetric.py | 2 +- .../update/attribute/bgpls/prefix/srprefix.py | 2 +- .../update/attribute/bgpls/prefix/srrid.py | 2 +- .../attribute/community/extended/bandwidth.py | 4 +- .../attribute/community/extended/chso.py | 6 +- .../attribute/community/extended/community.py | 2 +- .../community/extended/encapsulation.py | 22 +- .../community/extended/flowspec_scope.py | 4 +- .../attribute/community/extended/l2info.py | 4 +- .../community/extended/mac_mobility.py | 4 +- .../attribute/community/extended/mup.py | 2 +- .../attribute/community/extended/origin.py | 6 +- .../update/attribute/community/extended/rt.py | 6 +- .../attribute/community/extended/rt_record.py | 2 +- .../attribute/community/extended/traffic.py | 32 +-- .../community/initial/communities.py | 6 +- .../attribute/community/initial/community.py | 4 +- .../attribute/community/large/community.py | 4 +- .../bgp/message/update/attribute/mprnlri.py | 4 +- .../bgp/message/update/attribute/mpurnlri.py | 2 +- .../bgp/message/update/attribute/pmsi.py | 6 +- .../message/update/attribute/sr/labelindex.py | 5 +- .../message/update/attribute/sr/prefixsid.py | 8 +- .../bgp/message/update/attribute/sr/srgb.py | 5 +- .../update/attribute/sr/srv6/generic.py | 8 +- .../update/attribute/sr/srv6/l2service.py | 11 +- .../update/attribute/sr/srv6/l3service.py | 11 +- .../attribute/sr/srv6/sidinformation.py | 31 +-- .../update/attribute/sr/srv6/sidstructure.py | 31 +-- src/exabgp/bgp/message/update/eor.py | 2 +- .../bgp/message/update/nlri/bgpls/link.py | 10 +- .../bgp/message/update/nlri/bgpls/nlri.py | 4 +- .../bgp/message/update/nlri/bgpls/node.py | 6 +- .../bgp/message/update/nlri/bgpls/prefixv4.py | 6 +- .../bgp/message/update/nlri/bgpls/prefixv6.py | 6 +- .../message/update/nlri/bgpls/tlvs/ipreach.py | 10 +- .../message/update/nlri/bgpls/tlvs/node.py | 2 +- src/exabgp/bgp/message/update/nlri/cidr.py | 2 +- .../message/update/nlri/evpn/ethernetad.py | 6 +- .../bgp/message/update/nlri/evpn/mac.py | 18 +- .../bgp/message/update/nlri/evpn/multicast.py | 8 +- .../bgp/message/update/nlri/evpn/nlri.py | 6 +- .../bgp/message/update/nlri/evpn/prefix.py | 12 +- .../bgp/message/update/nlri/evpn/segment.py | 8 +- src/exabgp/bgp/message/update/nlri/flow.py | 20 +- src/exabgp/bgp/message/update/nlri/inet.py | 8 +- src/exabgp/bgp/message/update/nlri/ipvpn.py | 2 +- src/exabgp/bgp/message/update/nlri/label.py | 4 +- src/exabgp/bgp/message/update/nlri/mup/dsd.py | 8 +- src/exabgp/bgp/message/update/nlri/mup/isd.py | 6 +- .../bgp/message/update/nlri/mup/nlri.py | 13 +- .../bgp/message/update/nlri/mup/t1st.py | 14 +- .../bgp/message/update/nlri/mup/t2st.py | 14 +- .../bgp/message/update/nlri/mvpn/nlri.py | 6 +- .../message/update/nlri/mvpn/sharedjoin.py | 12 +- .../bgp/message/update/nlri/mvpn/sourcead.py | 10 +- .../message/update/nlri/mvpn/sourcejoin.py | 12 +- src/exabgp/bgp/message/update/nlri/nlri.py | 2 +- .../bgp/message/update/nlri/qualifier/esi.py | 6 +- .../bgp/message/update/nlri/qualifier/etag.py | 4 +- .../message/update/nlri/qualifier/labels.py | 8 +- .../bgp/message/update/nlri/qualifier/mac.py | 2 +- src/exabgp/bgp/message/update/nlri/rtc.py | 8 +- src/exabgp/bgp/message/update/nlri/vpls.py | 2 +- src/exabgp/bgp/neighbor.py | 36 ++-- src/exabgp/cli/main.py | 10 +- src/exabgp/cli/test.py | 1 + src/exabgp/conf/yang/code.py | 4 +- src/exabgp/conf/yang/generate.py | 2 +- src/exabgp/conf/yang/model.py | 2 +- src/exabgp/configuration/announce/mup.py | 10 +- src/exabgp/configuration/announce/mvpn.py | 2 +- src/exabgp/configuration/check.py | 10 +- src/exabgp/configuration/configuration.py | 40 ++-- src/exabgp/configuration/flow/parser.py | 11 +- src/exabgp/configuration/neighbor/__init__.py | 2 +- src/exabgp/configuration/neighbor/api.py | 4 +- src/exabgp/configuration/neighbor/parser.py | 1 + src/exabgp/configuration/static/mpls.py | 100 ++++----- src/exabgp/configuration/static/parser.py | 2 +- src/exabgp/data/check.py | 2 +- src/exabgp/debug/report.py | 6 +- src/exabgp/environment/environment.py | 2 +- src/exabgp/logger/history.py | 2 +- src/exabgp/netlink/attributes.py | 2 +- src/exabgp/netlink/firewall.py | 4 +- src/exabgp/netlink/netlink.py | 6 +- src/exabgp/netlink/old.py | 12 +- src/exabgp/netlink/tc.py | 2 +- src/exabgp/protocol/family.py | 4 +- src/exabgp/protocol/ip/__init__.py | 2 +- src/exabgp/reactor/api/command/announce.py | 14 +- src/exabgp/reactor/api/command/rib.py | 33 ++- src/exabgp/reactor/api/response/json.py | 33 +-- src/exabgp/reactor/api/transcoder.py | 10 +- src/exabgp/reactor/daemon.py | 16 +- src/exabgp/reactor/loop.py | 8 +- src/exabgp/reactor/network/connection.py | 4 +- src/exabgp/reactor/network/tcp.py | 4 +- src/exabgp/reactor/peer.py | 18 +- src/exabgp/reactor/protocol.py | 2 +- src/exabgp/rib/change.py | 2 +- src/exabgp/rib/outgoing.py | 1 + src/exabgp/util/dns.py | 4 +- src/exabgp/util/enumeration.py | 2 +- src/exabgp/vendoring/gcdump.py | 22 +- src/exabgp/vendoring/lsprofcalltree.py | 34 +-- src/exabgp/vendoring/objgraph.py | 44 ++-- src/exabgp/vendoring/profiler.py | 40 ++-- src/exabgp/version.py | 11 +- 155 files changed, 803 insertions(+), 768 deletions(-) diff --git a/src/exabgp/application/cli.py b/src/exabgp/application/cli.py index 9131ce34d..5590196f9 100644 --- a/src/exabgp/application/cli.py +++ b/src/exabgp/application/cli.py @@ -3,7 +3,6 @@ """exabgp command line interface""" - import os import sys import time @@ -126,7 +125,7 @@ def cmdline(cmdarg): pipes = named_pipe(ROOT, pipename) if len(pipes) != 1: - sys.stdout.write('could not find ExaBGP\'s named pipes (%s.in and %s.out) for the cli\n' % (pipename, pipename)) + sys.stdout.write("could not find ExaBGP's named pipes (%s.in and %s.out) for the cli\n" % (pipename, pipename)) sys.stdout.write('we scanned the following folders (the number is your PID):\n - ') sys.stdout.write('\n - '.join(pipes)) sys.stdout.flush() @@ -314,7 +313,7 @@ def cmdline(cmdarg): break if string == Answer.text_error or string == Answer.json_error: done = True - sys.stderr.write('ExaBGP returns an error (see ExaBGP\'s logs for more information)\n') + sys.stderr.write("ExaBGP returns an error (see ExaBGP's logs for more information)\n") sys.stderr.write('use help for a list of available commands\n') sys.stderr.flush() break diff --git a/src/exabgp/application/decode.py b/src/exabgp/application/decode.py index da323c46d..ee43cd5e8 100644 --- a/src/exabgp/application/decode.py +++ b/src/exabgp/application/decode.py @@ -70,7 +70,7 @@ def cmdline(cmdarg): sys.stdout.write(' 001E:02:0000:0007:900F:0003:0001:01\n') sys.stdout.write(' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF001E0200000007900F0003000101\n') sys.stdout.write(' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF:001E:02:0000:0007:900F:0003:0001:01\n') - sys.stdout.write(" FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 001E02 00000007900F0003000101\n") + sys.stdout.write(' FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 001E02 00000007900F0003000101\n') sys.stdout.flush() sys.exit(1) diff --git a/src/exabgp/application/healthcheck.py b/src/exabgp/application/healthcheck.py index cba894fd4..7559b2a0e 100644 --- a/src/exabgp/application/healthcheck.py +++ b/src/exabgp/application/healthcheck.py @@ -55,12 +55,12 @@ from ipaddress import ip_address -logger = logging.getLogger("healthcheck") +logger = logging.getLogger('healthcheck') def enum(*sequential): """Create a simple enumeration.""" - return type(str("Enum"), (), dict(zip(sequential, sequential))) + return type(str('Enum'), (), dict(zip(sequential, sequential))) def setargs(parser): @@ -135,9 +135,9 @@ def parse(): # build an equivalent command line. args = sum( [ - "--{0}".format(line.strip()).split("=", 1) + '--{0}'.format(line.strip()).split('=', 1) for line in options.config.readlines() - if not line.strip().startswith("#") and line.strip() + if not line.strip().startswith('#') and line.strip() ], [], ) @@ -152,65 +152,65 @@ def setup_logging(debug, silent, name, syslog_facility, syslog): def syslog_address(): """Return a sensible syslog address""" - if sys.platform == "darwin": - return "/var/run/syslog" - if sys.platform.startswith("freebsd"): - return "/var/run/log" - if sys.platform.startswith("netbsd"): - return "/var/run/log" - if sys.platform.startswith("linux"): - return "/dev/log" - raise EnvironmentError("Unable to guess syslog address for your " "platform, try to disable syslog") + if sys.platform == 'darwin': + return '/var/run/syslog' + if sys.platform.startswith('freebsd'): + return '/var/run/log' + if sys.platform.startswith('netbsd'): + return '/var/run/log' + if sys.platform.startswith('linux'): + return '/dev/log' + raise EnvironmentError('Unable to guess syslog address for your ' 'platform, try to disable syslog') logger.setLevel(debug and logging.DEBUG or logging.INFO) enable_syslog = syslog and not debug # To syslog if enable_syslog: - facility = getattr(logging.handlers.SysLogHandler, "LOG_{0}".format(syslog_facility.upper())) + facility = getattr(logging.handlers.SysLogHandler, 'LOG_{0}'.format(syslog_facility.upper())) sh = logging.handlers.SysLogHandler(address=str(syslog_address()), facility=facility) if name: - healthcheck_name = "healthcheck-{0}".format(name) + healthcheck_name = 'healthcheck-{0}'.format(name) else: - healthcheck_name = "healthcheck" - sh.setFormatter(logging.Formatter("{0}[{1}]: %(message)s".format(healthcheck_name, os.getpid()))) + healthcheck_name = 'healthcheck' + sh.setFormatter(logging.Formatter('{0}[{1}]: %(message)s'.format(healthcheck_name, os.getpid()))) logger.addHandler(sh) # To console if not silent: ch = logging.StreamHandler() - ch.setFormatter(logging.Formatter("%(levelname)s[%(name)s] %(message)s")) + ch.setFormatter(logging.Formatter('%(levelname)s[%(name)s] %(message)s')) logger.addHandler(ch) def loopback_ips(label, label_only, label_exact_match): """Retrieve loopback IP addresses""" - logger.debug("Retrieve loopback IP addresses") + logger.debug('Retrieve loopback IP addresses') addresses = [] - if sys.platform.startswith("linux"): + if sys.platform.startswith('linux'): # Use "ip" (ifconfig is not able to see all addresses) - ipre = re.compile(r"^(?P\d+):\s+(?P\S+)\s+inet6?\s+" r"(?P[\da-f.:]+)/(?P\d+)\s+.*") - labelre = re.compile(r".*\s+lo:(?P