Ejemplo n.º 1
0
def GetSVNFiles(SVNPaths=None):
    '''
	Function for filtering files to put in the SVN repository.
	'''

    if SVNPaths == None:
        SVNPaths = []

    LinkList = LM.LinksFromOperations(LM.LoadLiveModules())

    Things = numpy.array(
        uniqify(LinkList['TargetFile'].tolist() +
                LinkList['SourceFile'].tolist() +
                LinkList['UpdateScriptFile'].tolist()))
    Things.sort()

    CreatedThings = LinkList[LinkList['LinkType'] == 'CreatedBy']['LinkTarget']
    CreatedThings.sort()

    [A, B] = getpathalong(CreatedThings, Things)
    C = uniqify(ListUnion([range(a, b) for (a, b) in zip(A, B) if b > a]))
    D = numpy.ones((len(Things), ), bool)
    D[C] = False
    [A, B] = getpathalong(Things, CreatedThings)
    GoodThings = Things[D & (B == A)]

    SVNPaths = uniqify(SVNPaths + GoodThings.tolist())

    Files = uniqify([
        x for x in ListUnion([RecursiveFileList(x) for x in SVNPaths])
        if '.svn/' not in x and '.DS_Store' not in x
    ])

    return [Files, SVNPaths]
Ejemplo n.º 2
0
def GetSVNFiles(SVNPaths=None):
	'''
	Function for filtering files to put in the SVN repository.
	'''

	if SVNPaths == None:
		SVNPaths = []

	LinkList = LM.LinksFromOperations(LM.LoadLiveModules())
	
	Things = numpy.array(uniqify(LinkList['TargetFile'].tolist() + LinkList['SourceFile'].tolist() + LinkList['UpdateScriptFile'].tolist()))
	Things.sort()
	
	CreatedThings = LinkList[LinkList['LinkType'] == 'CreatedBy']['LinkTarget']
	CreatedThings.sort()
	
	[A,B] = getpathalong(CreatedThings,Things)
	C = uniqify(ListUnion([range(a,b) for (a,b) in zip(A,B) if b > a]))
	D = numpy.ones((len(Things),), bool) ; D[C] = False
	[A,B] = getpathalong(Things,CreatedThings)
	GoodThings = Things[D & (B == A)]
		
	SVNPaths = uniqify(SVNPaths + GoodThings.tolist())
	
	Files = uniqify([x for x in ListUnion([RecursiveFileList(x) for x in SVNPaths]) if '.svn/' not in x and '.DS_Store' not in x])
	
	return [Files,SVNPaths]
Ejemplo n.º 3
0
def SafeSimpleStack(seq):
	'''
		Vertically stack sequences numpy record arrays. 
		Avoids some of the problems of numpy.v_stack
	'''

	names =  uniqify(ListUnion([list(s.dtype.names) for s in seq if s.dtype.names != None]))
	formats =  [max([s.dtype[att] for s in seq if s.dtype.names != None and att in s.dtype.names]).str for att in names]
	D = numpy.rec.fromarrays([ListUnion([s[att].tolist() if (s.dtype.names != None and att in s.dtype.names) else [nullvalue(format)] * len(s) for s in seq]) for (att,format) in zip(names,formats)], names = names)
	D = D.dumps()
	return numpy.loads(D)
Ejemplo n.º 4
0
def SafeSimpleStack(seq):
	'''
		Vertically stack sequences numpy record arrays. 
		Avoids some of the problems of numpy.v_stack
	'''

	names =  uniqify(ListUnion([list(s.dtype.names) for s in seq if s.dtype.names != None]))
	formats =  [max([s.dtype[att] for s in seq if s.dtype.names != None and att in s.dtype.names]).str for att in names]
	D = numpy.rec.fromarrays([ListUnion([s[att].tolist() if (s.dtype.names != None and att in s.dtype.names) else [nullvalue(format)] * len(s) for s in seq]) for (att,format) in zip(names,formats)], names = names)
	D = D.dumps()
	return numpy.loads(D)
Ejemplo n.º 5
0
def ConsolidateSources(metapath,objname=None,extensions=None):
	
	consolidated = {}
	if extensions is None:
		extensions = ['Attached','Associated','Automatic','Inherited']
	combined = CombineSources(metapath,extensions=extensions)

	if 'Resources' in combined.keys():
		consolidated['Resources'] = uniqify(ListUnion(combined['Resources'].values()))
			
	if 'image' in combined.keys():
		consolidated['image'] = ListUnion([x.split(',') if is_string_like(x) else x for x in combined['image'].values()])
	
	if 'author' in combined.keys():
		consolidated['author'] = '; '.join(combined['author'].values())
	
	if 'title' in combined.keys():
		consolidated['title'] = '; '.join(combined['title'].values())
	
	if 'description' in combined.keys():
		descrs = combined['description'].items()
		if len(descrs) == 1:
			consolidated['description'] = descrs[0][1]
		else:
			consolidated['description'] = '\n\n'.join([e + ': ' + d for (e,d) in descrs])
			
	elif 'Verbose' in combined.keys():
		descrs = combined['Verbose'].items()
		if len(descrs) == 1:
			consolidated['description'] = descrs[0][1]
		else:
			consolidated['description'] = '\n\n'.join([e + ': ' + d for (e,d) in descrs])
	
	if 'keywords' in combined.keys():
		for k in combined['keywords'].keys():
			if not is_string_like(combined['keywords'][k]):
				combined['keywords'][k] = ','.join(combined['keywords'][k])
				
		consolidated['keywords'] = ','.join([x.strip() for x in uniqify((','.join(combined['keywords'].values())).split(','))])
				
				
	if 'signature' in combined.keys():
		s = uniqify(combined['signature'].values())
		if len(s) == 1:
			consolidated['signature'] = s[0]
		else:
			consolidated['signature'] = ''
	
	L = ['nrows','ncols','coloring','wordassoc','colformats','coltypes','colnames','wordassoc','frequentwords','nfiles','npaths']
	LL = L + [x for x in combined.keys() if x.startswith('DIR_')]
	for x in LL:
		if x in combined.keys() and 'Automatic' in combined[x].keys():
			consolidated[x] = combined[x]['Automatic']
		elif x in combined.keys() and 'Attached' in combined[x].keys():
			consolidated[x] = combined[x]['Automatic']
		elif x in combined.keys() and 'Associated' in combined[x].keys():
			consolidated[x] = combined[x]['Associated']		
		elif x in combined.keys() and 'Inherited' in combined[x].keys():
			consolidated[x] = combined[x]['Inherited']		


	if 'coldescrs' in combined.keys():
		coldescrs = {}
		for c in combined['coldescrs'].values():
			if isinstance(c,dict):
				for k in c.keys():
					if k in coldescrs.keys():
						coldescrs[k] += (c[k],)
					else:
						coldescrs[k] = (c[k],)
	
		for k in coldescrs.keys():
			coldescrs[k] = '\n'.join(coldescrs[k])
		
		consolidated['coldescrs'] = coldescrs
				
	OtherKeys = set(combined.keys()).difference(consolidated.keys())

	for k in OtherKeys:
		consolidated[k] = ' '.join([x if is_string_like(x) else repr(x) for x in combined[k].values()])

	return consolidated