mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
Merge pull request #223 from alexfikl/remove-sre-constants
Remove usage of deprecared sre_constants
This commit is contained in:
commit
8cd75fd101
3 changed files with 3 additions and 5 deletions
|
@ -2,7 +2,6 @@
|
||||||
# Copyright (c) 2021 lilydjwg <lilydjwg@gmail.com>, et al.
|
# Copyright (c) 2021 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sre_constants
|
|
||||||
|
|
||||||
from nvchecker.api import session, GetVersionError
|
from nvchecker.api import session, GetVersionError
|
||||||
|
|
||||||
|
@ -19,7 +18,7 @@ async def get_version_impl(info):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
regex = re.compile(conf['regex'])
|
regex = re.compile(conf['regex'])
|
||||||
except sre_constants.error as e:
|
except re.error as e:
|
||||||
raise GetVersionError('bad regex', exc_info=e)
|
raise GetVersionError('bad regex', exc_info=e)
|
||||||
|
|
||||||
res = await session.request(
|
res = await session.request(
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
|
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sre_constants
|
|
||||||
|
|
||||||
from nvchecker.api import session, GetVersionError
|
from nvchecker.api import session, GetVersionError
|
||||||
|
|
||||||
async def get_version(name, conf, *, cache, **kwargs):
|
async def get_version(name, conf, *, cache, **kwargs):
|
||||||
try:
|
try:
|
||||||
regex = re.compile(conf['regex'])
|
regex = re.compile(conf['regex'])
|
||||||
except sre_constants.error as e:
|
except re.error as e:
|
||||||
raise GetVersionError('bad regex', exc_info=e)
|
raise GetVersionError('bad regex', exc_info=e)
|
||||||
if regex.groups > 1:
|
if regex.groups > 1:
|
||||||
raise GetVersionError('multi-group regex')
|
raise GetVersionError('multi-group regex')
|
||||||
|
|
|
@ -7,4 +7,4 @@ pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
|
||||||
async def test_cran(get_version):
|
async def test_cran(get_version):
|
||||||
assert await get_version("xml2", {
|
assert await get_version("xml2", {
|
||||||
"source": "cran",
|
"source": "cran",
|
||||||
}) == "1.3.3"
|
}) == "1.3.4"
|
||||||
|
|
Loading…
Add table
Reference in a new issue