aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornico <nico@magicbroccoli.de>2018-12-22 14:57:13 +0100
committernico <nico@magicbroccoli.de>2018-12-22 14:57:13 +0100
commite9208a82770ca23bf74ec52f64402420fe03ecf5 (patch)
tree0871afd4f474ba7e0384b5a99101a3a162de8cca
parentaf5f1e494d895685916df7d68faa8a4329c9ec8c (diff)
yaml is crazy
- removed PyYAML from requirements * TODO remove try statements
-rw-r--r--main.py12
-rw-r--r--requirements.txt1
2 files changed, 5 insertions, 8 deletions
diff --git a/main.py b/main.py
index 949a80b..ae5f562 100644
--- a/main.py
+++ b/main.py
@@ -8,7 +8,6 @@ import requests
import os
import sys
import argparse
-import yaml
from ruamel.yaml import YAML, scalarstring
@@ -69,12 +68,11 @@ class BlacklistImporter:
os.system("ejabberdctl reload_config")
def process(self):
- # check if file was altered
- local_file = None
+ # init new YAML variable
+ local_file = YAML(typ="safe")
try:
- if os.path.isfile(self.outfile):
- local_file = yaml.load(open(self.outfile, "r", encoding="utf-8"))
- except TypeError:
+ local_file = local_file.load(open(self.outfile, "r", encoding="utf-8"))
+ except FileNotFoundError:
pass
remote_file = {
@@ -99,7 +97,7 @@ class BlacklistImporter:
elif local_file != remote_file:
self.change = True
- # only if the local_file and remote_file are different write new file
+ # only if the local_file and remote_file are unequal write new file
yml.dump(remote_file, open(self.outfile, "w"))
diff --git a/requirements.txt b/requirements.txt
index 6d82745..660749a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,2 @@
-PyYAML>=3.1.3
ruamel.yaml>=0.15.80
requests>=2.21.0