id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
174,809 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Given a filename this will try to calculate the python path, add it to the search path and return the actual module name that is expected. |
174,810 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | null |
174,811 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | null |
174,812 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Wraps a callback so that it's guaranteed to be executed with the script's application context. Custom commands (and their options) registered under ``app.cli`` or ``blueprint.cli`` will always have an app context available, this decorator is not required in that case. .. versionchanged:: 2.2 The app context is active f... |
174,813 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | null |
174,814 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | null |
174,815 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | null |
174,816 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Take ``other`` and remove the length of ``path`` from it. Then join it to ``path``. If it is the original value, ``path`` is an ancestor of ``other``. |
174,817 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | The ``--key`` option must be specified when ``--cert`` is a file. Modifies the ``cert`` param to be a ``(cert, key)`` pair if needed. |
174,818 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Run a local development server. This server is for development purposes only. It does not provide the stability, security, or performance of production WSGI servers. The reloader and debugger are enabled by default with the '--debug' option. |
174,819 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Run an interactive Python shell in the context of a given Flask application. The application will populate the default namespace of this shell according to its configuration. This is useful for executing small snippets of management code without having to manually configure the application. |
174,820 | from __future__ import annotations
import ast
import inspect
import os
import platform
import re
import sys
import traceback
import typing as t
from functools import update_wrapper
from operator import attrgetter
import click
from click.core import ParameterSource
from werkzeug import run_simple
from werkzeug.serving i... | Show all registered routes with endpoints and methods. |
174,821 | import typing as t
from .app import Flask
from .blueprints import Blueprint
from .globals import request_ctx
class DebugFilesKeyError(KeyError, AssertionError):
"""Raised from request.files during debugging. The idea is that it can
provide a better error message than just a generic KeyError/BadRequest.
"""... | Patch ``request.files.__getitem__`` to raise a descriptive error about ``enctype=multipart/form-data``. :param request: The request to patch. :meta private: |
174,822 | import typing as t
from .app import Flask
from .blueprints import Blueprint
from .globals import request_ctx
def _dump_loader_info(loader) -> t.Generator:
yield f"class: {type(loader).__module__}.{type(loader).__name__}"
for key, value in sorted(loader.__dict__.items()):
if key.startswith("_"):
... | This should help developers understand what failed |
174,823 | import logging
import sys
import typing as t
from werkzeug.local import LocalProxy
from .globals import request
if t.TYPE_CHECKING: # pragma: no cover
from .app import Flask
import typing as t
request: "Request" = LocalProxy( # type: ignore[assignment]
_cv_request, "request", unbound_message=_no_req_msg
)
... | Find the most appropriate error stream for the application. If a request is active, log to ``wsgi.errors``, otherwise use ``sys.stderr``. If you configure your own :class:`logging.StreamHandler`, you may want to use this for the stream. If you are using file or dict configuration and can't import this directly, you can... |
174,824 | import logging
import sys
import typing as t
from werkzeug.local import LocalProxy
from .globals import request
def has_level_handler(logger: logging.Logger) -> bool:
"""Check if there is a handler in the logging chain that will handle the
given logger's :meth:`effective level <~logging.Logger.getEffectiveLevel... | Get the Flask app's logger and configure it if needed. The logger name will be the same as :attr:`app.import_name <flask.Flask.name>`. When :attr:`~flask.Flask.debug` is enabled, set the logger level to :data:`logging.DEBUG` if it is not set. If there is no handler for the logger's effective level, add a :class:`~loggi... |
174,825 | import contextvars
import sys
import typing as t
from functools import update_wrapper
from types import TracebackType
from werkzeug.exceptions import HTTPException
from . import typing as ft
from .globals import _cv_app
from .globals import _cv_request
from .signals import appcontext_popped
from .signals import appcont... | Executes a function after this request. This is useful to modify response objects. The function is passed the response object and has to return the same or a new one. Example:: @app.route('/') def index(): @after_this_request def add_header(response): response.headers['X-Foo'] = 'Parachute' return response return 'Hell... |
174,826 | import contextvars
import sys
import typing as t
from functools import update_wrapper
from types import TracebackType
from werkzeug.exceptions import HTTPException
from . import typing as ft
from .globals import _cv_app
from .globals import _cv_request
from .signals import appcontext_popped
from .signals import appcont... | A helper function that decorates a function to retain the current request context. This is useful when working with greenlets. The moment the function is decorated a copy of the request context is created and then pushed when the function is called. The current session is also included in the copied request context. Ex... |
174,827 | import contextvars
import sys
import typing as t
from functools import update_wrapper
from types import TracebackType
from werkzeug.exceptions import HTTPException
from . import typing as ft
from .globals import _cv_app
from .globals import _cv_request
from .signals import appcontext_popped
from .signals import appcont... | If you have code that wants to test if a request context is there or not this function can be used. For instance, you may want to take advantage of request information if the request object is available, but fail silently if it is unavailable. :: class User(db.Model): def __init__(self, username, remote_addr=None): sel... |
174,828 | import contextvars
import sys
import typing as t
from functools import update_wrapper
from types import TracebackType
from werkzeug.exceptions import HTTPException
from . import typing as ft
from .globals import _cv_app
from .globals import _cv_request
from .signals import appcontext_popped
from .signals import appcont... | Works like :func:`has_request_context` but for the application context. You can also just do a boolean check on the :data:`current_app` object instead. .. versionadded:: 0.9 |
174,829 | import functools
import inspect
import json
import logging
import os
import sys
import typing as t
import weakref
from collections.abc import Iterator as _abc_Iterator
from datetime import timedelta
from itertools import chain
from threading import Lock
from types import TracebackType
import click
from werkzeug.datastr... | null |
174,830 | import functools
import inspect
import json
import logging
import os
import sys
import typing as t
import weakref
from collections.abc import Iterator as _abc_Iterator
from datetime import timedelta
from itertools import chain
from threading import Lock
from types import TracebackType
import click
from werkzeug.datastr... | null |
174,831 | import importlib.util
import json
import os
import pathlib
import pkgutil
import sys
import typing as t
from collections import defaultdict
from datetime import timedelta
from functools import update_wrapper
from jinja2 import FileSystemLoader
from werkzeug.exceptions import default_exceptions
from werkzeug.exceptions ... | null |
174,832 | import importlib.util
import json
import os
import pathlib
import pkgutil
import sys
import typing as t
from collections import defaultdict
from datetime import timedelta
from functools import update_wrapper
from jinja2 import FileSystemLoader
from werkzeug.exceptions import default_exceptions
from werkzeug.exceptions ... | Internal helper that returns the default endpoint for a given function. This always is the function name. |
174,833 | import importlib.util
import json
import os
import pathlib
import pkgutil
import sys
import typing as t
from collections import defaultdict
from datetime import timedelta
from functools import update_wrapper
from jinja2 import FileSystemLoader
from werkzeug.exceptions import default_exceptions
from werkzeug.exceptions ... | Find the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). If the package is not installed to the system (:attr:`sys.prefix`) or a virtualenv (``site-packages``), ``None`` is returned. The path... |
174,834 | import typing as t
from contextvars import ContextVar
from werkzeug.local import LocalProxy
if t.TYPE_CHECKING: # pragma: no cover
from .app import Flask
from .ctx import _AppCtxGlobals
from .ctx import AppContext
from .ctx import RequestContext
from .sessions import SessionMixin
from .wrappers... | null |
174,835 | from __future__ import annotations
import dataclasses
import decimal
import json
import typing as t
import uuid
import weakref
from datetime import date
from werkzeug.http import http_date
from ..globals import request
if t.TYPE_CHECKING: # pragma: no cover
from ..app import Flask
from ..wrappers import Respon... | null |
174,836 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Get the environment the app is running in, indicated by the :envvar:`FLASK_ENV` environment variable. The default is ``'production'``. .. deprecated:: 2.2 Will be removed in Flask 2.3. |
174,837 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Get whether the user has disabled loading default dotenv files by setting :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load the files. :param default: What to return if the env var isn't set. |
174,838 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can be called instead of using a return and you will get a response o... |
174,839 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Generate a URL to the given endpoint with the given values. This requires an active request or application context, and calls :meth:`current_app.url_for() <flask.Flask.url_for>`. See that method for full documentation. :param endpoint: The endpoint name associated with the URL to generate. If this starts with a ``.``, ... |
174,840 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Create a redirect response object. If :data:`~flask.current_app` is available, it will use its :meth:`~flask.Flask.redirect` method, otherwise it will use :func:`werkzeug.utils.redirect`. :param location: The URL to redirect to. :param code: The status code for the redirect. :param Response: The response class to use. ... |
174,841 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Raise an :exc:`~werkzeug.exceptions.HTTPException` for the given status code. If :data:`~flask.current_app` is available, it will call its :attr:`~flask.Flask.aborter` object, otherwise it will use :func:`werkzeug.exceptions.abort`. :param code: The status code for the exception, which must be registered in ``app.abort... |
174,842 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Loads a macro (or variable) a template exports. This can be used to invoke a macro from within Python code. If you for example have a template named :file:`_cider.html` with the following contents: .. sourcecode:: html+jinja {% macro hello(name) %}Hello {{ name }}!{% endmacro %} You can access this from Python code lik... |
174,843 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Flashes a message to the next request. In order to remove the flashed message from the session and to display it to the user, the template has to call :func:`get_flashed_messages`. .. versionchanged:: 0.3 `category` parameter added. :param message: the message to be flashed. :param category: the category for the messag... |
174,844 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Pulls all flashed messages from the session and returns them. Further calls in the same request to the function will return the same messages. By default just the messages are returned, but when `with_categories` is set to ``True``, the return value will be a list of tuples in the form ``(category, message)`` instead. ... |
174,845 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Send the contents of a file to the client. The first argument can be a file path or a file-like object. Paths are preferred in most cases because Werkzeug can manage the file and get extra information from the path. Passing a file-like object requires that the file is opened in binary mode, and is mostly useful when bu... |
174,846 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Send a file from within a directory using :func:`send_file`. .. code-block:: python @app.route("/uploads/<path:name>") def download_file(name): return send_from_directory( app.config['UPLOAD_FOLDER'], name, as_attachment=True ) This is a secure way to serve files from a folder, such as static files or uploads. Uses :fu... |
174,847 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Find the root path of a package, or the path that contains a module. If it cannot be found, returns the current working directory. Not to be confused with the value returned by :func:`find_package`. :meta private: |
174,848 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | Determine if the given string is an IP address. :param value: value to check :type value: str :return: True if string is an IP address :rtype: bool |
174,849 | import os
import pkgutil
import socket
import sys
import typing as t
from datetime import datetime
from functools import lru_cache
from functools import update_wrapper
from threading import RLock
import werkzeug.utils
from werkzeug.exceptions import abort as _wz_abort
from werkzeug.utils import redirect as _wz_redirect... | null |
174,850 | import typing as t
from jinja2 import BaseLoader
from jinja2 import Environment as BaseEnvironment
from jinja2 import Template
from jinja2 import TemplateNotFound
from .globals import _cv_app
from .globals import _cv_request
from .globals import current_app
from .globals import request
from .helpers import stream_with_... | Default template context processor. Injects `request`, `session` and `g`. |
174,851 | import typing as t
from jinja2 import BaseLoader
from jinja2 import Environment as BaseEnvironment
from jinja2 import Template
from jinja2 import TemplateNotFound
from .globals import _cv_app
from .globals import _cv_request
from .globals import current_app
from .globals import request
from .helpers import stream_with_... | Render a template by name with the given context. :param template_name_or_list: The name of the template to render. If a list is given, the first name to exist will be rendered. :param context: The variables to make available in the template. |
174,852 | import typing as t
from jinja2 import BaseLoader
from jinja2 import Environment as BaseEnvironment
from jinja2 import Template
from jinja2 import TemplateNotFound
from .globals import _cv_app
from .globals import _cv_request
from .globals import current_app
from .globals import request
from .helpers import stream_with_... | Render a template from the given source string with the given context. :param source: The source code of the template to render. :param context: The variables to make available in the template. |
174,853 | import typing as t
from jinja2 import BaseLoader
from jinja2 import Environment as BaseEnvironment
from jinja2 import Template
from jinja2 import TemplateNotFound
from .globals import _cv_app
from .globals import _cv_request
from .globals import current_app
from .globals import request
from .helpers import stream_with_... | Render a template by name with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view. :param template_name_or_list: The name of the template to render. If a list is given, the first name to exist will be rendered. :param context: The variables to make ... |
174,854 | import typing as t
from jinja2 import BaseLoader
from jinja2 import Environment as BaseEnvironment
from jinja2 import Template
from jinja2 import TemplateNotFound
from .globals import _cv_app
from .globals import _cv_request
from .globals import current_app
from .globals import request
from .helpers import stream_with_... | Render a template from the given source string with the given context as a stream. This returns an iterator of strings, which can be used as a streaming response from a view. :param source: The source code of the template to render. :param context: The variables to make available in the template. .. versionadded:: 2.2 |
174,927 | import ctypes
from typing import no_type_check
The provided code snippet includes necessary dependencies for implementing the `send_interrupt` function. Write a Python function `def send_interrupt(interrupt_handle)` to solve the following problem:
Sends an interrupt event using the specified handle.
Here is the funct... | Sends an interrupt event using the specified handle. |
174,928 | import asyncio
import os
import socket
import typing as t
import uuid
from functools import wraps
import zmq
from traitlets import Any, Bool, Dict, DottedObjectName, Instance, Unicode, default, observe
from traitlets.config.configurable import LoggingConfigurable
from traitlets.utils.importstring import import_item
fro... | decorator for proxying MKM.method(kernel_id) to individual KMs by ID |
174,929 | import typing as t
import zmq
from tornado import ioloop
from traitlets import Instance, Type
from zmq.eventloop.zmqstream import ZMQStream
from ..manager import AsyncKernelManager, KernelManager
from .restarter import AsyncIOLoopKernelRestarter, IOLoopKernelRestarter
class ZMQStream:
"""A utility class to registe... | Convert a socket to a zmq stream. |
174,930 | import json
import os
import re
import shutil
import warnings
from jupyter_core.paths import SYSTEM_JUPYTER_PATH, jupyter_data_dir, jupyter_path
from traitlets import Bool, CaselessStrEnum, Dict, HasTraits, List, Set, Type, Unicode, observe
from traitlets.config import LoggingConfigurable
from .provisioning import Kern... | Return a mapping of kernel names to resource directories from dir. If dir is None or does not exist, returns an empty dict. |
174,931 | import json
import os
import re
import shutil
import warnings
from jupyter_core.paths import SYSTEM_JUPYTER_PATH, jupyter_data_dir, jupyter_path
from traitlets import Bool, CaselessStrEnum, Dict, HasTraits, List, Set, Type, Unicode, observe
from traitlets.config import LoggingConfigurable
from .provisioning import Kern... | Returns a dict mapping kernel names to resource directories. |
174,932 | import json
import os
import re
import shutil
import warnings
from jupyter_core.paths import SYSTEM_JUPYTER_PATH, jupyter_data_dir, jupyter_path
from traitlets import Bool, CaselessStrEnum, Dict, HasTraits, List, Set, Type, Unicode, observe
from traitlets.config import LoggingConfigurable
from .provisioning import Kern... | Returns a :class:`KernelSpec` instance for the given kernel_name. Raises KeyError if the given kernel name is not found. |
174,933 | import json
import os
import re
import shutil
import warnings
from jupyter_core.paths import SYSTEM_JUPYTER_PATH, jupyter_data_dir, jupyter_path
from traitlets import Bool, CaselessStrEnum, Dict, HasTraits, List, Set, Type, Unicode, observe
from traitlets.config import LoggingConfigurable
from .provisioning import Kern... | Install the native kernel spec. |
174,934 | import errno
import glob
import json
import os
import socket
import stat
import tempfile
import warnings
from getpass import getpass
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
import zmq
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
from traitlets import B... | Generates a JSON config file, including the selection of random ports. Parameters ---------- fname : unicode The path to the file to write shell_port : int, optional The port to use for ROUTER (shell) channel. iopub_port : int, optional The port to use for the SUB channel. stdin_port : int, optional The port to use for... |
174,935 | import errno
import glob
import json
import os
import socket
import stat
import tempfile
import warnings
from getpass import getpass
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
import zmq
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
from traitlets import B... | find a connection file, and return its absolute path. The current working directory and optional search path will be searched for the file if it is not given by absolute path. If the argument does not match an existing file, it will be interpreted as a fileglob, and the matching file in the profile's security dir with ... |
174,936 | import errno
import glob
import json
import os
import socket
import stat
import tempfile
import warnings
from getpass import getpass
from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
import zmq
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
from traitlets import B... | tunnel connections to a kernel via ssh This will open five SSH tunnels from localhost on this machine to the ports associated with the kernel. They can be either direct localhost-localhost tunnels, or if an intermediate server is necessary, the kernel must be listening on a public IP. Parameters ---------- connection_i... |
174,937 | import os
import sys
import warnings
from subprocess import PIPE, Popen
from typing import Any, Dict, List, Optional
from traitlets.log import get_logger
PIPE: int
class Popen(Generic[AnyStr]):
args: _CMD
stdin: Optional[IO[AnyStr]]
stdout: Optional[IO[AnyStr]]
stderr: Optional[IO[AnyStr]]
pid:... | Launches a localhost kernel, binding to the specified ports. Parameters ---------- cmd : Popen list, A string of Python code that imports and executes a kernel entry point. stdin, stdout, stderr : optional (default None) Standards streams, as defined in subprocess.Popen. env: dict, optional Environment variables passed... |
174,938 | import atexit
import os
import re
import signal
import socket
import sys
import warnings
from getpass import getpass, getuser
from multiprocessing import Process
def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None, timeout=60):
"""Open a tunneled connection from a 0MQ url.
For use inside tu... | Connect a socket to an address via an ssh tunnel. This is a wrapper for socket.connect(addr), when addr is not accessible from the local machine. It simply creates an ssh tunnel using the remaining args, and calls socket.connect('tcp://localhost:lport') where lport is the randomly selected local port of the tunnel. |
174,939 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | coerce unicode back to bytestrings. |
174,940 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Convert a json object to a bytes. |
174,941 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Convert a json bytes or string to an object. |
174,942 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Pack an object using the pickle module. |
174,943 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Set the default behavior for a config environment to be secure. If Session.key/keyfile have not been set, set Session.key to a new random UUID. |
174,944 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Create a new message header |
174,945 | import hashlib
import hmac
import json
import logging
import os
import pickle
import pprint
import random
import typing as t
import warnings
from binascii import b2a_hex
from datetime import datetime, timezone
from hmac import compare_digest
from typing import Optional, Union
import zmq.asyncio
from tornado.ioloop impo... | Given a message or header, return the header. |
174,946 | import math
import numbers
import re
import types
import warnings
from binascii import b2a_base64
from collections.abc import Iterable
from datetime import datetime
from typing import Optional, Union
from dateutil.parser import parse as _dateutil_parse
from dateutil.tz import tzlocal
def json_default(obj):
"""defau... | DEPRECATED: Use jupyter_client.jsonutil.json_default |
174,947 | from traitlets import Type
from ..channels import HBChannel, ZMQSocketChannel
from ..client import KernelClient, reqrep
from ..utils import run_sync
The provided code snippet includes necessary dependencies for implementing the `wrapped` function. Write a Python function `def wrapped(meth, channel)` to solve the follo... | Wrap a method on a channel and handle replies. |
174,948 | import os
import re
import socket
import subprocess
from subprocess import PIPE, Popen
from typing import Iterable, List
from warnings import warn
The provided code snippet includes necessary dependencies for implementing the `_only_once` function. Write a Python function `def _only_once(f)` to solve the following pro... | decorator to only run a function once |
174,949 | import os
import re
import socket
import subprocess
from subprocess import PIPE, Popen
from typing import Iterable, List
from warnings import warn
def _load_ips(suppress_exceptions=True):
"""load the IPs that point to this machine
This function will only ever be called once.
It will use netifaces to do it q... | decorator to ensure load_ips has been run before f |
174,950 | import os
import re
import socket
import subprocess
from subprocess import PIPE, Popen
from typing import Iterable, List
from warnings import warn
LOCAL_IPS: List = []
The provided code snippet includes necessary dependencies for implementing the `is_local_ip` function. Write a Python function `def is_local_ip(ip)` to... | does `ip` point to this machine? |
174,951 | import os
import re
import socket
import subprocess
from subprocess import PIPE, Popen
from typing import Iterable, List
from warnings import warn
PUBLIC_IPS: List = []
The provided code snippet includes necessary dependencies for implementing the `is_public_ip` function. Write a Python function `def is_public_ip(ip)`... | is `ip` a publicly visible address? |
174,952 | import asyncio
import inspect
import sys
import time
import typing as t
from functools import partial
from getpass import getpass
from queue import Empty
import zmq.asyncio
from jupyter_core.utils import ensure_async
from traitlets import Any, Bool, Instance, Type
from .channels import major_protocol_version
from .chan... | Validate that the input is a dict with string keys and values. Raises ValueError if not. |
174,953 | import asyncio
import inspect
import sys
import time
import typing as t
from functools import partial
from getpass import getpass
from queue import Empty
import zmq.asyncio
from jupyter_core.utils import ensure_async
from traitlets import Any, Bool, Instance, Type
from .channels import major_protocol_version
from .chan... | null |
174,954 | import asyncio
import functools
import os
import re
import signal
import sys
import typing as t
import uuid
from asyncio.futures import Future
from concurrent.futures import Future as CFuture
from contextlib import contextmanager
from enum import Enum
import zmq
from jupyter_core.utils import run_sync
from traitlets im... | Sets the kernel to a pending state by creating a fresh Future for the KernelManager's `ready` attribute. Once the method is finished, set the Future's results. |
174,955 | import asyncio
import functools
import os
import re
import signal
import sys
import typing as t
import uuid
from asyncio.futures import Future
from concurrent.futures import Future as CFuture
from contextlib import contextmanager
from enum import Enum
import zmq
from jupyter_core.utils import run_sync
from traitlets im... | Start a new kernel, and return its Manager and Client |
174,956 | import asyncio
import functools
import os
import re
import signal
import sys
import typing as t
import uuid
from asyncio.futures import Future
from concurrent.futures import Future as CFuture
from contextlib import contextmanager
from enum import Enum
import zmq
from jupyter_core.utils import run_sync
from traitlets im... | Context manager to create a kernel in a subprocess. The kernel is shut down when the context exits. Returns ------- kernel_client: connected KernelClient instance |
174,957 | import zmq.asyncio
from traitlets import Instance, Type
from ..channels import AsyncZMQSocketChannel, HBChannel
from ..client import KernelClient, reqrep
The provided code snippet includes necessary dependencies for implementing the `wrapped` function. Write a Python function `def wrapped(meth, channel)` to solve the ... | Wrap a method on a channel and handle replies. |
174,958 | import json
import re
from typing import Any, Dict, List, Tuple
from ._version import protocol_version_info
def code_to_line(code: str, cursor_pos: int) -> Tuple[str, int]:
"""Turn a multiline code block and cursor position into a single line
and new cursor position.
For adapting ``complete_`` and ``object_... | Reimplement token-finding logic from IPython 2.x javascript for adapting object_info_request from v5 to v4 |
174,959 | import json
import re
from typing import Any, Dict, List, Tuple
from ._version import protocol_version_info
List = _Alias()
The provided code snippet includes necessary dependencies for implementing the `_version_str_to_list` function. Write a Python function `def _version_str_to_list(version: str) -> List[int]` to s... | convert a version string to a list of ints non-int segments are excluded |
174,960 | import json
import re
from typing import Any, Dict, List, Tuple
from ._version import protocol_version_info
adapters = {
(5, 4): V5toV4(),
(4, 5): V4toV5(),
}
Any = object()
Dict = _Alias()
protocol_version_info = (5, 3)
def utcnow() -> datetime:
"""Return timezone-aware UTC timestamp... | Adapt a single message to a target version Parameters ---------- msg : dict A Jupyter message. to_version : int, optional The target major version. If unspecified, adapt to the current version. Returns ------- msg : dict A Jupyter message appropriate in the new version. |
175,031 | from __future__ import absolute_import, division, print_function
import collections
import itertools
import re
from ._structures import Infinity
def _parse_version_parts(s):
for part in _legacy_version_component_re.split(s):
part = _legacy_version_replacement_map.get(part, part)
if not part or part ... | null |
175,039 | from __future__ import absolute_import, division, print_function
import operator
import os
import platform
import sys
from pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd
from pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString
from pkg_resources.ext... | null |
175,040 | from __future__ import absolute_import, division, print_function
import operator
import os
import platform
import sys
from pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd
from pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString
from pkg_resources.ext... | null |
175,041 | from __future__ import absolute_import, division, print_function
import operator
import os
import platform
import sys
from pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd
from pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString
from pkg_resources.ext... | null |
175,042 | from __future__ import absolute_import, division, print_function
import operator
import os
import platform
import sys
from pkg_resources.extern.pyparsing import ParseException, ParseResults, stringStart, stringEnd
from pkg_resources.extern.pyparsing import ZeroOrMore, Group, Forward, QuotedString
from pkg_resources.ext... | null |
175,047 | from __future__ import annotations
import os
import sys
from configparser import ConfigParser
from pathlib import Path
from .api import PlatformDirsABC
def getuid() -> int:
raise RuntimeError("should only be used on Linux") | null |
175,048 | from __future__ import annotations
import os
import sys
from configparser import ConfigParser
from pathlib import Path
from .api import PlatformDirsABC
class Unix(PlatformDirsABC):
"""
On Unix/Linux, we follow the
`XDG Basedir Spec <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.htm... | Return directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/ |
175,049 | from __future__ import annotations
import ctypes
import os
import sys
from functools import lru_cache
from typing import Callable
from .api import PlatformDirsABC
def get_win_folder_from_env_vars(csidl_name: str) -> str:
"""Get folder from environment variables."""
if csidl_name == "CSIDL_PERSONAL": # does not... | null |
175,050 | from __future__ import annotations
import os
import re
import sys
from functools import lru_cache
from typing import cast
from .api import PlatformDirsABC
import sys
if sys.version_info >= (3, 8): # pragma: no cover (py38+)
from typing import Literal
else: # pragma: no cover (py38+)
from typing_extensions i... | :return: base folder for the Android OS or None if cannot be found |
175,051 | from __future__ import annotations
import os
import re
import sys
from functools import lru_cache
from typing import cast
from .api import PlatformDirsABC
The provided code snippet includes necessary dependencies for implementing the `_android_documents_folder` function. Write a Python function `def _android_documents... | :return: documents folder for the Android OS |
175,052 |
def EIRESID(x):
return -1 * (int)(x) | null |
175,053 | import pythoncom
import win32con
import win32gui
from win32com.shell import shell, shellcon
class ShellExtension:
_reg_progid_ = "Python.ShellExtension.CopyHook"
_reg_desc_ = "Python Sample Shell Extension (copy hook)"
_reg_clsid_ = "{1845b6ba-2bbd-4197-b930-46d8651497c1}"
_com_interfaces_ = [shell.IID_... | null |
175,054 | import pythoncom
import win32con
import win32gui
from win32com.shell import shell, shellcon
class ShellExtension:
_reg_progid_ = "Python.ShellExtension.CopyHook"
_reg_desc_ = "Python Sample Shell Extension (copy hook)"
_reg_clsid_ = "{1845b6ba-2bbd-4197-b930-46d8651497c1}"
_com_interfaces_ = [shell.IID_... | null |
175,055 | import pythoncom
import win32con
import win32gui
from win32com.shell import shell, shellcon
class ShellExtension:
def Initialize(self, folder, dataobj, hkey):
def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags):
def InvokeCommand(self, ci):
def GetCommandString(self, cmd, typ... | null |
175,056 | import pythoncom
import win32con
import win32gui
from win32com.shell import shell, shellcon
class ShellExtension:
_reg_progid_ = "Python.ShellExtension.ContextMenu"
_reg_desc_ = "Python Sample Shell Extension (context menu)"
_reg_clsid_ = "{CED0336C-C9EE-4a7f-8D7F-C660393C381F}"
_com_interfaces_ = [shel... | null |
175,057 | import _thread
import os
import pyclbr
import sys
import commctrl
import pythoncom
import win32api
import win32con
import win32gui
import win32gui_struct
import winerror
from pywin.scintilla import scintillacon
from win32com.server.exception import COMException
from win32com.server.util import NewEnum, wrap
from win32c... | null |
175,058 | import _thread
import os
import pyclbr
import sys
import commctrl
import pythoncom
import win32api
import win32con
import win32gui
import win32gui_struct
import winerror
from pywin.scintilla import scintillacon
from win32com.server.exception import COMException
from win32com.server.util import NewEnum, wrap
from win32c... | null |
175,059 | import _thread
import os
import pyclbr
import sys
import commctrl
import pythoncom
import win32api
import win32con
import win32gui
import win32gui_struct
import winerror
from pywin.scintilla import scintillacon
from win32com.server.exception import COMException
from win32com.server.util import NewEnum, wrap
from win32c... | null |
175,060 | import _thread
import os
import pyclbr
import sys
import commctrl
import pythoncom
import win32api
import win32con
import win32gui
import win32gui_struct
import winerror
from pywin.scintilla import scintillacon
from win32com.server.exception import COMException
from win32com.server.util import NewEnum, wrap
from win32c... | null |
175,061 | import os
import stat
import sys
import pythoncom
import win32gui
import winerror
from win32com.server.exception import COMException
from win32com.shell import shell, shellcon
class EmptyVolumeCache:
_reg_progid_ = "Python.ShellExtension.EmptyVolumeCache"
_reg_desc_ = "Python Sample Shell Extension (disk cleanu... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.