def __parseCfg(self, cfgFile, data, lItem): tmpList = CList() data = data.replace('\r\n', '\n').split('\n') items = [] tmp = None hasOwnCfg = False for m in data: if m and m[0] != '#': index = m.find('=') if index != -1: key = lower(m[:index]).strip() value = m[index+1:] index = value.find('|') if value[:index] == 'sports.devil.locale': value = common.translate(int(value[index+1:])) elif value[:index] == 'sports.devil.image': value = os.path.join(common.Paths.imgDir, value[index+1:]) if key == 'start': tmpList.start = value elif key == 'section': tmpList.section = value elif key == 'sort': tmpList.sort = value elif key == 'skill': tmpList.skill = value elif key == 'catcher': tmpList.catcher = value elif key == 'item_infos': rule_tmp = CRuleItem() hasOwnCfg = False rule_tmp.infos = value elif key == 'item_order': rule_tmp.order = value elif key == 'item_skill': rule_tmp.skill = value elif key == 'item_curr': rule_tmp.curr = value elif key == 'item_precheck': rule_tmp.precheck = value elif key.startswith('item_info'): tmpkey = key[len('item_info'):] if tmpkey == '_name': info_tmp = CItemInfo() info_tmp.name = value if value == 'cfg': hasOwnCfg = True elif tmpkey == '_from': info_tmp.src = value elif tmpkey == '': info_tmp.rule = value elif tmpkey == '_default': info_tmp.default = value elif tmpkey == '_convert': info_tmp.convert.append(value) elif tmpkey == '_build': info_tmp.build = value rule_tmp.info_list.append(info_tmp) elif key == 'item_url_build': rule_tmp.url_build = value if tmpList.catcher != '': refInf = CItemInfo() refInf.name = 'referer' refInf.build = value rule_tmp.info_list.append(refInf) if not hasOwnCfg: refInf = CItemInfo() refInf.name = 'catcher' refInf.build = tmpList.catcher rule_tmp.info_list.append(refInf) tmpList.rules.append(rule_tmp) # static menu items (without regex) elif key == 'title': tmp = CListItem() tmp['title'] = value if tmpList.skill.find('videoTitle') > -1: tmp['videoTitle'] = value elif key == 'url': tmp['url'] = value if lItem: tmp.merge(lItem) if tmpList.catcher != '': tmp['referer'] = value if not hasOwnCfg: tmp['catcher'] = tmpList.catcher tmp['definedIn'] = cfgFile items.append(tmp) tmp = None elif tmp != None: if key == 'cfg': hasOwnCfg = True tmp[key] = value tmpList.items = items tmpList.cfg = cfgFile return tmpList
def __parseCfg(self, cfgFile, data, lItem): tmpList = CList() data = data.replace('\r\n', '\n').split('\n') items = [] tmp = None hasOwnCfg = False for m in data: if m and m[0] != '#': index = m.find('=') if index != -1: key = lower(m[:index]).strip() value = m[index + 1:] index = value.find('|') if value[:index] == 'sports.devil.locale': value = common.translate(int(value[index + 1:])) elif value[:index] == 'sports.devil.image': value = os.path.join(common.Paths.imgDir, value[index + 1:]) if key == 'start': tmpList.start = value elif key == 'section': tmpList.section = value elif key == 'sort': tmpList.sort = value elif key == 'skill': tmpList.skill = value elif key == 'catcher': tmpList.catcher = value elif key == 'item_infos': rule_tmp = CRuleItem() hasOwnCfg = False rule_tmp.infos = value elif key == 'item_order': rule_tmp.order = value elif key == 'item_skill': rule_tmp.skill = value elif key == 'item_curr': rule_tmp.curr = value elif key == 'item_precheck': rule_tmp.precheck = value elif key.startswith('item_info'): tmpkey = key[len('item_info'):] if tmpkey == '_name': info_tmp = CItemInfo() info_tmp.name = value if value == 'cfg': hasOwnCfg = True elif tmpkey == '_from': info_tmp.src = value elif tmpkey == '': info_tmp.rule = value elif tmpkey == '_default': info_tmp.default = value elif tmpkey == '_convert': info_tmp.convert.append(value) elif tmpkey == '_build': info_tmp.build = value rule_tmp.info_list.append(info_tmp) elif key == 'item_url_build': rule_tmp.url_build = value if tmpList.catcher != '': refInf = CItemInfo() refInf.name = 'referer' refInf.build = value rule_tmp.info_list.append(refInf) if not hasOwnCfg: refInf = CItemInfo() refInf.name = 'catcher' refInf.build = tmpList.catcher rule_tmp.info_list.append(refInf) tmpList.rules.append(rule_tmp) # static menu items (without regex) elif key == 'title': tmp = CListItem() tmp['title'] = value if tmpList.skill.find('videoTitle') > -1: tmp['videoTitle'] = value elif key == 'url': tmp['url'] = value if lItem: tmp.merge(lItem) if tmpList.catcher != '': tmp['referer'] = value if not hasOwnCfg: tmp['catcher'] = tmpList.catcher tmp['definedIn'] = cfgFile items.append(tmp) tmp = None elif tmp != None: if key == 'cfg': hasOwnCfg = True tmp[key] = value tmpList.items = items tmpList.cfg = cfgFile return tmpList
def __parseCfg(self, cfgFile, data, lItem): tmpList = CList() data = data.replace("\r\n", "\n").split("\n") items = [] tmp = None hasOwnCfg = False for m in data: if m and m[0] != "#": index = m.find("=") if index != -1: key = lower(m[:index]).strip() value = m[index + 1 :] index = value.find("|") if value[:index] == "sports.devil.locale": value = common.translate(int(value[index + 1 :])) elif value[:index] == "sports.devil.image": value = os.path.join(common.Paths.imgDir, value[index + 1 :]) if key == "start": tmpList.start = value elif key == "section": tmpList.section = value elif key == "sort": tmpList.sort = value elif key == "skill": tmpList.skill = value elif key == "catcher": tmpList.catcher = value elif key == "item_infos": rule_tmp = CRuleItem() hasOwnCfg = False rule_tmp.infos = value elif key == "item_order": rule_tmp.order = value elif key == "item_skill": rule_tmp.skill = value elif key == "item_curr": rule_tmp.curr = value elif key == "item_precheck": rule_tmp.precheck = value elif key.startswith("item_info"): tmpkey = key[len("item_info") :] if tmpkey == "_name": info_tmp = CItemInfo() info_tmp.name = value if value == "cfg": hasOwnCfg = True elif tmpkey == "_from": info_tmp.src = value elif tmpkey == "": info_tmp.rule = value elif tmpkey == "_default": info_tmp.default = value elif tmpkey == "_convert": info_tmp.convert.append(value) elif tmpkey == "_build": info_tmp.build = value rule_tmp.info_list.append(info_tmp) elif key == "item_url_build": rule_tmp.url_build = value if tmpList.catcher != "": refInf = CItemInfo() refInf.name = "referer" refInf.build = value rule_tmp.info_list.append(refInf) if not hasOwnCfg: refInf = CItemInfo() refInf.name = "catcher" refInf.build = tmpList.catcher rule_tmp.info_list.append(refInf) tmpList.rules.append(rule_tmp) # static menu items (without regex) elif key == "title": tmp = CListItem() tmp["title"] = value if tmpList.skill.find("videoTitle") > -1: tmp["videoTitle"] = value elif key == "url": tmp["url"] = value if lItem: tmp.merge(lItem) if tmpList.catcher != "": tmp["referer"] = value if not hasOwnCfg: tmp["catcher"] = tmpList.catcher tmp["definedIn"] = cfgFile items.append(tmp) tmp = None elif tmp != None: if key == "cfg": hasOwnCfg = True tmp[key] = value tmpList.items = items tmpList.cfg = cfgFile return tmpList