def get_paths(): curdir = os.path.abspath(__file__) curdir = os.path.dirname(curdir) curdir = os.path.dirname(curdir) sqldir = os.path.join(curdir,'sql') resultsdir,expecteddir = os.path.join(curdir,'results'),os.path.join(curdir,'expected') molet.mkdir(resultsdir,ignoreWarning = True) molet.mkdir(expecteddir,ignoreWarning = True) tup = (curdir,sqldir,resultsdir,expecteddir) return tup
def generate(config): ''' dépend de cliquid et conf produit trois fichiers ''' conf = config() # towner molet.mkdir(cliquid.PATH_DATA,ignoreWarning=True) fn = os.path.join(cliquid.PATH_DATA,'towner.sql') if(not os.path.exists(fn)): with open(fn,'w') as f: for i in range(cliquid.MAX_TOWNER): j = i+1 f.write('%i\town%i\t2013-02-10 16:24:01.651649\t\N\n' % (j,j)) # torder fn = os.path.join(cliquid.PATH_DATA,'torder_'+conf.CONF_NAME+'.sql') with open(fn,'w') as f: for i in range(cliquid.MAX_TORDER): j = i+1 w = random.randint(1,conf.MAX_OWNER) qlt_prov,qlt_requ = conf.coupleQlt(conf.distribQlt,conf.MAX_QLT) r = random.random()+0.5 qtt_requ = int(cliquid.QTT_PROV * r) # proba(QTT_PROV/qtt_requ < 1) = 0.5 #line = "%s\t(1,%i,%i,%i,%i,qlt%i,%i,qlt%i,%i)\t2013-02-10 16:24:01.651649\t\N\n" line = "%s\t(2,%i,%i,%i,%i,qlt%i,%i,qlt%i,%i,\"(0,0),(0,0)\",\"(0,0),(0,0)\",0,\"(1.5707963267949,3.14159265358979),(-1.5707963267949,-3.14159265358979)\")\t2014-04-29 19:40:44.382527\t2014-04-29 19:40:44.448502\n" f.write(line % (cliquid.DB_USER,j,w,j,qtt_requ,qlt_requ,cliquid.QTT_PROV,qlt_prov,cliquid.QTT_PROV)) # tstack fn = os.path.join(cliquid.PATH_DATA,'tstack_'+conf.CONF_NAME+'.sql') with open(fn,'w') as f: for i in range(cliquid.MAX_TSTACK): j = i+1+cliquid.MAX_TORDER w = random.randint(1,conf.MAX_OWNER) qlt_prov,qlt_requ = conf.coupleQlt(conf.distribQlt,conf.MAX_QLT) r = random.random()+0.5 qtt_requ = int(cliquid.QTT_PROV * r) # proba(QTT_PROV/qtt_requ < 1) = 0.5 line = "%i\t%s\town%i\t\N\t1\tqlt%i\t%i\tqlt%i\t%i\t%i\t100 year\t2013-03-24 22:50:08.300833\n" f.write(line % (j,cliquid.DB_USER,w,qlt_requ,qtt_requ,qlt_prov,cliquid.QTT_PROV,cliquid.QTT_PROV)) print "conf \'%s\' generated" % (conf.CONF_NAME,)