-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
607a51a
commit 1787d7e
Showing
15 changed files
with
238 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service_name: travis-pro | ||
repo_token: q6MDH1GuPSnyzcenp5tuFq3qO8rM5XiBm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
\.vscode/ | ||
|
||
\.DS_Store | ||
|
||
*/__pycache__/* | ||
**/__pycache__/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
dist: trusty | ||
sudo: false | ||
git: | ||
depth: false | ||
env: | ||
global: | ||
- CC_TEST_REPORTER_ID=53eef44d00d3465aeaf806ea310cfc5497e7473d13ae05fbc753890c39712c60 | ||
addons: | ||
sonarcloud: | ||
organization: "lucacappelletti94-github" | ||
token: | ||
secure: "VZoBh0CW+W8IP5f6yeTwYQ54R6Rth8asJaPcVK8xwdCH0C69/QXG1AwMn/B9ccUN0QpiMxcJp/fcYBHGmYaCzEKsXMxd7iL3CI3jn4CC7XpEN4qBzkMcxfp8mjMegkXAjXb6ZutTTZ+0F2I1SRHmgcDpyUHL7xdQEHNXu3EAj05+Ez3EtsEE2g7J3AhVXlDAI6CWxE0KoxRlTGpkOalsjdoh4wPDESJ1xQz5+BnbUCiACOCxC4nk9BU3Cs7FY5b3EakwyetoA/YcviItVzbKd5+Aq57KDKMpwwKQyazvxaJA8yjgkmCHq79NB2wzfCtN02uuCMrQqVfXUFDAKSJLkrKfl6h4bmhAPJ8HPt1oQo5FON2EHYX4qN/JOXV1viaqtMqBLz6QOHllXMNJrz0BuktjS7lsV6a/52OjDurVEc+DXHwwiJxg4nOCTjanqZm6OueZ/DUIIiSHmVcNz4BevHhXLf4c5TSUKdYVPz9+Zzg2tf/wa6IRpBVvq76dp+T65rDUQqU+NwpzQgT5cedFF/oh5Ciiu+FI7cHGXJtCSEu3mV90QfABbb5f3wE5sXIEUKVVm227Sh8xbD3Pd+rG/z6ty9Xr906qA45nsZrl/tmAtwjXfQ0vB+N+QsUFXrgCce8jWMIdqlU0uaVSSyljPRVwLQxYMIr4SuNuYTX8tlA=" | ||
language: python | ||
python: | ||
- '3.6' | ||
before_install: | ||
- pip install --upgrade pytest | ||
install: | ||
- pip install .[test] | ||
before_script: | ||
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
- chmod +x ./cc-test-reporter | ||
- ./cc-test-reporter before-build | ||
after_script: | ||
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT | ||
script: | ||
- rm -rf .coverage | ||
- coverage erase | ||
- pytest --cov=environments_utils --cov-report xml:coverage.xml | ||
- coverage report | ||
- coverage xml | ||
- sonar-scanner | ||
|
||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
environments_utils | ||
===================================================================================== | ||
|travis| |sonar_quality| |sonar_maintainability| |sonar_coverage| |code_climate_maintainability| |pip| | ||
|
||
Utilities to identify which environments is your python script running within. | ||
|
||
How do I get this? | ||
---------------------------------- | ||
As usual, just run pip: | ||
|
||
.. code:: bash | ||
pip install environments_utils | ||
is_tmux | ||
----------------------------------- | ||
Return a boolean representing if script is running within a TMUX-like terminal. | ||
|
||
.. code:: python | ||
from environments_utils import is_tmux | ||
if not is_tmux(): | ||
print("This script is long running, consider starting it within a TMUX-like terminal.") | ||
is_notebook | ||
----------------------------------- | ||
Return a boolean representing if script is running within a jupyter notebook. | ||
|
||
.. code:: python | ||
from environments_utils import is_notebook | ||
from tqdm import tqdm_notebook, tqdm as tqdm_cli | ||
tqdm = tqdm_notebook if is_notebook() else tqdm_cli | ||
.. |travis| image:: https://travis-ci.org/LucaCappelletti94/environments_utils.png | ||
:target: https://travis-ci.org/LucaCappelletti94/environments_utils | ||
|
||
.. |sonar_quality| image:: https://sonarcloud.io/api/project_badges/measure?project=LucaCappelletti94_environments_utils&metric=alert_status | ||
:target: https://sonarcloud.io/dashboard/index/LucaCappelletti94_environments_utils | ||
|
||
.. |sonar_maintainability| image:: https://sonarcloud.io/api/project_badges/measure?project=LucaCappelletti94_environments_utils&metric=sqale_rating | ||
:target: https://sonarcloud.io/dashboard/index/LucaCappelletti94_environments_utils | ||
|
||
.. |sonar_coverage| image:: https://sonarcloud.io/api/project_badges/measure?project=LucaCappelletti94_environments_utils&metric=coverage | ||
:target: https://sonarcloud.io/dashboard/index/LucaCappelletti94_environments_utils | ||
|
||
.. |code_climate_maintainability| image:: https://api.codeclimate.com/v1/badges/25fb7c6119e188dbd12c/maintainability | ||
:target: https://codeclimate.com/github/LucaCappelletti94/environments_utils/maintainability | ||
:alt: Maintainability | ||
|
||
.. |pip| image:: https://badge.fury.io/py/environments_utils.svg | ||
:target: https://badge.fury.io/py/environments_utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .is_notebook import is_notebook | ||
from .is_tmux import is_tmux | ||
|
||
|
||
__all__ = ["is_notebook", "is_tmux"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def is_notebook()->bool: | ||
"""Return a boolean representing if script is running within a jupyter notebook.""" | ||
try: | ||
return get_ipython().__class__.__name__ == 'ZMQInteractiveShell' | ||
except NameError: | ||
pass | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import os | ||
|
||
def is_tmux()->bool: | ||
"""Return a boolean representing if script is running within a TMUX-like terminal.""" | ||
return "TMUX" in os.environ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import os | ||
import re | ||
import sys | ||
# To use a consistent encoding | ||
from codecs import open | ||
from os import path | ||
|
||
from setuptools import find_packages, setup | ||
|
||
here = path.abspath(path.dirname(__file__)) | ||
|
||
# Get the long description from the relevant file | ||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f: | ||
long_description = f.read() | ||
|
||
|
||
def read(*parts): | ||
with open(os.path.join(here, *parts), 'r') as fp: | ||
return fp.read() | ||
|
||
|
||
def find_version(*file_paths): | ||
version_file = read(*file_paths) | ||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) | ||
if version_match: | ||
return version_match.group(1) | ||
raise RuntimeError("Unable to find version string.") | ||
|
||
|
||
__version__ = find_version("environments_utils", "__version__.py") | ||
|
||
test_deps = ['pytest', 'pytest-cov', 'coveralls', 'validate_version_code'] | ||
|
||
extras = { | ||
'test': test_deps, | ||
} | ||
|
||
setup( | ||
name='environments_utils', | ||
|
||
# Versions should comply with PEP440. For a discussion on single-sourcing | ||
# the version across setup.py and the project code, see | ||
# https://packaging.python.org/en/latest/single_source_version.html | ||
version=__version__, | ||
|
||
description='Utilities to identify which environments is your python script running within.', | ||
long_description=long_description, | ||
|
||
# The project's main homepage. | ||
url='https://github.com/LucaCappelletti94/environments_utils', | ||
|
||
# Author details | ||
author='Luca Cappelletti', | ||
author_email='cappelletti.luca94@gmail.com', | ||
|
||
# Choose your license | ||
license='MIT', | ||
|
||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
classifiers=[ | ||
# How mature is this project? Common values are | ||
# 3 - Alpha | ||
# 4 - Beta | ||
# 5 - Production/Stable | ||
'Development Status :: 5 - Production/Stable', | ||
|
||
# Pick your license as you wish (should match "license" above) | ||
'License :: OSI Approved :: MIT License', | ||
|
||
# Specify the Python versions you support here. In particular, ensure | ||
# that you indicate whether you support Python 2, Python 3 or both. | ||
'Programming Language :: Python :: 3' | ||
], | ||
# You can just specify the packages manually here if your project is | ||
# simple. Or you can use find_packages(). | ||
packages=find_packages(exclude=['contrib', 'docs', 'tests*']), | ||
|
||
# List run-time dependencies here. These will be installed by pip when | ||
# your project is installed. For an analysis of "install_requires" vs pip's | ||
# requirements files see: | ||
# https://packaging.python.org/en/latest/requirements.html | ||
tests_require=test_deps, | ||
extras_require=extras, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ===================================================== | ||
# Meta-data for the project | ||
# ===================================================== | ||
sonar.projectName=environments_utils | ||
sonar.projectKey=LucaCappelletti94_environments_utils | ||
sonar.projectVersion=1.0.0 | ||
sonar.organization=lucacappelletti94-github | ||
sonar.host.url=https://sonarcloud.io | ||
sonar.login=environments_utils | ||
|
||
sonar.links.homepage=https://github.com/LucaCappelletti94/environments_utils | ||
sonar.links.ci=https://travis-ci.org/LucaCappelletti94/environments_utils | ||
sonar.links.scm=https://github.com/LucaCappelletti94/environments_utils | ||
sonar.links.issue=https://github.com/LucaCappelletti94/environments_utils/issues | ||
|
||
sonar.language=py | ||
|
||
sonar.sources=./environments_utils | ||
sonar.tests=./tests | ||
|
||
sonar.exclusions=**/__pycache__/*,*/__pycache__/* | ||
|
||
sonar.python.coverage.reportPath=coverage.xml |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from environments_utils import is_notebook | ||
|
||
def test_is_notebook(): | ||
is_notebook() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from environments_utils import is_tmux | ||
|
||
def test_is_tmux(): | ||
is_tmux() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from validate_version_code import validate_version_code | ||
from environments_utils.__version__ import __version__ | ||
|
||
def test_version(): | ||
assert validate_version_code(__version__) |