- move a bunch of tests into the base class
authorSeth Vidal <skvidal@fedoraproject.org>
Thu, 17 Jan 2008 17:48:19 +0000 (12:48 -0500)
committerSeth Vidal <skvidal@fedoraproject.org>
Thu, 17 Jan 2008 17:48:19 +0000 (12:48 -0500)
- deprecate --cachedir - make it enable --update instead b/c it is MUCH
  faster

createrepo/__init__.py
genpkgmetadata.py

index 93d6d5a77ba824eadb0c6a1a69deca85832ece71..32e3b6c2202c59c5a8425c3cfdd7199543c98c69 100644 (file)
@@ -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.
index 260ddd0c91cedcb95a0ba75283266d9d633f3ce3..050a90e4c4816c97bd19891d95a245f16f1a04f8 100755 (executable)
@@ -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