def read_text_from_file(file_path, default_contents=None): """Reads the text from a file if it exists; if it doens't, some default contents are returned""" if isfile(file_path): handle = fopen(file_path, mode="r", encoding="utf-8") text = handle.read() handle.close() return text return default_contents
def read(location): if not exists(location): raise FileNotFoundError with fopen(location) as fp: content = fp.read() fp.close() return content
def ensure_file(file_path, default_contents=None): """Ensures a file exists; if it doesn't, one is created with some contents""" if not isdir(dirname(file_path)): makedirs(dirname(file_path)) if not isfile(file_path): handle = fopen(file_path, mode="w", encoding="utf-8") handle.write(default_contents) handle.close() return file_path
#!/usr/bin/env python2 # -*- coding: utf-8 -*- from codecs import open as fopen from os.path import dirname, abspath, join from setuptools import setup DIR = dirname(abspath(__file__)) VERSION = '1.4.0' with fopen(join(DIR, 'README.rst'), encoding='utf-8') as f: long_description = f.read() setup( name='wordpress-backup-data', version=VERSION, description='Back up your WordPress data', long_description=long_description, license='GPLv3', keywords='wordpress backup', author='Paul-Emmanuel Raoul', author_email='*****@*****.**', url='https://github.com/SkypLabs/wordpress-backup-data', download_url= 'https://github.com/SkypLabs/wordpress-backup-data/archive/v{0}.zip'. format(VERSION), classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: End Users/Desktop', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Utilities',
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from codecs import open as fopen from os.path import dirname, abspath, join from setuptools import setup, find_packages from sniff_probe_req.version import VERSION DIR = dirname(abspath(__file__)) with fopen(join(DIR, 'README.rst'), encoding='utf-8') as f: long_description = f.read() setup( name = 'sniff-probe-req', version = VERSION, description = 'Wi-Fi Probe Requests Sniffer', long_description = long_description, license = 'GPLv3', keywords = 'wifi wireless security sniffer', author = 'Paul-Emmanuel Raoul', author_email = '*****@*****.**', url = 'https://github.com/SkypLabs/sniff-probe-req', download_url = 'https://github.com/SkypLabs/sniff-probe-req/archive/v{0}.zip'.format(VERSION), classifiers = [ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries :: Python Modules', 'Programming Language :: Python :: 3', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
except Exception as setuptools_not_present: raise ImportError( "Setuptools is required to install Faker Wi-Fi ESSID!" ) from setuptools_not_present from codecs import open as fopen from os.path import dirname, abspath, join DIR = dirname(abspath(__file__)) VERSION = "0.3.1" URL = "https://github.com/SkypLabs/faker-wifi-essid" DL_URL = URL + "/archive/v{0}.zip" with fopen(join(DIR, "README.rst"), encoding="utf-8") as f: LONG_DESCRIPTION = f.read() setup( name="faker_wifi_essid", version=VERSION, description="Faker provider for Wi-Fi ESSIDs.", long_description=LONG_DESCRIPTION, license="MIT", keywords="faker faker-library faker-provider faker-generator wifi essid", author="Paul-Emmanuel Raoul", author_email="*****@*****.**", url=URL, download_url=DL_URL.format(VERSION), classifiers=[ "Development Status :: 4 - Beta",
def save_text_to_file(text, file_path): """Saves the given text to a file at the specified path""" handle = fopen(file_path, mode="w", encoding="utf-8") handle.write(text) handle.close()
"""SkLite-python installation.""" import os from codecs import open as fopen from setuptools import setup, find_packages CWD = os.path.abspath(os.path.dirname(__file__)) ABOUT = {} with fopen(os.path.join(CWD, "sklite", "__version__.py"), "r", "utf-8") as f: # pylint: disable=exec-used exec(f.read(), ABOUT) with fopen("README.md", "r", "utf-8") as f: README = f.read() setup( name=ABOUT["__title__"], version=ABOUT["__version__"], description=ABOUT["__description__"], long_description=README, long_description_content_type="text/markdown", author=ABOUT["__author__"], author_email=ABOUT["__author_email__"], url=ABOUT["__url__"], packages=find_packages(), package_dir={"sklite": "sklite"}, include_package_data=True, license=ABOUT["__license__"], zip_safe=False, classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers",