def __init__(self, filename): ag = ivy_new() try: ivy_load_file(open(filename), ag) except IvyError as e: e.filename = filename raise e self.ivy_ag = ag self.ivy_interp = ag.domain
def source_file(fn, f, **kwargs): try: with iu.SourceFile(fn): ivy_load_file(f, **kwargs) ivy_module.module.name = fn[:fn.rindex('.')] except IvyError as e: if not hasattr(e, 'filename'): e.filename = fn print str(e) sys.exit(1)
def source_file(fn,f,**kwargs): try: with iu.SourceFile(fn): ivy_load_file(f,**kwargs) ivy_module.module.name = fn[:fn.rindex('.')] except IvyError as e: if not hasattr(e,'filename'): e.filename = fn print str(e) sys.exit(1)
def source_file(fn, f, **kwargs): try: with iu.SourceFile(fn): ivy_load_file(f, **kwargs) ivy_module.module.name = fn[:fn.rindex('.')] except IvyError as e: if not hasattr(e, 'filename'): e.filename = fn print str(e) if hasattr(e, 'source_location'): print e.source_location.context_line if e.source_location.column: print ' ' * (e.source_location.column - 1) + '^' sys.exit(1)
def ivy_init(): read_params() # if mode.get() == "ivy2": # return ivy_init2() if len(sys.argv) < 2 or len(sys.argv) > 3: usage() files = [(fn, open_read(fn)) for fn in sys.argv[1:]] if files[0][0].endswith('.a2g'): fn, f = files.pop(0) ag = pickle.load(f) if not hasattr(ag.domain, 'all_relations'): # print "reconstructing all_relations" ag.domain.all_relations = [] for x in ag.domain.relations: ag.domain.all_relations.append((x, ag.domain.relations[x])) for (x, y) in ag.domain.concepts: ag.domain.all_relations.append( (x.atom.relname, len(x.atom.args))) ivy_logic.sig = ag.domain.sig # TODO: make this an environment f.close() else: # print "creating new" ag = ivy_new() if files: fn, f = files.pop(0) if not fn.endswith('.ivy') and not fn.endswith('.dfy'): usage() try: # print "loading file %s" % fn with iu.SourceFile(fn): ivy_load_file(f, ag) except IvyError as e: if not hasattr(e, 'filename'): e.filename = fn print repr(e) sys.exit(1) return ag
def ivy_init(): read_params() # if mode.get() == "ivy2": # return ivy_init2() if len(sys.argv) < 2 or len(sys.argv) > 3: usage() files = [(fn,open_read(fn)) for fn in sys.argv[1:]] if files[0][0].endswith('.a2g'): fn,f = files.pop(0) ag = pickle.load(f) if not hasattr(ag.domain,'all_relations'): # print "reconstructing all_relations" ag.domain.all_relations = [] for x in ag.domain.relations: ag.domain.all_relations.append((x,ag.domain.relations[x])) for (x,y) in ag.domain.concepts: ag.domain.all_relations.append((x.atom.relname,len(x.atom.args))) ivy_logic.sig = ag.domain.sig # TODO: make this an environment f.close() else: # print "creating new" ag = ivy_new() if files: fn,f = files.pop(0) if not fn.endswith('.ivy') and not fn.endswith('.dfy'): usage() try: # print "loading file %s" % fn with iu.SourceFile(fn): ivy_load_file(f,ag) except IvyError as e: if not hasattr(e,'filename'): e.filename = fn print repr(e) sys.exit(1) return ag