def run_prompt(self, interactive): """ Runs the interactive modus """ prompt = Interactive(self.gv) opts = ('Confirm', 'Unconfirm') sel = prompt.input_options(opts)
def run_prompt(self): self.run(False) self.debug.print_debug(self, u'Entering interactive mode') prompt = Interactive(self.gv) manipulate = NlmManipulate(self.gv) tree = manipulate.load_dom_tree() ref_items = tree.xpath('//back/ref-list/ref') # note that we don't want to exit even if there are no references to link because the user may want to delete # some delete_all = False for p in tree.xpath('//xref[@ref-type="bibr"]'): text = manipulate.get_stripped_text(p) prompt.print_(prompt.colorize('green', ("-" * 80))) if 'rid' in p.attrib and p.attrib['rid'] == 'TO_LINK': prompt.print_( u"Found an unhandled reference marker: {0}".format(text)) elif 'rid' in p.attrib: remote = next((x for x in ref_items if 'id' in x.attrib and ( x.attrib['id'] == p.attrib['rid'])), None) remote_text = manipulate.get_stripped_text( remote) if remote else '' prompt.print_( u"Found a handled reference marker: \"{0}\" which links to \"{1}\"" .format(text, remote_text)) opts = ('Skip', 'Delete', 'deleTe all', 'Enter search', 'Ibid', 'enter Link id', 'skip Rest', 'show Context') sel = '' if delete_all: sel = 'd' else: sel = prompt.input_options(opts) result = self.handle_input(manipulate, opts, p, prompt, ref_items, sel, tree=tree) if result == 'abort': manipulate.save_tree(tree) return elif result == 'delall': delete_all = True manipulate.save_tree(tree)
def run_prompt(self, interactive): if not interactive: self.debug.fatal_error( self, 'Cannot enter confirmation mode without interactive flag') prompt = Interactive(self.gv) opts = ('Confirm', 'Unconfirm', 'cOnfirm all', 'uNconfirm all', 'Abort') manipulate = NlmManipulate(self.gv) tree = manipulate.load_dom_tree() ref_items = tree.xpath('//back/ref-list/ref') # note that we don't want to exit even if there are no references to link because the user may want to delete # some delete_all = False confirm_all = False for p in tree.xpath('//ref'): text = manipulate.get_stripped_text(p) sel = '' if delete_all: sel = 'u' elif confirm_all: sel = 'c' else: prompt.print_( u"Please confirm whether the following is a bibliographic reference: {0}" .format(text)) sel = prompt.input_options(opts) result = self.handle_input(manipulate, opts, p, prompt, sel, tree, text) if result == 'abort': return elif result == 'delall': delete_all = True elif result == 'confirmall': confirm_all = True manipulate.save_tree(tree)
def run_prompt(self, interactive): if not interactive: self.debug.fatal_error(self, "Cannot enter confirmation mode without interactive flag") prompt = Interactive(self.gv) opts = ("Confirm", "Unconfirm", "cOnfirm all", "uNconfirm all", "Abort") manipulate = NlmManipulate(self.gv) tree = manipulate.load_dom_tree() ref_items = tree.xpath("//back/ref-list/ref") # note that we don't want to exit even if there are no references to link because the user may want to delete # some delete_all = False confirm_all = False for p in tree.xpath("//ref"): text = manipulate.get_stripped_text(p) sel = "" if delete_all: sel = "u" elif confirm_all: sel = "c" else: prompt.print_(u"Please confirm whether the following is a bibliographic reference: {0}".format(text)) sel = prompt.input_options(opts) result = self.handle_input(manipulate, opts, p, prompt, sel, tree, text) if result == "abort": return elif result == "delall": delete_all = True elif result == "confirmall": confirm_all = True manipulate.save_tree(tree)
def install(self, args): """ Grab a Compass package and perform the manifest creation """ if os.path.exists('out'): shutil.rmtree('out') os.mkdir('out') if args.uncompressed: compass_path = args.name else: if not args.local: path, temp_path = utils.download_compass( FRONTEND_API, args.name, args.version) else: path = args.name temp_path = None compass_path = utils.untar_compass(path, temp_path) files = os.listdir(compass_path) # check for config and interactive file for fi in files: if fi.startswith('config'): config_path = compass_path + '/' + fi elif fi.startswith('interactive'): interactive_path = compass_path + '/' + fi if not config_path: if self.LOG_LEVEL >= enums.LogLevel.ERROR.value: print('{}No configuration file found in {}'.format( ERROR_PREFIX, compass_path)) exit(1) if interactive_path: interact = Interactive(interactive_path) user_in = interact.do_prompt() else: user_in = None self.compose(compass_path, config_path, user_in, args.log_level) if temp_path: shutil.rmtree(temp_path)
def run_prompt(self): self.run(False) self.debug.print_debug(self, u'Entering interactive mode') prompt = Interactive(self.gv) manipulate = NlmManipulate(self.gv) tree = manipulate.load_dom_tree() ref_items = tree.xpath('//back/ref-list/ref') # note that we don't want to exit even if there are no references to link because the user may want to delete # some delete_all = False for p in tree.xpath('//xref[@ref-type="bibr"]'): text = manipulate.get_stripped_text(p) prompt.print_(prompt.colorize('green',("-" * 80))) if 'rid' in p.attrib and p.attrib['rid'] == 'TO_LINK': prompt.print_(u"Found an unhandled reference marker: {0}".format(text)) elif 'rid' in p.attrib: remote = next((x for x in ref_items if 'id' in x.attrib and (x.attrib['id'] == p.attrib['rid'])), None) remote_text = manipulate.get_stripped_text(remote) prompt.print_(u"Found a handled reference marker: \"{0}\" which links to \"{1}\"".format(text, remote_text)) opts = ('Skip', 'Delete', 'deleTe all', 'Enter search', 'Ibid', 'enter Link id', 'skip Rest', 'show Context') sel = '' if delete_all: sel = 'd' else: sel = prompt.input_options(opts) result = self.handle_input(manipulate, opts, p, prompt, ref_items, sel, tree=tree) if result == 'abort': manipulate.save_tree(tree) return elif result == 'delall': delete_all = True manipulate.save_tree(tree)
def main(): args = docopt(__doc__, version='meTypeset 0.1') bare_gv = GV(args) if args['--debug']: bare_gv.debug.enable_debug(True) bare_gv.debug.enable_prompt(Interactive(bare_gv)) if args['zotero']: from zotero import libzotero zotero = libzotero.LibZotero( unicode(bare_gv.settings.get_setting(u'zotero', bare_gv)), bare_gv) term = args['<query>'] term = re.sub(r'[\-,\.\<\>\(\)\;\:\@\'\#\~\}\{\[\]\"\!\\/]', ' ', term) term = term.replace(u'“', u'') term = re.sub(u'[^\s]+?\s[Ee]dition', u' ', term) term = term.replace(u'\'s', u'') term = term.replace(u'’s', u'') term = term.replace(u'’', u'') term = term.replace(u'”', u'') term = re.sub(r'[Aa]ccessed', '', term) term = re.sub(r'meTypesetbr', '', term) term = re.sub(r'\s+', ' ', term) results = zotero.search(term.strip()) bare_gv.debug.print_debug(bare_gv, "%d results for %s" % (len(results), term)) for item in results: interactive = Interactive(bare_gv) interactive.print_(item.JATS_format()) return bibliography_database_instance = BibliographyDatabase(bare_gv) bibliography_database_instance.run()
def main(): args = docopt(__doc__, version='meTypeset 0.1') bare_gv = GV(args) if args['--debug']: bare_gv.debug.enable_debug(True) bare_gv.debug.enable_prompt(Interactive(bare_gv)) if args['zotero']: from zotero import libzotero zotero = libzotero.LibZotero(unicode(bare_gv.settings.get_setting(u'zotero', bare_gv)), bare_gv) term = args['<query>'] term = re.sub(r'[\-,\.\<\>\(\)\;\:\@\'\#\~\}\{\[\]\"\!\\/]', ' ', term) term = term.replace(u'“', u'') term = re.sub(u'[^\s]+?\s[Ee]dition', u' ', term) term = term.replace(u'\'s', u'') term = term.replace(u'’s', u'') term = term.replace(u'’', u'') term = term.replace(u'”', u'') term = re.sub(r'[Aa]ccessed', '', term) term = re.sub(r'meTypesetbr', '', term) term = re.sub(r'\s+', ' ', term) results = zotero.search(term.strip()) bare_gv.debug.print_debug(bare_gv, "%d results for %s" % (len(results), term)) for item in results: interactive = Interactive(bare_gv) interactive.print_(item.JATS_format()) return bibliography_database_instance = BibliographyDatabase(bare_gv) bibliography_database_instance.run()
def run_prompt(self): self.run(False) self.debug.print_debug(self, u"Entering interactive mode") prompt = Interactive(self.gv) manipulate = NlmManipulate(self.gv) tree = manipulate.load_dom_tree() ref_items = tree.xpath("//back/ref-list/ref") # note that we don't want to exit even if there are no references to link because the user may want to delete # some delete_all = False for p in tree.xpath('//xref[@ref-type="bibr"]'): text = manipulate.get_stripped_text(p) if "rid" in p.attrib and p.attrib["rid"] == "TO_LINK": prompt.print_(u"Found an unhandled reference marker: {0}".format(text)) elif "rid" in p.attrib: remote = next((x for x in ref_items if "id" in x.attrib and (x.attrib["id"] == p.attrib["rid"])), None) remote_text = manipulate.get_stripped_text(remote) prompt.print_(u'Found a handled reference marker: "{0}" which links to "{1}"'.format(text, remote_text)) opts = ( "Skip", "Delete", "deleTe all", "Enter search", "Ibid", "enter Link id", "skip Rest", "show Context", ) sel = "" if delete_all: sel = "d" else: sel = prompt.input_options(opts) result = self.handle_input(manipulate, opts, p, prompt, ref_items, sel, tree=tree) if result == "abort": manipulate.save_tree(tree) return elif result == "delall": delete_all = True manipulate.save_tree(tree)
def __init__(self): # read command line arguments self.args = self.read_command_line() # absolute first priority is to initialize debugger so that anything triggered here can be logged self.debug = Debug() Debuggable.__init__(self, 'cassius-import') self.in_file = self.args['<in-file>'] self.out_file = self.args['<out-file>'] self.dir = os.path.dirname(os.path.abspath(__file__)) if self.args['--debug']: self.debug.enable_debug() self.debug.enable_prompt(Interactive(self.args['--debug']))
def __init__(self): # read command line arguments self.args = self.read_command_line() # absolute first priority is to initialize debugger so that anything triggered here can be logged self.debug = Debug() Debuggable.__init__(self, 'Main') if self.args['--debug']: self.debug.enable_debug(self.args['--nogit']) # read settings file self.settings_file_path = 'default' self.tei_file_path = None self.settings_file_path = Settings.setup_settings_file(self.args) self.settings = Settings(Settings.get_settings_file(self, self.settings_file_path), self.args) self.gv = GV(self.settings, self.debug) self.debug.enable_prompt(Interactive(self.gv))
from interactive import Interactive from input import File if __name__ == "__main__": print( "1.interactive for manual input. 2.file input for giving input in a file" ) interaction = input("write interactive or file to choose from them :") print() manual = Interactive() auto = File() if interaction == "interactive": cnt = 0 while cnt < 2: if cnt == 0: manual.Create_Parking() cnt += 1 else: manual.Activities() cnt += 1 elif interaction == "file": print("file E:\AttainU\PL\python-project-nihar-mohanty-au16") file_address = input("file location please :") f = open(file_address, "r") cnt = 0 for row in f: if cnt == 0: auto.Create_Parking(row) cnt += 1
def interactive(config, folder, args): try: Interactive(folder).run() except IndexError: print("unhandled index error in interactive mode")
import argparse import grbl from interactive import Interactive if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-s", "--start-console", action="store_true") parser.add_argument("-e", "--end-console", action="store_true") parser.add_argument("device") parser.add_argument("-f", "--filename") parser.add_argument("-b", "--baudrate", type=int, default=115200) args = parser.parse_args() with grbl.Serial(args.device, args.baudrate) as serial: controller = grbl.Controller(serial) controller.unlock() if args.start_console: inter = Interactive(controller) inter.cmdloop() controller.reset_origin() if "filename" in args: controller.send_file(args.filename) if args.end_console: inter = Interactive(controller) inter.cmdloop()
from interactive import Interactive from file_input import FileInput if __name__ == "__main__": print("Type interactive for manual input or file for auto inputs.") interaction = input("write interactive or file to choose from them :") print() manual = Interactive() auto = FileInput() if interaction == "interactive": cnt = 0 while cnt < 2: if cnt == 0: manual.create_Parking() cnt += 1 else: manual.activities() cnt += 1 elif interaction == "file": file_address = "new.txt" f = open(file_address, "r") cnt = 0 for row in f: if cnt == 0: auto.create_Parking(row) cnt += 1 else: auto.activities(row)
from graph import Graph from args import parse_args from pre_train import PreTraining from interactive import Interactive def train(walk=False, struc=False, link=False, attr=False, walk_struc=False, classes=False): pre_train = PreTraining(graph, args) pre_train.structure_proximity(trained=struc) pre_train.deep_walk(trained=walk, num_walks=100, walk_length=10, workers=13) pre_train.link_proximity(trained=link) pre_train.attributes_proximity(trained=attr) pre_train.walk_proximity(trained=walk_struc, num_walks=100, walk_length=5, workers=13) pre_train.classes_proximity(trained=classes) if __name__ == '__main__': args = parse_args() classes_path = args.classes_input edges_path = args.edges_list graph = Graph(test=0.5) # graph.load_edgelist(edges_path) train(walk=True, struc=True, link=False, attr=True, walk_struc=True, classes=True) # train(walk=True, struc=True, link=True, attr=True, walk_struc=True, classes=True) interactive = Interactive(graph, args) interactive.train(task='link')
self.paren_depth += 1 elif cmd.data == ')': self.paren_depth -= 1 if self.paren_depth == 0: self.finish_recording() else: cmd.execute(self) def finish_recording(self): w = stapel_types.UserDefinedWord(self.recorded[:-1]) self.recorded = [] self.push(w) def push(self, x): self.datastack[-1].append(x) def pop(self): return self.datastack[-1].pop() def stack_repr(self): reprs = [repr(x) for x in self.datastack[-1]] return string.join(reprs, " ") if __name__ == "__main__": from interactive import Interactive interactive = Interactive() interactive.mainloop()
def partial_decrypt(key, ciphertext): return [ chr(k ^ c) if k is not None else '*' for k, c in zip(key, ciphertext) ] # Add target to ciphertexts so it can be decrypted ciphertexts.append(bytearray.fromhex(target)) while True: def on_change_hook(level, index, char): global final_key ciphertext = ciphertexts[level] final_key[index] = char ^ ciphertext[index] texts = [ ''.join(partial_decrypt(final_key, ciphertext)) for ciphertext in ciphertexts ] texts[level] = ''.join(partial_decrypt(final_key, ciphertext)) return texts partial_decrypts = [ ''.join(partial_decrypt(final_key, ciphertext)) for ciphertext in ciphertexts ] Interactive(partial_decrypts, on_change_hook=on_change_hook).start()