Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 29e37231 authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Vidjil Team

vidjil_utils.py: log_links, link to source on GitHub

parent bc4fb2c4
......@@ -185,9 +185,18 @@ def extract_fields_from_json(json_fields, pos_in_list, filename):
####
SOURCES = "https://github.com/vidjil/vidjil/blob/master/server/web2py/applications/vidjil/%s#L%s"
SOURCES_DIR_DEFAULT = 'controllers/'
SOURCES_DIR = {
'task.py': 'models/',
'db.py': 'models/',
}
log_patient = re.compile('\((\d+)\)')
log_config = re.compile(' c(\d+)')
log_task = re.compile('\[(\d+)\]')
log_py = re.compile('(.*[.]py):(\d+)')
def log_links(s):
'''Add HTML links to a log string
......@@ -213,6 +222,14 @@ def log_links(s):
m_task = log_task.search(s)
task = int(m_task.group(1)) if m_task else None
m_py = log_py.search(s)
if m_py:
source = m_py.group(1)
if source in SOURCES_DIR:
source = SOURCES_DIR[source] + source
else:
source = SOURCES_DIR_DEFAULT + source
### Rules
url = '' # href link
......@@ -237,6 +254,10 @@ def log_links(s):
start += 1
end -= 1
if m_py:
(start, end) = m_py.span(2)
url = SOURCES % (source, m_py.group(2))
### Build final string
link = ''
......
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