Skip to content

Commit

Permalink
Incldue the function to parse the dependencies and set back to package
Browse files Browse the repository at this point in the history
…#253

Signed-off-by: Li <[email protected]>
  • Loading branch information
Li committed Jun 12, 2019
1 parent 0c579ad commit 30ed9dc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/packagedcode/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ def parse2(location):
is_dir = filetype.is_dir(location)
if is_dir:
parser = parse_unpackaged_source
return parser(location)
package = parser(location)
if package:
parse_dependencies(location, package)
return package
else:
file_name = fileutils.file_name(location)
parsers = {
Expand All @@ -354,9 +357,24 @@ def parse2(location):
}
for name, parser in parsers.items():
if file_name.endswith(name):
return parser(location)
package = parser(location)
if package:
parent_directory = fileutils.parent_directory(location)
parse_dependencies(parent_directory, package)
return package


def parse_dependencies(location, package):
"""
Loop all resources from the passing folder location, get the dependencies from the resources and set it to the passing package object.
"""
for resource_location in os.listdir(location):
dependencies = parse_with_dparse(resource_location)
if dependencies:
package.dependencies = dependencies



def parse_source_distribution(location):
"""
SDist objects are created from a filesystem path to the corresponding archive. Such as Zip or .tar.gz files
Expand Down Expand Up @@ -425,6 +443,9 @@ def parse_with_pkginfo(object):


def parse_with_dparse(location):
is_dir = filetype.is_dir(location)
if is_dir:
return
file_name = fileutils.file_name(location)
if file_name not in (filetypes.requirements_txt,
filetypes.conda_yml,
Expand Down

0 comments on commit 30ed9dc

Please sign in to comment.