createrepo/__init__.py genpkgmetadata.py

[email protected] (Seth Vidal)
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 createrepo/__init__.py |   21 ++++++++++++++++++---
 genpkgmetadata.py      |   30 ++++--------------------------
 2 files changed, 22 insertions(+), 29 deletions(-)

New commits:
commit 8a45afa98526932076e786fe726294829e8cc283
Author: Seth Vidal <[email protected]>
Date:   Thu Jan 17 12:48:19 2008 -0500

    - move a bunch of tests into the base class
    - deprecate --cachedir - make it enable --update instead b/c it is MUCH
      faster

diff --git a/createrepo/__init__.py b/createrepo/__init__.py
index 93d6d5a..32e3b6c 100644
--- a/createrepo/__init__.py
+++ b/createrepo/__init__.py
@@ -60,11 +60,10 @@ class MetaDataConfig(object):
         self.baseurl = ''
         self.groupfile = None
         self.sumtype = 'sha'
-        self.noepoch = False #???
+        self.noepoch = False # hmm - maybe a fixme?
         self.pretty = False
-        self.cachedir = None
+        self.cachedir = None #deprecated
         self.basedir = os.getcwd()
-        self.use_cache = False
         self.checkts = False
         self.split = False        
         self.update = False
@@ -121,6 +120,10 @@ class MetaDataGenerator:
             self.conf.directories = [self.conf.directory]
         if not self.conf.directory: # ensure we have both in the config object
             self.conf.directory = self.conf.directories[0]
+        
+        # the cachedir thing:
+        if self.conf.cachedir:
+            self.conf.update = True
             
         # this does the dir setup we need done
         self._parse_directory()
@@ -186,6 +189,18 @@ class MetaDataGenerator:
                         timestamp = os.path.getctime(filepath)
                         if timestamp > self.conf.mdtimestamp:
                             self.conf.mdtimestamp = timestamp
+        if self.conf.groupfile:
+            a = self.conf.groupfile
+            if self.conf.split:
+                a = os.path.join(self.package_dir, self.conf.groupfile)
+            elif not os.path.isabs(a):
+                a = os.path.join(self.package_dir, self.conf.groupfile)
+
+            if not os.path.exists(a):
+                raise MDError, _('Error: groupfile %s cannot be found.' % a)
+
+            self.conf.groupfile = a
+
 
     def _os_path_walk(self, top, func, arg):
         """Directory tree walk with callback function.
diff --git a/genpkgmetadata.py b/genpkgmetadata.py
index 260ddd0..050a90e 100755
--- a/genpkgmetadata.py
+++ b/genpkgmetadata.py
@@ -61,7 +61,7 @@ def parseArgs(args, conf):
     parser.add_option("-p", "--pretty", default=False, action="store_true",
                       help="make sure all xml generated is formatted")
     parser.add_option("-c", "--cachedir", default=None,
-                      help="set path to cache dir")
+                      help="enables --update as cachedir is MUCH slower")
     parser.add_option("-C", "--checkts", default=False, action="store_true",
       help="check timestamps on files vs the metadata to see if we need to update")
     parser.add_option("-d", "--database", default=False, action="store_true",
@@ -110,31 +110,10 @@ def parseArgs(args, conf):
     directory = directories[0]
     conf.directory = directory
     conf.directories = directories
-
-    # FIXME - I think this is unnecessary
-    if not opts.outputdir:
-        conf.outputdir = os.path.join(conf.basedir, directory)
-    if conf.groupfile:
-        a = conf.groupfile
-        if conf.split:
-            a = os.path.join(conf.basedir, directory, conf.groupfile)
-        elif not os.path.isabs(a):
-            a = os.path.join(conf.basedir, directory, conf.groupfile)
-        # FIXME, move this test most likely inside the class
-        if not os.path.exists(a):
-            errorprint(_('Error: groupfile %s cannot be found.' % a))
-            usage()
-        conf.groupfile = a
-    # FIXME - move this one inside the class, too
+    
     if conf.cachedir:
-        conf.cache = True
-        a = conf.cachedir
-        if not os.path.isabs(a):
-            a = os.path.join(conf.outputdir ,a)
-        if not checkAndMakeDir(a):
-            errorprint(_('Error: cannot open/write to cache dir %s' % a))
-            parser.print_usage()
-        conf.cachedir = a
+        conf.update = True
+       
 
     if conf.pkglist:
         lst = []
@@ -145,7 +124,6 @@ def parseArgs(args, conf):
         pfo.close()
             
         conf.pkglist = lst
-        
 
     return conf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.