当前位置: 首页>>代码示例>>Python>>正文


Python Xml.get_attribute方法代码示例

本文整理汇总了Python中pyasm.common.Xml.get_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Xml.get_attribute方法的具体用法?Python Xml.get_attribute怎么用?Python Xml.get_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.common.Xml的用法示例。


在下文中一共展示了Xml.get_attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_input_snapshots

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_input_snapshots(my, sobject, process_name, input_name, version='latest'):
        '''gets the snapshots of the input'''
        assert version in ['latest', 'current']

        process_node = my.xml.get_node( "pipeline/process[@name='%s']/input[@name='%s']" % (process_name, input_name))

        search_type = Xml.get_attribute(process_node, "search_type")
        context = Xml.get_attribute(process_node, "context")
        filter = Xml.get_attribute(process_node, "filter")


        # get the sobjects
        sobjects = sobject.get_all_children(search_type)

        # get the snapshots
        search = Search("sthpw/snapshot")
        search.add_filter('context', context)
        #if version == 'latest':
        #    search.add_filter("is_latest", 1)
        #elif version == 'current':
        #    search.add_filter("is_current", 1)


        # build filters for search_type, search_id combinations
        filters = []
        for sobject in sobjects:
            filter = "(\"search_type\" = '%s' and \"search_id\" = %s)" % (sobject.get_search_type(), sobject.get_id() )
            filters.append(filter)
        
        search.add_where( "( %s )" % " or ".join(filters) )

        snapshots = search.get_sobjects()
        return snapshots
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:pipeline.py

示例2: get_file_paths

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_file_paths(my, transaction, mode='lib'):

        transaction_xml = transaction.get_xml_value("transaction")
        if not transaction_xml:
            return []

        from pyasm.common import Xml, Environment

        if isinstance(transaction_xml, basestring):
            xml = Xml()
            xml.read_string(transaction_xml)
        else:
            xml = transaction_xml


        base_dir = Environment.get_asset_dir()
        paths = []


        # get all of the file nodes
        nodes = xml.get_nodes("transaction/file")
        for node in nodes:

            if xml.get_attribute(node, "type") == 'create':
                src = xml.get_attribute(node, "src")

                if mode == 'relative':
                    path = src
                else:
                    path = "%s/%s" % (base_dir, src)
                paths.append(path)

        return paths
开发者ID:0-T-0,项目名称:TACTIC,代码行数:35,代码来源:sync_utils.py

示例3: get_related_search_types

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_related_search_types(self, search_type, direction=None):
        related_types = []

        if not direction or direction == "parent":
            xpath = "schema/connect[@from='%s']" %(search_type)
            connects = self.xml.get_nodes(xpath)
            for connect in connects:
                related_type = Xml.get_attribute(connect,"to")
                related_types.append(related_type)

        if not direction or direction == "children":
            xpath = "schema/connect[@to='%s']" %(search_type)
            connects = self.xml.get_nodes(xpath)
            for connect in connects:
                related_type = Xml.get_attribute(connect,"from")
                related_types.append(related_type)


        if self.parent_schema:
            search_types = self.parent_schema.get_related_search_types(search_type, direction=direction)
            related_types.extend(search_types)

        if self.sthpw_schema:
            search_types = self.sthpw_schema.get_related_search_types(search_type, direction=direction)
            related_types.extend(search_types)

        return related_types 
开发者ID:mincau,项目名称:TACTIC,代码行数:29,代码来源:schema.py

示例4: get_child_types

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_child_types(self, search_type, relationship="hierarchy", hierarchy=True):
        if search_type.find("?") != -1:
            search_type, tmp = search_type.split("?", 1)

        child_types = []
        # first get the child types defined in the admin schema
        if hierarchy and self.sthpw_schema:
            sthpw_child_types = self.sthpw_schema.get_child_types(search_type, relationship)
            child_types.extend(sthpw_child_types)


        # get the child types in the project type schema
        if hierarchy and self.parent_schema:
            parent_child_types = self.parent_schema.get_child_types(search_type, relationship)
            child_types.extend(parent_child_types)


        # add new style
        connects = self.xml.get_nodes("schema/connect[@to='%s'] | schema/connect[@to='*']" % search_type) 
        for connect in connects:
            relationship = Xml.get_attribute(connect, "relationship")
            # skip old style
            if not relationship:
                continue

            child_type = Xml.get_attribute(connect, "from")
            # skip identical type
            if child_type == search_type:
                continue
            child_types.append(child_type)

        return child_types
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:schema.py

