fix: load remote blocklist for export and fix diff with toml input
This commit is contained in:
		@@ -12,6 +12,10 @@ from fediverse_blocklist_deploy.helpers import blocklist_to_markdown, blocklist_
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def load_blocklist_file(filename: str) -> [Instance]:
 | 
					def load_blocklist_file(filename: str) -> [Instance]:
 | 
				
			||||||
 | 
					    if filename.endswith("json"):
 | 
				
			||||||
 | 
					        with open(filename) as f:
 | 
				
			||||||
 | 
					            instances = blocklist_json_to_instances(json.load(f))
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
        with open(filename, "r") as f:
 | 
					        with open(filename, "r") as f:
 | 
				
			||||||
            data = toml.load(f)
 | 
					            data = toml.load(f)
 | 
				
			||||||
        instances = []
 | 
					        instances = []
 | 
				
			||||||
@@ -121,11 +125,10 @@ def cli():
 | 
				
			|||||||
        token = os.getenv('MBD_TOKEN')
 | 
					        token = os.getenv('MBD_TOKEN')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """Get a remote blocklist only when necessary"""
 | 
					    """Get a remote blocklist only when necessary"""
 | 
				
			||||||
    if args.action in ["diff", "deploy"]:
 | 
					    if args.action in ["diff", "deploy", "export"]:
 | 
				
			||||||
        """if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
 | 
					        """if there is a remote blocklist provided load this instead of fetching it from a server (for debugging reasons)"""
 | 
				
			||||||
        if args.remote_blocklist:
 | 
					        if args.remote_blocklist:
 | 
				
			||||||
            with open(args.remote_blocklist) as f:
 | 
					            remote_blocklist = load_blocklist_file(args.remote_blocklist)
 | 
				
			||||||
                remote_blocklist = blocklist_json_to_instances(json.load(f))
 | 
					 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            remote_blocklist = load_blocklist_from_instance(server=args.server, token=token)
 | 
					            remote_blocklist = load_blocklist_from_instance(server=args.server, token=token)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user