From f1201bdce9d966aac8db4ee63547267462f98cfd Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 7 Jun 2014 05:01:31 +0300 Subject: [PATCH] re-pcre: sub(): If suffix of string matched, None was returned. --- re-pcre/metadata.txt | 5 +++++ re-pcre/re.py | 1 + re-pcre/setup.py | 12 ++++++++---- re-pcre/test_re.py | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 re-pcre/metadata.txt diff --git a/re-pcre/metadata.txt b/re-pcre/metadata.txt new file mode 100644 index 00000000..7b1b0ea5 --- /dev/null +++ b/re-pcre/metadata.txt @@ -0,0 +1,5 @@ +name = re +srctype = micropython-lib +type = module +version = 0.1.7 +author = Paul Sokolovsky diff --git a/re-pcre/re.py b/re-pcre/re.py index 7e832a65..6083f04b 100644 --- a/re-pcre/re.py +++ b/re-pcre/re.py @@ -95,6 +95,7 @@ class PCREPattern: else: res += repl s = s[end:] + return res def split(self, s, maxsplit=0): res = [] diff --git a/re-pcre/setup.py b/re-pcre/setup.py index 665e9018..b3ffd185 100644 --- a/re-pcre/setup.py +++ b/re-pcre/setup.py @@ -1,14 +1,18 @@ import sys -# Remove current dir from sys.path, otherwise distutils will peek up our +# Remove current dir from sys.path, otherwise setuptools will peek up our # module instead of system. sys.path.pop(0) -from distutils.core import setup +from setuptools import setup + setup(name='micropython-re-pcre', - version='0.1.6', - description='re module for MicroPython, based on PCRE and FFI', + version='0.1.7', + description='re-pcre module for MicroPython', + long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.", url='https://github.com/micropython/micropython/issues/405', author='Paul Sokolovsky', author_email='micro-python@googlegroups.com', + maintainer='MicroPython Developers', + maintainer_email='micro-python@googlegroups.com', license='MIT', py_modules=['re']) diff --git a/re-pcre/test_re.py b/re-pcre/test_re.py index 7efe0c14..94e42f03 100644 --- a/re-pcre/test_re.py +++ b/re-pcre/test_re.py @@ -28,3 +28,5 @@ assert re.split('(\W+)', 'Words, words, words.') == ['Words', ', ', 'words', ', assert re.split('\W+', 'Words, words, words.', 1) == ['Words', 'words, words.'] assert re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE) == ['0', '3', '9'] assert re.split('(\W+)', '...words, words...') == ['', '...', 'words', ', ', 'words', '...', ''] + +assert re.sub(r"[ :/?&]", "_", "http://foo.ua/bar/?a=1&b=baz/") == "http___foo.ua_bar__a=1_b=baz_"