aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authornico wellpott <nico@magicbroccoli.de>2021-03-28 16:39:58 +0200
committernico wellpott <nico@magicbroccoli.de>2021-03-28 16:39:58 +0200
commitc9e689b3f3d043933ea953448832c8cc718cd28f (patch)
treeec6743afca52b550153b11fbc1b86d5fe96812a1 /src
parent3e8a728fe751cfb02a34e3d72730dc4d6ee1a7cb (diff)
packaging: various smaller fixes and corrections
- remove placeholder print statements * replace wildcard import with a direct one * rename main class to blimp * optimized imports
Diffstat (limited to 'src')
-rw-r--r--src/blimp/__init__.py6
-rw-r--r--src/blimp/bl_process.py7
-rw-r--r--src/blimp/cli.py4
-rw-r--r--src/blimp/main.py22
-rw-r--r--src/blimp/misc.py5
5 files changed, 19 insertions, 25 deletions
diff --git a/src/blimp/__init__.py b/src/blimp/__init__.py
index 5486de7..769e3ce 100644
--- a/src/blimp/__init__.py
+++ b/src/blimp/__init__.py
@@ -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 *
diff --git a/src/blimp/bl_process.py b/src/blimp/bl_process.py
index e1d8c93..2e56275 100644
--- a/src/blimp/bl_process.py
+++ b/src/blimp/bl_process.py
@@ -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")
diff --git a/src/blimp/cli.py b/src/blimp/cli.py
index b462918..12bd1dc 100644
--- a/src/blimp/cli.py
+++ b/src/blimp/cli.py
@@ -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()
diff --git a/src/blimp/main.py b/src/blimp/main.py
index 5d4c3ac..4189bbc 100644
--- a/src/blimp/main.py
+++ b/src/blimp/main.py
@@ -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()
diff --git a/src/blimp/misc.py b/src/blimp/misc.py
index d25c8d7..528ed5b 100644
--- a/src/blimp/misc.py
+++ b/src/blimp/misc.py
@@ -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")