modifyrepo.py

[email protected]
Newsgroups gmane.linux.rpm.metadata
Message-ID <[email protected]>
 modifyrepo.py |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit fbfec43a6a551fc70f707b786d583a33aaa8989d
Author: Seth Vidal <[email protected]>
Date:   Thu Oct 23 16:47:41 2008 -0400

    allow already-compressed metadata files to work and not be double-compressed

diff --git a/modifyrepo.py b/modifyrepo.py
index b86f53e..558ec08 100755
--- a/modifyrepo.py
+++ b/modifyrepo.py
@@ -62,7 +62,10 @@ class RepoMetadata:
             mdname = 'updateinfo.xml'
         elif isinstance(metadata, str):
             if os.path.exists(metadata):
-                oldmd = file(metadata, 'r')
+                if metadata.endswith('.gz'):
+                    oldmd = GzipFile(filename=metadata, mode='rb')
+                else:
+                    oldmd = file(metadata, 'r')
                 md = oldmd.read()
                 oldmd.close()
                 mdname = os.path.basename(metadata)
@@ -72,7 +75,8 @@ class RepoMetadata:
             raise Exception('invalid metadata type')
 
         ## Compress the metadata and move it into the repodata
-        mdname += '.gz'
+        if not mdname.endswith('.gz'):
+            mdname += '.gz'
         mdtype = mdname.split('.')[0]
         destmd = os.path.join(self.repodir, mdname)
         newmd = GzipFile(filename=destmd, mode='wb')
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.