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

Python common._函数代码示例

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

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



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

示例1: update

    def update(self):
        result = []
        periods = self.periods()
        numSlots = self.numSlots()
        for i in range(len(self.days())):
            day = []
            for j in range(numSlots[i]):
                name = 'period_%d_%d' % (i, j)
                if name not in self.request:
                    self.error = _('Please provide all periods.')
                    return False
                day.append(self.request[name])
            result.append(day)

        # Validate that all periods are selected
        errors = set()
        for i, day in enumerate(self.days()):
            seen = set()
            for period in result[i]:
                if period not in seen:
                    seen.add(period)
                else:
                    error = _("$period on day $day",
                              mapping={'period': period, 'day': self.days()[i]})
                    errors.add(translate(error, context=self.request))
        if errors:
            self.error = _('The following periods were selected more'
                           ' than once: $periods',
                           mapping={'periods': ', '.join(errors)})
            return False

        self.getSessionData()['periods_order'] = result
        return True
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:33,代码来源:ttwizard.py


示例2: renderBookedTable

    def renderBookedTable(self):
        prefix = "remove_item"
        available_columns = self.columns()
        available_columns[0].cell_formatter = label_cell_formatter_factory(prefix)
        available_columns[2].title = _('Reserved by others')
        columns = list(available_columns)

        title=_('Release resource')
        # XXX: this getter is just plain wrong
        getter = lambda r: r.__name__

        remove_column = ImageInputColumn(
            prefix, name='action',
            title=title, alt=title,
            library='schooltool.skin.flourish',
            image='remove-icon.png', id_getter=getter)
        columns.append(remove_column)

        formatter = zc.table.table.FormFullFormatter(
            self.context, self.request, self.getBookedItems(),
            columns=columns,
            sort_on=self.sortOn(),
            prefix="booked")
        formatter.cssClasses['table'] = 'data'

        return formatter()
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:26,代码来源:event.py


示例3: columns

 def columns(self):
     first_name = table.column.LocaleAwareGetterColumn(
         name='first_name',
         title=_(u'First Name'),
         getter=lambda i, f: i.first_name,
         subsort=True)
     last_name = table.column.LocaleAwareGetterColumn(
         name='last_name',
         title=_(u'Last Name'),
         getter=lambda i, f: i.last_name,
         subsort=True)
     result = [first_name, last_name]
     optional_column_token = self.request.get('optional')
     if optional_column_token is not None:
         provider_name, column_name = optional_column_token.split('.')
         provider = getAdapter(self.view, IColumnProvider,
                               name=provider_name)
         optional_column = None
         for column in provider.columns:
             if column.name == column_name:
                 optional_column = column
                 break
         if optional_column is not None:
             result.append(optional_column)
     return result
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:25,代码来源:group.py


示例4: populate

 def populate(self, states):
     super(GroupMembershipStatesStartup, self).populate(states)
     states.add(_('Pending'), INACTIVE, 'i')
     states.add(_('Member'), ACTIVE, 'a')
     states.add(_('Suspended'), INACTIVE, 's')
     states.add(_('Removed'), INACTIVE, 'r')
     states.add(_('Added in error'), INACTIVE, 'e')
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:7,代码来源:states.py


示例5: columns

 def columns(self):
     task_id = table.column.IndexedGetterColumn(
         index='task_id',
         name='task_id',
         cell_formatter=self.task_id_formatter,
         title=_(u'Task ID'),
         getter=lambda i, f: i.task_id,
         subsort=True)
     signature = table.table.GetterColumn(
         name='signature',
         title=_(u'Signature'),
         getter=lambda i, f: i.signature,
         subsort=True)
     internal_state = table.column.IndexedGetterColumn(
         index='internal_state',
         name='internal_state',
         title=_(u'Internal state'),
         getter=lambda i, f: i,
         cell_formatter=task_state_formatter,
         subsort=True)
     directlyProvides(internal_state, ISortableColumn)
     scheduled = table.column.IndexedGetterColumn(
         index='scheduled',
         name='scheduled',
         title=_(u'Scheduled'),
         getter=lambda i, f: i.scheduled,
         cell_formatter=table.table.datetime_formatter,
         subsort=True)
     directlyProvides(scheduled, ISortableColumn)
     return [task_id, signature, internal_state, scheduled]
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:30,代码来源:task.py


