2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-22 09:57:15 +01:00

cython: Enhance import regexp.

* avoid matching commented imports
* support `from foo.bar import baz` syntax.
This commit is contained in:
Romain Le Godais 2018-11-18 10:31:34 +01:00
parent a2105efc6f
commit af74bbcbee

View File

@ -8,8 +8,9 @@ from waflib.TaskGen import extension
cy_api_pat = re.compile(r'\s*?cdef\s*?(public|api)\w*')
re_cyt = re.compile(r"""
(?:from\s+(\w+)\s+)? # optionally match "from foo" and capture foo
c?import\s(\w+|[*]) # require "import bar" and capture bar
^\s* # must begin with some whitespace characters
(?:from\s+(\w+)(?:\.\w+)*\s+)? # optionally match "from foo(.baz)" and capture foo
c?import\s(\w+|[*]) # require "import bar" and capture bar
""", re.M | re.VERBOSE)
@extension('.pyx')