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
f564a8ac
Commit
f564a8ac
authored
Jun 27, 2020
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix map path for any paths
parent
404580b9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
8 deletions
+11
-8
parser.cpython-38.pyc
redirector/__pycache__/parser.cpython-38.pyc
+0
-0
redirector.cpython-38.pyc
redirector/__pycache__/redirector.cpython-38.pyc
+0
-0
parser.py
redirector/parser.py
+5
-2
watcher.py
redirector/watcher.py
+4
-2
test.map
tests/test.map
+1
-3
test.yaml
tests/test.yaml
+1
-1
No files found.
redirector/__pycache__/parser.cpython-38.pyc
View file @
f564a8ac
No preview for this file type
redirector/__pycache__/redirector.cpython-38.pyc
0 → 100644
View file @
f564a8ac
File added
redirector/parser.py
View file @
f564a8ac
...
...
@@ -106,11 +106,14 @@ class ConfigReader:
res_prefix
=
None
# normalize path
abs_map_path
=
os
.
path
.
abspath
(
os
.
path
.
realpath
(
map_file
))
yaml_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
yaml_file
))
map_file_name
=
os
.
path
.
split
(
map_file
)[
-
1
]
# get tail of map path from arg
try
:
for
map_path
,
prefix
in
self
.
parse_yaml
(
yaml_file
):
if
map_path
in
abs_map_path
:
rel_map_path
=
os
.
path
.
relpath
(
map_path
,
start
=
yaml_dir
)
abs_map_path
=
"{}/{}"
.
format
(
yaml_dir
,
rel_map_path
)
if
map_file_name
in
abs_map_path
:
res_prefix
=
prefix
.
split
(
"/"
)[
-
1
]
# Last directory of map_path a project's name
with
open
(
abs_map_path
,
"r"
)
as
file
:
for
i
,
line
in
enumerate
(
file
):
...
...
redirector/watcher.py
View file @
f564a8ac
...
...
@@ -8,6 +8,7 @@ import generators
import
logger
import
parser
import
const
from
redirector
import
Redirector
redirector_watch
=
None
...
...
@@ -26,6 +27,7 @@ class RedirectorWatch:
raise
self
.
RedirectorWatchException
(
"yaml_file list is empty"
,
Exception
)
Watch
=
self
.
create_watch_class
(
yaml_file
)
for
map_path
,
_
in
self
.
parser
.
parse_yaml
(
yaml_file
):
print
(
'is error here'
,
map_path
)
self
.
redirector
.
generate
(
yaml_file
,
map_path
)
try
:
self
.
set_inotify
(
yaml_file
,
Watch
)
...
...
@@ -62,8 +64,8 @@ class RedirectorWatch:
def
add_files
(
self
,
file_
,
wm
):
file_list
=
self
.
parser
.
parse_yaml
(
file_
)
for
map_path
,
_
in
file_list
:
cwd
=
os
.
getcwd
(
)
wdd
=
wm
.
add_watch
(
cwd
+
"/"
+
map_path
,
self
.
mask
,
rec
=
True
)
abs_map_path
=
os
.
path
.
abspath
(
map_path
)
wdd
=
wm
.
add_watch
(
abs_
map_path
,
self
.
mask
,
rec
=
True
)
class
RedirectorWatchException
(
Exception
):
def
__init__
(
self
,
message
,
errors
):
...
...
tests/test.map
View file @
f564a8ac
# comment
/some-page /another-page
...
...
@@ -13,4 +12,4 @@
/some-page //other-project/some-page
# absolute redirect
/special-project https://github.com/etersoft/special-project
\ No newline at end of file
/special-project https://github.com/etersoft/special-project
tests/test.yaml
View file @
f564a8ac
projects
:
-
map
:
tests/test.map
-
map
:
/home/kantegory/pvt/nginx-redirector/
tests/test.map
prefix
:
/test
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