packaging: various smaller fixes and corrections

- remove placeholder print statements
* replace wildcard import with a direct one
* rename main class to blimp
* optimized imports
This commit is contained in:
nico 2021-03-28 16:39:58 +02:00
parent 3e8a728fe7
commit c9e689b3f3
Signed by: mightyBroccoli
GPG Key ID: 1F6495B44DABCE6E
5 changed files with 19 additions and 25 deletions

View File

@ -4,11 +4,11 @@
# version
__version__ = "0.1"
# main
from .main import BlacklistImporter
# modules
from .bl_process import ProcessBlocklist
# main
from .main import Blimp
# utils
from .misc import *

View File

@ -6,7 +6,12 @@ from ruamel.yaml import YAML, scalarstring
from .misc import *
class ProcessBlocklist:
def __init__(self):
pass
@classmethod
def process(self, blacklist, outfile, dryrun: bool):
"""
function to build and compare the local yaml file to the remote file
@ -19,8 +24,6 @@ class ProcessBlocklist:
with open(outfile, "r", encoding="utf-8") as local_file:
local_blacklist = local_file.read()
print("step local file")
except TypeError:
# no local copy use empty one instead
local_blacklist = YAML(typ="safe")

View File

@ -3,7 +3,7 @@
import argparse
from .main import BlacklistImporter
from .main import Blimp
def cli():
@ -13,4 +13,4 @@ def cli():
args = parser.parse_args()
# run
BlacklistImporter(args).main()
Blimp(args).main()

View File

@ -1,16 +1,14 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import requests
from appdirs import *
from appdirs import user_cache_dir
from .bl_process import ProcessBlocklist
from .misc import *
class BlacklistImporter:
class Blimp:
def __init__(self, args):
self.outfile = args.outfile
self.dryrun = args.dry_run
@ -89,9 +87,10 @@ class BlacklistImporter:
self.start_request()
# blacklist processing
ProcessBlocklist().process(self.blacklist, self.outfile, self.dryrun)
ProcessBlocklist.process(self.blacklist, self.outfile, self.dryrun)
"""# reload config if changes have been applied
"""
# reload config if changes have been applied
if self.change:
# catch ejabberdctl missing
if Path("/usr/sbin/ejabberdctl").is_file():
@ -102,14 +101,9 @@ class BlacklistImporter:
print("/usr/sbin/ejabberdctl was not found", file=sys.stderr)
print("blacklist changes have been applied\nejabberd config was not reloaded", file=sys.stderr)
sys.exit(1)
"""
"""
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-out", "--outfile", help="set path to output file", action="store", default=None)
parser.add_argument("-dr", "--dry-run", help="perform a dry run", action="store_true", default=False)
args = parser.parse_args()
# run
BlacklistImporter(args).main()
from .cli import cli
cli()

View File

@ -5,13 +5,10 @@ from pathlib import Path
def local_file_present(somepath) -> bool:
"""
check local etag copy
check if a given local filepath exists
:return: true if present
"""
if not Path(somepath).is_file():
return False
return True
def asd():
print("yo")