mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 16:23:36 +05:00
feat: implement conversion of camel case to kebab case
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -140,7 +140,9 @@ class BaseInstance(ABC):
|
|||||||
_dir.mkdir(exist_ok=True)
|
_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
def get_service_file_name(self, extension: bool = False) -> str:
|
def get_service_file_name(self, extension: bool = False) -> str:
|
||||||
name = f"{self.__class__.__name__.lower()}"
|
from utils.common import convert_camelcase_to_kebabcase
|
||||||
|
|
||||||
|
name = convert_camelcase_to_kebabcase(self.__class__.__name__)
|
||||||
if self.suffix != "":
|
if self.suffix != "":
|
||||||
name += f"-{self.suffix}"
|
name += f"-{self.suffix}"
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,9 @@ class InstanceManager:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def find_instances(self) -> List[T]:
|
def find_instances(self) -> List[T]:
|
||||||
name = self.instance_type.__name__.lower()
|
from utils.common import convert_camelcase_to_kebabcase
|
||||||
|
|
||||||
|
name = convert_camelcase_to_kebabcase(self.instance_type.__name__)
|
||||||
pattern = re.compile(f"^{name}(-[0-9a-zA-Z]+)?.service$")
|
pattern = re.compile(f"^{name}(-[0-9a-zA-Z]+)?.service$")
|
||||||
excluded = self.instance_type.blacklist()
|
excluded = self.instance_type.blacklist()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, Literal, List, Type, Union
|
from typing import Dict, Literal, List, Type, Union
|
||||||
@@ -30,6 +30,10 @@ from utils.sys_utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def convert_camelcase_to_kebabcase(name: str) -> str:
|
||||||
|
return re.sub(r"(?<!^)(?=[A-Z])", "-", name).lower()
|
||||||
|
|
||||||
|
|
||||||
def get_current_date() -> Dict[Literal["date", "time"], str]:
|
def get_current_date() -> Dict[Literal["date", "time"], str]:
|
||||||
"""
|
"""
|
||||||
Get the current date |
|
Get the current date |
|
||||||
|
|||||||
Reference in New Issue
Block a user