-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace pkg_resources with importlib
pkg_resources is deprecated in favor of importlib.{resources,metadata} Closes #46 See-also: https://setuptools.pypa.io/en/latest/pkg_resources.html See-also: https://docs.python.org/3/library/importlib.resources.html See-also: https://docs.python.org/3/library/importlib.metadata.html Signed-off-by: Mubashshir <ahmubashshir@gmail.com>
- Loading branch information
1 parent
ce44f5b
commit 1652736
Showing
7 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2013 the BabelFish authors. All rights reserved. | ||
# Use of this source code is governed by the 3-clause BSD license | ||
# that can be found in the LICENSE file. | ||
# | ||
from sys import version_info as _python | ||
|
||
if _python >= (3, 9): | ||
# introduced in python 3.9 | ||
from importlib.resources import files | ||
else: | ||
from importlib_resources import files | ||
|
||
|
||
if _python >= (3, 10): | ||
# .select() was introduced in 3.10 | ||
from importlib.metadata import entry_points, EntryPoint as _EntryPoint | ||
else: | ||
from importlib_metadata import entry_points, EntryPoint as _EntryPoint | ||
|
||
|
||
def resource_stream(pkg, path): | ||
return files(pkg).joinpath(f'{path}').open('rb') | ||
|
||
|
||
def iter_entry_points(group, **kwargs): | ||
return entry_points().select(group=group, **kwargs) | ||
|
||
|
||
class EntryPoint(_EntryPoint): | ||
@staticmethod | ||
def parse(eps): | ||
return EntryPoint(*map(str.strip, eps.split('=')), None) | ||
|
||
def resolve(self): | ||
return self.load() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters