# Import from itools from itools.csv import CSVFile, Table, UniqueError from itools.csv.table import parse_table, unfold_lines from itools.datatypes import Date, Integer, Unicode, URI, String from itools.fs import lfs from itools.handlers import RODatabase TEST_DATA_1 = """python,http://python.org/,52343,2003-10-23 ruby,http://ruby-lang.org/,42352,2001-03-28""" TEST_DATA_2 = 'one,two,three\nfour,five,six\nseven,eight,nine' TEST_SYNTAX_ERROR = '"one",,\n,"two",,\n,,"three"' ro_database = RODatabase(fs=lfs) class Languages(CSVFile): columns = ['name', 'url', 'number', 'date'] schema = {'name': Unicode, 'url': URI, 'number': Integer, 'date': Date} class Numbers(CSVFile): columns = ['one', 'two', 'three'] schema = {'one': Unicode, 'two': Unicode, 'three': Unicode} class CSVTestCase(TestCase):
from itools.stl import stl from itools.uri import Path from itools.web import BaseView, STLView, STLForm, MSG_MISSING_OR_INVALID from itools.web import ERROR from itools.xliff import XLFFile from itools.xml import XMLParser, XMLError # Import from ikaaro from ikaaro.datatypes import FileDataType # Import from hforge from project import Project # ODF i18n Testsuite location ro_database = RODatabase(fs=lfs) test_suite = expanduser('~/sandboxes/odf-i18n-tests/documents') test_suite = ro_database.get_handler(test_suite) class ODFWSDownload(BaseView): access = True query_schema = { 'path': PathDataType} def GET(self, resource, context): path = context.query['path'] if path is None: return context.come_back(MSG_MISSING_OR_INVALID)
# XXX This code does not take into account changes in the filesystem once a # domain has been registered/loaded. domains = {} def register_domain(name, locale_path): if name not in domains: domains[name] = Domain(locale_path) def get_domain(name): return domains[name] database = RODatabase() class Domain(dict): def __init__(self, uri): folder = database.get_handler(uri) for key in folder.get_handler_names(): if key[-3:] == '.mo': language = key[:-3] self[language] = folder.get_handler(key) def gettext(self, message, language): if language not in self: return message handler = self[language] return handler.gettext(message)
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Import from the Standard Library from unittest import TestCase, main # Import from itools from itools.handlers import RODatabase from itools.handlers import ConfigFile, TGZFile from itools.fs import lfs ro_database = RODatabase(fs=lfs) class StateTestCase(TestCase): def test_abort(self): handler = ro_database.get_handler('tests/hello.txt') self.assertEqual(handler.data, u'hello world\n') handler.set_data(u'bye world\n') self.assertEqual(handler.data, u'bye world\n') handler.abort_changes() self.assertEqual(handler.data, u'hello world\n') class ConfigFileTestCase(TestCase):