Skip to content

Commit

Permalink
Don't drop selectors when formatting deps
Browse files Browse the repository at this point in the history
Previously, selectors were getting dropped as tags and comments
  • Loading branch information
xylar committed Dec 29, 2024
1 parent 3410718 commit 62c1fee
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions grayskull/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def format_dependencies(all_dependencies: list, name: str) -> list:
formatted_dependencies = []
re_deps = re.compile(r"^\s*([\.a-zA-Z0-9_-]+)\s*(.*)\s*$", re.MULTILINE | re.DOTALL)
re_remove_space = re.compile(r"([<>!=]+)\s+")
re_selector = re.compile(r"\s+#\s+\[.*\]", re.DOTALL)
re_remove_tags = re.compile(r"\s*(\[.*\])", re.DOTALL)
re_remove_comments = re.compile(r"\s+#.*", re.DOTALL)
for req in all_dependencies:
Expand All @@ -193,6 +194,10 @@ def format_dependencies(all_dependencies: list, name: str) -> list:
if len(match_req) > 1:
deps_name = " ".join(match_req)
deps_name = re_remove_space.sub(r"\1", deps_name.strip())
if re_selector.search(deps_name):
# don't want to remove selectors
formatted_dependencies.append(deps_name)
continue
deps_name = re_remove_tags.sub(r" ", deps_name.strip())
deps_name = re_remove_comments.sub("", deps_name)
formatted_dependencies.append(deps_name.strip())
Expand Down

0 comments on commit 62c1fee

Please sign in to comment.