示例5: get_parent_type

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_parent_type(my, search_type, relationship=None):
        # NOTE: relationship arg is deprecated!!

        if search_type.find("?") != -1:
            search_type, tmp = search_type.split("?", 1)

        # make a provision for admin search_types passed in
        if my.get_code() != "admin" and search_type.startswith("sthpw/"):
            
            parent_type = Schema.get_admin_schema().get_parent_type(search_type, relationship)
            if parent_type:
                return parent_type

        parent_type = ""
        # look at new style connections first
        connects = my.xml.get_nodes("schema/connect[@from='%s']" % search_type ) 
        for connect in connects:
            relationship_new = Xml.get_attribute(connect, "relationship")
            if relationship_new:
                type = Xml.get_attribute(connect, "type")
                if type == 'hierarchy':
                    parent_type = Xml.get_attribute(connect, "to")
                    break

        # NOTE: there could be multiple parents here.  Hierarchy type
        # should be the one to resolve this.
        # if there is no "hierarchy" type, use the first one
        if not parent_type:
            for connect in connects:
                from_type = Xml.get_attribute(connect, "from")
                if from_type == search_type:
                    parent_type = Xml.get_attribute(connect, "to")
                    break



        """
        # DEPRECATED: resort to old style
        if not parent_type:
            connects = my.xml.get_nodes("schema/connect[@to='%s']" % search_type ) 
            # FIXME: you need to assign parent_type here
            for connect in connects:
                type = Xml.get_attribute(connect, "type")
                if type != relationship:
                    continue
                parent_type = Xml.get_attribute(connect, "from") 
                # FIXME: should we call break?
        """


        if not parent_type and my.parent_schema:
            parent_type = my.parent_schema.get_parent_type(search_type, relationship)


        return parent_type
开发者ID:davidsouthpaw,项目名称:TACTIC,代码行数:57,代码来源:schema.py

示例6: get_task_pipeline

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_task_pipeline(my, default=True):
        ''' assuming the child pipeline is task related '''
        task_pipeline_code = Xml.get_attribute( my.node, "task_pipeline" )
        node_type = Xml.get_attribute(my.node, "type")
        if node_type == "approval":
            return "approval"

        if not task_pipeline_code and default:
            return "task"
        else:
            return task_pipeline_code
开发者ID:nuxping,项目名称:TACTIC,代码行数:13,代码来源:pipeline.py

示例7: get_sobjects_by_node

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_sobjects_by_node(my, node):
        # get the sobjects        
        search_type = my.xml.get_attribute(node, "search_type")
        expr = my.xml.get_attribute(node, "expression")
        code = my.xml.get_attribute(node, "code")


        if expr:
            sobjects = Search.eval(expr)

        elif search_type:
            search = Search(search_type)
            search.set_show_retired(True)
            if code:
                search.add_filter("code", code)


            # have some specific attributes for specific search types
            # can use wildcards like % and *
            if search_type == 'config/widget_config':
                view = Xml.get_attribute(node, "view")
                if view:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)

                    if view.find("%") != -1 or view.find("*") != -1:
                        view = view.replace("*", "%")
                        view = view.replace("/", ".")
                        search.add_filter("view", view, op="like")
                    else:
                        search.add_filter("view", view)

            elif search_type == 'config/url':
                url = Xml.get_attribute(node, "url")
                if url:
                    ignore_columns = 'id,code'
                    Xml.set_attribute(node, "ignore_columns", ignore_columns)
                    if url.find("%") != -1:
                        search.add_filter("url", url, op="like")
                    else:
                        search.add_filter("url", url)
 


            search.add_order_by("id")
            sobjects = search.get_sobjects()
        else:
            sobjects = []


        return sobjects
开发者ID:blezek,项目名称:TACTIC,代码行数:53,代码来源:plugin.py

示例8: get_file_info

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_file_info(xml, file_objects, sobject, snapshot, show_versionless=False, is_list=False, protocol='http'):
        info = {}
        #TODO: {'file_type': [file_type]: [path], 'base_type': [base_type]: [file|directory|sequence]}

        if is_list:
            info = []
        else:
            repo_info = {}
            info['_repo'] = repo_info

        nodes = xml.get_nodes("snapshot/file")
        for node in nodes:
            type = Xml.get_attribute(node, "type")

            file_code = Xml.get_attribute(node, "file_code")

            file_object = file_objects.get(file_code)
            if not file_object:
                if isinstance(info, dict):
                    info[type] = ThumbWdg.get_no_image()
                else:
                    info.append((type, ThumbWdg.get_no_image()))
                Environment.add_warning("No file object", "No file object found for file code '%s'" % file_code)
                continue

            file_name = file_object.get_full_file_name()
            web_dir = sobject.get_web_dir(snapshot, file_object=file_object)

            # handle a range if it exists
            file_range = file_object.get_value("file_range")
            if file_range:
                from pyasm.biz import FileGroup, FileRange
                file_range = FileRange.get(file_range)
                file_names = FileGroup.expand_paths(file_name, file_range)
                # just check the first frame
                if file_names:
                    file_name = file_names[0]
            path = "%s/%s" % (web_dir, file_name)

            if protocol != "file":
                path = urllib.pathname2url(path)

            if isinstance(info, dict):
                info[type] = path
                lib_dir = sobject.get_lib_dir(snapshot, file_object=file_object)
                repo_info[type] = "%s/%s" % (lib_dir, file_name)
            else:
                info.append((type, path))

        return info
开发者ID:asmboom,项目名称:TACTIC,代码行数:52,代码来源:file_wdg.py

示例9: get_action_node

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_action_node(my, event_name, scope="dependent"):
        nodes = Xml.get_children(my.node)
        for node in nodes:
            node_name = Xml.get_node_name(node)
            if node_name == "action":
                node_event = Xml.get_attribute(node, "event")
                if node_event != event_name:
                    continue

                node_scope = Xml.get_attribute(node, "scope")
                if scope and node_scope != scope:
                    continue

                return node
开发者ID:0-T-0,项目名称:TACTIC,代码行数:16,代码来源:pipeline.py

示例10: add_attr_access

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def add_attr_access(self, search_type, attr, level):
        # find the group
        group_xpath = "rules/group[@key='%s']" % (search_type)
        group = self.xml.get_node(group_xpath)
        if group == None:
            # add the group (default to view)
            group_level = "view"
            group = self.add_sobject_access(search_type,group_level)


        # get the attr rule
        rule_xpath = "rules/group[@key='%s']/rule[@key='%s']" % (search_type,attr)
        rule = self.xml.get_node(rule_xpath )
        if rule != None:
            # if nothing has changed, continue
            access = Xml.get_attribute(rule,"access")
            if level == access:
                raise CommandExitException()
        else:
            rule = self.xml.create_element("rule")
            rule.setAttributeNS(None,"key",attr)

            #group.appendChild(rule)
            Xml.append_child(group, rule)

            #self.root.appendChild(group)
            Xml.append_child(self.root, group)


        # set the access level
        rule.setAttributeNS(None,"type","attr")
        rule.setAttributeNS(None,"access",level)
开发者ID:mincau,项目名称:TACTIC,代码行数:34,代码来源:add_user_to_group_cmd.py

示例11: get_type

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
 def get_type(my):
     node_type = Xml.get_attribute( my.node, "type" )
     if node_type == "auto":
         node_type = "action"
     if not node_type:
         node_type = "manual"
     return node_type
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:pipeline.py

示例12: get_color

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
 def get_color(my):
     color = Xml.get_attribute( my.node, "color" )
     from pyasm.web import Palette
     theme = Palette.get().get_theme()
     if theme == 'dark':
         color = Common.modify_color(color, -50)
     return color
开发者ID:funic,项目名称:TACTIC,代码行数:9,代码来源:pipeline.py

示例13: get_context

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_context(my, from_xml=False):
        # if the context is not specified, use the "from" process
        context = Xml.get_attribute(my.node, "context")

        if from_xml:
            return context
        
        if not context:
            process = Xml.get_attribute(my.node, "from")

            # if the from process contains a /, then use the main context
            if process.find("/") != -1:
                parts = process.split("/")
                process = parts[1]
            context = process
                
        return context
开发者ID:0-T-0,项目名称:TACTIC,代码行数:19,代码来源:pipeline.py

示例14: get_instance_type

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def get_instance_type(self, search_type, related_search_type):
        connect = self.xml.get_node("schema/connect[@to='%s' and @from='%s']" % \
            (search_type, related_search_type) ) 
        if connect == None:
            return ""

        # ensure that the connection is "many_to_many"
        type = Xml.get_attribute(connect, "type")
        if type != "many_to_many":
            return ""

        instance_type = Xml.get_attribute(connect, "instance_type")
        if not instance_type:
            raise Exception("No instance_type defined for [%s] to [%s]" % \
                (search_type, related_search_type) )

        return instance_type
开发者ID:mincau,项目名称:TACTIC,代码行数:19,代码来源:schema.py

示例15: handle_sobject

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_attribute [as 别名]
    def handle_sobject(my, node):
        search_type = my.xml.get_attribute(node, "search_type")

        include_id = my.xml.get_attribute(node, "include_id")
        if include_id in [True, 'true']:
            include_id = True
        else:
            include_id = False


        ignore_columns = Xml.get_attribute(node, "ignore_columns")
        if ignore_columns:
            ignore_columns = ignore_columns.split(",")
            ignore_columns = [x.strip() for x in ignore_columns]
        else:
            ignore_columns = []

        # FIXME:
        # it is possible that the manifest defines sobjects on search types
        # that don't exist.  This is because it uses the manifest of
        # the new pipeline and not the original ... 
        sobjects = my.get_sobjects_by_node(node)
        if not sobjects:
            print "Skipping as no sobjects found for [%s]" %search_type
            return []



        # If there are no sobjects, then no file is created because
        # no path can be extracted.

        path = my.get_path_from_node(node)

        print "Writing: ", path
        fmode = 'w'
        if os.path.exists(path):
            fmode = 'a'
        if not sobjects:
            # write out an empty file
            #f = open(path, 'w')
            f = codecs.open(path, fmode, 'utf-8')
            f.close()
            return []

        dumper = TableDataDumper()
        dumper.set_delimiter("#-- Start Entry --#", "#-- End Entry --#")
        if search_type == 'config/widget_config':
            dumper.set_ignore_columns(['code'])
        dumper.set_include_id(include_id)
        dumper.set_ignore_columns(ignore_columns)
        dumper.set_sobjects(sobjects)
        dumper.dump_tactic_inserts(path, mode='sobject')

        print "\t....dumped [%s] entries" % (len(sobjects))

        return sobjects
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:58,代码来源:plugin.py


注:本文中的pyasm.common.Xml.get_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。