Use constants instead of config.ini

parent 49525a74
from redirector.conf.config import Config
from redirector.utils.const import MAPS_DIR, CONFIG_DIR
class Generator:
def __init__(self):
......@@ -6,13 +6,7 @@ class Generator:
self.conf_gen = ConfigGenerator()
def get_conf_dirs(self):
config = Config()
config.read_config()
maps_dir = config.get_default_dir('MAPS_DIR')
config_dir = config.get_default_dir('CONFIG_DIR')
return maps_dir, config_dir
return MAPS_DIR, CONFIG_DIR
def generate(self, redirects_data, project_name):
......@@ -23,7 +17,7 @@ class Generator:
maps_dir, config_dir = self.get_conf_dirs()
try:
with open(maps_dir + "/%s.map" % project_name, "w") as map_file:
with open(f"{maps_dir}/{project_name}.map", "w") as map_file:
map_file.write(redirects_map)
for code, data in redirects_with_options:
if code == "301":
......@@ -95,5 +89,4 @@ class ConfigGenerator:
else:
data += (self.opt_start_line % (project_name, code)) + (self.opt_rewrite_line % (project_name, project_name, code, "break")) + (self.option_line % code)
return data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment