trivial: Use same codestyle
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
parent
47597fcad7
commit
2b20b9e369
3 changed files with 27 additions and 27 deletions
|
@ -24,13 +24,14 @@ DEFAULT_EDITOR = "vi"
|
|||
XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
|
||||
CACHEDIR = os.path.join(XDG_CACHE_HOME, "rust2rpm")
|
||||
API_URL = "https://crates.io/api/v1/"
|
||||
JINJA_ENV = jinja2.Environment(loader=jinja2.ChoiceLoader([
|
||||
jinja2.FileSystemLoader(["/"]),
|
||||
jinja2.PackageLoader("rust2rpm", "templates"),
|
||||
]),
|
||||
extensions=["jinja2.ext.do"],
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True)
|
||||
JINJA_ENV = jinja2.Environment(
|
||||
loader=jinja2.ChoiceLoader([
|
||||
jinja2.FileSystemLoader(["/"]),
|
||||
jinja2.PackageLoader("rust2rpm", "templates"),
|
||||
]),
|
||||
extensions=["jinja2.ext.do"],
|
||||
trim_blocks=True,
|
||||
lstrip_blocks=True)
|
||||
|
||||
def get_default_target():
|
||||
# TODO: add fallback for /usr/lib/os-release
|
||||
|
@ -122,8 +123,7 @@ def download(crate, version):
|
|||
req = requests.get(url, stream=True)
|
||||
req.raise_for_status()
|
||||
total = int(req.headers["Content-Length"])
|
||||
with remove_on_error(cratef), \
|
||||
open(cratef, "wb") as f:
|
||||
with remove_on_error(cratef), open(cratef, "wb") as f:
|
||||
for chunk in tqdm.tqdm(req.iter_content(), f"Downloading {cratef_base}".format(cratef_base),
|
||||
total=total, unit="B", unit_scale=True):
|
||||
f.write(chunk)
|
||||
|
@ -183,7 +183,7 @@ def make_diff_metadata(crate, version, patch=False, store=False):
|
|||
cratef, crate, version = local_crate(crate, version)
|
||||
else:
|
||||
if store:
|
||||
raise ValueError('--store-crate can only be used for a crate')
|
||||
raise ValueError("--store-crate can only be used for a crate")
|
||||
|
||||
toml, crate, version = local_toml(crate, version)
|
||||
diff = make_patch(toml, enabled=patch, tmpfile=True)
|
||||
|
@ -234,7 +234,7 @@ def main():
|
|||
return
|
||||
|
||||
if args.crate is None:
|
||||
parser.error('required crate/path argument missing')
|
||||
parser.error("required crate/path argument missing")
|
||||
|
||||
crate, diff, metadata = make_diff_metadata(args.crate, args.version,
|
||||
patch=args.patch,
|
||||
|
@ -254,7 +254,7 @@ def main():
|
|||
kwargs["target"] = args.target
|
||||
kwargs["all_features"] = args.all_features
|
||||
bins = [tgt for tgt in metadata.targets if tgt.kind == "bin"]
|
||||
libs = [tgt for tgt in metadata.targets if tgt.kind in ("lib", "rlib", "proc-macro")]
|
||||
libs = [tgt for tgt in metadata.targets if tgt.kind in {"lib", "rlib", "proc-macro"}]
|
||||
is_bin = len(bins) > 0
|
||||
is_lib = len(libs) > 0
|
||||
if is_bin:
|
||||
|
@ -271,7 +271,7 @@ def main():
|
|||
else:
|
||||
kwargs["auto_changelog_entry"] = True
|
||||
|
||||
if args.target in ("fedora", "mageia", "opensuse"):
|
||||
if args.target in {"fedora", "mageia", "opensuse"}:
|
||||
kwargs["include_build_requires"] = True
|
||||
kwargs["include_provides"] = False
|
||||
kwargs["include_requires"] = False
|
||||
|
|
|
@ -17,12 +17,12 @@ def translate_slashes(license):
|
|||
def spdx_to_fedora_map():
|
||||
with open(SPDX_TO_FEDORA_CSV, newline='') as f:
|
||||
reader = _csv.DictReader(f)
|
||||
return {line['SPDX License Identifier'] : line['Fedora Short Name']
|
||||
return {line['SPDX License Identifier']: line['Fedora Short Name']
|
||||
for line in reader
|
||||
if line['SPDX License Identifier']}
|
||||
|
||||
def dump_sdpx_to_fedora_map(file):
|
||||
for k,v in spdx_to_fedora_map().items():
|
||||
for k, v in spdx_to_fedora_map().items():
|
||||
print(f"{k} → {v}", file=file)
|
||||
|
||||
def translate_license_fedora(license):
|
||||
|
@ -39,7 +39,7 @@ def translate_license_fedora(license):
|
|||
if mapped is None:
|
||||
comments += f'# FIXME: Upstream uses unknown SPDX tag {tag}!'
|
||||
final.append(tag)
|
||||
elif mapped is '':
|
||||
elif mapped == '':
|
||||
comments += f"# FIXME: Upstream SPDX tag {tag} not listed in Fedora's good licenses list.\n"
|
||||
comments += "# FIXME: This package might not be allowed in Fedora!\n"
|
||||
final.append(tag)
|
||||
|
|
|
@ -25,13 +25,13 @@ class Dependency:
|
|||
|
||||
@classmethod
|
||||
def from_json(cls, metadata):
|
||||
features = set(metadata['features'])
|
||||
if metadata['uses_default_features']:
|
||||
features.add('default')
|
||||
kwargs = {'name': metadata['name'],
|
||||
'req': metadata['req'],
|
||||
'optional': metadata['optional'],
|
||||
'features': features}
|
||||
features = set(metadata["features"])
|
||||
if metadata["uses_default_features"]:
|
||||
features.add("default")
|
||||
kwargs = {"name": metadata["name"],
|
||||
"req": metadata["req"],
|
||||
"optional": metadata["optional"],
|
||||
"features": features}
|
||||
return cls(**kwargs)
|
||||
|
||||
@staticmethod
|
||||
|
@ -45,7 +45,7 @@ class Dependency:
|
|||
# Any means any
|
||||
continue
|
||||
ver = req.spec
|
||||
if req.kind in (req.KIND_NEQ, req.KIND_EMPTY):
|
||||
if req.kind in {req.KIND_NEQ, req.KIND_EMPTY}:
|
||||
raise NotImplementedError(f"'!=' and empty kinds are not supported: {req}")
|
||||
coerced = str(semver.Version.coerce(str(ver)))
|
||||
if ver.prerelease:
|
||||
|
@ -54,7 +54,7 @@ class Dependency:
|
|||
ver = ver.next_patch()
|
||||
if req.kind == req.KIND_EQUAL:
|
||||
req.kind = req.KIND_SHORTEQ
|
||||
if req.kind in (req.KIND_CARET, req.KIND_COMPATIBLE):
|
||||
if req.kind in {req.KIND_CARET, req.KIND_COMPATIBLE}:
|
||||
if ver.major == 0:
|
||||
if ver.minor is not None:
|
||||
if ver.minor != 0 or ver.patch is None:
|
||||
|
@ -74,11 +74,11 @@ class Dependency:
|
|||
upper = ver.next_minor()
|
||||
reqs.append((">=", coerced))
|
||||
reqs.append(("<", upper))
|
||||
elif req.kind in (req.KIND_SHORTEQ,
|
||||
elif req.kind in {req.KIND_SHORTEQ,
|
||||
req.KIND_GT,
|
||||
req.KIND_GTE,
|
||||
req.KIND_LT,
|
||||
req.KIND_LTE):
|
||||
req.KIND_LTE}:
|
||||
reqs.append((str(req.kind), coerced))
|
||||
else:
|
||||
raise AssertionError(f"Found unhandled kind: {req.kind}")
|
||||
|
|
Loading…
Reference in a new issue