-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssdmfieldvalue.py
26 lines (23 loc) · 939 Bytes
/
ssdmfieldvalue.py
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
import sys
import os
###############################################################################
def main(*opargs, **kwargs):
'''test rig for ssdmfieldvalue'''
print(readvalue("SURVEY_ID", "defaultvalue"))
print(readvalue("invalidrequest", "defaultvalue"))
###############################################################################
def readvalue(fieldname, default=""):
dir = os.path.dirname(os.path.abspath(__file__))
filename = 'ssdmfieldvalue.txt'
filename = os.path.join(dir, filename)
if not os.path.isfile(filename):
return default
file = open(filename)
for line in file:
if line.lower().startswith(fieldname.lower()):
fields = line.strip().split(',')
if len(fields) > 0:
return str(fields[1]).strip()
###############################################################################
if __name__ == "__main__":
main()