예제 #1
0
파일: whurl.py 프로젝트: chexum/nnpkg
def whurl(db_conn,filename):
	import pkgname

	(dir,fn)=os.path.split(filename)
	#{'pre': '-', 'ext': '.tar.bz2', 'tag': '', 'ver': '0.8.0', 'pkg': 'libebml'}
	tofind = pkgname.pkgsplitname(fn)

	cur = db_conn.cursor()
	url = None

	cur.execute("select path,fn,url from meta where fn like ? order by stamp desc",(tofind['pkg']+"%",))
	for row in cur.fetchall():
		(oldpath,oldfn,oldurl)=row
		oldpkg = pkgname.pkgsplitname(oldfn)
		if oldpkg['pkg'] == tofind['pkg']:
			# XXX oldpkg ext starts with tofind ext
			if oldpkg['pre']==tofind['pre'] and \
			   tofind['ext'] in oldpkg['ext'] and \
			   oldpkg['tag']==tofind['tag'] and oldfn != fn:
				possibleurl = re.sub(oldfn,fn,oldurl)
				possibleurl = re.sub(oldpkg['ver'],tofind['ver'],possibleurl)
				#XXX uniquify
				print possibleurl
	cur.close()

	return
예제 #2
0
파일: zxvf.py 프로젝트: chexum/nnpkg
def zxvf(db_conn,filename):
	import pkgname

	(dir,fn)=os.path.split(filename)
	#{'pre': '-', 'ext': '.tar.bz2', 'tag': '', 'ver': '0.8.0', 'pkg': 'libebml'}
	prop = pkgname.pkgsplitname(fn)

	cur = db_conn.cursor()

	cur.execute("select path,fn,url from meta where fn=? order by stamp desc limit 1",(fn,))
	for row in cur.fetchall():
		newfn = os.path.join(row[0],row[1])
		if filename != newfn:
			filename = newfn

	cur.execute("select path,fn from meta where fn like ? order by stamp desc",(prop['pkg']+"%",))
	for row in cur.fetchall():
		(candidatepath,candidatefn)=row
		candidate = pkgname.pkgsplitname(candidatefn)
		if candidate['pkg'] == prop['pkg'] and candidate['ver'] == prop['ver']:
			if (candidatefn != fn):
				print "similar",candidate,fn,candidatefn
	cur.close()

	print "not unpacking", filename, prop
	return