Skip to content

Commit

Permalink
Merge pull request #2 from olpa/adapt-for-pip
Browse files Browse the repository at this point in the history
Adapt the package for pip
  • Loading branch information
rlpowell authored Oct 17, 2021
2 parents 4159ca9 + 4282b56 commit 38e9fd0
Show file tree
Hide file tree
Showing 30 changed files with 79 additions and 30 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include camxes_py/parsers/camxes_ilmen.peg
18 changes: 9 additions & 9 deletions camxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from optparse import OptionParser

import parsimonious_ext # expression_nodes
import camxes_py.parsimonious_ext # expression_nodes

__version__ = "v0.8.1"

Expand Down Expand Up @@ -87,29 +87,29 @@ def run(text, options):
def build_parser(options):
parser_option = options.parser if len(PARSERS) > 1 else "camxes-ilmen"
if parser_option == 'camxes-ilmen':
from parsers import camxes_ilmen
from camxes_py.parsers import camxes_ilmen
return camxes_ilmen.Parser(options.rule)
else:
bad_parser()

def build_transformer(transformer_option, parser):
if transformer_option == 'camxes-json':
from transformers import camxes_json
from camxes_py.transformers import camxes_json
return camxes_json.Transformer()
elif transformer_option == 'camxes-morphology':
from transformers import camxes_morphology
from camxes_py.transformers import camxes_morphology
return camxes_morphology.Transformer()
elif transformer_option == 'vlatai':
from transformers import vlatai
from camxes_py.transformers import vlatai
return vlatai.Transformer()
elif transformer_option == 'node-coverage':
from transformers import node_coverage
from camxes_py.transformers import node_coverage
return node_coverage.Transformer(parser)
elif transformer_option == 'debug':
from transformers import debug
from camxes_py.transformers import debug
return debug.Transformer()
elif transformer_option == 'raw':
from transformers import raw
from camxes_py.transformers import raw
return raw.Transformer()
else:
bad_transformer()
Expand All @@ -133,7 +133,7 @@ def serialize(transformed, fmt, default_serializer):
indent=4,
default=default_serializer)
elif fmt == 'xml':
from serializers import xml
from camxes_py.serializers import xml
return xml.dumps(transformed)
else:
bad_serializer()
Expand Down
12 changes: 12 additions & 0 deletions camxes_py/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .parsers import camxes_ilmen
from .transformers import camxes_json


def parse(text, parser=None, rule=None, transformer=None):
if parser is None:
parser = camxes_ilmen.Parser(rule)
if transformer is None:
transformer = camxes_json.Transformer()
parsed = parser.parse(text)
transformed = transformer.transform(parsed)
return transformed
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from parsimonious.grammar import Grammar

from parsimonious_ext.expressions import Predicate, LookaheadPredicate
from ..parsimonious_ext.expressions import Predicate, LookaheadPredicate

GRAMMAR_FILENAME = "camxes_ilmen.peg"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# pylint: disable=I0011, C0111, C0326

from structures.gensuha \
from .gensuha \
import Cmevla, Gismu, Lujvo, Fuhivla, Cmavo, ZeiLujvo, BuLetteral, Tosmabru, Slinkuhi

# legacy classifications
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# pylint: disable=I0011, C0111, C0302, too-few-public-methods, no-self-use, too-many-public-methods, invalid-name, unused-argument

from parsimonious_ext.expression_nodes import ALTERNATION, OPTIONAL, LITERAL, REGEX
from ..parsimonious_ext.expression_nodes import ALTERNATION, OPTIONAL, LITERAL, REGEX

from parsimonious.nodes import NodeVisitor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from parsimonious.nodes import NodeVisitor

from parsimonious_ext.expression_nodes import LITERAL, REGEX
from ..parsimonious_ext.expression_nodes import LITERAL, REGEX

from structures.gensuha \
from ..structures.gensuha \
import Gensuha, Cmevla, Gismu, Lujvo, Fuhivla, Cmavo, Naljbo

SELMAHO_UNKNOWN = "TOLSLABU"
Expand Down
4 changes: 2 additions & 2 deletions transformers/debug.py → camxes_py/transformers/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from parsimonious.nodes import NodeVisitor

