Zdenek Pavlas
2013-09-30 14:05:30 UTC
- Fix mdtype autodetection from filename.
Now we should correctly derive mdtype even if the file argument
used full path, and/or --unique-md-filenames was on.
- Remove metadata file using path relative to repodir.
See the BZ, unlink should work from any $cwd.
- Honor --mdtype option
When --mdtype is specified, it overrides mdtype autodetection.
This should work for --remove, too.
---
modifyrepo.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/modifyrepo.py b/modifyrepo.py
index 804a243..8d6366a 100755
--- a/modifyrepo.py
+++ b/modifyrepo.py
@@ -60,6 +60,9 @@ class RepoMetadata:
""" Get mdtype from existing mdtype or from a mdname. """
if mdtype:
return mdtype
+ mdname = os.path.basename(mdname)
+ if re.match(r'[0-9a-f]{32,}-', mdname):
+ mdname = mdname.split('-', 1)[1]
return mdname.split('.')[0]
def _print_repodata(self, repodata):
@@ -80,7 +83,8 @@ class RepoMetadata:
def _remove_repodata_file(self, repodata):
""" Remove a file specified in repodata location """
try:
- os.remove(repodata.location[1])
+ fname = os.path.basename(repodata.location[1])
+ os.remove(os.path.join(self.repodir, fname))
except OSError, ex:
if ex.errno != 2:
# continue on a missing file
@@ -239,7 +243,7 @@ def main(args):
# remove
if opts.remove:
try:
- repomd.remove(metadata)
+ repomd.remove(metadata, mdtype=opts.mdtype)
except MDError, ex:
print "Could not remove metadata: %s" % (metadata, str(ex))
return 1
Now we should correctly derive mdtype even if the file argument
used full path, and/or --unique-md-filenames was on.
- Remove metadata file using path relative to repodir.
See the BZ, unlink should work from any $cwd.
- Honor --mdtype option
When --mdtype is specified, it overrides mdtype autodetection.
This should work for --remove, too.
---
modifyrepo.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/modifyrepo.py b/modifyrepo.py
index 804a243..8d6366a 100755
--- a/modifyrepo.py
+++ b/modifyrepo.py
@@ -60,6 +60,9 @@ class RepoMetadata:
""" Get mdtype from existing mdtype or from a mdname. """
if mdtype:
return mdtype
+ mdname = os.path.basename(mdname)
+ if re.match(r'[0-9a-f]{32,}-', mdname):
+ mdname = mdname.split('-', 1)[1]
return mdname.split('.')[0]
def _print_repodata(self, repodata):
@@ -80,7 +83,8 @@ class RepoMetadata:
def _remove_repodata_file(self, repodata):
""" Remove a file specified in repodata location """
try:
- os.remove(repodata.location[1])
+ fname = os.path.basename(repodata.location[1])
+ os.remove(os.path.join(self.repodir, fname))
except OSError, ex:
if ex.errno != 2:
# continue on a missing file
@@ -239,7 +243,7 @@ def main(args):
# remove
if opts.remove:
try:
- repomd.remove(metadata)
+ repomd.remove(metadata, mdtype=opts.mdtype)
except MDError, ex:
print "Could not remove metadata: %s" % (metadata, str(ex))
return 1
--
1.7.11.7
1.7.11.7