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
404580b9
You need to sign in or sign up before continuing.
Commit
404580b9
authored
Jun 25, 2020
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update parser.py: fix path for every input params
parent
179ade80
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
11 additions
and
8 deletions
+11
-8
const.cpython-38.pyc
redirector/__pycache__/const.cpython-38.pyc
+0
-0
generators.cpython-38.pyc
redirector/__pycache__/generators.cpython-38.pyc
+0
-0
logger.cpython-38.pyc
redirector/__pycache__/logger.cpython-38.pyc
+0
-0
parser.cpython-38.pyc
redirector/__pycache__/parser.cpython-38.pyc
+0
-0
const.py
redirector/const.py
+3
-3
parser.py
redirector/parser.py
+7
-2
test.yaml
tests/test.yaml
+1
-3
No files found.
redirector/__pycache__/const.cpython-38.pyc
0 → 100644
View file @
404580b9
File added
redirector/__pycache__/generators.cpython-38.pyc
0 → 100644
View file @
404580b9
File added
redirector/__pycache__/logger.cpython-38.pyc
0 → 100644
View file @
404580b9
File added
redirector/__pycache__/parser.cpython-38.pyc
0 → 100644
View file @
404580b9
File added
redirector/const.py
View file @
404580b9
NAME
=
"redirector"
NAME
=
"
nginx-
redirector"
VERSION
=
"1.0"
VERSION
=
"1.0"
AUTHOR
=
"Nikita Yefremov"
AUTHOR
=
"Nikita Yefremov"
EMAIL
=
"enk@etersoft.ru"
EMAIL
=
"enk@etersoft.ru"
PYTHON_VERSION
=
"3.6"
PYTHON_VERSION
=
"3.6"
VERSION_STATUS
=
"alpha"
VERSION_STATUS
=
"alpha"
NGINX_DIR
=
"/etc/nginx"
# /home/enk
NGINX_DIR
=
"/
home/kantegory/pvt/redirector-tests"
#"/
etc/nginx" # /home/enk
CONFIG_YAML
=
'/etc/redirector/config.yaml'
CONFIG_YAML
=
"/home/kantegory/pvt/nginx-redirector/config.yaml"
MAPS_DIR
=
NGINX_DIR
+
"/maps"
MAPS_DIR
=
NGINX_DIR
+
"/maps"
CONFIG_DIR
=
NGINX_DIR
+
"/location-includes"
CONFIG_DIR
=
NGINX_DIR
+
"/location-includes"
redirector/parser.py
View file @
404580b9
...
@@ -104,11 +104,15 @@ class ConfigReader:
...
@@ -104,11 +104,15 @@ class ConfigReader:
def
parse_map
(
self
,
map_file
,
yaml_file
):
def
parse_map
(
self
,
map_file
,
yaml_file
):
res
=
[[],
{}]
res
=
[[],
{}]
res_prefix
=
None
res_prefix
=
None
# normalize path
abs_map_path
=
os
.
path
.
abspath
(
os
.
path
.
realpath
(
map_file
))
try
:
try
:
for
map_path
,
prefix
in
self
.
parse_yaml
(
yaml_file
):
for
map_path
,
prefix
in
self
.
parse_yaml
(
yaml_file
):
if
map_path
==
map_file
or
os
.
getcwd
()
+
"/"
+
map_path
==
map_file
:
if
map_path
in
abs_map_path
:
res_prefix
=
prefix
.
split
(
"/"
)[
-
1
]
# Last directory of map_path a project's name
res_prefix
=
prefix
.
split
(
"/"
)[
-
1
]
# Last directory of map_path a project's name
with
open
(
map_file
,
"r"
)
as
file
:
with
open
(
abs_map_path
,
"r"
)
as
file
:
for
i
,
line
in
enumerate
(
file
):
for
i
,
line
in
enumerate
(
file
):
request_url
,
redirect_url
,
option
=
None
,
None
,
[]
request_url
,
redirect_url
,
option
=
None
,
None
,
[]
try
:
try
:
...
@@ -131,6 +135,7 @@ class ConfigReader:
...
@@ -131,6 +135,7 @@ class ConfigReader:
else
:
else
:
res
[
1
][
opt_
]
=
[(
request_url
,
redirect_url
)]
res
[
1
][
opt_
]
=
[(
request_url
,
redirect_url
)]
return
res
,
res_prefix
return
res
,
res_prefix
except
YAMLError
as
e
:
except
YAMLError
as
e
:
self
.
logger
.
log
(
"Error occurred while reading
%
s"
%
yaml_file
+
str
(
e
))
self
.
logger
.
log
(
"Error occurred while reading
%
s"
%
yaml_file
+
str
(
e
))
...
...
tests/test.yaml
View file @
404580b9
projects
:
projects
:
-
map
:
tests/test.map
-
map
:
tests/test.map
prefix
:
/test
prefix
:
/test
-
map
:
tests/test2.map
prefix
:
/test2
\ No newline at end of file
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