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