client/rhel/rhnlib/rhn/connections.py | 19 +++++++++++++++++++
client/rhel/rhnlib/rhnlib.spec | 6 +++++-
rel-eng/packages/rhnlib | 2 +-
3 files changed, 25 insertions(+), 2 deletions(-)
New commits:
commit c74e181ee9ef5c84fb5b26f02bc378d10c1f0222
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Mar 11 15:44:22 2011 +0100
Automatic commit of package [rhnlib] release [2.5.35-1].
diff --git a/client/rhel/rhnlib/rhnlib.spec b/client/rhel/rhnlib/rhnlib.spec
index 4618aaf..07554f4 100644
--- a/client/rhel/rhnlib/rhnlib.spec
+++ b/client/rhel/rhnlib/rhnlib.spec
@@ -4,7 +4,7 @@ Summary: Python libraries for the RHN project
Name: rhnlib
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
-Version: 2.5.34
+Version: 2.5.35
Release: 1%{?dist}
Group: Development/Libraries
@@ -61,6 +61,10 @@ rm -rf $RPM_BUILD_ROOT
%{python_sitelib}/*
%changelog
+* Fri Mar 11 2011 Miroslav Suchý <msuchy(a)redhat.com> 2.5.35-1
+- 683200 - create idn_ascii_to_pune() and idn_pune_to_unicode(), which will
+ take care about corner cases of encodings.idna
+
* Wed Feb 16 2011 Miroslav Suchý <msuchy(a)redhat.com> 2.5.34-1
- Revert "Revert "get_server_capability() is defined twice in osad and rhncfg,
merge and move to rhnlib and make it member of rpclib.Server""
diff --git a/rel-eng/packages/rhnlib b/rel-eng/packages/rhnlib
index 1913841..6cfdd9f 100644
--- a/rel-eng/packages/rhnlib
+++ b/rel-eng/packages/rhnlib
@@ -1 +1 @@
-2.5.34-1 client/rhel/rhnlib/
+2.5.35-1 client/rhel/rhnlib/
commit 4342cb5b600dd2ce9785fd471769ca357601c7fc
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Mar 10 17:28:32 2011 +0100
683200 - create idn_ascii_to_pune() and idn_pune_to_unicode(), which will take care
about corner cases of encodings.idna
diff --git a/client/rhel/rhnlib/rhn/connections.py
b/client/rhel/rhnlib/rhn/connections.py
index 19e2250..884de9e 100644
--- a/client/rhel/rhnlib/rhn/connections.py
+++ b/client/rhel/rhnlib/rhn/connections.py
@@ -12,6 +12,7 @@ import SSL
import nonblocking
import httplib
import xmlrpclib
+import encodings.idna
# Import into the local namespace some httplib-related names
_CS_REQ_SENT = httplib._CS_REQ_SENT
@@ -244,3 +245,21 @@ class HTTPSProxyConnection(HTTPProxyConnection):
HTTPProxyConnection._add_proxy_headers(self)
# Add a User-Agent header
self.putheader("User-Agent", self._user_agent)
+
+def idn_pune_to_unicode(hostname):
+ """ Convert Internationalized domain name from Pune encoding to
Unicode """
+ if hostname is None:
+ return None
+ elif hostname == '':
+ return u''
+ else:
+ return u'.'.join([encodings.idna.ToUnicode(x) for x in
hostname.split('.')])
+
+def idn_ascii_to_pune(hostname):
+ """ Convert domain name to Pune encoding. Hostname can be instance of
string or Unicode """
+ if hostname is None:
+ return None
+ else:
+ if not isinstance(hostname, unicode):
+ hostname = unicode(hostname, 'utf-8')
+ return u'.'.join([encodings.idna.ToASCII(x) for x in
hostname.split('.')])