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


Python Search.add_op_filters方法代码示例

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


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

示例1: get_sobjects

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def get_sobjects(my, connections, direction='dst', filters=None, return_search=False):

        if not connections:
            return []

        if direction == "dst":
            prefix = "dst"
        else:
            prefix = "src"

        search_type = connections[0].get_value("%s_search_type" % prefix)

        search = Search(search_type)
        search_ids = [x.get_value("%s_search_id" % prefix) for x in connections]
        search.add_filters("id", search_ids )

        if filters:
            search.add_op_filters(filters)

        if return_search:
            return search

        sobjects = search.get_sobjects()

        return sobjects
开发者ID:0-T-0,项目名称:TACTIC,代码行数:27,代码来源:sobject_connection.py

示例2: get_connections

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [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

示例3: get_connections

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def get_connections(cls, sobjects, direction="dst", context='', context_filters=[]):

        if not sobjects:
            return []
        search_types = [x.get_search_type() for x in sobjects]
        search_ids = [x.get_id() for x in sobjects]
    
        if direction == "dst":
            prefix = "src"
        else:
            prefix = "dst"

        search = Search(SObjectConnection)

        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)


        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:blezek,项目名称:TACTIC,代码行数:44,代码来源:sobject_connection.py

示例4: get_notes_and_stypes_counts

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
def get_notes_and_stypes_counts(process, search_key, stypes_list):
    # getting notes by search_type process and count of stypes from stypes_list
    from pyasm.search import Search

    search_type, search_code = server.split_search_key(search_key)

    cnt = {
        'notes': {},
        'stypes': {},
    }
    for p in process:
        search = Search('sthpw/note')
        search.add_op_filters([('process', p), ('search_type', search_type), ('search_code', search_code)])
        cnt['notes'][p] = search.get_count()

    for stype in stypes_list:
        search = Search(stype)
        search.add_parent_filter(search_key)
        cnt['stypes'][stype] = search.get_count()

    return cnt
开发者ID:listyque,项目名称:TACTIC-Handler,代码行数:23,代码来源:tactic_query.py

示例5: get_display

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


        state = my.get_state()
        search_type = state.get("search_type")
        sobj = my.get_current_sobject()

        if search_type:
            st = search_type
        else:
            
            st = sobj.get_base_search_type()
        # for inline insert, this should proceed
        #if not sobj:
        #    return ''
        
        st_suffix = st.split('/', 1)
    
        if len(st_suffix) == 2:
            st_suffix = st_suffix[1]
        
        search = Search('sthpw/pipeline')
        search.add_op_filters([('search_type','EQ', '/%s' %st_suffix)])

        # takes into account site-wide pipeline
        search.add_project_filter(show_unset=True)
        sobjects = search.get_sobjects()

        codes = [x.get_code() for x in sobjects]

        if my.get_option("use_code") in [True, 'true']:
            names = codes
        else:

            names = []
            for x in sobjects:
                name = x.get_value("name")
                if not name:
                    name = x.get_value("code")
                names.append(name)



        select = SelectWdg(my.get_input_name())
        select.add_empty_option("-- Default --")
        select.set_option("values", codes)
        select.set_option("labels", names)
        if sobj:
            value = sobj.get_value(my.get_name())
            if value:
                select.set_value(value)

        else: 
            # only for inline
            #behavior =  { 'type': 'click',
            #       'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );'}
            #select.add_behavior(behavior)
            pass
        

        return select
开发者ID:nuxping,项目名称:TACTIC,代码行数:63,代码来源:pipeline_input_wdg.py

