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


Python datefmt.user_time函数代码示例

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


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

示例1: get_list_pages

def get_list_pages(request, dbp, obj, resource):
    require_permission(request.req, resource, dbp.env)

    artifact_id = request.req.args.get('artifact', None)
    if artifact_id is None:
        raise Exception("No artifact was specified.")
    dbp.load_artifact(artifact_id)
    artifact = dbp.pool.get_item(artifact_id)

    results = []
    for pagename, page_version_id, ref_count in dbp.get_wiki_page_ref_counts(artifact):
        page = WikiPage(dbp.env, pagename)

        results.append(
            {'href': get_resource_url(dbp.env, page.resource, request.req.href),
             'title': pagename,
             'date': user_time(request.req, format_datetime, page.time),
             'author': page.author,
             'excerpt': shorten_result(page.text)}
        )

    data = {
        'context': Context.from_request(request.req, resource),
        'artifact': artifact,
        'results': results,
    }
    return 'list_pages.html', data, None
开发者ID:filipefigcorreia,项目名称:TracAdaptiveSoftwareArtifacts,代码行数:27,代码来源:views.py

示例2: send_project_index

def send_project_index(environ, start_response, parent_dir=None,
                       env_paths=None):
    req = Request(environ, start_response)

    loadpaths = [pkg_resources.resource_filename('trac', 'templates')]
    if req.environ.get('trac.env_index_template'):
        env_index_template = req.environ['trac.env_index_template']
        tmpl_path, template = os.path.split(env_index_template)
        loadpaths.insert(0, tmpl_path)
    else:
        template = 'index.html'

    data = {'trac': {'version': TRAC_VERSION,
                     'time': user_time(req, format_datetime)},
            'req': req}
    if req.environ.get('trac.template_vars'):
        for pair in req.environ['trac.template_vars'].split(','):
            key, val = pair.split('=')
            data[key] = val
    try:
        href = Href(req.base_path)
        projects = []
        for env_name, env_path in get_environments(environ).items():
            try:
                env = open_environment(env_path,
                                       use_cache=not environ['wsgi.run_once'])
                proj = {
                    'env': env,
                    'name': env.project_name,
                    'description': env.project_description,
                    'href': href(env_name)
                }
            except Exception as e:
                proj = {'name': env_name, 'description': to_unicode(e)}
            projects.append(proj)
        projects.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))

        data['projects'] = projects

        loader = TemplateLoader(loadpaths, variable_lookup='lenient',
                                default_encoding='utf-8')
        tmpl = loader.load(template)
        stream = tmpl.generate(**data)
        if template.endswith('.xml'):
            output = stream.render('xml')
            req.send(output, 'text/xml')
        else:
            output = stream.render('xhtml', doctype=DocType.XHTML_STRICT,
                                   encoding='utf-8')
            req.send(output, 'text/html')

    except RequestDone:
        pass
开发者ID:pkdevbox,项目名称:trac,代码行数:53,代码来源:main.py

示例3: _render_link

 def _render_link(self, context, name, label, extra=''):
     if not (name or extra):
         return tag()
     try:
         milestone = Milestone(self.env, name)
     except ResourceNotFound:
         milestone = None
     # Note: the above should really not be needed, `Milestone.exists`
     # should simply be false if the milestone doesn't exist in the db
     # (related to #4130)
     href = context.href.milestone(name)
     if milestone and milestone.exists:
         if 'MILESTONE_VIEW' in context.perm(milestone.resource):
             title = None
             if hasattr(context, 'req'):
                 if milestone.is_completed:
                     title = _(
                         'Completed %(duration)s ago (%(date)s)',
                         duration=pretty_timedelta(milestone.completed),
                         date=user_time(context.req, format_datetime,
                                        milestone.completed))
                 elif milestone.is_late:
                     title = _('%(duration)s late (%(date)s)',
                               duration=pretty_timedelta(milestone.due),
                               date=user_time(context.req, format_datetime,
                                              milestone.due))
                 elif milestone.due:
                     title = _('Due in %(duration)s (%(date)s)',
                               duration=pretty_timedelta(milestone.due),
                               date=user_time(context.req, format_datetime,
                                              milestone.due))
                 else:
                     title = _('No date set')
             closed = 'closed ' if milestone.is_completed else ''
             return tag.a(label, class_='%smilestone' % closed,
                          href=href + extra, title=title)
     elif 'MILESTONE_CREATE' in context.perm(self.realm, name):
         return tag.a(label, class_='missing milestone', href=href + extra,
                      rel='nofollow')
     return tag.a(label, class_='missing milestone')
开发者ID:spsoft-RockWang,项目名称:project-_trac,代码行数:40,代码来源:roadmap.py

示例4: expand_macro

    def expand_macro(self, formatter, name, content):
        args, kw = parse_args(content)
        prefix = args[0].strip() if args else None
        limit = int(args[1].strip()) if len(args) > 1 else None
        group = kw.get('group', 'date')

        sql = """SELECT name, max(version) AS max_version,
                        max(time) AS max_time FROM wiki"""
        args = []
        if prefix:
            with self.env.db_query as db:
                sql += " WHERE name %s" % db.prefix_match()
                args.append(db.prefix_match_value(prefix))
        sql += " GROUP BY name ORDER BY max_time DESC"
        if limit:
            sql += " LIMIT %s"
            args.append(limit)

        entries_per_date = []
        prevdate = None
        for name, version, ts in self.env.db_query(sql, args):
            if not 'WIKI_VIEW' in formatter.perm('wiki', name, version):
                continue
            req = formatter.req
            date = user_time(req, format_date, from_utimestamp(ts))
            if date != prevdate:
                prevdate = date
                entries_per_date.append((date, []))
            version = int(version)
            diff_href = None
            if version > 1:
                diff_href = formatter.href.wiki(name, action='diff',
                                                version=version)
            page_name = formatter.wiki.format_page_name(name)
            entries_per_date[-1][1].append((page_name, name, version,
                                            diff_href))

        items_per_date = (
            (date, (tag.li(tag.a(page, href=formatter.href.wiki(name)),
                           tag.small(' (', tag.a(_("diff"), href=diff_href),
                                     ')') if diff_href else None,
                           '\n')
                    for page, name, version, diff_href in entries))
            for date, entries in entries_per_date)

        if group == 'date':
            out = ((tag.h3(date), tag.ul(entries))
                   for date, entries in items_per_date)
        else:
            out = tag.ul(entries for date, entries in items_per_date)
        return tag.div(out)
开发者ID:exocad,项目名称:exotrac,代码行数:51,代码来源:macros.py

示例5: pretty_dateinfo

 def pretty_dateinfo(date, format=None, dateonly=False):
     absolute = user_time(req, format_datetime, date)
     relative = pretty_timedelta(date)
     if not format:
         format = req.session.get('dateinfo',
                      Chrome(self.env).default_dateinfo_format)
     if format == 'absolute':
         if dateonly:
             label = absolute
         elif req.lc_time == 'iso8601':
             label = _("at %(iso8601)s", iso8601=absolute)
         else:
             label = _("on %(date)s at %(time)s",
                       date=user_time(req, format_date, date),
                       time=user_time(req, format_time, date))
         title = _("See timeline %(relativetime)s ago",
                   relativetime=relative)
     else:
         label = _("%(relativetime)s ago", relativetime=relative) \
                 if not dateonly else relative
         title = _("See timeline at %(absolutetime)s",
                   absolutetime=absolute)
     return self.get_timeline_link(req, date, label,
                                   precision='second', title=title)
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:24,代码来源:web_ui.py

