Pylinting
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
from rich import print
|
||||
from .mapper import *
|
||||
""" Module for the parser """
|
||||
from pathlib import Path
|
||||
from lark import Lark
|
||||
from .classes import Ziffers
|
||||
from .mapper import ZiffersTransformer
|
||||
|
||||
|
||||
grammar_path = Path(__file__).parent
|
||||
grammar = grammar_path / "ziffers.lark"
|
||||
@ -14,45 +16,83 @@ ziffers_parser = Lark.open(
|
||||
transformer=ZiffersTransformer(),
|
||||
)
|
||||
|
||||
def parse_expression(expr: str):
|
||||
"""Parse an expression using the Ziffers parser"""
|
||||
|
||||
def parse_expression(expr: str) -> Ziffers:
|
||||
"""Parse an expression using the Ziffers parser
|
||||
|
||||
Args:
|
||||
expr (str): Ziffers expression as a string
|
||||
|
||||
Returns:
|
||||
Ziffers: Reutrns Ziffers iterable
|
||||
"""
|
||||
return ziffers_parser.parse(expr)
|
||||
|
||||
def zparse(expr: str, opts: dict=None):
|
||||
|
||||
def zparse(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Parses ziffers expression with options
|
||||
|
||||
Args:
|
||||
expr (str): Ziffers expression as a string
|
||||
opts (dict, optional): Options for parsing the Ziffers expression. Defaults to None.
|
||||
|
||||
Returns:
|
||||
Ziffers: Returns Ziffers iterable parsed with the given options
|
||||
"""
|
||||
parsed = parse_expression(expr)
|
||||
if opts:
|
||||
parsed.set_defaults(opts)
|
||||
return parsed
|
||||
|
||||
def z0(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z1(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z2(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z3(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
# pylint: disable=invalid-name
|
||||
|
||||
def z3(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z4(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
def z0(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
def z5(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z6(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
def z1(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
def z7(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z8(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
def z2(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
def z9(expr: str, opts: dict=None):
|
||||
return zparse(expr,opts)
|
||||
|
||||
def z3(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z4(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z5(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z6(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z7(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z8(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
|
||||
def z9(expr: str, opts: dict = None) -> Ziffers:
|
||||
"""Shortened method name for zparse"""
|
||||
return zparse(expr, opts)
|
||||
|
||||
Reference in New Issue
Block a user