Changed files generation and fixed bugs for testing

parent b8285f03
......@@ -5,7 +5,7 @@ EMAIL = "enk@etersoft.ru"
PYTHON_VERSION = "3.6"
VERSION_STATUS = "alpha"
REDIRECTOR_DIR = "/root/redirector" # /home/enk
NGINX_DIR = "/etc/nginx" # /home/enk
CONFIG_YAML = '/etc/redirector/config.yaml'
MAPS_DIR = REDIRECTOR_DIR + "/maps"
CONFIG_DIR = REDIRECTOR_DIR + "/location-includes"
MAPS_DIR = NGINX_DIR + "/maps"
CONFIG_DIR = NGINX_DIR + "/location-includes"
class MapGenerator:
def __init__(self):
self.start_lines = [
"map $uri $%s-redirect {",
"\nmap $uri $%s-option-redirect {",
"\nmap $uri $%s-option {"
]
self.start_line = "map $uri $%s_redirect {"
self.codes_dict = {'301':"permanent", '302':'redirect'}
self.endline = "\n}"
def generate_map(self, redirects_sorted, project_name):
data = ""
for i, map_type in enumerate(self.start_lines):
data += map_type % project_name
for arg1, arg2 in redirects_sorted[i]:
data += "\n\t%s\t%s;" % (arg1, arg2)
data += self.endline
data = self.start_line % project_name
for arg1, arg2 in redirects_sorted[0]:
data += "\n\t%s\t%s;" % (arg1, arg2)
for arg1, arg2 in redirects_sorted[1]:
data += "\n\t%s\t%s;" % (arg1, arg2)
"""
for i, args in enumerate(redirects_sorted[1]):
try:
key_ = redirects_sorted[2][i]
except KeyError:
key_ = None
data = "\n\t%s\t%s;" % (args[0], args[1]) if not key_
else "\n\t%s\t%s\t%s;" % (args[0], args[1], key_)
"""
data += self.endline
return data
class ConfigGenerator:
def __init__(self):
self.start_line = "if($%s-redirect) {\n"
self.rewrite_line = "\trewrite ^/%s/(.^)$ $%s-redirect redirect;\n}"
self.start_line = "if ($%s_redirect) {\n"
self.rewrite_line = "\trewrite ^/%s/(.^)$ $%s_redirect redirect;\n}"
def generate_conf(self, project_name):
return (self.start_line % project_name) + (self.rewrite_line % (project_name, project_name))
......
import os
from setuptools import setup, find_packages
from core import const
from dev import const
classifiers_list = [
"Development Status :: 4 - Beta",
......
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