Skip to content

Commit

Permalink
Remove old compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Oct 3, 2018
1 parent 271eaad commit d0538b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions nsist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from .copymodules import copy_modules
from .nsiswriter import NSISFileWriter
from .wheels import WheelGetter
from .util import download, text_types, get_cache_dir, normalize_path
from .util import download, get_cache_dir, normalize_path

__version__ = '2.1'

Expand Down Expand Up @@ -286,7 +286,7 @@ def prepare_shortcuts(self):
+ ('' if sc['console'] else 'w')

specified_preamble = sc.get('extra_preamble', None)
if isinstance(specified_preamble, text_types):
if isinstance(specified_preamble, str):
# Filename
extra_preamble = io.open(specified_preamble, encoding='utf-8')
elif specified_preamble is None:
Expand Down
3 changes: 1 addition & 2 deletions nsist/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import shutil
import win_cli_launchers

from .util import text_types

SCRIPT_TEMPLATE = u"""#!python
import sys, os
Expand Down Expand Up @@ -30,7 +29,7 @@ def prepare_bin_directory(target, commands, bitness=32):
shutil.copy(exe_src, str(target / (name+'.exe')))

specified_preamble = command.get('extra_preamble', None)
if isinstance(specified_preamble, text_types):
if isinstance(specified_preamble, str):
# Filename
extra_preamble = io.open(specified_preamble, encoding='utf-8')
elif specified_preamble is None:
Expand Down
20 changes: 2 additions & 18 deletions nsist/util.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import os
import errno
import logging
try:
from pathlib import Path
except ImportError:
from pathlib2 import Path # Backport
from pathlib import Path
import requests
import sys

logger = logging.getLogger(__name__)

PY3 = sys.version_info[0] >= 3

if PY3:
text_types = (str,)
else:
text_types = (str, unicode) # analysis:ignore


def download(url, target):
"""Download a file using requests.
Expand Down Expand Up @@ -56,12 +45,7 @@ def get_cache_dir(ensure_existence=False):
p = Path(local, 'pynsist')

if ensure_existence:
try:
p.mkdir(parents=True)
except OSError as e:
# Py2 compatible equivalent of FileExistsError
if e.errno != errno.EEXIST:
raise
p.mkdir(parents=True, exist_ok=True)

return p

Expand Down

0 comments on commit d0538b5

Please sign in to comment.