示例6: handle_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def handle_search(my):

        # this is an absolute expression
        my.search_expr = my.kwargs.get("search_expr")
        my.search_type = my.kwargs.get("search_type")
        if not my.search_type:
            my.search_type = 'sthpw/task'
        if my.search_expr:
            search = Search.eval(my.search_expr)

        else:
            

            my.op_filters = my.kwargs.get("filters")
            if my.op_filters:
                if isinstance(my.op_filters, basestring):
                    my.op_filters = eval(my.op_filters)
            search = Search(my.search_type)
            if my.op_filters:
                search.add_op_filters(my.op_filters)

        my.start_column = my.kwargs.get('start_date_col')
        if not my.start_column:
            my.start_column = 'bid_start_date'

        my.end_column = my.kwargs.get('end_date_col')
        if not my.end_column:
            my.end_column = 'bid_end_date'

       
        

        search.add_op('begin')

        if my.handler:
            my.handler.alter_search(search)

        search.add_op('or')




        my.start_date = datetime(my.year, my.month, 1)
        next_month = my.month+1
        next_year = my.year
        if next_month > 12:
            next_month = 1
            next_year += 1

        my.end_date = datetime(next_year, next_month, 1)
        my.end_date = my.end_date - timedelta(days=1)

        # outer begin
        search.add_op('begin')

        search.add_op('begin')
        search.add_date_range_filter(my.start_column, my.start_date, my.end_date)
        search.add_date_range_filter(my.end_column, my.start_date, my.end_date)

        search.add_op('or')
        search.add_op('begin')
        search.add_filter(my.start_column, my.start_date, op='<=')
        search.add_filter(my.end_column, my.end_date, op='>=')
        search.add_op('and')
        
        search.add_op('or')


        search.add_order_by(my.start_column)
        print "search: ", search.get_statement()

        my.sobjects = search.get_sobjects()
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:74,代码来源:sobject_calendar_wdg.py

示例7: get_transaction_info

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def get_transaction_info(my):

        remote_server = my.get_remote_server()

        
        search_keys = my.kwargs.get("search_keys")

        project_code = my.kwargs.get("project_code")
        if not project_code:
            project_code = Project.get_project_code()

        print "search_keys: ", search_keys

        if search_keys:
            search_keys_str = "|".join(search_keys)
            # need to get the code from the search_keys
            codes = []
            for search_key in search_keys:
                # HACK
                parts = search_key.split("code=")
                code = parts[1]
                codes.append(code)
            codes_str = "|".join(codes)

            filters = [
                ['code','in',codes_str]
            ]
            remote_codes = remote_server.query("sthpw/transaction_log", filters=filters, columns=['code'], order_bys=['timestamp'])

        elif my.start_expr:

            start_date = my.get_date(my.start_expr)

            # FIXME: this only works with Postgres
            filters = [
	        ['timestamp', '>', str(start_date)],
            ]

            if project_code:
                filters.append( ['namespace', project_code] )

            remote_codes = remote_server.query("sthpw/transaction_log", filters=filters, columns=['code'], order_bys=['timestamp'])
        else:
            raise TacticException("No start date expression given")


        print "# remote codes: ", len(remote_codes)



        # get all of the local transactions with the same filters
        search = Search("sthpw/transaction_log")
        search.add_column("code")
        search.add_filter("namespace", project_code)
        search.add_op_filters(filters)
        search.add_order_by("timestamp")
        print "search: ", search.get_statement()
        local_codes = search.get_sobjects()
        print "local codes: ", local_codes

        lset = set()
        for lt in local_codes:
            lcode = lt.get_value("code")
            if not lcode:
                continue
            lset.add(lcode)
            

        rset = set()
        for rt in remote_codes:
            rcode = rt.get("code")
            if not rcode:
                continue
            rset.add(rcode)
            

        info = {}
        remote_diff = rset.difference(lset)
        local_diff = lset.difference(rset)

        # go get the missing remote transactions
        filters = [['code', 'in', "|".join(remote_diff)]]
        remote_transactions = remote_server.query("sthpw/transaction_log", filters=filters, order_bys=['timestamp'])
        for i, transaction in enumerate(remote_transactions):
            sobject = SearchType.create("sthpw/transaction_log")
            sobject.data = transaction
            remote_transactions[i] = sobject
        info['remote_transactions'] = remote_transactions
 

        search = Search("sthpw/transaction_log")
        search.add_filters("code", local_diff)
        search.add_order_by("timestamp")
        local_transactions = search.get_sobjects()
        info['local_transactions'] = local_transactions

        local_paths = []
        for transaction in local_transactions:
            paths = my.get_file_paths(transaction)
            if not paths:
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:103,代码来源:sync_utils.py

示例8: get_connected_sobjects

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def get_connected_sobjects(cls, sobject, direction="dst", order_by=None, context='', filters=None):
        '''get the sobjects that are connect to this sobject.'''

        search_type = sobject.get_search_type()
        search_id = sobject.get_id()
     
        if direction == "dst":
            prefixA = "dst"
            prefixB = "src"
        else:
            prefixA = "src"
            prefixB = "dst"

        search = Search(SObjectConnection)
        search.add_filter("%s_search_type" % prefixA, search_type )
        search.add_filter("%s_search_id" % prefixA, search_id )

        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()
        src_sobjects = []
        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
            if not filters:
                src = Search.get_by_id(src_search_type, src_search_id)
            else:
                src_search = Search(src_search_type)
                src_search.add_filter("id", src_search_id)
                src_search.add_op_filters(filters)
                src = src_search.get_sobject()

            #if not src.is_retired():
            # don't check for retired here. check it at the caller for
            # css manipulation
            if src:
                src_sobjects.append(src)
            else:
                print "WARNING: connection sobject does not exist .. deleting"
                connection.delete()

        cache[key] = connections, src_sobjects
        return connections, src_sobjects
开发者ID:blezek,项目名称:TACTIC,代码行数:64,代码来源:sobject_connection.py

示例9: get_connected_sobjects

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [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

示例10: create_snapshot_extended

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
def create_snapshot_extended(search_key, context, snapshot_type=None, is_revision=False, is_latest=True, is_current=False, description=None, version=None, level_key=None, update_versionless=True, file_types=None, file_names=None, file_paths=None, relative_paths=None, source_paths=None, file_sizes=None, exts=None, keep_file_name=True, repo_name=None, virtual_snapshot=None, mode=None, create_icon=False):
    from pyasm.biz import Snapshot
    from pyasm.checkin import FileAppendCheckin
    from pyasm.search import Search

    api = server.server

    sobjects = api._get_sobjects(search_key)
    sobject = sobjects[0]

    # get the level object
    if level_key:
        levels = api._get_sobjects(level_key)
        level = levels[0]
        level_type = level.get_search_type()
        level_id = level.get_id()
    else:
        level_type = None
        level_id = None

    if not description:
        description = 'No description'
    if not snapshot_type:
        snapshot_type = 'file'

    if mode == 'inplace':
        version_file_paths = []
        versionless_file_paths = []
        version_relative_paths = []
        versionless_relative_paths = []
        for p, fn in zip(virtual_snapshot['versioned']['paths'], virtual_snapshot['versioned']['names']):
            version_file_paths.append('{0}/{1}'.format(p, fn))
            version_relative_paths.append(p)
        for p, fn in zip(virtual_snapshot['versionless']['paths'], virtual_snapshot['versionless']['names']):
            versionless_file_paths.append('{0}/{1}'.format(p, fn))
            versionless_relative_paths.append(p)
    if not version:
        ver = server.eval("@MAX(sthpw/snapshot['context', '{0}'].version)".format(context), search_keys=[search_key])
        if ver:
            version = int(ver) + 1
        else:
            version = 1
    snapshot = Snapshot.create(sobject, snapshot_type=snapshot_type, context=context, description=description, is_revision=is_revision, is_latest=is_latest, is_current=is_current, level_type=level_type, level_id=level_id, commit=False, version=version)

    if repo_name:
        snapshot.set_value('repo', repo_name)
    if is_latest:
        snapshot.set_value('is_latest', 1)
    if is_current:
        snapshot.set_value('is_current', 1)

    snapshot.commit(triggers=True, log_transaction=True)

    dir_naming = None
    file_naming = None

    checkin = FileAppendCheckin(snapshot.get_code(), version_file_paths, file_types, keep_file_name=keep_file_name, mode=mode,
                                source_paths=source_paths, dir_naming=dir_naming, file_naming=file_naming,
                                checkin_type='auto', do_update_versionless=False)
    checkin.execute()

    files_list = checkin.get_file_objects()
    for i, fl in enumerate(files_list):
        fl.set_value(name='st_size', value=file_sizes[i])
        fl.set_value(name='relative_dir', value=version_relative_paths[i])
        fl.commit()

    # update_versionless = False

    if update_versionless:
        # snapshot.update_versionless(snapshot_mode='latest', sobject=sobject, checkin_type='auto')
        versionless_snapshot = snapshot.get_by_sobjects([sobject], context, version=-1)
        if not versionless_snapshot:
            versionless_snapshot = [
                Snapshot.create(sobject, snapshot_type=snapshot_type, context=context, description=description,
                                is_revision=False, is_latest=is_latest, level_type=level_type, level_id=level_id,
                                commit=False, version=-1)]
        if repo_name:
            versionless_snapshot[0].set_value('repo', repo_name)

        # file_objects = versionless_snapshot[0].get_all_file_objects()
        # for file_object in file_objects:
        #     file_object.delete(triggers=False)

        search = Search('sthpw/file')
        search.add_op_filters([('snapshot_code', versionless_snapshot[0].get_code())])
        file_objects = search.get_sobjects()
        for file_object in file_objects:
            file_object.delete(triggers=False)

        versionless_snapshot[0].set_value('snapshot', '<snapshot/>')
        versionless_snapshot[0].set_value('login', snapshot.get_attr_value('login'))
        versionless_snapshot[0].set_value('timestamp', snapshot.get_attr_value('timestamp'))
        versionless_snapshot[0].set_value('description', description)
        versionless_snapshot[0].commit(triggers=True, log_transaction=True)
        #snapshot.update_versionless(snapshot_mode='latest', sobject=sobject, checkin_type='auto')

        checkin_versionless = FileAppendCheckin(versionless_snapshot[0].get_code(), versionless_file_paths, file_types, keep_file_name=keep_file_name, mode=mode,
                                    source_paths=source_paths, dir_naming=dir_naming, file_naming=file_naming,
                                    checkin_type='auto', do_update_versionless=False)
#.........这里部分代码省略.........
开发者ID:listyque,项目名称:TACTIC-Handler,代码行数:103,代码来源:tactic_query.py

示例11: handle_search

# 需要导入模块: from pyasm.search import Search [as 别名]
# 或者: from pyasm.search.Search import add_op_filters [as 别名]
    def handle_search(self):

        parent_key = self.kwargs.get("parent_key")

        # this is an absolute expression
        self.search_expr = self.kwargs.get("search_expr")
        self.search_type = self.kwargs.get("search_type")
        if not self.search_type:
            self.search_type = 'sthpw/task'
        if self.search_expr:
            result = Search.eval(self.search_expr)
            if isinstance(result, list):
                search = Search(self.search_type)
                codes = [x.get_code() for x in result]
                search.add_filters("code", codes)
            else:
                search = result


        else:
            

            self.op_filters = self.kwargs.get("filters")
            if self.op_filters:
                if isinstance(self.op_filters, basestring):
                    self.op_filters = eval(self.op_filters)
            search = Search(self.search_type)
            if self.op_filters:
                search.add_op_filters(self.op_filters)

        self.start_column = self.kwargs.get('start_date_col')
        if not self.start_column:
            self.start_column = 'bid_start_date'

        self.end_column = self.kwargs.get('end_date_col')
        if not self.end_column:
            self.end_column = 'bid_end_date'

       
        if parent_key:
            parent = Search.get_by_search_key(parent_key)
            search.add_parent_filter(parent)

        search.add_op('begin')

        if self.handler:
            self.handler.alter_search(search)

        search.add_op('or')




        self.start_date = datetime(self.year, self.month, 1)
        next_month = self.month+1
        next_year = self.year
        if next_month > 12:
            next_month = 1
            next_year += 1

        self.end_date = datetime(next_year, next_month, 1)
        self.end_date = self.end_date - timedelta(days=1)

        # outer begin
        search.add_op('begin')

        search.add_op('begin')
        search.add_date_range_filter(self.start_column, self.start_date, self.end_date)
        search.add_date_range_filter(self.end_column, self.start_date, self.end_date)
        search.add_op('or')

        search.add_op('begin')
        search.add_filter(self.start_column, self.start_date, op='<=')
        search.add_filter(self.end_column, self.end_date, op='>=')
        search.add_op('and')

        search.add_op('or')

        extra_codes = self.kwargs.get("extra_codes")
        if extra_codes:
            search.add_op('and')
            extra_codes = extra_codes.split("|")
            search.add_filters("code", extra_codes)
            search.add_op('or')


        search.add_order_by(self.start_column)

        self.sobjects = search.get_sobjects()
开发者ID:mincau,项目名称:TACTIC,代码行数:91,代码来源:sobject_calendar_wdg.py


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