示例6: expand_macro

    def expand_macro(self, formatter, name, content):
        prefix = limit = None
        if content:
            argv = [arg.strip() for arg in content.split(',')]
            if len(argv) > 0:
                prefix = argv[0]
                if len(argv) > 1:
                    limit = int(argv[1])

        sql = """SELECT name, max(version) AS max_version, 
                        max(time) AS max_time FROM wiki"""
        args = []
        if prefix:
            sql += " WHERE name LIKE %s"
            args.append(prefix + '%')
        sql += " GROUP BY name ORDER BY max_time DESC"
        if limit:
            sql += " LIMIT %s"
            args.append(limit)

        entries_per_date = []
        prevdate = None
        for name, version, ts in self.env.db_query(sql, args):
            if not 'WIKI_VIEW' in formatter.perm('wiki', name, version):
                continue
            req = formatter.req
            date = user_time(req, format_date, from_utimestamp(ts))
            if date != prevdate:
                prevdate = date
                entries_per_date.append((date, []))
            version = int(version)
            diff_href = None
            if version > 1:
                diff_href = formatter.href.wiki(name, action='diff',
                                                version=version)
            page_name = formatter.wiki.format_page_name(name)
            entries_per_date[-1][1].append((page_name, name, version,
                                            diff_href))
        return tag.div(
            (tag.h3(date),
             tag.ul(
                 tag.li(tag.a(page, href=formatter.href.wiki(name)), ' ',
                        diff_href and
                        tag.small('(', tag.a('diff', href=diff_href), ')') or
                        None)
                 for page, name, version, diff_href in entries))
            for date, entries in entries_per_date)
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:47,代码来源:macros.py

示例7: _process_doc

    def _process_doc(self, doc):
        ui_doc = dict(doc)
        if doc['product']:
            product_href = ProductEnvironment(self.env, doc['product']).href
            # pylint: disable=too-many-function-args
            ui_doc["href"] = product_href(doc['type'], doc['id'])
        else:
            ui_doc["href"] = self.req.href(doc['type'], doc['id'])

        if doc['content']:
            ui_doc['content'] = shorten_result(doc['content'])

        if doc['time']:
            ui_doc['date'] = user_time(self.req, format_datetime, doc['time'])

        is_free_text_view = self.view is None
        if is_free_text_view:
            participant = self.allowed_participants[doc['type']]
            ui_doc['title'] = participant.format_search_results(doc)
        return ui_doc
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:20,代码来源:web_ui.py

示例8: _prepare_results

    def _prepare_results(self, req, filters, results):
        page = int(req.args.get('page', '1'))
        results = Paginator(results, page - 1, self.RESULTS_PER_PAGE)
        for idx, result in enumerate(results):
            results[idx] = {'href': result[0], 'title': result[1],
                            'date': user_time(req, format_datetime, result[2]),
                            'author': result[3], 'excerpt': result[4]}

        pagedata = []
        shown_pages = results.get_shown_pages(21)
        for shown_page in shown_pages:
            page_href = req.href.search([(f, 'on') for f in filters],
                                        q=req.args.get('q'),
                                        page=shown_page, noquickjump=1)
            pagedata.append([page_href, None, str(shown_page),
                             'page ' + str(shown_page)])

        fields = ['href', 'class', 'string', 'title']
        results.shown_pages = [dict(zip(fields, p)) for p in pagedata]

        results.current_page = {'href': None, 'class': 'current',
                                'string': str(results.page + 1),
                                'title':None}

        if results.has_next_page:
            next_href = req.href.search(zip(filters, ['on'] * len(filters)),
                                        q=req.args.get('q'), page=page + 1,
                                        noquickjump=1)
            add_link(req, 'next', next_href, _('Next Page'))

        if results.has_previous_page:
            prev_href = req.href.search(zip(filters, ['on'] * len(filters)),
                                        q=req.args.get('q'), page=page - 1,
                                        noquickjump=1)
            add_link(req, 'prev', prev_href, _('Previous Page'))

        page_href = req.href.search(
            zip(filters, ['on'] * len(filters)), q=req.args.get('q'),
            noquickjump=1)
        return {'results': results, 'page_href': page_href}
开发者ID:thimalk,项目名称:bloodhound,代码行数:40,代码来源:web_ui.py

