yaml is crazy
- removed PyYAML from requirements * TODO remove try statements
This commit is contained in:
parent
af5f1e494d
commit
e9208a8277
12
main.py
12
main.py
|
@ -8,7 +8,6 @@ import requests
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import yaml
|
|
||||||
from ruamel.yaml import YAML, scalarstring
|
from ruamel.yaml import YAML, scalarstring
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,12 +68,11 @@ class BlacklistImporter:
|
||||||
os.system("ejabberdctl reload_config")
|
os.system("ejabberdctl reload_config")
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
# check if file was altered
|
# init new YAML variable
|
||||||
local_file = None
|
local_file = YAML(typ="safe")
|
||||||
try:
|
try:
|
||||||
if os.path.isfile(self.outfile):
|
local_file = local_file.load(open(self.outfile, "r", encoding="utf-8"))
|
||||||
local_file = yaml.load(open(self.outfile, "r", encoding="utf-8"))
|
except FileNotFoundError:
|
||||||
except TypeError:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
remote_file = {
|
remote_file = {
|
||||||
|
@ -99,7 +97,7 @@ class BlacklistImporter:
|
||||||
|
|
||||||
elif local_file != remote_file:
|
elif local_file != remote_file:
|
||||||
self.change = True
|
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"))
|
yml.dump(remote_file, open(self.outfile, "w"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
PyYAML>=3.1.3
|
|
||||||
ruamel.yaml>=0.15.80
|
ruamel.yaml>=0.15.80
|
||||||
requests>=2.21.0
|
requests>=2.21.0
|
||||||
|
|
Loading…
Reference in New Issue