mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-06 11:35:24 +08:00
move DeprecatedClass to widgets, where it's used
avoids need to add warn to genutils
This commit is contained in:
parent
855799dc19
commit
d41d074c1e
22
IPython/html/widgets/deprecated.py
Normal file
22
IPython/html/widgets/deprecated.py
Normal file
@ -0,0 +1,22 @@
|
||||
"""Decorator for warning about deprecated widget classes"""
|
||||
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from warnings import warn
|
||||
|
||||
|
||||
def DeprecatedClass(base, class_name):
|
||||
"""Warn about a deprecated class on instantiation"""
|
||||
# Hook the init method of the base class.
|
||||
def init_hook(self, *pargs, **kwargs):
|
||||
base.__init__(self, *pargs, **kwargs)
|
||||
|
||||
# Warn once per class.
|
||||
if base not in DeprecatedClass._warned_classes:
|
||||
DeprecatedClass._warned_classes.append(base)
|
||||
warn('"{}" is deprecated, please use "{}" instead.'.format(
|
||||
class_name, base.__name__))
|
||||
return type(class_name, (base,), {'__init__': init_hook})
|
||||
|
||||
DeprecatedClass._warned_classes = []
|
@ -1,25 +1,16 @@
|
||||
"""Bool class.
|
||||
"""Bool class.
|
||||
|
||||
Represents a boolean using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget, register
|
||||
from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
class _Bool(DOMWidget):
|
||||
"""A base class for creating widgets that represent booleans."""
|
||||
value = Bool(False, help="Bool value", sync=True)
|
||||
|
@ -8,7 +8,7 @@ Represents a container that can be used to group other widgets.
|
||||
|
||||
from .widget import DOMWidget, Widget, register
|
||||
from IPython.utils.traitlets import Unicode, Tuple, TraitError, Int, CaselessStrEnum
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
def _widget_to_json(x):
|
||||
if isinstance(x, dict):
|
||||
|
@ -1,26 +1,17 @@
|
||||
"""Button class.
|
||||
"""Button class.
|
||||
|
||||
Represents a button in the frontend using a widget. Allows user to listen for
|
||||
click events on the button and trigger backend code when the clicks are fired.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget, CallbackDispatcher, register
|
||||
from IPython.utils.traitlets import Unicode, Bool, CaselessStrEnum
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
@register('IPython.Button')
|
||||
class Button(DOMWidget):
|
||||
"""Button widget.
|
||||
|
@ -2,26 +2,17 @@
|
||||
|
||||
Represents an unbounded float using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget, register
|
||||
from .trait_types import Color
|
||||
from IPython.utils.traitlets import (Unicode, CFloat, Bool, CaselessStrEnum,
|
||||
Tuple, TraitError)
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
class _Float(DOMWidget):
|
||||
value = CFloat(0.0, help="Float value", sync=True)
|
||||
disabled = Bool(False, help="Enable or disable user changes", sync=True)
|
||||
|
@ -1,27 +1,17 @@
|
||||
"""Image class.
|
||||
"""Image class.
|
||||
|
||||
Represents an image in the frontend using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import base64
|
||||
|
||||
from .widget import DOMWidget, register
|
||||
from IPython.utils.traitlets import Unicode, CUnicode, Bytes
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
@register('IPython.Image')
|
||||
class Image(DOMWidget):
|
||||
"""Displays an image as a widget.
|
||||
|
@ -2,26 +2,17 @@
|
||||
|
||||
Represents an unbounded int using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget, register
|
||||
from .trait_types import Color
|
||||
from IPython.utils.traitlets import (Unicode, CInt, Bool, CaselessStrEnum,
|
||||
Tuple, TraitError)
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
class _Int(DOMWidget):
|
||||
"""Base class used to create widgets that represent an int."""
|
||||
value = CInt(0, help="Int value", sync=True)
|
||||
|
@ -2,17 +2,9 @@
|
||||
|
||||
Represents an enumeration using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from collections import OrderedDict
|
||||
from threading import Lock
|
||||
@ -22,11 +14,9 @@ from IPython.utils.traitlets import (
|
||||
Unicode, Bool, Any, Dict, TraitError, CaselessStrEnum, Tuple, List
|
||||
)
|
||||
from IPython.utils.py3compat import unicode_type
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# SelectionWidget
|
||||
#-----------------------------------------------------------------------------
|
||||
class _Selection(DOMWidget):
|
||||
"""Base class for Selection widgets
|
||||
|
||||
|
@ -3,24 +3,14 @@
|
||||
Represents a multipage container that can be used to group other widgets into
|
||||
pages.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget_box import Box, register
|
||||
from IPython.utils.traitlets import Unicode, Dict, CInt
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
class _SelectionContainer(Box):
|
||||
"""Base class used to display multiple child widgets."""
|
||||
_titles = Dict(help="Titles of the pages", sync=True)
|
||||
|
@ -1,25 +1,16 @@
|
||||
"""String class.
|
||||
"""String class.
|
||||
|
||||
Represents a unicode string using a widget.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from .widget import DOMWidget, CallbackDispatcher, register
|
||||
from IPython.utils.traitlets import Unicode, Bool
|
||||
from IPython.utils.warn import DeprecatedClass
|
||||
from .deprecated import DeprecatedClass
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
class _String(DOMWidget):
|
||||
"""Base class used to create widgets that represent a string."""
|
||||
value = Unicode(help="String value", sync=True)
|
||||
|
Loading…
Reference in New Issue
Block a user