Skip to content

Commit

Permalink
Write GenericFunction.__init__ in a different way
Browse files Browse the repository at this point in the history
  • Loading branch information
Éric Lemoine committed Apr 9, 2020
1 parent ceba659 commit ed30d68
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions geoalchemy2/functions.py
Expand Up @@ -91,22 +91,19 @@ class ST_TransScale(GenericFunction):

def __init__(self, *args, **kwargs):
expr = kwargs.pop('expr', None)
args = list(args)
if expr is not None:
args = (expr,) + args
new_args = []
for elem in args:
args = [expr] + args
for idx, elem in enumerate(args):
if isinstance(elem, elements.HasFunction):
if elem.extended:
func_name = elem.geom_from_extended_version
func_args = [elem.data]
else:
func_name = elem.geom_from
func_args = [elem.data, elem.srid]
new_arg = getattr(functions.func, func_name)(*func_args)
else:
new_arg = elem
new_args.append(new_arg)
functions.GenericFunction.__init__(self, *new_args, **kwargs)
args[idx] = getattr(functions.func, func_name)(*func_args)
functions.GenericFunction.__init__(self, *args, **kwargs)


# Functions are classified as in the PostGIS doc.
Expand Down

0 comments on commit ed30d68

Please sign in to comment.