config_stubs.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. from pathlib import Path
  2. from typing import Optional, Dict, Union, Tuple, Callable, Pattern, Type, Any, List
  3. from mypy_extensions import TypedDict
  4. SimpleConfigValue = Union[str, bool, int, None, Pattern, Dict[str, Any]]
  5. SimpleConfigValueDict = Dict[str, SimpleConfigValue]
  6. SimpleConfigValueGetter = Callable[[], SimpleConfigValue]
  7. ConfigValue = Union[SimpleConfigValue, SimpleConfigValueDict, SimpleConfigValueGetter]
  8. class AttrDict(dict):
  9. def __init__(self, *args, **kwargs):
  10. super().__init__(*args, **kwargs)
  11. self.__dict__ = self
  12. class BaseConfig(TypedDict):
  13. pass
  14. class ConfigDict(BaseConfig, AttrDict, total=False):
  15. """
  16. # Regenerate by pasting this quine into `archivebox shell` 🥚
  17. from archivebox.config import ConfigDict, CONFIG_DEFAULTS
  18. print('class ConfigDict(BaseConfig, total=False):')
  19. print(' ' + '"'*3 + ConfigDict.__doc__ + '"'*3)
  20. for section, configs in CONFIG_DEFAULTS.items():
  21. for key, attrs in configs.items():
  22. Type, default = attrs['type'], attrs['default']
  23. if default is None:
  24. print(f' {key}: Optional[{Type.__name__}]')
  25. else:
  26. print(f' {key}: {Type.__name__}')
  27. print()
  28. """
  29. IS_TTY: bool
  30. USE_COLOR: bool
  31. SHOW_PROGRESS: bool
  32. IN_DOCKER: bool
  33. PACKAGE_DIR: Path
  34. OUTPUT_DIR: Path
  35. CONFIG_FILE: Path
  36. ONLY_NEW: bool
  37. TIMEOUT: int
  38. MEDIA_TIMEOUT: int
  39. OUTPUT_PERMISSIONS: str
  40. RESTRICT_FILE_NAMES: str
  41. URL_DENYLIST: str
  42. SECRET_KEY: Optional[str]
  43. BIND_ADDR: str
  44. ALLOWED_HOSTS: str
  45. DEBUG: bool
  46. PUBLIC_INDEX: bool
  47. PUBLIC_SNAPSHOTS: bool
  48. FOOTER_INFO: str
  49. SAVE_TITLE: bool
  50. SAVE_FAVICON: bool
  51. SAVE_WGET: bool
  52. SAVE_WGET_REQUISITES: bool
  53. SAVE_SINGLEFILE: bool
  54. SAVE_READABILITY: bool
  55. SAVE_MERCURY: bool
  56. SAVE_PDF: bool
  57. SAVE_SCREENSHOT: bool
  58. SAVE_DOM: bool
  59. SAVE_WARC: bool
  60. SAVE_GIT: bool
  61. SAVE_MEDIA: bool
  62. SAVE_ARCHIVE_DOT_ORG: bool
  63. RESOLUTION: str
  64. GIT_DOMAINS: str
  65. CHECK_SSL_VALIDITY: bool
  66. CURL_USER_AGENT: str
  67. WGET_USER_AGENT: str
  68. CHROME_USER_AGENT: str
  69. COOKIES_FILE: Union[str, Path, None]
  70. CHROME_USER_DATA_DIR: Union[str, Path, None]
  71. CHROME_TIMEOUT: int
  72. CHROME_HEADLESS: bool
  73. CHROME_SANDBOX: bool
  74. USE_CURL: bool
  75. USE_WGET: bool
  76. USE_SINGLEFILE: bool
  77. USE_READABILITY: bool
  78. USE_MERCURY: bool
  79. USE_GIT: bool
  80. USE_CHROME: bool
  81. USE_YOUTUBEDL: bool
  82. CURL_BINARY: str
  83. GIT_BINARY: str
  84. WGET_BINARY: str
  85. SINGLEFILE_BINARY: str
  86. READABILITY_BINARY: str
  87. MERCURY_BINARY: str
  88. YOUTUBEDL_BINARY: str
  89. CHROME_BINARY: Optional[str]
  90. YOUTUBEDL_ARGS: List[str]
  91. WGET_ARGS: List[str]
  92. CURL_ARGS: List[str]
  93. GIT_ARGS: List[str]
  94. TAG_SEPARATOR_PATTERN: str
  95. ConfigDefaultValueGetter = Callable[[ConfigDict], ConfigValue]
  96. ConfigDefaultValue = Union[ConfigValue, ConfigDefaultValueGetter]
  97. ConfigDefault = TypedDict('ConfigDefault', {
  98. 'default': ConfigDefaultValue,
  99. 'type': Optional[Type],
  100. 'aliases': Optional[Tuple[str, ...]],
  101. }, total=False)
  102. ConfigDefaultDict = Dict[str, ConfigDefault]