• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.Date类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_display

    def get_display(my):
        last_week = 52
        if my.kwargs.get('show_future') == 'false':
            today = Date()
            last_week = int(today.get_week())

        weeks = [i for i in xrange(1, last_week + 1)]
        weeks.reverse()
        my.set_option('values', weeks)
        return super(WeekSelectWdg, my).get_display()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:prod_input_wdg.py


示例2: get_display

    def get_display(my):
        filter_data = FilterData.get_from_cgi()
        values = filter_data.get_values("custom", "year")

        year = 0
        for value in values:
            if value:
                try:
                    year = int(value)
                except:
                    pass
        if not year:
            date = Date()
            year = int(date.get_year())

        sobject = my.get_current_sobject()
        id = sobject.get_id()

        column = my.get_option("column")
        month = int( my.get_option('month') )

        end_year = year
        end_month = month + 1
        if end_month > 12:
            end_month = 1
            end_year += 1



        search_type = 'MMS/personal_time_log'

        if year:

            search = Search(search_type)
            search.add_filter('login_id', id)
            search.add_filter('work_performed_date', '%s-%0.2d-01' % (year,month), '>')
            search.add_filter('work_performed_date', '%s-%0.2d-01' % (end_year,end_month), '<')

            sobjects = search.get_sobjects()
        else:
            sobjects = []


        if sobjects:
            parser = ExpressionParser()
            sum = parser.eval("@SUM(%s.%s)" % (search_type,column),sobjects=sobjects)
        else:
            sum = 0

        div = DivWdg()
        div.add(sum)
        return div
开发者ID:0-T-0,项目名称:TACTIC,代码行数:52,代码来源:yearly_report_wdg.py


示例3: get_display

    def get_display(my):
        value = my.get_value()
        name = my.get_name()

        type = my.get_option("type")
        if not type:
            type = my.get_type()

        # FIXME: this needs to be handled outside of this class to centralize
        # the type of an element!!!
        if type in ["timestamp"]:
            # make a guess here
            if name.endswith('time'):
                type = 'time'
            elif name.endswith('date'):
                type = 'date'

        if type == "text":
            wiki = WikiUtil()
            display = wiki.convert(value)

        elif type in ["time"]:
            if value:
                display = Date(value).get_display_time()
            else:
                display = ''

        elif type in ["datetime"]:
            if value:
                display = Date(value).get_display_datetime()
            else:
                display = ''

        elif type in ["timestamp", 'date']:
            if value == '{now}':
                display = Date()
            elif value:
                display = Date(value).get_display_date()
            else:
                display = ''
        elif type == "timecode":
            display = "00:00:00:00"
        elif type == "currency":
            display = "$%s" % value


        elif type == "color":
            display = DivWdg()

            color = DivWdg("&nbsp")
            color.add_style("height: 15px")
            color.add_style("width: 15px")
            color.add_style("float: left")
            color.add_style("margin: 0 5px 0 5px")
            color.add_style("background: %s" % value)
            display.add(color)

            display.add(value)

            display.add_style("width: 100%")
            display.add_style("height: 100%")

        elif type == "boolean":
            display = DivWdg()
            display.add_style("text-align: center")
            display.add_style("width: 100%")
            display.add_style("height: 100%")
            if value == True:
                from pyasm.widget import IconWdg
                icon = IconWdg("True", IconWdg.CHECK)
                display.add(icon)
            elif value == False:
                from pyasm.widget import IconWdg
                icon = IconWdg("False", IconWdg.INVALID)
                display.add(icon)
            else:
                display.add("&nbsp;")
        else:
            if not isinstance(value, basestring):
                display = DivWdg()
                display.add_style("float: right")
                display.add_style("padding-right: 3px")
                display.add(str(value))
            else:
                display = value

        return display
开发者ID:funic,项目名称:TACTIC,代码行数:87,代码来源:table_element_wdg.py


