id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
171,967 | import os
import sys
import traceback
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import afxres, dialog, window
from pywin.mfc.thread import WinApp
from . import scriptutils
def RectToCreateStructRect(rect):
return (rect[3] - rect[1], rect[2] - rect[0], rect[1], rect[0]) | null |
171,968 | import os
import sys
import traceback
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import afxres, dialog, window
from pywin.mfc.thread import WinApp
from . import scriptutils
def _GetRegistryValue(key, val, default=None):
# val is registry value - None for default val.
try:
... | null |
171,969 | import os
import sys
import traceback
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import afxres, dialog, window
from pywin.mfc.thread import WinApp
from . import scriptutils
def Win32RawInput(prompt=None):
"Provide raw_input() for gui apps"
# flush stderr/out first.
try:
... | null |
171,970 | import os
import sys
import traceback
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import afxres, dialog, window
from pywin.mfc.thread import WinApp
from . import scriptutils
def HaveGoodGUI():
"""Returns true if we currently have a good gui available."""
return "pywin.framework.... | Checks and creates if necessary a default GUI environment. |
171,971 | import glob
import os
import re
import win32api
import win32con
import win32ui
from pywin.mfc import dialog, docview, window
from . import scriptutils
def getsubdirs(d):
dlist = []
flist = glob.glob(d + "\\*")
for f in flist:
if os.path.isdir(f):
dlist.append(f)
dlist = dlis... | null |
171,972 | import sys
The provided code snippet includes necessary dependencies for implementing the `fake_raw_input` function. Write a Python function `def fake_raw_input(prompt=None)` to solve the following problem:
Replacement for raw_input() which pulls lines out of global test_input. For testing only!
Here is the function:... | Replacement for raw_input() which pulls lines out of global test_input. For testing only! |
171,973 | import os
import win32api
import win32con
import win32ui
from pywin.mfc import docview, window
from . import app
bitmapTemplate = BitmapTemplate()
bitmapTemplate.SetDocStrings(
"\nBitmap\nBitmap\nBitmap (*.bmp)\n.bmp\nPythonBitmapFileType\nPython Bitmap File"
)
def t():
bitmapTemplate.OpenDocumentFile("d:\\win... | null |
171,974 | import os
import win32api
import win32con
import win32ui
from pywin.mfc import docview, window
from . import app
bitmapTemplate = BitmapTemplate()
bitmapTemplate.SetDocStrings(
"\nBitmap\nBitmap\nBitmap (*.bmp)\n.bmp\nPythonBitmapFileType\nPython Bitmap File"
)
def demo():
import glob
winDir = win32api.Ge... | null |
171,975 | import os
import sys
import traceback
import __main__
import commctrl
import win32api
import win32con
import win32ui
from pywin.mfc import afxres, dialog
from . import app, dbgcommands
from pywin.mfc import docview
def _SetupSharedMenu_(self):
sharedMenu = self.GetSharedMenu()
from pywin.framework import toolm... | null |
171,976 | import os
import regutil
import win32api
import win32con
import win32ui
htmlhelp_handle = None
def FinalizeHelp():
global htmlhelp_handle
if htmlhelp_handle is not None:
import win32help
try:
# frame = win32ui.GetMainFrame().GetSafeHwnd()
frame = 0
win32help... | null |
171,977 | import os
import regutil
import win32api
import win32con
import win32ui
def OpenHelpFile(fileName, helpCmd=None, helpArg=None):
"Open a help file, given a full path"
# default help arg.
win32ui.DoWaitCursor(1)
try:
if helpCmd is None:
helpCmd = win32con.HELP_CONTENTS
ext = os... | null |
171,978 | import bdb
import linecache
import os
import sys
import traceback
import __main__
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from pywin.mfc.docview import TreeView
from .cmdline import ParseArgs
def GetActiveView():
"""Gets the edit control (eg, EditView) with the focus, or None"""
... | Returns the active editor document and view, or (None,None) if no active document or its not an editor document. |
171,979 | import bdb
import linecache
import os
import sys
import traceback
import __main__
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from pywin.mfc.docview import TreeView
from .cmdline import ParseArgs
RS_DEBUGGER_NONE = 0
RS_DEBUGGER_STEP = 1
RS_DEBUGGER_GO = 2
RS_DEBUGGER_PM = 3
byte_cr ... | null |
171,980 | import bdb
import linecache
import os
import sys
import traceback
import __main__
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from pywin.mfc.docview import TreeView
from .cmdline import ParseArgs
def GetPackageModuleName(fileName):
"""Given a filename, return (module name, new path).... | This code looks for the current window, and determines if it can be imported. If not, it will prompt for a file name, and allow it to be imported. |
171,981 | import bdb
import linecache
import os
import sys
import traceback
import __main__
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from pywin.mfc.docview import TreeView
from .cmdline import ParseArgs
def GetActiveFileName(bAutoSave=1):
"""Gets the file name for the active frame, saving i... | This code looks for the current window, and gets Python to check it without actually executing any code (ie, by compiling only) |
171,982 | import sys
import win32api
import win32con
import win32ui
from . import app
defaultToolMenuItems = [
("Browser", "win32ui.GetApp().OnViewBrowse(0,0)"),
(
"Browse PythonPath",
"from pywin.tools import browseProjects;browseProjects.Browse()",
),
("Edit Python Path", "from pywin.tools impor... | null |
171,983 | import queue
import re
import win32api
import win32con
import win32ui
from pywin.framework import app, window
from pywin.mfc import docview
import pywin.scintilla.document
from pywin import default_scintilla_encoding
from pywin.scintilla import scintillacon
class WindowOutputViewRTF(docview.RichEditView, WindowOutputVi... | null |
171,984 | import queue
import re
import win32api
import win32con
import win32ui
from pywin.framework import app, window
from pywin.mfc import docview
import pywin.scintilla.document
from pywin import default_scintilla_encoding
from pywin.scintilla import scintillacon
import pywin.scintilla.view
def thread_test(o):
for i in ... | null |
171,985 | import sys
import commctrl
import win32api
import win32con
import win32ui
from pywin.mfc import dialog, docview, object, window
from win32api import RGB
def GetItemText(item):
if type(item) == type(()) or type(item) == type([]):
use = item[0]
else:
use = item
if type(use) == type(""):
... | null |
171,986 | import glob
import os
import pyclbr
import afxres
import commctrl
import pywin.framework.scriptutils
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from . import hierlist
class HLIModuleItem(hierlist.HierListItem):
def __init__(self, path):
hierlist.HierListItem._... | null |
171,987 | import glob
import os
import pyclbr
import afxres
import commctrl
import pywin.framework.scriptutils
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from . import hierlist
class HLIRoot(hierlist.HierListItem):
def __init__(self):
hierlist.HierListItem.__init__(self... | null |
171,988 | import glob
import os
import pyclbr
import afxres
import commctrl
import pywin.framework.scriptutils
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import dialog
from . import hierlist
def DockableBrowserCreator(parent):
root = HLIRoot()
hl = hierlist.HierListWithItems(root, win32u... | null |
171,989 | import _thread
import win32api
import win32event
import win32trace
from pywin.framework import winout
def CollectorThread(stopEvent, file):
win32trace.InitRead()
handle = win32trace.GetHandle()
# Run this thread at a lower priority to the main message-loop (and printing output)
# thread can keep up
... | null |
171,990 | import _thread
import win32api
import win32event
import win32trace
from pywin.framework import winout
outputWindow = None
class WindowOutput(winout.WindowOutput):
def __init__(self, *args):
winout.WindowOutput.__init__(*(self,) + args)
self.hStopThread = win32event.CreateEvent(None, 0, 0, None)
... | null |
171,991 | import commctrl
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import dialog, docview, window
from . import hierlist
def SafeApply(fn, args, err_desc=""):
try:
fn(*args)
return 1
except win32api.error as exc:
msg = "Error " + err_desc + "\r\n\r\n" + exc.str... | null |
171,992 | import commctrl
import regutil
import win32api
import win32con
import win32ui
from pywin.mfc import dialog, docview, window
from . import hierlist
template = RegTemplate()
def EditRegistry(root=None, key=None):
doc = template.OpenRegistryKey(root, key) | null |
171,993 | import commctrl
import dialog
import win32con
import win32ui
class RegistryPage(RegEditPropertyPage):
def __init__(self):
def OnInitDialog(self):
class RegistrySheet(dialog.PropertySheet):
def __init__(self, title):
def OnActivate(self, msg):
def t():
ps = RegistrySheet("Registry Settings")
... | null |
171,994 | import sys
import types
import __main__
import win32ui
from pywin.mfc import dialog
from . import hierlist
class DialogShowObject(dialog.Dialog):
def __init__(self, object, title):
self.object = object
self.title = title
dialog.Dialog.__init__(self, win32ui.IDD_LARGE_EDIT)
def OnInitDial... | null |
171,995 | import sys
import types
import __main__
import win32ui
from pywin.mfc import dialog
from . import hierlist
def MakeHLI(ob, name=None):
try:
cls = TypeMap[type(ob)]
except KeyError:
# hrmph - this check gets more and more bogus as Python
# improves. Its possible we should just *always* u... | Browse the argument, or the main dictionary |
171,996 | import sys
import types
import __main__
import win32ui
from pywin.mfc import dialog
from . import hierlist
def MakeHLI(ob, name=None):
try:
cls = TypeMap[type(ob)]
except KeyError:
# hrmph - this check gets more and more bogus as Python
# improves. Its possible we should just *always* u... | Browse an object using an MDI window. |
171,997 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | null |
171,998 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Show deprecation warning about a magic method definition. Uses warn_explicit to bind warning to method definition instead of triggering code, which isn't relevant. |
171,999 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Safely evaluate an expression Returns original string if eval fails. Use only where types are ambiguous. |
172,000 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Convert the name argument to a list of names. Examples -------- >>> parse_notifier_name([]) [traitlets.All] >>> parse_notifier_name("a") ['a'] >>> parse_notifier_name(["a", "b"]) ['a', 'b'] >>> parse_notifier_name(All) [traitlets.All] |
172,001 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Validate arguments for traitlet link functions |
172,002 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | null |
172,003 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | A decorator which can be used to observe Traits on a class. The handler passed to the decorator will be called with one ``change`` dict argument. The change dictionary at least holds a 'type' key and a 'name' key, corresponding respectively to the type of notification and the name of the attribute that triggered the no... |
172,004 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Backward-compatibility shim decorator for observers Use with: @observe('name') @observe_compat def _foo_changed(self, change): ... With this, `super()._foo_changed(self, name, old, new)` in subclasses will still work. Allows adoption of new observer API without breaking subclasses that override and super. |
172,005 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | A decorator to register cross validator of HasTraits object's state when a Trait is set. The handler passed to the decorator must have one ``proposal`` dict argument. The proposal dictionary must hold the following keys: * ``owner`` : the HasTraits instance * ``value`` : the proposed value for the modified trait attrib... |
172,006 | import contextlib
import enum
import inspect
import os
import re
import sys
import types
import typing as t
from ast import literal_eval
from warnings import warn, warn_explicit
from .utils.bunch import Bunch
from .utils.descriptions import add_article, class_of, describe, repr_type
from .utils.getargspec import getarg... | Validate that a number to be applied to a trait is between bounds. If value is not between min_bound and max_bound, this raises a TraitError with an error message appropriate for this trait. |
172,007 | import argparse
import copy
import functools
import json
import os
import re
import sys
import typing as t
import warnings
from traitlets.traitlets import Any, Container, Dict, HasTraits, List, Undefined
from ..utils import cast_unicode, filefind
def execfile(fname, glob):
with open(fname, "rb") as f:
exec... | null |
172,008 | import argparse
import copy
import functools
import json
import os
import re
import sys
import typing as t
import warnings
from traitlets.traitlets import Any, Container, Dict, HasTraits, List, Undefined
from ..utils import cast_unicode, filefind
The provided code snippet includes necessary dependencies for implementi... | Is a Config key a section name (does it start with a capital)? |
172,009 | import argparse
import copy
import functools
import json
import os
import re
import sys
import typing as t
import warnings
from traitlets.traitlets import Any, Container, Dict, HasTraits, List, Undefined
from ..utils import cast_unicode, filefind
class ConfigFileNotFound(ConfigError): # noqa
pass
class Config(dict... | Load multiple Python config files, merging each of them in turn. Parameters ---------- config_files : list of str List of config files names to load and merge into the config. path : unicode The full path to the location of the config files. |
172,010 | from collections import defaultdict
from textwrap import dedent
from traitlets import Undefined
from traitlets.utils.text import indent
The provided code snippet includes necessary dependencies for implementing the `setup` function. Write a Python function `def setup(app)` to solve the following problem:
Registers the... | Registers the Sphinx extension. You shouldn't need to call this directly; configure Sphinx to use this module instead. |
172,011 | from collections import defaultdict
from textwrap import dedent
from traitlets import Undefined
from traitlets.utils.text import indent
def class_config_rst_doc(cls, trait_aliases):
"""Generate rST documentation for this class' config options.
Excludes traits defined on parent classes.
"""
lines = []
... | Write a rst file documenting config options for a traitlets application. Parameters ---------- path : str The file to be written title : str The human-readable title of the document app : traitlets.config.Application An instance of the application class to be documented preamble : str Extra text to add just after the t... |
172,012 | import errno
import json
import os
from traitlets.config import LoggingConfigurable
from traitlets.traitlets import Unicode
The provided code snippet includes necessary dependencies for implementing the `recursive_update` function. Write a Python function `def recursive_update(target, new)` to solve the following prob... | Recursively update one dictionary using another. None values will delete their keys. |
172,013 | import functools
import json
import logging
import os
import pprint
import re
import sys
import typing as t
from collections import OrderedDict, defaultdict
from contextlib import suppress
from copy import deepcopy
from logging.config import dictConfig
from textwrap import dedent
from typing import Any, Callable, TypeV... | Method decorator for catching invalid config (Trait/ArgumentErrors) during init. On a TraitError (generally caused by bad config), this will print the trait's message, and exit the app. For use on init methods, to prevent invoking excepthook on invalid input. |
172,014 | import functools
import json
import logging
import os
import pprint
import re
import sys
import typing as t
from collections import OrderedDict, defaultdict
from contextlib import suppress
from copy import deepcopy
from logging.config import dictConfig
from textwrap import dedent
from typing import Any, Callable, TypeV... | Helper for building basic --trait, --no-trait flags. Parameters ---------- name : str The name of the flag. configurable : str The 'Class.trait' string of the trait to be set/unset with the flag set_help : unicode help string for --name flag unset_help : unicode help string for --no-name flag Returns ------- cfg : dict... |
172,015 | import functools
import json
import logging
import os
import pprint
import re
import sys
import typing as t
from collections import OrderedDict, defaultdict
from contextlib import suppress
from copy import deepcopy
from logging.config import dictConfig
from textwrap import dedent
from typing import Any, Callable, TypeV... | Get the config object for the global Application instance, if there is one otherwise return an empty config object |
172,016 | import inspect
import re
import types
The provided code snippet includes necessary dependencies for implementing the `repr_type` function. Write a Python function `def repr_type(obj)` to solve the following problem:
Return a string representation of a value and its type for readable error messages.
Here is the functi... | Return a string representation of a value and its type for readable error messages. |
172,017 |
The provided code snippet includes necessary dependencies for implementing the `nested_update` function. Write a Python function `def nested_update(this, that)` to solve the following problem:
Merge two nested dictionaries. Effectively a recursive ``dict.update``. Examples -------- Merge two flat dictionaries: >>> ne... | Merge two nested dictionaries. Effectively a recursive ``dict.update``. Examples -------- Merge two flat dictionaries: >>> nested_update( ... {'a': 1, 'b': 2}, ... {'b': 3, 'c': 4} ... ) {'a': 1, 'b': 3, 'c': 4} Merge two nested dictionaries: >>> nested_update( ... {'x': {'a': 1, 'b': 2}, 'y': 5, 'z': 6}, ... {'x': {'b... |
172,018 | import copy
from inspect import Parameter, Signature, signature
from typing import Type, TypeVar
from ..traitlets import HasTraits, Undefined
def _get_default(value):
"""Get default argument value, given the trait default value."""
return Parameter.empty if value == Undefined else value
T = TypeVar("T", bound=H... | Return a decorated class with a constructor signature that contain Trait names as kwargs. |
172,019 | import re
import textwrap
from textwrap import dedent
from textwrap import indent as _indent
from typing import List
def dedent(text: str) -> str: ...
List = _Alias()
The provided code snippet includes necessary dependencies for implementing the `wrap_paragraphs` function. Write a Python function `def wrap_paragraph... | Wrap multiple paragraphs to fit a specified width. This is equivalent to textwrap.wrap, but with support for multiple paragraphs, as separated by empty lines. Returns ------- list of complete paragraphs, wrapped to fill `ncols` columns. |
172,020 | import inspect
from functools import partial
class partial(Generic[_T]):
func: Callable[..., _T]
args: Tuple[Any, ...]
keywords: Dict[str, Any]
def __init__(self, func: Callable[..., _T], *args: Any, **kwargs: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
if sys.ver... | Like inspect.getargspec but supports functools.partial as well. |
172,021 | import re
import sys
import inspect
import operator
import itertools
from contextlib import _GeneratorContextManager
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
class FunctionMaker(object):
"""
An object with the ability to create functions with a given signature.
It has att... | A version of "decorator" implemented via "exec" and not via the Signature object. Use this if you are want to preserve the `.__code__` object properties (https://github.com/micheles/decorator/issues/129). |
172,022 | import re
import sys
import inspect
import operator
import itertools
from contextlib import _GeneratorContextManager
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
POS = inspect.Parameter.POSITIONAL_OR_KEYWORD
EMPTY = inspect.Parameter.empty
def decorate(func, caller, extras=(), kwsyntax=F... | decorator(caller) converts a caller function into a decorator |
172,023 | import re
import sys
import inspect
import operator
import itertools
from contextlib import _GeneratorContextManager
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
_contextmanager = decorator(ContextManager)
def contextmanager(func):
# Enable Pylint config: contextmanager-decorators=d... | null |
172,024 | import re
import sys
import inspect
import operator
import itertools
from contextlib import _GeneratorContextManager
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
class FunctionMaker(object):
"""
An object with the ability to create functions with a given signature.
It has att... | Factory of decorators turning a function into a generic function dispatching on the given arguments. |
172,025 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
The provided code sn... | Returns `True` when the Python implementation supports suspend-to-background. This is typically `False' on Windows systems. |
172,026 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
The provided code sn... | True when we are using Windows. |
172,027 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
def is_win_vt100_ena... | True when we are using Windows, but VT100 escape sequences are supported. |
172,028 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
_T = TypeVar("_T")
c... | Generator that keeps yielding items from the items list, in proportion to their weight. For instance:: # Getting the first 70 items from this generator should have yielded 10 # times A, 20 times B and 40 times C, all distributed equally.. take_using_weights(['A', 'B', 'C'], [5, 10, 20]) :param items: List of items to t... |
172,029 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
class Callable(BaseT... | Turn callable or string into string. |
172,030 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
class Callable(BaseT... | Turn callable or int into int. |
172,031 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
AnyFloat = Union[Call... | Turn callable or float into float. |
172,032 | from __future__ import annotations
import os
import signal
import sys
import threading
from collections import deque
from typing import (
Callable,
ContextManager,
Deque,
Dict,
Generator,
Generic,
List,
Optional,
TypeVar,
Union,
)
from wcwidth import wcwidth
The provided code sn... | True if this terminal type is considered "dumb". If so, we should fall back to the simplest possible form of line editing, without cursor positioning and color support. |
172,033 | from __future__ import annotations
import asyncio
import contextvars
import socket
import sys
from asyncio import get_running_loop
from typing import Any, Awaitable, Callable, List, Optional, Set, TextIO, Tuple, cast
from prompt_toolkit.application.current import create_app_session, get_app
from prompt_toolkit.applicat... | null |
172,034 | from __future__ import annotations
import asyncio
import contextvars
import socket
import sys
from asyncio import get_running_loop
from typing import Any, Awaitable, Callable, List, Optional, Set, TextIO, Tuple, cast
from prompt_toolkit.application.current import create_app_session, get_app
from prompt_toolkit.applicat... | null |
172,035 | from __future__ import annotations
import re
from typing import Callable, Dict, Iterable, Iterator, List
from typing import Match as RegexMatch
from typing import Optional, Pattern, Tuple
from .regex_parser import (
AnyNode,
Lookahead,
Node,
NodeSequence,
Regex,
Repeat,
Variable,
parse_r... | Compile grammar (given as regex string), returning a `CompiledGrammar` instance. |
172,036 | from __future__ import annotations
from asyncio.events import AbstractEventLoop
from typing import TYPE_CHECKING, Any, Optional, TextIO
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app_or_none, get_app_session
from prompt_toolkit.application.run_in_terminal impor... | :: print_formatted_text(*values, sep=' ', end='\\n', file=None, flush=False, style=None, output=None) Print text to stdout. This is supposed to be compatible with Python's print function, but supports printing of formatted text. You can pass a :class:`~prompt_toolkit.formatted_text.FormattedText`, :class:`~prompt_toolk... |
172,037 | from __future__ import annotations
from asyncio.events import AbstractEventLoop
from typing import TYPE_CHECKING, Any, Optional, TextIO
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app_or_none, get_app_session
from prompt_toolkit.application.run_in_terminal impor... | Print any layout to the output in a non-interactive way. Example usage:: from prompt_toolkit.widgets import Frame, TextArea print_container( Frame(TextArea(text='Hello world!'))) |
172,038 | from __future__ import annotations
from asyncio.events import AbstractEventLoop
from typing import TYPE_CHECKING, Any, Optional, TextIO
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app_or_none, get_app_session
from prompt_toolkit.application.run_in_terminal impor... | Clear the screen. |
172,039 | from __future__ import annotations
from asyncio.events import AbstractEventLoop
from typing import TYPE_CHECKING, Any, Optional, TextIO
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app_or_none, get_app_session
from prompt_toolkit.application.run_in_terminal impor... | Erase the current title. |
172,040 | from __future__ import annotations
import datetime
import time
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, List, Tuple
from prompt_toolkit.formatted_text import (
HTML,
AnyFormattedText,
StyleAndTextTuples,
to_formatted_text,
)
from prompt_toolkit.formatted_text.utils impor... | Return hh:mm:ss, or mm:ss if the amount of hours is zero. |
172,041 | from __future__ import annotations
import datetime
import time
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, List, Tuple
from prompt_toolkit.formatted_text import (
HTML,
AnyFormattedText,
StyleAndTextTuples,
to_formatted_text,
)
from prompt_toolkit.formatted_text.utils impor... | Take hue between 0 and 1, return (r, g, b). |
172,042 | from __future__ import annotations
import datetime
import time
from abc import ABCMeta, abstractmethod
from typing import TYPE_CHECKING, List, Tuple
from prompt_toolkit.formatted_text import (
HTML,
AnyFormattedText,
StyleAndTextTuples,
to_formatted_text,
)
from prompt_toolkit.formatted_text.utils impor... | Return the list of default formatters. |
172,043 | from __future__ import annotations
import contextvars
import datetime
import functools
import os
import signal
import threading
import traceback
from typing import (
Callable,
Generic,
Iterable,
Iterator,
List,
Optional,
Sequence,
Sized,
TextIO,
TypeVar,
cast,
)
from prompt_t... | Key bindings handled by the progress bar. (The main thread is not supposed to handle any key bindings.) |
172,044 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a Yes/No dialog. Return a boolean. |
172,045 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a dialog with button choices (given as a list of tuples). Return the value associated with button. |
172,046 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a text input box. Return the given text, or None when cancelled. |
172,047 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a simple message box and wait until the user presses enter. |
172,048 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a simple list of element the user can choose amongst. Only one element can be selected at a time using Arrow keys and Enter. The focus can be moved between the list and the Ok/Cancel button with tab. |
172,049 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | Display a simple list of element the user can choose multiple values amongst. Several elements can be selected at a time using Arrow keys and Enter. The focus can be moved between the list and the Ok/Cancel button with tab. |
172,050 | from __future__ import annotations
import functools
from asyncio import get_running_loop
from typing import Any, Callable, List, Optional, Sequence, Tuple, TypeVar
from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.buffer import Buffer
from prom... | :param run_callback: A function that receives as input a `set_percentage` function and it does the work. |
172,051 | from __future__ import annotations
from asyncio import get_running_loop
from contextlib import contextmanager
from enum import Enum
from functools import partial
from typing import (
TYPE_CHECKING,
Callable,
Generic,
Iterator,
List,
Optional,
Tuple,
TypeVar,
Union,
cast,
)
from p... | Take a `get_prompt_text` function and return three new functions instead. One that tells whether this prompt consists of multiple lines; one that returns the fragments to be shown on the lines above the input; and another one with the fragments to be shown at the first line of the input. |
172,052 | from __future__ import annotations
from asyncio import FIRST_COMPLETED, Future, ensure_future, sleep, wait
from collections import deque
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, Deque, Dict, Hashable, Optional, Tuple
from prompt_toolkit.application.current import get_app
from prompt_toolki... | Render the diff between this screen and the previous screen. This takes two `Screen` instances. The one that represents the output like it was during the last rendering and one that represents the current output raster. Looking at these two `Screen` instances, this function will render the difference by calling the app... |
172,053 | from __future__ import annotations
from asyncio import FIRST_COMPLETED, Future, ensure_future, sleep, wait
from collections import deque
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, Deque, Dict, Hashable, Optional, Tuple
from prompt_toolkit.application.current import get_app
from prompt_toolki... | Print a list of (style_str, text) tuples in the given style to the output. |
172,054 | from __future__ import annotations
import sys
from ctypes import pointer
from ..utils import SPHINX_AUTODOC_RUNNING
from ctypes.wintypes import BOOL, DWORD, HANDLE
from typing import List, Optional
from prompt_toolkit.win32_types import SECURITY_ATTRIBUTES
WAIT_TIMEOUT = 0x00000102
INFINITE = -1
The provided code snip... | Waits for multiple handles. (Similar to 'select') Returns the handle which is ready. Returns `None` on timeout. http://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx Note that handles should be a list of `HANDLE` objects, not integers. See this comment in the patch by @quark-zju for the reason ... |
172,055 | from __future__ import annotations
import sys
from ctypes import pointer
from ..utils import SPHINX_AUTODOC_RUNNING
from ctypes.wintypes import BOOL, DWORD, HANDLE
from typing import List, Optional
from prompt_toolkit.win32_types import SECURITY_ATTRIBUTES
class SECURITY_ATTRIBUTES(Structure):
"""
http://msdn.... | Creates a Win32 unnamed Event . http://msdn.microsoft.com/en-us/library/windows/desktop/ms682396(v=vs.85).aspx |
172,056 | from __future__ import annotations
import asyncio
import contextvars
import sys
import time
from asyncio import get_running_loop
from types import TracebackType
from typing import Any, Awaitable, Callable, Dict, Optional, TypeVar, cast
class Callable(BaseTypingInstance):
def py__call__(self, arguments):
""... | Wrapper around asyncio's `call_soon_threadsafe`. This takes a `max_postpone_time` which can be used to tune the urgency of the method. Asyncio runs tasks in first-in-first-out. However, this is not what we want for the render function of the prompt_toolkit UI. Rendering is expensive, but since the UI is invalidated ver... |
172,057 | from __future__ import annotations
import asyncio
import contextvars
import sys
import time
from asyncio import get_running_loop
from types import TracebackType
from typing import Any, Awaitable, Callable, Dict, Optional, TypeVar, cast
class TracebackType:
if sys.version_info >= (3, 7):
def __init__(self, ... | Get the traceback object from the context. |
172,058 | from __future__ import annotations
from asyncio import get_running_loop
from contextlib import asynccontextmanager
from queue import Empty, Full, Queue
from typing import Any, AsyncGenerator, Callable, Iterable, TypeVar, Union
from .utils import run_in_executor_with_context
_T_Generator = TypeVar("_T_Generator", bound=... | Similar to `contextlib.aclosing`, in Python 3.10. |
172,059 | from __future__ import annotations
from asyncio import get_running_loop
from contextlib import asynccontextmanager
from queue import Empty, Full, Queue
from typing import Any, AsyncGenerator, Callable, Iterable, TypeVar, Union
from .utils import run_in_executor_with_context
DEFAULT_BUFFER_SIZE: int = 1000
_T = TypeVar(... | Turn a generator or iterable into an async generator. This works by running the generator in a background thread. :param get_iterable: Function that returns a generator or iterable when called. :param buffer_size: Size of the queue between the async consumer and the synchronous generator that produces items. |
172,060 | from __future__ import annotations
import asyncio
import os
import select
import selectors
import sys
import threading
from asyncio import AbstractEventLoop, get_running_loop
from selectors import BaseSelector, SelectorKey
from typing import TYPE_CHECKING, Any, Callable, List, Mapping, Optional, Tuple
def new_eventloop... | Create a new event loop with the given inputhook, and activate it. |
172,061 | from __future__ import annotations
from collections import deque
from functools import wraps
from typing import Any, Callable, Deque, Dict, Generic, Hashable, Tuple, TypeVar, cast
class SimpleCache(Generic[_T, _U]):
"""
Very simple cache that discards the oldest item when the cache size is
exceeded.
:pa... | Memoization decorator for immutable classes and pure functions. |
172,062 | from __future__ import annotations
import errno
import os
import sys
from contextlib import contextmanager
from typing import IO, Iterator, TextIO
def _blocking_io(io: IO[str]) -> Iterator[None]:
"""
Ensure that the FD for `io` is set to blocking in here.
"""
if sys.platform == "win32":
# On Win... | null |
172,063 | from __future__ import annotations
import sys
import os
from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer
from ..utils import SPHINX_AUTODOC_RUNNING
from ctypes.wintypes import DWORD, HANDLE
from typing import Callable, Dict, List, Optional, TextIO, Tuple, Type, TypeVar, Union
from promp... | Turns a COORD object into a c_long. This will cause it to be passed by value instead of by reference. (That is what I think at least.) When running ``ptipython`` is run (only with IPython), we often got the following error:: Error in 'SetConsoleCursorPosition'. ArgumentError("argument 2: <class 'TypeError'>: wrong type... |
172,064 | from __future__ import annotations
import sys
import os
from ctypes import ArgumentError, byref, c_char, c_long, c_uint, c_ulong, pointer
from ..utils import SPHINX_AUTODOC_RUNNING
from ctypes.wintypes import DWORD, HANDLE
from typing import Callable, Dict, List, Optional, TextIO, Tuple, Type, TypeVar, Union
from promp... | Create a table that maps the 16 named ansi colors to their Windows code. |
172,065 | from __future__ import annotations
import io
import os
import sys
from typing import (
Callable,
Dict,
Hashable,
Iterable,
List,
Optional,
Sequence,
Set,
TextIO,
Tuple,
)
from prompt_toolkit.cursor_shapes import CursorShape
from prompt_toolkit.data_structures import Size
from pro... | Find closest ANSI color. Return it by name. :param r: Red (Between 0 and 255.) :param g: Green (Between 0 and 255.) :param b: Blue (Between 0 and 255.) :param exclude: A tuple of color names to exclude. (E.g. ``('ansired', )``.) |
172,066 | from __future__ import annotations
import io
import os
import sys
from typing import (
Callable,
Dict,
Hashable,
Iterable,
List,
Optional,
Sequence,
Set,
TextIO,
Tuple,
)
from prompt_toolkit.cursor_shapes import CursorShape
from prompt_toolkit.data_structures import Size
from pro... | Get the size of this pseudo terminal. :param fileno: stdout.fileno() :returns: A (rows, cols) tuple. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.