Skip to content

Commit

Permalink
fix: fix pylint waning
Browse files Browse the repository at this point in the history
  • Loading branch information
topsworld committed Dec 20, 2024
1 parent f5e4208 commit 0af9e08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
16 changes: 8 additions & 8 deletions tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
from urllib.request import Request, urlopen


def load_yaml_file(file_path: str) -> dict:
with open(file_path, 'r', encoding='utf-8') as file:
def load_yaml_file(yaml_file: str) -> dict:
with open(yaml_file, 'r', encoding='utf-8') as file:
return yaml.safe_load(file)


def save_yaml_file(file_path: str, data: dict) -> None:
with open(file_path, 'w', encoding='utf-8') as file:
def save_yaml_file(yaml_file: str, data: dict) -> None:
with open(yaml_file, 'w', encoding='utf-8') as file:
yaml.safe_dump(
data=data, stream=file, allow_unicode=True)


def load_json_file(file_path: str) -> dict:
with open(file_path, 'r', encoding='utf-8') as file:
def load_json_file(json_file: str) -> dict:
with open(json_file, 'r', encoding='utf-8') as file:
return json.load(file)


def save_json_file(file_path: str, data: dict) -> None:
with open(file_path, 'w', encoding='utf-8') as file:
def save_json_file(json_file: str, data: dict) -> None:
with open(json_file, 'w', encoding='utf-8') as file:
json.dump(data, file, ensure_ascii=False, indent=4)


Expand Down
7 changes: 2 additions & 5 deletions tools/update_lan_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
'../custom_components/xiaomi_home/miot/lan/profile_models.yaml')


# SpecialModels


SPECIAL_MODELS: list[str] = [
# model2class-v2
'chuangmi.camera.ipc007b', 'chuangmi.camera.ipc019b',
Expand Down Expand Up @@ -63,7 +60,7 @@ def update_profile_model(file_path: str):
profile_rules['models'], dict):
raise ValueError('Failed to get profile rule')
local_rules: dict = load_yaml_file(
file_path=file_path) or {}
yaml_file=file_path) or {}
for rule, ts in profile_rules['models'].items():
if rule not in local_rules:
local_rules[rule] = {'ts': ts}
Expand All @@ -76,7 +73,7 @@ def update_profile_model(file_path: str):
local_rules[mode]['ts'] = 1531108800
local_rules = dict(sorted(local_rules.items()))
save_yaml_file(
file_path=file_path, data=local_rules)
yaml_file=file_path, data=local_rules)


update_profile_model(file_path=LAN_PROFILE_MODELS_FILE)
Expand Down

0 comments on commit 0af9e08

Please sign in to comment.