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


Python misc.utf8函数代码示例

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


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

示例1: set_language

    def set_language(self, language):
        # Support both iconview and treeview
        if self.only:
            model = self.iconview.get_model()
            iterator = model.iter_children(None)
            while iterator is not None:
                if misc.utf8(model.get_value(iterator, 0)) == language:
                    path = model.get_path(iterator)
                    self.iconview.select_path(path)
                    self.iconview.scroll_to_path(path, True, 0.5, 0.5)
                    break
                iterator = model.iter_next(iterator)
        else:
            model = self.treeview.get_model()
            iterator = model.iter_children(None)
            while iterator is not None:
                if misc.utf8(model.get_value(iterator, 0)) == language:
                    path = model.get_path(iterator)
                    self.treeview.get_selection().select_path(path)
                    self.treeview.scroll_to_cell(
                        path, use_align=True, row_align=0.5)
                    break
                iterator = model.iter_next(iterator)

        if not self.only and 'UBIQUITY_GREETER' in os.environ:
            self.try_ubuntu.set_sensitive(True)
            self.install_ubuntu.set_sensitive(True)
开发者ID:IbpTeam,项目名称:ubiquity,代码行数:27,代码来源:ubi-language.py

示例2: set_keyboard

    def set_keyboard(self, layout):
        index = self.page.keyboard_layout_combobox.findText(misc.utf8(layout))

        if index > -1:
            self.page.keyboard_layout_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            lang = 'C'
            ly = keyboard_names.layout_id(lang, misc.utf8(layout))
            self.keyboardDisplay.setLayout(ly)
开发者ID:kelebek333,项目名称:ubiquity,代码行数:10,代码来源:ubi-console-setup.py

示例3: set_keyboard

    def set_keyboard(self, layout):
        index = self.page.keyboard_layout_combobox.findText(misc.utf8(layout))

        if index > -1:
            self.page.keyboard_layout_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            l = self.controller.dbfilter.get_locale()
            ly = keyboard_names.layout_id(l, misc.utf8(layout))
            self.keyboardDisplay.setLayout(ly)
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:10,代码来源:ubi-console-setup.py

示例4: get_keyboard_variant

 def get_keyboard_variant(self):
     selection = self.keyboardvariantview.get_selection()
     (model, iterator) = selection.get_selected()
     if iterator is None:
         return None
     else:
         return misc.utf8(model.get_value(iterator, 0))
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:7,代码来源:ubi-console-setup.py

示例5: set_keyboard_choices

    def set_keyboard_choices(self, choices):
        self.page.keyboard_layout_combobox.clear()
        for choice in sorted(choices):
            self.page.keyboard_layout_combobox.addItem(misc.utf8(choice))

        if self.current_layout is not None:
            self.set_keyboard(self.current_layout)
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:7,代码来源:ubi-console-setup.py

示例6: changed

    def changed(self, entry):
        from gi.repository import Gtk, GObject, GLib, Soup

        text = misc.utf8(self.city_entry.get_text())
        if not text:
            return
        # TODO if the completion widget has a selection, return?  How do we
        # determine this?
        if text in self.geoname_cache:
            model = self.geoname_cache[text]
            self.city_entry.get_completion().set_model(model)
        else:
            model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING,
                                  GObject.TYPE_STRING, GObject.TYPE_STRING,
                                  GObject.TYPE_STRING)

            if self.geoname_session is None:
                self.geoname_session = Soup.SessionAsync()
            url = _geoname_url % (quote(text), misc.get_release().version)
            message = Soup.Message.new('GET', url)
            message.request_headers.append('User-agent', 'Ubiquity/1.0')
            self.geoname_session.abort()
            if self.geoname_timeout_id is not None:
                GLib.source_remove(self.geoname_timeout_id)
            self.geoname_timeout_id = \
                GLib.timeout_add_seconds(2, self.geoname_timeout,
                                         (text, model))
            self.geoname_session.queue_message(message, self.geoname_cb,
                                               (text, model))