示例6: renderAvailableTable

    def renderAvailableTable(self):
        prefix = "add_item"
        available_columns = self.columns()
        available_columns[0].cell_formatter = label_cell_formatter_factory(prefix)
        available_columns[2].title = _('Reserved by others')
        columns = list(available_columns)

        title=_('Reserve resource')
        # XXX: this getter is just plain wrong
        getter = lambda r: r.__name__

        add_column = ImageInputColumn(
            prefix, name='action',
            title=title, alt=title,
            library='schooltool.skin.flourish',
            image='add-icon.png', id_getter=getter)
        columns.append(add_column)

        formatter = zc.table.table.FormFullFormatter(
            self.context, self.request, self.filter(self.availableResources),
            columns=columns,
            batch_start=self.batch.start, batch_size=self.batch.size,
            sort_on=self.sortOn(),
            prefix="available")
        formatter.cssClasses['table'] = 'data'


        return formatter()
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:28,代码来源:event.py


示例7: email_container_table_columns

def email_container_table_columns():
    from_address = GetterColumn(name='from_address',
                                title=_(u'From'),
                                getter=lambda i, f: i.from_address,
                                subsort=True)
    directlyProvides(from_address, ISortableColumn)
    to_addresses = GetterColumn(name='to_addresses',
                                title=_(u'To'),
                                getter=lambda i, f: i.to_addresses,
                                cell_formatter=to_addresses_formatter,
                                subsort=True)
    directlyProvides(to_addresses, ISortableColumn)
    subject = GetterColumn(name='subject',
                           title=_(u'Subject'),
                           getter=lambda i, f: i.subject,
                           cell_formatter=subject_formatter,
                           subsort=True)
    directlyProvides(subject, ISortableColumn)
    time_created = GetterColumn(name='time_created',
                                title=_(u'Created on'),
                                getter=lambda i, f: i.time_created,
                                cell_formatter=table.table.datetime_formatter,
                                subsort=True)
    directlyProvides(time_created, ISortableColumn)
    time_sent = GetterColumn(name='time_sent',
                                title=_(u'Last time tried'),
                                getter=lambda i, f: i.time_sent,
                                cell_formatter=table.table.datetime_formatter,
                                subsort=True)
    directlyProvides(time_sent, ISortableColumn)
    return [from_address, to_addresses, subject, time_created, time_sent]
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:31,代码来源:email.py


示例8: sizeForDisplay

 def sizeForDisplay(self):
     num = self.sizeForSorting()[1]
     if num == 1:
         msgid = _("1 person")
     else:
         msgid = _("${number} persons", mapping={'number': num})
     return msgid
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:7,代码来源:__init__.py


示例9: toFieldValue

 def toFieldValue(self, value):
     if value is None or value == '':
         return z3c.form.interfaces.NOT_CHANGED
     if value == 'delete':
         # XXX: delete checkbox was marked
         return None
     data = value.read()
     try:
         image = Image.open(StringIO(data))
         if image.format not in ('JPEG', 'PNG'):
             raise IOError()
     except (IOError,):
         raise FormatterValidationError(
             _('The file uploaded is not a JPEG or PNG image'), value)
     size = len(data)
     if size > self.field.max_file_size:
         msg = _('The image uploaded cannot be larger than ${size} MB')
         raise FormatterValidationError(
             format_message(
                 msg,
                 mapping={'size': '%.2f' % (float(size) / (10**6))}),
             value)
     data = self.processImage(image)
     f = ImageFile()
     self.updateFile(f, data)
     return f
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:26,代码来源:widgets.py


示例10: update

    def update(self):
        """Read and validate form data, and update model if necessary.

        Also choose the correct template to render.
        """
        self.field_errors = []
        self.template = self.select_template

        if 'CANCEL' in self.request:
            self.request.response.redirect(
                absoluteURL(self.context, self.request))
            return

        if 'date' in self.request:
            try:
                self.date = parse_date(self.request['date'])
            except ValueError:
                self.error = _("Invalid date. Please use YYYY-MM-DD format.")
            else:
                self.term = getTermForDate(self.date)
                if self.term is None:
                    self.error = _("The date does not belong to any term.")
                    self.date = None

        if self.date:
            self.template = self.form_template

        if self.date and 'SUBMIT' in self.request:
            replacements = self.extractMeetings()
            if self.field_errors:
                self.error = self.field_error_message
            else:
                self.updateExceptions(replacements)
                self.request.response.redirect(
                    absoluteURL(self.context, self.request))
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:35,代码来源:schedule.py


