diff --git a/README.md b/README.md index 89062bd..bdd295c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/fediblockhole/__init__.py b/src/fediblockhole/__init__.py index 01e6a96..aec0a08 100755 --- a/src/fediblockhole/__init__.py +++ b/src/fediblockhole/__init__.py @@ -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', [])