当前位置: 首页>>代码示例>>Python>>正文


Python utils.ujoin函数代码示例

本文整理汇总了Python中notebook.utils.ujoin函数的典型用法代码示例。如果您正苦于以下问题:Python ujoin函数的具体用法?Python ujoin怎么用?Python ujoin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ujoin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialize

def initialize(webapp, notebook_dir, connection_url, settings):
    if os.name == 'nt':
        default_shell = 'powershell.exe'
    else:
        default_shell = which('sh')
    shell = settings.get('shell_command',
        [os.environ.get('SHELL') or default_shell]
    )
    # Enable login mode - to automatically source the /etc/profile script
    if os.name != 'nt':
        shell.append('-l')
    terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(
        shell_command=shell,
        extra_env={'JUPYTER_SERVER_ROOT': notebook_dir,
                   'JUPYTER_SERVER_URL': connection_url,
                   },
    )
    terminal_manager.log = app_log
    base_url = webapp.settings['base_url']
    handlers = [
        (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
        (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
             {'term_manager': terminal_manager}),
        (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
        (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
    ]
    webapp.add_handlers(".*$", handlers)
开发者ID:ian-r-rose,项目名称:notebook,代码行数:27,代码来源:__init__.py

示例2: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    webapp = nbapp.web_app
    base_url = webapp.settings['base_url']

    webapp.add_handlers(".*$", [
        (ujoin(base_url, r"/nbextensions"), NBExtensionHandler),
        (ujoin(base_url, r"/nbextensions/"), NBExtensionHandler),
        (ujoin(base_url, r"/nbextensions/config/rendermd/(.*)"), RenderExtensionHandler),
    ])
开发者ID:Feldman-Michael,项目名称:masterthesis,代码行数:9,代码来源:nbextensions.py

示例3: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    webapp = nbapp.web_app
    base_url = webapp.settings['base_url']
    mdregex = r'([^"\'>]+.md)'
    webapp.add_handlers(".*$", [
        (ujoin(base_url, r"/rendermd/%s" % mdregex), RenderExtensionHandler),
        (ujoin(base_url, r"/nbextensions"), NBExtensionHandler),
        (ujoin(base_url, r"/nbextensions/"), NBExtensionHandler)
    ])
开发者ID:dtpryce,项目名称:IPython-notebook-extensions,代码行数:9,代码来源:nbextensions.py

示例4: _get_lab_config

    def _get_lab_config(self, manifest):
        """Get the config data for the page template."""
        static_prefix = ujoin(self.base_url, PREFIX)
        labextensions = self.labextensions
        main = manifest['main']['entry']
        bundles = [ujoin(static_prefix, name + '.bundle.js') for name in
                   ['loader', 'main']]
        entries = []

        # Only load CSS files if they exist.
        css_files = []
        for css_file in ['main.css']:
            if os.path.isfile(os.path.join(BUILT_FILES, css_file)):
                css_files.append(ujoin(static_prefix, css_file))

        configData = dict(
            terminalsAvailable=self.settings.get('terminals_available', False),
        )

        # Gather the lab extension files and entry points.
        for (name, data) in sorted(labextensions.items()):
            for value in data.values():
                if not isinstance(value, dict):
                    continue
                if value.get('entry', None):
                    entries.append(value['entry'])
                    bundles.append('%s/%s/%s' % (
                        self.extension_prefix, name, value['files'][0]
                    ))
                for fname in value['files']:
                    if os.path.splitext(fname)[1] == '.css':
                        css_files.append('%s/%s/%s' % (
                            self.extension_prefix, name, fname
                        ))
            python_module = data.get('python_module', None)
            if python_module:
                try:
                    value = get_labextension_config_python(python_module)
                    configData.update(value)
                except Exception as e:
                    self.log.error(e)

        mathjax_config = self.settings.get('mathjax_config',
                                           'TeX-AMS_HTML-full,Safe')
        config = dict(
            static_prefix=static_prefix,
            page_title='JupyterLab Alpha Preview',
            mathjax_url=self.mathjax_url,
            mathjax_config=mathjax_config,
            jupyterlab_main=main,
            jupyterlab_css=css_files,
            jupyterlab_bundles=bundles,
            plugin_entries=entries,
        )
        config['jupyterlab_config'] = configData
        return config
开发者ID:rlugojr,项目名称:jupyterlab,代码行数:56,代码来源:extension.py

示例5: get

    def get(self):
        static_prefix = ujoin(self.base_url, PREFIX)
        labextensions = self.application.labextensions
        data = get_labextension_manifest_data_by_folder(BUILT_FILES)
        if 'main' not in data or 'extensions' not in data:
            msg = ('JupyterLab build artifacts not detected, please see ' + 
                   'CONTRIBUTING.md for build instructions.')
            self.log.error(msg)
            self.write(self.render_template('error.html', 
                       status_code=500, 
                       status_message='JupyterLab Error',
                       page_title='JupyterLab Error',
                       message=msg))
            return

        main = data['main']['entry']
        bundles = [ujoin(static_prefix, name + '.bundle.js') for name in
                   ['loader', 'main', 'extensions']]
        entries = [data['extensions']['entry']]

        # Only load CSS files if they exist.
        css_files = []
        for css_file in ['main.css', 'extensions.css']:
            if os.path.isfile(os.path.join(BUILT_FILES, css_file)):
                css_files.append(ujoin(static_prefix, css_file))

        # Gather the lab extension files and entry points.
        for name in labextensions:
            data = get_labextension_manifest_data_by_name(name)
            if data is None:
                self.log.warn('Could not locate extension: ' + name)
                continue
            for value in data.values():
                if value.get('entry', None):
                    entries.append(value['entry'])
                    bundles.append('%s/%s/%s' % (
                        EXTENSION_PREFIX, name, value['files'][0]
                    ))
                for fname in value['files']:
                    if os.path.splitext(fname)[1] == '.css':
                        css_files.append('%s/%s/%s' % (
                            EXTENSION_PREFIX, name, fname
                        ))

        self.write(self.render_template('lab.html',
            static_prefix=static_prefix,
            page_title='JupyterLab Alpha Preview',
            terminals_available=self.settings['terminals_available'],
            mathjax_url=self.mathjax_url,
            jupyterlab_main=main,
            jupyterlab_css=css_files,
            jupyterlab_bundles=bundles,
            plugin_entries=entries,
            mathjax_config='TeX-AMS_HTML-full,Safe',
            #mathjax_config=self.mathjax_config # for the next release of the notebook
        ))
开发者ID:danielballan,项目名称:jupyterlab,代码行数:56,代码来源:__init__.py

示例6: initialize

def initialize(webapp):
    shell = os.environ.get('SHELL') or 'sh'
    terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(shell_command=[shell])
    terminal_manager.log = app_log
    base_url = webapp.settings['base_url']
    handlers = [
        (ujoin(base_url, r"/terminals/(\w+)"), TerminalHandler),
        (ujoin(base_url, r"/terminals/websocket/(\w+)"), TermSocket,
             {'term_manager': terminal_manager}),
        (ujoin(base_url, r"/api/terminals"), api_handlers.TerminalRootHandler),
        (ujoin(base_url, r"/api/terminals/(\w+)"), api_handlers.TerminalHandler),
    ]
    webapp.add_handlers(".*$", handlers)
开发者ID:AFJay,项目名称:notebook,代码行数:13,代码来源:__init__.py

示例7: get

 def get(self, action):
     example_id = self.get_argument('example_id')
     if action == 'preview':
         self.finish(self.manager.preview_example(example_id))
     elif action == 'fetch':
         dest = self.get_argument('dest')
         dest = self.manager.fetch_example(example_id, dest)
         self.redirect(ujoin(self.base_url, 'notebooks', dest))
     elif action == 'submit':
         dest = self.manager.submit_example(example_id)
         self.redirect(ujoin(self.base_url, 'tree#examples' + dest))
     elif action == 'delete':
         self.manager.delete_example(example_id)
         self.redirect(ujoin(self.base_url))
开发者ID:danielballan,项目名称:nbexamples,代码行数:14,代码来源:handlers.py

示例8: get

 def get(self, action):
     example_id = self.get_argument('example_id')
     if action == 'preview':
         self.finish(self.manager.preview_example(example_id))
     elif action == 'fetch':
         dest = self.get_argument('dest')
         self.manager.fetch_example(example_id, dest)
         # nbconvert appends '.ipynb' if it isn't present
         if not dest.endswith('.ipynb'):
             dest += '.ipynb'
         self.redirect(ujoin(self.base_url, 'notebooks', dest))
     elif action == 'submit':
         dest = self.manager.submit_example(example_id)
         preview_url = '/examples/preview?example_id={}'.format(dest)
         self.redirect(ujoin(self.base_url, preview_url))
开发者ID:ericdill,项目名称:nbexamples,代码行数:15,代码来源:handlers.py

示例9: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    webapp = nbapp.web_app
    base_url = webapp.settings['base_url']

    zsd = find_zotero_styles_dir()
    if zsd:
        webapp.add_handlers(".*$", [
            (ujoin(base_url, r"/cite2c/styles/?"), ListStylesHandler,
             {'path': zsd}),
            (ujoin(base_url, r"/cite2c/styles/(.+)"), StaticFileHandler,
             {'path': zsd}),
        ])
    else:
        nbapp.log.warning('Could not find Zotero citation styles directory.')

    webapp.add_handlers(".*$", zotero_oauth.handlers(base_url))
开发者ID:takluyver,项目名称:cite2c,代码行数:16,代码来源:handlers.py

示例10: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load and initialise the server extension."""
    logger = ConfiguratorLogger(nbapp.log)
    logger.debug('Loading {}'.format(__version__))
    webapp = nbapp.web_app

    # ensure our template gets into search path
    templates_dir = os.path.join(os.path.dirname(__file__), 'templates')
    logger.debug('  Editing templates path to add {}'.format(templates_dir))
    rootloader = webapp.settings['jinja2_env'].loader
    for loader in getattr(rootloader, 'loaders', [rootloader]):
        if hasattr(loader, 'searchpath') and \
                templates_dir not in loader.searchpath:
            loader.searchpath.append(templates_dir)

    base_url = webapp.settings['base_url']

    # make sure our static files are available
    static_files_path = os.path.normpath(os.path.join(
        os.path.dirname(__file__), 'static'))
    logger.debug(
        '  Editing nbextensions path to add {}'.format(static_files_path))
    if static_files_path not in webapp.settings['nbextensions_path']:
        webapp.settings['nbextensions_path'].append(static_files_path)

    # add our new custom handlers
    logger.debug('  Adding new handlers')
    new_handlers = [(ujoin(base_url, '/nbextensions/' + u), h) for u, h in [
        (r"?", NBExtensionHandlerPage),
        (r"nbextensions_configurator/list$", NBExtensionHandlerJSON),
        (r"nbextensions_configurator/rendermd/(.*)", RenderExtensionHandler),
    ]]
    webapp.add_handlers(".*$", new_handlers)

    logger.info('enabled {}'.format(__version__))
开发者ID:Jupyter-contrib,项目名称:jupyter_nbextensions_configurator,代码行数:35,代码来源:__init__.py

示例11: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load the nbserver"""
    windows = sys.platform.startswith('win')
    webapp = nbapp.web_app
    webapp.settings['shared_manager'] = SharedManager(parent=nbapp)
    base_url = webapp.settings['base_url']

    install_nbextension(static, destination='nbshared', symlink=not windows, user=True)

    # cfgm = nbapp.config_manager
    # cfgm.update('tree', {
    #     'load_extensions': {
    #         'nbexamples/main': True,
    #     }
    # })
    # cfgm.update('notebook', {
    #     'load_extensions': {
    #         'nbexamples/submit-example-button': True,
    #     }
    # })

    webapp.add_handlers(".*$", [
        (ujoin(base_url, pat), handler)
        for pat, handler in default_handlers
    ])
开发者ID:Valdimus,项目名称:nbshared,代码行数:25,代码来源:handlers.py

示例12: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load the nbserver"""
    windows = sys.platform.startswith('win')
    webapp = nbapp.web_app
    webapp.settings['example_manager'] = Examples(parent=nbapp)
    base_url = webapp.settings['base_url']

    install_nbextension(static, destination='nbexamples', symlink=not windows,
                        user=True)
    cfgm = nbapp.config_manager
    cfgm.update('tree', {
        'load_extensions': {
            'nbexamples/main': True,
        }
    })
    cfgm.update('notebook', {
        'load_extensions': {
            'nbexamples/submit-example-button': True,
        }
    })

    ExampleActionHandler.base_url = base_url  # used to redirect after fetch
    webapp.add_handlers(".*$", [
        (ujoin(base_url, pat), handler)
        for pat, handler in default_handlers
    ])
开发者ID:jai11,项目名称:nbexamples,代码行数:26,代码来源:handlers.py

示例13: get

    def get(self, path="/"):
        config = self.nteract_config
        settings_dir = config.settings_dir
        assets_dir = config.assets_dir

        base_url = self.settings['base_url']
        url = ujoin(base_url, config.page_url, '/static/')

        # Handle page config data.
        page_config = dict()
        page_config.update(self.settings.get('page_config_data', {}))
        page_config.setdefault('appName', config.name)
        page_config.setdefault('appVersion', config.version)

        mathjax_config = self.settings.get('mathjax_config',
                                           'TeX-AMS_HTML-full,Safe')

        config = dict(
            page_title=config.page_title,
            mathjax_url=self.mathjax_url,
            mathjax_config=mathjax_config,
            page_config=page_config,
            public_url=url,
            contents_path=path,
            page=self.page,
        )
        self.write(self.render_template('index.html', **config))
开发者ID:captainsafia,项目名称:nteract,代码行数:27,代码来源:handlers.py

示例14: get

    def get(self, action):
        try:
            notebook_id = unquote(self.get_argument('notebook_id'))
            # Submit a notebook
            if action == 'submit':
                name = unquote(self.get_argument('name', default=None))
                dest = self.manager.storage.submit(notebook_id, name, True);
                self.finish(str(dest));

            # Delete a notebook
            elif action == 'delete':
                if self.manager.storage.delete(notebook_id):
                    self.finish("OK");
                else:
                    raise web.HTTPError(404, "Impossible to delete: %s" % notebook_id);

            # Preview a notebook
            elif action == 'preview':
                self.finish(self.manager.storage.preview(notebook_id))

            # Fetch a notebook
            elif action == 'fetch':
                dest = unquote(self.get_argument('dest'))
                if not dest.endswith('.ipynb'):
                    dest += '.ipynb'
                url = quote(self.manager.storage.fetch(notebook_id, dest));
                self.redirect(ujoin(self.base_url, 'notebooks', url))

            else:
                self.finish("%s is not a valid action!" % action);
        except Exception as e:
            self.log.error("Error happen when do %s on %s" % (action, notebook_id))
            self.log.error(str(e));
            raise web.HTTPError(500, "Error happen when do %s on %s" % (action, notebook_id));
开发者ID:Valdimus,项目名称:nbshared,代码行数:34,代码来源:handlers.py

示例15: load_jupyter_server_extension

def load_jupyter_server_extension(nbapp):
    """Load the nbserver"""

    c = Config()
    c.FormgradeApp.authenticator_class = 'notebookauth.NotebookAuth'
    c.BaseAuth.connect_ip = nbapp.ip
    c.BaseAuth.connect_port = nbapp.port
    c.BaseAuth.url_prefix = '/formgrader'
    c.NotebookAuth.notebook_base_url = nbapp.base_url
    c.NotebookAuth.notebook_url_prefix = "instructor"
    c.NbGrader.log_level = nbapp.log_level
    c.NbGrader.course_directory = os.path.join(os.getcwd(), "instructor")

    formgrader = FormgradeApp(parent=nbapp)
    formgrader.update_config(c)
    super(FormgradeApp, formgrader).initialize([])
    formgrader.init_tornado_settings()
    formgrader.init_handlers()

    # update handlers
    webapp = nbapp.web_app
    base_url = webapp.settings["base_url"]
    handlers = []
    for handler in formgrader.handlers:
        handler = list(handler)
        handler[0] = ujoin(base_url, handler[0])
        handlers.append(tuple(handler))
    webapp.add_handlers(".*$", handlers)

    # update settings
    formgrader.tornado_settings['nbgrader_mathjax_url'] = webapp.settings['mathjax_url']
    formgrader.tornado_settings['log_function'] = webapp.settings['log_function']
    webapp.settings.update(formgrader.tornado_settings)
开发者ID:bryanwweber,项目名称:nbgrader-demo,代码行数:33,代码来源:formgrade_extension.py


注:本文中的notebook.utils.ujoin函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。