Last change
on this file since 11995 was 11995, checked in by Mathieu Morlighem, 13 years ago |
merged trunk-jpl and trunk for revision 11994M
|
File size:
1.2 KB
|
Line | |
---|
1 | class pairoptions:
|
---|
2 | #properties
|
---|
3 | def __init__(self,*args):
|
---|
4 | # {{{ Properties
|
---|
5 | if len(args)%2==1:
|
---|
6 | raise RuntimeError('pairoption error message: an even number of options is required')
|
---|
7 |
|
---|
8 | #create a pairoption object
|
---|
9 | if len(args)==0:
|
---|
10 | self.list=[]
|
---|
11 | else:
|
---|
12 | self.list=[]
|
---|
13 | for i in range(int(round(len(args)/2))):
|
---|
14 | if isinstance(args[2*i],str):
|
---|
15 | self.list.append([args[2*i],args[2*i+1]])
|
---|
16 | else:
|
---|
17 | #option is not a string, ignore it
|
---|
18 | print("%s%i%s"%('buildlist info: option number ',i,' is not a string, it will be ignored'))
|
---|
19 | continue
|
---|
20 |
|
---|
21 | #}}}
|
---|
22 | def __repr__(obj):
|
---|
23 | # {{{ Display
|
---|
24 | if not obj.list:
|
---|
25 | string=' list: empty'
|
---|
26 | else:
|
---|
27 | string=" list: (%i)"%(len(obj.list))
|
---|
28 | for i in range(len(obj.list)):
|
---|
29 | if isinstance(obj.list[i][1],str):
|
---|
30 | string2=" field: %-10s value: '%s'"%(obj.list[i][0],obj.list[i][1])
|
---|
31 | elif isinstance(obj.list[i][1],float):
|
---|
32 | string2=" field: %-10s value: %g"%(obj.list[i][0],obj.list[i][1])
|
---|
33 | elif isinstance(obj.list[i][1],int):
|
---|
34 | string2=" field: %-10s value: %i"%(obj.list[i][0],obj.list[i][1])
|
---|
35 | else:
|
---|
36 | string2=" field: %-10s value: (%i)"%(len(obj.list[i][1]))
|
---|
37 | string="%s\n%s"%(string,string2)
|
---|
38 | return string
|
---|
Note:
See
TracBrowser
for help on using the repository browser.