py3.5 compat

This commit is contained in:
Kovid Goyal 2020-03-05 18:23:45 +05:30
parent a76a163db5
commit ac149be2bb
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 10 deletions

View File

@ -16,7 +16,6 @@ import sys
import tempfile import tempfile
import time import time
from contextlib import suppress from contextlib import suppress
from typing import cast
import requests import requests
@ -26,11 +25,10 @@ docs_dir = os.path.abspath('docs')
publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty')) publish_dir = os.path.abspath(os.path.join('..', 'kovidgoyal.github.io', 'kitty'))
with open('kitty/constants.py') as f: with open('kitty/constants.py') as f:
raw = f.read() raw = f.read()
nv = cast(re.Match, re.search( nv = re.search(r'^version\s+=\s+\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE)
r'^version\s+=\s+\((\d+), (\d+), (\d+)\)', raw, flags=re.MULTILINE)) if nv is not None:
version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3)) version = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3))
appname = cast(re.Match, re.search( appname = re.search(r"^appname\s+=\s+'([^']+)'", raw, flags=re.MULTILINE).group(1) # type: ignore
r"^appname\s+=\s+'([^']+)'", raw, flags=re.MULTILINE)).group(1)
ALL_ACTIONS = 'man html build tag sdist upload website'.split() ALL_ACTIONS = 'man html build tag sdist upload website'.split()

View File

@ -19,7 +19,6 @@ from functools import partial
from collections import namedtuple from collections import namedtuple
from contextlib import suppress from contextlib import suppress
from pathlib import Path from pathlib import Path
from typing import cast
base = os.path.dirname(os.path.abspath(__file__)) base = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, 'glfw') sys.path.insert(0, 'glfw')
@ -30,13 +29,13 @@ build_dir = 'build'
constants = os.path.join('kitty', 'constants.py') constants = os.path.join('kitty', 'constants.py')
with open(constants, 'rb') as f: with open(constants, 'rb') as f:
constants = f.read().decode('utf-8') constants = f.read().decode('utf-8')
appname = cast(re.Match, re.search(r"^appname = '([^']+)'", constants, re.MULTILINE)).group(1) appname = re.search(r"^appname = '([^']+)'", constants, re.MULTILINE).group(1) # type: ignore
version = tuple( version = tuple(
map( map(
int, int,
cast(re.Match, re.search( re.search( # type: ignore
r"^version = \((\d+), (\d+), (\d+)\)", constants, re.MULTILINE r"^version = \((\d+), (\d+), (\d+)\)", constants, re.MULTILINE
)).group(1, 2, 3) ).group(1, 2, 3)
) )
) )
_plat = sys.platform.lower() _plat = sys.platform.lower()