131 """Fetch languages and regions from Mullvad-Leta
135 Fetching the engine traits also requires a Mullvad VPN connection. If
136 not connected, then an error message will print and no traits will be
145 if not isinstance(resp, Response):
146 print(
"ERROR: failed to get response from mullvad-leta. Are you connected to the VPN?")
149 print(
"ERROR: response from mullvad-leta is not OK. Are you connected to the VPN?")
151 dom = html.fromstring(resp.text)
153 print(
'ERROR: Not connected to Mullvad VPN')
156 options = eval_xpath_list(dom.body,
'//main/div/form/div[2]/div/select[1]/option')
157 if options
is None or len(options) <= 0:
158 print(
'ERROR: could not find any results. Are you connected to the VPN?')
160 eng_country = x.get(
"value")
162 sxng_locales = get_official_locales(eng_country, engine_traits.languages.keys(), regional=
True)
166 "ERROR: can't map from Mullvad-Leta country %s (%s) to a babel region."
167 % (x.get(
'data-name'), eng_country)
171 for sxng_locale
in sxng_locales:
172 engine_traits.regions[region_tag(sxng_locale)] = eng_country