def main(): prompt = PromptClass() cfgfile = cfgFile.cfgFile() content = cfgfile.InitFile('StartPage.json', 'cfg', TransferredMeaning = True, Prompt = True) if not cfgfile: prompt.Exit() sys.exit(False) if content == '': URL = [] else: prompt.PrintErr("For Edit mode, only append URLs is allowed. Delete need to be done by yourself.") URL = json.loads(content) prompt.PrintErr("URLs:") map(prompt.PrintErr, URL) IllegalChars = r"[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\-\.\_\~\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]" try: prompt.InitInput() while True: tmp = raw_input() if re.search(IllegalChars, tmp): prompt.IllegalURL() URL.append(tmp) except EOFError: prompt.Exit() json.dump(URL, cfgfile) cfgfile.SaveFile() cfgfile.CloseFile() return
def main(): prompt = PromptClass() cfgfile = cfgFile.cfgFile() content = cfgfile.InitFile('StartPage.json', 'cfg', TransferredMeaning=True, Prompt=True) if not cfgfile: prompt.Exit() sys.exit(False) if content == '': URL = [] else: prompt.PrintErr( "For Edit mode, only append URLs is allowed. Delete need to be done by yourself." ) URL = json.loads(content) prompt.PrintErr("URLs:") map(prompt.PrintErr, URL) IllegalChars = r"[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\-\.\_\~\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]" try: prompt.InitInput() while True: tmp = raw_input() if re.search(IllegalChars, tmp): prompt.IllegalURL() URL.append(tmp) except EOFError: prompt.Exit() json.dump(URL, cfgfile) cfgfile.SaveFile() cfgfile.CloseFile() return
def main(self): prompt = PromptClass() self.cfgfile = cfgFile.cfgFile() content = self.cfgfile.InitFile('ReInfoExtract.json', 'cfg', TransferredMeaning = True, Prompt = True) if content == None: prompt.Exit() sys.exit(False) if content == '': self.RegularExpression = {} else: self.RegularExpression = json.loads(content) prompt.InitPrompt() self.FSM("Golbal", '', container = self.RegularExpression) prompt.EndPrompt() self.Save() self.cfgfile.CloseFile()
def main(self): prompt = PromptClass() self.cfgfile = cfgFile.cfgFile() content = self.cfgfile.InitFile('ReInfoExtract.json', 'cfg', TransferredMeaning=True, Prompt=True) if content == None: prompt.Exit() sys.exit(False) if content == '': self.RegularExpression = {} else: self.RegularExpression = json.loads(content) prompt.InitPrompt() self.FSM("Golbal", '', container=self.RegularExpression) prompt.EndPrompt() self.Save() self.cfgfile.CloseFile()