コード例 #1
0
ファイル: xmlimport.py プロジェクト: mohalfaki/bungeni-portal
def zcml_check_regenerate():
    """Called after all XML workflows have been loaded (see adapers.py).
    """

    #!+permissions.zcml(mr, aug-2011) bypass writing to disk?
    def get_filepath():
        # ZCML_FILENAME is under bungeni.core.workflows
        import bungeni.core.workflows
        __path__ = os.path.dirname(bungeni.core.workflows.__file__)
        return os.path.join(__path__, ZCML_FILENAME)

    filepath = get_filepath()
    # read current file
    persisted = open(filepath, "r").read().decode("utf-8")
    # regenerate, compare, and re-write if needed
    regenerated = ZCML_BOILERPLATE % ("\n".join(ZCML_LINES))
    if persisted != regenerated:
        log.warn("CHANGES to file:\n%s" %
                 (debug.unified_diff(persisted, regenerated, filepath, "NEW")))
        open(filepath, "w").write(regenerated.encode("utf-8"))

        class ChangedWorkflowsPermissionsZCML(Exception):
            pass

        raise ChangedWorkflowsPermissionsZCML(
            "Must restart system with updated file: %s" % (filepath))
コード例 #2
0
def zcml_check_regenerate():
    """Called after all XML workflows have been loaded (see adapers.py). 
    """
    # !+ bungeni_custom/sys/workflows
    import bungeni.core.workflows
    __path__ = os.path.dirname(bungeni.core.workflows.__file__)
    filepath = os.path.join(__path__, ZCML_FILENAME)
    persisted = open(filepath, "r").read().decode("utf-8")
    regenerated = ZCML_BOILERPLATE % ("\n".join(ZCML_LINES))
    if persisted != regenerated:
        log.warn("CHANGES to file:\n%s" % (
            debug.unified_diff(persisted, regenerated, filepath, "NEW")))
        open(filepath, "w").write(regenerated.encode("utf-8"))
        class ChangedWorkflowsPermissionsZCML(Exception): pass
        raise ChangedWorkflowsPermissionsZCML(
            "Must restart system with updated file: %s" % (filepath))
コード例 #3
0
ファイル: xmlimport.py プロジェクト: mohalfaki/bungeni-portal
def zcml_check_regenerate():
    """Called after all XML workflows have been loaded (see adapers.py). 
    """
    # !+ bungeni_custom/sys/workflows
    import bungeni.core.workflows
    __path__ = os.path.dirname(bungeni.core.workflows.__file__)
    filepath = os.path.join(__path__, ZCML_FILENAME)
    persisted = open(filepath, "r").read().decode("utf-8")
    regenerated = ZCML_BOILERPLATE % ("\n".join(ZCML_LINES))
    if persisted != regenerated:
        log.warn("CHANGES to file:\n%s" % (
            debug.unified_diff(persisted, regenerated, filepath, "NEW")))
        open(filepath, "w").write(regenerated.encode("utf-8"))
        class ChangedWorkflowsPermissionsZCML(Exception): pass
        raise ChangedWorkflowsPermissionsZCML(
            "Must restart system with updated file: %s" % (filepath))
コード例 #4
0
def zcml_check_regenerate():
    """Called after all XML workflows have been loaded (see adapers.py).
    """
    #!+permissions.zcml(mr, aug-2011) bypass writing to disk?
    # ZCML_FILENAME is under bungeni.core.workflows
    import bungeni.core.workflows
    __path__ = os.path.dirname(bungeni.core.workflows.__file__)
    filepath = os.path.join(__path__, ZCML_FILENAME)
    # read current file
    persisted = open(filepath, "r").read().decode("utf-8")
    # regenerate, compare, and re-write if needed
    regenerated = ZCML_BOILERPLATE % ("\n".join(ZCML_LINES))
    if persisted != regenerated:
        log.warn("CHANGES to file:\n%s" % (
            debug.unified_diff(persisted, regenerated, filepath, "NEW")))
        open(filepath, "w").write(regenerated.encode("utf-8"))
        class ChangedWorkflowsPermissionsZCML(Exception): pass
        raise ChangedWorkflowsPermissionsZCML(
            "Must restart system with updated file: %s" % (filepath))
コード例 #5
0
def write_custom(old_content, content):
    print "*** OVERWRITING localization file: %s" % (CUSTOM_PATH)
    print debug.unified_diff(old_content, content, CUSTOM_PATH, "NEW")
    open(CUSTOM_PATH, "w").write(content.encode("utf-8"))
コード例 #6
0
def write_custom(old_content, content):
    print "*** OVERWRITING localization file: %s" % (CUSTOM_PATH)
    print debug.unified_diff(old_content, content, CUSTOM_PATH, "NEW")
    open(CUSTOM_PATH, "w").write(content.encode("utf-8"))
コード例 #7
0
    _acc = []
    for dcls in localizable_descriptor_classes(module):
        _acc.extend(serialize_cls(dcls, depth=1))
    
    acc = []
    ind = INDENT * depth
    if _acc:
        acc.append('%s<ui roles="%s">' % (ind, ROLES_DEFAULT))
        acc.extend(_acc)
        acc.append("")
        acc.append("%s</ui>" % (ind))
    else:
        acc.append('%s<ui roles="%s" />' % (ind, ROLES_DEFAULT))
    acc.append("") # blank line at end of file
    acc.append("")
    return acc


if __name__ == "__main__":
    
    from bungeni.ui.utils import debug
    print "Processing localization file: %s" % (CUSTOM_PATH)
    persisted = read_custom()
    regenerated = "\n".join(serialize_module(DESCRIPTOR_MODULE))
    if persisted != regenerated:
        print "*** OVERWRITING:"
        print debug.unified_diff(persisted, regenerated, CUSTOM_PATH, "NEW")
        write_custom(regenerated)