"
out += "
%s
" % (self.anchor,self.anchor, self.path)
out += "
%s
" % (self.src_link())
out += self._make_list("Provides Widgets:", self.provides, False)
out += self._make_list("Uses Widgets:", self.widget_depends)
out += self._make_list("Uses Scripts:", self.js_depends)
out += self._make_list("Uses Resources:", self.file_depends)
out += self._make_list("Indirectly Uses Resources:",
set(self.list_indirects()) - self.depends())
firstRev = True
for name in sorted(self.names()):
if reverseMap(name):
if firstRev:
out += "
Used By:
"
firstRev = False
out += "- Files that reference: %s
" % name
for i in sorted(reverseMap(name)):
sf = source(i)
if sf:
out += "- %s
" % sf.get_link(i)
else:
out += "- [No Src] %s
" % (w)
out += "
"
if not firstRev:
out += "
"
try:
if mimetypes.guess_type(self.src)[0].startswith('image'):
out += "
Preview:
" % (self.src)
except: # If for some reason mime returns something that isn't a mime.
pass
out += "
"
return out
def list_indirects(self):
'''
Creates a list of indirect dependancies, i.e. a depends on b
and b depends on c, so a also depends on c.
These will all be the string representation of the widgets
which can be converted to the actual widgets by using the
source() function.
'''
tocheck = self.widget_depends | self.file_depends | self.js_depends
checked = set()
while tocheck:
checking = tocheck.pop()
checked.add(checking)
checkingsrc = source(checking)
if not checkingsrc:
continue
for item in checkingsrc.depends():
if item not in checked:
tocheck.add(item)
return checked
def parse_files():
'''Creates a list of source files and searches them for
dependancies.
'''
for f in list_files(options.install):
tmp = SourceFile(f)
if not options.quiet:
print ("Parsed: %s" % (tmp.path))
for name in tmp.names():
sourcefile_map[name] = tmp
if not options.quiet:
print ("\tFound Item: %s" % (name))
revMap = {}
def reverseMap(item, reset=False):
'''Tells an object all of those items that depend upon it, the
first time this is run it generates the table, after that simple
lookups are made.
If the tables have been updated, call reset=true in the params
to force an update.
PARAMS:
item - A string representing the item to search for.
RETURN:
A map of all of the other items that depend on this.
'''
global revMap
if reset or not revMap:
# Create Associations
revMap = {}
for sf in sourcefile_map.values():
for d in sf.depends():
try:
for name in sf.mainNames():
revMap[d].add(name)
except KeyError:
revMap[d] = set()
for name in sf.mainNames():
revMap[d].add(name)
try:
return revMap[item]
except KeyError:
return set()
def source(key):
'''Returns the source file with the given key, or None if none
found.
'''
try:
return sourcefile_map[key]
except KeyError:
return None
def output():
title = "Evergreen Widget Report: %s" % (DATE)
o = "