from parsimonious_ext.expression_nodes import LITERAL, REGEX
from transformers.camxes_morphology import is_selmaho_expression
from ..parsimonious_ext.expression_nodes import LITERAL, REGEX
from .camxes_morphology import is_selmaho_expression

def _is_consonant(name):
return re.match(r"^[bcdfghjklmnpqrstvxz]$", name)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions transformers/vlatai.py → camxes_py/transformers/vlatai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from .util import flatten

from transformers import camxes_morphology
from structures.gensuha import BuLetteral, ZeiLujvo, Tosmabru, Slinkuhi
from . import camxes_morphology
from ..structures.gensuha import BuLetteral, ZeiLujvo, Tosmabru, Slinkuhi

class Transformer(object):

Expand Down
4 changes: 2 additions & 2 deletions cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import json

from camxes import configure_platform
from parsers import camxes_ilmen
from transformers import node_coverage
from camxes_py.parsers import camxes_ilmen
from camxes_py.transformers import node_coverage

TEST_DIRECTORY = "test"
INPUT_FILENAME = "camxes_ilmen_js.json"
Expand Down
4 changes: 2 additions & 2 deletions irc/morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from irc.dispatcher import BaseDispatcher
from irc.factory_naming import Mixin as FactoryNamingMixin
from irc.protocol import DispatchableIrcClient
from parsers.camxes_ilmen import Parser
from transformers.camxes_morphology import Transformer
from camxes_py.parsers.camxes_ilmen import Parser
from camxes_py.transformers.camxes_morphology import Transformer

ERROR_MESSAGE = ".u'u mi na pu genturfa'i"

Expand Down
6 changes: 3 additions & 3 deletions irc/vlatai.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from irc.factory_naming import Mixin as FactoryNamingMixin
from irc.protocol import DispatchableIrcClient

from structures import jbovlaste_types
from parsers import camxes_ilmen
from transformers import vlatai
from camxes_py.structures import jbovlaste_types
from camxes_py.parsers import camxes_ilmen
from camxes_py.transformers import vlatai

class Dispatcher(BaseDispatcher, object):

Expand Down
36 changes: 36 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import setuptools

PACKAGE_NAME = 'camxes_py'
PACKAGE_DIR = 'camxes_py'


packages = setuptools.find_packages(PACKAGE_DIR)
packages.append('')
packages = list(map(lambda n: PACKAGE_NAME+"."+n, packages))


with open("README.txt", "r", encoding="utf-8") as fh:
long_description = fh.read()


setuptools.setup(
name=PACKAGE_NAME,
version="0.8.1",
author="Robin Lee Powell",
author_email="rlpowell@digitalkingdom.org",
description="A pure Python implementation of the lojban 'camxes' PEG parser.",
long_description=long_description,
long_description_content_type="text/plain",
url="https://github.com/lojban/camxes-py",
classifiers=[
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Text Processing :: Linguistic",
],
package_dir={PACKAGE_NAME: PACKAGE_DIR},
packages=packages,
include_package_data=True,
python_requires=">=3.6",
install_requires=["parsimonious==0.8.1"],
scripts=["camxes.py"],
)
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from parsimonious.exceptions import ParseError

from camxes import __version__, configure_platform
from parsers import camxes_ilmen
from transformers import camxes_json, camxes_morphology
from camxes_py.parsers import camxes_ilmen
from camxes_py.transformers import camxes_json, camxes_morphology

ENV = OrderedDict([
("engine", "camxes-py"),
Expand Down
6 changes: 3 additions & 3 deletions vlatai.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

from parsimonious.exceptions import ParseError

from structures import jbovlaste_types
from camxes_py.structures import jbovlaste_types
from camxes import configure_platform
from parsers.camxes_ilmen import Parser
from transformers.vlatai import Visitor
from camxes_py.parsers.camxes_ilmen import Parser
from camxes_py.transformers.vlatai import Visitor

VLATAI_RULE = "vlatai"

Expand Down

0 comments on commit 38e9fd0

Please sign in to comment.