[PATCH 02/14] Add code for getting timezones for country

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Gracik <mgracik@xxxxxxxxxx>

---
 anaconda.spec.in           |    1 +
 pyanaconda/localization.py |   22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index cc17ddf..cddcb77 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -132,6 +132,7 @@ Requires: cracklib-python
 Requires: python-bugzilla
 Requires: python-nss
 Requires: tigervnc-server-minimal
+Requires: pytz
 %ifarch %livearches
 Requires: usermode
 Requires: zenity
diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py
index f561557..75b2864 100644
--- a/pyanaconda/localization.py
+++ b/pyanaconda/localization.py
@@ -26,6 +26,7 @@ import os
 import re
 
 import babel
+import pytz
 
 
 LOCALE_PREFERENCES = {}
@@ -272,3 +273,24 @@ class Language(object):
 
         # XXX DEBUG
         print 'set system lang to "%s"' % self.system_lang
+
+
+def get_all_timezones(territory):
+    if isinstance(territory, LocaleInfo):
+        territory = territory.territory
+
+    try:
+        timezones = pytz.country_timezones(territory)
+    except KeyError:
+        timezones = list()
+
+    return timezones
+
+
+def get_preferred_timezone(territory):
+    try:
+        timezone = get_all_timezones(territory)[0]
+    except IndexError:
+        timezone = None
+
+    return timezone
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux