mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-04 14:57:56 +10:00
add new pydantic_settings based loader for ConfigSets
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import platform
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Dict, Any
|
||||
from typing_extensions import Self
|
||||
from typing import List, Optional, Dict, ClassVar
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
@@ -79,7 +78,7 @@ def create_macos_app_symlink(target: Path, shortcut: Path):
|
||||
|
||||
|
||||
class ChromeDependencyConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'DEPENDENCY_CONFIG'
|
||||
section: ClassVar[ConfigSectionName] = "DEPENDENCY_CONFIG"
|
||||
|
||||
CHROME_BINARY: str = Field(default='chrome')
|
||||
CHROME_ARGS: Optional[List[str]] = Field(default=None)
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import sys
|
||||
import inspect
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Optional
|
||||
from typing import List, Dict, Optional, ClassVar
|
||||
from pydantic import InstanceOf, Field
|
||||
|
||||
import django
|
||||
@@ -23,7 +23,7 @@ from plugantic.base_hook import BaseHook
|
||||
|
||||
|
||||
class PipDependencyConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'DEPENDENCY_CONFIG'
|
||||
section: ClassVar[ConfigSectionName] = "DEPENDENCY_CONFIG"
|
||||
|
||||
USE_PIP: bool = True
|
||||
PIP_BINARY: str = Field(default='pip')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
__package__ = 'archivebox.builtin_plugins.singlefile'
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List, Dict, Optional
|
||||
from typing import List, Dict, Optional, ClassVar
|
||||
from typing_extensions import Self
|
||||
|
||||
from django.conf import settings
|
||||
@@ -25,13 +25,13 @@ from builtin_plugins.npm.apps import SYS_NPM_BINPROVIDER, LIB_NPM_BINPROVIDER
|
||||
###################### Config ##########################
|
||||
|
||||
class SinglefileToggleConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'ARCHIVE_METHOD_TOGGLES'
|
||||
section: ClassVar[ConfigSectionName] = 'ARCHIVE_METHOD_TOGGLES'
|
||||
|
||||
SAVE_SINGLEFILE: bool = True
|
||||
|
||||
|
||||
class SinglefileOptionsConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'ARCHIVE_METHOD_OPTIONS'
|
||||
section: ClassVar[ConfigSectionName] = 'ARCHIVE_METHOD_OPTIONS'
|
||||
|
||||
# loaded from shared config
|
||||
SINGLEFILE_USER_AGENT: str = Field(default='', alias='USER_AGENT')
|
||||
@@ -42,7 +42,7 @@ class SinglefileOptionsConfigs(BaseConfigSet):
|
||||
|
||||
|
||||
class SinglefileDependencyConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'DEPENDENCY_CONFIG'
|
||||
section: ClassVar[ConfigSectionName] = 'DEPENDENCY_CONFIG'
|
||||
|
||||
SINGLEFILE_BINARY: str = Field(default='wget')
|
||||
SINGLEFILE_ARGS: Optional[List[str]] = Field(default=None)
|
||||
@@ -50,7 +50,7 @@ class SinglefileDependencyConfigs(BaseConfigSet):
|
||||
SINGLEFILE_DEFAULT_ARGS: List[str] = ['--timeout={TIMEOUT-10}']
|
||||
|
||||
class SinglefileConfigs(SinglefileToggleConfigs, SinglefileOptionsConfigs, SinglefileDependencyConfigs):
|
||||
# section: ConfigSectionName = 'ALL_CONFIGS'
|
||||
# section: ClassVar[ConfigSectionName] = 'ALL_CONFIGS'
|
||||
pass
|
||||
|
||||
DEFAULT_GLOBAL_CONFIG = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import List, Dict
|
||||
from typing import List, Dict, ClassVar
|
||||
from subprocess import run, PIPE
|
||||
from pydantic import InstanceOf, Field
|
||||
|
||||
@@ -16,7 +16,7 @@ from builtin_plugins.pip.apps import pip
|
||||
|
||||
|
||||
class YtdlpDependencyConfigs(BaseConfigSet):
|
||||
section: ConfigSectionName = 'DEPENDENCY_CONFIG'
|
||||
section: ClassVar[ConfigSectionName] = "DEPENDENCY_CONFIG"
|
||||
|
||||
USE_YTDLP: bool = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user