Fix issues reported by pylint
And silence the self-use warning: Tatsu requires it this way
This commit is contained in:
parent
5fcac5f937
commit
22aa5a0fb0
4 changed files with 19 additions and 16 deletions
|
@ -1,13 +1,13 @@
|
|||
# Import this class to load the standard HLDS definitions
|
||||
|
||||
from os import path
|
||||
import itertools
|
||||
from .parser import parse_all_directory
|
||||
|
||||
|
||||
__all__ = ["definitions"]
|
||||
__all__ = ["location_definitions"]
|
||||
|
||||
# TODO Use proper way to get resources, see https://stackoverflow.com/a/10935674
|
||||
data_dir = path.join(path.dirname(__file__), "..", "..", "data")
|
||||
DATA_DIR = path.join(path.dirname(__file__), "..", "..", "data")
|
||||
|
||||
location_definitions = parse_all_directory(data_dir)
|
||||
# pylint: disable=invalid-name
|
||||
location_definitions = parse_all_directory(DATA_DIR)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
from typing import List
|
||||
|
||||
|
@ -73,7 +74,13 @@ class Location:
|
|||
self.dishes: List[Dish] = dishes
|
||||
|
||||
def __str__(self):
|
||||
return "============================\n{0.id}: {0.name}\n============================\n\n{1}".format(
|
||||
return (
|
||||
"============================\n"
|
||||
"{0.id}: {0.name}\n"
|
||||
"============================\n"
|
||||
"\n"
|
||||
"{1}"
|
||||
).format(
|
||||
self,
|
||||
"\n\n".join(map(str, self.dishes))
|
||||
"\n".join(map(str, self.dishes))
|
||||
)
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from glob import glob
|
||||
from os import path, walk
|
||||
from tatsu import parse as tatsu_parse
|
||||
from os import path
|
||||
import itertools
|
||||
from tatsu import parse as tatsu_parse
|
||||
from .models import Location, Choice, Option, Dish
|
||||
import operator
|
||||
|
||||
|
||||
# TODO Use proper way to get resources, see https://stackoverflow.com/a/10935674
|
||||
|
@ -17,6 +16,7 @@ def filter_instance(cls, iterable):
|
|||
return [item for item in iterable if isinstance(item, cls)]
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
class HldsSemanticActions:
|
||||
def location(self, ast):
|
||||
choices = {choice.id: choice for choice in filter_instance(Choice, ast["items_"])}
|
||||
|
@ -53,10 +53,7 @@ class HldsSemanticActions:
|
|||
)
|
||||
|
||||
def indent_choice_block(self, ast):
|
||||
if ast["kind"] == "declaration":
|
||||
return self.choice_block(ast)
|
||||
else:
|
||||
return ast
|
||||
return self.choice_block(ast) if ast["kind"] == "declaration" else ast
|
||||
|
||||
def indent_choice_entry(self, ast):
|
||||
return Option(
|
||||
|
@ -84,8 +81,8 @@ def parse(menu):
|
|||
|
||||
|
||||
def parse_file(filename):
|
||||
with open(filename, "r") as fh:
|
||||
return parse(fh.read())
|
||||
with open(filename, "r") as file_handle:
|
||||
return parse(file_handle.read())
|
||||
|
||||
|
||||
def parse_files(files):
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
from tatsu.util import asjson
|
||||
from app.hlds.parser import parse_files
|
||||
|
||||
|
|
Loading…
Reference in a new issue