mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-24 04:51:27 +00:00
feat: add type hints
This commit is contained in:
parent
e6ddd1feed
commit
7d0cc5e630
|
@ -1,10 +1,11 @@
|
||||||
import re
|
import re
|
||||||
|
from typing import Dict, Tuple, Optional
|
||||||
|
|
||||||
FLAKE_CONFIG_PATH = "/etc/nixos/sp-modules/flake.nix"
|
FLAKE_CONFIG_PATH = "/etc/nixos/sp-modules/flake.nix"
|
||||||
|
|
||||||
|
|
||||||
class FlakeServiceManager:
|
class FlakeServiceManager:
|
||||||
def __enter__(self):
|
def __enter__(self) -> "FlakeServiceManager":
|
||||||
self.services = {}
|
self.services = {}
|
||||||
|
|
||||||
with open(FLAKE_CONFIG_PATH, "r") as file:
|
with open(FLAKE_CONFIG_PATH, "r") as file:
|
||||||
|
@ -15,7 +16,9 @@ class FlakeServiceManager:
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def _extract_services(self, input_string: str):
|
def _extract_services(
|
||||||
|
self, input_string: str
|
||||||
|
) -> Tuple[Optional[str], Optional[str]]:
|
||||||
pattern = r"inputs\.(\w+)\.url\s*=\s*(\S+);"
|
pattern = r"inputs\.(\w+)\.url\s*=\s*(\S+);"
|
||||||
match = re.search(pattern, input_string)
|
match = re.search(pattern, input_string)
|
||||||
|
|
||||||
|
@ -26,7 +29,7 @@ class FlakeServiceManager:
|
||||||
else:
|
else:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback) -> None:
|
||||||
with open(FLAKE_CONFIG_PATH, "w") as file:
|
with open(FLAKE_CONFIG_PATH, "w") as file:
|
||||||
file.write(
|
file.write(
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue