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


Python Common.get_unique_list方法代码示例

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


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

示例1: init

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
 def init(self):
     # dummy checkbox
     # it is required otherwise, it won't detect the value on first page load
     self.cb = CheckboxWdg('task_status')
     self.cb.set_persistence()
     for pipeline in self.task_pipelines:
         process_names = pipeline.get_process_names()
         self.process_names.extend(process_names)
     self.process_names = Common.get_unique_list(self.process_names)
     self.cb.set_option('default', self.process_names)
开发者ID:mincau,项目名称:TACTIC,代码行数:12,代码来源:task_manager_wdg.py

示例2: get_process_names

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_process_names(my):
        '''get a unique list of process names'''
        search_type = my._get_search_type()
        proj_code = Project.extract_project_code(search_type)

        dict = Pipeline.get_process_name_dict(search_type, project_code=proj_code)
        process_list = []
        for x in dict.values():
            process_list.extend(x)
        names = Common.get_unique_list(process_list)
        return names
开发者ID:0-T-0,项目名称:TACTIC,代码行数:13,代码来源:prod_input_wdg.py

示例3: get_connections

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_connections(cls, sobjects, direction="dst", context='', context_filters=[], src_search=None):
        '''return a Search instance if src_search is provided'''
        if not sobjects and not src_search:
            return []
        search = Search(SObjectConnection)

        if direction == "dst":
            prefix = "src"
        else:
            prefix = "dst"
        
        if src_search:
            search.add_filter("%s_search_type" % prefix, src_search.get_search_type() )
            search.add_search_filter('%s_search_id'%prefix, src_search, op="in") 
        else:
            search_types = [x.get_search_type() for x in sobjects]
            search_ids = [x.get_id() for x in sobjects]

            if len(Common.get_unique_list(search_types)) == 1:
                search.add_filter("%s_search_type" % prefix, search_types[0] )
                search.add_filters("%s_search_id" % prefix, search_ids)
            else:
                search.add_op("begin")
                for search_type, search_id in zip(search_types, search_ids):
                    search.add_op("begin")
                    search.add_filter("%s_search_type" % prefix, search_type )
                    search.add_filter("%s_search_id" % prefix, search_id )
                    search.add_op("and")
                search.add_op("or")

        if context:
            search.add_filter("context", context)
        elif context_filters:
            search.add_op_filters(context_filters)

        if src_search:
            return search

		# cache for connection sobjects
        key = search.get_statement()
        cache = Container.get("SObjectConnection:cache")
        if cache == None:
            cache = {}
            Container.put("SObjectConnection:cache", cache)

        ret_val = cache.get(key)
        if ret_val != None:
            return ret_val

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

示例4: get_config

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_config(cls, search_type, view, default=None, personal=False):
        # personal doesn't mean much here since this is only for Project view definition
        """
        if view == "__column__":
            xml == '''
            <config>
                <element name="tttt" type="__database__"/>
                <element name="uuuu" type="__database__"/>
                <element name="vvvv" type="__database__"/>
            </config>
            '''
        """
        widget_config = None
        config_view = None
        widget_config_list = []

        # get all the configs relevant to this search_type
        configs = []

        from pyasm.widget import WidgetConfigView

        if view == "definition":
            if default:
                try:
                    default_config_view = WidgetConfigView.get_by_search_type(
                        search_type, view, use_cache=False, local_search=True
                    )

                    user_config_view = WidgetConfigView.get_by_search_type(search_type, view)

                    # merge the user config view from db into the default config view in xml file
                    default_config = default_config_view.get_definition_config()
                    user_config = user_config_view.get_definition_config()
                    if user_config:
                        user_element_names = user_config.get_element_names()
                        # make sure it's unique, there is a new validate function for
                        # WidgetDbConfig to ensure that also
                        user_element_names = Common.get_unique_list(user_element_names)
                        for elem in user_element_names:
                            user_node = user_config.get_element_node(elem)
                            default_config.append_xml_element(elem, node=user_node)
                except SqlException, e:
                    print "Search ERROR: ", e.__str__()
                    default_config = None

                if default_config:
                    default_config.get_xml().clear_xpath_cache()
                    widget_config_list = [default_config]

            else:
                config_view = WidgetConfigView.get_by_search_type(search_type, view, use_cache=True)
开发者ID:pombredanne,项目名称:TACTIC,代码行数:53,代码来源:search_type_manager_wdg.py

示例5: get_snapshot_contexts

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_snapshot_contexts(my, search_type, search_id):
        '''get the contexts for the snapshots'''
        contexts = Snapshot.get_contexts(search_type, search_id)

        # add all of the asset snapshots
        #my.instance_search_type = my.kwargs.get('search_type')
        instance = Search.get_by_id(search_type, search_id)
        if not my.asset_search_type:
            my.asset_search_type = 'prod/asset'
        #asset = instance.get_asset(search_type = my.asset_search_type)

        asset_code = instance.get_value("asset_code")
        asset = Search.get_by_code(my.asset_search_type, asset_code)
        if not asset:
            return contexts
        asset_id = asset.get_id()
        asset_search_type = asset.get_search_type()

        asset_contexts = Snapshot.get_contexts(asset_search_type, asset_id)
        contexts.extend(asset_contexts)
        contexts = Common.get_unique_list(contexts)
        contexts.sort()
        return contexts
开发者ID:0-T-0,项目名称:TACTIC,代码行数:25,代码来源:asset_history_wdg.py

示例6: get_config

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_config(cls, search_type, view, default=None, personal=False):
        # personal doesn't mean much here since this is only for Project view definition
        """
        if view == "__column__":
            xml == '''
            <config>
                <element name="tttt" type="__database__"/>
                <element name="uuuu" type="__database__"/>
                <element name="vvvv" type="__database__"/>
            </config>
            '''
        """
        widget_config = None
        config_view = None
        widget_config_list = []


        # get all the configs relevant to this search_type
        configs = []
       
        from pyasm.widget import WidgetConfigView
        if view == "definition":
            if default:
                try:
                    default_config_view = WidgetConfigView.get_by_search_type(search_type, view, use_cache=False, local_search=True)

                    user_config_view = WidgetConfigView.get_by_search_type(search_type, view)
                  
                    #merge the user config view from db into the default config view in xml file
                    default_config = default_config_view.get_definition_config()
                    user_config = user_config_view.get_definition_config()
                    if user_config:
                        user_element_names = user_config.get_element_names()
                        # make sure it's unique, there is a new validate function for
                        # WidgetDbConfig to ensure that also
                        user_element_names = Common.get_unique_list(user_element_names)
                        for elem in user_element_names:
                            user_node = user_config.get_element_node(elem)
                            default_config.append_xml_element(elem, node=user_node)
                except SqlException as e:
                     print "Search ERROR: ", e.__str__()
                     default_config = None
                
                if default_config:
                    default_config.get_xml().clear_xpath_cache()
                    widget_config_list = [default_config]

            else:
                config_view = WidgetConfigView.get_by_search_type(search_type, view, use_cache=True)

        elif view == "database_definition":
            schema_config = SearchType.get_schema_config(search_type)
            widget_config_list = [schema_config]
        elif view == 'template':
            base_dir = Environment.get_install_dir()
            file_path="%s/src/config2/search_type/search/DEFAULT-conf.xml" % base_dir
            if os.path.exists(file_path):
                widget_config = WidgetConfig.get(file_path=file_path, view=view)
                widget_config_list = [widget_config]
            '''
            elif default == True :
                base_dir = Environment.get_install_dir()
                file_path="%s/src/config2/search_type/search/DEFAULT-conf.xml" % base_dir
                if os.path.exists(file_path):
                    widget_config = WidgetConfig.get(file_path=file_path, view="default_definition")
                    widget_config_list = [widget_config]
            '''
        elif view == "custom_definition":
            # look for a definition in the database
            search = Search("config/widget_config")
            search.add_filter("search_type", 'SearchTypeSchema')
            search.add_filter("view", view)
            config = search.get_sobject()
            # this is really just a custom made definition
            #view = "definition"
            
            if config:
                widget_config_list = [config]
            else:
                widget_config_list = []

        elif view == "db_column":
            # look for a definition in the database
            """
            view = "definition"
            from pyasm.search import SObjectDefaultConfig
            default = SObjectDefaultConfig(search_type=search_type,view=view)
            xml = default.get_xml()
            config = WidgetConfig.get(view=view, xml=xml)
            widget_config_list = [config]
            """
            try:   
                # add the schema config definiiton
                schema_config = SearchType.get_schema_config(search_type)
                widget_config_list = [schema_config]
            except SqlException as e:
                widget_config_list = []
        if not config_view:
            config_view = WidgetConfigView(search_type, view, widget_config_list)
        return config_view
开发者ID:mincau,项目名称:TACTIC,代码行数:102,代码来源:search_type_manager_wdg.py

示例7: get_connected_sobjects

# 需要导入模块: from pyasm.common import Common [as 别名]
# 或者: from pyasm.common.Common import get_unique_list [as 别名]
    def get_connected_sobjects(cls, sobjects, direction="dst", order_by=None, context='', filters=None):
        '''get the sobjects that are connect to this sobject.'''
        unique_stype = False
        single_sobject = False
        src_search_types = []
        src_search_ids = []
        if not sobjects:
            return [], []
        if isinstance(sobjects, list):
            search_types = [x.get_search_type() for x in sobjects]
            search_ids = [x.get_id() for x in sobjects]
            if len(Common.get_unique_list(search_types)) == 1:
                unique_stype = True
              
 
        else:
            search_types = [sobjects.get_search_type()]
            search_ids = [sobjects.get_id()]
            unique_stype = True
            single_sobject = True


        if direction == "dst":
            prefixA = "dst"
            prefixB = "src"
        else:
            prefixA = "src"
            prefixB = "dst"

        connections = []
        if unique_stype:
            search = Search(SObjectConnection)
            search.add_filter("%s_search_type" % prefixA, search_types[0] )
            search.add_filters("%s_search_id" % prefixA, search_ids )

            if context:
                search.add_filter("context", context)

            if order_by:
                search.add_order_by(order_by)


            key = search.get_statement()
            cache = Container.get("SObjectConnection:cache")
            if cache == None:
                cache = {}
                Container.put("SObjectConnection:cache", cache)
            ret_val = cache.get(key)
            if ret_val != None:
                return ret_val
            


            connections = search.get_sobjects()

            """
            new_search = Search(src_search_types[0])
            select = new_search.get_select()
            from_table = new_search.get_table()
            to_table = 'connection'
            from_col = 'id'
            to_col = 'src_search_id'
            select.add_join(from_table, to_table, from_col, to_col, join='INNER', database2='sthpw')
            """


        else:
            raise TacticException('Only unique stypes are supported for the passed in sobjects')

        src_sobjects = []
         
        src_stype = None
        src_stypes = SObject.get_values(connections, "%s_search_type" % prefixB, unique=True)
        src_ids = SObject.get_values(connections, "%s_search_id" % prefixB, unique=True)
        if len(src_stypes) == 1:
            src_stype = src_stypes[0]
           
        if src_stype:
            single_src_ids = len(src_ids) == 1
            if not filters and single_src_ids:

                src = Search.get_by_id(src_stype, src_ids[0])
                src_sobjects.append(src)
            else:
                new_search = Search(src_stype)
                if single_src_ids:
                    new_search.add_filter('id', src_ids[0])
                else:
                    new_search.add_filters('id', src_ids)
                if filters:
                    new_search.add_op_filters(filters)
                src_sobjects = new_search.get_sobjects()

        else:
            for connection in connections:
                src_search_type = connection.get_value("%s_search_type" % prefixB)
                src_search_id = connection.get_value("%s_search_id" % prefixB)

                # TODO: this could be made faster because often, these will be
                # of the same stype
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:sobject_connection.py

示例8: get_display

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

        config_search_type = "config/widget_config"
         
        configs = []
	all_element_names = []
        from tactic.ui.panel import SideBarBookmarkMenuWdg
        SideBarBookmarkMenuWdg.add_internal_config(configs, ['definition'])
        for internal_config in configs:
            all_element_names = internal_config.get_element_names()

	search = Search(config_search_type)
        search.add_filter("search_type", 'SideBarWdg')
        search.add_filter("view", 'definition')
        search.add_filter("login", None)

        config = search.get_sobject()
        element_names = []
        if config:
            element_names = config.get_element_names()
            for name in element_names:
                if 'separator' in name:
                    element_names.remove(name)

	all_element_names.extend(element_names)

	
        all_element_names = [str(name) for name in all_element_names] 
	all_element_names = Common.get_unique_list(all_element_names)
        widget = DivWdg(css='spt_load_test_top')
	
	span =SpanWdg('This loads all the pages defined in the Project views in popups. It will take a few minutes.')
	widget.add(span)
	widget.add('<br/>')
        div = ActionButtonWdg(title='Run')
        web = WebContainer.get_web()
        base_url = web.get_base_url().to_string()
        base_url = '%s/tactic/%s' %(base_url, Project.get_project_code())
        div.add_behavior({'type': 'click_up',
           'cbjs_action': '''
            var element_names = eval(%s);
            var all_element_names = eval(%s);
            var top = spt.get_parent(bvr.src_el, '.spt_load_test_top');
            var cb = spt.get_element(top, '.spt_input')
            if (cb.checked)
                element_list = all_element_names;
            else
                element_list = element_names
            for (var k=0; k < element_list.length; k++) {
                var name = element_list[k];
		//if (k > 3) break;

                var url = '%s/#/link/' + name;
		var bvr2 = {
                    title: name,
                    target_id: 'TEST',
                    options: {'link': name,
                    'title': name,
		    'path': '/Link Test/' + name
			},
                    is_popup: true};

                spt.side_bar.display_link_cbk(null, bvr2);

            }
            ''' %(element_names, all_element_names, base_url)})
        widget.add('<br/>')
        
        cb = CheckboxWdg('include_internal', label='include built-in pages')
        
        span = SpanWdg(cb, css='med')
        span.add_color('color','color')
        widget.add(span)
        widget.add(div)

        widget.add('<br/>')
        widget.add('<br/>')
	
        return widget
开发者ID:mincau,项目名称:TACTIC,代码行数:81,代码来源:system_info_wdg.py


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