[Pkg-isocodes-devel] [iso-codes] 02/06: Adapt parsing script
Tobias Quathamer
toddy at moszumanska.debian.org
Tue Apr 1 15:53:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
toddy pushed a commit to branch xml
in repository iso-codes.
commit 3f42c8bb4e8502159be372e10def9988f1f8fc66
Author: Tobias Quathamer <toddy at debian.org>
Date: Sat Jun 15 14:34:32 2013 +0200
Adapt parsing script
---
iso_639_3/iso-dis-639-tab-parse.py | 49 +++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/iso_639_3/iso-dis-639-tab-parse.py b/iso_639_3/iso-dis-639-tab-parse.py
index 2e3b472..28b9f9a 100755
--- a/iso_639_3/iso-dis-639-tab-parse.py
+++ b/iso_639_3/iso-dis-639-tab-parse.py
@@ -50,24 +50,21 @@ for li in names.readlines():
names.close()
def create_iso_639_3_entry(entry):
- result = '\t<iso_639_3_entry\n'
- result += '\t\tid="%s"\n' % entry['code']
+ result = '\t<entry\n'
+ result += '\t\tidentifier="%s"\n' % entry['code']
if entry['part1'] != '':
result += '\t\tpart1_code="%s"\n' % entry['part1']
+ if entry['part2b'] != '':
+ result += '\t\tpart2b_code="%s"\n' % entry['part2b']
if entry['part2t'] != '':
- result += '\t\tpart2_code="%s"\n' % entry['part2t']
+ result += '\t\tpart2t_code="%s"\n' % entry['part2t']
result += '\t\tscope="%s"\n' % entry['element_scope']
result += '\t\ttype="%s"\n' % entry['language_type']
if 'inverted_name' in entry:
result += '\t\tinverted_name="%s"\n' % entry['inverted_name']
- result += '\t\treference_name="%s"\n' % entry['reference_name']
if 'common_name' in entry:
result += '\t\tcommon_name="%s"\n' % entry['common_name']
- # Use the inverted form for the name attribute
- if 'inverted_name' in entry:
- result += '\t\tname="%s" />\n' % entry['inverted_name']
- else:
- result += '\t\tname="%s" />\n' % entry['reference_name']
+ result += '\t\treference_name="%s" />\n' % entry['reference_name']
return result
tabular_file = open("iso_639_3.tab")
@@ -99,23 +96,27 @@ Copyright © 2008,2012,2013 Tobias Quathamer <toddy at debian.org>
Source: <http://www.sil.org/iso639-3/>
-->
-<!DOCTYPE iso_639_3_entries [
- <!ELEMENT iso_639_3_entries (iso_639_3_entry+)>
- <!ELEMENT iso_639_3_entry EMPTY>
- <!ATTLIST iso_639_3_entry
- id CDATA #REQUIRED
- part1_code CDATA #IMPLIED
- part2_code CDATA #IMPLIED
- scope CDATA #REQUIRED
- type CDATA #REQUIRED
- inverted_name CDATA #IMPLIED
- reference_name CDATA #REQUIRED
- name CDATA #REQUIRED
- common_name CDATA #IMPLIED
+<!DOCTYPE iso_639_3 [
+ <!ELEMENT iso_639_3 (entry)+>
+ <!ATTLIST iso_639_3
+ version CDATA #REQUIRED
+ last_change CDATA #REQUIRED
+ >
+ <!ELEMENT entry EMPTY>
+ <!ATTLIST entry
+ identifier CDATA #REQUIRED
+ part1_code CDATA #IMPLIED
+ part2b_code CDATA #IMPLIED
+ part2t_code CDATA #IMPLIED
+ scope CDATA #REQUIRED
+ type (A|C|E|H|L|S) #REQUIRED
+ inverted_name CDATA #IMPLIED
+ common_name CDATA #IMPLIED
+ reference_name CDATA #REQUIRED
>
]>
-<iso_639_3_entries>
+<iso_639_3 version="4" last_change="">
""")
# The first line only contains a header, so discard it
@@ -153,7 +154,7 @@ for li in tabular_file.readlines():
xml_file.write(entry)
# Finally, close the XML file
-xml_file.write('</iso_639_3_entries>\n')
+xml_file.write('</iso_639_3>\n')
xml_file.close()
tabular_file.close()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-isocodes/iso-codes.git
More information about the Pkg-isocodes-devel
mailing list