コード例 #1
0
    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
コード例 #2
0
ファイル: repl.py プロジェクト: JoaoFelipe/provbug
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
コード例 #3
0
ファイル: now_prolog.py プロジェクト: LEONOB2014/noworkflow
 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)
コード例 #4
0
 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)
コード例 #5
0
ファイル: now_sql.py プロジェクト: remram44/noworkflow
 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
コード例 #6
0
ファイル: now_sql.py プロジェクト: LEONOB2014/noworkflow
 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
コード例 #7
0
 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
コード例 #8
0
    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