Ejemplo n.º 1
0
def rebuild_all():
    from langscape.base.loader import load_langlet
    good = []
    bad  = []
    for _, name in find_langlets():
        print "-"*90
        print "Build %s"%name
        print "-"*90
        try:
            load_langlet(name, build_langlet = True)
        except Exception:
            e = traceback.format_exc()
            print e
            s = "Failure: %s\n"%name
            print s
            bad.append(str(name))
        else:
            good.append(str(name))
    print "-"*90
    if good:
        print "\nSucceeded to build langlets: "
        print " "+pprint.pformat(good, indent = 4, width=1).replace("'", "").replace('"', "").replace(",", "")[1:-1]
    if bad:
        print "\nFailed to build langlets:"
        print " "+pprint.pformat(bad, indent = 4, width=1).replace("'", "").replace('"', "").replace(",", "")[1:-1]
    print
    print "-"*90+"\n"
Ejemplo n.º 2
0
def rebuild_all():
    from langscape.base.loader import load_langlet
    good = []
    bad = []
    for _, name in find_langlets():
        print "-" * 90
        print "Build %s" % name
        print "-" * 90
        try:
            load_langlet(name, build_langlet=True)
        except Exception:
            e = traceback.format_exc()
            print e
            s = "Failure: %s\n" % name
            print s
            bad.append(str(name))
        else:
            good.append(str(name))
    print "-" * 90
    if good:
        print "\nSucceeded to build langlets: "
        print " " + pprint.pformat(good, indent=4, width=1).replace(
            "'", "").replace('"', "").replace(",", "")[1:-1]
    if bad:
        print "\nFailed to build langlets:"
        print " " + pprint.pformat(bad, indent=4, width=1).replace(
            "'", "").replace('"', "").replace(",", "")[1:-1]
    print
    print "-" * 90 + "\n"
Ejemplo n.º 3
0
 def track_parent(self):
     parent_name, parent_path = self.get_parent()
     if parent_name and parent_name!="ls_grammar":
         options = {"build_langlet": True}
         parent_updater = self.__class__(parent_name, parent_path, options)
         if parent_updater.track_change():
             load_langlet(parent_name)
         base_cs = self.read_checksum(typ = "base")
         if base_cs!=parent_updater.gen_cs:
             parent_updater.grammar_gen_path().copy(self.grammar_base_path())
             self.compute_checksums()
             return True
     return False
Ejemplo n.º 4
0
 def track_parent(self):
     parent_name, parent_path = self.get_parent()
     if parent_name and parent_name != "ls_grammar":
         options = {"build_langlet": True}
         parent_updater = self.__class__(parent_name, parent_path, options)
         if parent_updater.track_change():
             load_langlet(parent_name)
         base_cs = self.read_checksum(typ="base")
         if base_cs != parent_updater.gen_cs:
             parent_updater.grammar_gen_path().copy(
                 self.grammar_base_path())
             self.compute_checksums()
             return True
     return False
Ejemplo n.º 5
0
def autorun():
    (options, args) = config.opt.parse_args()
    langlet_obj = loader.load_langlet(config.langlet_name, **options.__dict__)

    if langlet_obj.options["xml2p4d"]:
        f = path(args[-1])
        if not f.isfile():
            if f[0] == '*':
                ext = f.splitext()[1]
                for fl in path(os.getcwd()).listdir():
                    if fl.ext == ext:
                        convert2p4d(langlet_obj, fl)
                return
            else:
                f = path(os.getcwd()).joinpath(f)
        convert2p4d(langlet_obj, f)
    elif args:
        module = args[-1]
        langlet_obj.run_module(module)
    else:
        console = langlet_obj.console()
        console.interact()
Ejemplo n.º 6
0
def autorun():
    (options, args) = config.opt.parse_args()
    langlet_obj = loader.load_langlet(config.langlet_name, **options.__dict__)

    if langlet_obj.options["xml2p4d"]:
        f = path(args[-1])
        if not f.isfile():
            if f[0] == '*':
                ext = f.splitext()[1]
                for fl in path(os.getcwd()).listdir():
                    if fl.ext == ext:
                        convert2p4d(langlet_obj, fl)
                return
            else:
                f = path(os.getcwd()).joinpath(f)
        convert2p4d(langlet_obj, f)
    elif args:
        module = args[-1]
        langlet_obj.run_module(module)
    else:
        console = langlet_obj.console()
        console.interact()
Ejemplo n.º 7
0
 def _load_target_langlet(self):
     if self.config.langlet_name == self.config.target_langlet:
         self.target = self
     else:
         self.target = loader.load_langlet(self.config.target_langlet)
     self.target._load_compiler()
Ejemplo n.º 8
0
 def _load_target_langlet(self):
     if self.config.langlet_name == self.config.target_langlet:
         self.target = self
     else:
         self.target = loader.load_langlet(self.config.target_langlet)
     self.target._load_compiler()
Ejemplo n.º 9
0
import langlet_config as config
import langscape.base.loader as loader

if __name__ == '__main__':
    (options, args) = config.opt.parse_args()
    langlet_obj = loader.load_langlet(config.langlet_name, **options.__dict__)
    if args:
        module = args[-1]
        langlet_obj.run_module(module)
    else:
        console = langlet_obj.console()
        console.interact()