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


Python Xml.get_nodes方法代码示例

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


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

示例1: handle_include

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def handle_include(my, node):
        path = my.xml.get_attribute(node, "path")
        if not path:
            raise TacticException("No path found for include in manifest")

        path = "%s/%s" % (my.plugin_dir, path)

        if path.endswith(".py"):
            from tactic.command import PythonCmd
            cmd = PythonCmd(file_path=path)
            manifest = cmd.execute()

        if not manifest:
            print "No manifest discovered in [%s]" %path
            return

        xml = Xml()
        xml.read_string(manifest)
        nodes = xml.get_nodes("manifest/*")

        sobjects = []
        for i, node in enumerate(nodes):
            name = my.xml.get_node_name(node)
            if name == 'sobject':
                dumped_sobjects = my.handle_sobject(node)
                if not dumped_sobjects:
                    dumped_sobjects = []
                sobjects.extend(dumped_sobjects)
            elif name == 'search_type':
                my.handle_search_type(node)
            elif name == 'include':
                my.handle_include(node)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:34,代码来源:plugin.py

示例2: get_file_paths

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [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: delete_files

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def delete_files(my, nodes):

        # clean out all of the files
        for node in nodes:
            name = my.xml.get_node_name(node)

            if name == "include":
                path = my.xml.get_attribute(node, "path")
                if not path:
                    print("WARNING: No path found for search type in manifest")
                    continue

                path = "%s/%s" % (my.plugin_dir, path)

                if path.endswith(".py"):
                    from tactic.command import PythonCmd
                    cmd = PythonCmd(file_path=path)
                    manifest = cmd.execute()
                    if manifest:
                        xml = Xml()
                        xml.read_string(manifest)
                        include_nodes = xml.get_nodes("manifest/*")

                        my.delete_files(include_nodes)
            elif name == "python":
                # don't delete python node file
                pass
            else:
                path = my.get_path_from_node(node)
                if path and os.path.exists(path):
                    print "Deleting: ", path
                    os.unlink(path)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:34,代码来源:plugin.py

示例4: get_default_task_xml

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def get_default_task_xml():
        global TASK_PIPELINE

        from pyasm.web import Palette
        palette = Palette.get()
        xml = Xml()
        xml.read_string(TASK_PIPELINE)
        nodes = Xml.get_nodes(xml, "pipeline/process")
        for node in nodes:
            process = Xml.get_attribute(node, "name")
            color = Task.get_default_color(process)
            Xml.set_attribute(node, "color", color)

        return xml.to_string()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:16,代码来源:task.py

示例5: Package

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
class Package(Command):

    def __init__(self, search_key, context, package):
        self.search_key = search_key
        self.context = context
        self.package = package

        self.package_xml = Xml()
        self.package_xml.read_string(package)

        super(Package, self).__init__()

        

    def execute(self):

        from tactic_client_lib import TacticServerStub
        server = TacticServerStub.get(protocol='local')

        # create a new snapshot
        snapshot = server.create_snapshot(self.search_key, self.context)

        # get all of the file_types

        file_nodes = self.package_xml.get_nodes("package/file_type")

        count = 0

        for file_node in file_nodes:
            name = self.package_xml.get_attribute(file_node, "name")

            values = self.package_xml.get_node_values_of_children(file_node)
            expression = values.get("expression")
            dir_naming = values.get("dir_naming")
            file_naming = values.get("file_naming")

            files =  Search.eval(expression)

            for file in files:
                file_type = "%s%s" % (name, count)
                try:
                    # FIXME: the assumed action is to checkin
                    server.add_file(snapshot, file, file_type=file_type, mode='copy', dir_naming=dir_naming, file_naming=file_naming)

                    # What if we just wished to copy?  Can we run the files
                    # through a naming convention filter?

                    count += 1
                except Exception as e:
                    print "WARNING: ", str(e)
开发者ID:mincau,项目名称:TACTIC,代码行数:52,代码来源:package.py

示例6: handle_include

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def handle_include(my, node):
        path = my.xml.get_attribute(node, "path")
        if not path:
            raise TacticException("No path found for search type in manifest")

        path = "%s/%s" % (my.plugin_dir, path)

        if path.endswith(".py"):
            from tactic.command import PythonCmd
            cmd = PythonCmd(file_path=path)
            manifest = cmd.execute()

        xml = Xml()
        xml.read_string(manifest)
        nodes = xml.get_nodes("manifest/*")
        nodes.reverse()

        my.handle_nodes(nodes)
开发者ID:blezek,项目名称:TACTIC,代码行数:20,代码来源:plugin.py

示例7: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def execute(self):

        mode = self.kwargs.get('mode')
        if not mode:
            mode = 'lib'


        transaction_xml = self.kwargs.get("transaction_xml")
        assert(transaction_xml)

        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:
                    if src.startswith(base_dir):
                        path = src
                    else:
                        path = "%s/%s" % (base_dir, src)
                paths.append(path)

        return paths
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:run_transaction_cmd.py

示例8: execute

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def execute(self):
        sobject = self.sobject

        name = self.get_name()

        web = WebContainer.get_web()

        naming = web.get_form_value(name)

        if not naming:
            return

        xml = Xml(string=naming)
        sample_name = xml.get_value("naming/@sample")

        parts = re.split( '[\\/._]', sample_name)


        # make some adjustments based on selections
        nodes = xml.get_nodes("naming/part")
        for idx, node in enumerate(nodes):

            type_value = web.get_form_value("type_%s" % idx)
            part = parts[idx]

            if not type_value:
                continue

            if type_value == "placeholder":
                Xml.set_attribute(nodes[idx], "type", "placeholder")
                Xml.set_attribute(nodes[idx], "value", part)
            else:
                a, b = type_value.split("/")
                Xml.set_attribute(nodes[idx], "type", a)
                Xml.set_attribute(nodes[idx], "name", b)

        naming = xml.to_string() 


        sobject.set_value(name, naming)
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:naming_wdg.py

示例9: verify_dir

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def verify_dir(my, base):

        # ignore transactions that a derived from this server
        server_code = Config.get_value("install", "server")
        if base.startswith("%sTRANSACTION" % server_code):
            return False


        if base.find("TRANSACTION") == -1:
            return False


        if not os.path.isdir(base):
            if base.endswith(".zip.enc"):
                return True
            elif base.endswith(".zip"):
                return True
            else:
                return False


        asset_dir = Environment.get_asset_dir()

        transaction_path = "%s/_transaction.xml" % base
        if not os.path.exists(transaction_path):
            return False

        xml = Xml()
        xml.read_file(transaction_path)

        nodes = xml.get_nodes("transaction/file")

        # verify that all the files are present
        for node in nodes:

            code = xml.get_attribute(node, "code")

            file_sobj = Search.get_by_code("sthpw/file", code)

            src = xml.get_attribute(node, "src")
            rel_path = xml.get_attribute(node, "rel_path")

            src_path = "%s/%s" % (base, rel_path)
            if not os.path.exists(src_path):
                print "[%s] has not arrived" % src_path
                return False


            st_size = xml.get_attribute(node, "size")
            if st_size:
                st_size = int(st_size)
            else:
                st_size = -1
            md5 = xml.get_attribute(node, "md5")

            if st_size != -1:
                # check that the size is the same
                if st_size != os.path.getsize(src_path):
                    print "[%s] size does not match" % src_path
                    return False


        # all the tests have passed
        return True
开发者ID:0-T-0,项目名称:TACTIC,代码行数:66,代码来源:watch_handoff_folder.py

示例10: get_display

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
    def get_display(my):
        

        my.kwargs['search_key'] = 'prod/asset?project=sample3d&code=chr001'



        custom = """<?xml version='1.0' encoding='UTF-8'?>
        <custom>

        <html>
        <div>
            This is html
            <textarea class='spt_test spt_input' name='description'>
</textarea>
            <input class='spt_input' type='text' name='title'/>
            <br/>
            <input class='spt_button1' type='button' value='Press Me'/>
            <input class='spt_button2' type='button' value='Press Me2'/>
            <input class='spt_button3' type='button' value='Calendar'/>
            <input class='spt_refresh' type='button' value='Refresh'/>


            <element>
              <display class='tactic.ui.widget.CalendarWdg'/>
            </element>
            Much simpler!!!
            <elemeent class='CalendarWdg' blah='adasf'/>

        </div>
        </html>
        <behavior class='spt_button1'>{
            "type": "click_up",
            "cbjs_action": '''
            app.mel('sphere');
            //var top = bvr.src_el.getParent(".spt_panel");
            //var values = spt.api.Utility.get_input_values(top);
            //console.log(values);
            '''
        }</behavior>
        <behavior class='spt_button2'>{
            "type": "click_up",
            "cbjs_action": "alert(bvr.kwargs.search_key);"
        }</behavior>
        <behavior class='spt_button3'>{
            "type": "click_up",
            "cbjs_action": '''
            spt.panel.load('main_body', bvr.class_name, bvr.kwargs);
            //spt.panel.load('main_body', 'tactic.ui.widget.CalendarWdg', bvr.kwargs);
            '''
        }</behavior>
        <behavior class='spt_refresh'>{
            "type": "click_up",
            "cbjs_action": '''
            var top = bvr.src_el.getParent(".spt_panel");
            spt.panel.refresh(top);
            '''

        }</behavior>

        </custom>

        """

        xml = Xml()
        xml.read_string(custom)

        top = DivWdg()
        my.set_as_panel(top)
        top.add_class("spt_panel")

        inner = DivWdg()
        top.add(inner)

        html_node = xml.get_node("custom/html")
        html = xml.to_string(html_node)
        inner.add(html)

        behaviors = xml.get_nodes("custom/behavior")
        for behavior in behaviors:
            css_class = Xml.get_attribute(behavior, 'class')
            value = Xml.get_node_value(behavior)
            value = eval(value)

            # add the kwargs to this so behaviors have access
            value['kwargs'] = my.kwargs
            value['class_name'] = Common.get_full_class_name(my)

            inner.add_behavior({
                'type': 'load',
                'value': value,
                'css_class': css_class,
                'cbjs_action': '''
                var el = bvr.src_el.getElement("."+bvr.css_class);
                if (!el) {
                    alert("WARNING: element ["+bvr.css_clsss+"] does not exist");
                }
                spt.behavior.add( el, bvr.value);
                '''
            })
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:test_custom_wdg.py

示例11: CustomXmlWdg

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
class CustomXmlWdg(BaseTableElementWdg):
    '''Creates an widget from xml
    <widget name="Filter">
        <display class="FilterSelectWdg">
            <values>Sc01|Sc02|Sc03</values>
        </display>
    </widget>
    '''
    def __init__(self, xml_string):

        self.xml_string = xml_string
        self.xml = Xml(string=self.xml_string)
        super(CustomXmlWdg, self).__init__()

    def init(self):
        self.widget_class = self.xml.get_value("widget/display/@class")
        self.draw = self.xml.get_value("widget/display/@draw")
        self.title = self.xml.get_value("widget/@name")
        self.name = self.title


        # convert the widget data
        options = {}
        nodes = self.xml.get_nodes("widget/display/*")
        for node in nodes:
            name = node.nodeName
            value = Xml.get_node_value(node)

            if options.has_key(name):
                # turn this into an array
                array = []
                array.append(options.get(name))
                array.append(value)
                options[name] = array
            else:
                options[name] = value

        self.options = options
        self.widget = Common.create_from_class_path(self.widget_class, [self.title])
   


    def get_child_widget_class(self):
        return self.xml.get_value("widget/display/@class")

    def get_child_widget(self):
        return self.widget


    def get_title(self): 
        self.widget = Common.create_from_class_path(self.widget_class, [self.title])
        self.widget.options = self.options
        self.widget.set_title(self.title)
        self.widget.set_name(self.title)
        Container.put_dict("widgets", self.title, self.widget)

        index = self.get_current_index()
        self.widget.set_sobjects(self.sobjects)
        self.widget.set_current_index(index)
        if self.draw == "false":
            return ""
        else:
            return self.widget.get_title()
        

    def get_display_widget(self):
        return self.widget

    def get_display(self):
        self.widget.options = self.options
        self.widget.set_title(self.title)
        self.widget.set_name(self.title)
        self.widget.parent_wdg = self.parent_wdg
        Container.put_dict("widgets", self.title, self.widget)

        index = self.get_current_index()
        self.widget.set_sobjects(self.sobjects)
        self.widget.set_search(self.search)
        self.widget.set_current_index(index)
        if self.draw == "false":
            return None
        else:
            return self.widget
开发者ID:mincau,项目名称:TACTIC,代码行数:85,代码来源:tab_wdg.py

示例12: SyncFilter

# 需要导入模块: from pyasm.common import Xml [as 别名]
# 或者: from pyasm.common.Xml import get_nodes [as 别名]
class SyncFilter(object):

    def __init__(self, **kwargs):
        self.kwargs = kwargs

        self.log = self.kwargs.get("transaction")
        self.rules = self.kwargs.get("rules")
        self.message = ""


    def execute(self):
        log = self.log
        rules = self.rules

        # Give rules.  Only notes will get through
        # we need heirarchical rules.  This will ensure that only notes
        # for project/assets will pass
        # Here, the second one is much more difficult to do.
        rulesXXX = '''
        <rule group='heirarchy' key='project/asset.sthpw/note' access='allow'/>
        <rule group='heirarchy' key="project/asset.sthpw/note['assigned','beth']" access='allow'/>"
        '''

        access_manager = AccessManager()
        access_manager.add_xml_rules(rules)


        # filter out project
        namespace = log.get_value("namespace")
        key1 = { 'code': namespace }
        key2 = { 'code': '*' }
        keys = [key1, key2]
        if not access_manager.check_access("project", keys, "allow", default="deny"):
            self.filtered_xml = Xml()
            self.filtered_xml.read_string("<transaction/>")
            self.message = "Transaction prevented due to project restriction"
            return


        # filter the transaction against the security model
        xml = log.get_xml_value("transaction")

        self.filtered_xml = Xml()
        self.filtered_xml.create_doc("transaction")
        root2 = self.filtered_xml.get_root_node()

        nodes = xml.get_nodes("transaction/*")
        num_nodes = len(nodes)
        count = 0


        for node in nodes:
            if Xml.get_node_name(node) ==  "sobject":
                search_type = xml.get_attribute(node, "search_type")
                parts = search_type.split("?")
                search_type = parts[0]

                # filter search types
                key1 = { 'code': search_type }
                key2 = { 'code': "*" }
                keys = [ key1, key2 ]
                if not access_manager.check_access("search_type", keys, "allow", default="deny"):
                    continue

                # check hierachical rule
                parent_type = xml.get_attribute(node, "parent_type")
                key = "%s.%s" % (parent_type, search_type)
                
                self.filtered_xml.append_child(root2, node)
                count += 1
                
            else:
                self.filtered_xml.append_child(root2, node)
                count += 1

        if len(nodes) != 0 and len(self.filtered_xml.get_nodes("transaction/*")) == 0:
            self.message = "All actions filtered due to security restrictions (%s actions)" % num_nodes



    def get_filtered_xml(self):
        return self.filtered_xml

    def get_message(self):
        return self.message
开发者ID:mincau,项目名称:TACTIC,代码行数:87,代码来源:sync_filter.py


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