Skip to content

Commit

Permalink
Refactor PathInfo Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Nov 17, 2016
1 parent 9fb81e0 commit b2d49b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 2 additions & 3 deletions conda/gateways/disk/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from os.path import isfile, islink, join

from ...base.constants import FileMode, PREFIX_PLACEHOLDER, UTF8
from ...models.package_info import PackageInfoContents, PackageInfo
from ...models.package_info import PackageInfoContents, PackageInfo, PathInfoV1
from ...models.record import Record
from ...exceptions import CondaUpgradeError

Expand Down Expand Up @@ -53,8 +53,7 @@ def collect_all_info_for_package(extracted_package_directory):
data = json.load(file_json)
if data.get('version') != 1:
raise CondaUpgradeError("Expected files.json schema to be version 1")

return PackageInfo(files=data['files'],
return PackageInfo(files=(PathInfoV1(**f) for f in data['files']),
index_json_record=read_index_json(extracted_package_directory),
noarch=read_noarch(extracted_package_directory),
icondata=read_icondata(extracted_package_directory),
Expand Down
16 changes: 10 additions & 6 deletions conda/models/package_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,21 @@ def __str__(self):

class PathInfo(Entity):
path = StringField()
sha256 = StringField()
size_in_bytes = IntegerField()
node_type = EnumField(NodeType)
prefix_placeholder = StringField(required=False)
file_mode = EnumField(FileMode, required=False)
no_link = BooleanField(required=False, nullable=True)
inode_paths = ListField(string_types)


class PathInfoV1(PathInfo):
node_type = EnumField(NodeType)
sha256 = StringField()
size_in_bytes = IntegerField()
inode_paths = ListField(string_types, required=False, nullable=True)


class PackageInfo(Entity):
path_info_version = IntegerField()
files = ListField(PathInfo)
index_json_record = ComposableField(Record)
icondata = StringField()
noarch = ComposableField(NoarchInfo)
icondata = StringField(required=False, nullable=True)
noarch = ComposableField(NoarchInfo, required=False, nullable=True)

0 comments on commit b2d49b4

Please sign in to comment.