コード例 #1
0
def inheritmetadata(From,To,creates='../System/MetaData/'):
	FromPath = opmetadatapath(From) if IsDotPath(From) else metadatapath(From)
	ToPath = opmetadatapath(To) if IsDotPath(To) else metadatapath(To)
	X = ConsolidateSources(FromPath,extensions=['Associated','Attached','Inherited'])
	F = open(ToPath + '/InheritedMetaData.pickle','wb')
	pickle.dump(X,F)
	F.close()
	ProcessMetaData(ToPath,objname=To)
コード例 #2
0
def GenerateAutomaticMetaData(objname,forced=False,use=100):	

	metapath = opmetadatapath(objname) if IsDotPath(objname) else metadatapath(objname)
	if IsDotPath(objname):
		path = '../' + '/'.join(objname.split('.')[:-1]) + '.py'
		objectname = objname.split('.')[-1]
	else:
		path = objname
		objectname =''
		
	if forced or not PathExists(metapath) or os.path.getmtime(metapath) <= FindMtime(path,objectname=objectname,Simple=False):
		if IsDir(objname):
			if objname[-1] != '/': objname += '/'
			if is_hsv_dir(objname):
				pass
			else:
				D = {}
				L = [objname + ll for ll in listdir(objname) if not ll.startswith('.')]
				for l in L:
					D.update(GenerateAutomaticMetaData(l,forced=forced))
				LL = set(L).intersection(D.keys())
				D[objname] = IntegrateDirMetaData([D[l] for l in LL])
				return D
	
		else:
			if IsPythonFile(objname) or IsDotPath(objname):
				d = StoredDocstring(objname)
				if d:
					return {objname:{'description':d,'signature': 'python'}}		
		
			elif objname.endswith(('.csv','.tsv')):
				if IsFile(objname):
					try:
						x = tabularmetadata(objname,use=use)
					except:
						x = DEFAULT_GenerateAutomaticMetaData(objname)
						print 'Failed to tabular metadata for', objname
						print_exc()
					else:
						x['signature'] = 'tabular'
					return {objname : x}

						
		return {}
	else:
		try:
			return {objname:pickle.load(open(metapath+'/AutomaticMetaData.pickle','r'))}
		except:
			return GenerateAutomaticMetaData(objname,forced=True)