futzing with alignment

This commit is contained in:
Paul R. Tagliamonte 2013-04-09 20:44:05 -04:00
parent b71d5c597e
commit c0b34181bc

View File

@ -83,8 +83,7 @@ def builds(_type):
def _raise_wrong_args_number(expression, error):
err = TypeError(error % (expression.pop(0),
len(expression)))
err = TypeError(error % (expression.pop(0), len(expression)))
err.start_line = expression.start_line
err.start_column = expression.start_column
raise err
@ -94,18 +93,15 @@ def checkargs(exact=None, min=None, max=None):
def _dec(fn):
def checker(self, expression):
if exact is not None and (len(expression) - 1) != exact:
_raise_wrong_args_number(expression,
"`%%s' needs %d arguments, got %%d" %
exact)
_raise_wrong_args_number(
expression, "`%%s' needs %d arguments, got %%d" % exact)
if min is not None and (len(expression) - 1) < min:
_raise_wrong_args_number(
expression,
_raise_wrong_args_number(expression,
"`%%s' needs at least %d arguments, got %%d" % (min))
if max is not None and (len(expression) - 1) > max:
_raise_wrong_args_number(
expression,
_raise_wrong_args_number(expression,
"`%%s' needs at most %d arguments, got %%d" % (max))
return fn(self, expression)
@ -140,8 +136,7 @@ class HyASTCompiler(object):
def _mangle_branch(self, tree, start_line, start_column):
# If tree is empty, just return a pass statement
if tree == []:
return [ast.Pass(lineno=start_line,
col_offset=start_column)]
return [ast.Pass(lineno=start_line, col_offset=start_column)]
ret = []
tree = list(flatten_literal_list(tree))
@ -157,7 +152,7 @@ class HyASTCompiler(object):
if isinstance(el, ast.FunctionDef):
ret.append(ast.Return(
value=ast.Name(
arg=el.name, id=el.name, ctx=ast.Load(),
arg=el.name,id=el.name, ctx=ast.Load(),
lineno=el.lineno, col_offset=el.col_offset),
lineno=el.lineno, col_offset=el.col_offset))
@ -166,9 +161,10 @@ class HyASTCompiler(object):
ret.append(el)
continue
ret.append(ast.Expr(value=el,
lineno=el.lineno,
col_offset=el.col_offset))
ret.append(ast.Expr(
value=el,
lineno=el.lineno,
col_offset=el.col_offset))
ret.reverse()
return ret