示例4: get_message

    def get_message(my):
        search_type_obj = my.parent.get_search_type_obj()
        title = search_type_obj.get_title()
        subject = my.get_subject()
        notification_message = my.notification.get_value("message")

        message = "%s %s Note Entry" % (title, my.parent.get_name())
        if notification_message:
            message = "%s (%s)" %(message, notification_message)

        submit_desc = ''

        from pyasm.prod.biz import Submission
        if isinstance(my.parent, Submission):
            update_info = ['']
            # add more info about the file and bin
            snapshot = Snapshot.get_latest_by_sobject(my.parent, "publish")
            xpath = "snapshot/file[@type='main']"
            xml = snapshot.get_xml_value('snapshot')
            file = None
            if xml.get_node(xpath) is not None:
                file = my._get_file_obj(snapshot)
            else:
                snapshots = snapshot.get_all_ref_snapshots()
                snapshot_file_objects = []
                if snapshots:
                    snapshot = snapshots[0]
                    file = my._get_file_obj(snapshot, type=None)
            if file:
                file_name = file.get_file_name()
                web_path = file.get_web_path()
                from pyasm.web import WebContainer 
                host = WebContainer.get_web().get_base_url()
                update_info.append('Browse: %s %s%s' %( file_name, host.to_string(), web_path))

            bins = my.parent.get_bins()
            bin_labels = [ bin.get_label() for bin in bins]
            update_info.append('Bin: %s' %', '.join(bin_labels))

            update_info.append('Artist: %s' %my.parent.get_value('artist'))
            update_info.append('Description: %s' %my.parent.get_value('description'))
             
            # get notes
            search = Note.get_search_by_sobjects([my.parent])
            if search:
                search.add_order_by("context")
                search.add_order_by("timestamp desc")
            notes = search.get_sobjects()

            last_context = None
            note_list = []
            for i, note in enumerate(notes):
                context = note.get_value('context')
                # explicit compare to None
                if last_context == None or context != last_context:
                    note_list.append( "[ %s ] " % context )
                last_context = context
                
                #child_notes = my.notes_dict.get(note.get_id())
                # draw note item
                date = Date(db=note.get_value('timestamp'))
                note_list.append('(%s) %s'%(date.get_display_time(), note.get_value("note")))
            update_info.append('Notes: \n %s' % '\n'.join(note_list))

            submit_desc =  '\n'.join(update_info)

            
        update_desc = my.sobject.get_update_description()
        command_desc = my.command.get_description()

        message = '%s\n\nReport from transaction:\n%s\n\n%s\n%s' \
            % (message, update_desc, command_desc, submit_desc)
        return message
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:73,代码来源:email_handler.py


示例5: add_initial_tasks

    def add_initial_tasks(sobject, pipeline_code=None, processes=[], contexts=[], skip_duplicate=True, mode='standard',start_offset=0):
        '''add initial tasks based on the pipeline of the sobject'''
        from pipeline import Pipeline

        def _get_context(existing_task_dict, process_name, context=None):
            existed = False
            if not existing_task_dict:
                if context:
                    context = context
                else:
                    context = process_name
            else:

                compare_key = "%s:%s" %(process_name, context)
                max_num = 0
                for item in existing_task_dict.keys():
                    item_stripped = re.sub('/\d+$', '', item)
                    
                    #if item.startswith(compare_key):
                    if item_stripped == compare_key:
                        existing_context = item.replace('%s:'%process_name,'')
                        suffix = existing_context.split('/')[-1]
                        try:    
                            num = int(suffix)
                        except:
                            num = 0
                          
                        if num > max_num:
                            max_num = num

                        existed = True
            
         
                if existed:
                    context = "%s/%0.3d" % (context, max_num+1)
            

            return context
        # get pipeline
        if not pipeline_code:
            pipeline_code = sobject.get_value("pipeline_code")

        if pipeline_code in ['', '__default__']:
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "__default__")
            pipeline.set_value("pipeline", '''
<pipeline>
    <process name='publish'/>
</pipeline>
            ''')
            # FIXME: HACK to initialize virtual pipeline
            pipeline.set_pipeline(pipeline.get_value("pipeline"))
 

        else:
            pipeline = Pipeline.get_by_code(pipeline_code)

        if not pipeline:
            print "WARNING: pipeline '%s' does not exist" %  pipeline_code
            return []

        #TODO: add recursive property here 
        if processes:
            process_names = processes
        else:
            process_names = pipeline.get_process_names(recurse=True)


        # remember which ones already exist
        existing_tasks = Task.get_by_sobject(sobject, order=False)
    
        existing_task_dict = {}
        for x in existing_tasks:
            key1 = '%s:%s' %(x.get_value('process'),x.get_value("context"))
            existing_task_dict[key1] = True
            # for backward compatibility, if the process has been created, we will skip later below
            # we may remove this in the future
            #key2 = '%s' %(x.get_value('process'))
            #existing_task_dict[key2] = True

        # create all of the tasks
        description = ""
        tasks = []

        start_date = Date()
        start_date.add_days(start_offset)
        
        bid_duration_unit = ProdSetting.get_value_by_key("bid_duration_unit")
        if not bid_duration_unit:
            bid_duration_unit = 'hour'

        # that's the date range in 5 days (not hours)
        default_duration = 5
        default_bid_duration = 8
        if bid_duration_unit == 'minute':
            default_bid_duration = 60
        last_task = None

        # this is the explicit mode for creating task for a specific process:context combo
        if mode=='context':
#.........这里部分代码省略.........
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:101,代码来源:task.py


示例6: update_dependent_tasks

    def update_dependent_tasks(my, top=True):
        '''for purposes of dependent tasks'''
        if top:
            Task.tasks_updated = []
            Task.tasks_updated.append(my.get_id())

        # get the dependent tasks
        tasks = my.get_dependent_tasks()

        bid_start_date = my.get_value("bid_start_date")
        bid_end_date = my.get_value("bid_end_date")

        bid_duration_unit = ProdSetting.get_value_by_key("bid_duration_unit")
        if not bid_duration_unit:
            bid_duration_unit = 'hour'

        # if there is no end date specified, return
        if not bid_end_date:
            bid_duration = my.get_value("bid_duration")
            if bid_duration and bid_start_date:
                date = Date(db=bid_start_date)
                bid_duration = float(bid_duration)
                if bid_duration_unit == 'minute':
                    date.add_minutes(bid_duration)
                else:
                    date.add_hours(bid_duration)
                bid_end_date = date.get_db_time()
            else:
                return



        for task in tasks:

            # prevent circular dependency if for some reason they occur.
            if task.get_id() in Task.tasks_updated:
                Environment.add_warning("Circular dependency", "Circular dependency with task '%s'" % task.get_id() )
                continue


            Task.tasks_updated.append(my.get_id())

            # if the dependency is fixed, update the d
            #mode = task.get_value("mode")
            mode = "depend"

            # put the start date as the end date
            if mode == "depend":

                # add one day to the end date to get the start date
                date = Date(db=bid_end_date)
                date.add_days(1)
                bid_start_date = date.get_db_time()
                task.set_value("bid_start_date", bid_start_date )

                # check if there is a duration in hours to this date
                bid_duration = task.get_value("bid_duration")
                if bid_duration:
                    bid_duration = int(bid_duration)

                    date = Date(db=bid_start_date)
                    if bid_duration_unit == 'minute':
                        date.add_minutes(bid_duration)
                    else:
                        date.add_hours(bid_duration)
                    
                    bid_end_date = date.get_db_time()

                    task.set_value("bid_end_date", bid_end_date)


                task.commit()

                task.update_dependent_tasks(False)
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:74,代码来源:task.py


示例7: get_display

    def get_display(self):
        web = WebContainer.get_web()
        
        widget = Widget() 

        if not self.search_type:
            self.search_type = self.options.get("search_type")
        assert self.search_type


        sobject_filter = self.sobject_filter

        web_state = WebState.get()
        web_state.add_state("ref_search_type", self.search_type)

        div = FilterboxWdg()
        widget.add(div)


        # add the sobject filter
        if self.sobject_filter:
            div.add(self.sobject_filter)
      
        # add a milestone filter
        milestone_filter = FilterSelectWdg("milestone_filter", label="Milestone: ")
        milestones = Search("sthpw/milestone").get_sobjects()
        milestone_filter.set_sobjects_for_options(milestones, "code", "code")
        milestone_filter.add_empty_option(label='-- Any Milestones --')
        milestone_filter.set_submit_onchange(False)
        milestone = milestone_filter.get_value()
        
    
        div.add_advanced_filter(milestone_filter)

        # add a process filter
        process_filter = ProcessFilterSelectWdg(name=self.process_filter_name, label='Process: ')
        process_filter.set_search_type(self.search_type)
        process_filter.set_submit_onchange(False)
        
        div.add_advanced_filter(process_filter)


        user_filter = None
        user = Environment.get_user_name()
        # it has a special colunn 'assigned'
        if not UserFilterWdg.has_restriction():
            user_filter = UserFilterWdg() 
            user_filter.set_search_column('assigned')
            user = user_filter.get_value()
            div.add_advanced_filter(user_filter)

        
        # add a task properties search
        search_columns = ['status', 'description']
        task_search_filter = SearchFilterWdg(name='task_prop_search', \
                columns=search_columns, label='Task Search: ')
        div.add_advanced_filter(task_search_filter)

        # add a retired filter
        retired_filter = RetiredFilterWdg()
        div.add_advanced_filter(retired_filter)

        # set a limit to only see set amount of sobjects at a time
        search_limit = SearchLimitWdg()
        search_limit.set_limit(50)
        search_limit.set_style(SearchLimitWdg.LESS_DETAIL)
        div.add_bottom(search_limit)
        
        div.add_advanced_filter(HtmlElement.br(2))
        start_date_wdg = CalendarInputWdg("start_date_filter", label="From: ", css='med')
        start_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(start_date_wdg)

        start_date = start_date_wdg.get_value()

        # these dates are actually used for search filtering
        processed_start_date = None
        processed_end_date = None
        if start_date:
            date = Date(db_date=start_date)
            # this guarantees a valid date( today ) is invalid input is detected
            processed_start_date = date.get_db_date()
            if start_date != processed_start_date:
                start_date_wdg.set_value(self.INVALID)
        # add hints
        hint = HintWdg("The 'From' and 'To' dates apply to bid dates.")
        #span.add(hint)
        
        end_date_wdg = CalendarInputWdg("end_date_filter", label="To: ", css='med')
        end_date_wdg.set_persist_on_submit()
        div.add_advanced_filter(end_date_wdg)
        div.add_advanced_filter(hint)

        end_date = end_date_wdg.get_value()
        if end_date:
            date = Date(db_date=end_date)
            processed_end_date = date.get_db_date()
            if end_date != processed_end_date:
                end_date_wdg.set_value(self.INVALID)
      
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:101,代码来源:task_manager_wdg.py


