This commit is contained in:
@@ -3,14 +3,13 @@ from __future__ import annotations
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
import tomllib
|
||||
else:
|
||||
import tomli as tomllib
|
||||
|
||||
from depaudit.parsers import Parser, ParsedManifest, Dependency
|
||||
from depaudit.parsers import Parser, ParsedManifest
|
||||
|
||||
|
||||
class PythonParser(Parser):
|
||||
@@ -108,7 +107,7 @@ class PythonParser(Parser):
|
||||
content = file_path.read_text(encoding="utf-8")
|
||||
|
||||
install_requires_match = re.search(
|
||||
r"install_requires\s*=\s*\[([^\]]*)\]", content, re.DOTALL
|
||||
r"install_requires\s*=\s*\[(^\]]*)\]", content, re.DOTALL
|
||||
)
|
||||
if install_requires_match:
|
||||
deps_str = install_requires_match.group(1)
|
||||
@@ -119,11 +118,11 @@ class PythonParser(Parser):
|
||||
self._create_dependency(file_path, name, version)
|
||||
)
|
||||
|
||||
name_match = re.search(r'name\s*=\s*["']([^"\']+)["']', content)
|
||||
name_match = re.search(r'name\s*=\s*["']([^"']+)["']', content)
|
||||
if name_match:
|
||||
manifest.project_name = name_match.group(1)
|
||||
|
||||
version_match = re.search(r'version\s*=\s*["']([^"\']+)["']', content)
|
||||
version_match = re.search(r'version\s*=\s*["']([^"']+)["']', content)
|
||||
if version_match:
|
||||
manifest.project_version = version_match.group(1)
|
||||
|
||||
@@ -147,7 +146,7 @@ class PythonParser(Parser):
|
||||
def _parse_pipfile(self, file_path: Path, manifest: ParsedManifest) -> None:
|
||||
content = file_path.read_text(encoding="utf-8")
|
||||
|
||||
name_match = re.search(r'name\s*=\s*["']([^"\']+)["']', content)
|
||||
name_match = re.search(r'name\s*=\s*["']([^"']+)["']', content)
|
||||
if name_match:
|
||||
manifest.project_name = name_match.group(1)
|
||||
|
||||
@@ -195,10 +194,8 @@ class PythonParser(Parser):
|
||||
extras_match = re.match(r"([^\[]+)(?:\[([^\]]+)\])?", req)
|
||||
if extras_match:
|
||||
name = extras_match.group(1)
|
||||
extras = extras_match.group(2)
|
||||
else:
|
||||
name = req
|
||||
extras = None
|
||||
|
||||
for op in ["==", ">=", "<=", "~=", "!=", ">", "<", "==="]:
|
||||
if op in name:
|
||||
|
||||
Reference in New Issue
Block a user