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

Python translation.locale_sorted函数代码示例

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

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



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

示例1: for_person_combo

    def for_person_combo(self, resultset):
        """
        This is similar to :py:func:`~stoqlib.api.StoqAPI.for_combo` but takes a class that references a :py:class:`~stoqlib.domain.person.Person`,
        such as a :py:class:`~stoqlib.domain.person.Client`,
        :py:class:`~stoqlib.domain.person.Company`,
        :py:class:`~stoqlib.domain.person.Supplier` etc.

        :param resultset: a resultset

        Example::

          suppliers = Supplier.get_active_suppliers(self.store)
          self.supplier.prefill(api.for_person_combo(suppliers))
        """
        from stoqlib.domain.person import Person
        from storm import Undef
        store = resultset._store
        facet = resultset._find_spec.default_cls
        where = resultset._where

        # This is fetching all persons to cache the objects and avoid extra
        # queries when constructing the combo strings.
        resultset = store.find((Person, facet), Person.id == facet.person_id)
        if where is not Undef:
            resultset = resultset.find(where)

        items = [(obj[1].get_description(), obj[1]) for obj in resultset]
        # FIXME: A combo only changes to data mode (the one that it
        # returns an object insted of the label) when prefilled with
        # objects. Prefilling with this fake data will prevent the problem
        # from happening. We should fix this on kiwi later
        if not items:
            return [('', None)]

        return locale_sorted(items, key=operator.itemgetter(0))
开发者ID:romaia,项目名称:stoq,代码行数:35,代码来源:api.py


示例2: for_combo

    def for_combo(self, resultset, attr=None, empty=None, sorted=True):
        """
        Prepares the result of a table for inserting into a combo.
        Formats the item and sorts them according to the current locale

        :param resultset: a resultset
        :param attr: attribute to use instead of :py:class:`~stoqlib.domain.interfaces.IDescribable`
        :param empty: if set, add an initial None item with this parameter as
          a label

        Example::

          categories = self.store.find(SellableCategory)
          self.category_combo.prefill(api.for_combo(categories,
                                      attr='full_description'))
        """
        if attr is not None:
            items = [(getattr(obj, attr), obj) for obj in resultset]
        else:
            # If attr is not specified, the objects in the resultset must
            # implement IDescribable
            items = [(obj.get_description(), obj) for obj in resultset]

        if sorted:
            items = locale_sorted(items, key=operator.itemgetter(0))

        if empty is not None:
            items.insert(0, (empty, None))
        return items
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:29,代码来源:api.py


示例3: add_defaults

    def add_defaults(self):
        items = [
            (_('Branches'), 'branches', gtk.STOCK_HOME),
            (_('C.F.O.P.'), 'cfop', STOQ_CALC),
            (_('Client Categories'), 'client_categories', STOQ_CLIENTS),
            (_('Clients'), 'clients', STOQ_CLIENTS),
            (_('Computers'), 'stations', STOQ_SYSTEM),
            (_('Devices'), 'devices', STOQ_DEVICES),
            (_('Employees'), 'employees', STOQ_ADMIN_APP),
            (_('Events'), 'events', gtk.STOCK_DIALOG_WARNING),
            (_('Fiscal Books'), 'fiscal_books', STOQ_EDIT),
            (_('Forms'), 'forms', STOQ_FORMS),
            (_('Invoice Printers'), 'invoice_printers', gtk.STOCK_PRINT),
            (_('Parameters'), 'parameters', gtk.STOCK_PREFERENCES),
            (_('Payment Categories'), 'payment_categories', STOQ_PAYABLE_APP),
            (_('Payment Methods'), 'payment_methods', STOQ_MONEY),
            (_('Plugins'), 'plugins', STOQ_PLUGIN),
            (_('Products'), 'products', STOQ_PRODUCTS),
            (_('Roles'), 'employee_roles', STOQ_USERS),
            (_('Services'), 'services', STOQ_SERVICES),
            (_('Taxes'), 'taxes', STOQ_TAXES),
            (_('Suppliers'), 'suppliers', STOQ_SUPPLIERS),
            (_('Tax Classes'), 'tax_templates', STOQ_DOCUMENTS),
            (_('Transporters'), 'transporters', STOQ_DELIVERY),
            (_('User Profiles'), 'user_profiles', STOQ_USER_PROFILES),
            (_('Users'), 'users', STOQ_HR),
            (_('Connect to Stoq.Link'), 'stoq_link_connect', STOQ_CONNECT),
        ]

        for label, name, pixbuf in locale_sorted(
                items, key=operator.itemgetter(0)):
            self.add_item(label, name, pixbuf)
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:32,代码来源:admin.py


