Use typex name instead of type_

This commit is contained in:
Ivan Kravets
2023-06-24 19:39:34 +03:00
parent 53f1d82890
commit f720cd841c
3 changed files with 19 additions and 19 deletions

View File

@ -135,20 +135,20 @@ def list_global_packages(options):
("libraries", LibraryPackageManager(options.get("storage_dir"))), ("libraries", LibraryPackageManager(options.get("storage_dir"))),
] ]
only_packages = any( only_packages = any(
options.get(type_) or options.get(f"only_{type_}") for (type_, _) in data options.get(typex) or options.get(f"only_{typex}") for (typex, _) in data
) )
for type_, pm in data: for typex, pm in data:
skip_conds = [ skip_conds = [
only_packages only_packages
and not options.get(type_) and not options.get(typex)
and not options.get(f"only_{type_}"), and not options.get(f"only_{typex}"),
not pm.get_installed(), not pm.get_installed(),
] ]
if any(skip_conds): if any(skip_conds):
continue continue
click.secho(type_.capitalize(), bold=True) click.secho(typex.capitalize(), bold=True)
print_dependency_tree( print_dependency_tree(
pm, filter_specs=options.get(type_), verbose=options.get("verbose") pm, filter_specs=options.get(typex), verbose=options.get("verbose")
) )
click.echo() click.echo()
@ -156,12 +156,12 @@ def list_global_packages(options):
def list_project_packages(options): def list_project_packages(options):
environments = options["environments"] environments = options["environments"]
only_packages = any( only_packages = any(
options.get(type_) or options.get(f"only_{type_}") options.get(typex) or options.get(f"only_{typex}")
for type_ in ("platforms", "tools", "libraries") for typex in ("platforms", "tools", "libraries")
) )
only_platform_packages = any( only_platform_packages = any(
options.get(type_) or options.get(f"only_{type_}") options.get(typex) or options.get(f"only_{typex}")
for type_ in ("platforms", "tools") for typex in ("platforms", "tools")
) )
only_library_packages = options.get("libraries") or options.get("only_libraries") only_library_packages = options.get("libraries") or options.get("only_libraries")

View File

@ -56,7 +56,7 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument
) )
@click.option( @click.option(
"--type", "--type",
"type_", "typex",
type=click.Choice(list(PackageType.items().values())), type=click.Choice(list(PackageType.items().values())),
help="Custom package type", help="Custom package type",
) )
@ -83,7 +83,7 @@ def validate_datetime(ctx, param, value): # pylint: disable=unused-argument
hidden=True, hidden=True,
) )
def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
package, owner, type_, released_at, private, notify, no_interactive, non_interactive package, owner, typex, released_at, private, notify, no_interactive, non_interactive
): ):
click.secho("Preparing a package...", fg="cyan") click.secho("Preparing a package...", fg="cyan")
no_interactive = no_interactive or non_interactive no_interactive = no_interactive or non_interactive
@ -103,14 +103,14 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
p = PackagePacker(package) p = PackagePacker(package)
archive_path = p.pack() archive_path = p.pack()
type_ = type_ or PackageType.from_archive(archive_path) typex = typex or PackageType.from_archive(archive_path)
manifest = ManifestSchema().load_manifest( manifest = ManifestSchema().load_manifest(
ManifestParserFactory.new_from_archive(archive_path).as_dict() ManifestParserFactory.new_from_archive(archive_path).as_dict()
) )
name = manifest.get("name") name = manifest.get("name")
version = manifest.get("version") version = manifest.get("version")
data = [ data = [
("Type:", type_), ("Type:", typex),
("Owner:", owner), ("Owner:", owner),
("Name:", name), ("Name:", name),
("Version:", version), ("Version:", version),
@ -124,13 +124,13 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
check_archive_file_names(archive_path) check_archive_file_names(archive_path)
# look for duplicates # look for duplicates
check_package_duplicates(owner, type_, name, version, manifest.get("system")) check_package_duplicates(owner, typex, name, version, manifest.get("system"))
if not no_interactive: if not no_interactive:
click.confirm( click.confirm(
"Are you sure you want to publish the %s %s to the registry?\n" "Are you sure you want to publish the %s %s to the registry?\n"
% ( % (
type_, typex,
click.style( click.style(
"%s/%s@%s" % (owner, name, version), "%s/%s@%s" % (owner, name, version),
fg="cyan", fg="cyan",
@ -146,7 +146,7 @@ def package_publish_cmd( # pylint: disable=too-many-arguments, too-many-locals
) )
click.echo("Publishing...") click.echo("Publishing...")
response = RegistryClient().publish_package( response = RegistryClient().publish_package(
owner, type_, archive_path, released_at, private, notify owner, typex, archive_path, released_at, private, notify
) )
if not do_not_pack: if not do_not_pack:
os.remove(archive_path) os.remove(archive_path)

View File

@ -142,12 +142,12 @@ class RegistryClient(HTTPClient):
x_with_authorization=self.allowed_private_packages(), x_with_authorization=self.allowed_private_packages(),
) )
def get_package(self, type_, owner, name, version=None, extra_path=None): def get_package(self, typex, owner, name, version=None, extra_path=None):
try: try:
return self.fetch_json_data( return self.fetch_json_data(
"get", "get",
"/v3/packages/{owner}/{type}/{name}{extra_path}".format( "/v3/packages/{owner}/{type}/{name}{extra_path}".format(
type=type_, type=typex,
owner=owner.lower(), owner=owner.lower(),
name=name.lower(), name=name.lower(),
extra_path=extra_path or "", extra_path=extra_path or "",