-
Notifications
You must be signed in to change notification settings - Fork 25
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
a2b9b03
commit 4eb8acd
Showing
33 changed files
with
157 additions
and
46 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,36 @@ | ||
name: Publish Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and publish dash-bootstrap-templates to PyPI and TestPyPI | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install . build | ||
- name: Build package | ||
run: python -m build --sdist --wheel --outdir dist/ | ||
|
||
# - name: Publish dash-bootstrap-templates to TestPyPI | ||
# uses: pypa/[email protected] | ||
# with: | ||
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
# repository_url: https://test.pypi.org/legacy/ | ||
|
||
# - name: Publish dash-bootstrap-templates to PyPI | ||
# uses: pypa/[email protected] | ||
# with: | ||
# password: ${{ secrets.PYPI_API_TOKEN }} |
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,8 @@ | ||
# python build artifacts | ||
__pycache__ | ||
*.egg-info | ||
.ipynb_checkpoints | ||
build | ||
dist | ||
venv | ||
.idea |
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
[build-system] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] | ||
|
||
[tool.setuptools_scm] |
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,41 @@ | ||
|
||
[metadata] | ||
name = dash-bootstrap-templates | ||
description = A collection of Plotly figure templates with a Bootstrap theme | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
license = MIT | ||
author = AnnMarieW | ||
# author_email = | ||
url = https://github.com/AnnMarieW/dash-bootstrap-templates | ||
classifiers = | ||
Development Status :: 3 - Alpha | ||
Framework :: Dash | ||
License :: OSI Approved :: MIT License | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
Topic :: Scientific/Engineering :: Visualization | ||
|
||
[options] | ||
package_dir= | ||
=src | ||
packages=find: | ||
include_package_data = True | ||
install_requires = | ||
dash | ||
dash-bootstrap-components | ||
importlib_metadata>=3.4.0,<4.0.0; python_version == "3.7" | ||
importlib_resources>=5.1.0,<6.0.0; python_version < "3.9" | ||
numpy | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.package_data] | ||
dash_bootstrap_templates = templates/*.json | ||
|
||
[options.extras_require] | ||
dev = | ||
tinycss2 | ||
spectra |
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,66 @@ | ||
import json | ||
|
||
import plotly.io as pio | ||
|
||
try: | ||
from importlib.resources import files | ||
except ImportError: | ||
# if using Python 3.8 or lower import from the backport | ||
from importlib_resources import files | ||
|
||
try: | ||
from importlib.metadata import ( | ||
PackageNotFoundError, | ||
version, | ||
) | ||
except ModuleNotFoundError: | ||
# if using Python 3.7, import from the backport | ||
from importlib_metadata import ( | ||
PackageNotFoundError, | ||
version, | ||
) | ||
|
||
try: | ||
__version__ = version("dash_bootstrap_templates") | ||
except PackageNotFoundError: | ||
# package is not installed | ||
pass | ||
""" | ||
Use this function to make the bootstrap figure templates available in your Dash app | ||
""" | ||
|
||
|
||
def read_template(theme): | ||
try: | ||
with ( | ||
files("dash_bootstrap_templates") / "templates" / f"{theme}.json" | ||
).open() as f: | ||
template = json.load(f) | ||
except IOError: | ||
with ( | ||
files("dash_bootstrap_templates") / "templates" / "bootstrap.json" | ||
).open() as f: | ||
template = json.load(f) | ||
pio.templates[theme] = template | ||
|
||
|
||
def load_figure_template(themes="bootstrap"): | ||
"""Add figure template to plotly.io and sets the default template | ||
Keyword arguments: | ||
themes -- may be a string or list of strings. (Default "bootstrap") | ||
The string is the lowercase name of a Bootstrap theme | ||
built in _create_templates.py | ||
The plotly.io.templates.default will be the first theme if | ||
themes is a list. If the themes attribute is invalid, the | ||
"bootstrap" theme will be used. | ||
""" | ||
if type(themes) is list: | ||
for theme in themes: | ||
read_template(theme) | ||
pio.templates.default = themes[0] | ||
|
||
else: | ||
read_template(themes) | ||
pio.templates.default = themes |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.