OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/21/2019 03:48:35 PM
rwxr-xr-x
📁
Automat-0.6.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
CommandNotFound
-
05/09/2024 07:14:56 AM
rwxr-xr-x
📁
ConfigArgParse-0.11.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
Crypto
-
05/09/2024 06:57:58 AM
rwxr-xr-x
📁
DistUpgrade
-
05/09/2024 07:15:53 AM
rwxr-xr-x
📁
HweSupportStatus
-
10/28/2024 08:41:33 AM
rwxr-xr-x
📁
Jinja2-2.10.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📁
LanguageSelector
-
10/21/2019 03:50:05 PM
rwxr-xr-x
📁
MarkupSafe-1.0.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📁
OpenSSL
-
10/21/2019 03:50:02 PM
rwxr-xr-x
📄
PAM-0.4.2.egg-info
193 bytes
08/04/2017 04:59:28 AM
rw-r--r--
📄
PAM.cpython-36m-x86_64-linux-gnu.so
19.42 KB
08/04/2017 04:59:28 AM
rw-r--r--
📄
PyICU-1.9.8.egg-info
10.32 KB
11/09/2017 07:22:14 AM
rw-r--r--
📄
PyICU.py
1.43 KB
02/08/2016 11:30:00 PM
rw-r--r--
📁
PyJWT-1.5.3.egg-info
-
07/20/2022 06:59:45 AM
rwxr-xr-x
📄
PyYAML-3.12.egg-info
1.48 KB
08/05/2017 04:28:08 PM
rw-r--r--
📄
README.txt
119 bytes
03/10/2023 04:46:00 PM
rw-r--r--
📁
SecretStorage-2.3.1.egg-info
-
05/09/2024 06:57:57 AM
rwxr-xr-x
📁
Twisted-17.9.0.egg-info
-
03/31/2022 06:22:38 AM
rwxr-xr-x
📁
UpdateManager
-
10/28/2024 08:41:33 AM
rwxr-xr-x
📁
__pycache__
-
11/10/2024 09:42:49 AM
rwxr-xr-x
📄
_cffi_backend.cpython-36m-x86_64-linux-gnu.so
165.56 KB
02/27/2018 07:34:07 PM
rw-r--r--
📄
_dbus_bindings.cpython-36m-x86_64-linux-gnu.so
155.67 KB
01/29/2018 07:57:57 PM
rw-r--r--
📄
_dbus_glib_bindings.cpython-36m-x86_64-linux-gnu.so
18.7 KB
01/29/2018 07:57:57 PM
rw-r--r--
📄
_icu.cpython-36m-x86_64-linux-gnu.so
710.82 KB
11/09/2017 07:22:14 AM
rw-r--r--
📄
_snack.cpython-36m-x86_64-linux-gnu.so
42.59 KB
01/12/2018 04:42:24 PM
rw-r--r--
📄
_version.py
21 bytes
08/26/2014 01:11:36 AM
rw-r--r--
📄
_yaml.cpython-36m-x86_64-linux-gnu.so
220.16 KB
08/05/2017 04:28:08 PM
rw-r--r--
📁
acme
-
07/12/2020 04:36:20 PM
rwxr-xr-x
📁
acme-0.31.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
apport
-
05/09/2024 07:15:23 AM
rwxr-xr-x
📄
apport_python_hook.py
7.87 KB
05/13/2020 10:12:14 PM
rw-r--r--
📁
apt
-
05/09/2024 07:14:28 AM
rwxr-xr-x
📄
apt_inst.cpython-36m-x86_64-linux-gnu.so
50.37 KB
12/01/2022 12:36:29 PM
rw-r--r--
📄
apt_inst.pyi
227 bytes
12/01/2022 12:36:29 PM
rw-r--r--
📄
apt_pkg.cpython-36m-x86_64-linux-gnu.so
338.66 KB
12/01/2022 12:36:29 PM
rw-r--r--
📄
apt_pkg.pyi
8.69 KB
12/01/2022 12:36:29 PM
rw-r--r--
📁
aptsources
-
05/09/2024 07:14:28 AM
rwxr-xr-x
📁
asn1crypto
-
10/21/2019 03:49:46 PM
rwxr-xr-x
📁
asn1crypto-0.24.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
attr
-
10/21/2019 03:49:50 PM
rwxr-xr-x
📁
attrs-17.4.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
automat
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📁
blinker
-
10/21/2019 03:49:46 PM
rwxr-xr-x
📄
blinker-1.4.egg-info
3.81 KB
01/11/2018 02:57:15 PM
rw-r--r--
📁
certbot
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📁
certbot-0.31.0.egg-info
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📁
certbot_dns_digitalocean
-
05/25/2021 01:14:28 PM
rwxr-xr-x
📁
certbot_dns_digitalocean-0.23.0.egg-info
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📁
certifi
-
10/21/2019 03:49:43 PM
rwxr-xr-x
📁
certifi-2018.1.18.egg-info
-
10/21/2019 03:49:19 PM
rwxr-xr-x
📁
chardet
-
10/21/2019 03:49:47 PM
rwxr-xr-x
📁
chardet-3.0.4.egg-info
-
10/21/2019 03:49:15 PM
rwxr-xr-x
📁
click
-
10/21/2019 03:49:53 PM
rwxr-xr-x
📁
click-6.7.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📁
cloud_init-23.1.2.egg-info
-
05/09/2024 07:14:27 AM
rwxr-xr-x
📁
cloudinit
-
05/09/2024 07:15:07 AM
rwxr-xr-x
📁
colorama
-
10/21/2019 03:49:43 PM
rwxr-xr-x
📁
colorama-0.3.7.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📄
command_not_found-0.3.egg-info
189 bytes
02/14/2022 05:26:36 PM
rw-r--r--
📄
configargparse.py
40.35 KB
09/05/2016 01:22:39 AM
rw-r--r--
📁
configobj-5.0.6.egg-info
-
05/09/2024 07:14:03 AM
rwxr-xr-x
📄
configobj.py
87.51 KB
02/05/2018 01:01:15 PM
rw-r--r--
📁
constantly
-
10/21/2019 03:49:41 PM
rwxr-xr-x
📁
constantly-15.1.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
cryptography
-
11/05/2020 06:02:51 AM
rwxr-xr-x
📁
cryptography-2.1.4.egg-info
-
11/05/2020 06:02:51 AM
rwxr-xr-x
📄
cv2.cpython-36m-x86_64-linux-gnu.so
2.78 MB
09/20/2018 09:28:13 AM
rw-r--r--
📁
dbus
-
10/21/2019 03:48:44 PM
rwxr-xr-x
📄
deb822.py
146 bytes
02/17/2018 05:37:18 AM
rw-r--r--
📄
debconf.py
6.61 KB
05/06/2019 04:30:30 PM
rw-r--r--
📁
debian
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📁
debian_bundle
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📁
digitalocean
-
05/25/2021 01:14:28 PM
rwxr-xr-x
📁
distro_info-0.18ubuntu0.18.04.1.egg-info
-
10/21/2019 03:49:16 PM
rwxr-xr-x
📄
distro_info.py
10.68 KB
03/07/2019 07:33:56 PM
rw-r--r--
📁
distro_info_test
-
10/21/2019 03:49:40 PM
rwxr-xr-x
📄
easy_install.py
126 bytes
03/18/2018 02:41:50 PM
rw-r--r--
📁
future
-
07/12/2020 04:36:17 PM
rwxr-xr-x
📁
future-0.15.2.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
gi
-
10/21/2019 03:49:07 PM
rwxr-xr-x
📁
httplib2
-
05/09/2024 07:15:03 AM
rwxr-xr-x
📄
httplib2-0.9.2.egg-info
2.22 KB
12/15/2020 08:09:40 PM
rw-r--r--
📁
hyperlink
-
10/21/2019 03:49:51 PM
rwxr-xr-x
📁
hyperlink-17.3.1.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
icu
-
07/12/2020 04:36:17 PM
rwxr-xr-x
📁
idna
-
10/21/2019 03:49:42 PM
rwxr-xr-x
📁
idna-2.6.egg-info
-
10/21/2019 03:49:19 PM
rwxr-xr-x
📁
incremental
-
10/21/2019 03:49:40 PM
rwxr-xr-x
📁
incremental-16.10.1.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
janitor
-
10/28/2024 08:41:33 AM
rwxr-xr-x
📁
jinja2
-
10/21/2019 03:49:48 PM
rwxr-xr-x
📁
josepy
-
07/12/2020 04:36:18 PM
rwxr-xr-x
📁
josepy-1.1.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
jsonpatch-1.16.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📄
jsonpatch.py
26.19 KB
06/15/2017 03:41:06 PM
rw-r--r--
📁
jsonpickle
-
05/25/2021 01:14:27 PM
rwxr-xr-x
📄
jsonpickle-0.9.5.egg-info
1.01 KB
08/21/2017 09:29:37 AM
rw-r--r--
📁
jsonpointer-1.10.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📄
jsonpointer.py
9.15 KB
10/28/2015 07:06:37 PM
rw-r--r--
📁
jsonschema
-
10/21/2019 03:49:46 PM
rwxr-xr-x
📁
jsonschema-2.6.0.egg-info
-
10/21/2019 03:49:31 PM
rwxr-xr-x
📁
jwt
-
07/20/2022 06:59:45 AM
rwxr-xr-x
📁
keyring
-
05/09/2024 06:58:01 AM
rwxr-xr-x
📁
keyring-10.6.0.egg-info
-
05/09/2024 06:57:57 AM
rwxr-xr-x
📁
keyrings
-
05/09/2024 06:57:57 AM
rwxr-xr-x
📁
keyrings.alt-3.0.egg-info
-
05/09/2024 06:57:57 AM
rwxr-xr-x
📁
landscape
-
05/09/2024 07:14:55 AM
rwxr-xr-x
📁
language_selector-0.1.egg-info
-
10/21/2019 03:49:13 PM
rwxr-xr-x
📄
language_support_pkgs.py
9.89 KB
11/16/2017 08:34:16 PM
rw-r--r--
📁
libfuturize
-
07/12/2020 04:36:17 PM
rwxr-xr-x
📁
libpasteurize
-
07/12/2020 04:36:18 PM
rwxr-xr-x
📄
lsb_release.py
14.09 KB
08/07/2017 09:55:07 PM
rw-r--r--
📁
markupsafe
-
10/21/2019 03:49:45 PM
rwxr-xr-x
📁
mock
-
07/12/2020 04:36:16 PM
rwxr-xr-x
📁
mock-2.0.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
ndg
-
07/12/2020 04:36:18 PM
rwxr-xr-x
📁
ndg_httpsclient-0.4.4.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
netifaces-0.10.4.egg-info
-
10/21/2019 03:49:07 PM
rwxr-xr-x
📄
netifaces.cpython-36m-x86_64-linux-gnu.so
18.59 KB
08/04/2017 06:49:42 AM
rw-r--r--
📁
numpy
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📁
numpy-1.13.3.egg-info
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📁
oauthlib
-
10/21/2019 03:49:53 PM
rwxr-xr-x
📁
oauthlib-2.0.6.egg-info
-
10/21/2019 03:49:32 PM
rwxr-xr-x
📁
parsedatetime
-
07/12/2020 04:36:19 PM
rwxr-xr-x
📁
parsedatetime-2.4.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
past
-
07/12/2020 04:36:18 PM
rwxr-xr-x
📁
pbr
-
07/12/2020 04:36:16 PM
rwxr-xr-x
📁
pbr-3.1.1.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
pexpect
-
09/28/2022 06:45:12 AM
rwxr-xr-x
📄
pexpect-4.2.1.egg-info
2.23 KB
12/12/2016 02:59:09 PM
rw-r--r--
📁
pip
-
05/09/2024 06:58:02 AM
rwxr-xr-x
📁
pip-9.0.1.egg-info
-
05/09/2024 06:57:57 AM
rwxr-xr-x
📁
pkg_resources
-
05/09/2024 06:58:00 AM
rwxr-xr-x
📄
problem_report.py
26.28 KB
11/11/2019 09:57:56 PM
rw-r--r--
📁
ptyprocess
-
09/28/2022 06:45:11 AM
rwxr-xr-x
📁
pyOpenSSL-17.5.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
pyRFC3339-1.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
pyasn1
-
10/21/2019 03:49:47 PM
rwxr-xr-x
📁
pyasn1-0.4.2.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
pyasn1_modules
-
10/21/2019 03:49:49 PM
rwxr-xr-x
📄
pyasn1_modules-0.2.1.egg-info
1.68 KB
01/02/2018 11:18:24 AM
rw-r--r--
📄
pycrypto-2.6.1.egg-info
666 bytes
04/03/2018 01:26:21 PM
rw-r--r--
📄
pygobject-3.26.1.egg-info
1013 bytes
01/29/2019 12:46:03 PM
rw-r--r--
📁
pygtkcompat
-
10/21/2019 03:49:07 PM
rwxr-xr-x
📁
pyrfc3339
-
07/12/2020 04:36:19 PM
rwxr-xr-x
📄
pyserial-3.4.egg-info
1.62 KB
04/09/2018 11:57:25 AM
rw-r--r--
📄
python_apt-1.6.6.egg-info
226 bytes
12/01/2022 12:36:29 PM
rw-r--r--
📁
python_debian-0.1.32.egg-info
-
10/21/2019 03:49:15 PM
rwxr-xr-x
📁
python_digitalocean-1.13.2.egg-info
-
05/25/2021 01:14:26 PM
rwxr-xr-x
📁
pytz
-
07/12/2020 04:36:19 PM
rwxr-xr-x
📁
pytz-2018.3.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📄
pyxdg-0.25.egg-info
576 bytes
01/07/2021 02:49:21 AM
rw-r--r--
📁
requests
-
10/21/2019 03:49:53 PM
rwxr-xr-x
📁
requests-2.18.4.egg-info
-
10/21/2019 03:49:19 PM
rwxr-xr-x
📁
requests_toolbelt
-
07/12/2020 04:36:15 PM
rwxr-xr-x
📁
requests_toolbelt-0.8.0.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📁
requests_unixsocket
-
10/21/2019 03:50:04 PM
rwxr-xr-x
📁
requests_unixsocket-0.1.5.egg-info
-
10/21/2019 03:49:19 PM
rwxr-xr-x
📁
secretstorage
-
05/09/2024 06:58:01 AM
rwxr-xr-x
📁
serial
-
10/21/2019 03:49:40 PM
rwxr-xr-x
📁
service_identity
-
10/21/2019 03:50:02 PM
rwxr-xr-x
📁
service_identity-16.0.0.egg-info
-
10/21/2019 03:49:23 PM
rwxr-xr-x
📁
setuptools
-
05/09/2024 06:58:03 AM
rwxr-xr-x
📁
setuptools-39.0.1.egg-info
-
05/09/2024 06:57:58 AM
rwxr-xr-x
📁
six-1.11.0.egg-info
-
10/21/2019 03:49:15 PM
rwxr-xr-x
📄
six.py
30.16 KB
09/17/2017 06:46:32 PM
rw-r--r--
📄
snack.py
30.4 KB
01/12/2018 04:42:24 PM
rw-r--r--
📁
softwareproperties
-
05/09/2024 07:14:38 AM
rwxr-xr-x
📁
sos
-
03/17/2025 09:32:20 AM
rwxr-xr-x
📄
sos-4.4.egg-info
312 bytes
11/21/2024 02:52:56 PM
rw-r--r--
📁
ssh_import_id
-
10/21/2019 03:50:07 PM
rwxr-xr-x
📁
ssh_import_id-5.7.egg-info
-
10/21/2019 03:49:39 PM
rwxr-xr-x
📁
systemd
-
10/21/2019 03:49:48 PM
rwxr-xr-x
📄
systemd_python-234.egg-info
586 bytes
08/05/2017 04:28:04 PM
rw-r--r--
📁
twisted
-
03/31/2022 06:22:38 AM
rwxr-xr-x
📁
uaclient
-
10/28/2024 08:41:34 AM
rwxr-xr-x
📁
ubuntu_pro_client-8001.egg-info
-
10/28/2024 08:41:32 AM
rwxr-xr-x
📁
ufw
-
05/09/2024 07:15:19 AM
rwxr-xr-x
📄
ufw-0.36.egg-info
261 bytes
10/25/2021 05:30:24 PM
rw-r--r--
📁
unattended_upgrades-0.1.egg-info
-
05/09/2024 07:14:27 AM
rwxr-xr-x
📁
urllib3
-
10/07/2020 06:14:10 AM
rwxr-xr-x
📁
urllib3-1.22.egg-info
-
10/07/2020 06:14:10 AM
rwxr-xr-x
📄
validate.py
46.13 KB
08/26/2014 01:11:36 AM
rw-r--r--
📁
wheel
-
05/09/2024 06:58:00 AM
rwxr-xr-x
📁
wheel-0.30.0.egg-info
-
05/09/2024 06:57:58 AM
rwxr-xr-x
📁
xdg
-
05/09/2024 06:57:59 AM
rwxr-xr-x
📁
yaml
-
10/21/2019 03:48:44 PM
rwxr-xr-x
📁
zope
-
05/09/2024 07:14:32 AM
rwxr-xr-x
📄
zope.component-4.3.0-nspkg.pth
529 bytes
02/05/2018 01:00:17 PM
rw-r--r--
📁
zope.component-4.3.0.egg-info
-
07/12/2020 04:36:15 PM
rwxr-xr-x
📄
zope.event-4.2.0-nspkg.pth
299 bytes
03/25/2016 05:44:58 PM
rw-r--r--
📁
zope.event-4.2.0.egg-info
-
07/12/2020 04:36:15 PM
rwxr-xr-x
📄
zope.hookable-4.0.4-nspkg.pth
529 bytes
02/05/2018 12:24:34 PM
rw-r--r--
📁
zope.hookable-4.0.4.egg-info
-
07/12/2020 04:36:14 PM
rwxr-xr-x
📄
zope.interface-4.3.2-nspkg.pth
529 bytes
02/04/2018 09:30:45 AM
rw-r--r--
📁
zope.interface-4.3.2.egg-info
-
05/09/2024 07:14:26 AM
rwxr-xr-x
Editing: language_support_pkgs.py
Close
#!/usr/bin/python3 import apt import os import subprocess DEFAULT_DEPENDS_FILE='/usr/share/language-selector/data/pkg_depends' class LanguageSupport: lang_country_map = None def __init__(self, apt_cache=None, depends_file=None): if apt_cache is None: self.apt_cache = apt.Cache() else: self.apt_cache = apt_cache self.pkg_depends = self._parse_pkg_depends(depends_file or DEFAULT_DEPENDS_FILE) def by_package_and_locale(self, package, locale, installed=False): '''Get language support packages for a package and locale. Note that this does not include support packages which are not specific to a particular trigger package, e. g. general language packs. To get those, call this with package==''. By default, only return packages which are not installed. If installed is True, return all packages instead. ''' packages = [] depmap = self.pkg_depends.get(package, {}) # check explicit entries for that locale for pkglist in depmap.get(self._langcode_from_locale(locale), {}).values(): for p in pkglist: if p in self.apt_cache: packages.append(p) # check patterns for empty locale string (i. e. applies to any locale) for pattern_list in depmap.get('', {}).values(): for pattern in pattern_list: for pkg_candidate in self._expand_pkg_pattern(pattern, locale): if pkg_candidate in self.apt_cache: packages.append(pkg_candidate) if not installed: # filter out installed packages packages = [p for p in packages if not self.apt_cache[p].installed] # exclude Fcitx packages if GNOME desktop desktop = os.environ.get('XDG_CURRENT_DESKTOP') if desktop and 'GNOME' in desktop.split(':'): for p in list(packages): if p.startswith('fcitx'): packages.remove(p) # exclude hunspell-de-XX since they conflict with -frami for country in ['de', 'at', 'ch']: if 'hunspell-de-' + country in packages: packages.remove('hunspell-de-' + country) # exclude hunspell-gl since it conflicts with hunspell-gl-es # https://launchpad.net/bugs/1578821 if 'hunspell-gl' in packages: packages.remove('hunspell-gl') return packages def by_locale(self, locale, installed=False): '''Get language support packages for a locale. Return all packages which need to be installed in order to provide language support for the given locale for all already installed packages. This should be called after adding a new locale to the system. By default, only return packages which are not installed. If installed is True, return all packages instead. ''' packages = [] for trigger in self.pkg_depends: try: if trigger == '' or self.apt_cache[trigger].installed: packages += self.by_package_and_locale(trigger, locale, installed) except KeyError: continue return packages def by_package(self, package, installed=False): '''Get language support packages for a package. This will install language support for that package for all available system languages. This is a wrapper around available_languages() and by_package_and_locale(). Note that this does not include support packages which are not specific to a particular trigger package, e. g. general language packs. To get those, call this with package==''. By default, only return packages which are not installed. If installed is True, return all packages instead. ''' packages = set() for lang in self.available_languages(): packages.update(self.by_package_and_locale(package, lang, installed)) return packages def missing(self, installed=False): '''Get language support packages for current system. Return all packages which need to be installed in order to provide language support all system locales for all already installed packages. This should be called after installing the system without language support packages (perhaps because there was no network available to download them). This is a wrapper around available_languages() and by_locale(). By default, only return packages which are not installed. If installed is True, return all packages instead. ''' packages = set() for lang in self.available_languages(): packages.update(self.by_locale(lang, installed)) return packages def available_languages(self): '''List available languages in the system. The list items can be passed as the "locale" argument of by_locale(), by_package_and_locale(), etc. ''' languages = set() lang_string = subprocess.check_output( ['/usr/share/language-tools/language-options'], universal_newlines=True) for lang in lang_string.split(): languages.add(lang) if not lang.startswith('zh_'): languages.add(lang.split('_')[0]) if os.path.isdir('/usr/share/locale-langpack/en') == False: languages.discard('en') return languages def _parse_pkg_depends(self, filename): '''Parse pkg_depends file. Return trigger_package -> langcode -> category -> [dependency,...] map. ''' map = {} with open(filename) as f: for line in f: line = line.strip() if not line or line.startswith('#'): continue (cat, lc, trigger, dep) = line.split(':') map.setdefault(trigger, {}).setdefault(lc, {}).setdefault(cat, []).append(dep) return map @classmethod def _langcode_from_locale(klass, locale): '''Turn a locale name into a language code as in pkg_depends.''' # special-case Chinese locales, as they are split between -hans and # -hant if locale.startswith('zh_CN') or locale.startswith('zh_SG'): return 'zh-hans' # Hong Kong and Taiwan use traditional if locale.startswith('zh_'): return 'zh-hant' return locale.split('_', 1)[0] @classmethod def _expand_pkg_pattern(klass, pattern, locale): '''Return all possible suffixes for given pattern and locale''' # people might call this with the pseudo-locales "zh-han[st]", support # these as well; we can only guess the country here. if locale == 'zh-hans': locale = 'zh_CN' elif locale == 'zh-hant': locale = 'zh_TW' locale = locale.split('.', 1)[0].lower() variant = None country = None try: (lang, country) = locale.split('_', 1) if '@' in country: (country, variant) = country.split('@', 1) except ValueError: lang = locale pkgs = [pattern, '%s%s' % (pattern, lang)] if country: pkgs.append('%s%s%s' % (pattern, lang, country)) pkgs.append('%s%s-%s' % (pattern, lang, country)) else: for country in klass._countries_for_lang(lang): pkgs.append('%s%s%s' % (pattern, lang, country)) pkgs.append('%s%s-%s' % (pattern, lang, country)) if variant: pkgs.append('%s%s-%s' % (pattern, lang, variant)) if country and variant: pkgs.append('%s%s-%s-%s' % (pattern, lang, country, variant)) # special-case Chinese if lang == 'zh': if country in ['cn', 'sg']: pkgs.append(pattern + 'zh-hans') else: pkgs.append(pattern + 'zh-hant') return pkgs @classmethod def _countries_for_lang(klass, lang): '''Return a list of countries for given language''' if klass.lang_country_map is None: klass.lang_country_map = {} # fill cache with open('/usr/share/i18n/SUPPORTED') as f: for line in f: line = line.split('#', 1)[0].split(' ')[0] if not line: continue line = line.split('.', 1)[0].split('@')[0] try: (l, c) = line.split('_') except ValueError: continue c = c.lower() klass.lang_country_map.setdefault(l, set()).add(c) return klass.lang_country_map.get(lang, []) def apt_cache_add_language_packs(resolver, cache, depends_file=None): '''Add language support for packages marked for installation. For all packages which are marked for installation in the given apt.Cache() object, mark the corresponding language packs and support packages for installation as well. This function can be used as an aptdaemon modify_cache_after plugin. ''' ls = LanguageSupport(cache, depends_file) support_pkgs = set() for pkg in cache.get_changes(): if pkg.marked_install: support_pkgs.update(ls.by_package(pkg.name)) for pkg in support_pkgs: cache[pkg].mark_install(from_user=False) def packagekit_what_provides_locale(cache, type, search, depends_file=None): '''PackageKit WhatProvides plugin for locale().''' if not search.startswith('locale('): raise NotImplementedError('cannot handle query type ' + search) locale = search.split('(', 1)[1][:-1] ls = LanguageSupport(cache, depends_file) pkgs = ls.by_locale(locale, installed=True) return [cache[p] for p in pkgs]