-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateFieldNames.py
More file actions
29 lines (22 loc) · 928 Bytes
/
createFieldNames.py
File metadata and controls
29 lines (22 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# imports
import leads
# copy and paste this output into fieldNames.py so that you can access all your
# field names in your Marketo instance through code completion in your IDE
data = leads.describe2Lead()
firstLower = lambda s: s[:1].lower() + s[1:] if s else ''
allValues = set()
for apiNameList in data['result'][0]['fields']:
apiName = apiNameList['name']
apiName = apiName.strip()
if apiName[-3:] == "__c":
varName = apiName.replace("__c", "").replace("_", "").replace("-", "") + "c"
else:
varName = apiName.replace("_", "").replace("-", "")
# lower camel case unless acronym
if len(varName) > 1 and (varName[1].islower() or varName[1].isnumeric()):
varName = firstLower(varName)
# if there are duplicates
if varName in allValues:
varName += '2'
allValues.add(varName)
print(varName + " = " + "'" + apiName + "'")