grim/pyparser

merging

2014-01-16, Gary Kramlich
376a3e5b09dc
merging
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py Thu Jan 16 01:33:41 2014 -0600
@@ -0,0 +1,32 @@
+import os
+import sys
+
+from setuptools import setup, find_packages
+
+# add our path to sys.path
+_PATH = os.path.join(os.path.dirname(__file__), 'src')
+if not _PATH in sys.path:
+ sys.path.append(_PATH)
+
+from pyparser import __version__
+
+
+def main():
+ """ Creates our package """
+
+ setup(
+ name='pyparser',
+ version=__version__,
+ description=None,
+ packages=find_packages(),
+ zip_safe=True,
+ test_suite='tests',
+ author='Gary Kramlich',
+ author_email='grim@reaperworld.com',
+ url='http://bitbucket.org/rw_grim/pyparser',
+ )
+
+
+if __name__ == '__main__':
+ main()
+
--- a/src/pyparser/__init__.py Thu Jan 16 01:31:34 2014 -0600
+++ b/src/pyparser/__init__.py Thu Jan 16 01:33:41 2014 -0600
@@ -4,6 +4,10 @@
import abc
+
+__version__ = '0.1'
+
+
class Parser(object):
"""
Parser is an abstract base class that defines the behavior of a parser.
--- a/src/pyparser/regex.py Thu Jan 16 01:31:34 2014 -0600
+++ b/src/pyparser/regex.py Thu Jan 16 01:33:41 2014 -0600
@@ -11,7 +11,7 @@
_ATTRIBUTE_NAME = '_pyparser_re_pattern'
-class Pattern(object): # pylint:disable-msg=R0903
+class pattern(object): # pylint:disable-msg=R0903,C0103
"""
This class is a decorator that'll attach a regular expression attribute
to a function that the RegexParser class will use to call that function if
@@ -54,11 +54,11 @@
self.data = 0
- @Pattern('^$')
+ @pattern('^$')
def blank(self, match):
pass # ignore blank lines
- @Pattern('.+foo.+')
+ @pattern('.+foo.+')
def foo(self, match):
self.data += 1
@@ -72,7 +72,7 @@
self.data = {}
self.processor = None
- @Pattern('^(?P<attribute>.+)\\s+:\\s+(?P<value>.+)$')
+ @pattern('^(?P<attribute>.+)\\s+:\\s+(?P<value>.+)$')
def attribute(self, match, attribute, value):
if attribute == 'processor':
self.processor = {}
--- a/tests/testregex.py Thu Jan 16 01:31:34 2014 -0600
+++ b/tests/testregex.py Thu Jan 16 01:33:41 2014 -0600
@@ -2,7 +2,7 @@
import unittest
-from pyparser.regex import RegexParser, Pattern
+from pyparser.regex import RegexParser, pattern
import utils
@@ -19,7 +19,7 @@
RegexParser.__init__(self, handle_errors=handle_errors)
- @Pattern('(')
+ @pattern('(')
def _broken(self):
""" An invalid regex pattern function """
pass
@@ -51,7 +51,7 @@
self.data = {}
self.processor = None
- @Pattern('^(?P<attribute>.+[^\s])\s+:\s+(?P<value>.+)$')
+ @pattern('^(?P<attribute>.+[^\s])\s+:\s+(?P<value>.+)$')
def attribute(self, match, attribute, value): # pylint:disable-msg=W0613
""" Parsers an attribute """
@@ -72,7 +72,7 @@
self.data = {}
self.processor = None
- @Pattern('^(?P<attribute>.+[^\s])\s+:\s+(?P<value>.+)$')
+ @pattern('^(?P<attribute>.+[^\s])\s+:\s+(?P<value>.+)$')
def attribute(self, match): # pylint:disable-msg=W0613
""" Parsers an attribute """