dbrtools/dbr/dbrarchive.py
changeset 179 eab8a264a833
equal deleted inserted replaced
177:6d3c3db11e72 179:eab8a264a833
       
     1 # Copyright (c) 2009 Symbian Foundation Ltd
       
     2 # This component and the accompanying materials are made available
       
     3 # under the terms of the License "Eclipse Public License v1.0"
       
     4 # which accompanies this distribution, and is available
       
     5 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     6 #
       
     7 # Initial Contributors:
       
     8 # Symbian Foundation Ltd - initial contribution.
       
     9 #
       
    10 # Contributors:
       
    11 # mattd <mattd@symbian.org>
       
    12 #
       
    13 # Description:
       
    14 # DBR archive - handles archives - not used at present
       
    15 
       
    16 import dbrutils
       
    17 import re
       
    18 
       
    19 def readarchives(dbfile):
       
    20     db = dict()
       
    21     if(isfile(dbfile)):
       
    22         file = open(dbfile,'r')
       
    23         for line in file:
       
    24             #file structure 'name:zip
       
    25             results = re.split(',|\n',line)
       
    26             db[results[0]] = results[1]
       
    27         file.close()
       
    28     return db
       
    29     
       
    30 def writearchives(db, dbfile):
       
    31     file = open(dbfile,'w')
       
    32     for archive in sorted(db):
       
    33         str = "%s,%s\n" % (archive, db[archive])
       
    34         file.write(str)
       
    35     file.close()
       
    36 
       
    37 def archivefile():
       
    38     return '/epoc32/relinfo/archive.txt'
       
    39 
       
    40 def extract(archive,files):
       
    41     
       
    42     db = readarchives(archivefile())
       
    43     if(archive is in db):
       
    44         dbrutils.unzipfiles(db[archive],files)
       
    45     elsif(re.search('baseline' archive)): #Nasty
       
    46         for zip in sorted(db):
       
    47             if(re.search('baseline' zip):
       
    48                 dbrutils.unzipfiles(db[zip],files)
       
    49     
       
    50 def install(zip): #nasty at the moment...
       
    51 #    archives = readarchives(archivefile())
       
    52     unzip(zip)
       
    53     
       
    54     
       
    55