Instead of cluttering the user's home directory with multiple
SWC-installed directories, reduce clutter and improve namespacing by
dumping everything inside ~/.swc. Think of it as a SWC-specific
~/.local. We avoid actually using ~/.local because users might
already be using that for other purposes.
Use os.makedirs to create the nano install directory if it does not
already exist, because ZipFile.extract uses os.mkdir internally, and
mkdir will not recursively create directories.
from io import BytesIO as _BytesIO
except ImportError: # Python 2
from StringIO import StringIO as _BytesIO
from io import BytesIO as _BytesIO
except ImportError: # Python 2
from StringIO import StringIO as _BytesIO
try: # Python 3
from urllib.request import urlopen as _urlopen
except ImportError: # Python 2
try: # Python 3
from urllib.request import urlopen as _urlopen
except ImportError: # Python 2
nano_zip = zipfile.ZipFile(nano_zip_content)
nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll',
'cygiconv-2.dll', 'cyggcc_s-1.dll']
nano_zip = zipfile.ZipFile(nano_zip_content)
nano_files = ['nano.exe', 'cygwin1.dll', 'cygintl-8.dll',
'cygiconv-2.dll', 'cyggcc_s-1.dll']
+ os.makedirs(install_directory)
for file_name in nano_files:
nano_zip.extract(file_name, install_directory)
for file_name in nano_files:
nano_zip.extract(file_name, install_directory)
- home_dir = os.path.expanduser('~')
- nano_dir = os.path.join(home_dir, '.nano')
- bin_dir = os.path.join(home_dir, '.swc-bin')
+ swc_dir = os.path.join(os.path.expanduser('~'), '.swc')
+ nano_dir = os.path.join(swc_dir, 'lib', 'nano')
install_nano(installation_directory=nano_dir)
install_nano(installation_directory=nano_dir)
- update_bash_profile(extra_paths=(bin_dir, nano_dir))
+ update_bash_profile(extra_paths=(nano_dir,))
if __name__ == '__main__':
if __name__ == '__main__':