示例4: get_serial_devices

 def get_serial_devices(cls):
     """Get a list of serial devices available on the system
     :returns: a list of :class:`SerialDevice`
     """
     from serial.tools.list_ports import comports
     ports = [SerialDevice(p.device) for p in comports()]
     return locale_sorted(ports, key=operator.attrgetter('device_name'))
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:devicemanager.py


示例5: add_defaults

    def add_defaults(self):
        items = [
            (_("Branches"), "branches", gtk.STOCK_HOME),
            (_("C.F.O.P."), "cfop", STOQ_CALC),
            (_("Client Categories"), "client_categories", STOQ_CLIENTS),
            (_("Clients"), "clients", STOQ_CLIENTS),
            (_("Computers"), "stations", STOQ_SYSTEM),
            (_("Devices"), "devices", STOQ_DEVICES),
            (_("Employees"), "employees", STOQ_ADMIN_APP),
            (_("Events"), "events", gtk.STOCK_DIALOG_WARNING),
            (_("Fiscal Books"), "fiscal_books", STOQ_EDIT),
            (_("Forms"), "forms", STOQ_FORMS),
            (_("Invoice Printers"), "invoice_printers", gtk.STOCK_PRINT),
            (_("Parameters"), "parameters", gtk.STOCK_PREFERENCES),
            (_("Payment Categories"), "payment_categories", STOQ_PAYABLE_APP),
            (_("Payment Methods"), "payment_methods", STOQ_MONEY),
            (_("Plugins"), "plugins", STOQ_PLUGIN),
            (_("Roles"), "employee_roles", STOQ_USERS),
            (_("Taxes"), "taxes", STOQ_TAXES),
            (_("Suppliers"), "suppliers", STOQ_SUPPLIERS),
            (_("Tax Classes"), "tax_templates", STOQ_DOCUMENTS),
            (_("Transporters"), "transporters", STOQ_DELIVERY),
            (_("User Profiles"), "user_profiles", STOQ_USER_PROFILES),
            (_("Users"), "users", STOQ_HR),
        ]

        for label, name, pixbuf in locale_sorted(items, key=operator.itemgetter(0)):
            self.add_item(label, name, pixbuf)
开发者ID:relsi,项目名称:stoq,代码行数:28,代码来源:admin.py


示例6: get_serial_devices

 def get_serial_devices(self):
     """Get a list of serial devices available on the system
     :returns: a list of :class:`SerialDevice`
     """
     if gudev:
         devices = self._get_gudev_devices()
     elif self._hal_manager:
         devices = self._get_hal_devices()
     else:
         devices = self._get_default_devices()
     return locale_sorted(devices, key=operator.attrgetter('device_name'))
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:11,代码来源:devicemanager.py


示例7: get_editable_methods

    def get_editable_methods(cls, store):
        """Gets a list of methods that are editable
        Eg, you can change the details such as maximum installments etc.

        :returns: a list of :class:`payment methods <PaymentMethod>`
        """
        # FIXME: Dont let users see online payments for now, to avoid
        #        confusions with active state. online is an exception to that
        #        logic. 'trade' for the same reason
        clause = And(cls.method_name != u"online", cls.method_name != u"trade")
        methods = store.find(cls, clause)
        return locale_sorted(methods, key=operator.attrgetter("description"))
开发者ID:rosalin,项目名称:stoq,代码行数:12,代码来源:method.py


示例8: _setup_widgets

    def _setup_widgets(self):
        items = [(b.person.name, b)
                 for b in self.store.find(Branch)
                 if b is not self.branch]
        self.destination_branch.prefill(locale_sorted(
            items, key=operator.itemgetter(0)))
        self.source_branch.set_text(self.branch.person.name)

        employees = self.store.find(Employee)
        self.source_responsible.prefill(api.for_combo(employees))
        self.destination_responsible.prefill(api.for_combo(employees))

        self.transfer_order.source_branch = self.branch
        self.transfer_order.destination_branch = items[0][1]
开发者ID:leandrorchaves,项目名称:stoq,代码行数:14,代码来源:stocktransferwizard.py


示例9: _populate_printers

    def _populate_printers(self):
        supported_ifaces = get_supported_printers_by_iface(ICouponPrinter).items()
        printers = []
        for brand, printer_classes in supported_ifaces:
            for printer_class in printer_classes:
                printer = _PrinterModel(brand, printer_class)
                printers.append((printer.get_description(), printer))

        if sysparam(self.store).DEMO_MODE:
            from stoqdrivers.printers.virtual.Simple import Simple
            printer = _PrinterModel('virtual', Simple)
            printers.append((printer.get_description(), printer))

        self.printer.prefill(locale_sorted(
            printers, key=operator.itemgetter(0)))
