Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
bc7c6077
Commit
bc7c6077
authored
Jun 05, 2021
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use constants instead of config.ini
parent
49525a74
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
10 deletions
+3
-10
generators.py
redirector/utils/generators.py
+3
-10
No files found.
redirector/utils/generators.py
View file @
bc7c6077
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"
:
...
...
@@ -96,4 +90,3 @@ class ConfigGenerator:
data
+=
(
self
.
opt_start_line
%
(
project_name
,
code
))
+
(
self
.
opt_rewrite_line
%
(
project_name
,
project_name
,
code
,
"break"
))
+
(
self
.
option_line
%
code
)
return
data
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment