Added Formats, Format

Added I18n support for formats
This commit is contained in:
david 2002-05-18 20:44:15 +00:00
parent 03b4e828c9
commit b1fee4802c
7 changed files with 66 additions and 2 deletions

View File

@ -15,6 +15,7 @@ psql lampadas -qf document_wiki.sql
psql lampadas -qf doc_vote.sql
psql lampadas -qf dtd.sql
psql lampadas -qf format.sql
psql lampadas -qf format_i18n.sql
psql lampadas -qf language.sql
psql lampadas -qf license.sql
psql lampadas -qf notes.sql

View File

@ -3,7 +3,6 @@ DROP TABLE format;
CREATE TABLE format
(
format CHAR(12) NOT NULL,
format_name TEXT NOT NULL,
PRIMARY KEY (format)
);

View File

@ -0,0 +1,10 @@
DROP TABLE format_i18n;
CREATE TABLE format_i18n
(
format CHAR(12) NOT NULL,
lang CHAR(2) NOT NULL,
format_name TEXT NOT NULL,
PRIMARY KEY (format, lang)
);

View File

@ -13,6 +13,7 @@ copy document_user from '/tmp/lampadas_document_user.txt';
copy document_wiki from '/tmp/lampadas_document_wiki.txt';
copy dtd from '/tmp/lampadas_dtd.txt';
copy format from '/tmp/lampadas_format.txt';
copy format_i18n from '/tmp/lampadas_format_i18n.txt';
copy language from '/tmp/lampadas_language.txt';
copy license from '/tmp/lampadas_license.txt';
copy notes from '/tmp/lampadas_notes.txt';

View File

@ -13,6 +13,7 @@ copy document_user to '/tmp/lampadas_document_user.txt';
copy document_wiki to '/tmp/lampadas_document_wiki.txt';
copy dtd to '/tmp/lampadas_dtd.txt';
copy format to '/tmp/lampadas_format.txt';
copy format_i18n to '/tmp/lampadas_format_i18n.txt';
copy language to '/tmp/lampadas_language.txt';
copy license to '/tmp/lampadas_license.txt';
copy notes to '/tmp/lampadas_notes.txt';

View File

@ -115,6 +115,7 @@ class Lampadas:
self.Docs = Docs()
self.Docs.Load()
self.DTDs = DTDs()
self.Formats = Formats()
self.Languages = Languages()
self.Strings = Strings()
self.Topics = Topics()
@ -497,6 +498,51 @@ class DTD:
self.DTD = trim(row[0])
# Formats
class Formats(LampadasCollection):
"""
A collection object of all formats.
"""
def __init__(self):
self.data = {}
self.sql = "SELECT format FROM format"
self.cursor = DB.Select(self.sql)
while (1):
row = self.cursor.fetchone()
if row == None: break
newFormat = Format()
newFormat.Load(row)
self.data[newFormat.Format] = newFormat
class Format:
def __init__(self, Format=None):
self.I18n = {}
if Format==None: return
self.Code = Format
def Load(self, row):
self.Format = trim(row[0])
self.sql = "SELECT lang, format_name FROM format_i18n WHERE format=" + wsq(self.Format)
self.cursor = DB.Select(self.sql)
while (1):
self.row = self.cursor.fetchone()
if self.row == None: break
newFormatI18n = FormatI18n()
newFormatI18n.Load(self.row)
self.I18n[newFormatI18n.Lang] = newFormatI18n
# FormatI18n
class FormatI18n:
def Load(self, row):
self.Lang = row[0]
self.Name = trim(row[1])
# Languages
class Languages(LampadasCollection):
@ -529,7 +575,7 @@ class Language:
self.Name = trim(row[1])
# String
# Strings
class Strings(LampadasCollection):
"""

View File

@ -194,6 +194,12 @@ class testDTDs(unittest.TestCase):
assert L.DTDs.Count() > 0
assert not L.DTDs['DocBook'] == None
class testFormats(unittest.TestCase):
def testFormats(self):
assert L.Formats.Count() > 0
assert not L.Formats['XML'] == None
class testLanguages(unittest.TestCase):
def testLanguages(self):