Skip to content

Commit

Permalink
added parsing of egg=... in urls for requirements.txt (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Maas authored Sep 18, 2022
1 parent 1eb80c8 commit cf4098b
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 189 deletions.
7 changes: 6 additions & 1 deletion deptry/dependency_getter/requirements_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _find_dependency_name_in(self, line):

@staticmethod
def _remove_comments_from(line):
return re.sub(r"#.*", "", line).strip()
return re.sub(r"\s+#.*", "", line).strip()

@staticmethod
def _remove_newlines_from(line):
Expand All @@ -118,6 +118,11 @@ def _line_is_url(line):
@staticmethod
def _extract_name_from_url(line):

# Try to find egg, for url like git+https://github.com/xxxxx/package@xxxxx#egg=package
match = re.search("egg=([a-zA-Z0-9-_]*)", line)
if match:
return match.group(1)

# for url like git+https://github.com/name/python-module.git@0d6dc38d58
match = re.search("\/((?:(?!\/).)*?)\.git", line)
if match:
Expand Down
Loading

0 comments on commit cf4098b

Please sign in to comment.