示例9: render_admin_panel

    def render_admin_panel(self, req, cat, page, path_info):
        assert req.perm.has_permission('TRAC_ADMIN')

        action = req.args.get('action', 'view')
        if req.method == 'POST':
            confirm = req.args.get('confirm', 0)
            if 'purge_threshold' in req.args:
                purge_threshold_str = req.args.get('purge_threshold', '')
                purge_threshold = user_time(req, parse_date, purge_threshold_str, hint='datetime') \
                                if purge_threshold_str else None
            else:
                purge_threshold = None

            if not confirm:
                self.log.debug('render_admin_panel purge not yet confirmed')
                if purge_threshold is not None:
                    crashes = CrashDump.query_old_data(self.env, purge_threshold)
                data = {
                    'datetime_hint': get_datetime_format_hint(req.lc_time),
                    'purge_threshold': purge_threshold_str,
                    'purge_crashes': crashes
                }
                return 'crashdump_admin_%s.html' % page, data
            elif confirm == 'no':
                self.log.debug('render_admin_panel purge canceled')
                req.redirect(req.href.admin(cat, page))
            elif confirm == 'yes':
                self.log.debug('render_admin_panel purge confirmed')
                req.redirect(req.href.admin(cat, page))
        else:
            now = datetime.now(req.tz)

            purge_threshold = datetime(now.year, now.month, now.day, 0)
            purge_threshold -= timedelta(days=365)
            data = {
                'datetime_hint': get_datetime_format_hint(req.lc_time),
                'purge_threshold': purge_threshold,
            }
            return 'crashdump_admin_%s.html' % page, data
开发者ID:aroth-arsoft,项目名称:trac-crashdump,代码行数:39,代码来源:web_ui.py

示例10: _prepare_results

    def _prepare_results(self, req, filters, results):
        page = int(req.args.get("page", "1"))
        results = Paginator(results, page - 1, self.RESULTS_PER_PAGE)
        for idx, result in enumerate(results):
            results[idx] = {
                "href": result[0],
                "title": result[1],
                "date": user_time(req, format_datetime, result[2]),
                "author": result[3],
                "excerpt": result[4],
            }

        pagedata = []
        shown_pages = results.get_shown_pages(21)
        for shown_page in shown_pages:
            page_href = req.href.search(
                [(f, "on") for f in filters], q=req.args.get("q"), page=shown_page, noquickjump=1
            )
            pagedata.append([page_href, None, str(shown_page), _("Page %(num)d", num=shown_page)])

        fields = ["href", "class", "string", "title"]
        results.shown_pages = [dict(zip(fields, p)) for p in pagedata]

        results.current_page = {"href": None, "class": "current", "string": str(results.page + 1), "title": None}

        if results.has_next_page:
            next_href = req.href.search(
                zip(filters, ["on"] * len(filters)), q=req.args.get("q"), page=page + 1, noquickjump=1
            )
            add_link(req, "next", next_href, _("Next Page"))

        if results.has_previous_page:
            prev_href = req.href.search(
                zip(filters, ["on"] * len(filters)), q=req.args.get("q"), page=page - 1, noquickjump=1
            )
            add_link(req, "prev", prev_href, _("Previous Page"))

        page_href = req.href.search(zip(filters, ["on"] * len(filters)), q=req.args.get("q"), noquickjump=1)
        return {"results": results, "page_href": page_href}
开发者ID:exocad,项目名称:exotrac,代码行数:39,代码来源:web_ui.py

示例11: process_request

    def process_request(self, req):
        req.perm.assert_permission('TIMELINE_VIEW')

        format = req.args.get('format')
        maxrows = int(req.args.get('max', 50 if format == 'rss' else 0))
        lastvisit = int(req.session.get('timeline.lastvisit', '0'))

        # indication of new events is unchanged when form is updated by user
        revisit = any(a in req.args for a in ['update', 'from', 'daysback',
                                              'author'])
        if revisit:
            lastvisit = int(req.session.get('timeline.nextlastvisit',
                                            lastvisit))

        # Parse the from date and adjust the timestamp to the last second of
        # the day
        fromdate = today = datetime.now(req.tz)
        yesterday = to_datetime(today.replace(tzinfo=None) - timedelta(days=1),
                                req.tz)
        precisedate = precision = None
        if 'from' in req.args:
            # Acquire from date only from non-blank input
            reqfromdate = req.args['from'].strip()
            if reqfromdate:
                try:
                    precisedate = user_time(req, parse_date, reqfromdate)
                except TracError, e:
                    add_warning(req, e)
                else:
                    fromdate = precisedate.astimezone(req.tz)
            precision = req.args.get('precision', '')
            if precision.startswith('second'):
                precision = timedelta(seconds=1)
            elif precision.startswith('minute'):
                precision = timedelta(minutes=1)
            elif precision.startswith('hour'):
                precision = timedelta(hours=1)
            else:
                precision = None
开发者ID:exocad,项目名称:exotrac,代码行数:39,代码来源:web_ui.py

示例12: post_list_search_relatedpages_json

def post_list_search_relatedpages_json(request, dbp, obj, resource):
    require_permission(request.req, resource, dbp.env)

    unparsed_spec = request.req.args.get('spec', '')
    spec_name = json.loads(unparsed_spec) if unparsed_spec else ''
    attributes = json.loads(request.req.args.get('attributes', '[]'))

    if attributes is None:
        raise Exception("No artifacts specified.")

    artifacts_array = []

    for artifact in attributes:
        try:
            dbp.load_artifact(artifact)
            full_artifact = dbp.pool.get_item(artifact)
            #artifacts_array.append(full_artifact)
            results = []
            for pagename, page_version_id, ref_count in dbp.get_wiki_page_ref_counts(full_artifact):
                page = WikiPage(dbp.env, pagename)

                results.append(
                    {'href': get_resource_url(dbp.env, page.resource, request.req.href),
                     'title': pagename,
                     'date': user_time(request.req, format_datetime, page.time),
                     'author': page.author,
                     'excerpt': shorten_result(page.text)}
                )

            artifacts_array.append(
                {'id': full_artifact.get_id(),
                 'href': request.req.href.customartifacts('artifact', full_artifact.get_id(), action='view'),
                 'title': unicode(full_artifact),
                 'results' : results})
        except ValueError:
            continue
    _return_as_json(request, artifacts_array)
    return
开发者ID:filipefigcorreia,项目名称:TracAdaptiveSoftwareArtifacts,代码行数:38,代码来源:views.py

示例13: process_request

    def process_request(self, req):
        """Process the request
        """
        base = self.get_mypage_base(req.authname)
        tzinfo = getattr(req, 'tz', None)
        now = datetime.now(tzinfo or localtz)
        today = format_date(now, 'iso8601', tzinfo)
        today_page_name = base + today
        today_page = WikiPage(self.env, today_page_name)
        if today_page.exists:
            req.redirect(req.href.wiki(today_page_name, action='edit'))

        # create page of the day for today
        if 'WIKI_CREATE' not in req.perm(today_page.resource):
            raise ResourceNotFound(_("Can't create the page of the day."))
        ws = WikiSystem(self.env)
        def get_page_text(pagename):
            if ws.has_page(pagename):
                page = WikiPage(self.env, pagename)
                if 'WIKI_VIEW' in req.perm(page.resource):
                    self.log.debug("get_page_text(%s) -> %s",
                                   pagename, page.text)
                    return page.text
            self.log.debug("get_page_text(%s) -> None", pagename)

        # retrieve page template
        template_name = 'PageTemplates/MyPage'
        mytemplate_name = '/'.join([template_name, req.authname])
        template_text = get_page_text(mytemplate_name)
        if template_text is None:
            template_text = get_page_text(template_name)

        text = last_page_text = last_page_quoted = None
        if template_text is not None:
            # retrieve previous "page of the day", if any
            all_mypages = self.get_all_mypages(base)
            last = bisect(all_mypages, today_page_name) - 1
            self.log.debug("Pos of today %s in %r is %d",
                           today_page_name, all_mypages, last)
            last_page_name = all_mypages[last] if last >= 0 else None
            last_page_link = ''
            if last_page_name:
                last_page_link = '[[%s]]' % last_page_name
                last_page_text = get_page_text(last_page_name)
                if last_page_text is not None:
                    last_page_quoted = '\n'.join(
                        ['> ' + line for line in last_page_text.splitlines()])

            today_user = user_time(req, format_date, now, tzinfo=tzinfo)
            author = get_reporter_id(req)

            text = template_text \
                .replace(self.tokens['date'][0], today_user) \
                .replace(self.tokens['isodate'][0], today) \
                .replace(self.tokens['user'][0], req.authname) \
                .replace(self.tokens['author'][0], author) \
                .replace(self.tokens['lp_link'][0], last_page_link) \
                .replace(self.tokens['lp_name'][0], last_page_name or '') \
                .replace(self.tokens['lp_text'][0], last_page_text or '') \
                .replace(self.tokens['lp_quoted'][0], last_page_quoted or '')
        req.redirect(req.href.wiki(today_page_name, action='edit', text=text))
