@@ -63,19 +63,23 @@ def get_module_sources(parsed_lockfile: dict, include_devel: bool = True) -> lis
6363 for section , packages in parsed_lockfile .items ():
6464 if section == "package" :
6565 for package in packages :
66- if (
67- package ["category" ] == "dev"
68- and include_devel
69- and not package ["optional" ]
70- or package ["category" ] == "main"
71- and not package ["optional" ]
66+ if "category" not in package or (
67+ (
68+ package .get ("category" ) == "dev"
69+ and include_devel
70+ and not package .get ("optional" )
71+ )
72+ or (
73+ package .get ("category" ) == "main"
74+ and not package .get ("optional" )
75+ )
7276 ):
77+ hashes = []
7378 # Check for old metadata format (poetry version < 1.0.0b2)
7479 if "hashes" in parsed_lockfile ["metadata" ]:
7580 hashes = parsed_lockfile ["metadata" ]["hashes" ][package ["name" ]]
76- # Else new metadata format
77- else :
78- hashes = []
81+ # metadata format 1.1
82+ elif "files" in parsed_lockfile ["metadata" ]:
7983 for package_name in parsed_lockfile ["metadata" ]["files" ]:
8084 if package_name == package ["name" ]:
8185 package_files = parsed_lockfile ["metadata" ]["files" ][
@@ -86,6 +90,12 @@ def get_module_sources(parsed_lockfile: dict, include_devel: bool = True) -> lis
8690 match = hash_re .search (package_files [num ]["hash" ])
8791 if match :
8892 hashes .append (match .group (2 ))
93+ # metadata format 2.0
94+ else :
95+ for file in package ["files" ]:
96+ match = hash_re .search (file ["hash" ])
97+ if match :
98+ hashes .append (match .group (2 ))
8999 package_source = package .get ("source" )
90100 if package_source and package_source ["type" ] == "directory" :
91101 print (f'Skipping download url and hash extraction for { package ["name" ]} , source type is directory' )
@@ -112,12 +122,16 @@ def get_dep_names(parsed_lockfile: dict, include_devel: bool = True) -> list:
112122 for section , packages in parsed_lockfile .items ():
113123 if section == "package" :
114124 for package in packages :
115- if (
116- package ["category" ] == "dev"
117- and include_devel
118- and not package ["optional" ]
119- or package ["category" ] == "main"
120- and not package ["optional" ]
125+ if "category" not in package or (
126+ (
127+ package .get ("category" ) == "dev"
128+ and include_devel
129+ and not package .get ("optional" )
130+ )
131+ or (
132+ package .get ("category" ) == "main"
133+ and not package .get ("optional" )
134+ )
121135 ):
122136 dep_names .append (package ["name" ])
123137 return dep_names
0 commit comments