예제 #1
0
def write_dict(filename, contents):
    if '__corrupted__' in contents:
        return
    try:
        fp = LockedFile(filename, 'w')
    except (IOError, OSError):
        if not settings.global_settings.web2py_runtime_gae:
            logging.warning('Unable to write to file %s' % filename)
        return
    fp.write('# coding: utf8\n{\n')
    for key in sorted(contents, lambda x, y: cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())):
        fp.write('%s: %s,\n' % (repr(Utf8(key)), repr(Utf8(contents[key]))))
    fp.write('}\n')
    fp.close()
예제 #2
0
파일: languages.py 프로젝트: PopoWow/web2py
def write_dict(filename, contents):
    if '__corrupted__' in contents:
        return
    try:
        fp = LockedFile(filename, 'w')
    except (IOError, OSError):
        if not settings.global_settings.web2py_runtime_gae:
            logging.warning('Unable to write to file %s' % filename)
        return
    fp.write('# coding: utf8\n{\n')
    for key in sorted(contents, lambda x, y: cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())):
        fp.write('%s: %s,\n' % (repr(Utf8(key)), repr(Utf8(contents[key]))))
    fp.write('}\n')
    fp.close()
예제 #3
0
def write_dict(filename, contents):
    if "__corrupted__" in contents:
        return
    try:
        fp = LockedFile(filename, "w")
    except (IOError, OSError):
        if not settings.global_settings.web2py_runtime_gae:
            logging.warning("Unable to write to file %s" % filename)
        return
    fp.write("# coding: utf8\n{\n")
    for key in sorted(contents, lambda x, y: cmp(unicode(x, "utf-8").lower(), unicode(y, "utf-8").lower())):
        fp.write("%s: %s,\n" % (repr(Utf8(key)), repr(Utf8(contents[key]))))
    fp.write("}\n")
    fp.close()
예제 #4
0
def write_plural_dict(filename, contents):
    if '__corrupted__' in contents:
        return
    try:
        fp = LockedFile(filename, 'w')
        fp.write('#!/usr/bin/env python\n{\n# "singular form (0)": ["first plural form (1)", "second plural form (2)", ...],\n')
        # coding: utf8\n{\n')
        for key in sorted(contents, lambda x, y: cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())):
            forms = '[' + ','.join([repr(Utf8(form))
                                   for form in contents[key]]) + ']'
            fp.write('%s: %s,\n' % (repr(Utf8(key)), forms))
        fp.write('}\n')
    except (IOError, OSError):
        if not is_gae:
            logging.warning('Unable to write to file %s' % filename)
        return
    finally:
        fp.close()
예제 #5
0
파일: languages.py 프로젝트: PopoWow/web2py
def write_plural_dict(filename, contents):
    if '__corrupted__' in contents:
        return
    try:
        fp = LockedFile(filename, 'w')
        fp.write('#!/usr/bin/env python\n{\n# "singular form (0)": ["first plural form (1)", "second plural form (2)", ...],\n')
        # coding: utf8\n{\n')
        for key in sorted(contents, lambda x, y: cmp(unicode(x, 'utf-8').lower(), unicode(y, 'utf-8').lower())):
            forms = '[' + ','.join([repr(Utf8(form))
                                   for form in contents[key]]) + ']'
            fp.write('%s: %s,\n' % (repr(Utf8(key)), forms))
        fp.write('}\n')
    except (IOError, OSError):
        if not is_gae:
            logging.warning('Unable to write to file %s' % filename)
        return
    finally:
        fp.close()
예제 #6
0
def write_plural_dict(filename, contents):
    if "__corrupted__" in contents:
        return
    try:
        fp = LockedFile(filename, "w")
        fp.write(
            '#!/usr/bin/env python\n{\n# "singular form (0)": ["first plural form (1)", "second plural form (2)", ...],\n'
        )
        # coding: utf8\n{\n')
        for key in sorted(contents, lambda x, y: cmp(unicode(x, "utf-8").lower(), unicode(y, "utf-8").lower())):
            forms = "[" + ",".join([repr(Utf8(form)) for form in contents[key]]) + "]"
            fp.write("%s: %s,\n" % (repr(Utf8(key)), forms))
        fp.write("}\n")
    except (IOError, OSError):
        if not is_gae:
            logging.warning("Unable to write to file %s" % filename)
        return
    finally:
        fp.close()