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


Python SObject.get_dict方法代码示例

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


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

示例1: preprocess

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
    def preprocess(my):
        search_type_list  = SObject.get_values(my.sobjects, 'search_type', unique=True)
        search_id_dict = {}
        my.ref_sobject_cache = {}

        # initialize the search_id_dict
        for type in search_type_list:
            search_id_dict[type] = []
        # cache it first
        for sobject in my.sobjects:
            search_type = sobject.get_value('search_type')
            search_id_list = search_id_dict.get(search_type)
            search_id_list.append(sobject.get_value('search_id'))

        from pyasm.search import SearchException
        for key, value in search_id_dict.items():
            try:
                ref_sobjects = Search.get_by_id(key, value)
                sobj_dict = SObject.get_dict(ref_sobjects)
            except SearchException, e:
                print "WARNING: search_type [%s] with id [%s] does not exist" % (key, value)
                print str(e)
                sobj_dict = {}

            # store a dict of dict with the search_type as key
            my.ref_sobject_cache[key] = sobj_dict
开发者ID:0-T-0,项目名称:TACTIC,代码行数:28,代码来源:prod_wdg.py

示例2: preprocess

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
    def preprocess(my):
       
        my.is_preprocessed = True
        # get all of the instances

        search = Search("prod/shot_instance")

        # if not used in a TableWdg, only get the shot instances for one asset
        if not my.parent_wdg:
            search.add_filter('asset_code', my.get_current_sobject().get_code())

        search.add_order_by("shot_code")
        instances = search.get_sobjects()

        my.asset_instances = instances

        my.instances = {}
        for instance in instances:
            asset_code = instance.get_value("asset_code")
            
            list = my.instances.get(asset_code)
            if not list:
                list = []
                my.instances[asset_code] = list

            list.append(instance)
       
        search = Search("prod/shot")
        search.add_filters( "code", [x.get_value('shot_code') for x in instances] )
        shots = search.get_sobjects()
        my.shots = SObject.get_dict(shots, ["code"])
        my.shots_list = shots
开发者ID:0-T-0,项目名称:TACTIC,代码行数:34,代码来源:layout_summary_wdg.py

示例3: build_cache_by_column

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
    def build_cache_by_column(self, column):
        # do not build if it already exists
        if self.caches.has_key(column):
            return

        # build a search_key cache
        column_cache = SObject.get_dict(self.sobjects, key_cols=[column])
        self.caches[column] = column_cache
        return column_cache
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:cache.py

示例4: get_info

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
 def get_info(self):
     # check if the sobj type is the same
     search_types = SObject.get_values(self.sobjs, 'search_type', unique=True)
     search_ids = SObject.get_values(self.sobjs, 'search_id', unique=False)
   
     infos = []
     # this doesn't really work if the same asset is submitted multiple times
     if len(search_types) == 1 and len(search_ids) == len(self.sobjs):
         assets = []
         if search_types[0]:
             assets = Search.get_by_id(search_types[0], search_ids)
         
         asset_dict = SObject.get_dict(assets)
         for id in search_ids:
             asset = asset_dict.get(id)
             aux_dict = {}
             aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
             aux_dict['search_key'] = '%s:%s' %(search_types[0], id)
             infos.append(aux_dict)
         
     else:
         # TODO: this is a bit database intensive, mixed search_types not
         # recommended
         search_types = SObject.get_values(self.sobjs, 'search_type',\
             unique=False)
         for idx in xrange(0, len(search_types)):
             search_type = search_types[idx]
                 
             aux_dict = {}
             aux_dict['info'] = ''
             aux_dict['search_key'] = ''
             if search_type:
                 asset = Search.get_by_id(search_type, search_ids[idx])
                 aux_dict['info'] = SubmissionInfo._get_target_sobject_data(asset)
                 aux_dict['search_key'] = '%s:%s' %(search_types[idx], search_ids[idx])
             infos.append(aux_dict)
     return infos
开发者ID:mincau,项目名称:TACTIC,代码行数:39,代码来源:submission_wdg.py

示例5: preprocess

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
    def preprocess(self):
        
        # protect against the case where there is a single sobject that
        # is an insert (often seen in "insert")
        if self.is_preprocessed == True:
            return

        skip = False
        if len(self.sobjects) == 1:
            if not self.sobjects[0].has_value("search_type"):
                skip = True

        if not skip:
            search_types = SObject.get_values(self.sobjects, 'search_type', unique=True)

            try:
                search_codes = SObject.get_values(self.sobjects, 'search_code', unique=True)
                search_ids = None
            except Exception as e:
                print "WARNING: ", e
                search_ids = SObject.get_values(self.sobjects, 'search_id', unique=True)
                search_codes = None
        else:
            search_types = []
            search_codes = []


        # if there is more than one search_type, then go get each parent
        # individually
        # NOTE: this is very slow!!!!
        ref_sobjs = []
        if len(search_types) > 1:
            ref_sobjs = []
            for tmp_sobj in self.sobjects:
                try:
                    ref_sobj = tmp_sobj.get_parent()
                    if ref_sobj:
                        ref_sobjs.append(ref_sobj)
                    else:
                        warning = "Dangling reference: %s" % tmp_sobj.get_search_key()
                        Environment.add_warning(warning, warning)
                except SearchException as e:
                    # skips unknown search_type/project
                    print e.__str__()
                    continue

        elif len(search_types) == 1:
            search_type =  self.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException as e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        self.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if self.get_option('disable') == 'true':
            self.ref_sobj_dict = None
            self.empty = True
  
        self.is_preprocessed = True