示例8: _get_bar

    def _get_bar(my, percent, proc_count, task):
        '''get a vertical bar indicating the progress of a task '''
        sobject = my.get_current_sobject()
        bar = DivWdg()
        if my.desc_checkbox_value == "on":
            bar.add_style('margin-right: 20px')
        else:
            bar.add_style('width: 10px')
        bar.add_style('float: left')
        cur_percent = 100.0
        increment = 100.0 / proc_count
        
        # get some task info
        assigned = 'unassigned'
        process = task.get_value('process')
        if task.get_value('assigned').strip():
            assigned = task.get_value('assigned')
            
        task_desc = task.get_value('description')
        if not task_desc:
            task_desc = 'n/a'

        start_date = task.get_value("bid_start_date")
        end_date = task.get_value("bid_end_date")
        if start_date:
            start_date = Date(db_date=start_date, show_warning=False).get_display_date()
        else:
            start_date = "?"
        if end_date:
            end_date = Date(db_date=end_date, show_warning=False).get_display_date()
        else:
            end_date = "?"

        # remove some spacing characters
        task_desc = re.sub('(\n|\r|\t)', ' ', task_desc)
        task_desc = re.sub('"', "'", task_desc)
        task_status = task.get_value('status')

        display_percent = percent
        if percent < 0:
            task_status = "%s <font color=red>(obsolete)</font>" % task_status
            display_percent = 0
      
        msg =  '<b>%s</b><br/><hr>%s<br/><span style=padding-left:1em>desc: %s</span><br/>' \
            '<span style=padding-left:1em>status:%s (%s%%)</span><br/>'\
            '<span style=padding-left:1em>%s - %s</span>'\
            % (process, assigned, task_desc, task_status, display_percent, start_date, end_date)
       
        if WebContainer.get_web().get_browser() == "IE":
            bar.add_event('onmouseover', "hint_bubble.show(event, '%s')" %msg)
        else:
            bar.add_tip(msg)



        from pyasm.widget import IconWdg
        end_date = task.get_value("bid_end_date")
        end_date = Date(db_date=end_date, show_warning=False)
        now_date = Date(show_warning=False)
        if now_date.get_utc() > end_date.get_utc() and percent != 100:
            alert_color = "#f00"
        else:
            alert_color = None


        for x in xrange(proc_count):
            cur_percent -= increment
            div = DivWdg()
            content = '&nbsp;'
            # unidentified status probably
            if percent < 0:
                content = '&mdash;'
                div.add_style('text-decoration: blink')
        
            div.add(content)
            div.add_style('width: 10px')
            if cur_percent < percent or cur_percent == 0:
                if alert_color:
                    div.add_style("background-color: %s" % alert_color)
                else:
                    div.add_style("background-color: %s" % my._get_color_code(percent))


            bar_height = my.get_option("bar_height")
            if not bar_height:
                bar_height = my.bar_select_value
            if not bar_height:
                bar_height = '3'
            div.add_style("height: %spx" % bar_height)
            # IE needs to set the font size to reduce the overall size
            div.add_style("font-size: %spx" % bar_height )
            if sobject.is_retired():
                div.add_class('task_status_bar_retired')
            else:
                if my.label_select_value == "abbr":
                    div.add_style("margin: -1px")

                #div.add_class("task_status_bar")
                #div.add_style("margin-top: 2px")
                div.add_border()
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:parallel_status.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.Environment类代码示例发布时间:2022-05-25
下一篇:
Python common.Container类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap