Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-eremin committed Jan 5, 2017
1 parent 0c86d5b commit 8b0a859
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def main():
translator = Translator(show_ast=argv.show_ast)
lua_code = translator.translate(content)

print(translator.get_luainit())
print(Translator.get_luainit())
print(lua_code)
return 0

Expand Down
2 changes: 1 addition & 1 deletion pythonlua/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Python to lua translator module"""
"""Python to lua translator module"""
2 changes: 0 additions & 2 deletions pythonlua/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ def pop(self):
"""Pop last context state"""
assert len(self.ctx_stack) > 1, "Pop context failed. This is a last context in the stack."
return self.ctx_stack.pop()


14 changes: 7 additions & 7 deletions pythonlua/nodevisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def visit_Assign(self, node):


self.emit("{local}{target} = {value}".format(local=local_keyword,
target=target,
target=target,
value=value))

def visit_AugAssign(self, node):
Expand Down Expand Up @@ -161,7 +161,7 @@ def visit_Compare(self, node):
line += " and "

self.emit("({})".format(line))

def visit_Continue(self, node):
"""Visit continue"""
last_ctx = self.context.last()
Expand Down Expand Up @@ -257,7 +257,7 @@ def visit_FunctionDef(self, node):
last_ctx["locals"].add_symbol(name)

function_def = line.format(local=local_keyword,
name=name,
name=name,
arguments=", ".join(arguments))

self.emit(function_def)
Expand Down Expand Up @@ -309,15 +309,15 @@ def visit_For(self, node):

continue_label = LoopCounter.get_next()
self.context.push({
"loop_label_name": continue_label,
"loop_label_name": continue_label,
})
self.visit_all(node.body)
self.context.pop()

self.output[-1].append("::{}::".format(continue_label))

self.emit("end")

def visit_Global(self, node):
"""Visit globals"""
last_ctx = self.context.last()
Expand Down Expand Up @@ -507,7 +507,7 @@ def visit_While(self, node):

continue_label = LoopCounter.get_next()
self.context.push({
"loop_label_name": continue_label,
"loop_label_name": continue_label,
})
self.visit_all(node.body)
self.context.pop()
Expand All @@ -528,7 +528,7 @@ def visit_With(self, node):
line = ""
if i.optional_vars is not None:
line = "local {} = "
line = line.format(self.visit_all(i.optional_vars,
line = line.format(self.visit_all(i.optional_vars,
inline=True))
line += self.visit_all(i.context_expr, inline=True)
lines.append(line)
Expand Down
4 changes: 2 additions & 2 deletions pythonlua/symbolsstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SymbolsStack:
"""Class for the symbols stack"""
def __init__(self):
self.symbols = [[]]

def add_symbol(self, name):
"""Add a new symbol to the curent stack"""
self.symbols[-1].append(name)
Expand All @@ -23,4 +23,4 @@ def push(self):

def pop(self):
"""Pop the symbols stack"""
self.symbols.pop()
self.symbols.pop()
2 changes: 1 addition & 1 deletion pythonlua/tokenendmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
class TokenEndMode(Enum):
"""This enum represents token end mode"""
LINE_FEED = 0
LINE_CONTINUE = 1
LINE_CONTINUE = 1
3 changes: 2 additions & 1 deletion pythonlua/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def add_indentation(line):

return "\n".join(lines)

def get_luainit(self, filename="luainit.lua"):
@staticmethod
def get_luainit(filename="luainit.lua"):
"""Get lua initialization code."""
script_name = os.path.realpath(__file__)
folder = os.path.dirname(script_name)
Expand Down
2 changes: 1 addition & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def make_test(filename):
lua_code = translator.translate(content)

tmp_file = tempfile.NamedTemporaryFile("w")
tmp_file.write(translator.get_luainit()+ "\n")
tmp_file.write(Translator.get_luainit()+ "\n")
tmp_file.write(lua_code)
tmp_file.flush()

Expand Down

0 comments on commit 8b0a859

Please sign in to comment.