Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
parametersnapshot definition
#Copyright (c) mostafa el ayoubi , 2016
#Data-Shapes www.data-shapes.net , elayoubi.mostafa@gmail.com
#This code was inspired by Jeremy Tammik @Jeremytammik
def parametersnapshot(x):
parameters = x.Parameters
paramnames = [p.Definition.Name for p in parameters]
#Sorting is important because the parameters are queried in random order.
#We need to make sure the snapshots are ordered in the same way so we can compare them.
sortedindex = sorted(range(len(paramnames)), key = lambda k : paramnames[k])
sortedparameters = [paramnames[i] for i in sortedindex]
paramvalues = []
for p in parameters:
if p.AsString() != None:
paramvalues.append(p.AsString())
else :
paramvalues.append(p.AsValueString())
sortedvalues = [paramvalues[i] for i in sortedindex]
return ', '.join(['%s : %s' % (param,value) for param,value in zip(sortedparameters,sortedvalues)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.