def provn(self, line, cell): # Remove comment on %%provn line pos = line.find("#") line = line[:pos if pos != -1 else None] formatter = DollarFormatter() line = formatter.vformat(line, args=[], kwargs=self.shell.user_ns.copy()) args = parse_argstring(self.provn, line) provn, dot_content = configure_graph(graph, args, cell) extensions = [x.lower() for x in args.extensions] if "provn" in extensions: if args.output: with open(args.output + ".provn", "w") as f: f.write(provn) extensions.remove("provn") if not extensions: return "provn file created" dot_display = DotDisplay(dot_content, extensions, args.prog, args.extra) if args.output: dot_display.save(*((args.output + "." + ext) for ext in extensions)) return dot_display
def _pb_format(value): if value is None: return value try: shell = get_ipython() formatter = DollarFormatter() value = formatter.vformat(value, args=[], kwargs=shell.user_ns.copy()) except NameError: pass return value
def execute(self, func, line, cell, magic_cls): formatter = DollarFormatter() cell = formatter.vformat(cell, args=[], kwargs=magic_cls.shell.user_ns.copy()) _, args = self.arguments(func, line) for trial_ref in args.trials: trial = Trial(trial_ref=trial_ref) trial.prolog.load_cli_facts() result = TrialProlog.prolog_query(cell) if args.result: magic_cls.shell.user_ns[args.result] = result else: return list(result)
def execute(self, func, line, cell, magic_cls): formatter = DollarFormatter() cell = formatter.vformat(cell, args=[], kwargs=magic_cls.shell.user_ns.copy()) _, args = self.arguments(func, line) for trial_ref in args.trials: trial = Trial(trial_ref=trial_ref) trial.prolog.load_cli_facts() result = TrialProlog.prolog_query(cell) if args.result: magic_cls.shell.user_ns[args.result] = result else: return list(result)
def execute(self, func, line, cell, magic_cls): f = DollarFormatter() cell = f.vformat(cell, args=[], kwargs=magic_cls.shell.user_ns.copy()) _, args = self.arguments(func, line) result = persistence.query(default_string(cell)) if args.result: magic_cls.shell.user_ns[args.result] = result else: result = list(result) table = Table() if result: table.append(list(keys(result[0]))) for line in result: table.append(list(values(line))) return table
def execute(self, func, line, cell, magic_cls): formatter = DollarFormatter() cell = formatter.vformat(cell, args=[], kwargs=magic_cls.shell.user_ns.copy()) _, args = self.arguments(func, line) result = relational.query(text_to_native_str(cell)) if args.result: magic_cls.shell.user_ns[args.result] = result else: result = list(result) table = Table() if result: table.append(list(viewkeys(result[0]))) for line in result: table.append(list(viewvalues(line))) return table
def execute(self, func, line, cell, magic_cls): formatter = DollarFormatter() cell = formatter.vformat(cell, args=[], kwargs=magic_cls.shell.user_ns.copy()) _, args = self.arguments(func, line) result = relational.query(text_to_native_str(cell)) if args.result: magic_cls.shell.user_ns[args.result] = result else: result = list(result) table = Table() if result: table.append(list(viewkeys(result[0]))) for line in result: table.append(list(viewvalues(line))) return table
def dot(self, line, cell): # pylint: disable=E0602 # Remove comment on %%provn line pos = line.find("#") line = line[:pos if pos != -1 else None] formatter = DollarFormatter() line = formatter.vformat(line, args=[], kwargs=self.shell.user_ns.copy()) args = parse_argstring(self.dot, line) dot_display = DotDisplay(cell, args.extensions, args.prog, args.extra) if args.output: dot_display.save(*((args.output + "." + ext) for ext in args.extensions)) return dot_display