Fix issues pointed out by ruff
Signed-off-by: Alfred Wingate <parona@protonmail.com>
This commit is contained in:
parent
70f88ed37d
commit
a8f35aee25
@ -29,8 +29,8 @@ from portage.exception import AmbiguousPackageName
|
||||
from portage.output import green, turquoise, white, yellow
|
||||
|
||||
from euscan import CONFIG, output
|
||||
from euscan.out import progress_bar
|
||||
from euscan._version import __version__
|
||||
from euscan.out import progress_bar
|
||||
|
||||
# Globals
|
||||
isatty = os.environ.get("TERM") != "dumb" and sys.stdout.isatty()
|
||||
@ -75,7 +75,7 @@ def print_usage(_error=None, help=None):
|
||||
if _error:
|
||||
out = sys.stderr
|
||||
|
||||
if not _error in (
|
||||
if _error not in (
|
||||
"global-options",
|
||||
"packages",
|
||||
):
|
||||
@ -284,7 +284,7 @@ def parse_args():
|
||||
# apply getopts to command line, show partial help on failure
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
|
||||
except:
|
||||
except getopt.GetoptError:
|
||||
raise ParseArgsException(opts_mode + "-options")
|
||||
|
||||
# set options accordingly
|
||||
|
@ -127,7 +127,7 @@ def get_deb_url(name):
|
||||
|
||||
if not deb_url:
|
||||
logger.error(" Cannot get package from %s" % url)
|
||||
name = raw_input(" Package name in Debian: ")
|
||||
name = input(" Package name in Debian: ")
|
||||
|
||||
return deb_url, deb_type
|
||||
|
||||
|
@ -84,6 +84,6 @@ ROBOTS_TXT_BLACKLIST_DOMAINS = [
|
||||
"(.*)festvox\.org(.*)",
|
||||
]
|
||||
|
||||
from euscan.out import EuscanOutput
|
||||
from euscan.out import EuscanOutput # noqa: E402
|
||||
|
||||
output = EuscanOutput(CONFIG)
|
||||
|
@ -27,8 +27,10 @@ def guess_package(cp, url):
|
||||
if match:
|
||||
pkg = match.group(1)
|
||||
try:
|
||||
# Output is None if input is invalid, therefore TypeError when
|
||||
# this None is attempted to be unpacked into three variables.
|
||||
cp, ver, rev = portage.pkgsplit("fake/" + pkg)
|
||||
except:
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
cat, pkg = cp.split("/")
|
||||
@ -92,7 +94,7 @@ def cpan_mangle_version(pv):
|
||||
def cpan_vercmp(cp, a, b):
|
||||
try:
|
||||
return float(a) - float(b)
|
||||
except:
|
||||
except OverflowError:
|
||||
return helpers.simple_vercmp(a, b)
|
||||
|
||||
|
||||
@ -113,7 +115,7 @@ def scan_pkg(pkg, options):
|
||||
options["versionmangle"] = ["cpan", "gentoo"]
|
||||
|
||||
url = "http://search.cpan.org/api/dist/%s" % remote_pkg
|
||||
cp, ver, rev = pkg.cp, pkg.version, pkg.revision
|
||||
cp, ver = pkg.cp, pkg.version
|
||||
m_ver = cpan_mangle_version(ver)
|
||||
|
||||
output.einfo("Using CPAN API: " + url)
|
||||
|
@ -4,8 +4,6 @@ import urllib.parse
|
||||
import urllib.request
|
||||
import xml.dom.minidom
|
||||
|
||||
import portage
|
||||
|
||||
from euscan import helpers, mangling, output
|
||||
|
||||
HANDLER_NAME = "php"
|
||||
@ -35,7 +33,7 @@ def scan_url(pkg, url, options):
|
||||
|
||||
|
||||
def scan_pkg(pkg, options):
|
||||
cp, ver, rev = pkg.cp, pkg.version, pkg.revision
|
||||
cp, ver = pkg.cp, pkg.version
|
||||
|
||||
package = options["data"]
|
||||
channel = options["type"]
|
||||
|
@ -1,20 +1,16 @@
|
||||
import errno
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import urllib.robotparser
|
||||
from xml.dom.minidom import Document
|
||||
|
||||
import portage
|
||||
from portage import dep
|
||||
|
||||
try:
|
||||
from urllib import robotparser, urlparse
|
||||
except ImportError:
|
||||
import urllib.robotparser
|
||||
import urllib.parse
|
||||
|
||||
import euscan
|
||||
from euscan import BLACKLIST_VERSIONS, CONFIG, ROBOTS_TXT_BLACKLIST_DOMAINS
|
||||
from euscan.version import parse_version
|
||||
@ -188,7 +184,9 @@ def join_version(components):
|
||||
version += str(components[i])
|
||||
if i >= len(components) - 1:
|
||||
break
|
||||
if type(components[i]) != str and type(components[i + 1]) != str:
|
||||
if not isinstance(components[i], str) and not isinstance(
|
||||
components[i + 1], str
|
||||
):
|
||||
version += "."
|
||||
return version
|
||||
|
||||
@ -200,10 +198,10 @@ def increment_version(components, level):
|
||||
raise Exception
|
||||
|
||||
for i in range(n, level + 1, -1):
|
||||
if type(components[i - 1]) == int:
|
||||
if isinstance(components[i - 1], int):
|
||||
components[i - 1] = 0
|
||||
|
||||
if type(components[level]) == int:
|
||||
if isinstance(components[level], int):
|
||||
components[level] += 1
|
||||
|
||||
return components
|
||||
@ -278,7 +276,7 @@ def urlallowed(url):
|
||||
try:
|
||||
rp.read()
|
||||
rpcache[baseurl] = rp
|
||||
except:
|
||||
except IOError:
|
||||
rp = None
|
||||
|
||||
setdefaulttimeout(timeout)
|
||||
|
@ -69,7 +69,7 @@ def progress_bar():
|
||||
|
||||
|
||||
def clean_colors(string):
|
||||
if type(string) is str:
|
||||
if isinstance(string, str):
|
||||
string = re.sub("\033\[[0-9;]+m", "", string)
|
||||
string = re.sub(r"\\u001b\[[0-9;]+m", "", string)
|
||||
string = re.sub(r"\x1b\[[0-9;]+m", "", string)
|
||||
|
Loading…
Reference in New Issue
Block a user