diff --git a/pisi-cli b/pisi-cli
index 4ddfe070..599d255a 100755
--- a/pisi-cli
+++ b/pisi-cli
@@ -12,6 +12,10 @@
import sys
+import gettext
+__trans = gettext.translation('pisi', fallback=True)
+_ = __trans.ugettext
+
from pisi.cli.pisicli import PisiCLI
from pisi.ui import ui
@@ -22,20 +26,20 @@ def handle_exception(exception, value, tb):
from pisi.ui import ui
if exception == exceptions.KeyboardInterrupt:
- ui.error("\nKeyboardInterrupt: Exiting...\n")
+ ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
sys.exit(1)
elif exception == XmlError:
ui.error(str(value))
sys.exit(1)
- ui.error("""
+ ui.error(_("""
Internal PISI Error:
Please file a bug report! (http://bugs.uludag.org.tr)
-""")
+"""))
ui.error("%s\n" %value)
- ui.info("Traceback:\n")
+ ui.info(_("Traceback:\n"))
traceback.print_tb(tb)
sys.exit(1)
diff --git a/pisi/build.py b/pisi/build.py
index 6c2ec933..20956baa 100644
--- a/pisi/build.py
+++ b/pisi/build.py
@@ -17,6 +17,10 @@
import os
import sys
+import gettext
+__trans = gettext.translation('pisi', fallback=True)
+_ = __trans.ugettext
+
import pisi
import pisi.util as util
from pisi.ui import ui
@@ -70,7 +74,7 @@ def check_path_collision(package, pkgList):
# path.pathname: /usr/share/doc
if util.subpath(pinfo.pathname, path.pathname):
collisions.append(path.pathname)
- ui.error('Path %s belongs in multiple packages\n' %
+ ui.error(_('Path %s belongs in multiple packages\n') %
path.pathname)
return collisions
@@ -102,8 +106,8 @@ class PisiBuild:
def build(self):
"""Build the package in one shot."""
- ui.info("Building PISI source package: %s\n" % self.spec.source.name)
- util.xterm_title("Building PISI source package: %s\n" % self.spec.source.name)
+ ui.info(_("Building PISI source package: %s\n") % self.spec.source.name)
+ util.xterm_title(_("Building PISI source package: %s\n") % self.spec.source.name)
self.compile_action_script()
@@ -136,30 +140,30 @@ class PisiBuild:
os.environ.update(evn)
def fetch_source_archive(self):
- ui.info("Fetching source from: %s\n" % self.spec.source.archiveUri)
+ ui.info(_("Fetching source from: %s\n") % self.spec.source.archiveUri)
self.sourceArchive.fetch()
- ui.info("Source archive is stored: %s/%s\n"
+ ui.info(_("Source archive is stored: %s/%s\n")
%(config.archives_dir(), self.spec.source.archiveName))
def unpack_source_archive(self):
- ui.info("Unpacking archive...")
+ ui.info(_("Unpacking archive..."))
self.sourceArchive.unpack()
- ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir())
+ ui.info(_(" unpacked (%s)\n") % self.ctx.pkg_work_dir())
self.set_state("unpacked")
def run_setup_action(self):
# Run configure, build and install phase
- ui.action("Setting up source...\n")
+ ui.action(_("Setting up source...\n"))
self.run_action_function(const.setup_func)
self.set_state("setupaction")
def run_build_action(self):
- ui.action("Building source...\n")
+ ui.action(_("Building source...\n"))
self.run_action_function(const.build_func)
self.set_state("buildaction")
def run_install_action(self):
- ui.action("Installing...\n")
+ ui.action(_("Installing...\n"))
# Before install make sure install_dir is clean
if os.path.exists(self.ctx.pkg_install_dir()):
@@ -178,10 +182,10 @@ class PisiBuild:
buf = open(scriptfile).read()
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
except IOError, e:
- ui.error("Unable to read Action Script (%s): %s\n" %(scriptfile,e))
+ ui.error(_("Unable to read Action Script (%s): %s\n") %(scriptfile,e))
sys.exit(1)
except SyntaxError, e:
- ui.error ("SyntaxError in Action Script (%s): %s\n" %(scriptfile,e))
+ ui.error (_("SyntaxError in Action Script (%s): %s\n") %(scriptfile,e))
sys.exit(1)
self.actionLocals = localSymbols
@@ -212,7 +216,7 @@ class PisiBuild:
self.actionLocals[func]()
else:
if mandatory:
- Error, "unable to call function from actions: %s" %func
+ Error, _("unable to call function from actions: %s") %func
os.chdir(curDir)
@@ -232,7 +236,7 @@ class PisiBuild:
compressType=patch.compressionType,
targetDir=config.tmp_dir())
- ui.action("* Applying patch: %s\n" % patch.filename)
+ ui.action(_("* Applying patch: %s\n") % patch.filename)
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
def gen_metadata_xml(self, package):
@@ -273,7 +277,7 @@ class PisiBuild:
collisions = check_path_collision(package,
self.spec.packages)
if collisions:
- raise Error('Path collisions detected')
+ raise Error(_('Path collisions detected'))
d = {}
for pinfo in package.paths:
path = install_dir + pinfo.pathname
@@ -362,17 +366,17 @@ class PisiBuild:
self.spec.source.release)
- ui.action("** Building package %s\n" % package.name);
+ ui.action(_("** Building package %s\n") % package.name);
- ui.action("Generating %s..." % const.files_xml)
+ ui.action(_("Generating %s...") % const.files_xml)
self.gen_files_xml(package)
- ui.info(" done.\n")
+ ui.info(_(" done.\n"))
- ui.action("Generating %s..." % const.metadata_xml)
+ ui.action(_("Generating %s...") % const.metadata_xml)
self.gen_metadata_xml(package)
- ui.info(" done.\n")
+ ui.info(_(" done.\n"))
- ui.action("Creating PISI package %s\n" % name)
+ ui.action(_("Creating PISI package %s\n") % name)
pkg = Package(name, 'w')
diff --git a/tools/repostats.py b/tools/repostats.py
index 43f1ecb7..31e91f88 100755
--- a/tools/repostats.py
+++ b/tools/repostats.py
@@ -12,13 +12,21 @@
import sys
import os
+import gettext
+__trans = gettext.translation('pisi', fallback=True)
+_ = __trans.ugettext
+
sys.path.append('.')
import pisi.specfile
import pisi.uri
+def echo(string):
+ print string.encode("utf8")
+
class Histogram:
- def __init__(self):
+ def __init__(self, title):
self.list = {}
+ self.title = title
def add(self, name):
if self.list.has_key(name):
@@ -38,11 +46,14 @@ class Histogram:
items = self.list.items()
items.sort(self._sortfunc)
return items
+
+ def html_out(self):
+ echo("
%s
" % self.title)
+ for name,cnt in self.get_list():
+ echo("| %s | %s |
" % (name, cnt))
+ echo("
")
-def echo(string):
- print string.encode("utf8")
-
def scan_pspec(folder):
paks = []
for root, dirs, files in os.walk(folder):
@@ -67,10 +78,12 @@ def add_deps(deps, spec):
for p in a:
deps.add(p)
-hosts = Histogram()
-people = Histogram()
-licenses = Histogram()
-components = Histogram()
+hosts = Histogram(_("Source hosts"))
+people = Histogram(_("Packagers"))
+licenses = Histogram(_("Licenses"))
+components = Histogram(_("Components"))
+dependencies = Histogram(_("Dependencies"))
+types = Histogram(_("File types"))
mostp_name = None
mostp_count = 0
nr_binpaks = 0
@@ -78,8 +91,6 @@ nr_patches = 0
maxpy_lines = 0
maxpy_name = None
paknames = {}
-dependencies = Histogram()
-types = Histogram()
errors = []
@@ -128,7 +139,7 @@ for pak in paks:
print "%s İstatistikleri" % (sys.argv[1])
print ''
-print ""
+echo("")
print "Toplam %d kod paketi, ve bunlardan oluşturulacak %d ikili paket var.
" % (len(paks), nr_binpaks)
echo(u"Toplam peç sayısı %d
" % nr_patches)
@@ -146,28 +157,13 @@ if errors != []:
else:
print "Hata yok, tebrikler!
"
-print "Komponentler
"
-for name,cnt in components.get_list():
- print "| %s | %s |
" % (name, cnt)
-print "
"
+components.html_out()
+people.html_out()
+licenses.html_out()
+types.html_out()
-print "Paketleyiciler
"
-for name,cnt in people.get_list():
- echo("| %s | %s |
" % (name, cnt))
-print "
"
-
-print "Lisanslar
"
-for name,cnt in licenses.get_list():
- print "| %s | %s |
" % (name, cnt)
-print "
"
-
-print "Dosya tipleri
"
-for name,cnt in types.get_list():
- print "| %s | %s |
" % (name, cnt)
-print "
"
-
-echo(u"Bağımlılıklar
")
-echo(u"(italik olanlar depoda bulunmayanlar)
")
+echo(_("Dependencies
"))
+echo(_("package name with italics are not available in the repository
"))
print ""
for name,cnt in dependencies.get_list():
if paknames.has_key(name):
@@ -176,9 +172,6 @@ for name,cnt in dependencies.get_list():
print "| %s | %d |
" % (name, cnt)
print "
"
-echo(u"Kod kaynakları
")
-for name,cnt in hosts.get_list():
- print "| %s | %s |
" % (name, cnt)
-print "
"
+hosts.html_out()
print ""