Skip to content

Commit

Permalink
Removed dependency to PLY
Browse files Browse the repository at this point in the history
  • Loading branch information
ereOn committed Jan 16, 2016
1 parent e690c95 commit 3fe05bd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 214 deletions.
10 changes: 4 additions & 6 deletions pygen/scope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Scope manipulation.
"""

import re

from .exceptions import InvalidScope
from .yacc import parser


def parse_scope(value):
Expand All @@ -13,12 +14,10 @@ def parse_scope(value):
:param value: The dotted path string.
:returns: A `Scope` instance if `value` is a valid path.
"""
scope = parser.parse(value)

if scope is None:
if not re.match('^[\w\d_-]+(\.[\w\d_-]+)*$', value):
raise InvalidScope(value)

return Scope(scope=scope)
return Scope(scope=value.split('.'))


class Scope(object):
Expand All @@ -33,7 +32,6 @@ def __init__(self, scope=None):
"""
self.scope = scope or []


def __repr__(self):
return 'Scope(%r)' % self.scope

Expand Down
4 changes: 3 additions & 1 deletion pygen/scope/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
Scope exceptions.
"""

from voluptuous import Invalid

class InvalidScope(ValueError):

class InvalidScope(Invalid):
"""
An invalid scope was specified.
"""
Expand Down
30 changes: 0 additions & 30 deletions pygen/scope/lex.py

This file was deleted.

99 changes: 0 additions & 99 deletions pygen/scope/parser.out

This file was deleted.

35 changes: 0 additions & 35 deletions pygen/scope/parsetab.py

This file was deleted.

40 changes: 0 additions & 40 deletions pygen/scope/yacc.py

This file was deleted.

5 changes: 3 additions & 2 deletions pygen/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def perror(msg, *args, **kwargs):
)
@click.argument('templates-root', type=click.Path(exists=True))
@click.argument('definition-file', type=click.File())
def gxgen(debug, output_root, targets, templates_root, definition_file):
def pygen(debug, output_root, targets, templates_root, definition_file):
if debug:
pdebug(
"Parsing definition file: {definition_file_name}.",
Expand Down Expand Up @@ -98,7 +98,7 @@ def gxgen(debug, output_root, targets, templates_root, definition_file):
for index, target_name in enumerate(targets):
progress = float(index) / len(targets)
pinfo(
"[{progress:2d}%] Generating target `{target_name}`.",
"[{progress:3d}%] Generating target `{target_name}`.",
progress=int(progress * 100.0),
target_name=hl(target_name),
)
Expand All @@ -119,6 +119,7 @@ def gxgen(debug, output_root, targets, templates_root, definition_file):
with open(output_file_name, 'w') as destination_file:
destination_file.write(content)

pinfo("[100%] Done.")

except Exception as ex:
if debug:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
'click==6.2',
'PyYAML==3.11',
'voluptuous==0.8.8',
'ply==3.8',
],
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 3fe05bd

Please sign in to comment.