class Column(GridBase): # A container that lives in a Row _view_name = Unicode('ColumnView', sync=True) context = Enum(bs.Context, sync=True) background = Enum(bs.Context, sync=True) extra_small = _MaybeInt() small = _MaybeInt() medium = Int(1, allow_none=True, sync=True) large = _MaybeInt() offset_extra_small = _MaybeInt() offset_small = _MaybeInt() offset_medium = _MaybeInt() offset_large = _MaybeInt() push_extra_small = _MaybeInt() push_small = _MaybeInt() push_medium = _MaybeInt() push_large = _MaybeInt() pull_extra_small = _MaybeInt() pull_small = _MaybeInt() pull_medium = _MaybeInt() pull_large = _MaybeInt() __mul__ = _make_op() __add__ = _make_op("offset_%s") __gt__ = _make_op("push_%s") __lt__ = _make_op("pull_%s")
class Row(GridBase): """ A container """ _view_name = Unicode('RowView', sync=True) context = Enum(bs.Context, sync=True) background = Enum(bs.Context, sync=True)
class ButtonGroup(InstallerMixin, widgets.Box): """ A Group of Buttons """ _view_name = Unicode('ipbs/ButtonGroupView', sync=True) size = Enum(Size, default_value=Size.default, sync=True) orientation = Enum(Orientation, default_value=Orientation.horizontal, sync=True) justification = Enum(Justification, sync=True)
class Button(InstallerMixin, widgets.Button): """ A Button, with optional header and footer. """ _view_name = Unicode('ipbs/ButtonView', sync=True) # bootstrap context color context = Enum(Context, default_value=Context.default, sync=True) size = Enum(Size, default_value=Size.default, sync=True) body = Any(sync=True)
class Icon(InstallerMixin, widgets.DOMWidget): """ A widget which can show one or more icons """ icons = List(sync=True) size = Enum(Size, sync=True) context = Enum(bs.Context, sync=True) _view_name = Unicode('IconView', sync=True) _view_module = Unicode('nbextensions/ipbs/js/widget_icon', sync=True) def __init__(self, *args, **kwargs): kwargs["icons"] = list(args) + kwargs.pop("icons", []) super(Icon, self).__init__(**kwargs)
class ShaderMaterial(Material): _view_name = Unicode('ShaderMaterialView', sync=True) fragmentShader = Unicode('void main(){ }', sync=True) vertexShader = Unicode('void main(){ }', sync=True) morphTargets = Bool(False, sync=True) lights = Bool(False, sync=True) morphNormals = Bool(False, sync=True) wireframe = Bool(False, sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors', sync=True) skinning = Bool(False, sync=True) fog = Bool(False, sync=True) shading = Enum(['SmoothShading', 'FlatShading', 'NoShading'], 'SmoothShading', sync=True) linewidth = CFloat(1.0, sync=True) wireframeLinewidth = CFloat(1.0, sync=True)
class BasicMaterial(Material): _view_name = Unicode('BasicMaterialView', sync=True) color = Color('yellow', sync=True) wireframe = Bool(False, sync=True) wireframeLinewidth = CFloat(1.0, sync=True) wireframeLinecap = Unicode('round', sync=True) wireframeLinejoin = Unicode('round', sync=True) shading = Enum(['SmoothShading', 'FlatShading', 'NoShading'], 'SmoothShading', sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors', sync=True) fog = Bool(False, sync=True) map = Instance(Texture, sync=True) lightMap = Instance(Texture, sync=True) specularMap = Instance(Texture, sync=True) envMap = Instance(Texture, sync=True) skinning = Bool(False, sync=True) morphTargets = Bool(False, sync=True)
class IsCompleteReply(Reference): status = Enum((u'complete', u'incomplete', u'invalid', u'unknown')) def check(self, d): Reference.check(self, d) if d['status'] == 'incomplete': IsCompleteReplyIncomplete().check(d)
class OInfoReply(Reference): name = Unicode() found = Bool() ismagic = Bool() isalias = Bool() namespace = Enum((u'builtin', u'magics', u'alias', u'Interactive')) type_name = Unicode() string_form = Unicode() base_class = Unicode() length = Integer() file = Unicode() definition = Unicode() argspec = Dict() init_definition = Unicode() docstring = Unicode() init_docstring = Unicode() class_docstring = Unicode() call_def = Unicode() call_docstring = Unicode() source = Unicode() def check(self, d): for tst in Reference.check(self, d): yield tst if d['argspec'] is not None: for tst in ArgSpec().check(d['argspec']): yield tst
class LambertMaterial(BasicMaterial): _view_name = Unicode('LambertMaterialView', sync=True) ambient = Color('white', sync=True) emissive = Color('black', sync=True) reflectivity = CFloat(1.0, sync=True) refractionRatio = CFloat(0.98, sync=True) combine = Enum(['MultiplyOperation', 'MixOperation', 'AddOperation'], 'MultiplyOperation', sync=True)
class IPEngineSetJob(WinHPCJob): job_name = Unicode('IPEngineSet', config=False) is_exclusive = Bool(False, config=True) username = Unicode(find_username(), config=True) priority = Enum(('Lowest','BelowNormal','Normal','AboveNormal','Highest'), default_value='Highest', config=True) requested_nodes = Unicode('', config=True) project = Unicode('IPython', config=True)
class Renderer(DOMWidget): _view_name = Unicode('RendererView', sync=True) width = CInt(600, sync=True) height = CInt(400, sync=True) renderer_type = Enum(['webgl', 'canvas', 'auto'], 'auto', sync=True) scene = Instance(Scene, sync=True) camera = Instance(Camera, sync=True) controls = Instance(Controls, sync=True)
class LineBasicMaterial(Material): _view_name = Unicode('LineBasicMaterialView', sync=True) color = Color('yellow', sync=True) linewidth = CFloat(1.0, sync=True) linecap = Unicode('round', sync=True) linejoin = Unicode('round', sync=True) fog = Bool(False, sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors', sync=True)
class LineDashedMaterial(Material): _view_name = Unicode('LineDashedMaterialView', sync=True) color = Color('yellow', sync=True) linewidth = CFloat(1.0, sync=True) scale = CFloat(1.0, sync=True) dashSize = CFloat(3.0, sync=True) gapSize = CFloat(1.0, sync=True) vertexColors = Enum(['NoColors', 'FaceColors', 'VertexColors'], 'NoColors', sync=True) fog = Bool(False, sync=True)
class FloatSliderWidget(_BoundedFloatWidget): _view_name = Unicode('FloatSliderView', sync=True) orientation = Enum([u'horizontal', u'vertical'], u'horizontal', help="Vertical or horizontal.", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
class PhongMaterial(BasicMaterial): _view_name = Unicode('PhongMaterialView', sync=True) ambient = Color('white', sync=True) emissive = Color('black', sync=True) specular = Color('darkgray', sync=True) shininess = CFloat(30, sync=True) reflectivity = CFloat(1.0, sync=True) refractionRatio = CFloat(0.98, sync=True) combine = Enum(['MultiplyOperation', 'MixOperation', 'AddOperation'], 'MultiplyOperation', sync=True)
class IntRangeSlider(_BoundedIntRange): _view_name = Unicode('IntSliderView', sync=True) orientation = Enum([u'horizontal', u'vertical'], u'horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(True, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
class ExecuteReply(Reference): execution_count = Integer() status = Enum((u'ok', u'error')) def check(self, d): Reference.check(self, d) if d['status'] == 'ok': ExecuteReplyOkay().check(d) elif d['status'] == 'error': ExecuteReplyError().check(d)
class Parity(HasTraits): value = Int(0) parity = Enum(['odd', 'even'], default_value='even') def _value_validate(self, value, trait): if self.parity == 'even' and value % 2: raise TraitError('Expected an even number') if self.parity == 'odd' and (value % 2 == 0): raise TraitError('Expected an odd number') return value
class IntSlider(_BoundedInt): """Slider widget that represents a int bounded by a minimum and maximum value.""" _view_name = Unicode('IntSliderView', sync=True) orientation = Enum([u'horizontal', u'vertical'], u'horizontal', help="Vertical or horizontal.", sync=True) _range = Bool(False, help="Display a range selector", sync=True) readout = Bool(True, help="Display the current value of the slider next to it.", sync=True)
class Label(InstallerMixin, widgets.DOMWidget): """ Just some text... """ _view_name = Unicode('ipbs/LabelView', sync=True) value = Unicode(sync=True) html = Bool(False, sync=True) lead = Bool(False, sync=True) align = Enum(bs.Alignment, sync=True) # 3.2? transform = Enum(bs.Transformation, sync=True) # bootstrap context color context = Enum(bs.Context, default_value=bs.Context.default, sync=True) def __init__(self, value=None, **kwargs): if value is not None: kwargs["value"] = value super(Label, self).__init__(**kwargs)
class ExecuteReply(Reference): execution_count = Integer() status = Enum(('ok', 'error')) def check(self, d): for tst in Reference.check(self, d): yield tst if d['status'] == 'ok': for tst in ExecuteReplyOkay().check(d): yield tst elif d['status'] == 'error': for tst in ExecuteReplyError().check(d): yield tst
class NBExtensionApp(BaseIPythonApplication): """Entry point for installing notebook extensions""" description = """Install IPython notebook extensions Usage ipython install-nbextension file [more files, folders, archives or urls] This copies files and/or folders into the IPython nbextensions directory. If a URL is given, it will be downloaded. If an archive is given, it will be extracted into nbextensions. If the requested files are already up to date, no action is taken unless --overwrite is specified. """ examples = """ ipython install-nbextension /path/to/d3.js /path/to/myextension """ aliases = aliases flags = flags overwrite = Bool(False, config=True, help="Force overwrite of existing files") symlink = Bool(False, config=True, help="Create symlinks instead of copying files") verbose = Enum((0, 1, 2), default_value=1, config=True, help="Verbosity level") def install_extensions(self): install_nbextension( self.extra_args, overwrite=self.overwrite, symlink=self.symlink, verbose=self.verbose, ipython_dir=self.ipython_dir, ) def start(self): if not self.extra_args: nbext = pjoin(self.ipython_dir, u'nbextensions') print("Notebook extensions in %s:" % nbext) for ext in os.listdir(nbext): print(u" %s" % ext) else: self.install_extensions()
class Material(Widget): _view_name = Unicode('MaterialView', sync=True) # id = TODO name = Unicode('', sync=True) side = Enum(['FrontSide', 'BackSide', 'DoubleSide'], 'DoubleSide', sync=True) opacity = CFloat(1.0, sync=True) transparent = Bool(False, sync=True) blending = Enum(['NoBlending', 'NormalBlending', 'AdditiveBlending', 'SubtractiveBlending', 'MultiplyBlending', 'CustomBlending'], 'NormalBlending', sync=True) blendSrc = Enum(['ZeroFactor', 'OneFactor', 'SrcColorFactor', 'OneMinusSrcColorFactor', 'SrcAlphaFactor', 'OneMinusSrcAlphaFactor', 'DstAlphaFactor', 'OneMinusDstAlphaFactor'], 'SrcAlphaFactor', sync=True) blendDst = Enum(['DstColorFactor', 'OneMinusDstColorFactor', 'SrcAlphaSaturateFactor'], 'OneMinusDstColorFactor', sync=True) blendEquation = Enum(['AddEquation', 'SubtractEquation', 'ReverseSubtractEquation'], 'AddEquation', sync=True) depthTest = Bool(True, sync=True) depthWrite = Bool(True, sync=True) polygonOffset = Bool(False, sync=True) polygonOffsetFactor = CFloat(1.0, sync=True) polygonOffsetUnits = CFloat(1.0, sync=True) alphaTest = CFloat(1.0, sync=True) overdraw = CFloat(1.0, sync=True) visible = Bool(True, sync=True) needsUpdate = Bool(True, sync=True)
class Panel(InstallerMixin, widgets.DOMWidget): """ A Panel, with optional header and footer. """ _view_name = Unicode('PanelView', sync=True) _view_module = Unicode('nbextensions/ipbs/js/widget_panel', sync=True) # bootstrap context color context = Enum(Context, default_value=Context.default, sync=True) # all of these take either a string or a list of widgets title = Any(sync=True) body = Any(sync=True) heading = Any(sync=True) footer = Any(sync=True)
class BinaryView(DOMWidget): _view_module = Unicode('nbextensions/bitjet/bitjet', sync=True) _view_name = Unicode('BinaryView', sync=True) _model_module = Unicode('nbextensions/bitjet/bitjet', sync=True) _model_name = Unicode('BinaryModel', sync=True) datawidth = Int(2, sync=True) if ndarray: data = (Bytes(sync=True, to_json=b64encode_json) | Instance(ndarray, sync=True, to_json=b64encode_json)) else: data = Bytes(sync=True, to_json=b64encode_json) blockwidth = Int(4, sync=True) blockheight = Int(4, sync=True) height = Int(200, sync=True) width = Int(800, sync=True) bits_per_block = Enum([1, 8], default_value=1, sync=True)
class DataTexture(Texture): _view_name = Unicode('DataTextureView', sync=True) data = List(CInt, sync=True) format = Enum(['RGBAFormat', 'AlphaFormat', 'RGBFormat', 'LuminanceFormat', 'LuminanceAlphaFormat'], 'RGBAFormat', sync=True) width = CInt(256, sync=True) height = CInt(256, sync=True) type = Enum(['UnsignedByteType', 'ByteType', 'ShortType', 'UnsignedShortType', 'IntType', 'UnsignedIntType', 'FloatType', 'UnsignedShort4444Type', 'UnsignedShort5551Type', 'UnsignedShort565Type'], 'UnsignedByteType', sync=True) mapping = Enum(['UVMapping', 'CubeReflectionMapping', 'CubeRefractionMapping', 'SphericalReflectionMapping', 'SphericalRefractionMapping'], 'UVMapping', sync=True) wrapS = Enum(['ClampToEdgeWrapping', 'RepeatWrapping', 'MirroredRepeatWrapping'], 'ClampToEdgeWrapping', sync=True) wrapT = Enum(['ClampToEdgeWrapping', 'RepeatWrapping', 'MirroredRepeatWrapping'], 'ClampToEdgeWrapping', sync=True) magFilter = Enum(['LinearFilter', 'NearestFilter'], 'LinearFilter', sync=True) minFilter = Enum(['NearestFilter', 'NearestMipMapNearestFilter', 'NearestMipMapLinearFilter', 'LinearFilter', 'LinearMipMapNearestFilter'], 'NearestFilter', sync=True) anisotropy = CInt(1, sync=True)
class NotebookExporter(Exporter): """Exports to an IPython notebook.""" nbformat_version = Enum(list(nbformat.versions), default_value=nbformat.current_nbformat, config=True, help="""The nbformat version to write. Use this to downgrade notebooks. """ ) def _file_extension_default(self): return '.ipynb' output_mimetype = 'application/json' def from_notebook_node(self, nb, resources=None, **kw): nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw) if self.nbformat_version != nb_copy.nbformat: resources['output_suffix'] = '.v%i' % self.nbformat_version else: resources['output_suffix'] = '.nbconvert' output = nbformat.writes(nb_copy, version=self.nbformat_version) return output, resources
class Parameter(EmbeddedDocument): name = Unicode() param_type = Enum(default_value="String", values=param_types) default = Any() value = Any(db=False) description = Unicode() #parent_ref = ObjectIdTrait(allow_none = True) def __eq__(self, other): return hash(self) == hash(other) def __hash__(self): return hash(self.id) def repr_name(self): return self.name def __str__(self): return self.name def __unicode__(self): return self.name
class NotebookApp(BaseIPythonApplication): name = 'ipython-notebook' default_config_file_name='ipython_notebook_config.py' description = """ The IPython HTML Notebook. This launches a Tornado based HTML Notebook Server that serves up an HTML5/Javascript Notebook client. """ examples = _examples classes = [IPKernelApp, ZMQInteractiveShell, ProfileDir, Session, MappingKernelManager, NotebookManager] flags = Dict(flags) aliases = Dict(aliases) kernel_argv = List(Unicode) log_level = Enum((0,10,20,30,40,50,'DEBUG','INFO','WARN','ERROR','CRITICAL'), default_value=logging.INFO, config=True, help="Set the log level by value or name.") # create requested profiles by default, if they don't exist: auto_create = Bool(True) # Network related information. ip = Unicode(LOCALHOST, config=True, help="The IP address the notebook server will listen on." ) def _ip_changed(self, name, old, new): if new == u'*': self.ip = u'' port = Integer(8888, config=True, help="The port the notebook server will listen on." ) certfile = Unicode(u'', config=True, help="""The full path to an SSL/TLS certificate file.""" ) keyfile = Unicode(u'', config=True, help="""The full path to a private key file for usage with SSL/TLS.""" ) password = Unicode(u'', config=True, help="""Hashed password to use for web authentication. To generate, type in a python/IPython shell: from IPython.lib import passwd; passwd() The string should be of the form type:salt:hashed-password. """ ) open_browser = Bool(True, config=True, help="Whether to open in a browser after starting.") read_only = Bool(False, config=True, help="Whether to prevent editing/execution of notebooks." ) webapp_settings = Dict(config=True, help="Supply overrides for the tornado.web.Application that the " "IPython notebook uses.") enable_mathjax = Bool(True, config=True, help="""Whether to enable MathJax for typesetting math/TeX MathJax is the javascript library IPython uses to render math/LaTeX. It is very large, so you may want to disable it if you have a slow internet connection, or for offline use of the notebook. When disabled, equations etc. will appear as their untransformed TeX source. """ ) def _enable_mathjax_changed(self, name, old, new): """set mathjax url to empty if mathjax is disabled""" if not new: self.mathjax_url = u'' mathjax_url = Unicode("", config=True, help="""The url for MathJax.js.""" ) def _mathjax_url_default(self): if not self.enable_mathjax: return u'' static_path = self.webapp_settings.get("static_path", os.path.join(os.path.dirname(__file__), "static")) if os.path.exists(os.path.join(static_path, 'mathjax', "MathJax.js")): self.log.info("Using local MathJax") return u"/static/mathjax/MathJax.js" else: self.log.info("Using MathJax from CDN") return u"http://cdn.mathjax.org/mathjax/latest/MathJax.js" def _mathjax_url_changed(self, name, old, new): if new and not self.enable_mathjax: # enable_mathjax=False overrides mathjax_url self.mathjax_url = u'' else: self.log.info("Using MathJax: %s", new) def parse_command_line(self, argv=None): super(NotebookApp, self).parse_command_line(argv) if argv is None: argv = sys.argv[1:] # Scrub frontend-specific flags self.kernel_argv = swallow_argv(argv, notebook_aliases, notebook_flags) # Kernel should inherit default config file from frontend self.kernel_argv.append("--KernelApp.parent_appname='%s'"%self.name) def init_configurables(self): # force Session default to be secure default_secure(self.config) # Create a KernelManager and start a kernel. self.kernel_manager = MappingKernelManager( config=self.config, log=self.log, kernel_argv=self.kernel_argv, connection_dir = self.profile_dir.security_dir, ) self.notebook_manager = NotebookManager(config=self.config, log=self.log) self.notebook_manager.list_notebooks() def init_logging(self): super(NotebookApp, self).init_logging() # This prevents double log messages because tornado use a root logger that # self.log is a child of. The logging module dipatches log messages to a log # and all of its ancenstors until propagate is set to False. self.log.propagate = False def init_webapp(self): """initialize tornado webapp and httpserver""" self.web_app = NotebookWebApplication( self, self.kernel_manager, self.notebook_manager, self.log, self.webapp_settings ) if self.certfile: ssl_options = dict(certfile=self.certfile) if self.keyfile: ssl_options['keyfile'] = self.keyfile else: ssl_options = None self.web_app.password = self.password self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) if ssl_options is None and not self.ip and not (self.read_only and not self.password): self.log.critical('WARNING: the notebook server is listening on all IP addresses ' 'but not using any encryption or authentication. This is highly ' 'insecure and not recommended.') # Try random ports centered around the default. from random import randint n = 50 # Max number of attempts, keep reasonably large. for port in range(self.port, self.port+5) + [self.port + randint(-2*n, 2*n) for i in range(n-5)]: try: self.http_server.listen(port, self.ip) except socket.error, e: if e.errno != errno.EADDRINUSE: raise self.log.info('The port %i is already in use, trying another random port.' % port) else: self.port = port break