Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pkg_resources with importlib.metadata #144

Merged
merged 2 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions ansi2html/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
from collections import OrderedDict
from typing import Iterator, List, Optional, Set, Tuple, Union

import pkg_resources

from ansi2html.style import SCHEME, get_styles

if sys.version_info >= (3, 8):
from importlib.metadata import version
else:
from importlib_metadata import version

if sys.version_info >= (3, 8):
from typing import TypedDict
else:
Expand Down Expand Up @@ -566,12 +569,6 @@ def prepare(

return self._attrs

def attrs(self) -> Attributes:
"""Prepare attributes for the template"""
if not self._attrs:
raise Exception("Method .prepare not yet called.")
return self._attrs

def convert(
self, ansi: str, full: bool = True, ensure_trailing_newline: bool = False
) -> str:
Expand Down Expand Up @@ -618,7 +615,7 @@ def main() -> None:
"""

scheme_names = sorted(SCHEME.keys())
version_str = pkg_resources.get_distribution("ansi2html").version
version_str = version("ansi2html")
parser = optparse.OptionParser(
usage=main.__doc__, version="%%prog %s" % version_str
)
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ python_requires = >=3.6
packages = find:
include_package_data = True
zip_safe = False
install_requires =
importlib-metadata; python_version<"3.8"

[options.entry_points]
console_scripts =
Expand Down