开发者ID:mincau,项目名称:TACTIC,代码行数:70,代码来源:group_element_wdg.py

示例6: execute

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
    def execute(my):
        date = Date()
        cur_time = date.get_utc()

        print "Burn down"

        #first = 8 * 60 * 60
        first = 30
        next = 10
       
        # search for all of the tasks that are pending
        search = Search("sthpw/task")
        search.add_filter("status", "Pending")
        sobjects = search.get_sobjects()

        # get the time when this was set to pending
        search = Search("sthpw/status_log")
        search.add_filter("from_status", "Assignment")
        search.add_filter("to_status", "Pending")
        logs = search.get_sobjects()

        logs_dict = SObject.get_dict(logs, ["search_type", "search_id"] )

        # analyze tasks
        ready_sobjects = []

        for sobject in sobjects:
            search_key = sobject.get_search_key()

            
            # get the logs
            log = logs_dict.get(search_key)
            if not log:
                continue

            log_date = Date(db=log.get_value("timestamp"))
            log_time = log_date.get_utc()

            interval = cur_time - log_time


            # if we haven't passed the first marker, then just skip
            if interval < first:
                continue

            # put an upper limit where it doesn't make anymore sense
            if interval > 21*24*60*60:
                continue


            # once we've reached the first marker, email next interval
            start = (interval - first) / next
            print "start: ", interval, first, start

            continue

            parent = sobject.get_parent()
            if not parent:
                print "WARNING: parent does not exist [%s]" % sobject.get_search_key()
                continue

            process = sobject.get_value("process")
            assigned = sobject.get_value("assigned")
            status = sobject.get_value("status")
            code = parent.get_code()

            print (code, assigned, process, status, interval/3600)
            ready_sobjects.append( sobject )





        # TODO: problem how to prevent emails from happening every iteration?

        # this is run every minute, so remember the last time an email has been
        # sent for a particular 
 
        if not ready_sobjects:
            return

        from pyasm.command import Command
        class BurnDownCmd(Command):
            def get_title(my):
                return "Burn Down Command"
            def set_sobjects(my, sobjects):
                my.sobjects = [sobject]
            def execute(my):
                # call email trigger
                from email_trigger import EmailTrigger
                email_trigger = EmailTrigger()
                email_trigger.set_command(my)
                email_trigger.execute()


        # call email trigger
        #cmd = BurnDownCmd()
        #cmd.set_sobjects(ready_sobjects)
        #Command.execute_cmd(cmd)

#.........这里部分代码省略.........
开发者ID:blezek,项目名称:TACTIC,代码行数:103,代码来源:trigger.py

示例7: get_display

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]

#.........这里部分代码省略.........
        checkin_options.add( my.get_handoff_wdg())
       
        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)
      
        
        top.add( my.get_introspect_wdg() )
        top.add(HtmlElement.br(2))
        
        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background','background2') 
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background','background2', -15)
        

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir() )
        else:
            my.add("Current Project: Please press 'Introspect'")


        count = 0
        for i in range(0, len(node_names) ):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                    continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()


            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue
           
            # list items if it is a set
            if asset.get_value('asset_type', no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set( table, instance_name, asset, instance_names)
                count +=1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name, snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)


            count += 1
开发者ID:0-T-0,项目名称:TACTIC,代码行数:104,代码来源:app_sobject_checkin_wdg.py

示例8: len

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
                    continue

        elif len(search_types) == 1:
            search_type =  my.sobjects[0].get_value("search_type")
            try:
                if search_codes != None:
                    ref_sobjs = Search.get_by_code(search_type, search_codes)
                else:
                    ref_sobjs = Search.get_by_id(search_type, search_ids)
            except SearchException, e:
                # skips unknown search_type/project
                print e.__str__()
                pass

        # TODO: None defaults to search_key, should be empty
        my.ref_sobj_dict = SObject.get_dict(ref_sobjs, None)

        # when drawn as part of a TbodyWdg, we want to disable the calculation
        # of most things so that it will not try to display a prev row
        if my.get_option('disable') == 'true':
            my.ref_sobj_dict = None
            my.empty = True
  
        my.is_preprocessed = True

    #def handle_td(my, td):
    #    td.add_class("task_spacer_column")
    #    td.add_style("font-weight: bold")
    #    if my.empty:
    #        td.add_style("border-top: 0px")
开发者ID:0-T-0,项目名称:TACTIC,代码行数:32,代码来源:group_element_wdg.py

示例9: preprocess

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
 def preprocess(my):
     episode_codes = SObject.get_values(my.sobjects, 'episode_code')
     search = Search(NatPause)
     search.add_filters('episode_code', episode_codes)
     net_pauses = search.get_sobjects()
     my.sobject_dict = SObject.get_dict(net_pauses, key_cols=['episode_code'])
开发者ID:0-T-0,项目名称:TACTIC,代码行数:8,代码来源:flash_table_element_wdg.py

示例10: _init_snapshots

# 需要导入模块: from pyasm.search import SObject [as 别名]
# 或者: from pyasm.search.SObject import get_dict [as 别名]
 def _init_snapshots(my):
     '''preselect all of the snapshots'''
     snapshots = Snapshot.get_latest_by_sobjects(my.sobjects)
     my.snapshot_dict = SObject.get_dict(snapshots,\
         key_cols=['search_type','search_id'])
开发者ID:0-T-0,项目名称:TACTIC,代码行数:7,代码来源:flash_snapshot_wdg.py


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