buildframework/helium/tools/common/python/lib/dependancygraph.py
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
    19 
    19 
    20 import os
    20 import os
    21 import amara
    21 import amara
    22 import codecs
    22 import codecs
    23 import zipfile
    23 import zipfile
    24 from Ft.Lib import Uri
       
    25 
    24 
    26 class Library:
    25 class Library:
    27     def __init__(self, name, license, version=''):
    26     def __init__(self, name, license, version=''):
    28         self.name = name
    27         self.name = name
    29         self.license = license
    28         self.license = license
    54 COLORS = ['pink', 'red', 'lightblue', 'orange', 'green', 'yellow', 'turquoise', 'limegreen']
    53 COLORS = ['pink', 'red', 'lightblue', 'orange', 'green', 'yellow', 'turquoise', 'limegreen']
    55 
    54 
    56 class ReadIvyConfig:
    55 class ReadIvyConfig:
    57     def __init__(self, ivyfilename):
    56     def __init__(self, ivyfilename):
    58         self.ivyfilename = ivyfilename
    57         self.ivyfilename = ivyfilename
    59         self.ivyxml = amara.parse(Uri.OsPathToUri(ivyfilename))
    58         self.ivyxml = amara.parse(open(ivyfilename))
    60         self.group = ModuleGroup()
    59         self.group = ModuleGroup()
    61 
    60 
    62     def readConfigurations(self):
    61     def readConfigurations(self):
    63         for conf in self.ivyxml['ivy-module'].configurations.conf:
    62         for conf in self.ivyxml['ivy-module'].configurations.conf:
    64             color = COLORS.pop()
    63             color = COLORS.pop()
    82             if hasattr(module, 'name'):
    81             if hasattr(module, 'name'):
    83                 if 'jars' in module.name:
    82                 if 'jars' in module.name:
    84                     ivydir = os.path.dirname(self.ivyfilename)
    83                     ivydir = os.path.dirname(self.ivyfilename)
    85                     ivydir = os.path.join(ivydir, 'modules')
    84                     ivydir = os.path.join(ivydir, 'modules')
    86                     ivyjarfile = os.path.join(ivydir, module.name + '-1.0.ivy.xml')
    85                     ivyjarfile = os.path.join(ivydir, module.name + '-1.0.ivy.xml')
    87                     ivymodulexml = amara.parse(Uri.OsPathToUri(ivyjarfile))
    86                     ivymodulexml = amara.parse(open(ivyjarfile))
    88                     license = ''
    87                     license = ''
    89                     for artifact in ivymodulexml['ivy-module'].publications.xml_children:
    88                     for artifact in ivymodulexml['ivy-module'].publications.xml_children:
    90                         if hasattr(artifact, 'data'):
    89                         if hasattr(artifact, 'data'):
    91                             if 'License:' in artifact.data:
    90                             if 'License:' in artifact.data:
    92                                 license = artifact.data.strip()
    91                                 license = artifact.data.strip()
   278     graphwritefile.writelines(graphdata)
   277     graphwritefile.writelines(graphdata)
   279     graphwritefile.close()
   278     graphwritefile.close()
   280 
   279 
   281 def externalDependancies(database, output):
   280 def externalDependancies(database, output):
   282     out = open(output, 'w')
   281     out = open(output, 'w')
   283     db = amara.parse(Uri.OsPathToUri(database))
   282     db = amara.parse(open(database))
   284     out.write('digraph G {\n')
   283     out.write('digraph G {\n')
   285     for p in db.antDatabase.project:
   284     for p in db.antDatabase.project:
   286         items = []
   285         items = []
   287         if hasattr(p, 'property'):
   286         if hasattr(p, 'property'):
   288             for prop in p.property:
   287             for prop in p.property:
   331                 output.append('subgraph \"cluster%s\" {label = \"%s\"; \"%s\"}\n' % (str(p.name), str(p.name), str(t.name)))
   330                 output.append('subgraph \"cluster%s\" {label = \"%s\"; \"%s\"}\n' % (str(p.name), str(p.name), str(t.name)))
   332                 output.append('\"%s\" -> \"%s\"\n' % (str(t.name), logname))
   331                 output.append('\"%s\" -> \"%s\"\n' % (str(t.name), logname))
   333 
   332 
   334 def findLogFiles(database, output):
   333 def findLogFiles(database, output):
   335     out = open(output, 'w')
   334     out = open(output, 'w')
   336     db = amara.parse(Uri.OsPathToUri(database))
   335     db = amara.parse(open(database))
   337     out.write('digraph G {\n')
   336     out.write('digraph G {\n')
   338     output = []
   337     output = []
   339     
   338     
   340     for p in db.antDatabase.project:
   339     for p in db.antDatabase.project:
   341         if hasattr(p, 'macro'):
   340         if hasattr(p, 'macro'):