Mercurial > babel > old > babel-test
annotate babel/localedata.py @ 484:d91b2fa43c39 stable-0.9.x
Block CLDR 1.7.x work.
author | jruigrok |
---|---|
date | Sun, 11 Apr 2010 08:58:49 +0000 |
parents | bd03ca5059f3 |
children | b1c8cc751458 |
rev | line source |
---|---|
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
2 # |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
3 # Copyright (C) 2007 Edgewall Software |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
4 # All rights reserved. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
5 # |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
6 # This software is licensed as described in the file COPYING, which |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
7 # you should have received as part of this distribution. The terms |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
8 # are also available at http://babel.edgewall.org/wiki/License. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
9 # |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
10 # This software consists of voluntary contributions made by many |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
11 # individuals. For the exact contribution history, see the revision |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
12 # history and logs, available at http://babel.edgewall.org/log/. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
13 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
14 """Low-level locale data access. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
15 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
16 :note: The `Locale` class, which uses this module under the hood, provides a |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
17 more convenient interface for accessing the locale data. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
18 """ |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
19 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
20 import os |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
21 import pickle |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
22 try: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
23 import threading |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
24 except ImportError: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
25 import dummy_threading as threading |
379 | 26 from UserDict import DictMixin |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
27 |
379 | 28 __all__ = ['exists', 'list', 'load'] |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
29 __docformat__ = 'restructuredtext en' |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
30 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
31 _cache = {} |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
32 _cache_lock = threading.RLock() |
41
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
33 _dirname = os.path.join(os.path.dirname(__file__), 'localedata') |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
34 |
379 | 35 |
41
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
36 def exists(name): |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
37 """Check whether locale data is available for the given locale. |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
38 |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
39 :param name: the locale identifier string |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
40 :return: `True` if the locale data exists, `False` otherwise |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
41 :rtype: `bool` |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
42 """ |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
43 if name in _cache: |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
44 return True |
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
45 return os.path.exists(os.path.join(_dirname, '%s.dat' % name)) |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
46 |
379 | 47 |
185
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
48 def list(): |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
49 """Return a list of all locale identifiers for which locale data is |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
50 available. |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
51 |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
52 :return: a list of locale identifiers (strings) |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
53 :rtype: `list` |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
54 :since: version 0.8.1 |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
55 """ |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
56 return [stem for stem, extension in [ |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
57 os.path.splitext(filename) for filename in os.listdir(_dirname) |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
58 ] if extension == '.dat' and stem != 'root'] |
170cffc66554
Add a command-line option that prints out all available locales. Closes #24.
cmlenz
parents:
99
diff
changeset
|
59 |
379 | 60 |
61 def load(name, merge_inherited=True): | |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
62 """Load the locale data for the given locale. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
63 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
64 The locale data is a dictionary that contains much of the data defined by |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
65 the Common Locale Data Repository (CLDR). This data is stored as a |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
66 collection of pickle files inside the ``babel`` package. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
67 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
68 >>> d = load('en_US') |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
69 >>> d['languages']['sv'] |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
70 u'Swedish' |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
71 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
72 Note that the results are cached, and subsequent requests for the same |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
73 locale return the same dictionary: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
74 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
75 >>> d1 = load('en_US') |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
76 >>> d2 = load('en_US') |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
77 >>> d1 is d2 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
78 True |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
79 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
80 :param name: the locale identifier string (or "root") |
379 | 81 :param merge_inherited: whether the inherited data should be merged into |
82 the data of the requested locale | |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
83 :return: the locale data |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
84 :rtype: `dict` |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
85 :raise `IOError`: if no locale data file is found for the given locale |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
86 identifer, or one of the locales it inherits from |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
87 """ |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
88 _cache_lock.acquire() |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
89 try: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
90 data = _cache.get(name) |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
91 if not data: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
92 # Load inherited data |
379 | 93 if name == 'root' or not merge_inherited: |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
94 data = {} |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
95 else: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
96 parts = name.split('_') |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
97 if len(parts) == 1: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
98 parent = 'root' |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
99 else: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
100 parent = '_'.join(parts[:-1]) |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
101 data = load(parent).copy() |
41
e967fbafcda1
Load locale data lazily to avoid penalizing usage of `Locale` objects when no locale data is actually needed.
cmlenz
parents:
26
diff
changeset
|
102 filename = os.path.join(_dirname, '%s.dat' % name) |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
103 fileobj = open(filename, 'rb') |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
104 try: |
379 | 105 if name != 'root' and merge_inherited: |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
106 merge(data, pickle.load(fileobj)) |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
107 else: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
108 data = pickle.load(fileobj) |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
109 _cache[name] = data |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
110 finally: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
111 fileobj.close() |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
112 return data |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
113 finally: |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
114 _cache_lock.release() |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
115 |
379 | 116 |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
117 def merge(dict1, dict2): |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
118 """Merge the data from `dict2` into the `dict1` dictionary, making copies |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
119 of nested dictionaries. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
120 |
379 | 121 >>> d = {1: 'foo', 3: 'baz'} |
122 >>> merge(d, {1: 'Foo', 2: 'Bar'}) | |
123 >>> d | |
124 {1: 'Foo', 2: 'Bar', 3: 'baz'} | |
125 | |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
126 :param dict1: the dictionary to merge into |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
127 :param dict2: the dictionary containing the data that should be merged |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
128 """ |
379 | 129 for key, val2 in dict2.items(): |
130 if val2 is not None: | |
131 val1 = dict1.get(key) | |
132 if isinstance(val2, dict): | |
133 if val1 is None: | |
134 val1 = {} | |
135 if isinstance(val1, Alias): | |
136 val1 = (val1, val2) | |
137 elif isinstance(val1, tuple): | |
138 alias, others = val1 | |
139 others = others.copy() | |
140 merge(others, val2) | |
141 val1 = (alias, others) | |
142 else: | |
143 val1 = val1.copy() | |
144 merge(val1, val2) | |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
145 else: |
379 | 146 val1 = val2 |
147 dict1[key] = val1 | |
148 | |
149 | |
150 class Alias(object): | |
151 """Representation of an alias in the locale data. | |
152 | |
153 An alias is a value that refers to some other part of the locale data, | |
154 as specified by the `keys`. | |
155 """ | |
156 | |
157 def __init__(self, keys): | |
158 self.keys = tuple(keys) | |
159 | |
160 def __repr__(self): | |
161 return '<%s %r>' % (type(self).__name__, self.keys) | |
162 | |
163 def resolve(self, data): | |
164 """Resolve the alias based on the given data. | |
165 | |
166 This is done recursively, so if one alias resolves to a second alias, | |
167 that second alias will also be resolved. | |
168 | |
169 :param data: the locale data | |
170 :type data: `dict` | |
171 """ | |
172 base = data | |
173 for key in self.keys: | |
174 data = data[key] | |
175 if isinstance(data, Alias): | |
176 data = data.resolve(base) | |
400 | 177 elif isinstance(data, tuple): |
178 alias, others = data | |
179 data = alias.resolve(base) | |
379 | 180 return data |
181 | |
182 | |
183 class LocaleDataDict(DictMixin, dict): | |
184 """Dictionary wrapper that automatically resolves aliases to the actual | |
185 values. | |
186 """ | |
187 | |
188 def __init__(self, data, base=None): | |
189 dict.__init__(self, data) | |
190 if base is None: | |
400 | 191 base = data |
379 | 192 self.base = base |
193 | |
194 def __getitem__(self, key): | |
400 | 195 orig = val = dict.__getitem__(self, key) |
379 | 196 if isinstance(val, Alias): # resolve an alias |
197 val = val.resolve(self.base) | |
198 if isinstance(val, tuple): # Merge a partial dict with an alias | |
199 alias, others = val | |
200 val = alias.resolve(self.base).copy() | |
201 merge(val, others) | |
400 | 202 if type(val) is dict: # Return a nested alias-resolving dict |
379 | 203 val = LocaleDataDict(val, base=self.base) |
400 | 204 if val is not orig: |
205 self[key] = val | |
379 | 206 return val |
207 | |
208 def copy(self): | |
209 return LocaleDataDict(dict.copy(self), base=self.base) |