kopia lustrzana https://github.com/bellingcat/auto-archiver
rodzic
40488e0869
commit
eda359a1ef
|
@ -68,7 +68,7 @@ def generate_module_docs():
|
|||
config_yaml = {}
|
||||
for key, value in manifest['configs'].items():
|
||||
type = value.get('type', 'string')
|
||||
if type == 'auto_archiver.utils.json_loader':
|
||||
if type == 'json_loader':
|
||||
value['type'] = 'json'
|
||||
elif type == 'str':
|
||||
type = "string"
|
||||
|
|
|
@ -208,7 +208,7 @@ def read_yaml(yaml_filename: str) -> CommentedMap:
|
|||
pass
|
||||
|
||||
if not config:
|
||||
config = EMPTY_CONFIG
|
||||
config = deepcopy(EMPTY_CONFIG)
|
||||
|
||||
return config
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# used as validators for config values. Should raise an exception if the value is invalid.
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import json
|
||||
|
||||
def example_validator(value):
|
||||
if "example" not in value:
|
||||
|
@ -17,3 +18,6 @@ def valid_file(value):
|
|||
if not Path(value).is_file():
|
||||
raise argparse.ArgumentTypeError(f"File '{value}' does not exist.")
|
||||
return value
|
||||
|
||||
def json_loader(cli_val):
|
||||
return json.loads(cli_val)
|
|
@ -35,7 +35,7 @@
|
|||
"replaywebpage": "replaywebpage",
|
||||
},
|
||||
"help": "names of columns in the google sheet (stringified JSON object)",
|
||||
"type": "auto_archiver.utils.json_loader",
|
||||
"type": "json_loader",
|
||||
},
|
||||
"allow_worksheets": {
|
||||
"default": set(),
|
||||
|
|
|
@ -24,9 +24,8 @@ class GsheetsFeeder(Feeder):
|
|||
def setup(self) -> None:
|
||||
self.gsheets_client = gspread.service_account(filename=self.service_account)
|
||||
# TODO mv to validators
|
||||
assert self.sheet or self.sheet_id, (
|
||||
"You need to define either a 'sheet' name or a 'sheet_id' in your manifest."
|
||||
)
|
||||
if not (self.sheet or self.sheet_id):
|
||||
raise ValueError("You need to define either a 'sheet' name or a 'sheet_id' in your manifest.")
|
||||
|
||||
def open_sheet(self):
|
||||
if self.sheet:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"channel_invites": {
|
||||
"default": {},
|
||||
"help": "(JSON string) private channel invite links (format: t.me/joinchat/HASH OR t.me/+HASH) and (optional but important to avoid hanging for minutes on startup) channel id (format: CHANNEL_ID taken from a post url like https://t.me/c/CHANNEL_ID/1), the telegram account will join any new channels on setup",
|
||||
"type": "auto_archiver.utils.json_loader",
|
||||
"type": "json_loader",
|
||||
}
|
||||
},
|
||||
"description": """
|
||||
|
|
|
@ -59,10 +59,6 @@ def random_str(length: int = 32) -> str:
|
|||
return str(uuid.uuid4()).replace("-", "")[:length]
|
||||
|
||||
|
||||
def json_loader(cli_val):
|
||||
return json.loads(cli_val)
|
||||
|
||||
|
||||
def calculate_file_hash(filename: str, hash_algo = hashlib.sha256, chunksize: int = 16000000) -> str:
|
||||
hash = hash_algo()
|
||||
with open(filename, "rb") as f:
|
||||
|
|
Ładowanie…
Reference in New Issue