Skip to content

Commit

Permalink
Remove PyYAML usages and dependency (#13889)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickM-27 authored Sep 22, 2024
1 parent e8763b3 commit 6bafb68
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 0 additions & 2 deletions docker/main/requirements-wheels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ peewee_migrate == 1.13.*
psutil == 5.9.*
pydantic == 2.8.*
git+https://github.com/fbcotter/py3nvml#egg=py3nvml
PyYAML == 6.0.*
pytz == 2024.1
pyzmq == 26.2.*
ruamel.yaml == 0.18.*
tzlocal == 5.2
types-PyYAML == 6.0.*
requests == 2.32.*
types-requests == 2.32.*
scipy == 1.13.*
Expand Down
5 changes: 3 additions & 2 deletions docker/main/rootfs/usr/local/go2rtc/create_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
from pathlib import Path

import yaml
from ruamel.yaml import YAML

sys.path.insert(0, "/opt/frigate")
from frigate.const import (
Expand All @@ -18,6 +18,7 @@

sys.path.remove("/opt/frigate")

yaml = YAML()

FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE_")}
# read docker secret files as env vars too
Expand All @@ -40,7 +41,7 @@
raw_config = f.read()

if config_file.endswith((".yaml", ".yml")):
config: dict[str, any] = yaml.safe_load(raw_config)
config: dict[str, any] = yaml.load(raw_config)
elif config_file.endswith(".json"):
config: dict[str, any] = json.loads(raw_config)
except FileNotFoundError:
Expand Down
6 changes: 4 additions & 2 deletions docker/main/rootfs/usr/local/nginx/get_tls_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import json
import os

import yaml
from ruamel.yaml import YAML

yaml = YAML()

config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")

Expand All @@ -17,7 +19,7 @@
raw_config = f.read()

if config_file.endswith((".yaml", ".yml")):
config: dict[str, any] = yaml.safe_load(raw_config)
config: dict[str, any] = yaml.load(raw_config)
elif config_file.endswith(".json"):
config: dict[str, any] = json.loads(raw_config)
except FileNotFoundError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import json
import os

import yaml
from ruamel.yaml import YAML

yaml = YAML()

config_file = os.environ.get("CONFIG_FILE", "/config/config.yml")

Expand All @@ -17,7 +19,7 @@
raw_config = f.read()

if config_file.endswith((".yaml", ".yml")):
config: dict[str, any] = yaml.safe_load(raw_config)
config: dict[str, any] = yaml.load(raw_config)
elif config_file.endswith(".json"):
config: dict[str, any] = json.loads(raw_config)
except FileNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion frigate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ def parse(cls, config, *, is_json=None, **context):
elif ext == ".json":
is_json = True

# At this point, ry to sniff the config string, to guess if it is json or not.
# At this point, try to sniff the config string, to guess if it is json or not.
if is_json is None:
is_json = REGEX_JSON.match(config) is not None

Expand Down

0 comments on commit 6bafb68

Please sign in to comment.