7
7
import os
8
8
import re
9
9
import zipfile
10
- import six
11
10
import threading
12
11
13
12
13
+ # Avoid using six as this file should be usable without any dependencies
14
+ try :
15
+ string_types = (basestring ,)
16
+ except NameError :
17
+ string_types = (str ,)
18
+
19
+
14
20
def S_ERROR (messageString = '' ):
15
21
return {'OK' : False , 'Message' : str (messageString )}
16
22
@@ -21,8 +27,8 @@ def S_OK(value=''):
21
27
22
28
class ListDummy (object ):
23
29
def fromChar (self , inputString , sepChar = "," ):
24
- if not (isinstance (inputString , six . string_types )
25
- and isinstance (sepChar , six . string_types )
30
+ if not (isinstance (inputString , string_types )
31
+ and isinstance (sepChar , string_types )
26
32
and sepChar ): # to prevent getting an empty String as argument
27
33
return None
28
34
@@ -100,7 +106,7 @@ def createNewSection(self, sectionName, comment="", contents=False):
100
106
if not recDict :
101
107
return S_ERROR ("Parent section does not exist %s" % sectionName )
102
108
parentSection = recDict ['value' ]
103
- if isinstance (parentSection , six . string_types ):
109
+ if isinstance (parentSection , string_types ):
104
110
raise KeyError ("Entry %s doesn't seem to be a section" % recDict ['key' ])
105
111
return parentSection .createNewSection (recDict ['levelsBelow' ], comment , contents )
106
112
self .__addEntry (sectionName , comment )
@@ -145,7 +151,7 @@ def setOption(self, optionName, value, comment=""):
145
151
if not recDict :
146
152
return S_ERROR ("Parent section does not exist %s" % optionName )
147
153
parentSection = recDict ['value' ]
148
- if isinstance (parentSection , six . string_types ):
154
+ if isinstance (parentSection , string_types ):
149
155
raise KeyError ("Entry %s doesn't seem to be a section" % recDict ['key' ])
150
156
return parentSection .setOption (recDict ['levelsBelow' ], value , comment )
151
157
self .__addEntry (optionName , comment )
@@ -259,9 +265,9 @@ def listOptions(self, ordered=True):
259
265
:return: List with the option names
260
266
"""
261
267
if ordered :
262
- return [sKey for sKey in self .__orderedList if isinstance (self .__dataDict [sKey ], six . string_types )]
268
+ return [sKey for sKey in self .__orderedList if isinstance (self .__dataDict [sKey ], string_types )]
263
269
else :
264
- return [sKey for sKey in self .__dataDict .keys () if isinstance (self .__dataDict [sKey ], six . string_types )]
270
+ return [sKey for sKey in self .__dataDict .keys () if isinstance (self .__dataDict [sKey ], string_types )]
265
271
266
272
@gCFGSynchro
267
273
def listSections (self , ordered = True ):
@@ -273,9 +279,9 @@ def listSections(self, ordered=True):
273
279
:return: List with the subsection names
274
280
"""
275
281
if ordered :
276
- return [sKey for sKey in self .__orderedList if not isinstance (self .__dataDict [sKey ], six . string_types )]
282
+ return [sKey for sKey in self .__orderedList if not isinstance (self .__dataDict [sKey ], string_types )]
277
283
else :
278
- return [sKey for sKey in self .__dataDict .keys () if not isinstance (self .__dataDict [sKey ], six . string_types )]
284
+ return [sKey for sKey in self .__dataDict .keys () if not isinstance (self .__dataDict [sKey ], string_types )]
279
285
280
286
@gCFGSynchro
281
287
def isSection (self , key ):
@@ -291,11 +297,11 @@ def isSection(self, key):
291
297
if not keyDict :
292
298
return False
293
299
section = keyDict ['value' ]
294
- if isinstance (section , six . string_types ):
300
+ if isinstance (section , string_types ):
295
301
return False
296
302
secKey = keyDict ['levelsBelow' ]
297
303
return section .isSection (secKey )
298
- return key in self .__dataDict and not isinstance (self .__dataDict [key ], six . string_types )
304
+ return key in self .__dataDict and not isinstance (self .__dataDict [key ], string_types )
299
305
300
306
@gCFGSynchro
301
307
def isOption (self , key ):
@@ -311,11 +317,11 @@ def isOption(self, key):
311
317
if not keyDict :
312
318
return False
313
319
section = keyDict ['value' ]
314
- if isinstance (section , six . string_types ):
320
+ if isinstance (section , string_types ):
315
321
return False
316
322
secKey = keyDict ['levelsBelow' ]
317
323
return section .isOption (secKey )
318
- return key in self .__dataDict and isinstance (self .__dataDict [key ], six . string_types )
324
+ return key in self .__dataDict and isinstance (self .__dataDict [key ], string_types )
319
325
320
326
def listAll (self ):
321
327
"""
@@ -399,7 +405,7 @@ def getOption(self, opName, defaultValue=None):
399
405
return defaultValue
400
406
dataD = dataV
401
407
402
- if not isinstance (dataV , six . string_types ):
408
+ if not isinstance (dataV , string_types ):
403
409
optionValue = defaultValue
404
410
else :
405
411
optionValue = dataV
@@ -465,7 +471,7 @@ def getAsDict(self, path=""):
465
471
if not reqDict :
466
472
return resVal
467
473
keyCfg = reqDict ['value' ]
468
- if isinstance (keyCfg , six . string_types ):
474
+ if isinstance (keyCfg , string_types ):
469
475
return resVal
470
476
return keyCfg .getAsDict ()
471
477
for op in self .listOptions ():
0 commit comments