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: class Generator:
def __init__(self): def __init__(self):
...@@ -6,13 +6,7 @@ class Generator: ...@@ -6,13 +6,7 @@ class Generator:
self.conf_gen = ConfigGenerator() self.conf_gen = ConfigGenerator()
def get_conf_dirs(self): def get_conf_dirs(self):
config = Config() return MAPS_DIR, CONFIG_DIR
config.read_config()
maps_dir = config.get_default_dir('MAPS_DIR')
config_dir = config.get_default_dir('CONFIG_DIR')
return maps_dir, config_dir
def generate(self, redirects_data, project_name): def generate(self, redirects_data, project_name):
...@@ -23,7 +17,7 @@ class Generator: ...@@ -23,7 +17,7 @@ class Generator:
maps_dir, config_dir = self.get_conf_dirs() maps_dir, config_dir = self.get_conf_dirs()
try: 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) map_file.write(redirects_map)
for code, data in redirects_with_options: for code, data in redirects_with_options:
if code == "301": if code == "301":
...@@ -95,5 +89,4 @@ class ConfigGenerator: ...@@ -95,5 +89,4 @@ class ConfigGenerator:
else: else:
data += (self.opt_start_line % (project_name, code)) + (self.opt_rewrite_line % (project_name, project_name, code, "break")) + (self.option_line % code) data += (self.opt_start_line % (project_name, code)) + (self.opt_rewrite_line % (project_name, project_name, code, "break")) + (self.option_line % code)
return data 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