MCPcopy Index your code
hub / github.com/pyload/pyload / cast

Method cast

module/ConfigParser.py:246–265  ·  view source on GitHub ↗

cast value to given format

(self, typ, value)

Source from the content-addressed store, hash-verified

244 f.write('\t%s %s : "%s" = %s' % (data["type"], option, data["desc"], value.encode("utf8")))
245
246 def cast(self, typ, value):
247 """cast value to given format"""
248 if type(value) not in (str, unicode):
249 return value
250
251 elif typ == "int":
252 return int(value)
253 elif typ == "bool":
254 return True if value.lower() in ("1", "true", "on", "an", "yes") else False
255 elif typ == "time":
256 if not value: value = "0:00"
257 if not ":" in value: value += ":00"
258 return value
259 elif typ in ("str", "file", "folder"):
260 try:
261 return value.decode("utf8")
262 except:
263 return value
264 else:
265 return value
266
267
268 def save(self):

Callers 4

parseConfigMethod · 0.95
setMethod · 0.95
setPluginMethod · 0.95
addPluginConfigMethod · 0.95

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected