Merge pull request #3 from eigenmagic/main

Bring in changes from upstream
This commit is contained in:
Shawn Grigson 2023-09-06 16:29:06 -05:00 committed by GitHub
commit c06f4a9b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -363,6 +363,11 @@ The filename is based on the URL or domain used so you can tell where each list
Sets where to save intermediate blocklist files. Defaults to `/tmp`.
### blocklist_auditfile
If provided, will save an audit file of counts and percentages by domain. Useful for debugging
thresholds. Defaults to None.
### no_push_instance
Defaults to False.

View File

@ -184,7 +184,7 @@ def fetch_from_instances(sources: dict,
def merge_blocklists(blocklists: list[Blocklist], mergeplan: str='max',
threshold: int=0,
threshold_type: str='count',
save_block_audit_file: str='') -> Blocklist:
save_block_audit_file: str=None) -> Blocklist:
"""Merge fetched remote blocklists into a bulk update
@param blocklists: A dict of lists of DomainBlocks, keyed by source.
Each value is a list of DomainBlocks
@ -242,7 +242,7 @@ def merge_blocklists(blocklists: list[Blocklist], mergeplan: str='max',
block = apply_mergeplan(block, newblock, mergeplan)
merged.blocks[block.domain] = block
if len(save_block_audit_file) > 0:
if save_block_audit_file:
blockdata:BlockAudit = {
'domain': domain,
'count': domain_matches_count,
@ -250,7 +250,7 @@ def merge_blocklists(blocklists: list[Blocklist], mergeplan: str='max',
}
audit.blocks[domain] = blockdata
if len(save_block_audit_file) > 0:
if save_block_audit_file:
log.info(f"Saving audit file to {save_block_audit_file}")
save_domain_block_audit_to_file(audit, save_block_audit_file)
@ -746,7 +746,7 @@ def augment_args(args, tomldata: str=None):
args.savedir = conf.get('savedir', '/tmp')
if not args.blocklist_auditfile:
args.blocklist_auditfile = conf.get('blocklist_auditfile', '')
args.blocklist_auditfile = conf.get('blocklist_auditfile', None)
if not args.export_fields:
args.export_fields = conf.get('export_fields', [])