namespace
stringlengths
12
102
type
stringclasses
2 values
project_path
stringclasses
115 values
completion_path
stringlengths
20
110
signature_position
listlengths
2
2
body_position
listlengths
2
2
dependency
dict
requirement
dict
tests
listlengths
1
5
indent
int64
2
12
prompt
stringlengths
358
22.1k
target_function_prompt
stringlengths
15
74.4k
benedict.utils.type_util.is_json_serializable
function
Text-Processing/python-benedict
Text-Processing/python-benedict/benedict/utils/type_util.py
[ 53, 53 ]
[ 54, 55 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param val: Any. The input value to be checked for JSON serializability.\n:return: Bool. True if the input value is JSON serializable, False otherwise.", "Functionality": "Check if the input value is JSON serializable. It checks if the input value is of the JSON serializable types." }
[ "tests/utils/test_type_util.py::type_util_test_case::test_is_json_serializable" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/python-benedict/benedict/utils/type_util.py import pathlib import re from datetime import datetime from decimal import Decimal regex = re.compile("").__class__ uu...
def is_json_serializable(val):
feedparser.urls.convert_to_idn
function
Text-Processing/feedparser
Text-Processing/feedparser/feedparser/urls.py
[ 61, 61 ]
[ 66, 83 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param url: String. The URL to be converted to IDN notation.\n:return: String. The URL in IDN notation.", "Functionality": "Convert a URL to IDN notation. It checks if the host can be encoded in ASCII. If not, it converts the host to IDN form." }
[ "tests/runtests.py::TestConvertToIdn::test_port", "tests/runtests.py::TestConvertToIdn::test_idn", "tests/runtests.py::TestConvertToIdn::test_control" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/feedparser/feedparser/html.py # lines: 195-206 # def handle_charref(self, ref): # """ # :type ref: str # :rtype: None # """ # ...
def convert_to_idn(url): """Convert a URL to IDN notation"""
mistune.toc.add_toc_hook
function
Text-Processing/mistune
Text-Processing/mistune/src/mistune/toc.py
[ 4, 4 ]
[ 23, 44 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param md: Markdown instance. The instance of the Markdown class.\n:param min_level: Integer. The minimum heading level to include in the TOC.\n:param max_level: Integer. The maximum heading level to include in the TOC.\n:param heading_id: Function. A function to generate heading_id.\n:return: No retu...
[ "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/mistune/src/mistune/util.py # lines: 22-36 # def escape_url(link: str): # """Escape URL for safety.""" # safe = ( # ':/?#@' # gen-delims - '...
def add_toc_hook(md, min_level=1, max_level=3, heading_id=None): """Add a hook to save toc items into ``state.env``. This is usually helpful for doc generator:: import mistune from mistune.toc import add_toc_hook, render_toc_ul md = mistune.create_markdown(...) add_toc_hook(md)...
mistune.plugins.table.table_in_quote
function
Text-Processing/mistune
Text-Processing/mistune/src/mistune/plugins/table.py
[ 170, 170 ]
[ 172, 173 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param md: Markdown. The Markdown instance.\n:return: No return values.", "Functionality": "This function enables the table plugin in block quotes by inserting rules for table and nptable before the paragraph in the block quote rules." }
[ "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/mistune/src/mistune/helpers.py # lines: 41-50 # def unescape_char(text): # return _ESCAPE_CHAR_RE.sub(r'\1', text) # def parse_link_text(src, pos): # level = ...
def table_in_quote(md): """Enable table plugin in block quotes."""
mistune.plugins.table.table_in_list
function
Text-Processing/mistune
Text-Processing/mistune/src/mistune/plugins/table.py
[ 176, 176 ]
[ 178, 179 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param md: Markdown. The Markdown instance to enable the table plugin in the list.\n:return: No return values.", "Functionality": "This function enables the table plugin in the list. It inserts the table and nptable rules before the paragraph rule in the list." }
[ "tests/test_plugins.py::TestExtraPlugins::test_table_in_list" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/mistune/src/mistune/helpers.py # lines: 26-40 # BLOCK_TAGS = ( # 'address', 'article', 'aside', 'base', 'basefont', 'blockquote', # 'body', 'caption', 'center...
def table_in_list(md): """Enable table plugin in list."""
xmnlp.utils.parallel_handler
function
Text-Processing/xmnlp
Text-Processing/xmnlp/xmnlp/utils/__init__.py
[ 90, 92 ]
[ 101, 107 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param callback: Callable. The callback function to be applied to the list of texts.\n:param texts: List[str]. The list of texts to be processed.\n:param n_jobs: int. The pool size of threads. Defaults to 2.\n:param kwargs: Any additional keyword arguments to be passed to the callback function.\n:retu...
[ "tests/test_xmnlp.py::test_radical_parallel", "tests/test_xmnlp.py::test_pinyin_parallel" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/PyLaTeX/pylatex/lists.py # lines: 1-15 # # -*- coding: utf-8 -*- # """ # This module implements the classes that deal with LaTeX lists. # These lists are specifically...
def parallel_handler(callback: Callable, texts: List[str], n_jobs: int = 2, **kwargs) -> Generator[ List[Any], None, None ]: """parallel handler Args: callback: callback function texts: List[str] n_jobs: int, pool size of threads Return: Generator[List[str]] """
parsel.utils.shorten
function
Text-Processing/parsel
Text-Processing/parsel/parsel/utils.py
[ 87, 87 ]
[ 89, 95 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param text: String. The input text to be shortened.\n:param width: Integer. The width to which the text should be shortened.\n:param suffix: String. The suffix to be added at the end of the shortened text. Defaults to \"...\".\n:return: String. The shortened text.", "Functionality": "Shorten the gi...
[ "tests/test_utils.py::test_shorten" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/extractors.py # lines: 51-59 # def find(self, text): # matches = list(self(text)) # if not matches: # return # ...
def shorten(text: str, width: int, suffix: str = "...") -> str: """Truncate the given text to fit in the given width."""
parsel.xpathfuncs.set_xpathfunc
function
Text-Processing/parsel
Text-Processing/parsel/parsel/xpathfuncs.py
[ 13, 13 ]
[ 27, 31 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param fname: String. The identifier under which the function will be registered.\n:param func: Callable. The function to be registered. If None, the extension function will be removed.\n:return: No return values.", "Functionality": "This function registers a custom extension function to use in XPat...
[ "tests/test_xpathfuncs.py::XPathFuncsTestCase::test_set_xpathfunc" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/parsel/parsel/xpathfuncs.py import re from typing import Any, Callable, Optional from lxml import etree from w3lib.html import HTML5_WHITESPACE regex = f"[{HTM...
def set_xpathfunc(fname: str, func: Optional[Callable]) -> None: # type: ignore[type-arg] """Register a custom extension function to use in XPath expressions. The function ``func`` registered under ``fname`` identifier will be called for every matching node, being passed a ``context`` parameter as well as...
dominate.dom_tag._get_thread_context
function
Text-Processing/dominate
Text-Processing/dominate/dominate/dom_tag.py
[ 47, 47 ]
[ 48, 51 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param: No input parameters.\n:return: Integer. The hash value of the current thread context.", "Functionality": "This function returns the hash value of the current thread context. It first creates a list of the current thread and greenlet (if available) and then returns the hash value of the tuple...
[ "tests/test_dom_tag.py::test___get_thread_context" ]
2
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/dominate/dominate/util.py # lines: 117-130 # def __init__(self, func, *args, **kwargs): # super(lazy, self).__init__() # self.func = func # self.args ...
def _get_thread_context():
dominate.util.system
function
Text-Processing/dominate
Text-Processing/dominate/dominate/util.py
[ 45, 45 ]
[ 49, 52 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param cmd: String. The system command to be executed.\n:param data: Bytes. Optional input data to be passed to the command.\n:return: String. The output of the system command as a decoded string.", "Functionality": "This function runs a system command and returns the output as a string. It uses the...
[ "tests/test_utils.py::test_system" ]
2
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/dominate/dominate/dom_tag.py # lines: 41-55 # class dom_tag(object): # is_single = False # Tag does not require matching end tag (ex. <hr/>) # is_pretty = True ...
def system(cmd, data=None): ''' pipes the output of a program '''
dominate.util.url_unescape
function
Text-Processing/dominate
Text-Processing/dominate/dominate/util.py
[ 118, 118 ]
[ 119, 120 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param data: String. The URL-encoded string to be unescaped.\n:return: String. The unescaped string.", "Functionality": "This function takes a string as input and unescapes any URL-encoded characters in the string." }
[ "tests/test_utils.py::test_url" ]
2
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/dominate/dominate/dom_tag.py # lines: 147-161 # if isinstance(obj, basestring): # obj = util.escape(obj) # self.children.append(obj) # eli...
def url_unescape(data):
rows.fields.DatetimeField.serialize
method
Text-Processing/rows
Text-Processing/rows/rows/fields.py
[ 390, 390 ]
[ 391, 394 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param cls: Class. The class instance.\n:param value: Datetime. The datetime value to be serialized.\n:param *args: Additional positional arguments.\n:param **kwargs: Additional keyword arguments.\n:return: String. The serialized datetime value in ISO 8601 format.", "Functionality": "Serialize the g...
[ "tests/tests_fields.py::FieldsTestCase::test_DatetimeField" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/norm.py # lines: 29-43 # def feats_match(a, b): # return ( # a.get(GENDER) == b.get(GENDER) # and a.get(NUMBER) == b.get(NUMBER) #...
class DatetimeField(Field): """Field class to represent date-time Is not locale-aware (does not need to be) """ TYPE = (datetime.datetime,) DATETIME_REGEXP = re.compile( "^([0-9]{4})-([0-9]{2})-([0-9]{2})[ T]" "([0-9]{2}):([0-9]{2}):([0-9]{2})$" ) @classmethod def serialize(cl...
rows.fields.Field.serialize
method
Text-Processing/rows
Text-Processing/rows/rows/fields.py
[ 77, 77 ]
[ 84, 86 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param cls: Class. The class instance.\n:param value: Any. The value to be serialized.\n:param *args: Tuple. Additional positional arguments.\n:param **kwargs: Dictionary. Additional keyword arguments.\n:return: Any. The serialized value.", "Functionality": "This function serializes a value to be ex...
[ "tests/tests_fields.py::FieldsTestCase::test_Field", "tests/tests_fields.py::FieldsTestCase::test_TextField" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/norm.py # lines: 29-43 # def feats_match(a, b): # return ( # a.get(GENDER) == b.get(GENDER) # and a.get(NUMBER) == b.get(NUMBER) #...
class Field(object): """Base Field class - all fields should inherit from this As the fallback for all other field types are the BinaryField, this Field actually implements what is expected in the BinaryField """ TYPE = (type(None),) @classmethod def serialize(cls, value, *args, **kwargs)...
rows.fields.EmailField.serialize
method
Text-Processing/rows
Text-Processing/rows/rows/fields.py
[ 438, 438 ]
[ 439, 442 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param cls: Class. The class itself.\n:param value: Any. The value to be serialized.\n:param *args: Tuple. Additional positional arguments.\n:param **kwargs: Dictionary. Additional keyword arguments.\n:return: String. The serialized value.", "Functionality": "Serialize the value of the email field. ...
[ "tests/tests_fields.py::FieldsTestCase::test_EmailField" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/norm.py # lines: 83-91 # def syntax_normalize(vocab, tokens): # ids = set(select_inflectable(tokens)) # words = inflect_words(vocab, tokens, i...
class EmailField(TextField): """Field class to represent e-mail addresses Is not locale-aware (does not need to be) """ EMAIL_REGEXP = re.compile( r"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$", flags=re.IGNORECASE ) @classmethod def serialize(cls, value, *args, **kwargs):
rows.fields.as_string
function
Text-Processing/rows
Text-Processing/rows/rows/fields.py
[ 478, 478 ]
[ 479, 484 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param value: Any. The input value to be converted to a string.\n:return: String. The input value converted to a string.", "Functionality": "Convert the input value to a string. If the input value is already a string, it returns the input value. If the input value is a binary type, it raises a Value...
[ "tests/tests_fields.py::FieldsFunctionsTestCase::test_as_string" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/norm.py # lines: 29-43 # def feats_match(a, b): # return ( # a.get(GENDER) == b.get(GENDER) # and a.get(NUMBER) == b.get(NUMBER) #...
def as_string(value):
rows.fields.get_items
function
Text-Processing/rows
Text-Processing/rows/rows/fields.py
[ 506, 506 ]
[ 513, 515 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param indexes: Tuple. The indexes of the object to be fetched.\n:return: Lambda function. A callable that fetches the given indexes of an object.", "Functionality": "This function returns a callable that fetches the given indexes of an object. It always returns a tuple even when len(indexes) == 1. ...
[ "tests/tests_fields.py::FieldsFunctionsTestCase::test_get_items" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/norm.py # lines: 14-28 # def recover_spaces(words, tokens): # offset = None # parts = [] # for index, (word, token) in enumerate(zip(words...
def get_items(*indexes): """Return a callable that fetches the given indexes of an object Always return a tuple even when len(indexes) == 1. Similar to `operator.itemgetter`, but will insert `None` when the object does not have the desired index (instead of raising IndexError). """
pycorrector.proper_corrector.load_dict_file
function
Text-Processing/pycorrector
Text-Processing/pycorrector/pycorrector/proper_corrector.py
[ 31, 31 ]
[ 37, 52 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param path: String. The file path from which the dictionary is to be loaded.\n:return: Dictionary. The loaded dictionary from the file. If the file is not found, an empty dictionary is returned.", "Functionality": "Load a dictionary from the given file path. It reads the file line by line and creat...
[ "tests/ner_error_test.py::test_common_error" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/pycorrector/pycorrector/utils/tokenizer.py # lines: 109-119 # class Tokenizer(object): # def __init__(self, dict_path='', custom_word_freq_dict=None, custom_confu...
def load_dict_file(path): """ 加载词典 :param path: :return: """
natasha.span.envelop_spans
function
Text-Processing/natasha
Text-Processing/natasha/natasha/span.py
[ 23, 23 ]
[ 24, 37 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param spans: List of spans. The spans to be enveloped.\n:param envelopes: List of envelopes. The envelopes used to envelop the spans.\n:return: Yield the chunk of spans for each envelope.", "Functionality": "This function envelops the spans based on the given envelopes. It iterates through the span...
[ "tests/test_span.py::test_envelope_spans" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/natasha/natasha/record.py # lines: 1-12 # from collections import OrderedDict # def parse_annotation(annotation): # type = annotation or str # repeatable = Fa...
def envelop_spans(spans, envelopes):
googleapiclient._helpers.parse_unique_urlencoded
function
Internet/google-api-python-client
Internet/google-api-python-client/googleapiclient/_helpers.py
[ 141, 141 ]
[ 153, 163 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param content: string. URL-encoded key-value pairs.\n:return: dict. The key-value pairs from the input content.\nRaises:\nValueError: if one of the keys is repeated.", "Functionality": "This function parses unique key-value parameters from URL-encoded content. It first parses the URL-encoded conten...
[ "tests/test__helpers.py::Test_parse_unique_urlencoded::test_without_repeats", "tests/test__helpers.py::Test_parse_unique_urlencoded::test_with_repeats" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/oauth2/rfc7523/validator.py # lines: 1-15 # import time # import logging # from authlib.jose import jwt, JoseError, JWTClaims # from ..rfc6749 import TokenMi...
def parse_unique_urlencoded(content): """Parses unique key-value parameters from urlencoded content. Args: content: string, URL-encoded key-value pairs. Returns: dict, The key-value pairs from ``content``. Raises: ValueError: if one of the keys is repeated. """
jinja2.async_utils.auto_aiter
function
Internet/Jinja2
Internet/Jinja2/src/jinja2/async_utils.py
[ 70, 72 ]
[ 73, 78 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param iterable: Union of AsyncIterable and Iterable. The input iterable from which the iterator is created.\n:return: AsyncIterator. The created asynchronous iterator.", "Functionality": "This function creates an asynchronous iterator from the given iterable. It checks if the iterable has an __aite...
[ "tests/test_async.py::test_async_iteration_in_templates_extended" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Jinja2/src/jinja2/utils.py # lines: 444-454 # def select_autoescape( # enabled_extensions: t.Collection[str] = ("html", "htm", "xml"), # disabled_extensions: t.Colle...
def auto_aiter( iterable: "t.Union[t.AsyncIterable[V], t.Iterable[V]]", ) -> "t.AsyncIterator[V]":
jinja2.utils.consume
function
Internet/Jinja2
Internet/Jinja2/src/jinja2/utils.py
[ 112, 112 ]
[ 114, 115 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param iterable: Iterable. The iterable to be consumed.\n:return: No return values.", "Functionality": "This function consumes an iterable without doing anything with it. It iterates through the given iterable and does nothing with the elements." }
[ "tests/test_utils.py::test_consume" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Jinja2/src/jinja2/compiler.py # lines: 93-107 # generator = environment.code_generator_class( # environment, name, filename, stream, defer_init, optimized # ...
def consume(iterable: t.Iterable[t.Any]) -> None: """Consumes an iterable without doing anything with it."""
pycorrector.utils.tokenizer.segment
function
Text-Processing/pycorrector
Text-Processing/pycorrector/pycorrector/utils/tokenizer.py
[ 101, 101 ]
[ 109, 128 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param sentence: String. The input sentence to be segmented.\n:param cut_type: String. The type of segmentation to be used. It defaults to 'word' if not specified.\n:param pos: Bool. Whether to enable POS tagging. It defaults to False if not specified.\n:return: List. The segmented words or characters...
[ "tests/ner_error_test.py::test_ner" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Text-Processing/pycorrector/pycorrector/utils/text_utils.py # lines: 78-89 # def get_homophones_by_char(input_char): # """ # 根据汉字取同音字 # :param input_char: # :return: ...
def segment(sentence, cut_type='word', pos=False): """ 切词 :param sentence: :param cut_type: 'word' use jieba.lcut; 'char' use list(sentence) :param pos: enable POS :return: list """
jinja2.utils.object_type_repr
function
Internet/Jinja2
Internet/Jinja2/src/jinja2/utils.py
[ 165, 165 ]
[ 170, 180 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param obj: Any. The object for which the type name is to be returned.\n:return: str. The name of the object's type or the name of the object if it is a recognized singleton.", "Functionality": "This function returns the name of the object's type. For some recognized singletons, the name of the obje...
[ "tests/test_utils.py::TestHelpers::test_object_type_repr" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Jinja2/src/jinja2/compiler.py # lines: 93-107 # generator = environment.code_generator_class( # environment, name, filename, stream, defer_init, optimized # ...
def object_type_repr(obj: t.Any) -> str: """Returns the name of the object's type. For some recognized singletons the name of the object is returned instead. (For example for `None` and `Ellipsis`). """
jinja2.utils.LRUCache.setdefault
method
Internet/Jinja2
Internet/Jinja2/src/jinja2/utils.py
[ 470, 470 ]
[ 474, 478 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: LRUCache. An instance of the LRUCache class.\n:param key: Any. The key to be checked and set in the cache.\n:param default: Any. The default value to be set for the key if it is not already in the cache. Defaults to None.\n:return: Any. The value of the key.", "Functionality": "Set the ...
[ "tests/test_utils.py::TestLRUCache::test_setdefault" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Jinja2/src/jinja2/compiler.py # lines: 486-496 # def leave_frame(self, frame: Frame, with_python_scope: bool = False) -> None: # if not with_python_scope: # ...
class LRUCache: """A simple LRU Cache implementation.""" # this is fast for small capacities (something below 1000) but doesn't # scale. But as long as it's only used as storage for templates this # won't do any harm. def __init__(self, capacity: int) -> None: self.capacity = capacity ...
sumy.summarizers.sum_basic.SumBasicSummarizer._compute_word_freq
method
Internet/sumy
Internet/sumy/sumy/summarizers/sum_basic.py
[ 49, 49 ]
[ 50, 53 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param list_of_words: List of strings. The list of words for which the frequency needs to be computed.\n:return: Dictionary. A dictionary containing the frequency of each word in the input list.", "Functionality": "This function computes the frequency of each word in the given list of words and retu...
[ "tests/test_summarizers/test_sum_basic.py::test_compute_word_freq" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/summarizers/_summarizer.py # lines: 15-29 # def __call__(self, document, sentences_count): # raise NotImplementedError("This method should be overriden...
class SumBasicSummarizer(AbstractSummarizer): """ SumBasic: a frequency-based summarization system that adjusts word frequencies as sentences are extracted. Source: http://www.cis.upenn.edu/~nenkova/papers/ipm.pdf """ _stop_words = frozenset() @property def stop_words(self): ret...
sumy.summarizers.sum_basic.SumBasicSummarizer._compute_average_probability_of_words
method
Internet/sumy
Internet/sumy/sumy/summarizers/sum_basic.py
[ 72, 72 ]
[ 73, 79 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param word_freq_in_doc: Dictionary. The frequency of words in the document.\n:param content_words_in_sentence: List. The content words in a sentence.\n:return: Float. The average probability of words in the document. If the content words count is 0, it returns 0.", "Functionality": "This function c...
[ "tests/test_summarizers/test_sum_basic.py::test_compute_average_probability_of_words" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/summarizers/_summarizer.py # lines: 15-29 # def __call__(self, document, sentences_count): # raise NotImplementedError("This method should be overriden...
class SumBasicSummarizer(AbstractSummarizer): """ SumBasic: a frequency-based summarization system that adjusts word frequencies as sentences are extracted. Source: http://www.cis.upenn.edu/~nenkova/papers/ipm.pdf """ _stop_words = frozenset() @property def stop_words(self): ret...
sumy.summarizers.lex_rank.LexRankSummarizer._compute_idf
method
Internet/sumy
Internet/sumy/sumy/summarizers/lex_rank.py
[ 78, 78 ]
[ 79, 88 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param sentences: List of strings. The sentences to compute IDF.\n:return: Dictionary. The IDF metrics for each term in the sentences.", "Functionality": "This function computes the inverse document frequency (IDF) for each term in the sentences." }
[ "tests/test_summarizers/test_lex_rank.py::test_idf_metrics" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/summarizers/_summarizer.py # lines: 15-29 # def __call__(self, document, sentences_count): # raise NotImplementedError("This method should be overriden...
class LexRankSummarizer(AbstractSummarizer): """ LexRank: Graph-based Centrality as Salience in Text Summarization Source: http://tangra.si.umich.edu/~radev/lexrank/lexrank.pdf """ threshold = 0.1 epsilon = 0.1 _stop_words = frozenset() @property def stop_words(self): return...
sumy.summarizers.lex_rank.LexRankSummarizer.cosine_similarity
method
Internet/sumy
Internet/sumy/sumy/summarizers/lex_rank.py
[ 119, 119 ]
[ 142, 156 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param sentence1: Iterable object. Every item represents a word of the 1st sentence.\n:param sentence2: Iterable object. Every item represents a word of the 2nd sentence.\n:param tf1: Dict. Term frequencies of words from the 1st sentence.\n:param tf2: Dict. Term frequencies of words from the 2nd sente...
[ "tests/test_summarizers/test_lex_rank.py::test_cosine_similarity_for_the_same_sentence_with_duplicate_words_should_be_one", "tests/test_summarizers/test_lex_rank.py::test_cosine_similarity_sentences_with_no_common_word_should_be_zero" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/summarizers/_summarizer.py # lines: 30-38 # # sort sentences by rating in descending order # infos = sorted(infos, key=attrgetter("rating"), revers...
class LexRankSummarizer(AbstractSummarizer): """ LexRank: Graph-based Centrality as Salience in Text Summarization Source: http://tangra.si.umich.edu/~radev/lexrank/lexrank.pdf """ threshold = 0.1 epsilon = 0.1 _stop_words = frozenset() @property def stop_words(self): return...
sumy.evaluation.rouge._get_ngrams
function
Internet/sumy
Internet/sumy/sumy/evaluation/rouge.py
[ 9, 9 ]
[ 10, 15 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param n: Integer. The size of the n-grams.\n:param text: String. The input text from which n-grams are generated.\n:return: Set. A set of n-grams generated from the input text.", "Functionality": "This function generates n-grams from the given text." }
[ "tests/test_evaluation/test_evaluation_rouge.py::test_get_ngrams" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/models/dom/_sentence.py # lines: 1-15 # # -*- coding: utf-8 -*- # from __future__ import absolute_import # from __future__ import division, print_function, unicode...
def _get_ngrams(n, text):
sumy.evaluation.rouge._split_into_words
function
Internet/sumy
Internet/sumy/sumy/evaluation/rouge.py
[ 18, 18 ]
[ 19, 24 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param sentences: List of Sentence instances. The input sentences to be split into words.\n:return: List of String. The list of words obtained after splitting the sentences.", "Functionality": "This function splits the input sentences into words and returns a list of words. If there exists a element...
[ "tests/test_evaluation/test_evaluation_rouge.py::test_split_into_words" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/sumy/sumy/models/dom/_sentence.py # lines: 1-15 # # -*- coding: utf-8 -*- # from __future__ import absolute_import # from __future__ import division, print_function, unicode...
def _split_into_words(sentences):
falcon.inspect.register_router
function
Internet/falcon
Internet/falcon/falcon/inspect.py
[ 71, 71 ]
[ 89, 98 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param router_class: Type. The router class to register. If already registered, an error will be raised.\n:return: The new function that inspects the router.", "Functionality": "This function is a decorator that registers a new function for a custom router class. It takes the router class as input a...
[ "tests/test_inspect.py::TestRouter::test_register_other_router", "tests/test_inspect.py::TestRouter::test_register_router_multiple_time" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/routing/compiled.py # lines: 110-124 # Keyword Args: # suffix (str): Optional responder name suffix for this route. If # a ...
def register_router(router_class): """Register a function to inspect a particular router. This decorator registers a new function for a custom router class, so that it can be inspected with the function :func:`.inspect_routes`. An inspection function takes the router instance used by the applic...
falcon.inspect.inspect_compiled_router
function
Internet/falcon
Internet/falcon/falcon/inspect.py
[ 204, 204 ]
[ 216, 245 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param router: CompiledRouter. The router to inspect.\n:return: List[RouteInfo]. A list of RouteInfo objects representing the defined routes.", "Functionality": "This function inspects a compiled router to return a list of defined routes. It walks through the compiled router and extracts information...
[ "tests/test_inspect.py::TestRouter::test_compiled_partial", "tests/test_inspect.py::TestRouter::test_compiled_no_method_map" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/routing/compiled.py # lines: 216-230 # Keyword Args: # req: The :class:`falcon.Request` or :class:`falcon.asgi.Request` # o...
def inspect_compiled_router(router: CompiledRouter) -> 'List[RouteInfo]': """Walk an instance of :class:`~.CompiledRouter` to return a list of defined routes. Default route inspector for CompiledRouter. Args: router (CompiledRouter): The router to inspect. Returns: List[RouteInfo]: A ...
falcon.inspect._is_internal
function
Internet/falcon
Internet/falcon/falcon/inspect.py
[ 787, 787 ]
[ 789, 792 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param obj: Object. The object to be checked.\n:return: Bool. True if the module of the object is a falcon module, False otherwise.", "Functionality": "This function checks if the module of the object is a falcon module." }
[ "tests/test_inspect.py::test_is_internal" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Jinja2/src/jinja2/nodes.py # lines: 776-790 # class ImportedName(Expr): # """If created with an import name the import name is returned on node # access. For exampl...
def _is_internal(obj): """Check if the module of the object is a falcon module."""
falcon.cmd.inspect_app.load_app
function
Internet/falcon
Internet/falcon/falcon/cmd/inspect_app.py
[ 61, 62 ]
[ 63, 86 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param parser: The parser object.\n:param args: The arguments object.\n:return: falcon.App. The loaded falcon app instance.", "Functionality": "This function loads the app based on the given parser and args. It first splits the app_module into module and instance. Then, it tries to get the app insta...
[ "tests/test_cmd_inspect_app.py::TestLoadApp::test_load_app_module_error", "tests/test_cmd_inspect_app.py::TestLoadApp::test_load_app", "tests/test_cmd_inspect_app.py::TestLoadApp::test_load_app_error" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/inspect.py # lines: 42-56 # Args: # app (falcon.App): The application to inspect. Works with both # :class:`falcon.App` and :class:`fal...
def load_app(parser, args):
falcon.cmd.inspect_app.make_parser
function
Internet/falcon
Internet/falcon/falcon/cmd/inspect_app.py
[ 31, 31 ]
[ 33, 58 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param: No input parameters.\n:return: ArgumentParser. The created parser instance.", "Functionality": "Create a parser for the application with the specified arguments and options. The arguments contains \"-r (--router)\", \"-v (--verbose)\", \"-i (--internal)\", and \"app_module\"." }
[ "tests/test_cmd_inspect_app.py::TestLoadApp::test_load_app_module_error", "tests/test_cmd_inspect_app.py::TestMakeParser::test_make_parser_error", "tests/test_cmd_inspect_app.py::TestMakeParser::test_make_parser", "tests/test_cmd_inspect_app.py::TestLoadApp::test_load_app_error" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/inspect.py # lines: 57-70 # def register_router(router_class): # """Register a function to inspect a particular router. # This decorator registers a ne...
def make_parser(): """Create the parser or the application."""
falcon.util.uri.unquote_string
function
Internet/falcon
Internet/falcon/falcon/util/uri.py
[ 505, 505 ]
[ 518, 534 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param quoted: str. Original quoted string.\n:return: str. Unquoted string.\n:raises: TypeError: If the input is not a string.", "Functionality": "This function unquotes an RFC 7320 \"quoted-string\" by removing the quotes and escaping characters." }
[ "tests/test_utils.py::TestFalconUtils::test_unquote_string" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/constants.py # lines: 1-11 # from enum import Enum # import os # import sys # PYPY = sys.implementation.name == 'pypy' # """Evaluates to ``True`` when the curr...
def unquote_string(quoted): """Unquote an RFC 7320 "quoted-string". Args: quoted (str): Original quoted string Returns: str: unquoted string Raises: TypeError: `quoted` was not a ``str``. """
falcon.util.misc.get_argnames
function
Internet/falcon
Internet/falcon/falcon/util/misc.py
[ 287, 287 ]
[ 298, 313 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param func: The callable to introspect.\n:return: A list of argument names, excluding *arg and **kwargs arguments.", "Functionality": "This function introspects the arguments of a callable and returns a list of argument names, excluding *arg and **kwargs arguments." }
[ "tests/test_utils.py::test_get_argnames" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/util/deprecation.py # lines: 59-72 # Keyword Args: # allowed_positional (int): Number of allowed positional arguments # is_method (bool, op...
def get_argnames(func): """Introspect the arguments of a callable. Args: func: The callable to introspect Returns: A list of argument names, excluding *arg and **kwargs arguments. """
falcon.testing.client._is_asgi_app
function
Internet/falcon
Internet/falcon/falcon/testing/client.py
[ 2161, 2161 ]
[ 2162, 2173 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param app: The app to be checked.\n:return: Boolean. True if the app is an ASGI app, False otherwise.", "Functionality": "This function checks if the given app is an ASGI app by inspecting the number of arguments it accepts. If the number of arguments is 3, it is considered an ASGI app. The \"self\...
[ "tests/asgi/test_testing_asgi.py::test_is_asgi_app_cls" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/testing/helpers.py # lines: 290-303 # self.more_body = event.get('more_body', False) # if not isinstance(self.more_body, bool): # ...
def _is_asgi_app(app):
falcon.routing.converters.UUIDConverter.convert
method
Internet/falcon
Internet/falcon/falcon/routing/converters.py
[ 128, 128 ]
[ 129, 132 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: UUIDConverter. An instance of the UUIDConverter class.\n:param value: The value to be converted to a UUID.\n:return: UUID. The UUID value if the input is a valid UUID, otherwise None.", "Functionality": "Convert the input value to a UUID. If the input value is not a valid UUID, return N...
[ "tests/test_uri_converters.py::test_uuid_converter" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/falcon/falcon/request.py # lines: 1191-1204 # if max_value is not None and max_value < val: # msg = 'The value may not exceed ' + str(max_value) ...
class UUIDConverter(BaseConverter): """Converts a field value to a uuid.UUID. Identifier: `uuid` In order to be converted, the field value must consist of a string of 32 hexadecimal digits, as defined in RFC 4122, Section 3. Note, however, that hyphens and the URN prefix are optional. """ ...
rest_framework_simplejwt.utils.make_utc
function
Internet/djangorestframework-simplejwt
Internet/djangorestframework-simplejwt/rest_framework_simplejwt/utils.py
[ 18, 18 ]
[ 19, 22 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param dt: datetime. The datetime object to be converted to UTC.\n:return: datetime. The UTC-aware datetime object.", "Functionality": "The function converts a naive datetime object to a UTC-aware datetime object if the USE_TZ setting is enabled." }
[ "tests/test_utils.py::TestDatetimeFromEpoch::test_it_should_return_the_correct_values", "tests/test_utils.py::TestMakeUtc::test_it_should_return_the_correct_values" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/djangorestframework-simplejwt/rest_framework_simplejwt/utils.py import hashlib from calendar import timegm from datetime import datetime, timezone from typing import Call...
def make_utc(dt: datetime) -> datetime:
boto.sdb.db.sequence.fib
function
Internet/boto
Internet/boto/boto/sdb/db/sequence.py
[ 91, 91 ]
[ 94, 98 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param cv: int. The current value in the sequence. Defaults to 1.\n:param lv: int. The last value in the sequence. Defaults to 0.\n:return: int. The next number in the Fibonacci sequence.", "Functionality": "This function calculates the next number in the Fibonacci sequence based on the last two num...
[ "tests/db/test_sequence.py::TestDBHandler::test_fib" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/boto/boto/exception.py # lines: 437-451 # def __init__(self, message): # super(TooManyRecordsException, self).__init__(message) # self.message = message ...
def fib(cv=1, lv=0): """The fibonacci sequence, this incrementer uses the last value"""
boto.s3.website.RoutingRules.add_rule
method
Internet/boto
Internet/boto/boto/s3/website.py
[ 142, 142 ]
[ 152, 153 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param rule: RoutingRule. A routing rule to be added.\n:return: RoutingRules. The updated RoutingRules object.", "Functionality": "Add a routing rule to the RoutingRules object and return the updated object. This function allows chaining of subsequent calls." }
[ "tests/unit/s3/test_website.py::TestS3WebsiteConfiguration::test_routing_rules_to_host_on_404", "tests/unit/s3/test_website.py::TestS3WebsiteConfiguration::test_routing_rules_key_prefix", "tests/unit/s3/test_website.py::TestS3WebsiteConfiguration::test_key_prefix", "tests/unit/s3/test_website.py::TestS3Websit...
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/boto/boto/s3/website.py # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved # # Permission is hereby granted, free of charge, to any person obta...
class RoutingRules(list): def add_rule(self, rule): """ :type rule: :class:`boto.s3.website.RoutingRule` :param rule: A routing rule. :return: This ``RoutingRules`` object is returned, so that it can chain subsequent calls. """
boto.cloudfront.distribution.Distribution._canned_policy
method
Internet/boto
Internet/boto/boto/cloudfront/distribution.py
[ 617, 617 ]
[ 621, 624 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param resource: String. The resource for which the policy is created.\n:param expires: String. The expiration time for the policy.\n:return: String. The created canned policy string.", "Functionality": "This function creates a canned policy string based on the given resource and expiration time '{\...
[ "tests/unit/cloudfront/test_signed_urls.py::CloudfrontSignedUrlsTest::test_create_canned_policy" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/kinto/kinto/core/utils.py # lines: 102-116 # :param key: the setting name # :param value: default value if undefined in environment # :returns: the value from en...
class Distribution(object): def __init__(self, connection=None, config=None, domain_name='', id='', last_modified_time=None, status=''): self.connection = connection self.config = config self.domain_name = domain_name self.id = id self.last_modified_time = l...
boto.cloudfront.invalidation.InvalidationBatch.escape
method
Internet/boto
Internet/boto/boto/cloudfront/invalidation.py
[ 70, 70 ]
[ 72, 74 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: InvalidationBatch. An instance of the InvalidationBatch class.\n:param p: str. The path to escape.\n:return: str. The escaped path.", "Functionality": "This function escapes a path. It prepends a slash if it does not start with one and then escapes the path but retaining '/' and '*'." }
[ "tests/unit/cloudfront/test_invalidation.py::CFInvalidationTest::test_wildcard_escape" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/boto/tests/unit/route53/test_connection.py # lines: 56-69 # def test_retryable_400_prior_request_not_complete(self): # # Test ability to retry on ``PriorRequestN...
class InvalidationBatch(object): """A simple invalidation request. :see: http://docs.amazonwebservices.com/AmazonCloudFront/2010-08-01/APIReference/index.html?InvalidationBatchDatatype.html """ def __init__(self, paths=None, connection=None, distribution=None, caller_reference=''): """Creat...
proxybroker.utils.get_status_code
function
Internet/proxybroker
Internet/proxybroker/proxybroker/utils.py
[ 59, 59 ]
[ 60, 65 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param resp: String. The response string from which the status code is to be extracted.\n:param start: Integer. The starting index of the status code in the response string. Defaults to 9.\n:param stop: Integer. The ending index of the status code in the response string. Defaults to 12.\n:return: Inte...
[ "tests/test_utils.py::test_get_status_code" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/proxybroker/proxybroker/errors.py # lines: 16-25 # class ProxyEmptyRecvError(ProxyError): # errmsg = 'empty_response' # class BadStatusError(Exception): # BadStatusLine...
def get_status_code(resp, start=9, stop=12):
authlib.oauth2.rfc6749.util.scope_to_list
function
Internet/Authlib
Internet/Authlib/authlib/oauth2/rfc6749/util.py
[ 15, 15 ]
[ 17, 21 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param scope: The space separated string of scopes or a tuple, list, or set of scopes or None.\n:return: list[str] or None. The list of scopes. If the input is None, it returns None.", "Functionality": "Convert a space separated string to a list of scopes. It checks if the input is a tuple, list, or...
[ "tests/core/test_oauth2/test_rfc6749_misc.py::OAuth2UtilTest::test_scope_to_list" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/oauth2/rfc6749/util.py import base64 import binascii from authlib.common.encoding import to_unicode def list_to_scope(scope): """Convert a list of s...
def scope_to_list(scope): """Convert a space separated string to a list of scopes."""
authlib.common.encoding.to_unicode
function
Internet/Authlib
Internet/Authlib/authlib/common/encoding.py
[ 18, 18 ]
[ 19, 23 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param x: Any. The input to be converted to Unicode.\n:param charset: String. The character set to be used for decoding byte strings. Defaults to 'utf-8'.\n:param errors: String. The error handling scheme to be used for decoding byte strings. Defaults to 'strict'.\n:return: String. The Unicode represe...
[ "tests/jose/test_jwe.py::JWETest::test_deserialize_json_fails_if_protected_header_contains_unknown_field_while_private_fields_restricted" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/common/encoding.py import json import base64 import struct def to_bytes(x, charset='utf-8', errors='strict'): if x is None: return None ...
def to_unicode(x, charset='utf-8', errors='strict'):
authlib.common.encoding.to_bytes
function
Internet/Authlib
Internet/Authlib/authlib/common/encoding.py
[ 6, 6 ]
[ 7, 15 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param x: Any. The input to be converted to bytes.\n:param charset: String. The character set to be used for encoding. Defaults to 'utf-8'.\n:param errors: String. The error handling scheme to be used. Defaults to 'strict'.\n:return: Bytes. The converted bytes. Or None if the input is None.", "Funct...
[ "tests/jose/test_ecdh_1pu.py::ECDH1PUTest::test_ecdh_1pu_key_agreement_computation_appx_b", "tests/jose/test_ecdh_1pu.py::ECDH1PUTest::test_ecdh_1pu_encryption_with_json_serialization", "tests/jose/test_jwe.py::JWETest::test_deserialize_json_fails_if_protected_header_contains_unknown_field_while_private_fields_...
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/common/encoding.py import json import base64 import struct Based on the information above, please complete the function in the current file Internet/Au...
def to_bytes(x, charset='utf-8', errors='strict'):
authlib.common.encoding.urlsafe_b64decode
function
Internet/Authlib
Internet/Authlib/authlib/common/encoding.py
[ 40, 40 ]
[ 41, 42 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param s: bytes. The URL-safe base64-encoded string to be decoded.\n:return: bytes. The decoded string.", "Functionality": "Decode the URL-safe base64-encoded string. It pads the input string with '=' until the length is a multiple of 4 before decoding it." }
[ "tests/jose/test_ecdh_1pu.py::ECDH1PUTest::test_ecdh_1pu_encryption_with_json_serialization" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/common/encoding.py import json import base64 import struct def to_bytes(x, charset='utf-8', errors='strict'): if x is None: return None ...
def urlsafe_b64decode(s):
csvs_to_sqlite.utils.table_exists
function
Database/csvs-to-sqlite
Database/csvs-to-sqlite/csvs_to_sqlite/utils.py
[ 257, 257 ]
[ 258, 264 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param conn: Connection. The connection to the database.\n:param table: String. The name of the table to check.\n:return: Bool. True if the table exists, False otherwise.", "Functionality": "Check if the table exists in the database." }
[ "tests/test_utils.py::test_table_exists" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/csvs-to-sqlite/csvs_to_sqlite/utils.py import dateparser import os import fnmatch import hashlib import lru import pandas as pd import numpy as np import re import six im...
def table_exists(conn, table):
sqlitedict.SqliteDict.get_tablenames
method
Database/sqlitedict
Database/sqlitedict/sqlitedict.py
[ 359, 359 ]
[ 361, 368 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param filename: String. The name of the SQLite database file.\n:return: List of strings. The names of the tables in the SQLite database.", "Functionality": "This function retrieves the names of the tables in an SQLite database and returns them as a list. If the file does not exist, it raises an IOE...
[ "tests/test_core.py::TablenamesTest::test_tablenams_named", "tests/test_core.py::NamedSqliteDictCreateOrReuseTest::test_readonly_table", "tests/test_core.py::TablenamesTest::test_tablenames_unnamed" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/arctic-latest/arctic/arctic.py # lines: 378-390 # logger.info('Renaming collection: %s' % colname) # lib._db[colname].rename(to_colname) # for coll i...
class SqliteDict(DictClass): VALID_FLAGS = ['c', 'r', 'w', 'n'] def __init__(self, filename=None, tablename='unnamed', flag='c', autocommit=False, journal_mode="DELETE", encode=encode, decode=decode, encode_key=identity, decode_key=identity, timeout=5, outer_s...
litecli.packages.parseutils.query_starts_with
function
Database/litecli
Database/litecli/litecli/packages/parseutils.py
[ 204, 204 ]
[ 206, 208 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param query: String. The input query to be checked.\n:param prefixes: List of strings. The list of prefixes to check if the query starts with.\n:return: Bool. True if the query starts with any item from the prefixes, False otherwise.", "Functionality": "Check if the query starts with any item from ...
[ "tests/test_parseutils.py::test_query_starts_with_comment", "tests/test_parseutils.py::test_query_starts_with" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mssql-cli/mssqlcli/packages/sqlcompletion.py # lines: 236-250 # if isinstance(token, string_types): # token_v = token.lower() # elif isinstance(token, Compar...
def query_starts_with(query, prefixes): """Check if the query starts with any item from *prefixes*."""
rest_framework.negotiation.DefaultContentNegotiation.filter_renderers
method
Internet/djangorestframework
Internet/djangorestframework/rest_framework/negotiation.py
[ 80, 80 ]
[ 85, 89 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param renderers: List of Renderer. The list of renderers to be filtered.\n:param format: String. The format to be used for filtering the renderers.\n:return: List of Renderer. The filtered list of renderers.", "Functionality": "This function filters the renderers based on the given format. It only ...
[ "tests/test_negotiation.py::TestAcceptedMediaType::test_raise_error_if_no_suitable_renderers_found" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/djangorestframework/rest_framework/exceptions.py # lines: 155-169 # def __init__(self, method, detail=None, code=None): # if detail is None: # detail...
class DefaultContentNegotiation(BaseContentNegotiation): settings = api_settings def select_parser(self, request, parsers): """ Given a list of parsers and a media type, return the appropriate parser to handle the incoming request. """ for parser in parsers: ...
rest_framework.templatetags.rest_framework.as_string
function
Internet/djangorestframework
Internet/djangorestframework/rest_framework/templatetags/rest_framework.py
[ 159, 159 ]
[ 160, 162 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param value: Any. The input value to be converted to a string.\n:return: String. The converted string value.", "Functionality": "Convert the input value to a string. If the input value is None, it returns an empty string." }
[ "tests/test_templatetags.py::TemplateTagTests::test_as_string_with_none" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/djangorestframework/tests/test_templatetags.py # lines: 22-36 # def test_add_query_param_with_non_latin_character(self): # # Ensure we don't double-escape non-la...
def as_string(value):
rest_framework.templatetags.rest_framework.add_nested_class
function
Internet/djangorestframework
Internet/djangorestframework/rest_framework/templatetags/rest_framework.py
[ 286, 286 ]
[ 287, 291 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param value: Any. The input value to be checked.\n:return: String. It returns 'class=nested' if the input value is a dictionary or a list containing a dictionary or a list. Otherwise, it returns an empty string.", "Functionality": "The function checks if the input value is a dictionary or a list co...
[ "tests/test_templatetags.py::TemplateTagTests::test_add_nested_class" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/djangorestframework/tests/test_templatetags.py # lines: 22-36 # def test_add_query_param_with_non_latin_character(self): # # Ensure we don't double-escape non-la...
def add_nested_class(value):
pyramid.session.PickleSerializer.loads
method
Internet/pyramid
Internet/pyramid/src/pyramid/session.py
[ 67, 67 ]
[ 69, 74 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: PickleSerializer. An instance of the PickleSerializer class.\n:param bstruct: Bytes. The byte stream to be deserialized.\n:return: Python object. The deserialized Python object.", "Functionality": "Deserialize a byte stream to a Python object using the pickle module. It raises a ValueEr...
[ "tests/test_session.py::TestPickleSerializer::test_loads", "tests/test_session.py::TestPickleSerializer::test_loads_raises_ValueError_on_invalid_data", "tests/test_session.py::TestPickleSerializer::test_loads_raises_ValueError_on_bad_import" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/session.py # lines: 42-54 # ``protocol`` may be specified to control the version of pickle used. # Defaults to :attr:`pickle.HIGHEST_PROTOC...
class PickleSerializer: """ .. deprecated:: 2.0 .. warning:: In :app:`Pyramid` 2.0 the default ``serializer`` option changed to use :class:`pyramid.session.JSONSerializer`, and ``PickleSerializer`` has been been removed from active Pyramid code. Pyramid will require JSON-s...
pyramid.testing.DummySession.flash
method
Internet/pyramid
Internet/pyramid/src/pyramid/testing.py
[ 247, 247 ]
[ 248, 250 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: DummySession. An instance of the DummySession class.\n:param msg: The message to be added to the flash storage.\n:param queue: String. The queue to which the message is added. Defaults to an empty string.\n:param allow_duplicate: Bool. Whether to allow duplicate messages in the storage. D...
[ "tests/test_testing.py::TestDummySession::test_flash_mixed", "tests/test_testing.py::TestDummySession::test_flash_default" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/testing.py # lines: 188-201 # return inst # DummyModel = DummyResource # b/w compat (forever) # @implementer(ISession) # class DummySessio...
class DummySession(dict): created = None new = True def changed(self): pass def invalidate(self): self.clear() def flash(self, msg, queue='', allow_duplicate=True):
pyramid.testing.DummySession.pop_flash
method
Internet/pyramid
Internet/pyramid/src/pyramid/testing.py
[ 252, 252 ]
[ 253, 254 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: DummySession. An instance of the DummySession class.\n:param queue: String. The queue from which the flash message is to be removed. Defaults to an empty string.\n:return: List. The flash message storage.", "Functionality": "This function removes and returns the flash message from the s...
[ "tests/test_testing.py::TestDummySession::test_pop_flash_nodefault_queue", "tests/test_testing.py::TestDummySession::test_pop_flash_default_queue" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/testing.py # lines: 202-216 # def pop_flash(self, queue=''): # storage = self.pop('_f_' + queue, []) # return storage # def...
class DummySession(dict): created = None new = True def changed(self): pass def invalidate(self): self.clear() def flash(self, msg, queue='', allow_duplicate=True): storage = self.setdefault('_f_' + queue, []) if allow_duplicate or (msg not in storage): ...
pyramid.testing.DummySession.peek_flash
method
Internet/pyramid
Internet/pyramid/src/pyramid/testing.py
[ 256, 256 ]
[ 257, 258 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: DummySession. An instance of the DummySession class.\n:param queue: String. The queue name to retrieve the flash messages from. Defaults to an empty string.\n:return: List. The list of flash messages from the session storage.", "Functionality": "Return the flash messages from the sessio...
[ "tests/test_testing.py::TestDummySession::test_peek_flash_default_queue", "tests/test_testing.py::TestDummySession::test_peek_flash_nodefault_queue" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/testing.py # lines: 202-216 # def pop_flash(self, queue=''): # storage = self.pop('_f_' + queue, []) # return storage # def...
class DummySession(dict): created = None new = True def changed(self): pass def invalidate(self): self.clear() def flash(self, msg, queue='', allow_duplicate=True): storage = self.setdefault('_f_' + queue, []) if allow_duplicate or (msg not in storage): ...
pyramid.testing.DummySession.new_csrf_token
method
Internet/pyramid
Internet/pyramid/src/pyramid/testing.py
[ 260, 260 ]
[ 261, 263 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: DummySession. An instance of the DummySession class.\n:return: String. The generated CSRF token.", "Functionality": "Generate a new CSRF token '0123456789012345678901234567890123456789' and store it in the DummySession instance. It then returns the generated token." }
[ "tests/test_testing.py::TestDummySession::test_new_csrf_token" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/testing.py # lines: 202-216 # def pop_flash(self, queue=''): # storage = self.pop('_f_' + queue, []) # return storage # def...
class DummySession(dict): created = None new = True def changed(self): pass def invalidate(self): self.clear() def flash(self, msg, queue='', allow_duplicate=True): storage = self.setdefault('_f_' + queue, []) if allow_duplicate or (msg not in storage): ...
pyramid.view.view_defaults
function
Internet/pyramid
Internet/pyramid/src/pyramid/view.py
[ 264, 264 ]
[ 273, 277 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param **settings: Arbitrary keyword arguments. The settings to be applied as defaults for all view configurations that use the class.\n:return: A decorator function that sets the defaults for all view configurations that use the class.", "Functionality": "This function is a decorator that, when app...
[ "tests/test_view.py::Test_view_defaults::test_it_inheritance_overriden", "tests/test_view.py::Test_view_defaults::test_it_inheritance_not_overridden", "tests/test_view.py::Test_view_defaults::test_it", "tests/test_view.py::Test_view_defaults::test_it_inheritance_overriden_empty" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/view.py # lines: 209-219 # def view_defaults(**settings): # """A class :term:`decorator` which, when applied to a class, will # provide def...
def view_defaults(**settings): """A class :term:`decorator` which, when applied to a class, will provide defaults for all view configurations that use the class. This decorator accepts all the arguments accepted by :meth:`pyramid.view.view_config`, and each has the same meaning. See :ref:`view_def...
pyramid.util.bytes_
function
Internet/pyramid
Internet/pyramid/src/pyramid/util.py
[ 38, 38 ]
[ 41, 43 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param s: String. The input string to be encoded.\n:param encoding: String. The encoding to be used for encoding the input string. Defaults to 'latin-1'.\n:param errors: String. The error handling scheme to use for encoding errors. Defaults to 'strict'.\n:return: Bytes. The encoded bytes if the input ...
[ "tests/test_authentication.py::TestBasicAuthAuthenticationPolicy::test_unauthenticated_userid_invalid_payload", "tests/test_authentication.py::TestBasicAuthAuthenticationPolicy::test_authenticated_userid", "tests/test_authentication.py::TestExtractHTTPBasicCredentials::test_not_a_basic_auth_scheme", "tests/te...
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/util.py # lines: 27-40 # def bytes_(s, encoding='latin-1', errors='strict'): # """If ``s`` is an instance of ``str``, return # ``s.encode(e...
def bytes_(s, encoding='latin-1', errors='strict'): """If ``s`` is an instance of ``str``, return ``s.encode(encoding, errors)``, otherwise return ``s``"""
pyramid.scripts.common.parse_vars
function
Internet/pyramid
Internet/pyramid/src/pyramid/scripts/common.py
[ 4, 4 ]
[ 9, 15 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param args: List of strings. The list of strings in the format 'a=b'.\n:return: Dictionary. The dictionary with keys and values.", "Functionality": "This function takes a list of strings in the format 'a=b' and turns it into a dictionary with keys and values." }
[ "tests/test_scripts/test_common.py::TestParseVars::test_parse_vars_good", "tests/test_scripts/test_common.py::TestParseVars::test_parse_vars_bad" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/src/pyramid/scripts/common.py import plaster Based on the information above, please complete the function in the current file Internet/pyramid/src/pyramid/scri...
def parse_vars(args): """ Given variables like ``['a=b', 'c=d']`` turns it into ``{'a': 'b', 'c': 'd'}`` """
pyramid.scripts.pviews.PViewsCommand._find_multi_routes
method
Internet/pyramid
Internet/pyramid/src/pyramid/scripts/pviews.py
[ 70, 70 ]
[ 71, 79 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: PViewsCommand. An instance of the PViewsCommand class.\n:param mapper: The mapper object that contains routes.\n:param request: The request object that contains the path information.\n:return: A list of dictionaries, each containing the 'match' and the 'route' that matches the given path....
[ "tests/test_scripts/test_pviews.py::TestPViewsCommand::test__find_multi_routes_some_match", "tests/test_scripts/test_pviews.py::TestPViewsCommand::test__find_multi_routes_all_match", "tests/test_scripts/test_pviews.py::TestPViewsCommand::test__find_multi_routes_none_match" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/src/pyramid/scripts/pviews.py import argparse import sys import textwrap from pyramid.interfaces import IMultiView from pyramid.paster import bootstrap, setup_lo...
class PViewsCommand: description = """\ Print, for a given URL, the views that might match. Underneath each potentially matching route, list the predicates required. Underneath each route+predicate set, print each view that might match and its predicates. This command accepts two positional arg...
pyramid.scripts.pserve.PServeCommand.guess_server_url
method
Internet/pyramid
Internet/pyramid/src/pyramid/scripts/pserve.py
[ 174, 174 ]
[ 175, 178 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: PServeCommand. An instance of the PServeCommand class.\n:param loader: The loader to get the settings.\n:param server_name: The name of the server. Defaults to 'main'.\n:param global_conf: The global configuration settings. Defaults to None.\n:return: String. The guessed server URL.", "...
[ "tests/test_scripts/test_pserve.py::TestPServeCommand::test_guess_server_url" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/src/pyramid/scripts/pserve.py # (c) 2005 Ian Bicking and contributors; written for Paste # (http://pythonpaste.org) Licensed under the MIT license: # http://www.o...
class PServeCommand: description = """\ This command serves a web application that uses a PasteDeploy configuration file for the server and application. You can also include variable assignments like 'http_port=8080' and then use %(http_port)s in your config files. """ default_verbosity = ...
aiohappybase._util.pep8_to_camel_case
function
Database/happybase
Database/happybase/aiohappybase/_util.py
[ 27, 27 ]
[ 29, 34 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param name: String. The PEP8 style name to be converted to camel case.\n:param initial: Bool. Whether to capitalize the first letter of the camel case name. Defaults to False.\n:return: String. The name in camel case.", "Functionality": "Convert a PEP8 style name to camel case. It splits the input ...
[ "tests/test_util.py::TestUtil::test_camel_case_to_pep8" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/happybase/aiohappybase/_util.py """ AIOHappyBase utility module. These functions are not part of the public API. """ import re from typing import Dict, List, Any, AnySt...
def pep8_to_camel_case(name: str, initial: bool = False) -> str: """Convert a PEP8 style name to camel case."""
aiohappybase._util.bytes_increment
function
Database/happybase
Database/happybase/aiohappybase/_util.py
[ 61, 61 ]
[ 72, 78 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param b: bytes. The byte string to be incremented and truncated.\n:return: Optional[bytes]. The incremented and truncated byte string. If the string only contains ``0xFF`` bytes, `None` is returned.", "Functionality": "This function increments and truncates a byte string for sorting purposes. It re...
[ "tests/test_util.py::TestUtil::test_bytes_increment" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/happybase/aiohappybase/_util.py """ AIOHappyBase utility module. These functions are not part of the public API. """ import re from typing import Dict, List, Any, AnySt...
def bytes_increment(b: bytes) -> Optional[bytes]: """ Increment and truncate a byte string (for sorting purposes) This functions returns the shortest string that sorts after the given string when compared using regular string comparison semantics. This function increments the last byte that is sma...
mssqlcli.config.ensure_dir_exists
function
Database/mssql-cli
Database/mssql-cli/mssqlcli/config.py
[ 29, 29 ]
[ 30, 32 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param path: String. The path for which the directory existence needs to be ensured.\n:return: No return values.", "Functionality": "This function ensures that the directory of the given path exists. If the parent directory of the path does not exist, it creates the directory." }
[ "tests/test_config.py::ConfigTests::test_ensure_existing_dir" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mssql-cli/mssqlcli/config.py import os from os.path import expanduser, exists, dirname import shutil import platform from configobj import ConfigObj from mssqlcli import...
def ensure_dir_exists(path):
mssqlcli.telemetry._user_id_file_is_old
function
Database/mssql-cli
Database/mssql-cli/mssqlcli/telemetry.py
[ 188, 188 ]
[ 189, 194 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param id_file_path: String. The path to the user id file.\n:return: Bool. True if the file is older than 24 hours, otherwise False.", "Functionality": "Check if the user id file is older than 24 hours. It compares the modified time of the file with the current time and returns True if the file is o...
[ "tests/test_telemetry.py::TelemetryTests::test_file_time_check_rotation" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mssql-cli/mssqlcli/__init__.py # lines: 1-1 # __version__ = '1.0.0' # file path: Database/mssql-cli/mssqlcli/telemetry.py import binascii import json import locale import ...
def _user_id_file_is_old(id_file_path):
mssqlcli.util.is_command_valid
function
Database/mssql-cli
Database/mssql-cli/mssqlcli/util.py
[ 21, 21 ]
[ 26, 36 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param command: String. The command to be checked.\n:return: Bool. True if the command is recognized, False otherwise.", "Functionality": "Check if the command is recognized on the machine. It is used to determine the installation of the 'less' pager. If the command is empty or if calling the comman...
[ "tests/test_interactive_mode.py::TestInteractiveModeRun::test_valid_command" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mssql-cli/mssqlcli/util.py from os import devnull import subprocess def encode(s): try: return s.encode('utf-8') except (AttributeError, SyntaxError): ...
def is_command_valid(command): """ Checks if command is recognized on machine. Used to determine installations of 'less' pager. """
mssqlcli.packages.parseutils.utils.find_prev_keyword
function
Database/mssql-cli
Database/mssql-cli/mssqlcli/packages/parseutils/utils.py
[ 65, 65 ]
[ 71, 99 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param sql: String. The SQL statement to be processed.\n:param n_skip: Integer. The number of tokens to skip from the end of the SQL statement. Defaults to 0.\n:return: Tuple. The value of the last keyword and the text of the query with everything after the last keyword stripped.", "Functionality": ...
[ "tests/parseutils/test_parseutils.py::test_find_prev_keyword_using", "tests/parseutils/test_parseutils.py::test_find_prev_keyword_where", "tests/parseutils/test_parseutils.py::test_find_prev_keyword_open_parens" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mssql-cli/mssqlcli/packages/parseutils/utils.py from __future__ import print_function import re import sqlparse from sqlparse.sql import Identifier from sqlparse.tokens i...
def find_prev_keyword(sql, n_skip=0): """ Find the last sql keyword in an SQL statement Returns the value of the last keyword, and the text of the query with everything after the last keyword stripped """
pyramid.util.text_
function
Internet/pyramid
Internet/pyramid/src/pyramid/util.py
[ 30, 30 ]
[ 33, 35 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param s: String or bytes. The input string to be checked and decoded if it is an instance of bytes.\n:param encoding: String. The encoding to be used for decoding the bytes. Defaults to 'latin-1'.\n:param errors: String. The error handling scheme to be used for decoding. Defaults to 'strict'.\n:retur...
[ "tests/test_urldispatch.py::TestCompileRoute::test_generate_with_mixedtype_values", "tests/test_urldispatch.py::TestCompileRoute::test_pattern_generate_with_high_order_dynamic", "tests/test_urldispatch.py::TestCompileRoute::test_pattern_with_high_order_literal", "tests/test_urldispatch.py::TestCompileRoute::t...
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/util.py # lines: 27-40 # def bytes_(s, encoding='latin-1', errors='strict'): # """If ``s`` is an instance of ``str``, return # ``s.encode(e...
def text_(s, encoding='latin-1', errors='strict'): """If ``s`` is an instance of ``bytes``, return ``s.decode(encoding, errors)``, otherwise return ``s``"""
datasette.filters.where_filters
function
Database/datasette
Database/datasette/datasette/filters.py
[ 10, 11 ]
[ 12, 40 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param request: The request object.\n:param database: The database object.\n:param datasette: The datasette object.\n:return: A nested function that processes the \"_where\" query parameter and returns the filter arguments.", "Functionality": "The function is used to handle the \"_where=\" parameter...
[ "tests/test_filters.py::test_where_filters_from_request" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/views/base.py # lines: 10-24 # from datasette import __version__ # from datasette.database import QueryInterrupted # from datasette.utils.asgi import Req...
def where_filters(request, database, datasette):
datasette.utils.path_with_added_args
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 273, 273 ]
[ 274, 286 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param request: The request object.\n:param args: Dictionary. The arguments to be added to the path.\n:param path: String. The path to which the arguments are to be added. Defaults to None.\n:return: String. The new path with added arguments.", "Functionality": "This function returns a new path with...
[ "tests/test_utils.py::test_path_with_added_args" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 15-28 # def _sqlite_version(): # return tuple( # map( # int, # sqlite3.connect(":memory:") #...
def path_with_added_args(request, args, path=None):
datasette.utils.path_with_replaced_args
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 318, 318 ]
[ 319, 331 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param request: The request object.\n:param args: Dictionary or list of tuples. The arguments to replace in the query string.\n:param path: String. The path to be updated. Defaults to None, in which case the path from the request object is used.\n:return: String. The updated path with replaced argumen...
[ "tests/test_utils.py::test_path_with_replaced_args" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/shutil_backport.py # lines: 25-39 # for srcentry in entries: # if srcentry.name in ignored_names: # continue # srcn...
def path_with_replaced_args(request, args, path=None):
datasette.utils.format_bytes
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 870, 870 ]
[ 871, 879 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param bytes: int. The number of bytes to be converted.\n:return: str. The formatted string of the converted bytes.", "Functionality": "Convert the input bytes to the largest possible unit (\"bytes\", \"KB\", \"MB\", \"GB\", and \"TB\") and return the formatted string." }
[ "tests/test_utils.py::test_format_bytes" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 15-28 # def _sqlite_version(): # return tuple( # map( # int, # sqlite3.connect(":memory:") #...
def format_bytes(bytes):
datasette.utils.actor_matches_allow
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1013, 1013 ]
[ 1014, 1036 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param actor: Any. The actor to be checked against the allow condition.\n:param allow: Any. The allow condition to be checked against the actor.\n:return: Bool. True if the actor matches the allow condition, otherwise False.", "Functionality": "This function checks if the actor matches the allow con...
[ "tests/test_utils.py::test_actor_matches_allow" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/__init__.py _variables=None, port=8001, apt_get_extras=None, ): extra_metadata = extra_metadata or {} tmp = tempfile.TemporaryDi...
def actor_matches_allow(actor, allow):
datasette.utils.resolve_env_secrets
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1039, 1039 ]
[ 1041, 1054 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param config: Dictionary or List. The input configuration to be resolved.\n:param environ: Dictionary. The environment dictionary containing the values to be replaced.\n:return: Dictionary or List. The resolved configuration.", "Functionality": "Create a copy of the input config that recursively re...
[ "tests/test_utils.py::test_resolve_env_secrets" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/shutil_backport.py # lines: 8-21 # def _copytree( # entries, # src, # dst, # symlinks, # ignore, # copy_function, # ign...
def resolve_env_secrets(config, environ): """Create copy that recursively replaces {"$env": "NAME"} with values from environ"""
datasette.utils.display_actor
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1057, 1057 ]
[ 1058, 1061 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param actor: Dictionary. The actor information.\n:return: String. The displayed actor information based on the priority.", "Functionality": "Display the actor information based on the given priority. It first checks if the actor has a display name, then a name, username, login, and id. If none of t...
[ "tests/test_utils.py::test_display_actor" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/__init__.py _content, indent=2)) with open("Dockerfile", "w") as fp: fp.write(dockerfile) for path, filename in zip(...
def display_actor(actor):
datasette.utils.initial_path_for_datasette
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1076, 1076 ]
[ 1078, 1089 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param datasette: Datasette. The Datasette instance for which the path is to be suggested.\n:return: String. The suggested path for opening the Datasette instance.", "Functionality": "This function returns the suggested path for opening the given Datasette instance based on the number of databases a...
[ "tests/test_utils.py::test_initial_path_for_datasette" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 1-14 # using_pysqlite3 = False # try: # import pysqlite3 as sqlite3 # using_pysqlite3 = True # except ImportError: # ...
def initial_path_for_datasette(datasette): """Return suggested path for opening this Datasette, based on number of DBs and tables"""
datasette.utils.tilde_decode
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1176, 1176 ]
[ 1179, 1182 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param s: String. The tilde-encoded string to be decoded.\n:return: String. The decoded string.\n```", "Functionality": "Decode a tilde-encoded string to its original form. It first replaces the % symbol with a temporary string to avoid accidental decoding of %2f style sequences. Then, it decodes th...
[ "tests/test_utils.py::test_tilde_encoding" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 1-14 # using_pysqlite3 = False # try: # import pysqlite3 as sqlite3 # using_pysqlite3 = True # except ImportError: # ...
def tilde_decode(s: str) -> str: """ Decodes a tilde-encoded string, so ``~2Ffoo~2Fbar`` -> ``/foo/bar``"""
datasette.utils.resolve_routes
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1185, 1185 ]
[ 1186, 1190 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param routes: List of tuples. A list of tuples containing regex and view.\n:param path: String. The path to be resolved.\n:return: Tuple. The first match and the corresponding view. If no match is found, it returns None.", "Functionality": "This function resolves the routes based on the given path....
[ "tests/test_routes.py::test_routes" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 1-14 # using_pysqlite3 = False # try: # import pysqlite3 as sqlite3 # using_pysqlite3 = True # except ImportError: # ...
def resolve_routes(routes, path):
datasette.utils.truncate_url
function
Database/datasette
Database/datasette/datasette/utils/__init__.py
[ 1193, 1193 ]
[ 1194, 1200 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param url: String. The URL to be truncated.\n:param length: Integer. The maximum length of the truncated URL.\n:return: String. The truncated URL. If the URL is shorter than the specified length, the original URL is returned.", "Functionality": "The function is used to truncate a given URL to a spe...
[ "tests/test_utils.py::test_truncate_url" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/datasette/datasette/utils/sqlite.py # lines: 15-28 # def _sqlite_version(): # return tuple( # map( # int, # sqlite3.connect(":memory:") #...
def truncate_url(url, length):
kinto.core.authorization.groupfinder
function
Internet/kinto
Internet/kinto/kinto/core/authorization.py
[ 21, 21 ]
[ 26, 41 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param userid: The user id for which the principals are to be fetched.\n:param request: The request object.\n:return: List. The list of principals fetched from the permission backend. If the permission backend is not configured, an empty list is returned.", "Functionality": "This function fetches pr...
[ "tests/core/test_authorization.py::GroupFinderTest::test_uses_provided_id_if_no_prefixed_userid", "tests/core/test_authorization.py::GroupFinderTest::test_uses_prefixed_as_userid" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/kinto/kinto/core/utils.py # lines: 253-266 # def prefixed_principals(request): # """ # :returns: the list principals with prefixed user id. # """ # principal...
def groupfinder(userid, request): """Fetch principals from permission backend for the specified `userid`. This is plugged by default using the ``multiauth.groupfinder`` setting. """
kinto.core.utils.json.dumps
method
Internet/kinto
Internet/kinto/kinto/core/utils.py
[ 35, 35 ]
[ 36, 37 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param v: Object. Python object to be serialized.\n:param kw: Dict. Additional keyword arguments to be passed to the rapidjson.dumps function.\n:return: String. The JSON string corresponding to the Python object.", "Functionality": "The function is a custom serialization function that uses the rapid...
[ "tests/core/resource/test_pagination.py::PaginationTest::test_raises_bad_request_if_token_has_bad_data_structure", "tests/core/test_views_batch.py::BatchServiceTest::test_subrequests_body_are_json_serialized", "tests/core/test_views_batch.py::BatchServiceTest::test_subrequests_body_have_utf8_charset" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/httpexceptions.py # lines: 248-258 # class JsonPageTemplate: # def __init__(self, excobj): # ...
class json: def dumps(v, **kw):
kinto.core.utils.json.loads
method
Internet/kinto
Internet/kinto/kinto/core/utils.py
[ 43, 43 ]
[ 44, 45 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param v: String. The JSON string to be loaded.\n:param kw: Dict. Additional keyword arguments to be passed to the rapidjson.loads function.\n:return: Object. The Python object corresponding to the JSON string.", "Functionality": "This function loads the given JSON string and returns the correspondi...
[ "tests/core/resource/test_pagination.py::BuildPaginationTokenTest::test_sorting_handle_both_rules", "tests/core/resource/test_pagination.py::BuildPaginationTokenTest::test_multiple_sorting_keep_all", "tests/core/resource/test_pagination.py::BuildPaginationTokenTest::test_token_contains_current_offset", "tests...
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/common/urls.py # lines: 89-100 # def extract_params(raw): # """Extract parameters and return them as a list of 2-tuples. # Will successfully extract ...
class json: def dumps(v, **kw): kw.setdefault("bytes_mode", rapidjson.BM_NONE) return rapidjson.dumps(v, **kw) def load(v, **kw): kw.setdefault("number_mode", rapidjson.NM_NATIVE) return rapidjson.load(v, **kw) def loads(v, **kw):
kinto.core.utils.hmac_digest
function
Internet/kinto
Internet/kinto/kinto/core/utils.py
[ 161, 161 ]
[ 163, 165 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param secret: String or bytes. The secret key used for generating the HMAC digest.\n:param message: String. The message for which the HMAC digest is to be generated.\n:param encoding: String. The encoding to be used for encoding the secret key and the message. Defaults to \"utf-8\".\n:return: String....
[ "tests/plugins/test_default_bucket.py::DefaultBucketViewTest::test_default_bucket_exists_and_has_user_id_fallback_to_hmac_secret", "tests/plugins/test_default_bucket.py::DefaultBucketViewTest::test_default_bucket_exists_and_has_user_id", "tests/core/test_utils.py::HmacDigestTest::test_supports_secret_as_bytes",...
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/Authlib/authlib/common/urls.py # lines: 40-45 # # Check for correctly hex encoded values using a regular expression # # All encoded values begin with % followed by t...
def hmac_digest(secret, message, encoding="utf-8"): """Return hex digest of a message HMAC using secret"""
kinto.core.utils.current_service
function
Internet/kinto
Internet/kinto/kinto/core/utils.py
[ 285, 285 ]
[ 291, 299 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param request: The request object.\n:return: The service or None if unmatched.", "Functionality": "This function is a decorator that is used to get the Cornice service matching the specified request. If the request matches a route, it retrieves the Cornice services from the request's registry and r...
[ "tests/core/test_utils.py::CurrentServiceTest::test_current_service_returns_the_service_for_existing_patterns" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/httpexceptions.py # lines: 221-233 # def prepare(self, environ): # if not self.has_body and not self.empty_body: # html_com...
def current_service(request): """Return the Cornice service matching the specified request. :returns: the service or None if unmatched. :rtype: cornice.Service """
kinto.core.utils.prefixed_principals
function
Internet/kinto
Internet/kinto/kinto/core/utils.py
[ 328, 328 ]
[ 332, 344 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param request: Request. The request object containing the effective principals and the prefixed user id.\n:return: List. The list of principals with the prefixed user id.", "Functionality": "This function returns a list of principals with a prefixed user id. It first retrieves the list of principal...
[ "tests/core/test_utils.py::PrefixedPrincipalsTest::test_works_if_userid_is_not_in_principals", "tests/core/test_utils.py::PrefixedPrincipalsTest::test_removes_unprefixed_from_principals" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/pyramid/build/lib/pyramid/authorization.py # lines: 50-63 # def permits(self, context, principals, permission): # """Return an instance of # :class:`pyra...
def prefixed_principals(request): """ :returns: the list principals with prefixed user id. """
kinto.plugins.accounts.views.on_account_created
function
Internet/kinto
Internet/kinto/kinto/plugins/accounts/views/__init__.py
[ 176, 176 ]
[ 177, 190 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param event: The event object containing the request and impacted objects.\n:return: No return values.", "Functionality": "This function is called when an account is created. It checks if the account validation is enabled in the settings. If it is enabled, the function proceeds to iterate through e...
[ "tests/plugins/test_accounts.py::AccountValidationCreationTest::test_user_creation_listener" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/kinto/kinto/plugins/accounts/utils.py # lines: 15-26 # def is_validated(user): # """Is this user record validated?""" # # An account is "validated" if it has the `va...
def on_account_created(event):
kinto.plugins.accounts.utils.hash_password
function
Internet/kinto
Internet/kinto/kinto/plugins/accounts/utils.py
[ 13, 15 ]
[ 16, 18 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param password: String. The password to be hashed.\n:return: String. The hashed password.", "Functionality": "This function takes a password as input, hashes it using bcrypt, and returns the hashed password as a string." }
[ "tests/plugins/test_accounts.py::AccountValidationCreationTest::test_previously_created_accounts_can_still_authenticate" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/kinto/kinto/core/utils.py # lines: 117-127 # :rtype: str # """ # return b64decode(encoded_content.encode(encoding)).decode(encoding) # def hmac_digest(secret, me...
def hash_password(password):
kinto.views.admin.get_parent_uri
function
Internet/kinto
Internet/kinto/kinto/views/admin.py
[ 44, 44 ]
[ 52, 58 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param object_uri: String. The URI of the object.\n:return: String. The parent URI for the object URI. If the object URI does not conform to the URL scheme, an empty string is returned.", "Functionality": "This function is a function that retrieves the parent URI of an object's URI. It achieves univ...
[ "tests/test_views_admin.py::GetParentUriTest::test_parent_uri_behaves_sensibly_for_unknown_resources", "tests/test_views_admin.py::GetParentUriTest::test_parent_uri_accepts_pathological_urls" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Internet/kinto/kinto/core/utils.py # lines: 377-389 # resource_name = route.name.replace("-object", "").replace("-plural", "") # return resource_name, matchdict # def instanc...
def get_parent_uri(object_uri): """Get the parent URI for an object_uri. In order to be generic over any kind of resource hierarchy, we do this by string manipulation on the URI instead of trying to parse the URI, identify the parent resource, and generate a new URI. """
alembic.script.write_hooks.register
function
Database/alembic
Database/alembic/alembic/script/write_hooks.py
[ 23, 23 ]
[ 35, 39 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param name: String. The name to register the function with.\n:return: Callable. A callable function that registers the input function.", "Functionality": "This function is a function decorator that registers the function as a write hook. It adds the function to the registry with the given name." }
[ "tests/test_post_write.py::RunHookTest::test_generic", "tests/test_post_write.py::HookTest::test_invoke", "tests/test_post_write.py::HookTest::test_register" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/alembic/alembic/util/compat.py # lines: 16-29 # # produce a wrapper that allows encoded text to stream # # into a given buffer, but doesn't close it. # # not sure of a more ...
def register(name: str) -> Callable: """A function decorator that will register that function as a write hook. See the documentation linked below for an example. .. seealso:: :ref:`post_write_hooks_custom` """
mongo_connector.namespace_config.match_replace_regex
function
Database/mongo-doc-manager
Database/mongo-doc-manager/mongo_connector/namespace_config.py
[ 546, 546 ]
[ 549, 552 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param regex: Regular expression. The regular expression pattern to match the source namespace.\n:param src_namespace: String. The source namespace to be matched.\n:param dest_namespace: String. The destination namespace to be replaced.\n:return: String. The new mapped namespace if the source namespac...
[ "tests/test_namespace_config.py::TestNamespaceConfig::test_match_replace_regex" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mongo-doc-manager/mongo_connector/command_helper.py # lines: 30-41 # # Applies the namespace mapping to a "db.collection" string # # The input parameter ns is plain ...
def match_replace_regex(regex, src_namespace, dest_namespace): """Return the new mapped namespace if the src_namespace matches the regex."""
mongo_connector.namespace_config.namespace_to_regex
function
Database/mongo-doc-manager
Database/mongo-doc-manager/mongo_connector/namespace_config.py
[ 560, 560 ]
[ 562, 567 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param namespace: String. The wildcard namespace to be converted into a regular expression.\n:return: RegexObject. The compiled regular expression object.", "Functionality": "Create a regular expression object from a wildcard namespace. It first splits the namespace into database and collection name...
[ "tests/test_namespace_config.py::TestNamespaceConfig::test_namespace_to_regex_escapes_metacharacters", "tests/test_namespace_config.py::TestNamespaceConfig::test_namespace_to_regex" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mongo-doc-manager/mongo_connector/command_helper.py # lines: 30-41 # # Applies the namespace mapping to a "db.collection" string # # The input parameter ns is plain ...
def namespace_to_regex(namespace): """Create a RegexObject from a wildcard namespace."""
mongo_connector.util.long_to_bson_ts
function
Database/mongo-doc-manager
Database/mongo-doc-manager/mongo_connector/util.py
[ 60, 60 ]
[ 63, 66 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param val: Integer. The value to be converted into a BSON timestamp.\n:return: Timestamp. The BSON timestamp created from the input value.", "Functionality": "Converts an integer into a BSON timestamp. The resulting BSON timestamp is a combination of the time (in seconds) and an incrementor, both e...
[ "tests/test_util.py::TestUtil::test_bson_ts_to_long" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mongo-doc-manager/mongo_connector/command_helper.py # lines: 30-41 # # Applies the namespace mapping to a "db.collection" string # # The input parameter ns is plain ...
def long_to_bson_ts(val): """Convert integer into BSON timestamp. """
mongo_connector.doc_managers.formatters.DocumentFlattener.format_document
method
Database/mongo-doc-manager
Database/mongo-doc-manager/mongo_connector/doc_managers/formatters.py
[ 150, 150 ]
[ 151, 170 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: DocumentFlattener. An instance of the DocumentFlattener class.\n:param document: Dictionary. The document to be flattened.\n:return: Dictionary. The flattened document.", "Functionality": "This function flattens the given document and returns a dictionary with the flattened keys and val...
[ "tests/test_formatters.py::TestFormatters::test_flattener" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/mongo-doc-manager/mongo_connector/command_helper.py # lines: 30-41 # # Applies the namespace mapping to a "db.collection" string # # The input parameter ns is plain ...
class DocumentFlattener(DefaultDocumentFormatter): """Formatter that completely flattens documents and unwinds arrays: An example: {"a": 2, "b": { "c": { "d": 5 } }, "e": [6, 7, 8] } becomes: {"a": 2, "b.c.d": 5, "e.0": 6, "e.1": 7, "e.2"...
bplustree.memory.open_file_in_dir
function
Database/bplustree
Database/bplustree/bplustree/memory.py
[ 23, 23 ]
[ 32, 49 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param path: String. The path of the file to be opened.\n:return: Tuple[io.FileIO, Optional[int]]. The file descriptor and directory descriptor.", "Functionality": "This function opens a file and its directory. The file is opened in binary mode and created if it does not exist. Both file descriptors...
[ "tests/test_memory.py::test_open_file_in_dir_windows", "tests/test_memory.py::test_open_file_in_dir" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/bplustree/bplustree/node.py # lines: 141-152 # def __init__(self, tree_conf: TreeConf, data: Optional[bytes]=None, # page: int=None, parent: 'Node'=None...
def open_file_in_dir(path: str) -> Tuple[io.FileIO, Optional[int]]: """Open a file and its directory. The file is opened in binary mode and created if it does not exist. Both file descriptors must be closed after use to prevent them from leaking. On Windows, the directory is not opened, as it is u...
bplustree.memory.FileMemory.read_transaction
method
Database/bplustree
Database/bplustree/bplustree/memory.py
[ 167, 168 ]
[ 169, 177 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param self: FileMemory. An instance of the FileMemory class.\n:return: ReadTransaction. The created ReadTransaction instance.", "Functionality": "This function creates a read transaction for the FileMemory instance. When the transaction begins ( __enter__ method), it acquires a reader lock, ensurin...
[ "tests/test_memory.py::test_file_memory_write_transaction" ]
8
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/bplustree/bplustree/node.py # lines: 74-87 # @property # def biggest_entry(self): # return self.entries[-1] # @property # @abc.abstractmethod # d...
class FileMemory: __slots__ = ['_filename', '_tree_conf', '_lock', '_cache', '_fd', '_dir_fd', '_wal', 'last_page'] def __init__(self, filename: str, tree_conf: TreeConf, cache_size: int=512): self._filename = filename self._tree_conf = tree_conf self....
bplustree.utils.pairwise
function
Database/bplustree
Database/bplustree/bplustree/utils.py
[ 5, 5 ]
[ 10, 12 ]
{ "cross_file": [], "intra_class": [], "intra_file": [] }
{ "Arguments": ":param iterable: Iterable. The input iterable to iterate over.\n:return: Zip. The pairs of elements in the iterable.", "Functionality": "This function iterates over elements two by two in the given iterable." }
[ "tests/test_utils.py::test_pairwise" ]
4
You are a Python programmer working with a repository. Here is all the context you may find useful to complete the function: # file path: Database/bplustree/bplustree/utils.py import itertools from typing import Iterable Based on the information above, please complete the function in the current file Database/bpl...
def pairwise(iterable: Iterable): """Iterate over elements two by two. s -> (s0,s1), (s1,s2), (s2, s3), ... """