|
2 | 2 | import os |
3 | 3 | import sys |
4 | 4 |
|
5 | | -from dash_bootstrap_components import icons # noqa |
6 | | -from dash_bootstrap_components import themes # noqa |
7 | | -from dash_bootstrap_components import _components |
| 5 | +from dash_bootstrap_components import _components, icons, themes |
8 | 6 | from dash_bootstrap_components._components import * # noqa |
9 | 7 | from dash_bootstrap_components._table import _generate_table_from_df |
10 | 8 | from dash_bootstrap_components._version import __version__ |
11 | 9 |
|
12 | | -_current_path = os.path.dirname(os.path.abspath(__file__)) |
| 10 | +__all__ = _components.__all__ + ["icons", "themes"] |
13 | 11 |
|
14 | | -METADATA_PATH = os.path.join(_current_path, "_components", "metadata.json") |
| 12 | +_current_path = os.path.dirname(os.path.abspath(__file__)) |
| 13 | +_METADATA_PATH = os.path.join(_current_path, "_components", "metadata.json") |
15 | 14 |
|
16 | 15 | _js_dist = [ |
17 | 16 | { |
18 | 17 | "relative_package_path": ( |
19 | 18 | "_components/dash_bootstrap_components.min.js" |
20 | 19 | ), |
21 | 20 | "external_url": ( |
22 | | - "https://unpkg.com/dash-bootstrap-components@{}" |
| 21 | + f"https://unpkg.com/dash-bootstrap-components@{__version__}" |
23 | 22 | "/dist/dash_bootstrap_components.min.js" |
24 | | - ).format(__version__), |
| 23 | + ), |
25 | 24 | "namespace": "dash_bootstrap_components", |
26 | 25 | } |
27 | 26 | ] |
|
38 | 37 | sys.modules[__name__].Table.from_dataframe = classmethod( |
39 | 38 | _generate_table_from_df |
40 | 39 | ) |
| 40 | + |
| 41 | + |
| 42 | +# TODO: when Python 3.6 support is dropped we can simplify this with PEP 562 |
| 43 | +# https://www.python.org/dev/peps/pep-0562/ |
| 44 | +class _V1DeprecationWarningWrapper: |
| 45 | + def __init__(self, wrapped, deprecated): |
| 46 | + self.wrapped = wrapped |
| 47 | + self.deprecated = deprecated |
| 48 | + |
| 49 | + def __getattr__(self, name): |
| 50 | + if name in self.deprecated: |
| 51 | + # TODO: update URL before release |
| 52 | + raise AttributeError( |
| 53 | + f"{name} was deprecated in dash-bootstrap-components version " |
| 54 | + f"1.0.0. You are using {__version__}. For more details please " |
| 55 | + "see the migration guide: " |
| 56 | + "https://dbc-v1.herokuapp.com/migration-guide/" |
| 57 | + ) |
| 58 | + return getattr(self.wrapped, name) |
| 59 | + |
| 60 | + def __dir__(self): |
| 61 | + # required for autocomplete. filter out os, and sys imports |
| 62 | + return [ |
| 63 | + item |
| 64 | + for item in self.wrapped.__dir__() |
| 65 | + if item not in {"os", "sys"} |
| 66 | + ] |
| 67 | + |
| 68 | + |
| 69 | +sys.modules[__name__] = _V1DeprecationWarningWrapper( |
| 70 | + sys.modules[__name__], |
| 71 | + [ |
| 72 | + "CardColumns", |
| 73 | + "CardDeck", |
| 74 | + "FormGroup", |
| 75 | + "InputGroupAddon", |
| 76 | + "Jumbotron", |
| 77 | + "ListGroupItemHeading", |
| 78 | + "ListGroupItemText", |
| 79 | + ], |
| 80 | +) |
0 commit comments