Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def dist_str(self):
return "%s::%s-%s-%s" % (self.channel.canonical_name, self.name, self.version, self.build)
def dist_fields_dump(self):
return {
"base_url": self.channel.base_url,
"build_number": self.build_number,
"build_string": self.build,
"channel": self.channel.name,
"dist_name": self.dist_str().split(":")[-1],
"name": self.name,
"platform": self.subdir,
"version": self.version,
}
arch = StringField(required=False, nullable=True) # so legacy
platform = EnumField(Platform, required=False, nullable=True) # so legacy
depends = ListField(string_types, default=())
constrains = ListField(string_types, default=())
track_features = _FeaturesField(required=False, default=(), default_in_dump=False)
features = _FeaturesField(required=False, default=(), default_in_dump=False)
noarch = NoarchField(NoarchType, required=False, nullable=True, default=None,
default_in_dump=False) # TODO: rename to package_type
preferred_env = StringField(required=False, nullable=True, default=None, default_in_dump=False)
license = StringField(required=False, nullable=True, default=None, default_in_dump=False)
license_family = StringField(required=False, nullable=True, default=None,
default_in_dump=False)
package_type = PackageTypeField()
build = StringField(aliases=('build_string',))
build_number = IntegerField()
# the canonical code abbreviation for PackageRef is `pref`
# fields required to uniquely identifying a package
channel = ChannelField(aliases=('schannel',))
subdir = SubdirField()
fn = FilenameField(aliases=('filename',))
md5 = StringField(default=None, required=False, nullable=True, default_in_dump=False)
legacy_bz2_md5 = StringField(default=None, required=False, nullable=True,
default_in_dump=False)
legacy_bz2_size = IntegerField(required=False, nullable=True, default_in_dump=False)
url = StringField(default=None, required=False, nullable=True, default_in_dump=False)
sha256 = StringField(default=None, required=False, nullable=True, default_in_dump=False)
@property
def schannel(self):
return self.channel.canonical_name
@property
def _pkey(self):
try:
return self.__pkey
except AttributeError:
__pkey = self.__pkey = [
self.channel.canonical_name, self.subdir, self.name,
self.version, self.build_number, self.build
]
# NOTE: fn is included to distinguish between .conda and .tar.bz2 packages
if context.separate_format_cache:
executable_paths = ListField(string_types, required=False, nullable=True)
softlink_paths = ListField(string_types, required=False, nullable=True)
class PackageMetadata(Entity):
# from info/package_metadata.json
package_metadata_version = IntegerField()
noarch = ComposableField(Noarch, required=False, nullable=True)
preferred_env = ComposableField(PreferredEnv, required=False, nullable=True, default=None,
default_in_dump=False)
class PackageInfo(ImmutableEntity):
# attributes external to the package tarball
extracted_package_dir = StringField()
channel = ComposableField(Channel)
repodata_record = ComposableField(PackageRecord)
url = StringField()
# attributes within the package tarball
index_json_record = ComposableField(IndexJsonRecord)
icondata = StringField(required=False, nullable=True)
package_metadata = ComposableField(PackageMetadata, required=False, nullable=True)
paths_data = ComposableField(PathsData)
def dist_str(self):
return "%s::%s-%s-%s" % (self.channel.canonical_name, self.name, self.version, self.build)
@property
def name(self):
return self.repodata_record.name
md5 = StringField(required=False, nullable=True)
name = StringField()
noarch = NoarchField(NoarchType, required=False, nullable=True)
platform = EnumField(Platform, required=False, nullable=True)
requires = ListField(string_types, required=False)
size = IntegerField(required=False)
subdir = StringField(required=False)
track_features = StringField(required=False)
version = StringField()
fn = StringField(required=False, nullable=True)
schannel = StringField(required=False, nullable=True)
channel = StringField(required=False, nullable=True)
priority = IntegerField(required=False)
url = StringField(required=False, nullable=True)
auth = StringField(required=False, nullable=True)
files = ListField(string_types, default=(), required=False)
link = ComposableField(Link, required=False)
with_features_depends = MapField(required=False)
preferred_env = StringField(default=None, required=False, nullable=True)
"platform": self.subdir,
"version": self.version,
}
arch = StringField(required=False, nullable=True) # so legacy
platform = EnumField(Platform, required=False, nullable=True) # so legacy
depends = ListField(string_types, default=())
constrains = ListField(string_types, default=())
track_features = _FeaturesField(required=False, default=(), default_in_dump=False)
features = _FeaturesField(required=False, default=(), default_in_dump=False)
noarch = NoarchField(NoarchType, required=False, nullable=True, default=None,
default_in_dump=False) # TODO: rename to package_type
preferred_env = StringField(required=False, nullable=True, default=None, default_in_dump=False)
license = StringField(required=False, nullable=True, default=None, default_in_dump=False)
license_family = StringField(required=False, nullable=True, default=None,
default_in_dump=False)
package_type = PackageTypeField()
@property
def is_unmanageable(self):
return self.package_type in PackageType.unmanageable_package_types()
timestamp = TimestampField()
@property
def combined_depends(self):
from .match_spec import MatchSpec
result = {ms.name: ms for ms in MatchSpec.merge(self.depends)}
class LeasedPathEntry(Entity):
"""
_path: short path for the leased path, using forward slashes
target_path: the full path to the executable in the private env
target_prefix: the full path to the private environment
leased_path: the full path for the lease in the root prefix
package_name: the package holding the lease
leased_path_type: application_entry_point
"""
_path = StringField()
target_path = StringField()
target_prefix = StringField()
leased_path = StringField()
package_name = StringField()
leased_path_type = EnumField(LeasedPathType)
channel_override=value.channel.canonical_name)
elif isinstance(value, Channel):
return Dist.from_url(value.url())
else:
return Dist.from_string(value)
else:
return super(DistType, cls).__call__(*args, **kwargs)
@with_metaclass(DistType)
class Dist(Entity):
_lazy_validate = True
channel = StringField(required=False, nullable=True, immutable=True)
dist_name = StringField(immutable=True)
name = StringField(immutable=True)
version = StringField(immutable=True)
build_string = StringField(immutable=True)
build_number = IntegerField(immutable=True)
base_url = StringField(required=False, nullable=True, immutable=True)
platform = StringField(required=False, nullable=True, immutable=True)
def __init__(self, channel, dist_name=None, name=None, version=None, build_string=None,
build_number=None, base_url=None, platform=None):
super(Dist, self).__init__(channel=channel,
dist_name=dist_name,
name=name,
version=version,
build_string=build_string,
build_number=build_number,
elif isinstance(value, PackageInfo):
return Dist.from_string(value.repodata_record.fn,
channel_override=value.channel.canonical_name)
elif isinstance(value, Channel):
return Dist.from_url(value.url())
else:
return Dist.from_string(value)
else:
return super(DistType, cls).__call__(*args, **kwargs)
@with_metaclass(DistType)
class Dist(Entity):
_lazy_validate = True
channel = StringField(required=False, nullable=True, immutable=True)
dist_name = StringField(immutable=True)
name = StringField(immutable=True)
version = StringField(immutable=True)
build_string = StringField(immutable=True)
build_number = IntegerField(immutable=True)
base_url = StringField(required=False, nullable=True, immutable=True)
platform = StringField(required=False, nullable=True, immutable=True)
def __init__(self, channel, dist_name=None, name=None, version=None, build_string=None,
build_number=None, base_url=None, platform=None):
super(Dist, self).__init__(channel=channel,
dist_name=dist_name,
name=name,
version=version,
return super(DistType, cls).__call__(*args, **kwargs)
@with_metaclass(DistType)
class Dist(Entity):
_lazy_validate = True
channel = StringField(required=False, nullable=True, immutable=True)
dist_name = StringField(immutable=True)
name = StringField(immutable=True)
version = StringField(immutable=True)
build_string = StringField(immutable=True)
build_number = IntegerField(immutable=True)
base_url = StringField(required=False, nullable=True, immutable=True)
platform = StringField(required=False, nullable=True, immutable=True)
def __init__(self, channel, dist_name=None, name=None, version=None, build_string=None,
build_number=None, base_url=None, platform=None):
super(Dist, self).__init__(channel=channel,
dist_name=dist_name,
name=name,
version=version,
build_string=build_string,
build_number=build_number,
base_url=base_url,
platform=platform)
def to_package_ref(self):
return PackageRef(
channel=self.channel,
subdir = StringField(required=False)
track_features = StringField(required=False)
version = StringField()
fn = StringField(required=False, nullable=True)
schannel = StringField(required=False, nullable=True)
channel = StringField(required=False, nullable=True)
priority = IntegerField(required=False)
url = StringField(required=False, nullable=True)
auth = StringField(required=False, nullable=True)
files = ListField(string_types, default=(), required=False)
link = ComposableField(Link, required=False)
with_features_depends = MapField(required=False)
preferred_env = StringField(default=None, required=False, nullable=True)