Skip to content

Commit

Permalink
fix(packaging): use importlib-resources instead of pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Apr 29, 2021
1 parent 85ac52a commit 6ef222e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions guessit/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Data
"""
8 changes: 4 additions & 4 deletions guessit/rules/properties/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Website property.
"""
from pkg_resources import resource_stream # @UnresolvedImport
from importlib_resources import open_text # @UnresolvedImport
from rebulk.remodule import re

from rebulk import Rebulk, Rule, RemoveMatch
Expand All @@ -27,11 +27,11 @@ def website(config):
rebulk = rebulk.regex_defaults(flags=re.IGNORECASE).string_defaults(ignore_case=True)
rebulk.defaults(name="website")

with resource_stream('guessit', 'data/tlds-alpha-by-domain.txt') as tld_file:
with open_text('guessit.data', 'tlds-alpha-by-domain.txt') as tld_file:
tlds = [
tld.strip().decode('utf-8')
tld.strip()
for tld in tld_file.readlines()
if b'--' not in tld
if '--' not in tld
][1:] # All registered domain extension

safe_tlds = config['safe_tlds'] # For sure a website extension
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
with io.open(os.path.join(here, 'CHANGELOG.md'), encoding='utf-8') as f:
changelog = f.read()

install_requires = ['rebulk>=3', 'babelfish', 'python-dateutil']
install_requires = ['rebulk>=3', 'babelfish', 'python-dateutil', 'importlib-resources']

setup_requires = ['pytest-runner']

Expand Down

0 comments on commit 6ef222e

Please sign in to comment.