2
0
mirror of https://gitlab.com/ita1024/waf.git synced 2024-11-23 02:16:01 +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,7 +8,8 @@ from waflib.TaskGen import extension
cy_api_pat = re.compile(r'\s*?cdef\s*?(public|api)\w*') cy_api_pat = re.compile(r'\s*?cdef\s*?(public|api)\w*')
re_cyt = re.compile(r""" re_cyt = re.compile(r"""
(?:from\s+(\w+)\s+)? # optionally match "from foo" and capture foo ^\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 c?import\s(\w+|[*]) # require "import bar" and capture bar
""", re.M | re.VERBOSE) """, re.M | re.VERBOSE)