config_stubs.py 3.0 KB

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