diff --git a/hdlparse/__init__.py b/hdlparse/__init__.py index e69de29..571a96d 100644 --- a/hdlparse/__init__.py +++ b/hdlparse/__init__.py @@ -0,0 +1,2 @@ +"""Parse Verilog and VHDL files""" +__version__ = '1.1.0' diff --git a/hdlparse/minilexer.py b/hdlparse/minilexer.py index 00936e9..c36f6fd 100644 --- a/hdlparse/minilexer.py +++ b/hdlparse/minilexer.py @@ -1,20 +1,20 @@ # -*- coding: utf-8 -*- # Copyright © 2017 Kevin Thibedeau # Distributed under the terms of the MIT license +"""Minimalistic lexer engine inspired by the PyPigments RegexLexer""" import re import logging -"""Minimalistic lexer engine inspired by the PyPigments RegexLexer""" - -__version__ = '1.0.7' log = logging.getLogger(__name__) -handler = logging.StreamHandler() -handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s')) -log.addHandler(handler) + +if not log.handlers: # only add the handler if no handlers are already registered + handler = logging.StreamHandler() + handler.setFormatter(logging.Formatter('%(name)s - %(levelname)s - %(message)s')) + log.addHandler(handler) -class MiniLexer(object): +class MiniLexer(): """Simple lexer state machine with regex matching rules""" def __init__(self, tokens, flags=re.MULTILINE): @@ -53,7 +53,7 @@ def run(self, text): text (str): Text to apply lexer to Yields: - A sequence of lexer matches. + A sequence of lexer matches """ stack = ['root'] @@ -66,7 +66,7 @@ def run(self, text): m = pat.match(text, pos) if m: if action: - log.debug(f"Match: {m.group().strip()} -> {action}") + log.debug("Match: %s -> %s", m.group().strip(), action) yield (pos, m.end() - 1), action, m.groups() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..db7b831 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,39 @@ +[metadata] +name = hdlparse +author = Kevin Thibedeau +author_email = kevin.thibedeau@gmail.com +url = http://kevinpt.github.io/hdlparse +download_url = http://kevinpt.github.io/hdlparse +description = HDL parser +long_description = file: README.rst +description_file = README.rst +version = attr: hdlparse.__version__ +license = MIT +keywords = HDL parser +classifiers = + Development Status :: 5 - Production/Stable + Operating System :: OS Independent + Intended Audience :: Developers + Topic :: Text Processing :: General + Natural Language :: English + Programming Language :: Python :: 3 + License :: OSI Approved :: MIT License + +[options] +packages = hdlparse +py_modules = +install_requires = +include_package_data = True + +[pycodestyle] +max_line_length = 120 +ignore = E501 + +[pydocstyle] +ignore = D100,D102,D103,D105,D202,D203,D213,D400,D405,D406,D407,D413,D415 + +[pylint] +disable = + C0103,C0301,C0103,C0116,R0201,R0801,R0903,R0912,R0913,R0914,R0915,W0702 +ignore-docstrings = yes +output-format = colorized diff --git a/setup.py b/setup.py index 29e2e86..6068493 100755 --- a/setup.py +++ b/setup.py @@ -1,44 +1,3 @@ from setuptools import setup -# Use README.rst for the long description -with open('README.rst') as fh: - long_description = fh.read() - -# Scan the script for the version string -version_file = 'hdlparse/minilexer.py' -version = None -with open(version_file) as fh: - try: - version = [line.split('=')[1].strip().strip("'") for line in fh if - line.startswith('__version__')][0] - except IndexError: - pass - -if version is None: - raise RuntimeError('Unable to find version string in file: {0}'.format(version_file)) - -setup(name='hdlparse', - version=version, - author='Kevin Thibedeau', - author_email='kevin.thibedeau@gmail.com', - url='http://kevinpt.github.io/hdlparse', - download_url='http://kevinpt.github.io/hdlparse', - description='HDL parser', - long_description=long_description, - platforms=['Any'], - install_requires=[], - packages=['hdlparse'], - py_modules=[], - include_package_data=True, - - keywords='HDL parser', - license='MIT', - classifiers=['Development Status :: 5 - Production/Stable', - 'Operating System :: OS Independent', - 'Intended Audience :: Developers', - 'Topic :: Text Processing :: General', - 'Natural Language :: English', - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: MIT License' - ] - ) +setup()