Move config object to variables.py

- Initialized in main.py
- This way the configuration is available for all modules
This commit is contained in:
Fabian Würfl
2018-05-26 10:56:23 +02:00
parent 07234fb640
commit 432aaa856c
3 changed files with 46 additions and 52 deletions

10
util.py
View File

@ -7,17 +7,15 @@ import variables as var
import zipfile
def get_recursive_filelist_sorted(path):
global __CONFIG
filelist = []
for root, dirs, files in os.walk(path):
relroot = root.replace(path, '')
if relroot != '' and relroot in __CONFIG.get('bot', 'ignored_folders'):
if relroot != '' and relroot in var.config.get('bot', 'ignored_folders'):
continue
if len(relroot):
relroot += '/'
for file in files:
if file in __CONFIG.get('bot', 'ignored_files'):
if file in var.config.get('bot', 'ignored_files'):
continue
fullpath = os.path.join(path, relroot, file)
@ -36,9 +34,7 @@ def get_recursive_filelist_sorted(path):
# - hash is a sha1 of the string representation of the directories' contents (which are
# zipped)
def zipdir(zippath, zipname_prefix=None):
global __CONFIG
zipname = __CONFIG.get('bot', 'tmp_folder')
zipname = var.config.get('bot', 'tmp_folder')
if zipname_prefix and '../' not in zipname_prefix:
zipname += zipname_prefix.strip().replace('/', '_') + '_'