def test_long_value(self): # Init data value = "HELLO, WORLD!\n\nHELLO WORLD2222" self._init_test(value) # Read data config2 = ConfigFile(self.config_path) try: config2_value = config2.get_value("test") except SyntaxError, e: self.fail(e)
def test_wrapped_quote_value(self): # Init data value = "\"HELLO, WORLD!\"" self._init_test(value) # Write data config = ConfigFile(self.config_path) try: config.set_value("test", value) except SyntaxError, e: self.fail(e)
def test_simple_value(self): # Init data value = "HELLO, WORLD!" self._init_test(value) # Read data config2 = ConfigFile(self.config_path) config2_value = config2.get_value("test") lfs.remove(self.config_path) # Test data self.assertEqual(config2_value, value)
def test_last_line_empty(self): # Init data value = "HELLO, WORLD!\n\n" self._init_test(value) # Write data config = ConfigFile(self.config_path) config.set_value("test", value) config.save_state() # Read data config2 = ConfigFile(self.config_path) config2_value = config2.get_value("test") lfs.remove(self.config_path) # Test data self.assertEqual(config2_value, value)
def _init_test(self, value): # Init data if not lfs.exists(self.config_path): lfs.make_file(self.config_path) # Write data config = ConfigFile(self.config_path) config.set_value("test", value) config.save_state()
def get_available_languages(self): """Returns the language codes for the user interface. """ source = itools_source_language target = itools_target_languages # A package based on itools cls = self.__class__ if cls is not Root: exec('import %s as pkg' % cls.__module__.split('.', 1)[0]) config = Path(pkg.__path__[0]).resolve_name('setup.conf') config = ConfigFile(str(config)) source = config.get_value('source_language', default=source) target = config.get_value('target_languages', default=target) target = target.split() if source in target: target.remove(source) target.insert(0, source) return target
from config import Configuration from config_register import RegisterForm, TermsOfService_View from context import CMSContext from fields import Char_Field from folder import Folder from resource_views import LoginView from skins import skin_registry from utils import get_base_path_query from root_views import PoweredBy, ContactForm from root_views import NotFoundView, ForbiddenView, NotAllowedView from root_views import UploadStatsView, UpdateDocs, UnavailableView from update import UpdateInstanceView # itools source and target languages config = get_abspath('setup.conf') config = ConfigFile(config) itools_source_language = config.get_value('source_language') itools_target_languages = config.get_value('target_languages') # Force email to send UTF-8 mails in plain text add_charset('utf-8', QP, None, 'utf-8') add_codec('utf-8', 'utf_8') class CtrlView(BaseView): access = True def GET(self, resource, context): context.content_type = 'text/plain' database = context.database
def test_quote_value(self): # Init data value = "HELLO, \"WORLD\"!" self._init_test(value) # Write data config = ConfigFile(self.config_path) try: config.set_value("test", value) except SyntaxError, e: self.fail(e) config.save_state() # Read data config2 = ConfigFile(self.config_path) try: config2_value = config2.get_value("test") except SyntaxError, e: self.fail(e) finally: lfs.remove(self.config_path) # Test data self.assertEqual(config2_value, value) def test_wrapped_quote_value(self): # Init data value = "\"HELLO, WORLD!\"" self._init_test(value)
from config_register import RegisterForm, TermsOfService_View from context import CMSContext from fields import Char_Field from folder import Folder from resource_views import LoginView from skins import skin_registry from utils import get_base_path_query from root_views import PoweredBy, ContactForm from root_views import NotFoundView, ForbiddenView, NotAllowedView from root_views import UploadStatsView, UpdateDocs, UnavailableView from update import UpdateInstanceView # itools source and target languages config = get_abspath('setup.conf') config = ConfigFile(config) itools_source_language = config.get_value('source_language') itools_target_languages = config.get_value('target_languages') # Force email to send UTF-8 mails in plain text add_charset('utf-8', QP, None, 'utf-8') add_codec('utf-8', 'utf_8') class CtrlView(BaseView): access = True def GET(self, resource, context):