开发者ID:linuxmint,项目名称:ubiquity,代码行数:29,代码来源:ubi-timezone.py

示例7: get_string

def get_string(name, lang, prefix=None):
    """Get the translation of a single string."""
    question = map_widget_name(prefix, name)
    translations = get_translations()
    if question not in translations:
        return None

    if lang is None:
        lang = 'c'
    else:
        lang = lang.lower()
    if name in string_extended:
        lang = 'extended:%s' % lang

    if lang in translations[question]:
        text = translations[question][lang]
    else:
        ll_cc = lang.split('.')[0]
        ll = ll_cc.split('_')[0]
        if ll_cc in translations[question]:
            text = translations[question][ll_cc]
        elif ll in translations[question]:
            text = translations[question][ll]
        elif lang.startswith('extended:'):
            text = translations[question]['extended:c']
        else:
            text = translations[question]['c']

    return misc.utf8(text, errors='replace')
开发者ID:pkt,项目名称:ubiquity.squibby,代码行数:29,代码来源:i18n.py

示例8: on_keyboard_layout_selected

    def on_keyboard_layout_selected(self, *args):
        layout = self.get_keyboard()
        lang = self.controller.dbfilter.get_locale()
        if layout is not None:
                # skip updating keyboard if not using display
                if self.keyboardDisplay:
                    try:
                        ly = keyboard_names.layout_id(lang, misc.utf8(layout))
                    except KeyError:
                        ly = keyboard_names.layout_id('C', misc.utf8(layout))
                    self.keyboardDisplay.setLayout(ly)

                    # no variants, force update by setting none
                    # if not keyboard_names.has_variants(l, ly):
                    #    self.keyboardDisplay.setVariant(None)

                self.current_layout = layout
                self.controller.dbfilter.change_layout(layout)
开发者ID:Sunderland93,项目名称:ubiquity,代码行数:18,代码来源:ubi-console-setup.py

示例9: set_keyboard_variant

    def set_keyboard_variant(self, variant):
        index = self.page.keyboard_variant_combobox.findText(
            misc.utf8(variant))

        if index > -1:
            self.page.keyboard_variant_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            lang = 'C'
            layout = keyboard_names.layout_id(lang, self.get_keyboard())
            if variant:
                try:
                    var = keyboard_names.variant_id(
                        lang, layout, misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)
开发者ID:kelebek333,项目名称:ubiquity,代码行数:18,代码来源:ubi-console-setup.py

