id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
35,045
import tensorflow as tf import dnnlib.tflib as tflib from dnnlib.tflib.autosummary import autosummary def fp32(*values): if len(values) == 1 and isinstance(values[0], tuple): values = values[0] values = tuple(tf.cast(v, tf.float32) for v in values) return values if len(values) >= 2 else values[0] ...
null
35,046
import tensorflow as tf import dnnlib.tflib as tflib from dnnlib.tflib.autosummary import autosummary def fp32(*values): if len(values) == 1 and isinstance(values[0], tuple): values = values[0] values = tuple(tf.cast(v, tf.float32) for v in values) return values if len(values) >= 2 else values[0] ...
null
35,047
import numpy as np import tensorflow as tf def lerp(a, b, t): return a + (b - a) * t def lerp_clip(a, b, t): return a + (b - a) * tf.clip_by_value(t, 0.0, 1.0) def cset(cur_lambda, new_cond, new_lambda): return lambda: tf.cond(new_cond, new_lambda, cur_lambda) def dense(x, fmaps, gain=np.sqrt(2), use_wscale=False): ...
null
35,048
import numpy as np import tensorflow as tf def lerp(a, b, t): return a + (b - a) * t def lerp_clip(a, b, t): return a + (b - a) * tf.clip_by_value(t, 0.0, 1.0) def cset(cur_lambda, new_cond, new_lambda): return lambda: tf.cond(new_cond, new_lambda, cur_lambda) def dense(x, fmaps, gain=np.sqrt(2), use_wscale=False): ...
null
35,049
import os import glob import numpy as np import tensorflow as tf import dnnlib import dnnlib.tflib as tflib def parse_tfrecord_tf(record): features = tf.parse_single_example(record, features={ 'shape': tf.FixedLenFeature([3], tf.int64), 'data': tf.FixedLenFeature([], tf.string)}) data = tf.deco...
null
35,050
import os import glob import numpy as np import tensorflow as tf import dnnlib import dnnlib.tflib as tflib def parse_tfrecord_np(record): ex = tf.train.Example() ex.ParseFromString(record) shape = ex.features.feature['shape'].int64_list.value # temporary pylint workaround # pylint: disable=no-member d...
null
35,051
# import numpy as np import tensorflow as tf import dnnlib import dnnlib.tflib as tflib def G_mapping( latents_in, # First input: Latent vectors (Z) [minibatch, latent_size]. labels_in, # Second input: Conditioning labels [minibatch, label_size]. lat...
null
35,052
# import numpy as np import tensorflow as tf import dnnlib import dnnlib.tflib as tflib def blur2d(x, f=[1,2,1], normalize=True): with tf.variable_scope('Blur2D'): def func(x): y = _blur2d(x, f, normalize) def grad(dy): dx = _blur2d(dy, f, normalize, flip=True) ...
null
35,053
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config _Gs_cache = dict() def load_Gs(url): if url not in _Gs_cache: with dnnlib.util.open_url(url, cache_dir=config.cache_dir) as f: _G, _D, Gs = pickle.load(f) _Gs_cache[url] ...
null
35,054
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=8) def draw_uncurated_result_figure(png, Gs, cx, cy, cw, ch, rows, lods, seed): p...
null
35,055
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=8) def draw_style_mixing_figure(png, Gs, w, h, src_seeds, dst_seeds, style_ranges): ...
null
35,056
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=8) def draw_noise_detail_figure(png, Gs, w, h, num_samples, seeds): print(png) ...
null
35,057
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=8) def draw_noise_components_figure(png, Gs, w, h, seeds, noise_ranges, flips): p...
null
35,058
import os import pickle import numpy as np import PIL.Image import dnnlib import dnnlib.tflib as tflib import config synthesis_kwargs = dict(output_transform=dict(func=tflib.convert_images_to_uint8, nchw_to_nhwc=True), minibatch_size=8) def draw_truncation_trick_figure(png, Gs, w, h, seeds, psis): print(png) l...
null
35,059
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def display(tfrecord_dir): print('Loading dataset "%s"' % tfrecord_dir) tflib....
null
35,060
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def extract(tfrecord_dir, output_dir): print('Loading dataset "%s"' % tfrecord_dir...
null
35,061
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def compare(tfrecord_dir_a, tfrecord_dir_b, ignore_labels): max_label_size = 0 if ...
null
35,062
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pr...
null
35,063
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,064
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,065
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,066
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pr...
null
35,067
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,068
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,069
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def error(msg): print('Error: ' + msg) exit(1) class TFRecordExporter: def ...
null
35,070
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def error(msg): print('Error: ' + msg) exit(1) class TFRecordExporter: def ...
null
35,071
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset class TFRecordExporter: def __init__(self, tfrecord_dir, expected_images, print_pro...
null
35,072
import os import sys import glob import argparse import threading import six.moves.queue as Queue import traceback import numpy as np import tensorflow as tf import PIL.Image import dnnlib.tflib as tflib from training import dataset def execute_cmdline(argv): prog = argv[0] parser = argparse.ArgumentParser( ...
null
35,073
import os import sys import logging import numpy as np import torch from . import model_settings The provided code snippet includes necessary dependencies for implementing the `get_temp_logger` function. Write a Python function `def get_temp_logger(logger_name='logger')` to solve the following problem: Gets a temporar...
Gets a temporary logger. This logger will print all levels of messages onto the screen. Args: logger_name: Name of the logger. Returns: A `logging.Logger`. Raises: ValueError: If the input `logger_name` is empty.
35,074
import numpy as np from sklearn import svm from .logger import setup_logger def setup_logger(work_dir=None, logfile_name='log.txt', logger_name='logger'): """Sets up logger from target work directory. The function will sets up a logger with `DEBUG` log level. Two handlers will be added to the logger automatical...
Trains boundary in latent space with offline predicted attribute scores. Given a collection of latent codes and the attribute scores predicted from the corresponding images, this function will train a linear SVM by treating it as a bi-classification problem. Basically, the samples with highest attribute scores are trea...
35,075
import numpy as np from sklearn import svm from .logger import setup_logger The provided code snippet includes necessary dependencies for implementing the `project_boundary` function. Write a Python function `def project_boundary(primal, *args)` to solve the following problem: Projects the primal boundary onto conditi...
Projects the primal boundary onto condition boundaries. The function is used for conditional manipulation, where the projected vector will be subscribed from the normal direction of the original boundary. Here, all input boundaries are supposed to have already been normalized to unit norm, and with same shape [1, laten...
35,076
import numpy as np from sklearn import svm from .logger import setup_logger The provided code snippet includes necessary dependencies for implementing the `linear_interpolate` function. Write a Python function `def linear_interpolate(latent_code, boundary, start_distance=-...
Manipulates the given latent code with respect to a particular boundary. Basically, this function takes a latent code and a boundary as inputs, and outputs a collection of manipulated latent codes. For example, let `steps` to be 10, then the input `latent_code` is with shape [1, latent_space_dim], input `boundary` is w...
35,077
STDOUT = -11 STDERR = -12 try: import ctypes from ctypes import LibraryLoader windll = LibraryLoader(ctypes.WinDLL) from ctypes import wintypes except (AttributeError, ImportError): windll = None SetConsoleTextAttribute = lambda *_: None winapi_test = lambda *_: None else: from ctypes im...
null
35,079
STDOUT = -11 try: import ctypes from ctypes import LibraryLoader windll = LibraryLoader(ctypes.WinDLL) from ctypes import wintypes except (AttributeError, ImportError): windll = None SetConsoleTextAttribute = lambda *_: None winapi_test = lambda *_: None else: from ctypes import byref, S...
null
35,088
import atexit import contextlib import sys from .ansitowin32 import AnsiToWin32 wrapped_stdout = None wrapped_stderr = None def reinit(): if wrapped_stdout is not None: sys.stdout = wrapped_stdout if wrapped_stderr is not None: sys.stderr = wrapped_stderr
null
35,089
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
null
35,090
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
Internal handler for the bash completion support.
35,091
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
null
35,092
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
null
35,093
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
null
35,094
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
Context manager that attaches extra information to exceptions.
35,095
import errno import inspect import os import sys from contextlib import contextmanager from functools import update_wrapper from itertools import repeat from ._compat import isidentifier from ._compat import iteritems from ._compat import PY2 from ._compat import string_types from ._unicodefun import _check_for_unicode...
Given a sequence of parameters in the order as should be considered for processing and an iterable of parameters that exist, this returns a list in the correct order as they should be processed.
35,096
import codecs import os import sys from ._compat import PY2 PY2 = sys.version_info[0] == 2 if PY2: text_type = unicode raw_input = raw_input string_types = (str, unicode) int_types = (int, long) iteritems = lambda x: x.iteritems() range_type = xrange def is_bytes(x): ...
Ensures that the environment is good for unicode on Python 3.
35,097
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Wraps a function so that it swallows exceptions.
35,098
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Converts a value into a valid string.
35,099
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Return a condensed version of help string.
35,100
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Returns a system stream for byte processing. This essentially returns the stream from the sys module with the given name but it solves some compatibility issues between different Python versions. Primarily this function is necessary for getting binary streams on Python 3. :param name: the name of the stream to open. Va...
35,101
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Returns a system stream for text processing. This usually returns a wrapped stream around a binary stream returned from :func:`get_binary_stream` but it also can take shortcuts on Python 3 for already correctly configured streams. :param name: the name of the stream to open. Valid names are ``'stdin'``, ``'stdout'`` an...
35,102
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
This is similar to how the :class:`File` works but for manual usage. Files are opened non lazy by default. This can open regular files as well as stdin/stdout if ``'-'`` is passed. If stdin/stdout is returned the stream is wrapped so that the context manager will not close the stream accidentally. This makes it possibl...
35,103
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
This returns the argument part of sys.argv in the most appropriate form for processing. What this means is that this return value is in a format that works for Click to process but does not necessarily correspond well to what's actually standard for the interpreter. On most environments the return value is ``sys.argv[:...
35,104
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
Formats a filename for user display. The main purpose of this function is to ensure that the filename can be displayed at all. This will decode the filename to unicode if necessary in a way that it will not fail. Optionally, it can shorten the filename to not include the full path to the filename. :param filename: form...
35,105
import os import sys from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import auto_wrap_for_ansi from ._compat import binary_streams from ._compat import filename_to_ui from ._compat import get_filesystem_encoding from ._compat import get_streerror from ._compat import is...
r"""Returns the config folder for the application. The default behavior is to return whatever is most appropriate for the operating system. To give you an idea, for an app called ``"Foo Bar"``, something like the following folders could be returned: Mac OS X: ``~/Library/Application Support/Foo Bar`` Mac OS X (POSIX): ...
35,106
from contextlib import contextmanager from ._compat import term_len from .parser import split_opt from .termui import get_terminal_size def term_len(x): return len(strip_ansi(x)) def measure_table(rows): widths = {} for row in rows: for idx, col in enumerate(row): widths[idx] = max(wid...
null
35,107
from contextlib import contextmanager from ._compat import term_len from .parser import split_opt from .termui import get_terminal_size def iter_rows(rows, col_count): for row in rows: row = tuple(row) yield row + ("",) * (col_count - len(row))
null
35,108
from contextlib import contextmanager from ._compat import term_len from .parser import split_opt from .termui import get_terminal_size def term_len(x): return len(strip_ansi(x)) class TextWrapper(textwrap.TextWrapper): def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width): space_left...
A helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intelligently handle paragraphs (defined by two empty lines). If paragraphs are handled, a paragraph can be prefixed with an empty line co...
35,109
from contextlib import contextmanager from ._compat import term_len from .parser import split_opt from .termui import get_terminal_size def split_opt(opt): first = opt[:1] if first.isalnum(): return "", opt if opt[1:2] == first: return opt[:2], opt[2:] return first, opt[1:] The provide...
Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash.
35,110
import re from collections import deque from .exceptions import BadArgumentUsage from .exceptions import BadOptionUsage from .exceptions import NoSuchOption from .exceptions import UsageError The provided code snippet includes necessary dependencies for implementing the `_unpack_args` function. Write a Python function...
Given an iterable of arguments and an iterable of nargs specifications, it returns a tuple with all the unpacked arguments at the first index and all remaining arguments as the second. The nargs specification is the number of arguments that should be consumed or `-1` to indicate that this position should eat up all the...
35,111
import re from collections import deque from .exceptions import BadArgumentUsage from .exceptions import BadOptionUsage from .exceptions import NoSuchOption from .exceptions import UsageError class BadOptionUsage(UsageError): """Raised if an option is generally supplied but the use of the option was incorrect....
null
35,112
import re from collections import deque from .exceptions import BadArgumentUsage from .exceptions import BadOptionUsage from .exceptions import NoSuchOption from .exceptions import UsageError def split_opt(opt): first = opt[:1] if first.isalnum(): return "", opt if opt[1:2] == first: return ...
null
35,113
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def g...
Marks a callback as wanting to receive the current context object as first argument.
35,114
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def g...
Similar to :func:`pass_context`, but only pass the object on the context onwards (:attr:`Context.obj`). This is useful if that object represents the state of a nested system.
35,115
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def g...
Given an object type this creates a decorator that will work similar to :func:`pass_obj` but instead of passing the object of the current context, it will find the innermost context of type :func:`object_type`. This generates a decorator that works roughly like this:: from functools import update_wrapper def decorator(...
35,116
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def co...
Creates a new :class:`Group` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Group`.
35,117
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def _p...
Attaches an argument to the command. All positional arguments are passed as parameter declarations to :class:`Argument`; all keyword arguments are forwarded unchanged (except ``cls``). This is equivalent to creating an :class:`Argument` instance manually and attaching it to the :attr:`Command.params` list. :param cls: ...
35,118
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def op...
Shortcut for confirmation prompts that can be ignored by passing ``--yes`` as parameter. This is equivalent to decorating a function with :func:`option` with the following parameters:: def callback(ctx, param, value): if not value: ctx.abort() @click.command() @click.option('--yes', is_flag=True, callback=callback, exp...
35,119
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def op...
Shortcut for password prompts. This is equivalent to decorating a function with :func:`option` with the following parameters:: @click.command() @click.option('--password', prompt=True, confirmation_prompt=True, hide_input=True) def changeadmin(password): pass
35,120
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def op...
Adds a ``--version`` option which immediately ends the program printing out the version number. This is implemented as an eager option that prints the version and exits the program in the callback. :param version: the version number to show. If not provided Click attempts an auto discovery via setuptools. :param prog_n...
35,121
import inspect import sys from functools import update_wrapper from ._compat import iteritems from ._unicodefun import _check_for_unicode_literals from .core import Argument from .core import Command from .core import Group from .core import Option from .globals import get_current_context from .utils import echo def op...
Adds a ``--help`` option which immediately ends the program printing out the help page. This is usually unnecessary to add as this is added by default to all commands unless suppressed. Like :func:`version_option`, this is implemented as eager option that prints in the callback and exits. All arguments are forwarded to...
35,122
import ctypes import io import os import sys import time import zlib from ctypes import byref from ctypes import c_char from ctypes import c_char_p from ctypes import c_int from ctypes import c_ssize_t from ctypes import c_ulong from ctypes import c_void_p from ctypes import POINTER from ctypes import py_object from ct...
null
35,123
import ctypes import io import os import sys import time import zlib from ctypes import byref from ctypes import c_char from ctypes import c_char_p from ctypes import c_int from ctypes import c_ssize_t from ctypes import c_ulong from ctypes import c_void_p from ctypes import POINTER from ctypes import py_object from ct...
null
35,124
import ctypes import io import os import sys import time import zlib from ctypes import byref from ctypes import c_char from ctypes import c_char_p from ctypes import c_int from ctypes import c_ssize_t from ctypes import c_ulong from ctypes import c_void_p from ctypes import POINTER from ctypes import py_object from ct...
null
35,125
from ._compat import filename_to_ui from ._compat import get_text_stderr from ._compat import PY2 from .utils import echo def _join_param_hints(param_hint): if isinstance(param_hint, (tuple, list)): return " / ".join(repr(x) for x in param_hint) return param_hint
null
35,126
from threading import local _local = local() The provided code snippet includes necessary dependencies for implementing the `push_context` function. Write a Python function `def push_context(ctx)` to solve the following problem: Pushes a new context to the current stack. Here is the function: def push_context(ctx): ...
Pushes a new context to the current stack.
35,127
from threading import local _local = local() The provided code snippet includes necessary dependencies for implementing the `pop_context` function. Write a Python function `def pop_context()` to solve the following problem: Removes the top level from the stack. Here is the function: def pop_context(): """Removes...
Removes the top level from the stack.
35,128
import codecs import io import os import re import sys from weakref import WeakKeyDictionary def isidentifier(x): return _identifier_re.search(x) is not None
null
35,129
import codecs import io import os import re import sys from weakref import WeakKeyDictionary if PY2: text_type = unicode raw_input = raw_input string_types = (str, unicode) int_types = (int, long) iteritems = lambda x: x.iteritems() range_type = xrange _identifier_re = re.compile(r"^[a-zA-Z_...
null
35,130
import codecs import io import os import re import sys from weakref import WeakKeyDictionary def _make_text_stream( stream, encoding, errors, force_readable=False, force_writable=False ): if encoding is None: encoding = get_best_encoding(stream) if errors is None: errors = "replace" retu...
null
35,131
import codecs import io import os import re import sys from weakref import WeakKeyDictionary if PY2: text_type = unicode raw_input = raw_input string_types = (str, unicode) int_types = (int, long) iteritems = lambda x: x.iteritems() range_type = xrange _identifier_re = re.compile(r"^[a-zA-Z_...
null
35,132
import codecs import io import os import re import sys from weakref import WeakKeyDictionary if PY2: text_type = unicode raw_input = raw_input string_types = (str, unicode) int_types = (int, long) iteritems = lambda x: x.iteritems() range_type = xrange _identifier_re = re.compile(r"^[a-zA-Z_...
null
35,133
import codecs import io import os import re import sys from weakref import WeakKeyDictionary if hasattr(os, "replace"): _replace = os.replace _can_replace = True else: _replace = os.rename _can_replace = not WIN def get_streerror(e, default=None): if hasattr(e, "strerror"): msg = e.strerror...
null
35,134
import codecs import io import os import re import sys from weakref import WeakKeyDictionary def _get_argv_encoding(): import locale return locale.getpreferredencoding()
null
35,135
import codecs import io import os import re import sys from weakref import WeakKeyDictionary _default_text_stdin = _make_cached_stream_func(lambda: sys.stdin, get_text_stdin) _default_text_stdout = _make_cached_stream_func(lambda: sys.stdout, get_text_stdout) def raw_input(prompt=""): sys.stderr.flush() ...
null
35,136
import codecs import io import os import re import sys from weakref import WeakKeyDictionary def get_filesystem_encoding(): return sys.getfilesystemencoding() or sys.getdefaultencoding() def _get_argv_encoding(): return getattr(sys.stdin, "encoding", None) or get_filesystem_encoding()
null
35,137
import codecs import io import os import re import sys from weakref import WeakKeyDictionary def _make_cached_stream_func(src_func, wrapper_func): cache = WeakKeyDictionary() def func(): stream = src_func() try: rv = cache.get(stream) except Exception: rv = None...
null
35,138
import contextlib import math import os import sys import time from ._compat import _default_text_stdout from ._compat import CYGWIN from ._compat import get_best_encoding from ._compat import int_types from ._compat import isatty from ._compat import open_stream from ._compat import range_type from ._compat import str...
Returns the length hint of an object.
35,139
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
Prompts for confirmation (yes/no question). If the user aborts the input by sending a interrupt signal this function will catch it and raise a :exc:`Abort` exception. .. versionadded:: 4.0 Added the `err` parameter. :param text: the question to ask. :param default: the default for the prompt. :param abort: if this is s...
35,140
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
Returns the current size of the terminal as tuple in the form ``(width, height)`` in columns and rows.
35,141
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
This function takes a text and shows it via an environment specific pager on stdout. .. versionchanged:: 3.0 Added the `color` flag. :param text_or_generator: the text to page, or alternatively, a generator emitting the text to page. :param color: controls if the pager supports ANSI colors or not. The default is autode...
35,142
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
This function creates an iterable context manager that can be used to iterate over something while showing a progress bar. It will either iterate over the `iterable` or `length` items (that are counted up). While iteration happens, this function will print a rendered progress bar to the given `file` (defaults to stdout...
35,143
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
Clears the terminal screen. This will have the effect of clearing the whole visible space of the terminal and moving the cursor to the top left. This does not do anything if not connected to a terminal. .. versionadded:: 2.0
35,144
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
Removes ANSI styling information from a string. Usually it's not necessary to use this function as Click's echo function will automatically remove styling if necessary. .. versionadded:: 2.0 :param text: the text to remove style information from.
35,145
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
This function combines :func:`echo` and :func:`style` into one call. As such the following two calls are the same:: click.secho('Hello World!', fg='green') click.echo(click.style('Hello World!', fg='green')) All keyword arguments are forwarded to the underlying functions depending on which one they go with. .. versiona...
35,146
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
r"""Edits the given text in the defined editor. If an editor is given (should be the full path to the executable but the regular operating system search path is used for finding the executable) it overrides the detected editor. Optionally, some environment variables can be used. If the editor is closed without changes,...
35,147
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
This function launches the given URL (or filename) in the default viewer application for this file type. If this is an executable, it might launch the executable in a new session. The return value is the exit code of the launched application. Usually, ``0`` indicates success. Examples:: click.launch('https://click.pall...
35,148
import inspect import io import itertools import os import struct import sys from ._compat import DEFAULT_COLUMNS from ._compat import get_winterm_size from ._compat import isatty from ._compat import raw_input from ._compat import string_types from ._compat import strip_ansi from ._compat import text_type from ._compa...
This command stops execution and waits for the user to press any key to continue. This is similar to the Windows batch "pause" command. If the program is not run through a terminal, this command will instead do nothing. .. versionadded:: 2.0 .. versionadded:: 4.0 Added the `err` parameter. :param info: the info string ...
35,149
import multiprocessing from thirdparty import requests from . import thread from .._compat import queue def _identity(session_obj): return session_obj
null
35,150
import contextlib import io import os from uuid import uuid4 from thirdparty import requests from .._compat import fields def IDENTITY(monitor): return monitor
null
35,151
import contextlib import io import os from uuid import uuid4 from thirdparty import requests from .._compat import fields class CustomBytesIO(io.BytesIO): def __init__(self, buffer=None, encoding='utf-8'): buffer = encode_with(buffer, encoding) super(CustomBytesIO, self).__init__(buffer) def _ge...
Coerce the data to an object with a ``read`` method.
35,152
import contextlib import io import os from uuid import uuid4 from thirdparty import requests from .._compat import fields def total_len(o): if hasattr(o, '__len__'): return len(o) if hasattr(o, 'len'): return o.len if hasattr(o, 'fileno'): try: fileno = o.fileno() ...
null
35,153
import contextlib import io import os from uuid import uuid4 from thirdparty import requests from .._compat import fields The provided code snippet includes necessary dependencies for implementing the `reset` function. Write a Python function `def reset(buffer)` to solve the following problem: Keep track of the buffer...
Keep track of the buffer's current position and write to the end. This is a context manager meant to be used when adding data to the buffer. It eliminates the need for every function to be concerned with the position of the cursor in the buffer.