示例#1
0
 def __init__(self, tb_name, fct_name, mode="scalar", submode="") :
     Nt2_fct_props.__init__(self,tb_name, fct_name, mode, submode)
     self.adds = {}
     self.ranges={}
     self.ad_hoc_modifications()
     self.add_includes()
     self.ad_hoc_ranges()
示例#2
0
    def write_unit(self, fct_name, mode, part, s):
        def test_immutable(p):
            s = '\n'.join(read(p))
            return s.find('//COMMENTED') != -1

        nfp = Nt2_fct_props(self.tb_name, fct_name, mode)
        p = nfp.get_fct_unit_path(mode, part)
        if exist(os.path.split(p)[0]):
            if self.verbose: print('path = %s' % p)
            print("---%s" % exist(p))
            if exist(p) and test_immutable(p):
                print("%s has been marked as immutable" % p)
                return
            if self.backup_on_write and exist(p):
                if self.verbose: print("backing up %s" % fct_name)
                i = 1
                while True:
                    pi = p + '.' + str(i) + '.bak'
                    if not (exist(pi)): break
                    i += 1
                if self.verbose: print("to %s" % pi)
                shutil.copy(p, pi)
            elif self.verbose:
                print "writing to %s" % p
            write(p, s, self.check_on_write)
            p1 = os.path.join(os.path.split(p)[0], 'CMakeLists.txt')
            addline = Add_line(p1, fct_name)
            addline.update_file("SET\( *SOURCES")
        elif self.verbose:
            print("%s directory\n  does not exist " % os.path.split(p)[0])
示例#3
0
 def __init__(self, base_gen):
     Py_doc.__init__(self, bg=base_gen, arity=1)
     self.name = self.bg.get_fct_name()
     self.tb_name = self.bg.get_tb_name()
     self.mode = self.bg.get_fct_mode()
     self.nfp = Nt2_fct_props(self.tb_name, self.name, self.mode)
     self.txts = self.tpl[self.mode]
     self.types = self.get_types()
     self.collect_py_doc_global_data()
示例#4
0
def write_bench(tb_name, fct_name, mode, s, check=False, backup=True):
    nfp = Nt2_fct_props(tb_name, fct_name, mode)
    print("mode %s" % mode)
    p = nfp.get_fct_bench_path(mode)
    ##    print ('p = %s'%p)
    if backup and exist(p):
        ##        print("p=%s" %p)
        i = 1
        while True:
            pi = p + '.' + str(i) + '.bak'
            if not (exist(pi)): break
            i += 1
        print("backing to %s" % pi)
        shutil.copy(p, pi)
    print "writing to %s" % p
    write(p, s, check)
示例#5
0
def write_exhaustive(tb_name,fct_name,mode,s,check=False,backup=True) :
    nfp = Nt2_fct_props(tb_name,fct_name,mode)
    print("mode %s"%mode)
    p = nfp.get_fct_exhaustive_path(mode)
    print ('p = %s'%p)
    if backup and exist(p) :
##        print("p=%s" %p)
        i = 1;
        while True :
            pi = p+'.'+str(i)+'.bak'
            if not(exist(pi)) : break
            i += 1
        print("backing to %s"% pi)
        shutil.copy(p,pi)
    print "writing to %s"%p
    write(p,s,check)
    p1 = os.path.join(os.path.split(p)[0],'CMakeLists.txt')
    addline=Add_line(p1,fct_name)
    addline.update_file("SET\( *SOURCES")
示例#6
0
 def __init__(self, tb_name, fct_name, fct_mode) :
     Nt2_fct_props.__init__(self,tb_name,fct_name)
     self.dl = self.get_fct_dict_list()
     self.__fct_mode = fct_mode
示例#7
0
 def __init__(self, tb_name, fct_name) :
     Nt2_fct_props.__init__(self, tb_name, fct_name)
示例#8
0
 def __init__(self, tb_name, fct_name, fct_mode) :
     Nt2_fct_props.__init__(self,tb_name,fct_name)
     self.dl = self.get_fct_dict_list()
     self.__fct_mode = fct_mode
示例#9
0
                    beg = i + offset
                    m1 = re.search("(" + ld + ")", l)
                    m2 = re.search("(" + rd + ")", l)
                    nbl += len(m1.groups()) if m1 else 0
                    nbr += len(m2.groups()) if m2 else 0
                    #                    print("tag just found i %d -> %s"% (i,l))
                    if nbl and (nbl == nbr): return (g, i, i + 1)  #[s[i]]
            else:
                m1 = re.search("(" + ld + ")", l)
                m2 = re.search("(" + rd + ")", l)
                nbl += len(m1.groups()) if m1 else 0
                nbr += len(m2.groups()) if m2 else 0
                #                print("tag      found i %d -> %s (%s,%s)"% (i,l,nbl,nbr))
                if (nbl != 0 or nbr != 0) and nbl == nbr:
                    end = i + 1
                    for j in range(beg, end):
                        if re.match(tag, s[j]): return (g, j, end)  #s[j:end]
        return (None, 0, 0)


if __name__ == "__main__":
    from nt2_fct_props import Nt2_fct_props
    nfp = Nt2_fct_props("trigonometric", "acos")
    s = nfp.get_fct_text()
    PrettyPrinter().pprint(Nt2_fct_internals.get_dispatch_types(s))
    PrettyPrinter().pprint(Nt2_fct_internals.get_calls(s))
    PrettyPrinter().pprint(Nt2_fct_internals.get_returns(s))
    PrettyPrinter().pprint(Nt2_fct_internals.get_footer(s))
    PrettyPrinter().pprint(Nt2_fct_internals.get_head_up_to_first_call(s))
    PrettyPrinter().pprint(Nt2_fct_internals.get_head_up_to_first_dispatch(s))
示例#10
0
def write_unit(tb_name, fct_name, mode, s, check=False):
    nfp = Nt2_fct_props(tb_name, fct_name, mode)
    p = nfp.get_fct_unit_path(mode)
    print "write to %s" % p
示例#11
0
 def __init__(self, tb_name,fct_name) :
     Nt2_fct_props.__init__(self, tb_name, fct_name)
     self.author = Nt2_base_infos.get_author()
     self.date = datetime.datetime.now().strftime("%d/%m/%Y")
     print("zut2")
示例#12
0
 def __init__(self, tb_name, fct_name) :
     Nt2_fct_props.__init__(self, tb_name, fct_name)
     self.__oldtxt = self.get_fct_def_text()