示例10: set_keyboard_variant

    def set_keyboard_variant(self, variant):
        index = self.page.keyboard_variant_combobox.findText(
            misc.utf8(variant))

        if index > -1:
            self.page.keyboard_variant_combobox.setCurrentIndex(index)

        if self.keyboardDisplay:
            l = self.controller.dbfilter.get_locale()
            layout = keyboard_names.layout_id(l, self.get_keyboard())
            if variant:
                try:
                    var = keyboard_names.variant_id(
                        l, layout, misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:18,代码来源:ubi-console-setup.py

示例11: default_locales

def default_locales():
    with open('/usr/lib/ubiquity/localechooser/languagelist') as languagelist:
        defaults = {}
        for line in languagelist:
            line = misc.utf8(line)
            if line == '' or line == '\n':
                continue
            bits = line.strip('\n').split(';')
            code = bits[0]
            locale = bits[4]
            defaults[code] = locale
    return defaults
开发者ID:Sunderland93,项目名称:ubiquity,代码行数:12,代码来源:i18n.py

示例12: check_hostname

def check_hostname(hostname):
    """Returns a list of reasons why the hostname is invalid."""
    errors = []
    for result in validation.check_hostname(misc.utf8(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            errors.append('hostname_error_length')
        elif result == validation.HOSTNAME_BADCHAR:
            errors.append('hostname_error_badchar')
        elif result == validation.HOSTNAME_BADHYPHEN:
            errors.append('hostname_error_badhyphen')
        elif result == validation.HOSTNAME_BADDOTS:
            errors.append('hostname_error_baddots')
    return errors
开发者ID:pkt,项目名称:ubiquity.squibby,代码行数:13,代码来源:ubi-usersetup.py

示例13: get_language

 def get_language(self):
     # Support both iconview and treeview
     if self.only:
         model = self.iconview.get_model()
         items = self.iconview.get_selected_items()
         if not items:
             return None
         iterator = model.get_iter(items[0])
     else:
         selection = self.treeview.get_selection()
         (model, iterator) = selection.get_selected()
     if iterator is None:
         return None
     else:
         value = misc.utf8(model.get_value(iterator, 0))
         return self.language_choice_map[value][1]
开发者ID:IbpTeam,项目名称:ubiquity,代码行数:16,代码来源:ubi-language.py

示例14: on_keyboard_variant_selected

    def on_keyboard_variant_selected(self, *args):
        layout = self.get_keyboard()
        variant = self.get_keyboard_variant()

        if self.keyboardDisplay:
            var = None
            l = self.controller.dbfilter.get_locale()
            ly = keyboard_names.layout_id(l, layout)
            if variant:
                try:
                    var = keyboard_names.variant_id(l, ly, misc.utf8(variant))
                except KeyError:
                    var = None

            self.keyboardDisplay.setVariant(var)

        if layout is not None and variant is not None:
            self.controller.dbfilter.apply_keyboard(layout, variant)
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:18,代码来源:ubi-console-setup.py

示例15: run

    def run(self, priority, question):
        if self.done:
            return self.succeeded

        if question == 'keyboard-configuration/layout':
            # TODO cjwatson 2006-09-07: no keyboard-configuration support
            # for layout choice translation yet
            self.ui.set_keyboard_choices(
                self.choices_untranslated(question))
            self.ui.set_keyboard(misc.utf8(self.db.get(question)))
            # Reset these in case we just backed up from the variant
            # question.
            self.store_defaults(True)
            self.has_variants = False
            self.succeeded = True
            return True
        elif question in ('keyboard-configuration/variant',
                          'keyboard-configuration/altgr'):
            if question == 'keyboard-configuration/altgr':
                if self.has_variants:
                    return True
                else:
                    # If there's only one variant, it is always the same as
                    # the layout name.
                    single_variant = misc.utf8(self.db.get(
                        'keyboard-configuration/layout'))
                    self.ui.set_keyboard_variant_choices([single_variant])
                    self.ui.set_keyboard_variant(single_variant)
            else:
                # TODO cjwatson 2006-10-02: no keyboard-configuration
                # support for variant choice translation yet
                self.has_variants = True
                self.ui.set_keyboard_variant_choices(
                    self.choices_untranslated(question))
                self.ui.set_keyboard_variant(misc.utf8(self.db.get(question)))
            # keyboard-configuration preseeding is special, and needs to be
            # checked by hand. The seen flag on
            # keyboard-configuration/layout is used internally by
            # keyboard-configuration, so we can't just force it to true.
            if (self.is_automatic and
                self.db.fget(
                    'keyboard-configuration/layoutcode', 'seen') == 'true'):
                return True
            else:
                return plugin.Plugin.run(self, priority, question)
        elif question == 'keyboard-configuration/model':
            # Backing up from the variant question inconveniently goes back
            # to the model question.  Catch this and go forward again so
            # that we can reach the layout question.
            return True
        elif question.startswith('keyboard-configuration/unsupported_'):
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/imported/yes', 'ubiquity/imported/no'))
            if response == 'ubiquity/imported/yes':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True
        else:
            return True
开发者ID:kissthink,项目名称:ubiquity-burg,代码行数:62,代码来源:ubi-console-setup.py


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