[yum-commits] Makefile plugins/aliases yumutils/i18n.py yumutils/__init__.py yumutils/Makefile yum-utils.spec

Tim Lauridsen timlau at osuosl.org
Mon Jan 3 06:48:46 UTC 2011


 Makefile                   |    2 -
 plugins/aliases/aliases.py |    6 -----
 yum-utils.spec             |    6 +++++
 yumutils/Makefile          |   20 +++++++++++++++++
 yumutils/__init__.py       |   18 +++++++++++++++
 yumutils/i18n.py           |   51 +++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 97 insertions(+), 6 deletions(-)

New commits:
commit 6f1140f9eda12e93c7e5a69bd4945dd44b41b78c
Author: Tim Lauridsen <timlau at fedoraproject.org>
Date:   Mon Jan 3 07:33:42 2011 +0100

    Added yumutils python module with i18n handling code

diff --git a/Makefile b/Makefile
index 4a4afa0..a12ae1f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = docs po
+SUBDIRS = docs po yumutils
 PKGNAME = yum-utils
 UTILS = package-cleanup debuginfo-install repoclosure repomanage repoquery repo-graph repo-rss yumdownloader yum-builddep repotrack reposync repodiff yum-debug-dump yum-debug-restore verifytree yum-groups-manager find-repos-of-install needs-restarting yum-config-manager show-installed
 UTILSROOT = yum-complete-transaction yumdb
diff --git a/plugins/aliases/aliases.py b/plugins/aliases/aliases.py
index 975b538..a0cb15c 100644
--- a/plugins/aliases/aliases.py
+++ b/plugins/aliases/aliases.py
@@ -24,11 +24,7 @@ except:
     class CliError: # Never used by yumex
         pass
 
-from kitchen.i18n import easy_gettext_setup
-
-# setup the translation wrappers
-
-_, P_  = easy_gettext_setup('yum-utils') 
+from yumutils.i18n import _, P_
 
 requires_api_version = '2.1'
 plugin_type = (TYPE_INTERACTIVE,)
diff --git a/yum-utils.spec b/yum-utils.spec
index 2f19f04..b41b90a 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -1,3 +1,5 @@
+%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+
 Summary: Utilities based around the yum package manager
 Name: yum-utils
 Version: 1.1.29
@@ -459,6 +461,7 @@ fi
 %{_bindir}/show-installed
 %{_sbindir}/yum-complete-transaction
 %{_sbindir}/yumdb
+%{python_sitelib}/yumutils/
 %{_mandir}/man1/yum-utils.1.*
 %{_mandir}/man1/debuginfo-install.1.*
 %{_mandir}/man1/package-cleanup.1.*
@@ -652,6 +655,9 @@ fi
 /usr/lib/yum-plugins/ps.*
 
 %changelog
+* Mon Jan 3 2011 Tim Lauridsen <timlau at fedoraproject.org>
+- Added yumutils python module
+ 
 * Thu Dec 30 2010 Tim Lauridsen <timlau at fedoraproject.org>
 - Added Translation support and need Requires, BuildRequires 
 
diff --git a/yumutils/Makefile b/yumutils/Makefile
new file mode 100644
index 0000000..faeac19
--- /dev/null
+++ b/yumutils/Makefile
@@ -0,0 +1,20 @@
+PYTHON=python
+PACKAGE = $(shell basename `pwd`)
+PYFILES = $(wildcard *.py)
+PYVER := $(shell $(PYTHON) -c 'import sys; print "%.3s" %(sys.version)')
+PYSYSDIR := $(shell $(PYTHON) -c 'import sys; print sys.prefix')
+PYLIBDIR = $(PYSYSDIR)/lib/python$(PYVER)
+PKGDIR = $(PYLIBDIR)/site-packages/$(PACKAGE)
+
+all: 
+	echo "Nothing to do"
+
+clean:
+	rm -f *.pyc *.pyo *~
+
+install:
+	mkdir -p $(DESTDIR)/$(PKGDIR)
+	for p in $(PYFILES) ; do \
+		install -m 755 $$p $(DESTDIR)/$(PKGDIR)/$$p; \
+	done
+	$(PYTHON) -c "import compileall; compileall.compile_dir('$(DESTDIR)/$(PKGDIR)', 1, '$(PYDIR)', 1)"
diff --git a/yumutils/__init__.py b/yumutils/__init__.py
new file mode 100644
index 0000000..75fd7a6
--- /dev/null
+++ b/yumutils/__init__.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""
+The yumutils pythom module for common code used by utils and plugins
+"""
diff --git a/yumutils/i18n.py b/yumutils/i18n.py
new file mode 100644
index 0000000..50d448c
--- /dev/null
+++ b/yumutils/i18n.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""
+The yumutils.i18n pythom module for i18n code used by utils and plugins
+"""
+
+# flag to disable i18n, set it to false to enable dummy wrappers.
+_use_i18n = True
+
+if _use_i18n:
+    try:
+        from kitchen.i18n import easy_gettext_setup
+        # setup the translation wrappers
+        _, P_  = easy_gettext_setup('yum-utils') 
+    except:
+        _ = dummy_wrapper
+        P_ = dummyP_wrapper
+else:
+    _ = dummy_wrapper
+    P_ = dummyP_wrapper
+    
+    
+def dummy_wrapper(str):
+    '''
+    Dummy Translation wrapper, just returning the same string.
+    '''
+    return str
+
+def dummyP_wrapper(str1, str2, n):
+    '''
+    Dummy Plural Translation wrapper, just returning the singular or plural
+    string.
+    '''
+    if n == 1:
+        return str1
+    else:
+        return str2
+    
\ No newline at end of file


More information about the Yum-commits mailing list