开发者ID:romaia,项目名称:stoq,代码行数:15,代码来源:ecfprinterdialog.py


示例10: get_available_applications

    def get_available_applications(self):
        user = api.get_current_user(self.store)

        permissions = user.profile.get_permissions()
        descriptions = get_utility(IApplicationDescriptions).get_descriptions()

        available_applications = []

        # sorting by app_full_name
        for name, full, icon, descr in locale_sorted(
                descriptions, key=operator.itemgetter(1)):
            if permissions.get(name):
                available_applications.append(
                    Application(name, full, icon, descr))
        return available_applications
开发者ID:hackedbellini,项目名称:stoq,代码行数:15,代码来源:shellwindow.py


示例11: _fill_wo_categories_combo

    def _fill_wo_categories_combo(self):
        wo_categories = list(self.store.find(WorkOrderCategory))
        self.wo_categories.color_attribute = 'color'

        if len(wo_categories) > 0:
            items = [(category.get_description(), category)
                     for category in wo_categories]
            items = locale_sorted(items, key=operator.itemgetter(0))
            items.insert(0, ('No category', None))
            self.wo_categories.prefill(items)
            self.wo_categories.set_sensitive(True)

        # We can use any work order, since all workorders in the same sale are
        # sharing the same category.
        workorder = WorkOrder.find_by_sale(self.store, self.model).any()
        if workorder and workorder.category:
            self.wo_categories.select(workorder.category)
开发者ID:qman1989,项目名称:stoq,代码行数:17,代码来源:opticalwizard.py


示例12: _fill_clients_combo

    def _fill_clients_combo(self):
        # FIXME: This should not be using a normal ProxyComboEntry,
        #        we need a specialized widget that does the searching
        #        on demand.

        # This is to keep the clients in cache
        clients_cache = list(Client.get_active_clients(self.store))
        clients_cache  # pyflakes

        # We are using ClientView here to show the fancy name as well
        clients = ClientView.get_active_clients(self.store)
        items = [(c.get_description(), c.client) for c in clients]
        items = locale_sorted(items, key=operator.itemgetter(0))
        self.client.prefill(items)

        # TODO: Implement a has_items() in kiwi
        self.client.set_sensitive(len(self.client.get_model()))
开发者ID:rosalin,项目名称:stoq,代码行数:17,代码来源:salequotewizard.py


示例13: get_countries

def get_countries():
    """Fetch a list of translated/untranslated countries suitable for usage
    within combo.prefill()::

    [(translated label, label), ...]

    :returns: a list of tuples
    """
    # FIXME: Get this lazely from /usr/share/xml/iso-codes/iso_3166.xml
    #        as pointed out on bug 5100.
    def cmp_func(a, b):
        return locale.strcoll(a[0], b[0])
    # We store translated country names in a set to ensure
    # there are no dupes because the combo expects that.
    items = set()
    for country in countries:
        items.add((dgettext("iso_3166", country), country))
    return locale_sorted(items, key=operator.itemgetter(0))
开发者ID:Guillon88,项目名称:stoq,代码行数:18,代码来源:countries.py


示例14: get_available_applications

    def get_available_applications(self):
        user = api.get_current_user(self.store)

        permissions = {}
        for settings in user.profile.profile_settings:
            permissions[settings.app_dir_name] = settings.has_permission

        descriptions = get_utility(IApplicationDescriptions).get_descriptions()

        available_applications = []

        # sorting by app_full_name
        for name, full, icon, descr in locale_sorted(
                descriptions, key=operator.itemgetter(1)):
            # FIXME:
            # if name in self._hidden_apps:
            #    continue
            # and name not in self._blocked_apps:
            if permissions.get(name):
                available_applications.append(
                    Application(name, full, icon, descr))
        return available_applications
开发者ID:fuinha,项目名称:stoq,代码行数:22,代码来源:shellwindow.py


示例15: get_active_methods

 def get_active_methods(cls, store):
     """Returns a list of active payment methods
     """
     methods = store.find(PaymentMethod, is_active=True)
     return locale_sorted(methods,
                          key=operator.attrgetter('description'))
开发者ID:leandrorchaves,项目名称:stoq,代码行数:6,代码来源:method.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python translation.stoqlib_ngettext函数代码示例发布时间:2022-05-27
下一篇:
Python translation._函数代码示例发布时间: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