summaryrefslogtreecommitdiff
path: root/muggle-plugin/scripts/iso639tab.py
diff options
context:
space:
mode:
authorLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-22 06:47:53 +0000
committerLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-22 06:47:53 +0000
commite2de0c5ed7bbbe4b236246e8bfd71cc87c8d974f (patch)
tree616f2f0a482597e3968e281ccf8adcfd04f45bbc /muggle-plugin/scripts/iso639tab.py
parent101360901576c7e91196de60e2e6ebd6a4b145dd (diff)
downloadvdr-plugin-muggle-0.1.6-BETA.tar.gz
vdr-plugin-muggle-0.1.6-BETA.tar.bz2
Added 0.1.6 beta tag0.1.6-BETA
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/tags/0.1.6-BETA@586 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'muggle-plugin/scripts/iso639tab.py')
-rwxr-xr-xmuggle-plugin/scripts/iso639tab.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/muggle-plugin/scripts/iso639tab.py b/muggle-plugin/scripts/iso639tab.py
new file mode 100755
index 0000000..b2739c9
--- /dev/null
+++ b/muggle-plugin/scripts/iso639tab.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+#
+# Read iso-codes iso_639.xml data file and output a .tab file
+#
+# Copyright (C) 2005 Alastair McKinstry <mckinstry@debian.org>
+# Released under the GPL.
+# $Id: iso639tab.py,v 1.1 2005/03/02 07:24:51 mckinstry Exp $
+
+from xml.sax import saxutils, make_parser, saxlib, saxexts, ContentHandler
+from xml.sax.handler import feature_namespaces
+import sys, os, getopt, urllib2
+
+class printLines(saxutils.DefaultHandler):
+ def __init__(self, ofile):
+ self.ofile = ofile
+
+ def startElement(self, name, attrs):
+ if name != 'iso_639_entry':
+ return
+ t_code = attrs.get('iso_639_2T_code', None)
+ if t_code == None:
+ raise RunTimeError, "Bad file"
+ if type(t_code) == unicode:
+ t_code = t_code.encode('UTF-8')
+ b_code = attrs.get('iso_639_2B_code', None)
+ if b_code == None:
+ raise RunTimeError, "Bad file"
+ if type(b_code) == unicode:
+ b_code = b_code.encode('UTF-8')
+ name = attrs.get('name', None)
+ if name == None:
+ raise RunTimeError, " BadFile"
+ short_code=attrs.get('iso_639_1_code','XX')
+ short_code=short_code.encode('UTF-8')
+ if type(name) == unicode:
+ name = name.encode('UTF-8')
+ self.ofile.write (t_code + '\t' + b_code + '\t' + short_code + '\t' + name + '\n')
+
+
+##
+## MAIN
+##
+
+
+ofile = sys.stdout
+ofile.write("""
+## iso-639.tab
+##
+## Copyright (C) 2005 Alastair McKinstry <mckinstry@computer.org>
+## Released under the GNU License; see file COPYING for details
+##
+## PLEASE NOTE: THIS FILE IS DEPRECATED AND SCHEDULED TO BE REMOVED.
+## IT IS FOR BACKWARD-COMPATIBILITY ONLY: PLEASE USE THE ISO-639.XML
+## FILE INSTEAD.
+##
+## This file gives a list of all languages in the ISO-639
+## standard, and is used to provide translations (via gettext)
+##
+## Status: ISO 639-2:1998 + additions and changes until 2003-03-05
+## Source: http://lcweb.loc.gov/standards/iso639-2/englangn.html
+##
+## Columns:
+## iso-639-2 terminology code
+## iso-639-2 bibliography code
+## iso-639-1 code (XX if none exists)
+## Name (English)
+##
+##
+""")
+p = make_parser()
+p.setErrorHandler(saxutils.ErrorPrinter())
+try:
+ dh = printLines(ofile)
+ p.setContentHandler(dh)
+ p.parse(sys.argv[1])
+except IOError,e:
+ print in_sysID+": "+str(e)
+except saxlib.SAXException,e:
+ print str(e)
+
+ofile.close()