Skip to content

Commit

Permalink
Update update_requirements script
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Feb 26, 2022
1 parent 0c4e78b commit 9d99006
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
12 changes: 6 additions & 6 deletions bin/update_requirements
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ def get_package(requre: str) -> str:

harequire = []
request = requests.get(
"https://raw.githubusercontent.com/home-assistant/home-assistant/dev/setup.py"
"https://raw.githubusercontent.com/home-assistant/core/dev/requirements.txt"
)
request = request.text.split("REQUIRES = [")[1].split("]")[0].split("\n")
request = request.text.split("\n")
for req in request:
if "=" in req:
harequire.append(get_package(req.split('"')[1]))
harequire.append(get_package(req))

print(harequire)

with open(f"{PKG_PATH}/manifest.json") as manifest:
with open(f"{PKG_PATH}/manifest.json", encoding="utf8") as manifest:
manifest = json.load(manifest)
requirements = []
for req in manifest["requirements"]:
requirements.append(get_package(req))
manifest["requirements"] = requirements
with open(f"{ROOT}/requirements.txt") as requirements:
with open(f"{ROOT}/requirements.txt", encoding="utf8") as requirements:
tmp = requirements.readlines()
requirements = []
for req in tmp:
Expand All @@ -58,5 +58,5 @@ for req in manifest["requirements"]:
if pkg in harequire:
print(f"{pkg} in HA requirements, no need here.")
print(json.dumps(manifest["requirements"], indent=4))
with open(f"{PKG_PATH}/manifest.json", "w") as manifestfile:
with open(f"{PKG_PATH}/manifest.json", "w", encoding="utf8") as manifestfile:
manifestfile.write(json.dumps(manifest, indent=4))
26 changes: 13 additions & 13 deletions custom_components/integration_blueprint/manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"domain": "",
"name": "",
"version": "",
"documentation": "https://github.com/Limych/ha-blueprint",
"issue_tracker": "",
"dependencies": [],
"config_flow": true,
"codeowners": [
"@Limych"
],
"requirements": [],
"iot_class": "cloud_polling"
}
"domain": "",
"name": "",
"version": "",
"documentation": "https://github.com/Limych/ha-blueprint",
"issue_tracker": "",
"dependencies": [],
"config_flow": true,
"codeowners": [
"@Limych"
],
"requirements": [],
"iot_class": "cloud_polling"
}
4 changes: 3 additions & 1 deletion tests/const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Constants for tests."""
from typing import Final

from custom_components.integration_blueprint.const import CONF_PASSWORD, CONF_USERNAME

# Mock config data to be used across multiple tests
MOCK_CONFIG = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"}
MOCK_CONFIG: Final = {CONF_USERNAME: "test_username", CONF_PASSWORD: "test_password"}

0 comments on commit 9d99006

Please sign in to comment.