Remove custom config file path

This commit is contained in:
yoshiko2
2021-05-04 20:08:55 +08:00
parent 3f5a7a0f52
commit 7f51ba1514
2 changed files with 20 additions and 15 deletions

View File

@@ -1,8 +1,8 @@
import os
import sys
import configparser
import codecs
class Config:
def __init__(self, path: str = "config.ini"):
if os.path.exists(path):
@@ -12,16 +12,20 @@ class Config:
except:
self.conf.read(path, encoding="utf-8")
else:
try:
self.conf = configparser.ConfigParser()
try: # From single crawler debug use only
self.conf.read('../' + path, encoding="utf-8-sig")
except:
self.conf.read('../' + path, encoding="utf-8")
except Exception as e:
print("[-]Config file not found! Use the default settings")
print("[-]",e)
self.conf = self._default_config()
print("[-]Config file not found!")
sys.exit(3)
# self.conf = self._default_config()
# try:
# self.conf = configparser.ConfigParser()
# try: # From single crawler debug use only
# self.conf.read('../' + path, encoding="utf-8-sig")
# except:
# self.conf.read('../' + path, encoding="utf-8")
# except Exception as e:
# print("[-]Config file not found! Use the default settings")
# print("[-]",e)
# sys.exit(3)
# #self.conf = self._default_config()
def main_mode(self) -> str:
try: