tools/gen-components
changeset 1205 6c6c27bcf9ac
parent 1139 2fe2a52488cb
child 2140 ba3091d7e9b6
equal deleted inserted replaced
1204:c8e9f85492a3 1205:6c6c27bcf9ac
    30 import getopt
    30 import getopt
    31 import os
    31 import os
    32 import sys
    32 import sys
    33 
    33 
    34 debug = False
    34 debug = False
       
    35 
       
    36 # TPNO string to search for in each .p5m file.
       
    37 TPNO_str = "com.oracle.info.tpno"
    35 
    38 
    36 # Hashtable of components with TPNOs keyed by component name.
    39 # Hashtable of components with TPNOs keyed by component name.
    37 comp_TPNOs = {}
    40 comp_TPNOs = {}
    38 
    41 
    39 # Hashtable of RE's, RM's and Teams keyed by component path.
    42 # Hashtable of RE's, RM's and Teams keyed by component path.
   127 # Return a hashtable of components with TPNOs keyed by component name.
   130 # Return a hashtable of components with TPNOs keyed by component name.
   128 def find_TPNOs(workspace):
   131 def find_TPNOs(workspace):
   129     comp_TPNOs = {}
   132     comp_TPNOs = {}
   130     for directory, _, files in os.walk(workspace + "/components"):
   133     for directory, _, files in os.walk(workspace + "/components"):
   131         for filename in files:
   134         for filename in files:
   132             if filename.endswith(".license") or filename.endswith(".copyright"):
   135             if filename.endswith(".p5m"):
   133                 pathname = os.path.join(directory, filename)
   136                 pathname = os.path.join(directory, filename)
   134                 fin = open(pathname, 'r')
   137                 fin = open(pathname, 'r')
   135                 lines = fin.readlines()
   138                 lines = fin.readlines()
   136                 fin.close()
   139                 fin.close()
   137 
   140 
   138                 for line in lines:
   141                 for line in lines:
   139                     line = line.replace("\n", "")
   142                     line = line.replace("\n", "")
   140                     if line.startswith("Oracle Internal Tracking Number"):
   143                     n = line.find(TPNO_str)
   141                         tpno_str = line.split()[-1]
   144                     if n != -1:
       
   145                         tpno_str = line[n:].split("=")[1]
   142                         try:
   146                         try:
   143                             # Check that the TPNO is a valid number.
   147                             # Check that the TPNO is a valid number.
   144                             tpno = int(tpno_str)
   148                             tpno = int(tpno_str)
   145                             if debug:
   149                             if debug:
   146                                 print >> sys.stderr, "TPNO: %s: %s" % \
   150                                 print >> sys.stderr, "TPNO: %s: %s" % \
   147                                     (directory, tpno_str)
   151                                     (directory, tpno_str)
   148                             comp_TPNOs[directory] = tpno_str
   152                             comp_TPNOs[directory] = tpno_str
   149                         except:
   153                         except:
   150                             print >> sys.stderr, "Unable to read TPNO: %s" % \
   154                             # Check to see if line end in a "\" character in
   151                                 pathname
   155                             # which case, it's an attribute rather than an
       
   156                             # set name action, so extract it a different way.
       
   157                             try:
       
   158                                 n += len(TPNO_str)+1
       
   159                                 tpno_str = line[n:].split()[0]
       
   160                                 # Check that the TPNO is a valid number.
       
   161                                 tpno = int(tpno_str)
       
   162                                 if debug:
       
   163                                     print >> sys.stderr, "TPNO: %s: %s" % \
       
   164                                         (directory, tpno_str)
       
   165 
       
   166                                 # If it's an attribute, there might be more
       
   167                                 # than one TPNO for this component.
       
   168                                 if directory in comp_TPNOs:
       
   169                                     entry = comp_TPNOs[directory]
       
   170                                     tpno_str = "%s,%s" % (entry, tpno_str)
       
   171 
       
   172                                 comp_TPNOs[directory] = tpno_str
       
   173                             except:
       
   174                                 print >> sys.stderr, \
       
   175                                     "Unable to read TPNO: %s" % pathname
   152 
   176 
   153     return(comp_TPNOs)
   177     return(comp_TPNOs)
   154 
   178 
   155 # Return a sorted list of the directories containing one or more .p5m files.
   179 # Return a sorted list of the directories containing one or more .p5m files.
   156 def find_p5m_dirs(workspace):
   180 def find_p5m_dirs(workspace):