id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20,900 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/languages.py | chatterbot.languages.ZHT | class ZHT:
ISO_639_1 = ''
ISO_639 = 'zht'
ENGLISH_NAME = 'TraditionalChinese' | class ZHT:
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 3 | 0 | 4 | 4 | 3 | 0 | 0 | 0 | 0 |
20,901 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/languages.py | chatterbot.languages.ZUL | class ZUL:
ISO_639_1 = ''
ISO_639 = 'zul'
ENGLISH_NAME = 'Zulu' | class ZUL:
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 3 | 0 | 4 | 4 | 3 | 0 | 0 | 0 | 0 |
20,902 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/languages.py | chatterbot.languages.ZUN | class ZUN:
ISO_639_1 = ''
ISO_639 = 'zun'
ENGLISH_NAME = 'Zuni' | class ZUN:
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 3 | 0 | 4 | 4 | 3 | 0 | 0 | 0 | 0 |
20,903 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/languages.py | chatterbot.languages.ZZA | class ZZA:
ISO_639_1 = ''
ISO_639 = 'zza'
ENGLISH_NAME = 'Zaza' | class ZZA:
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4 | 0 | 4 | 4 | 3 | 0 | 4 | 4 | 3 | 0 | 0 | 0 | 0 |
20,904 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/logic/best_match.py | chatterbot.logic.best_match.BestMatch | from chatterbot import filters
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
class BestMatch(LogicAdapter):
"""
A logic adapter that returns a response based on known responses to
the closest matches to the input statement.
:param excluded_words:
The e... |
class BestMatch(LogicAdapter):
'''
A logic adapter that returns a response based on known responses to
the closest matches to the input statement.
:param excluded_words:
The excluded_words parameter allows a list of words to be set that will
prevent the logic adapter from returning stat... | 3 | 1 | 48 | 9 | 35 | 4 | 5 | 0.28 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 8 | 112 | 21 | 71 | 14 | 68 | 20 | 36 | 14 | 33 | 8 | 3 | 2 | 9 |
20,905 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/logic/logic_adapter.py | chatterbot.logic.logic_adapter.LogicAdapter | from chatterbot.search import IndexedTextSearch
from random import choice
from chatterbot.conversation import Statement
from chatterbot.adapters import Adapter
from chatterbot import utils
from chatterbot.storage import StorageAdapter
class LogicAdapter(Adapter):
"""
This is an abstract class that represents t... |
class LogicAdapter(Adapter):
'''
This is an abstract class that represents the interface
that all logic adapters should implement.
:param search_algorithm_name: The name of the search algorithm that should
be used to search for close matches to the provided input.
Defaults to the value ... | 7 | 5 | 19 | 3 | 9 | 7 | 2 | 1.15 | 1 | 6 | 4 | 9 | 5 | 5 | 5 | 6 | 127 | 26 | 47 | 16 | 38 | 54 | 29 | 15 | 21 | 3 | 2 | 2 | 8 |
20,906 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/logic/mathematical_evaluation.py | chatterbot.logic.mathematical_evaluation.MathematicalEvaluation | from chatterbot.conversation import Statement
from chatterbot import languages
from chatterbot.logic import LogicAdapter
class MathematicalEvaluation(LogicAdapter):
"""
The MathematicalEvaluation logic adapter parses input to determine
whether the user is asking a question that requires math to be done.
... |
class MathematicalEvaluation(LogicAdapter):
'''
The MathematicalEvaluation logic adapter parses input to determine
whether the user is asking a question that requires math to be done.
If so, the equation is extracted from the input and returned with
the evaluated result.
For example:
Us... | 4 | 3 | 15 | 3 | 9 | 4 | 2 | 0.85 | 1 | 2 | 1 | 0 | 3 | 2 | 3 | 9 | 63 | 13 | 27 | 12 | 22 | 23 | 24 | 12 | 19 | 3 | 3 | 1 | 5 |
20,907 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/logic/specific_response.py | chatterbot.logic.specific_response.SpecificResponseAdapter | from chatterbot import languages
from chatterbot.logic import LogicAdapter
from chatterbot.conversation import Statement
from chatterbot.utils import get_model_for_language
import spacy
class SpecificResponseAdapter(LogicAdapter):
"""
Return a specific response to a specific input.
:kwargs:
* *inp... |
class SpecificResponseAdapter(LogicAdapter):
'''
Return a specific response to a specific input.
:kwargs:
* *input_text* (``str``) --
The input text that triggers this logic adapter.
* *output_text* (``str`` or ``function``) --
The output text returned by this logic adap... | 5 | 1 | 7 | 2 | 5 | 0 | 2 | 0.47 | 1 | 2 | 1 | 0 | 3 | 2 | 3 | 9 | 34 | 9 | 17 | 8 | 12 | 8 | 16 | 8 | 11 | 2 | 3 | 1 | 5 |
20,908 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/logic/time_adapter.py | chatterbot.logic.time_adapter.TimeLogicAdapter | from chatterbot.conversation import Statement
from chatterbot import languages
from chatterbot.logic import LogicAdapter
import spacy
from chatterbot.utils import get_model_for_language
from datetime import datetime
class TimeLogicAdapter(LogicAdapter):
"""
The TimeLogicAdapter returns the current time.
:... |
class TimeLogicAdapter(LogicAdapter):
'''
The TimeLogicAdapter returns the current time.
:kwargs:
* *positive* (``list``) --
The time-related questions used to identify time questions about the current time.
Defaults to a list of English sentences.
* *language* (``str``)... | 3 | 1 | 27 | 4 | 21 | 2 | 3 | 0.24 | 1 | 5 | 2 | 0 | 3 | 3 | 3 | 9 | 95 | 17 | 63 | 21 | 58 | 15 | 34 | 21 | 29 | 5 | 3 | 1 | 8 |
20,909 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/search.py | chatterbot.search.IndexedTextSearch | class IndexedTextSearch:
"""
:param statement_comparison_function: A comparison class.
Defaults to ``LevenshteinDistance``.
:param search_page_size:
The maximum number of records to load into memory at a time when searching.
Defaults to 1000
"""
name = 'indexed_text_search'
... | class IndexedTextSearch:
'''
:param statement_comparison_function: A comparison class.
Defaults to ``LevenshteinDistance``.
:param search_page_size:
The maximum number of records to load into memory at a time when searching.
Defaults to 1000
'''
def __init__(self, chatbot, *... | 3 | 2 | 36 | 10 | 21 | 5 | 3 | 0.39 | 0 | 1 | 1 | 0 | 2 | 3 | 2 | 2 | 84 | 23 | 44 | 15 | 40 | 17 | 27 | 15 | 23 | 5 | 0 | 2 | 6 |
20,910 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/search.py | chatterbot.search.TextSearch | class TextSearch:
"""
:param statement_comparison_function: A comparison class.
Defaults to ``LevenshteinDistance``.
:param search_page_size:
The maximum number of records to load into memory at a time when searching.
Defaults to 1000
"""
name = 'text_search'
def __init... | class TextSearch:
'''
:param statement_comparison_function: A comparison class.
Defaults to ``LevenshteinDistance``.
:param search_page_size:
The maximum number of records to load into memory at a time when searching.
Defaults to 1000
'''
def __init__(self, chatbot, **kwargs... | 3 | 2 | 30 | 8 | 17 | 5 | 3 | 0.49 | 0 | 1 | 1 | 0 | 2 | 3 | 2 | 2 | 72 | 20 | 35 | 14 | 31 | 17 | 23 | 14 | 19 | 4 | 0 | 2 | 5 |
20,911 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/storage/django_storage.py | chatterbot.storage.django_storage.DjangoStorageAdapter | from chatterbot.storage import StorageAdapter
from chatterbot import constants
class DjangoStorageAdapter(StorageAdapter):
"""
Storage adapter that allows ChatterBot to interact with
Django storage backends.
"""
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.django_a... |
class DjangoStorageAdapter(StorageAdapter):
'''
Storage adapter that allows ChatterBot to interact with
Django storage backends.
'''
def __init__(self, **kwargs):
pass
def get_statement_model(self):
pass
def get_tag_model(self):
pass
def count(self) -> int:
... | 12 | 8 | 18 | 4 | 12 | 2 | 3 | 0.23 | 1 | 3 | 0 | 0 | 11 | 1 | 11 | 23 | 214 | 55 | 129 | 55 | 114 | 30 | 107 | 55 | 92 | 10 | 2 | 3 | 32 |
20,912 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/storage/mongodb.py | chatterbot.storage.mongodb.MongoDatabaseAdapter | from random import randint
import re
from chatterbot.storage import StorageAdapter
class MongoDatabaseAdapter(StorageAdapter):
"""
The MongoDatabaseAdapter is an interface that allows
ChatterBot to store statements in a MongoDB database.
:keyword database_uri: The URI of a remote instance of MongoDB.
... |
class MongoDatabaseAdapter(StorageAdapter):
'''
The MongoDatabaseAdapter is an interface that allows
ChatterBot to store statements in a MongoDB database.
:keyword database_uri: The URI of a remote instance of MongoDB.
This can be any valid
`MongoDB... | 12 | 9 | 21 | 4 | 14 | 3 | 4 | 0.28 | 1 | 6 | 1 | 0 | 11 | 4 | 11 | 23 | 258 | 60 | 155 | 52 | 138 | 43 | 126 | 52 | 109 | 19 | 2 | 3 | 42 |
20,913 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/storage/sql_storage.py | chatterbot.storage.sql_storage.SQLStorageAdapter | import random
from chatterbot.storage import StorageAdapter
class SQLStorageAdapter(StorageAdapter):
"""
The SQLStorageAdapter allows ChatterBot to store conversation
data in any database supported by the SQL Alchemy ORM.
All parameters are optional, by default a sqlite database is used.
It will ... |
class SQLStorageAdapter(StorageAdapter):
'''
The SQLStorageAdapter allows ChatterBot to store conversation
data in any database supported by the SQL Alchemy ORM.
All parameters are optional, by default a sqlite database is used.
It will check if tables are present, if they are not, it will attempt
... | 16 | 12 | 24 | 6 | 15 | 3 | 3 | 0.27 | 1 | 8 | 3 | 0 | 14 | 3 | 14 | 26 | 392 | 101 | 229 | 99 | 197 | 62 | 195 | 98 | 164 | 12 | 2 | 3 | 52 |
20,914 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/storage/storage_adapter.py | chatterbot.storage.storage_adapter.StorageAdapter | import logging
class StorageAdapter(object):
"""
This is an abstract class that represents the interface
that all storage adapters should implement.
"""
def __init__(self, *args, **kwargs):
"""
Initialize common attributes shared by all storage adapters.
:param str tagger_... |
class StorageAdapter(object):
'''
This is an abstract class that represents the interface
that all storage adapters should implement.
'''
def __init__(self, *args, **kwargs):
'''
Initialize common attributes shared by all storage adapters.
:param str tagger_language: The la... | 16 | 13 | 11 | 1 | 4 | 5 | 1 | 1.26 | 1 | 3 | 3 | 3 | 12 | 2 | 12 | 12 | 172 | 32 | 62 | 24 | 45 | 78 | 38 | 24 | 21 | 1 | 1 | 0 | 13 |
20,915 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/tagging.py | chatterbot.tagging.LowercaseTagger | import spacy
from typing import List, Union, Tuple
from chatterbot import languages
class LowercaseTagger(object):
"""
Returns the text in lowercase.
"""
def __init__(self, language=None):
from chatterbot.components import chatterbot_lowercase_indexer
self.language = language or langua... |
class LowercaseTagger(object):
'''
Returns the text in lowercase.
'''
def __init__(self, language=None):
pass
def get_text_index_string(self, text: Union[str, List[str]]):
pass
def as_nlp_pipeline(self, texts: Union[List[str], Tuple[str, dict]]):
pass | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.6 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 2 | 10 | 2 | 5 | 4 | 2 | 3 | 5 | 4 | 2 | 1 | 1 | 0 | 2 |
20,916 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/tagging.py | chatterbot.tagging.PosLemmaTagger | from chatterbot.utils import get_model_for_language
from typing import List, Union, Tuple
from chatterbot import languages
import spacy
class PosLemmaTagger(object):
def __init__(self, language=None):
from chatterbot.components import chatterbot_bigram_indexer
self.language = language or languages... |
class PosLemmaTagger(object):
def __init__(self, language=None):
pass
def get_text_index_string(self, text: Union[str, List[str]]) -> str:
'''
Return a string of text containing part-of-speech, lemma pairs.
'''
pass
def as_nlp_pipeline(self, texts: Union[List[str]... | 4 | 2 | 27 | 6 | 20 | 2 | 5 | 0.07 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 2 | 57 | 13 | 41 | 14 | 37 | 3 | 27 | 13 | 23 | 7 | 1 | 2 | 9 |
20,917 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/trainers.py | chatterbot.trainers.ChatterBotCorpusTrainer | from tqdm import tqdm
from chatterbot.conversation import Statement
from typing import List, Union
class ChatterBotCorpusTrainer(Trainer):
"""
Allows the chat bot to be trained using data from the
ChatterBot dialog corpus.
"""
def train(self, *corpus_paths: Union[str, List[str]]):
from cha... |
class ChatterBotCorpusTrainer(Trainer):
'''
Allows the chat bot to be trained using data from the
ChatterBot dialog corpus.
'''
def train(self, *corpus_paths: Union[str, List[str]]):
pass | 2 | 1 | 49 | 15 | 32 | 2 | 7 | 0.18 | 1 | 3 | 1 | 0 | 1 | 0 | 1 | 6 | 55 | 16 | 33 | 13 | 30 | 6 | 23 | 13 | 20 | 7 | 2 | 3 | 7 |
20,918 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/trainers.py | chatterbot.trainers.ListTrainer | from chatterbot.conversation import Statement
from tqdm import tqdm
from typing import List, Union
class ListTrainer(Trainer):
"""
Allows a chat bot to be trained using a list of strings
where the list represents a conversation.
"""
def train(self, conversation: List[str]):
"""
Tra... |
class ListTrainer(Trainer):
'''
Allows a chat bot to be trained using a list of strings
where the list represents a conversation.
'''
def train(self, conversation: List[str]):
'''
Train the chat bot based on the provided list of
statements that represents a single conversat... | 2 | 2 | 35 | 7 | 24 | 4 | 3 | 0.32 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 6 | 41 | 8 | 25 | 8 | 23 | 8 | 14 | 8 | 12 | 3 | 2 | 2 | 3 |
20,919 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/trainers.py | chatterbot.trainers.Trainer | from chatterbot.conversation import Statement
import json
from chatterbot.chatterbot import ChatBot
import os
class Trainer(object):
"""
Base class for all other trainer classes.
:param boolean show_training_progress: Show progress indicators for the
trainer. The environment variable ``CHATTERB... |
class Trainer(object):
'''
Base class for all other trainer classes.
:param boolean show_training_progress: Show progress indicators for the
trainer. The environment variable ``CHATTERBOT_SHOW_TRAINING_PROGRESS``
can also be set to control this. ``show_training_progress`` will overrid... | 8 | 5 | 7 | 1 | 5 | 2 | 2 | 0.66 | 1 | 3 | 1 | 3 | 5 | 2 | 5 | 5 | 65 | 12 | 32 | 18 | 23 | 21 | 26 | 17 | 17 | 3 | 1 | 2 | 9 |
20,920 | gunthercox/ChatterBot | gunthercox_ChatterBot/chatterbot/trainers.py | chatterbot.trainers.UbuntuCorpusTrainer | from chatterbot.chatterbot import ChatBot
from tqdm import tqdm
import os
import tarfile
import glob
import time
from typing import List, Union
class UbuntuCorpusTrainer(CsvFileTrainer):
"""
.. note::
PENDING DEPRECATION: Please use the ``CsvFileTrainer`` for data formats similar to this one.
Allo... |
class UbuntuCorpusTrainer(CsvFileTrainer):
'''
.. note::
PENDING DEPRECATION: Please use the ``CsvFileTrainer`` for data formats similar to this one.
Allow chatbots to be trained with the data from the Ubuntu Dialog Corpus.
For more information about the Ubuntu Dialog Corpus visit:
https://... | 10 | 7 | 21 | 5 | 14 | 3 | 3 | 0.25 | 1 | 9 | 2 | 0 | 6 | 3 | 6 | 11 | 202 | 52 | 120 | 51 | 106 | 30 | 102 | 48 | 88 | 8 | 2 | 6 | 29 |
20,921 | gunthercox/ChatterBot | gunthercox_ChatterBot/examples/django_example/django_example/views.py | django_example.views.ChatterBotApiView | from django.conf import settings
from django.views.generic import View
from chatterbot import ChatBot
import json
from django.http import JsonResponse
class ChatterBotApiView(View):
"""
Provide an API endpoint to interact with ChatterBot.
"""
chatterbot = ChatBot(**settings.CHATTERBOT)
def post(se... |
class ChatterBotApiView(View):
'''
Provide an API endpoint to interact with ChatterBot.
'''
def post(self, request, *args, **kwargs):
'''
Return a response to the statement in the posted data.
* The JSON data should contain a 'text' attribute.
'''
pass
def ... | 3 | 3 | 14 | 3 | 8 | 4 | 2 | 0.59 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 35 | 8 | 17 | 7 | 14 | 10 | 11 | 7 | 8 | 2 | 1 | 1 | 3 |
20,922 | gunthercox/ChatterBot | gunthercox_ChatterBot/examples/django_example/django_example/views.py | django_example.views.ChatterBotAppView | from django.views.generic.base import TemplateView
class ChatterBotAppView(TemplateView):
template_name = 'app.html' |
class ChatterBotAppView(TemplateView):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 1 | 0 | 0 |
20,923 | gunthercox/ChatterBot | gunthercox_ChatterBot/examples/tkinter_gui.py | examples.tkinter_gui.TkinterGUIExample | import tkinter as tk
from chatterbot import ChatBot
import time
class TkinterGUIExample(tk.Tk):
def __init__(self, *args, **kwargs):
"""
Create & set window variables.
"""
tk.Tk.__init__(self, *args, **kwargs)
self.chatbot = ChatBot('GUI Bot', storage_adapter='chatterbot.st... |
class TkinterGUIExample(tk.Tk):
def __init__(self, *args, **kwargs):
'''
Create & set window variables.
'''
pass
def initialize(self):
'''
Set window layout.
'''
pass
def get_response(self):
'''
Get a response from the chatb... | 4 | 3 | 17 | 3 | 11 | 3 | 1 | 0.27 | 1 | 2 | 1 | 0 | 3 | 5 | 3 | 190 | 55 | 13 | 33 | 11 | 29 | 9 | 24 | 11 | 20 | 1 | 2 | 0 | 3 |
20,924 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.DeprecatedDefaultStagesWarning | import cfgv
from typing import NamedTuple
from typing import Any
class DeprecatedDefaultStagesWarning(NamedTuple):
key: str
def check(self, dct: dict[str, Any]) -> None:
if self.key not in dct:
return
val = dct[self.key]
cfgv.check_array(cfgv.check_any)(val)
legacy_... |
class DeprecatedDefaultStagesWarning(NamedTuple):
def check(self, dct: dict[str, Any]) -> None:
pass
def apply_default(self, dct: dict[str, Any]) -> None:
pass
def remove_default(self, dct: dict[str, Any]) -> None:
pass | 4 | 0 | 6 | 1 | 6 | 0 | 2 | 0 | 1 | 4 | 0 | 0 | 3 | 0 | 3 | 3 | 24 | 5 | 19 | 6 | 15 | 0 | 14 | 6 | 10 | 3 | 1 | 1 | 5 |
20,925 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.DeprecatedStagesWarning | from typing import NamedTuple
import cfgv
from typing import Any
class DeprecatedStagesWarning(NamedTuple):
key: str
def check(self, dct: dict[str, Any]) -> None:
if self.key not in dct:
return
val = dct[self.key]
cfgv.check_array(cfgv.check_any)(val)
legacy_stages ... |
class DeprecatedStagesWarning(NamedTuple):
def check(self, dct: dict[str, Any]) -> None:
pass
def apply_default(self, dct: dict[str, Any]) -> None:
pass
def remove_default(self, dct: dict[str, Any]) -> None:
pass | 4 | 0 | 6 | 1 | 6 | 0 | 2 | 0 | 1 | 4 | 0 | 0 | 3 | 0 | 3 | 3 | 24 | 5 | 19 | 6 | 15 | 0 | 14 | 6 | 10 | 3 | 1 | 1 | 5 |
20,926 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.InvalidConfigError | from pre_commit.errors import FatalError
class InvalidConfigError(FatalError):
pass |
class InvalidConfigError(FatalError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 5 | 0 | 0 |
20,927 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.InvalidManifestError | from pre_commit.errors import FatalError
class InvalidManifestError(FatalError):
pass |
class InvalidManifestError(FatalError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 5 | 0 | 0 |
20,928 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.NotAllowed | from typing import Any
import cfgv
class NotAllowed(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
if self.key in dct:
raise cfgv.ValidationError(f'{self.key!r} cannot be overridden') |
class NotAllowed(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
pass | 2 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 1 | 1 | 1 | 1 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 2 | 2 | 2 | 1 | 1 | 2 |
20,929 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.OptionalSensibleRegexAtHook | import cfgv
from typing import Any
class OptionalSensibleRegexAtHook(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
super().check(dct)
if '/*' in dct.get(self.key, ''):
logger.warning(f"The {self.key!r} field in hook {dct.get('id')!r} is a regex, not a glob -- m... |
class OptionalSensibleRegexAtHook(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
pass | 2 | 0 | 16 | 1 | 15 | 0 | 4 | 0 | 1 | 4 | 0 | 0 | 1 | 0 | 1 | 1 | 17 | 1 | 16 | 3 | 14 | 0 | 8 | 3 | 6 | 4 | 1 | 2 | 4 |
20,930 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.OptionalSensibleRegexAtTop | import cfgv
from typing import Any
class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
super().check(dct)
if '/*' in dct.get(self.key, ''):
logger.warning(f"The top-level {self.key!r} field is a regex, not a glob -- matching '/*' prob... |
class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
def check(self, dct: dict[str, Any]) -> None:
pass | 2 | 0 | 15 | 1 | 14 | 0 | 4 | 0 | 1 | 4 | 0 | 0 | 1 | 0 | 1 | 1 | 16 | 1 | 15 | 3 | 13 | 0 | 8 | 3 | 6 | 4 | 1 | 2 | 4 |
20,931 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.StagesMigration | from typing import Any
class StagesMigration(StagesMigrationNoDefault):
def apply_default(self, dct: dict[str, Any]) -> None:
dct.setdefault(self.key, self.default)
super().apply_default(dct) |
class StagesMigration(StagesMigrationNoDefault):
def apply_default(self, dct: dict[str, Any]) -> None:
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 4 | 0 | 0 | 1 | 0 | 1 | 4 | 4 | 0 | 4 | 2 | 2 | 0 | 4 | 2 | 2 | 1 | 2 | 0 | 1 |
20,932 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.StagesMigrationNoDefault | from typing import NamedTuple
import cfgv
from typing import Any
from collections.abc import Sequence
class StagesMigrationNoDefault(NamedTuple):
key: str
default: Sequence[str]
def check(self, dct: dict[str, Any]) -> None:
if self.key not in dct:
return
val = dct[self.key]
... |
class StagesMigrationNoDefault(NamedTuple):
def check(self, dct: dict[str, Any]) -> None:
pass
def apply_default(self, dct: dict[str, Any]) -> None:
pass
def remove_default(self, dct: dict[str, Any]) -> None:
pass | 4 | 0 | 5 | 1 | 4 | 0 | 2 | 0 | 1 | 4 | 0 | 1 | 3 | 0 | 3 | 3 | 21 | 5 | 16 | 5 | 12 | 0 | 16 | 5 | 12 | 2 | 1 | 1 | 5 |
20,933 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/clientlib.py | pre_commit.clientlib.WarnMutableRev | import cfgv
from typing import Any
import re
class WarnMutableRev(cfgv.Conditional):
def check(self, dct: dict[str, Any]) -> None:
super().check(dct)
if self.key in dct:
rev = dct[self.key]
if '.' not in rev and (not re.match('^[a-fA-F0-9]+$', rev)):
logger.... |
class WarnMutableRev(cfgv.Conditional):
def check(self, dct: dict[str, Any]) -> None:
pass | 2 | 0 | 16 | 2 | 14 | 1 | 3 | 0.07 | 1 | 4 | 0 | 0 | 1 | 1 | 1 | 1 | 17 | 2 | 15 | 4 | 13 | 1 | 7 | 3 | 5 | 3 | 1 | 2 | 3 |
20,934 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/commands/autoupdate.py | pre_commit.commands.autoupdate.RepositoryCannotBeUpdatedError | class RepositoryCannotBeUpdatedError(RuntimeError):
pass | class RepositoryCannotBeUpdatedError(RuntimeError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
20,935 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/commands/autoupdate.py | pre_commit.commands.autoupdate.RevInfo | from pre_commit.clientlib import load_manifest
from pre_commit.util import cmd_output_b
from pre_commit.clientlib import InvalidManifestError
from pre_commit.util import cmd_output
from typing import NamedTuple
import pre_commit.constants as C
from typing import Any
from pre_commit.util import CalledProcessError
import... |
class RevInfo(NamedTuple):
@classmethod
def from_config(cls, config: dict[str, Any]) -> RevInfo:
pass
def update(self, tags_only: bool, freeze: bool) -> RevInfo:
pass | 4 | 0 | 24 | 3 | 20 | 1 | 5 | 0.04 | 1 | 9 | 3 | 0 | 1 | 0 | 2 | 2 | 55 | 8 | 46 | 16 | 42 | 2 | 41 | 13 | 38 | 8 | 1 | 3 | 9 |
20,936 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/commands/run.py | pre_commit.commands.run.Classifier | import os
from collections.abc import Iterable
from identify.identify import tags_from_path
from collections.abc import Generator
from pre_commit.hook import Hook
import functools
class Classifier:
def __init__(self, filenames: Iterable[str]) -> None:
self.filenames = [f for f in filenames if os.path.lexi... |
class Classifier:
def __init__(self, filenames: Iterable[str]) -> None:
pass
@functools.cache
def _types_for_file(self, filename: str) -> set[str]:
pass
def by_types(self, names: Iterable[str], types: Iterable[str], types_or: Iterable[str], exclude_types: Iterable[str]) -> Generator[s... | 8 | 0 | 9 | 0 | 9 | 1 | 2 | 0.09 | 0 | 6 | 1 | 0 | 4 | 1 | 5 | 5 | 54 | 4 | 46 | 22 | 27 | 4 | 20 | 9 | 14 | 3 | 0 | 2 | 8 |
20,937 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/envcontext.py | pre_commit.envcontext.Var | from typing import NamedTuple
class Var(NamedTuple):
name: str
default: str = '' |
class Var(NamedTuple):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 2 | 2 | 0 | 3 | 2 | 2 | 0 | 1 | 0 | 0 |
20,938 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/errors.py | pre_commit.errors.FatalError | class FatalError(RuntimeError):
pass | class FatalError(RuntimeError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
20,939 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/hook.py | pre_commit.hook.Hook | from pre_commit.prefix import Prefix
from typing import Any
from collections.abc import Sequence
from typing import NamedTuple
class Hook(NamedTuple):
src: str
prefix: Prefix
id: str
name: str
entry: str
language: str
alias: str
files: str
exclude: str
types: Sequence[str]
t... |
class Hook(NamedTuple):
@property
def install_key(self) -> tuple[Prefix, str, str, tuple[str, ...]]:
pass
@classmethod
def create(cls, src: str, prefix: Prefix, dct: dict[str, Any]) -> Hook:
pass | 5 | 0 | 8 | 0 | 8 | 1 | 2 | 0.02 | 1 | 6 | 1 | 0 | 1 | 0 | 2 | 2 | 45 | 2 | 42 | 6 | 37 | 1 | 32 | 4 | 29 | 2 | 1 | 1 | 3 |
20,940 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/lang_base.py | pre_commit.lang_base.Language | from typing import Protocol
from pre_commit.prefix import Prefix
from collections.abc import Sequence
from typing import ContextManager
class Language(Protocol):
@property
def ENVIRONMENT_DIR(self) -> str | None:
...
def get_default_version(self) -> str:
...
def health_check(self, pr... |
class Language(Protocol):
@property
def ENVIRONMENT_DIR(self) -> str | None:
pass
def get_default_version(self) -> str:
pass
def health_check(self, prefix: Prefix, version: str) -> str | None:
pass
def install_environment(self, prefix: Prefix, version: str, additional_de... | 8 | 0 | 4 | 0 | 4 | 0 | 1 | 0.24 | 1 | 7 | 1 | 0 | 6 | 0 | 6 | 30 | 34 | 3 | 25 | 23 | 6 | 6 | 13 | 7 | 6 | 1 | 5 | 0 | 6 |
20,941 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/languages/golang.py | pre_commit.languages.golang.ExtractAll | from typing import Protocol
class ExtractAll(Protocol):
def extractall(self, path: str) -> None:
... |
class ExtractAll(Protocol):
def extractall(self, path: str) -> None:
pass | 2 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 25 | 2 | 0 | 2 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
20,942 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/languages/pygrep.py | pre_commit.languages.pygrep.Choice | from typing import NamedTuple
class Choice(NamedTuple):
multiline: bool
negate: bool |
class Choice(NamedTuple):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 1 | 2 | 0 | 3 | 1 | 2 | 0 | 1 | 0 | 0 |
20,943 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/logging_handler.py | pre_commit.logging_handler.LoggingHandler | from pre_commit import output
import logging
from pre_commit import color
class LoggingHandler(logging.Handler):
def __init__(self, use_color: bool) -> None:
super().__init__()
self.use_color = use_color
def emit(self, record: logging.LogRecord) -> None:
level_msg = color.format_color... |
class LoggingHandler(logging.Handler):
def __init__(self, use_color: bool) -> None:
pass
def emit(self, record: logging.LogRecord) -> None:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 22 | 12 | 1 | 11 | 5 | 8 | 0 | 7 | 5 | 4 | 1 | 3 | 0 | 2 |
20,944 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/parse_shebang.py | pre_commit.parse_shebang.ExecutableNotFoundError | class ExecutableNotFoundError(OSError):
def to_output(self) -> tuple[int, bytes, None]:
return (1, self.args[0].encode(), None) | class ExecutableNotFoundError(OSError):
def to_output(self) -> tuple[int, bytes, None]:
pass | 2 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 1 | 0 | 1 | 14 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
20,945 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/prefix.py | pre_commit.prefix.Prefix | import os.path
from typing import NamedTuple
class Prefix(NamedTuple):
prefix_dir: str
def path(self, *parts: str) -> str:
return os.path.normpath(os.path.join(self.prefix_dir, *parts))
def exists(self, *parts: str) -> bool:
return os.path.exists(self.path(*parts))
def star(self, end... |
class Prefix(NamedTuple):
def path(self, *parts: str) -> str:
pass
def exists(self, *parts: str) -> bool:
pass
def star(self, end: str) -> tuple[str, ...]:
pass | 4 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 3 | 0 | 0 | 3 | 0 | 3 | 3 | 12 | 3 | 9 | 6 | 5 | 0 | 9 | 5 | 5 | 1 | 1 | 0 | 3 |
20,946 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/store.py | pre_commit.store.Store | from typing import Callable
from pre_commit.util import clean_path_on_failure
import sqlite3
import contextlib
from collections.abc import Generator
from collections.abc import Sequence
import pre_commit.constants as C
from pre_commit import file_lock
from pre_commit.util import cmd_output_b
import tempfile
from pre_co... |
class Store:
def __init__(self, directory: str | None=None) -> None:
pass
@contextlib.contextmanager
def exclusive_lock(self) -> Generator[None]:
pass
def blocked_cb() -> None:
pass
@contextlib.contextmanager
def connect(self, db_path: str | None=None) -> G... | 23 | 3 | 11 | 1 | 9 | 1 | 2 | 0.14 | 0 | 7 | 1 | 0 | 14 | 3 | 15 | 15 | 200 | 32 | 151 | 55 | 119 | 21 | 106 | 33 | 86 | 4 | 0 | 2 | 29 |
20,947 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/util.py | pre_commit.util.CalledProcessError | class CalledProcessError(RuntimeError):
def __init__(self, returncode: int, cmd: tuple[str, ...], stdout: bytes, stderr: bytes | None) -> None:
super().__init__(returncode, cmd, stdout, stderr)
self.returncode = returncode
self.cmd = cmd
self.stdout = stdout
self.stderr = st... | class CalledProcessError(RuntimeError):
def __init__(self, returncode: int, cmd: tuple[str, ...], stdout: bytes, stderr: bytes | None) -> None:
pass
def __bytes__(self) -> bytes:
pass
def _indent_or_none(part: bytes | None) -> bytes:
pass
def __str__(self) -> str:... | 5 | 0 | 8 | 0 | 8 | 0 | 1 | 0 | 1 | 5 | 0 | 0 | 3 | 4 | 3 | 14 | 30 | 3 | 27 | 15 | 16 | 0 | 15 | 9 | 10 | 2 | 4 | 1 | 5 |
20,948 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/xargs.py | pre_commit.xargs.ArgumentTooLongError | class ArgumentTooLongError(RuntimeError):
pass | class ArgumentTooLongError(RuntimeError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 4 | 0 | 0 |
20,949 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/yaml_rewrite.py | pre_commit.yaml_rewrite.MappingKey | from collections.abc import Generator
from yaml.nodes import MappingNode
from yaml.nodes import Node
from typing import NamedTuple
class MappingKey(NamedTuple):
k: str
def match(self, n: Node) -> Generator[Node]:
if isinstance(n, MappingNode):
for k, _ in n.value:
if k.valu... |
class MappingKey(NamedTuple):
def match(self, n: Node) -> Generator[Node]:
pass | 2 | 0 | 5 | 0 | 5 | 0 | 4 | 0 | 1 | 3 | 0 | 0 | 1 | 0 | 1 | 1 | 8 | 1 | 7 | 3 | 5 | 0 | 7 | 3 | 5 | 4 | 1 | 3 | 4 |
20,950 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/yaml_rewrite.py | pre_commit.yaml_rewrite.MappingValue | from yaml.nodes import MappingNode
from collections.abc import Generator
from yaml.nodes import Node
from typing import NamedTuple
class MappingValue(NamedTuple):
k: str
def match(self, n: Node) -> Generator[Node]:
if isinstance(n, MappingNode):
for k, v in n.value:
if k.va... |
class MappingValue(NamedTuple):
def match(self, n: Node) -> Generator[Node]:
pass | 2 | 0 | 5 | 0 | 5 | 0 | 4 | 0 | 1 | 3 | 0 | 0 | 1 | 0 | 1 | 1 | 8 | 1 | 7 | 3 | 5 | 0 | 7 | 3 | 5 | 4 | 1 | 3 | 4 |
20,951 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/yaml_rewrite.py | pre_commit.yaml_rewrite.SequenceItem | from collections.abc import Generator
from yaml.nodes import Node
from yaml.nodes import SequenceNode
from typing import NamedTuple
class SequenceItem(NamedTuple):
def match(self, n: Node) -> Generator[Node]:
if isinstance(n, SequenceNode):
yield from n.value |
class SequenceItem(NamedTuple):
def match(self, n: Node) -> Generator[Node]:
pass | 2 | 0 | 3 | 0 | 3 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 1 | 0 | 1 | 1 | 4 | 0 | 4 | 2 | 2 | 0 | 4 | 2 | 2 | 2 | 1 | 1 | 2 |
20,952 | pre-commit/pre-commit | pre-commit_pre-commit/pre_commit/yaml_rewrite.py | pre_commit.yaml_rewrite._Matcher | from collections.abc import Generator
from yaml.nodes import Node
from typing import Protocol
class _Matcher(Protocol):
def match(self, n: Node) -> Generator[Node]:
... |
class _Matcher(Protocol):
def match(self, n: Node) -> Generator[Node]:
pass | 2 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 1 | 0 | 1 | 25 | 2 | 0 | 2 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 5 | 0 | 1 |
20,953 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.BitStream | class BitStream:
"""Represent a bytes object. Can read bits and prefix codes the way
Brotli does.
"""
def __init__(self, byteString):
self.data = byteString
self.pos = 0
def __repr__(self):
"""Representation
>>> olleke
BitStream(pos=0:0)
"""
... | class BitStream:
'''Represent a bytes object. Can read bits and prefix codes the way
Brotli does.
'''
def __init__(self, byteString):
pass
def __repr__(self):
'''Representation
>>> olleke
BitStream(pos=0:0)
'''
pass
def read(self, n):
''... | 6 | 5 | 10 | 0 | 4 | 6 | 1 | 1.52 | 0 | 2 | 0 | 0 | 5 | 2 | 5 | 5 | 58 | 5 | 21 | 10 | 15 | 32 | 20 | 10 | 14 | 2 | 0 | 1 | 7 |
20,954 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.BlockCountAlphabet | class BlockCountAlphabet(Enumerator):
"""Block counts
>>> b = BlockCountAlphabet('L')
>>> print(b[25])
[24*x]: BC16625-16793840
"""
value0 = 1
extraTable = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 24]
def __init__(self, name, **args):
super... | class BlockCountAlphabet(Enumerator):
'''Block counts
>>> b = BlockCountAlphabet('L')
>>> print(b[25])
[24*x]: BC16625-16793840
'''
def __init__(self, name, **args):
pass
def mnemonic(self, index):
pass
def explanation(self, index, extra):
pass | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.42 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 46 | 20 | 3 | 12 | 7 | 8 | 5 | 10 | 7 | 6 | 2 | 4 | 0 | 4 |
20,955 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.BlockTypeAlphabet | class BlockTypeAlphabet(Code):
"""The block types; this code works for all three kinds.
>>> b = BlockTypeAlphabet('T', NBLTYPES=5)
>>> print(*(x for x in b))
prev +1 #0 #1 #2 #3 #4
"""
def __init__(self, name, NBLTYPES, **args):
super().__init__(name, alphabetSize=NBLTYPES + 2, **args)
... | class BlockTypeAlphabet(Code):
'''The block types; this code works for all three kinds.
>>> b = BlockTypeAlphabet('T', NBLTYPES=5)
>>> print(*(x for x in b))
prev +1 #0 #1 #2 #3 #4
'''
def __init__(self, name, NBLTYPES, **args):
pass
def mnemonic(self, index):
pass
def... | 5 | 1 | 3 | 0 | 3 | 0 | 2 | 0.43 | 1 | 2 | 0 | 0 | 4 | 1 | 4 | 37 | 22 | 3 | 14 | 6 | 9 | 6 | 16 | 6 | 11 | 3 | 2 | 1 | 8 |
20,956 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.BoolCode | class BoolCode(Code):
"""Same as Code(bitLength=1), but shows a boolean.
"""
def __init__(self, name=None, **args):
super().__init__(name, bitLength=1, **args)
def value(self, index, extra=None):
return bool(super().value(index, extra)) | class BoolCode(Code):
'''Same as Code(bitLength=1), but shows a boolean.
'''
def __init__(self, name=None, **args):
pass
def value(self, index, extra=None):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 0.4 | 1 | 2 | 0 | 2 | 2 | 0 | 2 | 35 | 8 | 1 | 5 | 3 | 2 | 2 | 5 | 3 | 2 | 1 | 2 | 0 | 2 |
20,957 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.Code | from itertools import accumulate, repeat
class Code(RangeDecoder, PrefixDecoder):
"""An alphabet of symbols, that can be read from a stream.
If you use setDecode or setLength, you have a prefix code,
otherwise you have a range code.
Features:
code[index] produces symbol with given index
value(i... |
class Code(RangeDecoder, PrefixDecoder):
'''An alphabet of symbols, that can be read from a stream.
If you use setDecode or setLength, you have a prefix code,
otherwise you have a range code.
Features:
code[index] produces symbol with given index
value(index): value of symbol
mnemonic(index... | 18 | 7 | 5 | 0 | 4 | 1 | 1 | 0.62 | 2 | 7 | 0 | 8 | 16 | 2 | 16 | 33 | 111 | 9 | 63 | 30 | 51 | 39 | 58 | 30 | 40 | 5 | 1 | 1 | 23 |
20,958 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.ContextModeKeeper | from collections import defaultdict, deque
class ContextModeKeeper:
"""For computing the literal context mode.
You feed it characters, and it computes indices in the context map.
"""
def __init__(self, mode):
self.chars = deque([0, 0], maxlen=2)
self.mode = mode
def setContextMode... |
class ContextModeKeeper:
'''For computing the literal context mode.
You feed it characters, and it computes indices in the context map.
'''
def __init__(self, mode):
pass
def setContextMode(self, mode):
'''Switch to given context mode (0..3)'''
pass
def getIndex(self)... | 5 | 3 | 5 | 0 | 5 | 2 | 2 | 0.38 | 0 | 0 | 0 | 0 | 4 | 2 | 4 | 4 | 53 | 3 | 39 | 11 | 34 | 15 | 20 | 11 | 15 | 5 | 0 | 1 | 8 |
20,959 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.CopyLengthAlphabet | class CopyLengthAlphabet(Enumerator):
value0 = 2
extraTable = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24] | class CopyLengthAlphabet(Enumerator):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 43 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
20,960 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.DistanceAlphabet | class DistanceAlphabet(WithExtra):
"""Represent the distance encoding.
Dynamically generated alphabet.
This is what the documentation should have said:
Ignoring offsets for the moment, the "long" encoding works as follows:
Write the distance in binary as follows:
1xy..yz..z, then the distance sy... | class DistanceAlphabet(WithExtra):
'''Represent the distance encoding.
Dynamically generated alphabet.
This is what the documentation should have said:
Ignoring offsets for the moment, the "long" encoding works as follows:
Write the distance in binary as follows:
1xy..yz..z, then the distance sy... | 6 | 5 | 14 | 0 | 9 | 5 | 2 | 0.94 | 1 | 2 | 0 | 0 | 5 | 2 | 5 | 43 | 97 | 4 | 48 | 19 | 42 | 45 | 37 | 19 | 31 | 5 | 3 | 1 | 12 |
20,961 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.DistanceParamAlphabet | class DistanceParamAlphabet(WithExtra):
"""The distance parameters NPOSTFIX and NDIRECT.
Although these are treated as two in the description, this is easier.
"""
def __init__(self):
super().__init__('DIST', bitLength=2)
def extraBits(self, index):
return 4
def value(self, ind... | class DistanceParamAlphabet(WithExtra):
'''The distance parameters NPOSTFIX and NDIRECT.
Although these are treated as two in the description, this is easier.
'''
def __init__(self):
pass
def extraBits(self, index):
pass
def value(self, index, extra):
'''Returns NPOSTF... | 6 | 2 | 3 | 0 | 3 | 0 | 1 | 0.36 | 1 | 3 | 0 | 0 | 5 | 0 | 5 | 43 | 23 | 4 | 14 | 6 | 8 | 5 | 13 | 6 | 7 | 2 | 3 | 1 | 6 |
20,962 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.Enumerator | class Enumerator(WithExtra):
"""Code that is defined by the ExtraTable.
extraTable is a class variable that contains
the extraBits of the symbols from 0
value0 contains the value of symbol 0
encodings is not necessary, but allowed.
Note: place for FixedCode to make sure extraBits works
"""
... | class Enumerator(WithExtra):
'''Code that is defined by the ExtraTable.
extraTable is a class variable that contains
the extraBits of the symbols from 0
value0 contains the value of symbol 0
encodings is not necessary, but allowed.
Note: place for FixedCode to make sure extraBits works
'''
... | 6 | 4 | 6 | 0 | 4 | 2 | 2 | 0.68 | 1 | 3 | 1 | 5 | 5 | 0 | 5 | 43 | 41 | 4 | 22 | 10 | 16 | 15 | 21 | 10 | 15 | 2 | 3 | 1 | 8 |
20,963 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.FillerAlphabet | class FillerAlphabet(Code):
def __init__(self, *, streamPos):
super().__init__('SKIP', bitLength=-streamPos & 7)
def explanation(self, index):
return '{} bit{} ignored'.format(self.length(index), '' if self.length(index) == 1 else 's') | class FillerAlphabet(Code):
def __init__(self, *, streamPos):
pass
def explanation(self, index):
pass | 3 | 0 | 4 | 0 | 4 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 35 | 9 | 1 | 8 | 3 | 5 | 0 | 5 | 3 | 2 | 2 | 2 | 0 | 3 |
20,964 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.InsertAndCopyAlphabet | class InsertAndCopyAlphabet(WithExtra):
"""The insert and copy code
>>> for x in range(0,704,704//13):
... print('{:10b}'.format(x), InsertAndCopyAlphabet()[x])
0 I0C2&D=0
110110 I6+xC8&D=0
1101100 I5C22+xxx&D=0
10100010 I4C4
11011000 I3C10+x
100001110 I14+xxC... | class InsertAndCopyAlphabet(WithExtra):
'''The insert and copy code
>>> for x in range(0,704,704//13):
... print('{:10b}'.format(x), InsertAndCopyAlphabet()[x])
0 I0C2&D=0
110110 I6+xC8&D=0
1101100 I5C22+xxx&D=0
10100010 I4C4
11011000 I3C10+x
100001110 I14+xxC... | 8 | 3 | 7 | 0 | 6 | 1 | 2 | 0.53 | 1 | 5 | 3 | 0 | 7 | 0 | 7 | 45 | 79 | 7 | 47 | 26 | 39 | 25 | 37 | 26 | 29 | 6 | 3 | 1 | 14 |
20,965 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.InsertLengthAlphabet | class InsertLengthAlphabet(Enumerator):
"""Intern code for insert counts
"""
value0 = 0
extraTable = [0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 12, 14, 24] | class InsertLengthAlphabet(Enumerator):
'''Intern code for insert counts
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 43 | 5 | 0 | 3 | 3 | 2 | 2 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
20,966 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.InvalidStream | class InvalidStream(Exception):
pass | class InvalidStream(Exception):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | 0 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 3 | 0 | 0 |
20,967 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.Layout | from itertools import accumulate, repeat
from collections import defaultdict, deque
class Layout:
"""Class to layout the output.
"""
width = 25
def __init__(self, stream):
self.stream = stream
self.bitPtr = self.width
def makeHexData(self, pos):
"""Produce hex dump of all ... |
class Layout:
'''Class to layout the output.
'''
def __init__(self, stream):
pass
def makeHexData(self, pos):
'''Produce hex dump of all data containing the bits
from pos to stream.pos
'''
pass
def formatBitData(self, pos, width1, width2=0):
'''Sho... | 20 | 16 | 30 | 0 | 22 | 8 | 5 | 0.4 | 0 | 32 | 22 | 0 | 15 | 18 | 16 | 16 | 540 | 17 | 378 | 119 | 358 | 150 | 331 | 118 | 312 | 17 | 0 | 4 | 89 |
20,968 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.LengthAlphabet | class LengthAlphabet(WithExtra):
"""Length of symbols
Used during construction of a code.
"""
def __init__(self, name):
super().__init__(name, alphabetSize=18)
def extraBits(self, index):
return {16: 2, 17: 3}.get(index, 0)
def mnemonic(self, index):
if index == 0:
... | class LengthAlphabet(WithExtra):
'''Length of symbols
Used during construction of a code.
'''
def __init__(self, name):
pass
def extraBits(self, index):
pass
def mnemonic(self, index):
pass
def explanation(self, index, extra):
pass
def value(self, ind... | 6 | 1 | 3 | 0 | 3 | 0 | 2 | 0.29 | 1 | 1 | 0 | 0 | 5 | 0 | 5 | 43 | 22 | 4 | 14 | 6 | 8 | 4 | 15 | 6 | 9 | 4 | 3 | 1 | 8 |
20,969 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.LengthOfLengthAlphabet | class LengthOfLengthAlphabet(Code):
"""For use in decoding complex code descriptors.
>>> lengthOfLengthAlphabet = LengthOfLengthAlphabet('')
>>> print(lengthOfLengthAlphabet[2])
coded with 2 bits
>>> len(lengthOfLengthAlphabet[0])
2
>>> [len(lengthOfLengthAlphabet[x]) for x in range(6)]
... | class LengthOfLengthAlphabet(Code):
'''For use in decoding complex code descriptors.
>>> lengthOfLengthAlphabet = LengthOfLengthAlphabet('')
>>> print(lengthOfLengthAlphabet[2])
coded with 2 bits
>>> len(lengthOfLengthAlphabet[0])
2
>>> [len(lengthOfLengthAlphabet[x]) for x in range(6)]
... | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.92 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 36 | 28 | 3 | 13 | 5 | 9 | 12 | 10 | 5 | 6 | 2 | 2 | 1 | 4 |
20,970 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.LiteralAlphabet | class LiteralAlphabet(Code):
"""Alphabet of symbols.
"""
minLength = maxLength = 8
def __init__(self, number):
super().__init__('L' + str(number), alphabetSize=1 << 8)
def mnemonic(self, index):
return outputCharFormatter(index)
def value(self, index, extra=None):
retu... | class LiteralAlphabet(Code):
'''Alphabet of symbols.
'''
def __init__(self, number):
pass
def mnemonic(self, index):
pass
def value(self, index, extra=None):
pass
def explanation(self, index, extra=None):
pass | 5 | 1 | 2 | 0 | 2 | 0 | 1 | 0.2 | 1 | 2 | 0 | 0 | 4 | 0 | 4 | 37 | 15 | 3 | 10 | 6 | 5 | 2 | 10 | 6 | 5 | 1 | 2 | 0 | 4 |
20,971 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.LiteralContextMode | class LiteralContextMode(Code):
"""For the literal context modes.
>>> LiteralContextMode().showCode()
00:LSB6 01:MSB6 10:UTF8 11:Signed
>>> LiteralContextMode().explanation(2)
'Context mode for type 9: 2(UTF8)'
"""
def __init__(self, *, number=9):
super().__init__('LC' + str(n... | class LiteralContextMode(Code):
'''For the literal context modes.
>>> LiteralContextMode().showCode()
00:LSB6 01:MSB6 10:UTF8 11:Signed
>>> LiteralContextMode().explanation(2)
'Context mode for type 9: 2(UTF8)'
'''
def __init__(self, *, number=9):
pass
def mnemonic(self, ... | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.55 | 1 | 2 | 0 | 0 | 3 | 1 | 3 | 36 | 20 | 3 | 11 | 5 | 7 | 6 | 8 | 5 | 4 | 1 | 2 | 0 | 3 |
20,972 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.MetablockLengthAlphabet | class MetablockLengthAlphabet(WithExtra):
"""Used for the meta block length;
also indicates a block with no data
>>> metablockLengthAlphabet = MetablockLengthAlphabet()
>>> metablockLengthAlphabet[0]; str(metablockLengthAlphabet[0])
Symbol(MLEN, 0)
'empty'
>>> metablockLengthAlphabet[3]
... | class MetablockLengthAlphabet(WithExtra):
'''Used for the meta block length;
also indicates a block with no data
>>> metablockLengthAlphabet = MetablockLengthAlphabet()
>>> metablockLengthAlphabet[0]; str(metablockLengthAlphabet[0])
Symbol(MLEN, 0)
'empty'
>>> metablockLengthAlphabet[3]
... | 6 | 1 | 4 | 0 | 4 | 0 | 2 | 1.05 | 1 | 3 | 1 | 0 | 5 | 0 | 5 | 43 | 50 | 5 | 22 | 10 | 16 | 23 | 25 | 10 | 19 | 4 | 3 | 1 | 10 |
20,973 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.PrefixCodeHeader | class PrefixCodeHeader(WithExtra):
"""Header of prefix codes.
"""
def __init__(self, codename):
super().__init__('PFX', bitLength=2)
self.codename = codename
def extraBits(self, index):
return 2 if index == 1 else 0
def value(self, index, extra):
"""Returns ('Simpl... | class PrefixCodeHeader(WithExtra):
'''Header of prefix codes.
'''
def __init__(self, codename):
pass
def extraBits(self, index):
pass
def value(self, index, extra):
'''Returns ('Simple', #codewords) or ('Complex', HSKIP)
'''
pass
def explanation(self, ... | 5 | 2 | 7 | 0 | 6 | 1 | 3 | 0.21 | 1 | 4 | 0 | 0 | 4 | 1 | 4 | 42 | 32 | 3 | 24 | 7 | 19 | 5 | 19 | 7 | 14 | 4 | 3 | 2 | 10 |
20,974 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.PrefixDecoder | from collections import defaultdict, deque
class PrefixDecoder:
"""A decoder for the Code class that uses a prefix code.
The code is determined by encoding:
encode[p] gives the index corresponding to bit pattern p.
Used setDecode(decodeTable) to switch the decoder from the default
to a prefix decod... |
class PrefixDecoder:
'''A decoder for the Code class that uses a prefix code.
The code is determined by encoding:
encode[p] gives the index corresponding to bit pattern p.
Used setDecode(decodeTable) to switch the decoder from the default
to a prefix decoder, or pass decodeTable at init.
You ca... | 12 | 6 | 10 | 0 | 7 | 3 | 2 | 0.59 | 0 | 7 | 1 | 1 | 10 | 5 | 10 | 10 | 125 | 9 | 73 | 35 | 61 | 43 | 72 | 35 | 60 | 5 | 0 | 3 | 22 |
20,975 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.RLEmaxAlphabet | class RLEmaxAlphabet(Enumerator):
"""Used for describing the run length encoding used for describing context maps.
>>> RLEmaxAlphabet().showCode()
0:1 1:more
"""
value0 = 0
extraTable = [0, 4]
name = 'RLE#'
def mnemonic(self, index):
return ['1', 'more'][index]
def expla... | class RLEmaxAlphabet(Enumerator):
'''Used for describing the run length encoding used for describing context maps.
>>> RLEmaxAlphabet().showCode()
0:1 1:more
'''
def mnemonic(self, index):
pass
def explanation(self, index, extra):
pass | 3 | 1 | 3 | 0 | 3 | 0 | 2 | 0.5 | 1 | 0 | 0 | 0 | 2 | 0 | 2 | 45 | 16 | 2 | 10 | 7 | 7 | 5 | 11 | 7 | 8 | 2 | 4 | 1 | 3 |
20,976 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.RangeDecoder | from functools import partial
class RangeDecoder:
"""A decoder for the Code class that assumes the symbols
are encoded consecutively in binary.
It all depends on the "alphabetSize" property.
The range runs from 0 to alphabetSize-1.
This is the default decoder.
"""
def __init__(self, *, alp... |
class RangeDecoder:
'''A decoder for the Code class that assumes the symbols
are encoded consecutively in binary.
It all depends on the "alphabetSize" property.
The range runs from 0 to alphabetSize-1.
This is the default decoder.
'''
def __init__(self, *, alphabetSize=None, bitLength=... | 8 | 4 | 4 | 0 | 3 | 1 | 1 | 0.79 | 0 | 5 | 1 | 1 | 7 | 2 | 7 | 7 | 40 | 6 | 19 | 10 | 11 | 15 | 21 | 10 | 13 | 3 | 0 | 1 | 10 |
20,977 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.ReservedAlphabet | class ReservedAlphabet(BoolCode):
"""The reserved bit that must be zero.
"""
name = 'RSVD'
def value(self, index):
if index:
raise ValueError('Reserved bit is not zero')
def explanation(self, index):
return 'Reserved (must be zero)' | class ReservedAlphabet(BoolCode):
'''The reserved bit that must be zero.
'''
def value(self, index):
pass
def explanation(self, index):
pass | 3 | 1 | 2 | 0 | 2 | 0 | 2 | 0.33 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 37 | 9 | 1 | 6 | 4 | 3 | 2 | 7 | 4 | 4 | 2 | 3 | 1 | 3 |
20,978 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.SkipLengthAlphabet | class SkipLengthAlphabet(WithExtra):
"""Used for the skip length in an empty metablock
>>> skipLengthAlphabet = SkipLengthAlphabet()
>>> skipLengthAlphabet[0]; str(skipLengthAlphabet[0])
Symbol(SKIP, 0)
'empty'
>>> skipLengthAlphabet[4]
Traceback (most recent call last):
...
Valu... | class SkipLengthAlphabet(WithExtra):
'''Used for the skip length in an empty metablock
>>> skipLengthAlphabet = SkipLengthAlphabet()
>>> skipLengthAlphabet[0]; str(skipLengthAlphabet[0])
Symbol(SKIP, 0)
'empty'
>>> skipLengthAlphabet[4]
Traceback (most recent call last):
...
Valu... | 6 | 1 | 4 | 0 | 4 | 0 | 2 | 1.1 | 1 | 3 | 1 | 0 | 5 | 0 | 5 | 43 | 46 | 4 | 20 | 8 | 14 | 22 | 23 | 8 | 17 | 4 | 3 | 1 | 10 |
20,979 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.Symbol | class Symbol:
"""A symbol in a code.
Refers back to the code that contains it.
Index is the place in the alphabet of the symbol.
"""
__slots__ = ('code', 'index')
def __init__(self, code, value):
self.code = code
self.index = value
def __repr__(self):
return 'Symbol... | class Symbol:
'''A symbol in a code.
Refers back to the code that contains it.
Index is the place in the alphabet of the symbol.
'''
def __init__(self, code, value):
pass
def __repr__(self):
pass
def __len__(self):
'''Number of bits in the prefix notation of this s... | 10 | 7 | 5 | 0 | 3 | 2 | 1 | 0.72 | 0 | 2 | 1 | 0 | 9 | 2 | 9 | 9 | 58 | 8 | 29 | 13 | 19 | 21 | 29 | 13 | 19 | 4 | 0 | 2 | 13 |
20,980 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.TreeAlphabet | class TreeAlphabet(WithExtra):
"""The alphabet to enumerate entries (called trees) in the context map.
parameters are RLEMAX and NTREES
>>> t = TreeAlphabet('', RLEMAX=3, NTREES=5)
>>> len(t)
8
>>> print(t[2])
xx+4 zeroes
>>> t[3].explanation(2)
'8+010=10 zeroes'
>>> t[0].value(0... | class TreeAlphabet(WithExtra):
'''The alphabet to enumerate entries (called trees) in the context map.
parameters are RLEMAX and NTREES
>>> t = TreeAlphabet('', RLEMAX=3, NTREES=5)
>>> len(t)
8
>>> print(t[2])
xx+4 zeroes
>>> t[3].explanation(2)
'8+010=10 zeroes'
>>> t[0].value(0... | 6 | 2 | 6 | 0 | 6 | 1 | 2 | 0.57 | 1 | 1 | 0 | 0 | 5 | 2 | 5 | 43 | 47 | 4 | 30 | 10 | 24 | 17 | 30 | 10 | 24 | 3 | 3 | 1 | 12 |
20,981 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.TypeCountAlphabet | class TypeCountAlphabet(Enumerator):
"""Used for giving block type counts and tree counts.
>>> TypeCountAlphabet(description='').showCode()
0:0 0101:xx,0101 1011:xxxxx,1011
0001:0001 1101:xxxxxx,1101 0111:xxx,0111
1001:xxxx,1001 0011:x,0011 1111:xxxxxxx,1111
... | class TypeCountAlphabet(Enumerator):
'''Used for giving block type counts and tree counts.
>>> TypeCountAlphabet(description='').showCode()
0:0 0101:xx,0101 1011:xxxxx,1011
0001:0001 1101:xxxxxx,1101 0111:xxx,0111
1001:xxxx,1001 0011:x,0011 1111:xxxxxxx,1111
... | 4 | 1 | 6 | 0 | 6 | 0 | 2 | 0.25 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 46 | 38 | 4 | 28 | 10 | 24 | 7 | 19 | 10 | 15 | 3 | 4 | 1 | 6 |
20,982 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.WindowSizeAlphabet | class WindowSizeAlphabet(Code):
"""The alphabet used for window size in the stream header.
>>> WindowSizeAlphabet()[10].explanation()
'windowsize=(1<<10)-16=1008'
"""
decodeTable = {33: 10, 97: 14, 3: 18, 11: 22, 49: 11, 113: 15, 5: 19, 13: 23, 65: 12, 0: 16, 7: 20, 15: 24, 81: 13, 1: 17, 9: 21, 17:... | class WindowSizeAlphabet(Code):
'''The alphabet used for window size in the stream header.
>>> WindowSizeAlphabet()[10].explanation()
'windowsize=(1<<10)-16=1008'
'''
def __init__(self, name=None):
pass
def value(self, index):
pass
def explanation(self, index):
pas... | 4 | 1 | 3 | 0 | 3 | 0 | 1 | 0.29 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 36 | 26 | 4 | 17 | 6 | 13 | 5 | 11 | 6 | 7 | 2 | 2 | 1 | 4 |
20,983 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.WithExtra | class WithExtra(Code):
"""Extension for Code so that symbol may have extra bits associated.
If you supply an extraTable, you can use extraBits
You can define an extraTable,
which allows to call extraBits to get the number of extraBits.
Otherwise, you can supply extraBits yourself.
Routine readTu... | class WithExtra(Code):
'''Extension for Code so that symbol may have extra bits associated.
If you supply an extraTable, you can use extraBits
You can define an extraTable,
which allows to call extraBits to get the number of extraBits.
Otherwise, you can supply extraBits yourself.
Routine readTu... | 6 | 5 | 9 | 0 | 6 | 3 | 2 | 0.7 | 1 | 1 | 0 | 9 | 5 | 0 | 5 | 38 | 60 | 4 | 33 | 11 | 27 | 23 | 24 | 11 | 18 | 4 | 2 | 1 | 8 |
20,984 | google/brotli | google_brotli/research/brotlidump.py | brotlidump.WordList | class WordList:
"""Word list.
>>> WordList().word(7, 35555)
b'Program to '
"""
NDBITS = [0, 0, 0, 0, 10, 10, 11, 11, 10, 10, 10, 10, 10, 9, 9, 8, 7, 7, 8, 7, 7, 6, 6, 5, 5]
def __init__(self):
self.file = open(DICTIONARY_PATH, 'rb')
self.compileActions()
def word(self, size... | class WordList:
'''Word list.
>>> WordList().word(7, 35555)
b'Program to '
'''
def __init__(self):
pass
def word(self, size, dist):
'''Get word
'''
pass
def upperCase1(self, word):
pass
def compileActions(self):
'''Build the action tabl... | 6 | 4 | 13 | 0 | 8 | 5 | 2 | 0.44 | 0 | 2 | 0 | 0 | 5 | 2 | 5 | 5 | 108 | 6 | 71 | 24 | 64 | 31 | 41 | 24 | 34 | 4 | 0 | 3 | 8 |
20,985 | google/brotli | google_brotli/setup.py | setup.BuildExt | from distutils.command.build_ext import build_ext
import platform
from distutils import dep_util
from distutils import log
from distutils import errors
class BuildExt(build_ext):
def get_source_files(self):
filenames = build_ext.get_source_files(self)
for ext in self.extensions:
filena... |
class BuildExt(build_ext):
def get_source_files(self):
pass
def build_extension(self, ext):
pass | 3 | 0 | 37 | 4 | 30 | 3 | 6 | 0.1 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 50 | 76 | 10 | 60 | 18 | 57 | 6 | 38 | 16 | 35 | 10 | 2 | 2 | 12 |
20,986 | dagster-io/dagster | dagster-io_dagster/examples/docs_snippets/docs_snippets/docs_beta/guides/automation/asset-sensor-with-config.py | asset-sensor-with-config.MyConfig | import dagster as dg
class MyConfig(dg.Config):
param1: str |
class MyConfig(dg.Config):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
20,987 | dagster-io/dagster | dagster-io_dagster/examples/docs_snippets/docs_snippets/guides/dagster/asset_versioning_and_caching/observable_source_asset_path_with_io_managers.py | asset_versioning_and_caching.observable_source_asset_path_with_io_managers.ExternalFileInputManager | import dagster as dg
from typing import Any
class ExternalFileInputManager(dg.IOManager):
def load_input(self, context: 'dg.InputContext') -> object:
with open(FILE_PATH) as ff:
return int(ff.read())
def handle_output(self, context: 'dg.OutputContext', obj: Any) -> None:
raise Exc... |
class ExternalFileInputManager(dg.IOManager):
def load_input(self, context: 'dg.InputContext') -> object:
pass
def handle_output(self, context: 'dg.OutputContext', obj: Any) -> None:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 4 | 0 | 0 | 2 | 0 | 2 | 2 | 7 | 1 | 6 | 4 | 3 | 0 | 6 | 3 | 3 | 1 | 1 | 1 | 2 |
20,988 | dagster-io/dagster | dagster-io_dagster/examples/docs_snippets/docs_snippets/guides/dagster/asset_versioning_and_caching/observable_source_asset_path_with_io_managers.py | asset_versioning_and_caching.observable_source_asset_path_with_io_managers.NumberTextFileIOManager | import dagster as dg
import os
from dagster._utils import mkdir_p
class NumberTextFileIOManager(dg.IOManager):
def __init__(self, root_dir: str):
self.root_dir = root_dir
@staticmethod
def with_directory(root_dir: str):
mkdir_p(root_dir)
return NumberTextFileIOManager(root_dir=roo... |
class NumberTextFileIOManager(dg.IOManager):
def __init__(self, root_dir: str):
pass
@staticmethod
def with_directory(root_dir: str):
pass
def load_input(self, context: 'dg.InputContext') -> int:
pass
def handle_output(self, context: 'dg.OutputContext', obj: int) -> None:... | 6 | 0 | 7 | 1 | 4 | 2 | 1 | 0.42 | 1 | 2 | 0 | 0 | 3 | 1 | 4 | 4 | 34 | 7 | 19 | 13 | 13 | 8 | 18 | 10 | 13 | 2 | 1 | 1 | 5 |
20,989 | dagster-io/dagster | dagster-io_dagster/examples/assets_dbt_python/assets_dbt_python/assets/dbt.py | assets_dbt_python.assets.dbt.CustomDagsterDbtTranslator | from dagster_dbt import DagsterDbtTranslator, DbtCliResource, dbt_assets, get_asset_key_for_model
from collections.abc import Mapping
from dagster import AssetExecutionContext, AssetKey
from typing import Any
class CustomDagsterDbtTranslator(DagsterDbtTranslator):
def get_asset_key(self, dbt_resource_props: Mappi... |
class CustomDagsterDbtTranslator(DagsterDbtTranslator):
def get_asset_key(self, dbt_resource_props: Mapping[str, Any]) -> AssetKey:
pass | 2 | 0 | 9 | 2 | 7 | 0 | 3 | 0 | 1 | 4 | 0 | 0 | 1 | 0 | 1 | 15 | 10 | 2 | 8 | 3 | 6 | 0 | 8 | 3 | 6 | 3 | 1 | 1 | 3 |
20,990 | dagster-io/dagster | dagster-io_dagster/examples/assets_modern_data_stack/assets_modern_data_stack/db_io_manager.py | assets_modern_data_stack.db_io_manager.DbIOManager | from dagster import ConfigurableIOManager
import pandas as pd
class DbIOManager(ConfigurableIOManager):
"""Sample IOManager to handle loading the contents of tables as pandas DataFrames.
Does not handle cases where data is written to different schemas for different outputs, and
uses the name of the asset ... |
class DbIOManager(ConfigurableIOManager):
'''Sample IOManager to handle loading the contents of tables as pandas DataFrames.
Does not handle cases where data is written to different schemas for different outputs, and
uses the name of the asset key as the table name.
'''
def handle_output(self, con... | 3 | 2 | 7 | 0 | 5 | 2 | 2 | 0.58 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 2 | 23 | 4 | 12 | 5 | 9 | 7 | 10 | 4 | 7 | 3 | 1 | 1 | 4 |
20,991 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_pyspark/assets_pandas_pyspark/local_filesystem_io_manager.py | assets_pandas_pyspark.local_filesystem_io_manager.LocalFileSystemIOManager | from dagster import AssetKey, ConfigurableIOManager
from pandas import DataFrame
import os
import pandas as pd
class LocalFileSystemIOManager(ConfigurableIOManager):
"""Translates between Pandas DataFrames and CSVs on the local filesystem."""
def _get_fs_path(self, asset_key: AssetKey) -> str:
rpath =... |
class LocalFileSystemIOManager(ConfigurableIOManager):
'''Translates between Pandas DataFrames and CSVs on the local filesystem.'''
def _get_fs_path(self, asset_key: AssetKey) -> str:
pass
def handle_output(self, context, obj: DataFrame):
'''This saves the dataframe as a CSV.'''
p... | 4 | 3 | 4 | 0 | 3 | 1 | 1 | 0.3 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 3 | 16 | 3 | 10 | 7 | 6 | 3 | 10 | 7 | 6 | 1 | 1 | 0 | 3 |
20,992 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_pyspark/assets_pandas_pyspark/local_spark_filesystem_io_manager.py | assets_pandas_pyspark.local_spark_filesystem_io_manager.LocalFileSystemIOManager | import os
from pandas import DataFrame as PandasDF
from typing import Union
import glob
import pandas as pd
from dagster import AssetKey, ConfigurableIOManager, _check as check
from pyspark.sql import DataFrame as SparkDF, SparkSession
class LocalFileSystemIOManager(ConfigurableIOManager):
def _get_fs_path(self, ... |
class LocalFileSystemIOManager(ConfigurableIOManager):
def _get_fs_path(self, asset_key: AssetKey) -> str:
pass
def handle_output(self, context, obj: Union[PandasDF, SparkDF]):
'''This saves the DataFrame as a CSV using the layout written and expected by Spark/Hadoop.
E.g. if the give... | 4 | 2 | 17 | 2 | 10 | 6 | 2 | 0.55 | 1 | 3 | 0 | 0 | 3 | 0 | 3 | 3 | 54 | 7 | 31 | 8 | 27 | 17 | 20 | 8 | 16 | 3 | 1 | 1 | 7 |
20,993 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_type_metadata/assets_pandas_type_metadata/assets/bollinger_analysis.py | assets_pandas_type_metadata.assets.bollinger_analysis.BollingerBandsConfig | from dagster import Config, asset
from pydantic import Field
class BollingerBandsConfig(Config):
rate: int = Field(default=30, description='Size of sliding window in days')
sigma: float = Field(default=2.0, description='Width of envelope in standard deviations') |
class BollingerBandsConfig(Config):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
20,994 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_type_metadata/assets_pandas_type_metadata/lib.py | assets_pandas_type_metadata.lib.AnomalousEvents | import pandas as pd
from pandera.typing import Series
import pandera as pa
class AnomalousEvents(pa.DataFrameModel):
"""Anomalous price events, defined by a day on which a stock's closing price strayed above or
below its Bollinger bands.
"""
date: Series[pd.Timestamp] = pa.Field(description='Date of pr... |
class AnomalousEvents(pa.DataFrameModel):
'''Anomalous price events, defined by a day on which a stock's closing price strayed above or
below its Bollinger bands.
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.75 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 8 | 1 | 4 | 4 | 3 | 3 | 4 | 4 | 3 | 0 | 0 | 0 | 0 |
20,995 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_type_metadata/assets_pandas_type_metadata/lib.py | assets_pandas_type_metadata.lib.BollingerBands | from pandera.typing import Series
import pandera as pa
import pandas as pd
class BollingerBands(pa.DataFrameModel):
"""Bollinger bands for a set of stock prices."""
name: Series[str] = pa.Field(description='Ticker symbol of stock')
date: Series[pd.Timestamp] = pa.Field(description='Date of prices')
upp... |
class BollingerBands(pa.DataFrameModel):
'''Bollinger bands for a set of stock prices.'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 1 | 5 | 5 | 4 | 1 | 5 | 5 | 4 | 0 | 0 | 0 | 0 |
20,996 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_type_metadata/assets_pandas_type_metadata/lib.py | assets_pandas_type_metadata.lib.StockPrices | from pandera.typing import Series
import pandera as pa
import pandas as pd
class StockPrices(pa.DataFrameModel):
"""Open/high/low/close prices for a set of stocks by day."""
name: Series[str] = pa.Field(description='Ticker symbol of stock')
date: Series[pd.Timestamp] = pa.Field(description='Date of prices'... |
class StockPrices(pa.DataFrameModel):
'''Open/high/low/close prices for a set of stocks by day.'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.13 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | 8 | 7 | 7 | 1 | 8 | 7 | 7 | 0 | 0 | 0 | 0 |
20,997 | dagster-io/dagster | dagster-io_dagster/examples/assets_pandas_type_metadata/assets_pandas_type_metadata/resources/csv_io_manager.py | assets_pandas_type_metadata.resources.csv_io_manager.LocalCsvIOManager | from pydantic import Field
from dagster._utils.cached_method import cached_method
from dagster._core.definitions.metadata import MetadataValue
import os
from dagster import AssetKey, ConfigurableIOManager, TableSchemaMetadataValue
import pandas as pd
from typing import Optional
class LocalCsvIOManager(ConfigurableIOMa... |
class LocalCsvIOManager(ConfigurableIOManager):
'''Translates between Pandas DataFrames and CSVs on the local filesystem.'''
@property
@cached_method
def resolved_base_dir(self) -> str:
pass
def _get_fs_path(self, asset_key: AssetKey) -> str:
pass
def handle_output(self, conte... | 9 | 3 | 9 | 0 | 8 | 1 | 2 | 0.08 | 1 | 3 | 1 | 0 | 6 | 0 | 6 | 6 | 65 | 9 | 53 | 20 | 44 | 4 | 35 | 17 | 28 | 3 | 1 | 1 | 10 |
20,998 | dagster-io/dagster | dagster-io_dagster/examples/experimental/assets_yaml_dsl/assets_yaml_dsl/domain_specific_dsl/stocks_dsl.py | assets_yaml_dsl.domain_specific_dsl.stocks_dsl.Forecast | from typing import Any, NamedTuple
class Forecast(NamedTuple):
days: int |
class Forecast(NamedTuple):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
20,999 | dagster-io/dagster | dagster-io_dagster/examples/experimental/assets_yaml_dsl/assets_yaml_dsl/domain_specific_dsl/stocks_dsl.py | assets_yaml_dsl.domain_specific_dsl.stocks_dsl.IndexStrategy | from typing import Any, NamedTuple
class IndexStrategy(NamedTuple):
type: str |
class IndexStrategy(NamedTuple):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.