Blob Blame History Raw
diff --git a/langpacks.py b/langpacks.py
index d42069f..98039ce 100644
--- a/langpacks.py
+++ b/langpacks.py
@@ -134,6 +134,7 @@ def config_hook(conduit):
         conduit.registerCommand(LanginstallCommand())
         conduit.registerCommand(LangremoveCommand())
         conduit.registerCommand(LanglistCommand())
+        conduit.registerCommand(LanginfoCommand())
 
 def init_hook(conduit):
     global langs
@@ -179,6 +180,45 @@ def get_matches(sack, list):
             ret = ret + p
     return ret
 
+def get_uniq_available_pkgs(pkgs):
+   uniq_list = []
+   for pkg in pkgs:
+     try:
+       pkgname= str(pkg)
+       woarch = pkgname.rsplit('.', 1)[0]
+       worel = woarch.rsplit('-', 1)[0]
+       wover = worel.rsplit('-', 1)[0]
+     except Exception, e:
+       print '%s **** %s' % (e, pkg)
+       continue
+
+     check_epoch = wover.find(":",0, len(wover))
+     if check_epoch != -1 :
+          uniq_list.append(wover[check_epoch+1:])
+     else :
+          uniq_list.append(wover)
+   return sorted(uniq_list)
+
+def get_matches_from_ts(conduit, lang, base = None):
+    yb = base
+    sack = base.pkgSack
+
+    pkgmatches = []
+    for basepkg in conditional_pkgs:
+        if yb.rpmdb.searchNevra(name=basepkg) or yb.tsInfo.matchNaevr(name=basepkg):
+            conds = conditional_pkgs[basepkg]
+            patterns = map(lambda x: x % (lang,), conds)
+            shortlang = lang.split('_')[0]
+            if shortlang != lang:
+                patterns = patterns + map(lambda x: x % (shortlang,), conds)
+            for p in patterns:
+                if p not in pkgmatches:
+                    pkgmatches.append(p)
+
+    pkgs = get_matches(sack, pkgmatches)
+    pkgs_uniq = get_uniq_available_pkgs( pkgs)
+    return pkgs_uniq
+
 def add_deps_to_ts(conduit, po):
     global langinstalled
 
@@ -409,3 +449,27 @@ class LanglistCommand:
                 print "\t" + item
         return 0, [""]
 
+class LanginfoCommand:
+    def getNames(self):
+        return ['langinfo']
+
+    def getUsage(self):
+        return "[langinfo lang1|lang2|...]"
+
+    def getSummary(self):
+        return "List languages information"
+
+    def doCheck(self, base, basecmd, extcmds):
+        pass
+
+    def doCommand(self, base, basecmd, extcmds):
+        base.repos.doSetup()
+        for lang in extcmds:
+	    print "Language-Id={0}".format(lang)
+	    list_pkgs = get_matches_from_ts(None, lang, base)
+	    for pkg in set(list_pkgs):
+		print "  " + pkg
+	    if len(list_pkgs) == 0:
+                 print "No langpacks to show for languages: {0}".format(lang)
+        return 0, [""]
+