[feat] Extension Builder (#3339)
This commit is contained in:
+30
-1
@@ -53,7 +53,12 @@ def static_url_for(static: str, path: str) -> str:
|
||||
|
||||
|
||||
def template_renderer(additional_folders: list | None = None) -> Jinja2Templates:
|
||||
folders = ["lnbits/templates", "lnbits/core/templates"]
|
||||
folders = [
|
||||
"lnbits/templates",
|
||||
"lnbits/core/templates",
|
||||
settings.extension_builder_working_dir_path.as_posix(),
|
||||
]
|
||||
|
||||
if additional_folders:
|
||||
additional_folders += [
|
||||
Path(settings.lnbits_extensions_path, "extensions", f)
|
||||
@@ -368,3 +373,27 @@ def normalize_endpoint(endpoint: str, add_proto=True) -> str:
|
||||
f"https://{endpoint}" if not endpoint.startswith("http") else endpoint
|
||||
)
|
||||
return endpoint
|
||||
|
||||
|
||||
def camel_to_words(name: str) -> str:
|
||||
# Add space before capital letters (but not at the start)
|
||||
words = re.sub(r"(?<!^)(?=[A-Z])", " ", name)
|
||||
return words.strip()
|
||||
|
||||
|
||||
def camel_to_snake(name: str) -> str:
|
||||
name = re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", name)
|
||||
name = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name)
|
||||
return name.lower()
|
||||
|
||||
|
||||
def is_camel_case(v: str) -> bool:
|
||||
return re.match(r"^[A-Z][a-z0-9]+([A-Z][a-z0-9]+)*$", v) is not None
|
||||
|
||||
|
||||
def is_snake_case(v: str) -> bool:
|
||||
return re.match(r"^[a-z]+(_[a-z0-9]+)*$", v) is not None
|
||||
|
||||
|
||||
def lowercase_first_letter(s: str) -> str:
|
||||
return s[:1].lower() + s[1:] if s else s
|
||||
|
||||
Reference in New Issue
Block a user