MCPcopy Index your code
hub / github.com/daviddrysdale/python-phonenumbers / load_locale_prefixdata

Function load_locale_prefixdata

tools/python/buildprefixdata.py:131–145  ·  view source on GitHub ↗

Load per-prefix data from the given top-level directory. Prefix data is assumed to be held in files / / .txt. The same prefix may occur in multiple files, giving the prefix's description in different locales.

(indir, separator=None)

Source from the content-addressed store, hash-verified

129
130
131def load_locale_prefixdata(indir, separator=None):
132 """Load per-prefix data from the given top-level directory.
133
134 Prefix data is assumed to be held in files <indir>/<locale>/<prefix>.txt.
135 The same prefix may occur in multiple files, giving the prefix&#x27;s description
136 in different locales.
137 """
138 prefixdata = {} # prefix => dict mapping locale to description
139 for locale in os.listdir(indir):
140 if not os.path.isdir(os.path.join(indir, locale)):
141 continue
142 for filename in glob.glob(os.path.join(indir, locale, "*%s" % PREFIXDATA_SUFFIX)):
143 overall_prefix, ext = os.path.splitext(os.path.basename(filename))
144 load_locale_prefixdata_file(prefixdata, filename, locale, overall_prefix, separator)
145 return prefixdata
146
147
148def _stable_dict_repr(strdict):

Callers 1

_standaloneFunction · 0.85

Calls 1

Tested by

no test coverage detected