Beispiel #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()
Beispiel #2
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()
Beispiel #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()
Beispiel #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()
Beispiel #5
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()
Beispiel #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()