Commit 504eb96b by David Hotham Committed by Branch Vincent

use types-html5lib

parent d959f1fc
...@@ -731,6 +731,14 @@ optional = false ...@@ -731,6 +731,14 @@ optional = false
python-versions = "*" python-versions = "*"
[[package]] [[package]]
name = "types-html5lib"
version = "1.1.7"
description = "Typing stubs for html5lib"
category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "types-requests" name = "types-requests"
version = "2.27.26" version = "2.27.26"
description = "Typing stubs for requests" description = "Typing stubs for requests"
...@@ -812,7 +820,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- ...@@ -812,7 +820,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.7" python-versions = "^3.7"
content-hash = "de4d886bc0dfaf7a2cbc42d82147bbcb9490b1f13f1e7abada8c824f1e592a2a" content-hash = "58010109be37f846df33e17737ed95a64df555288aabf96c3089fd0d58cc6872"
[metadata.files] [metadata.files]
atomicwrites = [ atomicwrites = [
...@@ -1279,6 +1287,10 @@ types-entrypoints = [ ...@@ -1279,6 +1287,10 @@ types-entrypoints = [
{file = "types-entrypoints-0.3.7.tar.gz", hash = "sha256:3d002ba32fc2c7fb44f65228fb912969a495cb4aa4ae63e05152f4304bc9bba2"}, {file = "types-entrypoints-0.3.7.tar.gz", hash = "sha256:3d002ba32fc2c7fb44f65228fb912969a495cb4aa4ae63e05152f4304bc9bba2"},
{file = "types_entrypoints-0.3.7-py3-none-any.whl", hash = "sha256:06aea9245f25b7b335ef0c3e8e4cc422b1f7c2cc47ae11f9a000a0a15d8ea6aa"}, {file = "types_entrypoints-0.3.7-py3-none-any.whl", hash = "sha256:06aea9245f25b7b335ef0c3e8e4cc422b1f7c2cc47ae11f9a000a0a15d8ea6aa"},
] ]
types-html5lib = [
{file = "types-html5lib-1.1.7.tar.gz", hash = "sha256:fdb307102ceea52adf52aea0e10255d142ee29d7f169014144a730707a92066a"},
{file = "types_html5lib-1.1.7-py3-none-any.whl", hash = "sha256:4bc5a1de03b9a697b7cc04b0d03eeed5d36c0073165dd9dc54f2f43d0f23b31f"},
]
types-requests = [ types-requests = [
{file = "types-requests-2.27.26.tar.gz", hash = "sha256:a6a04c0274c0949fd0525f35d8b53ac34e77afecbeb3c4932ddc6ce675ac009c"}, {file = "types-requests-2.27.26.tar.gz", hash = "sha256:a6a04c0274c0949fd0525f35d8b53ac34e77afecbeb3c4932ddc6ce675ac009c"},
{file = "types_requests-2.27.26-py3-none-any.whl", hash = "sha256:302137cb5bd482357398a155faf3ed095855fbc6994e952d0496c7fd50f44125"}, {file = "types_requests-2.27.26-py3-none-any.whl", hash = "sha256:302137cb5bd482357398a155faf3ed095855fbc6994e952d0496c7fd50f44125"},
......
...@@ -73,6 +73,7 @@ zipp = { version = "^3.4", python = "<3.8" } ...@@ -73,6 +73,7 @@ zipp = { version = "^3.4", python = "<3.8" }
flatdict = "^4.0.1" flatdict = "^4.0.1"
mypy = ">=0.950" mypy = ">=0.950"
types-entrypoints = ">=0.3.7" types-entrypoints = ">=0.3.7"
types-html5lib = ">=1.1.7"
types-requests = ">=2.27.11" types-requests = ">=2.27.11"
[tool.poetry.scripts] [tool.poetry.scripts]
...@@ -141,7 +142,6 @@ module = [ ...@@ -141,7 +142,6 @@ module = [
'cachy.*', 'cachy.*',
'cleo.*', 'cleo.*',
'crashtest.*', 'crashtest.*',
'html5lib.*',
'jsonschema.*', 'jsonschema.*',
'pexpect.*', 'pexpect.*',
'pkginfo.*', 'pkginfo.*',
......
...@@ -106,20 +106,33 @@ class PyPiRepository(HTTPRepository): ...@@ -106,20 +106,33 @@ class PyPiRepository(HTTPRepository):
response = requests.session().get(self._base_url + "search", params=search) response = requests.session().get(self._base_url + "search", params=search)
content = parse(response.content, namespaceHTMLElements=False) content = parse(response.content, namespaceHTMLElements=False)
for result in content.findall(".//*[@class='package-snippet']"): for result in content.findall(".//*[@class='package-snippet']"):
name = result.find("h3/*[@class='package-snippet__name']").text name_element = result.find("h3/*[@class='package-snippet__name']")
version = result.find("h3/*[@class='package-snippet__version']").text version_element = result.find("h3/*[@class='package-snippet__version']")
if not name or not version: if (
name_element is None
or version_element is None
or not name_element.text
or not version_element.text
):
continue continue
description = result.find("p[@class='package-snippet__description']").text name = name_element.text
if not description: version = version_element.text
description = ""
description_element = result.find(
"p[@class='package-snippet__description']"
)
description = (
description_element.text
if description_element is not None and description_element.text
else ""
)
try: try:
result = Package(name, version, description) package = Package(name, version)
result.description = to_str(description.strip()) package.description = to_str(description.strip())
results.append(result) results.append(package)
except InvalidVersion: except InvalidVersion:
self._log( self._log(
f'Unable to parse version "{version}" for the {name} package,' f'Unable to parse version "{version}" for the {name} package,'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment