Skip to content

Commit cc2e830

Browse files
committed
[chores] Removed code for Python<=3.9
1 parent 3c16b3b commit cc2e830

1 file changed

Lines changed: 9 additions & 28 deletions

File tree

openwisp_utils/admin_theme/system_info.py

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import importlib.metadata
12
import platform
2-
import sys
33
from collections import OrderedDict
44

55
import distro
@@ -9,33 +9,14 @@
99
EXTRA_OPENWISP_PACKAGES = ["netdiff", "netjsonconfig"]
1010

1111

12-
# python 3.10+
13-
if sys.version_info >= (3, 10):
14-
import importlib
15-
16-
def get_installed_openwisp_packages():
17-
dists = importlib.metadata.distributions()
18-
return {
19-
dist.name: dist.version
20-
for dist in dists
21-
if dist.name is not None
22-
and (
23-
dist.name.startswith("openwisp") or dist.name in EXTRA_OPENWISP_PACKAGES
24-
)
25-
}
26-
27-
28-
# legacy python 3.9, deprecated on recent python versions
29-
else:
30-
import pkg_resources
31-
32-
def get_installed_openwisp_packages():
33-
dists = pkg_resources.working_set
34-
return {
35-
dist.key: dist.version
36-
for dist in dists
37-
if dist.key.startswith("openwisp") or dist.key in EXTRA_OPENWISP_PACKAGES
38-
}
12+
def get_installed_openwisp_packages():
13+
dists = importlib.metadata.distributions()
14+
return {
15+
dist.name: dist.version
16+
for dist in dists
17+
if dist.name is not None
18+
and (dist.name.startswith("openwisp") or dist.name in EXTRA_OPENWISP_PACKAGES)
19+
}
3920

4021

4122
def _get_openwisp2_detail(attribute_name, fallback=None):

0 commit comments

Comments
 (0)