Miscellaneous Fixes

This commit is contained in:
Otto Winter
2019-02-03 20:46:18 +01:00
parent 98bdfc821e
commit 4a74027848
20 changed files with 63 additions and 66 deletions
+5 -2
View File
@@ -134,7 +134,7 @@ class StructInitializer(Expression):
class ArrayInitializer(Expression):
def __init__(self, *args, **kwargs): # type: (*Any, **Any) -> None
super(ArrayInitializer, self).__init__()
self.multiline = kwargs.get('multiline', True)
self.multiline = kwargs.get('multiline', False)
self.args = []
for arg in args:
if arg is None:
@@ -264,7 +264,8 @@ class FloatLiteral(Literal):
# pylint: disable=bad-continuation
def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod]
def safe_exp(
obj # type: Union[Expression, bool, str, unicode, int, long, float, TimePeriod, list]
):
# type: (...) -> Expression
if isinstance(obj, Expression):
@@ -285,6 +286,8 @@ def safe_exp(obj # type: Union[Expression, bool, str, unicode, int, long, float
return IntLiteral(int(obj.total_milliseconds))
if isinstance(obj, TimePeriodSeconds):
return IntLiteral(int(obj.total_seconds))
if isinstance(obj, (tuple, list)):
return ArrayInitializer(*[safe_exp(o) for o in obj])
raise ValueError(u"Object is not an expression", obj)