Beispiel #1
0
    def parse(self, value):
        chosen = unicode(value)
        for (candidate, label) in self.choices:
            if unicode(candidate) == chosen:
                return chosen if value is not None else value

        raise ValueError(_("This is not a valid choice."))
Beispiel #2
0
    def parse(self, value):
        chosen = unicode(value)
        for (candidate, label) in self.choices:
            if unicode(candidate) == chosen:
                return chosen if value is not None else value

        raise ValueError(_("This is not a valid choice."))
    def __init__(self,
                 notification_id,
                 message,
                 created_at,
                 category=None,
                 icon=None,
                 priority=NORMAL,
                 expires_at=None,
                 dismissable=True,
                 groupable=True,
                 read_at=None,
                 username=None,
                 db=None):
        self.notification_id = notification_id
        try:
            self.message = json.loads(message)
        except ValueError:
            self.message = unicode(message)

        self.created_at = created_at
        self.category = category
        self.icon = icon
        self.priority = priority
        self.expires_at = expires_at
        self.dismissable = dismissable
        self.groupable = groupable
        self._read_at = read_at
        self.username = username
        self.db = db or request.db.notifications
def test_coercion_using_to_unicode():
    fn, lazy = get_lazy()
    fn.return_value = b'foo'
    try:
        s = unicode(lazy)
    except Exception as err:
        assert False, "Should not raise, but raised '%s'" % err
    assert s == 'foo'
Beispiel #5
0
def content_languages():
    conf = request.app.config
    archive = Archive.setup(conf['librarian.backend'],
                            request.db.main,
                            unpackdir=conf['content.unpackdir'],
                            contentdir=conf['content.contentdir'],
                            spooldir=conf['content.spooldir'],
                            meta_filename=conf['content.metadata'])
    content_langs = archive.get_content_languages()
    return [(code, unicode(name)) for (code, name) in SELECT_LANGS
            if code in content_langs]
    def __init__(self, notification_id, message, created_at, category=None,
                 icon=None, priority=NORMAL, expires_at=None, dismissable=True,
                 read_at=None, user=None):
        self.notification_id = notification_id
        try:
            self.message = json.loads(message)
        except ValueError:
            self.message = unicode(message)

        self.created_at = created_at
        self.category = category
        self.icon = icon
        self.priority = priority
        self.expires_at = expires_at
        self.dismissable = dismissable
        self._read_at = read_at
        self.user = user
Beispiel #7
0
def content_languages():
    archive = open_archive()
    content_langs = archive.get_content_languages()
    return [(code, unicode(name)) for (code, name) in SELECT_LANGS
            if code in content_langs]
    ("VI", _("United States Virgin Islands")),
    ("BF", _("Burkina Faso")),
    ("UY", _("Uruguay, Eastern Republic of")),
    ("UZ", _("Uzbekistan, Republic of")),
    ("VE", _("Venezuela, Bolivarian Republic of")),
    ("WF", _("Wallis and Futuna")),
    ("WS", _("Samoa, Independent State of")),
    ("YE", _("Yemen")),
    ("ZM", _("Zambia, Republic of")),
    ("XX", _("Disputed Territory")),
    ("XE", _("Iraq-Saudi Arabia Neutral Zone")),
    ("XD", _("United Nations Neutral Zone")),
    ("XS", _("Spratly Islands")),
)

COUNTRIES = Lazy(lambda: sorted(COUNTRY_CHOICES, key=lambda x: unicode(x[1]), cmp=locale.strcoll))

COUNTRY_CODES = [""] + [i[0] for i in COUNTRY_CHOICES]

CHANNELS = [(str(i), str(i)) for i in range(1, 14)]

HEADER = "# Auto-generated by Librarian. Do not edit manually.\n\n"

WPA_NONE = 0
WPA_COMPATIBLE = 1
WPA_SECURE = 2
WPA_MODES = (
    (WPA_NONE, _("Disabled")),
    (WPA_SECURE, _("Enabled")),
    # (WPA_COMPATIBLE, _('Low / Support older devices (WPA1/WPA2)')),
)
Beispiel #9
0
 def parse(self, value):
     if value is None:
         return ''
     return unicode(value)
Beispiel #10
0
 def parse(self, value):
     if value is None:
         return ''
     return unicode(value)
Beispiel #11
0
def download_languages():
    downloads = filter_downloads(lang=None)
    download_langs = [meta["language"] for meta in downloads]
    return [(code, unicode(name)) for (code, name) in SELECT_LANGS if code in download_langs]
Beispiel #12
0
    ("VI", _("United States Virgin Islands")),
    ("BF", _("Burkina Faso")),
    ("UY", _("Uruguay, Eastern Republic of")),
    ("UZ", _("Uzbekistan, Republic of")),
    ("VE", _("Venezuela, Bolivarian Republic of")),
    ("WF", _("Wallis and Futuna")),
    ("WS", _("Samoa, Independent State of")),
    ("YE", _("Yemen")),
    ("ZM", _("Zambia, Republic of")),
    ("XX", _("Disputed Territory")),
    ("XE", _("Iraq-Saudi Arabia Neutral Zone")),
    ("XD", _("United Nations Neutral Zone")),
    ("XS", _("Spratly Islands")),
)

COUNTRIES = Lazy(lambda: sorted(COUNTRY_CHOICES, key=lambda x: unicode(x[1]),
                                cmp=locale.strcoll))

COUNTRY_CODES = [""] +  [i[0] for i in COUNTRY_CHOICES]

CHANNELS = [(str(i), str(i)) for i in range(1, 14)]

HEADER = '# Auto-generated by Librarian. Do not edit manually.\n\n'

WPA_NONE = 0
WPA_COMPATIBLE = 1
WPA_SECURE = 2
WPA_MODES = (
    (WPA_NONE, _('Disabled')),
    (WPA_SECURE, _('Enabled')),
    #(WPA_COMPATIBLE, _('Low / Support older devices (WPA1/WPA2)')),
def safe_title(source, delim=u' '):
    result = []
    for word in ILLEGAL.split(source):
        if word:
            result.append(word)
    return unicode(delim.join(result))
Beispiel #14
0
def safe_title(source, delim=u' '):
    result = []
    for word in ILLEGAL.split(source):
        if word:
            result.append(word)
    return unicode(delim.join(result))