davidblewett / rure-python Goto Github PK
View Code? Open in Web Editor NEWPython wrapper of the RuRe.
Python wrapper of the RuRe.
The installation instructions in https://github.com/davidblewett/rure-python/blob/master/README.rst instruct to set the simd-accel
feature for rust::Regex, but starting with version 1.0.1 the SIMD features are automatically activated at runtime: rust-lang/regex#490
I suggest stating in the install instructions that the steps to set simd-accel
are only necessary for rust::Regex versions <1.0.1 (2018-06-19).
Hey,
Rure-python is excellent, it would be nice if there where wheels for ARM Macs.
Minimal example:
import rure
ptn = u"(re)|(ger)"
email = u"tony@tiremove_thisger.net"
groups = rure.search(ptn, email).groups()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-7f52b4f2c143> in <module>()
1 ptn = u"(re)|(ger)"
2 email = u"tony@tiremove_thisger.net"
----> 3 groups = rure.search(ptn, email).groups()
/Users/mdeboard/crowdstrike/rure-python/rure/regex.pyc in groups(self, default)
211 # Exclude the entire match (index 0)
212 return self.group(*[i for i in range(len(self.captures)) if i > 0],
--> 213 default=default)
214
215 def groupdict(self, default=None, decode=True):
/Users/mdeboard/crowdstrike/rure-python/rure/regex.pyc in captures(self)
173 def captures(self):
174 if self._captures is None:
--> 175 self._captures = self.re._rure.captures(self.string, self.pos)
176 return self._captures
177
/Users/mdeboard/crowdstrike/rure-python/rure/decorators.pyc in wrapper(cls_instance, string, *args, **kwargs)
16 if not isinstance(string, bytes):
17 raise TypeError(err_msg)
---> 18 return f(cls_instance, string, *args, **kwargs)
19 return wrapper
20
/Users/mdeboard/crowdstrike/rure-python/rure/lib.pyc in captures(self, haystack, start)
215 RureMatch(match.start, match.end)
216 for i in range(0, _lib.rure_captures_len(captures))
--> 217 if _lib.rure_captures_at(captures, i, match)
218 ])
219
TypeError: __new__() takes exactly 4 arguments (3 given)
The current pypi release only has Mac wheels.
Can you release a plain sdist? not everyone runs on mac ;)
Thanks!
I'm trying to follow the instructions for "installing from a source tarball".
I cloned the Rust regex repo, put it in a dir named 'rust-regex', and built it okay.
I cloned this repo, put it in a sibling dir.
So when it says:
RURE_DIR=/path/to/regex/regex-capi python setup.py bdist_wheel
I did this:
RURE_DIR=../rust-regex/regex-capi python3 setup.py bdist_wheel
and it died with this:
running build_rust
error: [Errno 2] No such file or directory: '../rust-regex/regex-capi/target/release'
Now, it's not clear what RURE_DIR
is supposed to mean, but I noticed that there's a target
dir in the rust-regex
dir itself. So I changed my command to:
RURE_DIR=../rust-regex python3 setup.py bdist_wheel
and it seemed to work. So is that a mistake in the README?
Then, when I do this:
pip3 install rure --no-index -f ./dist
I get either
Could not find a version that satisfies the requirement six (from rure) (from versions: )
or
Could not find a version that satisfies the requirement cffi>=1.5.0 (from rure) (from versions: )
I don't know what's going on.
Hi,
when trying to use rure on https://github.com/ua-parser/uap-core, i came across this behaviour where rure isn't consistent with re. i'm not sure who's "right"
$ python
Python 3.7.3 (default, May 6 2019, 08:10:06)
[Clang 9.0.0 (clang-900.0.38)] on darwin
>>> import re, rure
>>> re.match('\/', '/')
<re.Match object; span=(0, 1), match='/'>
>>> rure.match('\/', '/')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
[snip]
rure.exceptions.RegexSyntaxError: regex parse error:
\/
^^
error: unrecognized escape sequence
$ pip install rure
Requirement already satisfied: rure in /home/eth/tools/virtualenvs/w3af/lib/python2.7/site-packages (0.2.0)
Requirement already satisfied: six in /home/eth/tools/virtualenvs/w3af/lib/python2.7/site-packages (from rure) (1.11.0)
Requirement already satisfied: cffi>=1.5.0 in /home/eth/tools/virtualenvs/w3af/lib/python2.7/site-packages (from rure) (1.11.5)
Requirement already satisfied: pycparser in /home/eth/tools/virtualenvs/w3af/lib/python2.7/site-packages (from cffi>=1.5.0->rure) (2.18)
$ python -c 'import rure'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "rure/__init__.py", line 3, in <module>
from rure.lib import Rure, RureSet
File "rure/lib.py", line 5, in <module>
from rure._ffi import ffi
ImportError: No module named _ffi
This line:
[m.groupdict() for m in rure.compile('(?P<word>\w+)').finditer("hello there")]
Returns this:
[{'word': 'h'}, {'word': 't'}]
I would expect it to return this:
[{'word': 'hello'}, {'word': 'there'}]
Adding a second named group fixes this issue for some reason:
[m.groupdict() for m in rure.compile('(?P<name>\w+)(?P<nomatch>)').finditer("hello there")]
Returns:
[{'name': 'hello', 'nomatch': ''}, {'name': 'there', 'nomatch': ''}]
I was wondering if you'd be open to adding python types directly to the repo to support mypy
and similar tools.
Since rure
supports python 2.7 the comment based type hint syntax would be required: https://mypy.readthedocs.io/en/stable/python2.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.