Giter VIP home page Giter VIP logo

rure-python's People

Contributors

aroden-crowdstrike avatar c-nixon avatar davidblewett avatar jmdyck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rure-python's Issues

groupdict() returns only first character of the match if there is a single named capture group

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': ''}]

ImportError: No module named _ffi

$ 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

Distribute sdist on Pypi

The current pypi release only has Mac wheels.
Can you release a plain sdist? not everyone runs on mac ;)
Thanks!

SyntaxError with multiple unnamed capture groups

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)

build/install problems

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.

escaped forward slashes?

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

Automate build process

  • Add a git submodule for the regex repo
  • Use milksnake to generate bindings

This will resolve #12, with the caveat that you will need Rust installed to build from an sdist.

Wheels for arm mac

Hey,

Rure-python is excellent, it would be nice if there where wheels for ARM Macs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.