开发者ID:cboos,项目名称:trac-mypage-plugin,代码行数:61,代码来源:mypage.py

示例14: _do_save

    def _do_save(self, req, milestone):
        if milestone.exists:
            req.perm(milestone.resource).require('MILESTONE_MODIFY')
        else:
            req.perm(milestone.resource).require('MILESTONE_CREATE')

        old_name = milestone.name
        new_name = req.args.get('name')

        milestone.description = req.args.get('description', '')

        if 'due' in req.args:
            due = req.args.get('duedate', '')
            milestone.due = user_time(req, parse_date, due, hint='datetime') \
                            if due else None
        else:
            milestone.due = None

        completed = req.args.get('completeddate', '')
        retarget_to = req.args.get('target')

        # Instead of raising one single error, check all the constraints and
        # let the user fix them by going back to edit mode showing the warnings
        warnings = []
        def warn(msg):
            add_warning(req, msg)
            warnings.append(msg)

        # -- check the name
        # If the name has changed, check that the milestone doesn't already
        # exist
        # FIXME: the whole .exists business needs to be clarified
        #        (#4130) and should behave like a WikiPage does in
        #        this respect.
        try:
            new_milestone = Milestone(self.env, new_name)
            if new_milestone.name == old_name:
                pass        # Creation or no name change
            elif new_milestone.name:
                warn(_('Milestone "%(name)s" already exists, please '
                       'choose another name.', name=new_milestone.name))
            else:
                warn(_('You must provide a name for the milestone.'))
        except ResourceNotFound:
            milestone.name = new_name

        # -- check completed date
        if 'completed' in req.args:
            completed = user_time(req, parse_date, completed,
                                  hint='datetime') if completed else None
            if completed and completed > datetime.now(utc):
                warn(_('Completion date may not be in the future'))
        else:
            completed = None
        milestone.completed = completed

        if warnings:
            return self._render_editor(req, milestone)

        # -- actually save changes
        if milestone.exists:
            milestone.update()
            # eventually retarget opened tickets associated with the milestone
            if 'retarget' in req.args and completed:
                self.env.db_transaction("""
                    UPDATE ticket SET milestone=%s
                    WHERE milestone=%s and status != 'closed'
                    """, (retarget_to, old_name))
                self.log.info("Tickets associated with milestone %s "
                              "retargeted to %s" % (old_name, retarget_to))
        else:
            milestone.insert()

        add_notice(req, _("Your changes have been saved."))
        req.redirect(req.href.milestone(milestone.name))
开发者ID:nextview,项目名称:medicticket,代码行数:75,代码来源:roadmap.py

