dbrtools/dbr/dbrenv.py
changeset 208 01c2b1268053
parent 203 e274d29c8bc9
child 217 1eec8c29548a
equal deleted inserted replaced
206:2fd92922bf5c 208:01c2b1268053
    23 
    23 
    24 
    24 
    25 def CreateDB(location): #virtual constructor
    25 def CreateDB(location): #virtual constructor
    26   print location
    26   print location
    27 #  print dbrutils.patch_path_internal()
    27 #  print dbrutils.patch_path_internal()
    28   if(os.path.exists(os.path.join(location,dbrutils.defaultdb()))):
    28   if(os.path.isfile(os.path.join(location,dbrutils.defaultdb()))):
    29 #    print 'loading baseline environment'
    29 #    print 'loading baseline environment'
    30 #    return DBRBaselineEnv(location)
    30 #    return DBRBaselineEnv(location)
    31     print 'loading patched baseline environment'
    31     print 'loading patched baseline environment'
    32     return DBRPatchedBaselineEnv(location)
    32     return DBRPatchedBaselineEnv(location)
    33   if(os.path.exists(os.path.join(location,'build_md5.zip'))):
    33   if(os.path.exists(os.path.join(location,'build_md5.zip'))):
    40     print 'loading localenv'
    40     print 'loading localenv'
    41     return DBRLocalEnv(location)
    41     return DBRLocalEnv(location)
    42 
    42 
    43   return DBREnv(location)
    43   return DBREnv(location)
    44 
    44 
    45 
    45 #Start simple with the filtering...
       
    46 def CreateFilter(arg):
       
    47   if(os.path.isfile(arg)):
       
    48     return DBRFileFilter(arg)
       
    49   return DBRFilter()     
    46 
    50 
    47 class DBREnv:
    51 class DBREnv:
    48   db = dict()
    52   db = dict()
    49   location = ''
    53   location = ''
    50   name = ''
    54   name = ''
   228   def printsummary(self):
   232   def printsummary(self):
   229     if(len(self.added | self.removed | self.changed | self.unknown)):
   233     if(len(self.added | self.removed | self.changed | self.unknown)):
   230       print 'status: dirty'
   234       print 'status: dirty'
   231     else:
   235     else:
   232       print 'status: clean' 
   236       print 'status: clean' 
   233                      
   237 
       
   238 
       
   239 
       
   240 class DBRFilter:
       
   241   info = ''
       
   242   def __init__(self):
       
   243     self.info = 'null filter'
       
   244   def filter(self, results):
       
   245     return results
       
   246 
       
   247 class DBRFileFilter (DBRFilter):
       
   248   filename = ''
       
   249   def __init__(self, filename):
       
   250     DBRFilter.__init__(self)
       
   251     self.info = 'file filter'
       
   252     self.filename = filename
       
   253     self.files = dbrutils.readfilenamesfromfile(self.filename)
       
   254 #    for file in sorted(self.files):
       
   255 #      print file
       
   256      
       
   257   def filter(self, results):
       
   258     return DBRCompResults(results.added & self.files, results.removed & self.files, results.touched & self.files, results.changed & self.files, results.unknown & self.files)
       
   259