This file is indexed.

/usr/lib/python3/dist-packages/sqlalchemy_utils/types/locale.py is in python3-sqlalchemy-utils 0.32.21-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import six
from sqlalchemy import types

from ..exceptions import ImproperlyConfigured
from .scalar_coercible import ScalarCoercible

babel = None
try:
    import babel
except ImportError:
    pass


class LocaleType(types.TypeDecorator, ScalarCoercible):
    """
    LocaleType saves Babel_ Locale objects into database. The Locale objects
    are converted to string on the way in and back to object on the way out.

    In order to use LocaleType you need to install Babel_ first.

    .. _Babel: http://babel.pocoo.org/

    ::


        from sqlalchemy_utils import LocaleType
        from babel import Locale


        class User(Base):
            __tablename__ = 'user'
            id = sa.Column(sa.Integer, autoincrement=True)
            name = sa.Column(sa.Unicode(50))
            locale = sa.Column(LocaleType)


        user = User()
        user.locale = Locale('en_US')
        session.add(user)
        session.commit()


    Like many other types this type also supports scalar coercion:

    ::


        user.locale = 'de_DE'
        user.locale  # Locale('de', territory='DE')

    """

    impl = types.Unicode(10)

    def __init__(self):
        if babel is None:
            raise ImproperlyConfigured(
                'Babel packaged is required with LocaleType.'
            )

    def process_bind_param(self, value, dialect):
        if isinstance(value, babel.Locale):
            return six.text_type(value)

        if isinstance(value, six.string_types):
            return value

    def process_result_value(self, value, dialect):
        if value is not None:
            return babel.Locale.parse(value)

    def _coerce(self, value):
        if value is not None and not isinstance(value, babel.Locale):
            return babel.Locale.parse(value)
        return value