示例11: parseCSVRows

    def parseCSVRows(self, rows):
        """Parse rows (a list of strings) in CSV format.

        Returns a list of rows as lists.

        rows must be in the encoding specified during construction of
        BaseCSVImportView; the returned values are in unicode.

        If the provided data is invalid, self.errors.generic will be updated
        and None will be returned.
        """
        result = []
        reader = csv.reader(rows)
        line = 0
        try:
            while True:
                line += 1
                values = [v.strip() for v in reader.next()]
                if self.charset:
                    values = [unicode(v, self.charset) for v in values]
                # Remove trailing empty cells.
                while values and not values[-1].strip():
                    del values[-1]
                result.append(values)
        except StopIteration:
            return result
        except csv.Error:
            error_msg = _("Error in CSV data, line ${line_no}",
                          mapping={'line_no': line})
            self.errors.generic.append(error_msg)
        except UnicodeError:
            error_msg = _("Conversion to unicode failed in line ${line_no}",
                          mapping={'line_no': line})
            self.errors.generic.append(error_msg)
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:34,代码来源:csvimport.py


示例12: choices

 def choices(self):
     session = self.getSessionData()
     if session['cycle'] == 'rotating':
         choices = ((True,  _("Have names")),)
     else:
         choices = ((True,  _("Have names")),
                    (False, _("Designated by time")))
     return choices
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:8,代码来源:ttwizard.py


示例13: updateWidgets

 def updateWidgets(self):
     super(FlourishTermAddView, self).updateWidgets()
     description = _(u'The year starts ${year_start}',
         mapping={'year_start': self.dateString(self.context.first)})
     self.widgets['first'].field.description = description
     description = _(u'The year ends ${year_end}',
         mapping={'year_end': self.dateString(self.context.last)})
     self.widgets['last'].field.description = description
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:8,代码来源:term.py


示例14: subtitle

 def subtitle(self):
     cursor_yw = year_week(self.cursor)
     if cursor_yw == year_week(self.today):
         return _("This Week")
     if cursor_yw == year_week(self.today - datetime.timedelta(weeks=1)):
         return _("Last Week")
     if cursor_yw == year_week(self.today + datetime.timedelta(weeks=1)):
         return _("Next Week")
     return None
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:9,代码来源:calendar.py


示例15: types

 def types(self):
     options = [
         {'id': 'equipment',
          'title': _('Equipment')},
         {'id': 'location',
          'title': _('Location')},
         {'id': 'resource',
          'title': _('Resource')},
         ]
     return options
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:10,代码来源:resource.py


示例16: getColumnsAfter

 def getColumnsAfter(self):
     result = [
         table.DateColumn(title=_("First Day"),
                          name='first',
                          getter=lambda x, y: x.first),
         table.DateColumn(title=_("Last Day"),
                          getter=lambda x, y: x.last),
         FlourishActiveSchoolYearColumn(title=_("Active")),
         ]
     return result
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:10,代码来源:schoolyear.py


示例17: set_server_status_message

def set_server_status_message(form, container):
    form.widgets['server_status'].mode = 'display'
    if container.enabled:
        info = '%s:%s' % (container.hostname,
                          container.port or '25')
        form.widgets['server_status'].value = _('Enabled on ${info}',
                                                mapping={'info': info})
        form.widgets['server_status'].style = u'color: green;'
    else:
        form.widgets['server_status'].value = _('Disabled')
        form.widgets['server_status'].style = u'color: red;'
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:11,代码来源:email.py


示例18: columns

 def columns(self):
     title = GetterColumn(
         name='title',
         title=_(u"Title"),
         getter=lambda i, f: i.title,
         subsort=True)
     type = GetterColumn(
         name='type',
         title=_(u"Type"),
         getter=lambda i, f: i.cal_type,
         subsort=True)
     return [title, type]
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:12,代码来源:overlay.py


示例19: serverStatus

 def serverStatus(self):
     result = {}
     if self.context.hostname:
         info = '%s:%s' % (self.context.hostname,
                           self.context.port or '25')
         result['status'] = _('Enabled on ${info}',
                              mapping={'info': info})
         result['color'] = 'green'
     else:
         result['status'] = _('Disabled')
         result['color'] = 'red'
     return result
开发者ID:achouhans,项目名称:schooltool-2.8.5,代码行数:12,代码来源:email.py


示例20: toFieldValue

 def toFieldValue(self, value):
     """See interfaces.IDataConverter"""
     if value == u"":
         return self.field.missing_value
     try:
         value = parse_date(value)
     except (ValueError,):
         raise FormatterValidationError(_("The datetime string did not match the pattern yyyy-mm-dd"), value)
     try:
         value.strftime("%Y-%m-%d")
     except (ValueError,):
         raise FormatterValidationError(_("Year has to be equal or greater than 1900"), value)
     return value
开发者ID:docker2use,项目名称:schooltool,代码行数:13,代码来源:widgets.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python audiolab.wavread函数代码示例发布时间:2022-05-27
下一篇:
Python test.raises函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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