Beispiel #1
0
def _extractVariableNodes( root, encoding=None ):

    result = []

    for v_node in root.getElementsByTagName( 'variable' ):

        info = { 'variable_id' : _getNodeAttribute( v_node, 'variable_id'
                                                    , encoding )
               , 'description' : _extractDescriptionNode( v_node, encoding )
               , 'for_catalog' : _getNodeAttributeBoolean( v_node
                                                         , 'for_catalog'
                                                         )
               , 'for_status' : _getNodeAttributeBoolean( v_node
                                                        , 'for_status'
                                                        )
               , 'update_always' : _getNodeAttributeBoolean( v_node
                                                           , 'update_always'
                                                           )
               , 'default' : _extractDefaultNode( v_node, encoding )
               , 'guard' : _extractGuardNode( v_node, encoding )
               }

        result.append( info )

    return result
Beispiel #2
0
def _extractVariableNodes( root, encoding=None ):

    result = []

    for v_node in root.getElementsByTagName( 'variable' ):

        info = { 'variable_id' : _getNodeAttribute( v_node, 'variable_id'
                                                    , encoding )
               , 'description' : _extractDescriptionNode( v_node, encoding )
               , 'for_catalog' : _getNodeAttributeBoolean( v_node
                                                         , 'for_catalog'
                                                         )
               , 'for_status' : _getNodeAttributeBoolean( v_node
                                                        , 'for_status'
                                                        )
               , 'update_always' : _getNodeAttributeBoolean( v_node
                                                           , 'update_always'
                                                           )
               , 'default' : _extractDefaultNode( v_node, encoding )
               , 'guard' : _extractGuardNode( v_node, encoding )
               }

        result.append( info )

    return result
Beispiel #3
0
def _extractStateNodes(root, encoding=None):

    result = []

    for s_node in root.getElementsByTagName('state'):

        info = {
            'state_id': _getNodeAttribute(s_node, 'state_id', encoding),
            'title': _getNodeAttribute(s_node, 'title', encoding),
            'description': _extractDescriptionNode(s_node, encoding)
        }

        info['transitions'] = [
            _getNodeAttribute(x, 'transition_id', encoding)
            for x in s_node.getElementsByTagName('exit-transition')
        ]

        info['permissions'] = permission_map = {}

        for p_map in s_node.getElementsByTagName('permission-map'):

            name = _getNodeAttribute(p_map, 'name', encoding)
            acquired = _getNodeAttributeBoolean(p_map, 'acquired')

            roles = [
                _coalesceTextNodeChildren(x, encoding)
                for x in p_map.getElementsByTagName('permission-role')
            ]

            if not acquired:
                roles = tuple(roles)

            permission_map[name] = roles

        info['groups'] = group_map = []

        for g_map in s_node.getElementsByTagName('group-map'):

            name = _getNodeAttribute(g_map, 'name', encoding)

            roles = [
                _coalesceTextNodeChildren(x, encoding)
                for x in g_map.getElementsByTagName('group-role')
            ]

            group_map.append((name, tuple(roles)))

        info['variables'] = var_map = {}

        for assignment in s_node.getElementsByTagName('assignment'):

            name = _getNodeAttribute(assignment, 'name', encoding)
            type_id = _getNodeAttribute(assignment, 'type', encoding)
            value = _coalesceTextNodeChildren(assignment, encoding)

            var_map[name] = {'name': name, 'type': type_id, 'value': value}

        result.append(info)

    return result
Beispiel #4
0
def _extractStateNodes( root, encoding=None ):

    result = []

    for s_node in root.getElementsByTagName( 'state' ):

        info = { 'state_id' : _getNodeAttribute( s_node, 'state_id', encoding )
               , 'title' : _getNodeAttribute( s_node, 'title', encoding )
               , 'description' : _extractDescriptionNode( s_node, encoding )
               }

        info[ 'transitions' ] = [ _getNodeAttribute( x, 'transition_id'
                                                   , encoding )
                                  for x in s_node.getElementsByTagName(
                                                        'exit-transition' ) ]

        info[ 'permissions' ] = permission_map = {}

        for p_map in s_node.getElementsByTagName( 'permission-map' ):

            name = _getNodeAttribute( p_map, 'name', encoding )
            acquired = _getNodeAttributeBoolean( p_map, 'acquired' )

            roles = [ _coalesceTextNodeChildren( x, encoding )
                        for x in p_map.getElementsByTagName(
                                            'permission-role' ) ]

            if not acquired:
                roles = tuple( roles )

            permission_map[ name ] = roles

        info[ 'groups' ] = group_map = []

        for g_map in s_node.getElementsByTagName( 'group-map' ):

            name = _getNodeAttribute( g_map, 'name', encoding )

            roles = [ _coalesceTextNodeChildren( x, encoding )
                        for x in g_map.getElementsByTagName(
                                            'group-role' ) ]

            group_map.append( ( name, tuple( roles ) ) )

        info[ 'variables' ] = var_map = {}

        for assignment in s_node.getElementsByTagName( 'assignment' ):

            name = _getNodeAttribute( assignment, 'name', encoding )
            type_id = _getNodeAttribute( assignment, 'type', encoding )
            value = _coalesceTextNodeChildren( assignment, encoding )

            var_map[ name ] = { 'name'  : name
                              , 'type'  : type_id
                              , 'value' : value
                              }

        result.append( info )

    return result
Beispiel #5
0
def _extractActionNodes(parent, encoding=None):

    result = []

    for a_node in parent.getElementsByTagName('action'):

        def _es(key):
            return _getNodeAttribute(a_node, key, encoding)

        action_id      = _es('action_id')
        title          = _es('title')
        category       = _es('category')
        condition_expr = _es('condition_expr')
        permissions    = _extractPermissionNodes(a_node, encoding)
        category       = _es('category')
        visible        = _getNodeAttributeBoolean(a_node, 'visible')
        url_expr       = _es('url_expr')

        result.append( { 'id': action_id,
                         'title': title,
#                         'description': description,
                         'category': category,
                         'condition': condition_expr,
                         'permissions': permissions,
                         'visible': visible,
                         'action': url_expr } )

    return result
Beispiel #6
0
def _extractActionNodes(parent, encoding=None):

    result = []

    for a_node in parent.getElementsByTagName('action'):

        def _es(key):
            return _getNodeAttribute(a_node, key, encoding)

        action_id      = _es('action_id')
        title          = _es('title')
        category       = _es('category')
        condition_expr = _es('condition_expr')
        permissions    = _extractPermissionNodes(a_node, encoding)
        category       = _es('category')
        visible        = _getNodeAttributeBoolean(a_node, 'visible')
        url_expr       = _es('url_expr')

        result.append( { 'id': action_id,
                         'title': title,
#                         'description': description,
                         'category': category,
                         'condition': condition_expr,
                         'permissions': permissions,
                         'visible': visible,
                         'action': url_expr } )

    return result
Beispiel #7
0
def _extractPermissionNodes(parent, encoding=None):

    result = []

    for p_node in parent.getElementsByTagName('permission'):
        name = _getNodeAttribute(p_node, 'name', encoding)
        roles = _extractRoleNodes(p_node, encoding)
        acquire = _getNodeAttributeBoolean(p_node, 'acquire')
        result.append({'name': name, 'roles': roles, 'acquire': acquire})

    return tuple(result)
Beispiel #8
0
def _extractPermissionNodes(parent, encoding=None):

    result = []

    for p_node in parent.getElementsByTagName('permission'):
        name    = _getNodeAttribute(p_node, 'name', encoding)
        roles   = _extractRoleNodes(p_node, encoding)
        acquire = _getNodeAttributeBoolean(p_node, 'acquire')
        result.append( { 'name': name,
                         'roles': roles,
                         'acquire': acquire } )

    return tuple(result)