[yum-cvs] yum/yum sqlitecache.py,1.8,1.9 sqlitesack.py,1.13,1.14

Gijs Hollestelle gijs at login.linux.duke.edu
Wed Mar 9 16:03:54 UTC 2005


Update of /home/groups/yum/cvs/yum/yum
In directory login:/tmp/cvs-serv10114

Modified Files:
	sqlitecache.py sqlitesack.py 
Log Message:
- store filetypes as one char instead of as a / seperated string
- move functions for encoding and decoding lists of filenames / filetypes
  to seperate helper functions.
- update TODOs



Index: sqlitecache.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitecache.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- sqlitecache.py	8 Mar 2005 09:22:22 -0000	1.8
+++ sqlitecache.py	9 Mar 2005 16:03:52 -0000	1.9
@@ -16,21 +16,18 @@
 # Copyright 2005 Duke University 
 
 # TODO
-# - Add support for multiple checksums per rpm (is this required??)
-# - Store filetypes as one char per type instead of a string
-# - Move the stuff that turns a list of files into a string into a helper unit
-# - Don't fall back to a memory sqlite cache but to pickles if a cache
-#   file can't be created.
+# - Add support for multiple checksums per rpm (not required)
 
 import os
 import sqlite
 import time
 import mdparser
+from sqlitesack import encodefiletypelist,encodefilenamelist
 
 # This version refers to the internal structure of the sqlite cache files
 # increasing this number forces all caches of a lower version number
 # to be re-generated
-dbversion = '5'
+dbversion = '6'
 
 class RepodataParserSqlite:
     def __init__(self, storedir, repoid, callback=None):
@@ -291,8 +288,8 @@
             data = {
                 'pkgKey': pkgKey,
                 'dirname': dirname,
-                'filenames': '/'.join(dir['files']),
-                'filetypes': '/'.join(dir['types'])
+                'filenames': encodefilenamelist(dir['files']),
+                'filetypes': encodefiletypelist(dir['types'])
             }
             self.insertHash('filelist',data,cur)
 

Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- sqlitesack.py	8 Mar 2005 08:54:16 -0000	1.13
+++ sqlitesack.py	9 Mar 2005 16:03:52 -0000	1.14
@@ -160,8 +160,8 @@
             for ob in cur.fetchall():
                 found = True
                 dirname = ob['filelist.dirname']
-                filetypes = ob['filelist.filetypes'].split('/')
-                filenames = ob['filelist.filenames'].split('/')
+                filetypes = decodefiletypelist(ob['filelist.filetypes'])
+                filenames = decodefilenamelist(ob['filelist.filenames'])
                 while(filenames):
                     filename = dirname+'/'+filenames.pop()
                     filetype = filetypes.pop()
@@ -205,7 +205,7 @@
                 if (self.excludes[rep].has_key(ob['packages.pkgId'])):
                     continue
                 real = False
-                for filename in ob['filelist.filenames'].split('/'):
+                for filename in decodefilenamelist(ob['filelist.filenames']):
                     if (ob['filelist.dirname']+'/'+filename).find(name) != -1:
                         real = True
                 if (not real):
@@ -429,3 +429,28 @@
                 obj = self.pc(self.db2class(x), rep)
                 self.delPackage(obj)
 
+# Simple helper functions
+
+# Return a string representing filenamelist (filenames can not contain /)
+def encodefilenamelist(filenamelist):
+    return '/'.join(filenamelist)
+
+# Return a list representing filestring (filenames can not contain /)
+def decodefilenamelist(filenamestring):
+    return filenamestring.split('/')
+
+# Return a string representing filetypeslist
+# filetypes should be file, dir or ghost
+def encodefiletypelist(filetypelist):
+    result = ''
+    ft2string = {'file': 'f','dir': 'd','ghost': 'g'}
+    for x in filetypelist:
+        result += ft2string[x]
+    return result
+
+# Return a list representing filetypestring
+# filetypes should be file, dir or ghost
+def decodefiletypelist(filetypestring):
+    string2ft = {'f':'file','d': 'dir','g': 'ghost'}
+    return [string2ft[x] for x in filetypestring]
+




More information about the Yum-cvs-commits mailing list