示例15: _do_actions

    def _do_actions(self, context, actions):

        api = TrackerApi()

        time_interval = self.env.config.getint('tracker', 'time_interval', 10)
        time_separate = 1
        minutes_interval=0
        screenshotsWithHourse = []
        screenshotsWithMinutes = []
        template_hourse = []
        minute = 0
        min_hourse = 0
        max_hourse = 0
        allScreenshots=[]

        for action in actions:
            if action == 'view':
                date = datetime.datetime.now(context.req.tz)
                if 'date' in context.req.args:
                    date_from_calendar = context.req.args['date'].strip()
                    if date_from_calendar:
                        precisedate = user_time(context.req, parse_date, date_from_calendar)
                        date = precisedate.astimezone(context.req.tz)
                to_date = to_datetime(datetime.datetime(date.year, date.month, date.day,
                                               23, 59, 59, 999999), context.req.tz)
                to_date_timestamp = to_timestamp(to_date)

                full_date = {
                    'from_date': to_date_timestamp - 86400,
                    'to_date'  : to_date_timestamp
                }

                context.req.data['fromdate'] = to_date
                context.req.data['username'] = context.req.args.get('username')

                screenshot_id = int(context.req.args.get('id') or 0)
                screenshots = api.get_screenshots(context, context.req.args.get('username'), full_date)

                context.req.data['id'] = screenshot_id

                for hourse in range(0, 24):
                    for screenshot in screenshots:
                        screenshot["hourse"] = datetime.datetime.fromtimestamp(screenshot["time"]).strftime('%H')
                        if (int(screenshot["hourse"]) == hourse):
                            if min_hourse == 0:
                                min_hourse = hourse
                            elif min_hourse > hourse:
                                min_hourse = hourse
                            if max_hourse < hourse:
                                max_hourse = hourse
                            screenshotsWithHourse.append({hourse:screenshot})

                while (minute <= 59):
                    for screenshotsAll in screenshotsWithHourse:

                        for index in screenshotsAll:

                            screenshotMinute = datetime.datetime.fromtimestamp(float(screenshotsAll[index]["time"])).strftime('%M')
                            if int(screenshotMinute) == minute:
                                screenshotHourse = datetime.datetime.fromtimestamp(screenshotsAll[index]["time"]).strftime('%H')
                                if int(screenshotHourse) not in template_hourse:
                                    template_hourse.append(int(screenshotHourse))
                                screenshotsAll[index]['hourse'] = int(screenshotHourse)
                                screenshotsAll[index]['minute'] = int(screenshotMinute)
                                if len(screenshotsWithMinutes)>0 and screenshotsWithMinutes[0]['minute']==screenshotsAll[index]['minute']:
                                    screenshotsWithMinutes.pop()
                                screenshotsWithMinutes.append(screenshotsAll[index])
                    minute += 10
                for hourse in template_hourse:
                    for screenshot in screenshotsWithMinutes:
                        if screenshot['hourse']==hourse:
                            while screenshot['minute']!=minutes_interval:
                                allScreenshots.append({"hourse":hourse,"screen":None,"minute":minutes_interval})
                                minutes_interval+=10
                            screenshot["screen"]=1
                            allScreenshots.append(screenshot)
                            minutes_interval+=10
                    while (minutes_interval!=60):
                        allScreenshots.append({"hourse":hourse,"screen":None,"minute":minutes_interval})
                        minutes_interval+=10
                    minutes_interval=0

                context.req.data['allScreenshots'] = allScreenshots
                context.req.data['template_hourse'] = range(int(min_hourse), int(max_hourse)+time_separate)
                context.req.data['time_interval'] = time_interval
                context.req.data['time_separate'] = time_separate
                context.req.data['template'] = 'user_worklog_view.html'
                add_stylesheet(context.req, 'trac/css/tracker.css')
                chrome = Chrome(self.env)
                chrome.add_jquery_ui(context.req)

                return 'screenshots', None

            if action == 'get-file':

                screenshot_id = int(context.req.args.get('id') or 0)
                format = context.req.args.get('format') or self.default_format

                screenshot = api.get_screenshot(context, screenshot_id)

#.........这里部分代码省略.........
开发者ID:AI3Zakir,项目名称:Tracker-for-TRAC,代码行数:101,代码来源:user_list.py


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