|
|
9b68ce |
From f6692e9842f7a4d5c2b414e61159eb454d0e20b2 Mon Sep 17 00:00:00 2001
|
|
|
9b68ce |
From: Michal Srb <msrb@redhat.com>
|
|
|
9b68ce |
Date: Tue, 6 Jan 2015 14:35:28 +0100
|
|
|
9b68ce |
Subject: [PATCH 1/3] Do not try to produce "pretty" XML with Python < 2.7
|
|
|
9b68ce |
|
|
|
9b68ce |
---
|
|
|
9b68ce |
java-utils/maven_depmap.py | 4 ++--
|
|
|
9b68ce |
java-utils/mvn_artifact.py | 5 ++---
|
|
|
9b68ce |
python/javapackages/common/util.py | 11 +++++++++++
|
|
|
9b68ce |
3 files changed, 15 insertions(+), 5 deletions(-)
|
|
|
9b68ce |
|
|
|
9b68ce |
diff --git a/java-utils/maven_depmap.py b/java-utils/maven_depmap.py
|
|
|
9b68ce |
index 8f6b11f..9a25211 100644
|
|
|
9b68ce |
--- a/java-utils/maven_depmap.py
|
|
|
9b68ce |
+++ b/java-utils/maven_depmap.py
|
|
|
9b68ce |
@@ -51,6 +51,7 @@ from javapackages.metadata.artifact import MetadataArtifact
|
|
|
9b68ce |
from javapackages.metadata.alias import MetadataAlias
|
|
|
9b68ce |
|
|
|
9b68ce |
import javapackages.metadata.pyxbmetadata as m
|
|
|
9b68ce |
+import javapackages.common.util as util
|
|
|
9b68ce |
import pyxb
|
|
|
9b68ce |
|
|
|
9b68ce |
|
|
|
9b68ce |
@@ -199,8 +200,7 @@ def write_metadata(metadata_file, artifacts):
|
|
|
9b68ce |
root.artifacts = pyxb.BIND(*artifacts)
|
|
|
9b68ce |
|
|
|
9b68ce |
with open(metadata_file, 'w') as f:
|
|
|
9b68ce |
- dom = root.toDOM(None)
|
|
|
9b68ce |
- f.write(dom.toprettyxml(indent=" "))
|
|
|
9b68ce |
+ util.write_metadata(f, root)
|
|
|
9b68ce |
|
|
|
9b68ce |
if __name__ == "__main__":
|
|
|
9b68ce |
|
|
|
9b68ce |
diff --git a/java-utils/mvn_artifact.py b/java-utils/mvn_artifact.py
|
|
|
9b68ce |
index 424252b..0bd97e0 100644
|
|
|
9b68ce |
--- a/java-utils/mvn_artifact.py
|
|
|
9b68ce |
+++ b/java-utils/mvn_artifact.py
|
|
|
9b68ce |
@@ -42,7 +42,7 @@ from javapackages.maven.pom import POM, PomLoadingException
|
|
|
9b68ce |
from javapackages.ivy.ivyfile import IvyFile
|
|
|
9b68ce |
|
|
|
9b68ce |
from javapackages.xmvn.xmvn_resolve import XMvnResolve, ResolutionResult, ResolutionRequest
|
|
|
9b68ce |
-from javapackages.common.util import args_to_unicode
|
|
|
9b68ce |
+from javapackages.common.util import args_to_unicode, write_metadata
|
|
|
9b68ce |
|
|
|
9b68ce |
import sys
|
|
|
9b68ce |
import os
|
|
|
9b68ce |
@@ -316,5 +316,4 @@ if __name__ == "__main__":
|
|
|
9b68ce |
add_artifact_elements(metadata, art, pom_path, jar_path)
|
|
|
9b68ce |
|
|
|
9b68ce |
with open(config, 'w') as f:
|
|
|
9b68ce |
- dom = metadata.toDOM(None)
|
|
|
9b68ce |
- f.write(dom.toprettyxml(indent=" "))
|
|
|
9b68ce |
+ write_metadata(f, metadata)
|
|
|
9b68ce |
diff --git a/python/javapackages/common/util.py b/python/javapackages/common/util.py
|
|
|
9b68ce |
index f893cc4..37942a4 100644
|
|
|
9b68ce |
--- a/python/javapackages/common/util.py
|
|
|
9b68ce |
+++ b/python/javapackages/common/util.py
|
|
|
9b68ce |
@@ -128,3 +128,14 @@ def get_logger(name):
|
|
|
9b68ce |
handler.setFormatter(formatter)
|
|
|
9b68ce |
logger.addHandler(handler)
|
|
|
9b68ce |
return logger
|
|
|
9b68ce |
+
|
|
|
9b68ce |
+
|
|
|
9b68ce |
+def write_metadata(fileobj, metadata):
|
|
|
9b68ce |
+ dom = metadata.toDOM(None)
|
|
|
9b68ce |
+
|
|
|
9b68ce |
+ # minidom in Python < 2.6 adds unnecessary whitespace
|
|
|
9b68ce |
+ # see: http://bugs.python.org/issue4147
|
|
|
9b68ce |
+ if sys.version_info < (2, 7):
|
|
|
9b68ce |
+ fileobj.write(dom.toxml())
|
|
|
9b68ce |
+ else:
|
|
|
9b68ce |
+ fileobj.write(dom.toprettyxml(indent=" "))
|
|
|
9b68ce |
--
|
|
|
9b68ce |
2.1.0
|
|
|
9b68ce |
|