id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
176,295 | import collections
import contextlib
import errno
import functools
import os
import sys
import types
import sys
if sys.version_info[0] < 3:
del num, x
def redirect_stderr(new_target):
... | null |
176,296 | import glob
import os
import signal
import sys
import time
from ._common import MACOS
from ._common import TimeoutExpired
from ._common import memoize
from ._common import sdiskusage
from ._common import usage_percent
from ._compat import PY3
from ._compat import ChildProcessError
from ._compat import FileNotFoundError... | Wait for a process PID to terminate. If the process terminated normally by calling exit(3) or _exit(2), or by returning from main(), the return value is the positive integer passed to *exit(). If it was terminated by a signal it returns the negated value of the signal which caused the termination (e.g. -SIGTERM). If PI... |
176,297 | import glob
import os
import signal
import sys
import time
from ._common import MACOS
from ._common import TimeoutExpired
from ._common import memoize
from ._common import sdiskusage
from ._common import usage_percent
from ._compat import PY3
from ._compat import ChildProcessError
from ._compat import FileNotFoundError... | Get a map of device-id -> path as a dict. Used by Process.terminal() |
176,298 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Report virtual memory metrics. |
176,299 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Report swap memory metrics. |
176,300 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return system-wide CPU times as a named tuple |
176,301 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return the number of logical CPUs in the system. |
176,302 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return the number of CPU cores in the system. |
176,303 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return various CPU stats as a named tuple. |
176,304 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return system disk partitions. |
176,305 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return socket connections. If pid == -1 return system-wide connections (as opposed to connections opened by one process only). Only INET sockets are returned (UNIX are not). |
176,306 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Get NIC stats (isup, duplex, speed, mtu). |
176,307 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | The system boot time expressed in seconds since the epoch. |
176,308 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Return currently connected users as a list of namedtuples. |
176,309 | import errno
import functools
import os
import socket
import subprocess
import sys
from collections import namedtuple
from socket import AF_INET
from . import _common
from . import _psposix
from . import _psutil_posix as cext_posix
from . import _psutil_sunos as cext
from ._common import AF_INET6
from ._common import A... | Call callable into a try/except clause and translate ENOENT, EACCES and EPERM in NoSuchProcess or AccessDenied exceptions. |
176,310 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | System virtual memory as a namedtuple. |
176,311 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | System swap memory as (total, used, free, sin, sout) namedtuple. |
176,312 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return system CPU times as a namedtuple |
176,313 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return system CPU times as a namedtuple |
176,314 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | null |
176,315 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return the number of CPU cores in the system. |
176,316 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return various CPU stats as a named tuple. |
176,317 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return frequency metrics for CPUs. As of Dec 2018 only CPU 0 appears to be supported by FreeBSD and all other cores match the frequency of CPU 0. |
176,318 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | null |
176,319 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return mounted disk partitions as a list of namedtuples. 'all' argument is ignored, see: https://github.com/giampaolo/psutil/issues/906 |
176,320 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Get NIC stats (isup, duplex, speed, mtu). |
176,321 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | System-wide network connections. |
176,322 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return battery info. |
176,323 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return CPU cores temperatures if available, else an empty dict. |
176,324 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | The system boot time expressed in seconds since the epoch. |
176,325 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return currently connected users as a list of namedtuples. |
176,326 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Return True if pid exists. |
176,327 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Decorator which translates bare OSError exceptions into NoSuchProcess and AccessDenied. |
176,328 | import contextlib
import errno
import functools
import os
import xml.etree.ElementTree as ET
from collections import defaultdict
from collections import namedtuple
from . import _common
from . import _psposix
from . import _psutil_bsd as cext
from . import _psutil_posix as cext_posix
from ._common import FREEBSD
from .... | Same as above, for routines relying on reading /proc fs. |
176,329 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,330 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,331 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,332 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,333 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,334 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,335 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,336 | from functools import wraps
from copy import deepcopy
from traitlets import TraitError
from traitlets.config.loader import (
Config,
)
from jupyter_core.application import JupyterApp
from jupyter_server.serverapp import ServerApp
from jupyter_server.extension.application import ExtensionApp
from .traits import Note... | null |
176,337 | import os
import types
import inspect
from functools import wraps
from jupyter_core.paths import jupyter_config_path
from traitlets.traitlets import is_trait
from jupyter_server.services.config.manager import ConfigManager
from .traits import NotebookAppTraits
def proxy(obj1, obj2, name, overwrite=False):
def diff_memb... | null |
176,338 | import os
import types
import inspect
from functools import wraps
from jupyter_core.paths import jupyter_config_path
from traitlets.traitlets import is_trait
from jupyter_server.services.config.manager import ConfigManager
from .traits import NotebookAppTraits
def jupyter_config_path() -> List[str]:
"""Return the ... | null |
176,340 | from __future__ import absolute_import
import binascii
import codecs
import os
from io import BytesIO
from .fields import RequestField
from .packages import six
from .packages.six import b
writer = codecs.lookup("utf-8")[3]
def choose_boundary():
"""
Our embarrassingly-simple replacement for mimetools.choose_bo... | Encode a dictionary of ``fields`` using the multipart/form-data MIME format. :param fields: Dictionary of fields or list of (key, :class:`~urllib3.fields.RequestField`). :param boundary: If not specified, then a random boundary will be generated using :func:`urllib3.filepost.choose_boundary`. |
176,396 | from __future__ import absolute_import
import functools
import itertools
import operator
import sys
import types
if sys.version_info[0:2] < (3, 4):
# This does exactly the same what the :func:`py3:functools.update_wrapper`
# function does on Python versions after 3.2. It sets the ``__wrapped__``
# attribute... | null |
176,408 | from __future__ import absolute_import
from base64 import b64encode
from ..exceptions import UnrewindableBodyError
from ..packages.six import b, integer_types
ACCEPT_ENCODING = "gzip,deflate"
def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ...
The provided code snippet includes necessary depen... | Shortcuts for generating request headers. :param keep_alive: If ``True``, adds 'connection: keep-alive' header. :param accept_encoding: Can be a boolean, list, or string. ``True`` translates to 'gzip,deflate'. List will get joined by comma. String will be used as provided. :param user_agent: String representing the use... |
176,412 | from __future__ import absolute_import
import hmac
import os
import sys
import warnings
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
from ..exceptions import (
InsecurePlatformWarning,
ProxySchemeUnsupported,
SNIMissingWarning,
SSLError,
)
from ..packages import six
from... | Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. |
176,413 | from __future__ import absolute_import
import hmac
import os
import sys
import warnings
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256
from ..exceptions import (
InsecurePlatformWarning,
ProxySchemeUnsupported,
SNIMissingWarning,
SSLError,
)
from ..packages import six
from... | All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object. If none is provided, one will be ... |
176,419 | from __future__ import absolute_import
import json
from collections import OrderedDict
from textblob.compat import PY2, csv
from textblob.utils import is_filelike
_registry = OrderedDict([
('csv', CSV),
('json', JSON),
('tsv', TSV),
])
def is_filelike(obj):
"""Return whether ``obj`` is a file-like obje... | Attempt to detect a file's format, trying each of the supported formats. Return the format class that was detected. If no format is detected, return ``None``. |
176,420 | from __future__ import absolute_import
import json
from collections import OrderedDict
from textblob.compat import PY2, csv
from textblob.utils import is_filelike
def get_registry():
"""Return a dictionary of registered formats."""
return _registry
The provided code snippet includes necessary dependencies for ... | Register a new format. :param str name: The name that will be used to refer to the format, e.g. 'csv' :param type format_class: The format class to register. |
176,421 | import re
import string
def strip_punc(s, all=False):
"""Removes punctuation from a string.
:param s: The string.
:param all: Remove all punctuation. If False, only removes punctuation from
the ends of the string.
"""
if all:
return PUNCTUATION_REGEX.sub('', s.strip())
else:
... | Makes text all lowercase and strips punctuation and whitespace. :param s: The string. :param all: Remove all punctuation. If False, only removes punctuation from the ends of the string. |
176,422 | import re
import string
The provided code snippet includes necessary dependencies for implementing the `tree2str` function. Write a Python function `def tree2str(tree, concat=' ')` to solve the following problem:
Convert a nltk.tree.Tree to a string. For example: (NP a/DT beautiful/JJ new/JJ dashboard/NN) -> "a beauti... | Convert a nltk.tree.Tree to a string. For example: (NP a/DT beautiful/JJ new/JJ dashboard/NN) -> "a beautiful dashboard" |
176,423 | import re
import string
The provided code snippet includes necessary dependencies for implementing the `filter_insignificant` function. Write a Python function `def filter_insignificant(chunk, tag_suffixes=('DT', 'CC', 'PRP$', 'PRP'))` to solve the following problem:
Filter out insignificant (word, tag) tuples from a ... | Filter out insignificant (word, tag) tuples from a chunk of text. |
176,424 | from __future__ import unicode_literals, absolute_import
import sys
import json
import warnings
from collections import defaultdict
import nltk
from textblob.decorators import cached_property, requires_nltk_corpus
from textblob.utils import lowerstrip, PUNCTUATION_REGEX
from textblob.inflect import singularize as _sing... | Converts a Penn corpus tag into a Wordnet tag. |
176,425 | from __future__ import unicode_literals, absolute_import
import sys
import json
import warnings
from collections import defaultdict
import nltk
from textblob.decorators import cached_property, requires_nltk_corpus
from textblob.utils import lowerstrip, PUNCTUATION_REGEX
from textblob.inflect import singularize as _sing... | Common initialization between BaseBlob and Blobber classes. |
176,426 | from __future__ import absolute_import
from itertools import chain
import nltk
from textblob.compat import basestring
from textblob.decorators import cached_property
from textblob.exceptions import FormatError
from textblob.tokenizers import word_tokenize
from textblob.utils import strip_punc, is_filelike
import textbl... | A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list of tuples of the form ``(words, label)`` OR an iterable of str... |
176,427 | from __future__ import absolute_import
from itertools import chain
import nltk
from textblob.compat import basestring
from textblob.decorators import cached_property
from textblob.exceptions import FormatError
from textblob.tokenizers import word_tokenize
from textblob.utils import strip_punc, is_filelike
import textbl... | A basic document feature extractor that returns a dict of words that the document contains. |
176,428 | import sys
import nltk
MIN_CORPORA = [
'brown', # Required for FastNPExtractor
'punkt', # Required for WordTokenizer
'wordnet', # Required for lemmatization
'averaged_perceptron_tagger', # Required for NLTKTagger
]
def download_lite():
for each in MIN_CORPORA:
nltk.download(each) | null |
176,429 | import sys
import nltk
ALL_CORPORA = MIN_CORPORA + ADDITIONAL_CORPORA
def download_all():
for each in ALL_CORPORA:
nltk.download(each) | null |
176,430 | from __future__ import absolute_import
from collections import namedtuple
import nltk
from textblob.en import sentiment as pattern_sentiment
from textblob.tokenizers import word_tokenize
from textblob.decorators import requires_nltk_corpus
from textblob.base import BaseSentimentAnalyzer, DISCRETE, CONTINUOUS
The provi... | Default feature extractor for the NaiveBayesAnalyzer. |
176,431 | import re
plural_prepositions = [
"about", "above", "across", "after", "among", "around", "at", "athwart", "before", "behind",
"below", "beneath", "beside", "besides", "between", "betwixt", "beyond", "but", "by", "during",
"except", "for", "from", "in", "into", "near", "of", "off", "on", "onto", "out", "ove... | Returns the plural of a given word. For example: child -> children. Handles nouns and adjectives, using classical inflection by default (e.g. where "matrix" pluralizes to "matrices" instead of "matrixes"). The custom dictionary is for user-defined replacements. |
176,432 | import re
plural_prepositions = [
"about", "above", "across", "after", "among", "around", "at", "athwart", "before", "behind",
"below", "beneath", "beside", "besides", "between", "betwixt", "beyond", "but", "by", "during",
"except", "for", "from", "in", "into", "near", "of", "off", "on", "onto", "out", "ove... | null |
176,433 | from __future__ import unicode_literals, absolute_import
import nltk
from textblob.taggers import PatternTagger
from textblob.decorators import requires_nltk_corpus
from textblob.utils import tree2str, filter_insignificant
from textblob.base import BaseNPExtractor
The provided code snippet includes necessary dependenc... | Normalize the corpus tags. ("NN", "NN-PL", "NNS") -> "NN" |
176,434 | from __future__ import unicode_literals, absolute_import
import nltk
from textblob.taggers import PatternTagger
from textblob.decorators import requires_nltk_corpus
from textblob.utils import tree2str, filter_insignificant
from textblob.base import BaseNPExtractor
The provided code snippet includes necessary dependenc... | Return whether or not a tagged phrases matches a context-free grammar. |
176,435 | from __future__ import absolute_import
from functools import wraps
from textblob.exceptions import MissingCorpusError
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ...
class MissingCorpusError(TextBlobError):
"""Exception thrown when a user tr... | Wraps a function that requires an NLTK corpus. If the corpus isn't found, raise a :exc:`MissingCorpusError`. |
176,436 | from __future__ import absolute_import
import codecs
import json
import re
from textblob.compat import PY2, request, urlencode
from textblob.exceptions import TranslatorError, NotTranslated
The provided code snippet includes necessary dependencies for implementing the `_unescape` function. Write a Python function `def... | Unescape unicode character codes within a string. |
176,437 | from __future__ import absolute_import
import codecs
import json
import re
from textblob.compat import PY2, request, urlencode
from textblob.exceptions import TranslatorError, NotTranslated
PY2 = int(sys.version[0]) == 2
if PY2:
from itertools import imap, izip
import urllib2 as request
from urllib import... | Reverse engineered cross-site request protection. |
176,438 | import sys
The provided code snippet includes necessary dependencies for implementing the `implements_to_string` function. Write a Python function `def implements_to_string(cls)` to solve the following problem:
Class decorator that renames __str__ to __unicode__ and modifies __str__ that returns utf-8.
Here is the fu... | Class decorator that renames __str__ to __unicode__ and modifies __str__ that returns utf-8. |
176,439 | import sys
The provided code snippet includes necessary dependencies for implementing the `with_metaclass` function. Write a Python function `def with_metaclass(meta, *bases)` to solve the following problem:
Create a base class with a metaclass.
Here is the function:
def with_metaclass(meta, *bases):
"""Create a... | Create a base class with a metaclass. |
176,440 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
The provided code snippet includes necessary dependencies for implementing the `... | Returns the given value as a Unicode string (if possible). |
176,441 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
The provided code snippet includes necessary dependencies for implementing the `... | Returns the given value as a Python byte string (if possible). |
176,442 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
def isnumeric(strg):
try:
float(strg)
except ValueError:
... | null |
176,443 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
NOUN, VERB, ADJ, ADV, PRON, DET, PREP, ADP, NUM, CONJ, INTJ, PRT, PUNC, X = \
... | Returns a (token, tag)-tuple with a simplified universal part-of-speech tag. |
176,444 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
TOKEN = re.compile(r"(\S+)\s")
PUNCTUATION = \
punctuation = ".,;:!?()[]{}`''\"@#... | Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence. Headings without an ending period are inferred by line breaks. |
176,445 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
decode_utf8 = decode_string
PY2 = int(sys.version[0]) == 2
if PY2:
from ite... | Returns an iterator over the lines in the file at the given path, stripping comments and decoding each line to Unicode. |
176,446 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
def avg(list):
return sum(list) / float(len(list) or 1) | null |
176,447 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
CD = re.compile(r"^[0-9\-\,\.\:\/\%\$]+$")
def _suffix_rules(token, tag="NN"):
... | Returns a list of [token, tag]-items for the given list of tokens: ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]] Words are tagged using the given lexicon of (word, tag)-items. Unknown words are tagged NN by default. Unknown words that start with a capital letter are tagged NNP (unless languag... |
176,448 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
SEPARATOR = "/"
CHUNKS = [[
# Germanic languages: en, de, nl, ...
( "NP"... | The input is a list of [token, tag]-items. The output is a list of [token, tag, chunk]-items: The/DT nice/JJ fish/NN is/VBZ dead/JJ ./. => The/DT/B-NP nice/JJ/I-NP fish/NN/I-NP is/VBZ/B-VP dead/JJ/B-ADJP ././O |
176,449 | from __future__ import unicode_literals
import string
import codecs
from itertools import chain
import types
import os
import re
from xml.etree import cElementTree
from .compat import text_type, basestring, imap, unicode, binary_type, PY2
The provided code snippet includes necessary dependencies for implementing the `... | The input is a list of [token, tag, chunk]-items. The output is a list of [token, tag, chunk, preposition]-items. PP-chunks followed by NP-chunks make up a PNP-chunk. |
176,451 | import typing as t
from . import Markup
def escape(s: t.Any) -> Markup:
"""Replace the characters ``&``, ``<``, ``>``, ``'``, and ``"`` in
the string with HTML-safe sequences. Use this if you need to display
text that might contain such characters in HTML.
If the object has an ``__html__`` method, it is... | Like :func:`escape` but treats ``None`` as the empty string. Useful with optional values, as otherwise you get the string ``'None'`` when the value is ``None``. >>> escape(None) Markup('None') >>> escape_silent(None) Markup('') |
176,452 | import typing as t
from . import Markup
The provided code snippet includes necessary dependencies for implementing the `soft_str` function. Write a Python function `def soft_str(s: t.Any) -> str` to solve the following problem:
Convert an object to a string if it isn't already. This preserves a :class:`Markup` string ... | Convert an object to a string if it isn't already. This preserves a :class:`Markup` string rather than converting it back to a basic string, so it will still be marked as safe and won't be escaped again. >>> value = escape("<User 1>") >>> value Markup('<User 1>') >>> escape(str(value)) Markup('&lt;User 1&... |
176,453 | from textwrap import dedent
from parso import split_lines
from jedi import debug
from jedi.api.exceptions import RefactoringError
from jedi.api.refactoring import Refactoring, EXPRESSION_PARTS
from jedi.common import indent_block
from jedi.parser_utils import function_is_classmethod, function_is_staticmethod
def _is_ex... | null |
176,454 | from textwrap import dedent
from parso import split_lines
from jedi import debug
from jedi.api.exceptions import RefactoringError
from jedi.api.refactoring import Refactoring, EXPRESSION_PARTS
from jedi.common import indent_block
from jedi.parser_utils import function_is_classmethod, function_is_staticmethod
def _is_ex... | null |
176,455 | import pydoc
from contextlib import suppress
from typing import Dict, Optional
from jedi.inference.names import AbstractArbitraryName
The provided code snippet includes necessary dependencies for implementing the `imitate_pydoc` function. Write a Python function `def imitate_pydoc(string)` to solve the following probl... | It's not possible to get the pydoc's without starting the annoying pager stuff. |
176,456 | from jedi.inference import compiled
from jedi.inference.base_value import ValueSet
from jedi.inference.filters import ParserTreeFilter, MergedFilter
from jedi.inference.names import TreeNameDefinition
from jedi.inference.compiled import mixed
from jedi.inference.compiled.access import create_access_path
from jedi.infer... | null |
176,457 | from typing import Dict, Tuple, Callable
CacheValuesCallback = Callable[[], CacheValues]
_cache: Dict[str, Dict[str, CacheValues]] = {}
def save_entry(module_name: str, name: str, cache: CacheValues) -> None:
try:
module_cache = _cache[module_name]
except KeyError:
module_cache = _cache[module_n... | null |
176,458 | import os
import sys
import hashlib
import filecmp
from collections import namedtuple
from shutil import which
from jedi.cache import memoize_method, time_cache
from jedi.inference.compiled.subprocess import CompiledSubprocess, \
InferenceStateSameProcess, InferenceStateSubprocess
import parso
import sys
if sys.v... | null |
176,459 | import os
import sys
import hashlib
import filecmp
from collections import namedtuple
from shutil import which
from jedi.cache import memoize_method, time_cache
from jedi.inference.compiled.subprocess import CompiledSubprocess, \
InferenceStateSameProcess, InferenceStateSubprocess
import parso
_CONDA_VAR = 'CONDA_P... | null |
176,460 | import os
import sys
import hashlib
import filecmp
from collections import namedtuple
from shutil import which
from jedi.cache import memoize_method, time_cache
from jedi.inference.compiled.subprocess import CompiledSubprocess, \
InferenceStateSameProcess, InferenceStateSubprocess
import parso
_CONDA_VAR = 'CONDA_P... | :param paths: A list of paths in your file system to be scanned for Virtualenvs. It will search in these paths and potentially execute the Python binaries. :param safe: Default True. In case this is False, it will allow this function to execute potential `python` environments. An attacker might be able to drop an execu... |
176,461 | class SyntaxError:
"""
Syntax errors are generated by :meth:`.Script.get_syntax_errors`.
"""
def __init__(self, parso_error):
self._parso_error = parso_error
def line(self):
"""The line where the error starts (starting with 1)."""
return self._parso_error.start_pos[0]
def... | null |
176,462 | import os
from jedi.api import classes
from jedi.api.strings import StringName, get_quote_ending
from jedi.api.helpers import match
from jedi.inference.helpers import get_str_or_none
class PathName(StringName):
def _get_string_additions(module_context, start_leaf):
def _add_os_path_join(module_context, start_leaf, brac... | null |
176,463 | import json
from pathlib import Path
from itertools import chain
from jedi import debug
from jedi.api.environment import get_cached_default_environment, create_environment
from jedi.api.exceptions import WrongVersion
from jedi.api.completion import search_in_module
from jedi.api.helpers import split_search_string, get_... | null |
176,464 | import json
from pathlib import Path
from itertools import chain
from jedi import debug
from jedi.api.environment import get_cached_default_environment, create_environment
from jedi.api.exceptions import WrongVersion
from jedi.api.completion import search_in_module
from jedi.api.helpers import split_search_string, get_... | null |
176,465 | import json
from pathlib import Path
from itertools import chain
from jedi import debug
from jedi.api.environment import get_cached_default_environment, create_environment
from jedi.api.exceptions import WrongVersion
from jedi.api.completion import search_in_module
from jedi.api.helpers import split_search_string, get_... | If a project is not defined by the user, Jedi tries to define a project by itself as well as possible. Jedi traverses folders until it finds one of the following: 1. A ``.jedi/config.json`` 2. One of the following files: ``setup.py``, ``.git``, ``.hg``, ``requirements.txt`` and ``MANIFEST.in``. |
176,466 | import json
from pathlib import Path
from itertools import chain
from jedi import debug
from jedi.api.environment import get_cached_default_environment, create_environment
from jedi.api.exceptions import WrongVersion
from jedi.api.completion import search_in_module
from jedi.api.helpers import split_search_string, get_... | null |
176,467 | import re
from pathlib import Path
from typing import Optional
from parso.tree import search_ancestor
from jedi import settings
from jedi import debug
from jedi.inference.utils import unite
from jedi.cache import memoize_method
from jedi.inference.compiled.mixed import MixedName
from jedi.inference.names import ImportN... | null |
176,468 | import re
from jedi.inference.names import AbstractArbitraryName
from jedi.inference.helpers import infer_call_of_leaf
from jedi.api.classes import Completion
from jedi.parser_utils import cut_value_at_position
def _completions_for_dicts(inference_state, dicts, literal_string, cut_end_quote, fuzzy):
for dict_key in... | null |
176,469 | import re
from collections import namedtuple
from textwrap import dedent
from itertools import chain
from functools import wraps
from inspect import Parameter
from parso.python.parser import Parser
from parso.python import tree
from jedi.inference.base_value import NO_VALUES
from jedi.inference.syntax_tree import infer... | null |
176,470 | import re
from collections import namedtuple
from textwrap import dedent
from itertools import chain
from functools import wraps
from inspect import Parameter
from parso.python.parser import Parser
from parso.python import tree
from jedi.inference.base_value import NO_VALUES
from jedi.inference.syntax_tree import infer... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.