commit 5fbf57e3810d14a139812b23fa455492cb4614f5
Author: Stanislav Ochotnicky <sochotnicky(a)redhat.com>
Date: Thu Oct 3 17:27:47 2013 +0200
Simplify pom.properties injection
java-utils/maven_depmap.py | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/java-utils/maven_depmap.py b/java-utils/maven_depmap.py
index e638a52..1e09bcc 100644
--- a/java-utils/maven_depmap.py
+++ b/java-utils/maven_depmap.py
@@ -44,8 +44,8 @@ from StringIO import StringIO
import xml.dom.minidom
import codecs
-from os.path import basename, dirname, splitext
-from zipfile import ZipFile
+from os.path import basename, dirname
+import zipfile
from time import gmtime, strftime
from lxml.etree import SubElement, Element, ElementTree, XMLParser
@@ -300,14 +300,15 @@ def output_fragment(fragment_path, fragment, mappings,
add_versions):
# Add a file to a ZIP archive (or JAR, WAR, ...) unless the file
# already exists in the archive. Provided by Tomas Radej.
def append_if_missing(archive_name, file_name, file_contents):
- with ZipFile(archive_name, 'a') as archive:
+ with zipfile.ZipFile(archive_name, 'a') as archive:
if file_name not in archive.namelist():
- path = file_name[0:file_name.rfind('/')]
- subdir = ''
- for part in path.split('/'):
- subdir += part + '/'
- if subdir not in archive.namelist():
- archive.writestr(subdir, '')
+ path = os.path.dirname(file_name)
+ while True:
+ if not path:
+ break
+ archive.writestr(path+os.path.sep,
+ '', compress_type=zipfile.ZIP_STORED)
+ path, tail = os.path.split(path)
archive.writestr(file_name, file_contents)
# Inject pom.properties if JAR doesn't have one. This is necessary to
Show replies by date