Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
get_supported_language_variant
(lang_code, strict=False)
Returns the language-code that's listed in supported languages, possibly selecting a more generic variant. Raises LookupError if nothing found. If `strict` is False (the default), the function will look for an alternative country-specific variant when the currently checked is not found. lru_cache...
Returns the language-code that's listed in supported languages, possibly selecting a more generic variant. Raises LookupError if nothing found.
def get_supported_language_variant(lang_code, strict=False): """ Returns the language-code that's listed in supported languages, possibly selecting a more generic variant. Raises LookupError if nothing found. If `strict` is False (the default), the function will look for an alternative country-spec...
[ "def", "get_supported_language_variant", "(", "lang_code", ",", "strict", "=", "False", ")", ":", "if", "lang_code", ":", "# If 'fr-ca' is not supported, try special fallback or language-only 'fr'.", "possible_lang_codes", "=", "[", "lang_code", "]", "try", ":", "possible_l...
[ 448, 0 ]
[ 479, 32 ]
python
en
['en', 'error', 'th']
False
get_language_from_path
(path, strict=False)
Returns the language-code if there is a valid language-code found in the `path`. If `strict` is False (the default), the function will look for an alternative country-specific variant when the currently checked is not found.
Returns the language-code if there is a valid language-code found in the `path`.
def get_language_from_path(path, strict=False): """ Returns the language-code if there is a valid language-code found in the `path`. If `strict` is False (the default), the function will look for an alternative country-specific variant when the currently checked is not found. """ regex_matc...
[ "def", "get_language_from_path", "(", "path", ",", "strict", "=", "False", ")", ":", "regex_match", "=", "language_code_prefix_re", ".", "match", "(", "path", ")", "if", "not", "regex_match", ":", "return", "None", "lang_code", "=", "regex_match", ".", "group"...
[ 482, 0 ]
[ 497, 19 ]
python
en
['en', 'error', 'th']
False
get_language_from_request
(request, check_path=False)
Analyzes the request to find what language the user wants the system to show. Only languages listed in settings.LANGUAGES are taken into account. If the user requests a sublanguage where we have a main language, we send out the main language. If check_path is True, the URL path prefix will be chec...
Analyzes the request to find what language the user wants the system to show. Only languages listed in settings.LANGUAGES are taken into account. If the user requests a sublanguage where we have a main language, we send out the main language.
def get_language_from_request(request, check_path=False): """ Analyzes the request to find what language the user wants the system to show. Only languages listed in settings.LANGUAGES are taken into account. If the user requests a sublanguage where we have a main language, we send out the main langu...
[ "def", "get_language_from_request", "(", "request", ",", "check_path", "=", "False", ")", ":", "if", "check_path", ":", "lang_code", "=", "get_language_from_path", "(", "request", ".", "path_info", ")", "if", "lang_code", "is", "not", "None", ":", "return", "l...
[ 500, 0 ]
[ 545, 37 ]
python
en
['en', 'error', 'th']
False
parse_accept_lang_header
(lang_string)
Parses the lang_string, which is the body of an HTTP Accept-Language header, and returns a list of (lang, q-value), ordered by 'q' values. Any format errors in lang_string results in an empty list being returned.
Parses the lang_string, which is the body of an HTTP Accept-Language header, and returns a list of (lang, q-value), ordered by 'q' values.
def parse_accept_lang_header(lang_string): """ Parses the lang_string, which is the body of an HTTP Accept-Language header, and returns a list of (lang, q-value), ordered by 'q' values. Any format errors in lang_string results in an empty list being returned. """ result = [] pieces = accept...
[ "def", "parse_accept_lang_header", "(", "lang_string", ")", ":", "result", "=", "[", "]", "pieces", "=", "accept_language_re", ".", "split", "(", "lang_string", ".", "lower", "(", ")", ")", "if", "pieces", "[", "-", "1", "]", ":", "return", "[", "]", "...
[ 548, 0 ]
[ 569, 17 ]
python
en
['en', 'error', 'th']
False
DjangoTranslation.__init__
(self, language, domain=None, localedirs=None)
Create a GNUTranslations() using many locale directories
Create a GNUTranslations() using many locale directories
def __init__(self, language, domain=None, localedirs=None): """Create a GNUTranslations() using many locale directories""" gettext_module.GNUTranslations.__init__(self) if domain is not None: self.domain = domain self.set_output_charset('utf-8') # For Python 2 gettext() (#25...
[ "def", "__init__", "(", "self", ",", "language", ",", "domain", "=", "None", ",", "localedirs", "=", "None", ")", ":", "gettext_module", ".", "GNUTranslations", ".", "__init__", "(", "self", ")", "if", "domain", "is", "not", "None", ":", "self", ".", "...
[ 101, 4 ]
[ 137, 30 ]
python
en
['en', 'en', 'en']
True
DjangoTranslation._new_gnu_trans
(self, localedir, use_null_fallback=True)
Returns a mergeable gettext.GNUTranslations instance. A convenience wrapper. By default gettext uses 'fallback=False'. Using param `use_null_fallback` to avoid confusion with any other references to 'fallback'.
Returns a mergeable gettext.GNUTranslations instance.
def _new_gnu_trans(self, localedir, use_null_fallback=True): """ Returns a mergeable gettext.GNUTranslations instance. A convenience wrapper. By default gettext uses 'fallback=False'. Using param `use_null_fallback` to avoid confusion with any other references to 'fallback'. ...
[ "def", "_new_gnu_trans", "(", "self", ",", "localedir", ",", "use_null_fallback", "=", "True", ")", ":", "return", "gettext_module", ".", "translation", "(", "domain", "=", "self", ".", "domain", ",", "localedir", "=", "localedir", ",", "languages", "=", "["...
[ 142, 4 ]
[ 155, 39 ]
python
en
['en', 'error', 'th']
False
DjangoTranslation._init_translation_catalog
(self)
Creates a base catalog using global django translations.
Creates a base catalog using global django translations.
def _init_translation_catalog(self): """Creates a base catalog using global django translations.""" settingsfile = upath(sys.modules[settings.__module__].__file__) localedir = os.path.join(os.path.dirname(settingsfile), 'locale') translation = self._new_gnu_trans(localedir) self....
[ "def", "_init_translation_catalog", "(", "self", ")", ":", "settingsfile", "=", "upath", "(", "sys", ".", "modules", "[", "settings", ".", "__module__", "]", ".", "__file__", ")", "localedir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ...
[ 157, 4 ]
[ 162, 31 ]
python
en
['en', 'zu', 'en']
True
DjangoTranslation._add_installed_apps_translations
(self)
Merges translations from each installed app.
Merges translations from each installed app.
def _add_installed_apps_translations(self): """Merges translations from each installed app.""" try: app_configs = reversed(list(apps.get_app_configs())) except AppRegistryNotReady: raise AppRegistryNotReady( "The translation infrastructure cannot be initia...
[ "def", "_add_installed_apps_translations", "(", "self", ")", ":", "try", ":", "app_configs", "=", "reversed", "(", "list", "(", "apps", ".", "get_app_configs", "(", ")", ")", ")", "except", "AppRegistryNotReady", ":", "raise", "AppRegistryNotReady", "(", "\"The ...
[ 164, 4 ]
[ 177, 39 ]
python
en
['en', 'en', 'en']
True
DjangoTranslation._add_local_translations
(self)
Merges translations defined in LOCALE_PATHS.
Merges translations defined in LOCALE_PATHS.
def _add_local_translations(self): """Merges translations defined in LOCALE_PATHS.""" for localedir in reversed(settings.LOCALE_PATHS): translation = self._new_gnu_trans(localedir) self.merge(translation)
[ "def", "_add_local_translations", "(", "self", ")", ":", "for", "localedir", "in", "reversed", "(", "settings", ".", "LOCALE_PATHS", ")", ":", "translation", "=", "self", ".", "_new_gnu_trans", "(", "localedir", ")", "self", ".", "merge", "(", "translation", ...
[ 179, 4 ]
[ 183, 35 ]
python
en
['en', 'en', 'en']
True
DjangoTranslation._add_fallback
(self, localedirs=None)
Sets the GNUTranslations() fallback with the default language.
Sets the GNUTranslations() fallback with the default language.
def _add_fallback(self, localedirs=None): """Sets the GNUTranslations() fallback with the default language.""" # Don't set a fallback for the default language or any English variant # (as it's empty, so it'll ALWAYS fall back to the default language) if self.__language == settings.LANGUA...
[ "def", "_add_fallback", "(", "self", ",", "localedirs", "=", "None", ")", ":", "# Don't set a fallback for the default language or any English variant", "# (as it's empty, so it'll ALWAYS fall back to the default language)", "if", "self", ".", "__language", "==", "settings", ".",...
[ 185, 4 ]
[ 198, 46 ]
python
en
['en', 'en', 'en']
True
DjangoTranslation.merge
(self, other)
Merge another translation into this catalog.
Merge another translation into this catalog.
def merge(self, other): """Merge another translation into this catalog.""" if not getattr(other, '_catalog', None): return # NullTranslations() has no _catalog if self._catalog is None: # Take plural and _info from first catalog found (generally Django's). se...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "if", "not", "getattr", "(", "other", ",", "'_catalog'", ",", "None", ")", ":", "return", "# NullTranslations() has no _catalog", "if", "self", ".", "_catalog", "is", "None", ":", "# Take plural and _info fr...
[ 200, 4 ]
[ 210, 48 ]
python
en
['en', 'en', 'en']
True
DjangoTranslation.language
(self)
Returns the translation language.
Returns the translation language.
def language(self): """Returns the translation language.""" return self.__language
[ "def", "language", "(", "self", ")", ":", "return", "self", ".", "__language" ]
[ 212, 4 ]
[ 214, 30 ]
python
en
['en', 'zu', 'en']
True
DjangoTranslation.to_language
(self)
Returns the translation language name.
Returns the translation language name.
def to_language(self): """Returns the translation language name.""" return self.__to_language
[ "def", "to_language", "(", "self", ")", ":", "return", "self", ".", "__to_language" ]
[ 216, 4 ]
[ 218, 33 ]
python
en
['en', 'zu', 'en']
True
get_bza_report_info
(engine, log)
:return: [(url, test), (url, test), ...]
:return: [(url, test), (url, test), ...]
def get_bza_report_info(engine, log): """ :return: [(url, test), (url, test), ...] """ result = [] if isinstance(engine.provisioning, CloudProvisioning): cloud_prov = engine.provisioning test_name = cloud_prov.settings.get("test") report_url = cloud_prov.results_url r...
[ "def", "get_bza_report_info", "(", "engine", ",", "log", ")", ":", "result", "=", "[", "]", "if", "isinstance", "(", "engine", ".", "provisioning", ",", "CloudProvisioning", ")", ":", "cloud_prov", "=", "engine", ".", "provisioning", "test_name", "=", "cloud...
[ 485, 0 ]
[ 505, 17 ]
python
en
['en', 'error', 'th']
False
FinalStatus.aggregated_second
(self, data)
Just store the latest info :type data: bzt.modules.aggregator.DataPoint
Just store the latest info
def aggregated_second(self, data): """ Just store the latest info :type data: bzt.modules.aggregator.DataPoint """ self.first_ts = min(self.first_ts, data[DataPoint.TIMESTAMP]) self.last_ts = max(self.last_ts, data[DataPoint.TIMESTAMP]) self.last_sec = data
[ "def", "aggregated_second", "(", "self", ",", "data", ")", ":", "self", ".", "first_ts", "=", "min", "(", "self", ".", "first_ts", ",", "data", "[", "DataPoint", ".", "TIMESTAMP", "]", ")", "self", ".", "last_ts", "=", "max", "(", "self", ".", "last_...
[ 59, 4 ]
[ 67, 28 ]
python
en
['en', 'error', 'th']
False
FinalStatus.aggregated_results
(self, results, cumulative_results)
Just store the latest info :type cumulative_results: bzt.modules.functional.ResultsTree :type results: bzt.modules.functional.ResultsTree
Just store the latest info
def aggregated_results(self, results, cumulative_results): """ Just store the latest info :type cumulative_results: bzt.modules.functional.ResultsTree :type results: bzt.modules.functional.ResultsTree """ self.cumulative_results = cumulative_results
[ "def", "aggregated_results", "(", "self", ",", "results", ",", "cumulative_results", ")", ":", "self", ".", "cumulative_results", "=", "cumulative_results" ]
[ 69, 4 ]
[ 76, 52 ]
python
en
['en', 'error', 'th']
False
FinalStatus.post_process
(self)
Log basic stats
Log basic stats
def post_process(self): """ Log basic stats """ super(FinalStatus, self).post_process() if self.parameters.get("test-duration", True): self.__report_duration() if self.last_sec: if '' in self.last_sec[DataPoint.CUMULATIVE]: summar...
[ "def", "post_process", "(", "self", ")", ":", "super", "(", "FinalStatus", ",", "self", ")", ".", "post_process", "(", ")", "if", "self", ".", "parameters", ".", "get", "(", "\"test-duration\"", ",", "True", ")", ":", "self", ".", "__report_duration", "(...
[ 81, 4 ]
[ 117, 41 ]
python
en
['en', 'error', 'th']
False
FinalStatus.__report_samples_count
(self, summary_kpi_set)
reports samples count
reports samples count
def __report_samples_count(self, summary_kpi_set): """ reports samples count """ if summary_kpi_set[KPISet.SAMPLE_COUNT]: err_rate = 100 * summary_kpi_set[KPISet.FAILURES] / float(summary_kpi_set[KPISet.SAMPLE_COUNT]) self.log.info("Samples count: %s, %.2f%% failu...
[ "def", "__report_samples_count", "(", "self", ",", "summary_kpi_set", ")", ":", "if", "summary_kpi_set", "[", "KPISet", ".", "SAMPLE_COUNT", "]", ":", "err_rate", "=", "100", "*", "summary_kpi_set", "[", "KPISet", ".", "FAILURES", "]", "/", "float", "(", "su...
[ 151, 4 ]
[ 157, 111 ]
python
en
['en', 'error', 'th']
False
FinalStatus.__report_percentiles
(self, summary_kpi_set)
reports percentiles
reports percentiles
def __report_percentiles(self, summary_kpi_set): """ reports percentiles """ fmt = "Average times: total %.3f, latency %.3f, connect %.3f" self.log.info(fmt, summary_kpi_set[KPISet.AVG_RESP_TIME], summary_kpi_set[KPISet.AVG_LATENCY], summary_kpi_set[KPISet.A...
[ "def", "__report_percentiles", "(", "self", ",", "summary_kpi_set", ")", ":", "fmt", "=", "\"Average times: total %.3f, latency %.3f, connect %.3f\"", "self", ".", "log", ".", "info", "(", "fmt", ",", "summary_kpi_set", "[", "KPISet", ".", "AVG_RESP_TIME", "]", ",",...
[ 159, 4 ]
[ 173, 54 ]
python
en
['en', 'error', 'th']
False
FinalStatus.__report_failed_labels
(self, cumulative)
reports failed labels
reports failed labels
def __report_failed_labels(self, cumulative): """ reports failed labels """ report_template = "%d failed samples: %s" sorted_labels = sorted(cumulative.keys()) for sample_label in sorted_labels: if sample_label != "": failed_samples_count = cum...
[ "def", "__report_failed_labels", "(", "self", ",", "cumulative", ")", ":", "report_template", "=", "\"%d failed samples: %s\"", "sorted_labels", "=", "sorted", "(", "cumulative", ".", "keys", "(", ")", ")", "for", "sample_label", "in", "sorted_labels", ":", "if", ...
[ 175, 4 ]
[ 185, 86 ]
python
en
['en', 'error', 'th']
False
FinalStatus.__report_duration
(self)
asks executors start_time and end_time, provides time delta
asks executors start_time and end_time, provides time delta
def __report_duration(self): """ asks executors start_time and end_time, provides time delta """ date_start = datetime.fromtimestamp(int(self.start_time)) date_end = datetime.fromtimestamp(int(self.end_time)) self.log.info("Test duration: %s", date_end - date_start)
[ "def", "__report_duration", "(", "self", ")", ":", "date_start", "=", "datetime", ".", "fromtimestamp", "(", "int", "(", "self", ".", "start_time", ")", ")", "date_end", "=", "datetime", ".", "fromtimestamp", "(", "int", "(", "self", ".", "end_time", ")", ...
[ 218, 4 ]
[ 224, 65 ]
python
en
['en', 'error', 'th']
False
JUnitXMLReporter.aggregated_results
(self, _, cumulative_results)
:type cumulative_results: bzt.modules.functional.ResultsTree
:type cumulative_results: bzt.modules.functional.ResultsTree
def aggregated_results(self, _, cumulative_results): """ :type cumulative_results: bzt.modules.functional.ResultsTree """ self.cumulative_results = cumulative_results
[ "def", "aggregated_results", "(", "self", ",", "_", ",", "cumulative_results", ")", ":", "self", ".", "cumulative_results", "=", "cumulative_results" ]
[ 350, 4 ]
[ 354, 52 ]
python
en
['en', 'error', 'th']
False
JUnitXMLReporter.post_process
(self)
Get report data, generate xml report.
Get report data, generate xml report.
def post_process(self): """ Get report data, generate xml report. """ filename = self.parameters.get("filename", None) if not filename: filename = self.engine.create_artifact(XUnitFileWriter.REPORT_FILE_NAME, XUnitFileWriter.REPORT_FILE_EXT) self.parameters["f...
[ "def", "post_process", "(", "self", ")", ":", "filename", "=", "self", ".", "parameters", ".", "get", "(", "\"filename\"", ",", "None", ")", "if", "not", "filename", ":", "filename", "=", "self", ".", "engine", ".", "create_artifact", "(", "XUnitFileWriter...
[ 356, 4 ]
[ 386, 40 ]
python
en
['en', 'error', 'th']
False
JUnitXMLReporter.process_sample_labels
(self, xunit)
:type xunit: XUnitFileWriter
:type xunit: XUnitFileWriter
def process_sample_labels(self, xunit): """ :type xunit: XUnitFileWriter """ xunit.report_test_suite('sample_labels') labels = self.last_second[DataPoint.CUMULATIVE] for key in sorted(labels.keys()): if key == "": # skip total label continue ...
[ "def", "process_sample_labels", "(", "self", ",", "xunit", ")", ":", "xunit", ".", "report_test_suite", "(", "'sample_labels'", ")", "labels", "=", "self", ".", "last_second", "[", "DataPoint", ".", "CUMULATIVE", "]", "for", "key", "in", "sorted", "(", "labe...
[ 388, 4 ]
[ 412, 64 ]
python
en
['en', 'error', 'th']
False
JUnitXMLReporter.process_pass_fail
(self, xunit)
:type xunit: XUnitFileWriter
:type xunit: XUnitFileWriter
def process_pass_fail(self, xunit): """ :type xunit: XUnitFileWriter """ xunit.report_test_suite('bzt_pass_fail') mods = self.engine.reporters + self.engine.services # TODO: remove it after passfail is only reporter pass_fail_objects = [_x for _x in mods if isinstance(_x...
[ "def", "process_pass_fail", "(", "self", ",", "xunit", ")", ":", "xunit", ".", "report_test_suite", "(", "'bzt_pass_fail'", ")", "mods", "=", "self", ".", "engine", ".", "reporters", "+", "self", ".", "engine", ".", "services", "# TODO: remove it after passfail ...
[ 414, 4 ]
[ 446, 70 ]
python
en
['en', 'error', 'th']
False
XUnitFileWriter.__init__
(self, engine)
:type engine: bzt.engine.Engine
:type engine: bzt.engine.Engine
def __init__(self, engine): """ :type engine: bzt.engine.Engine """ super(XUnitFileWriter, self).__init__() self.engine = engine self.log = engine.log.getChild(self.__class__.__name__) self.test_suites = OrderedDict() bza_report_info = get_bza_report_info(...
[ "def", "__init__", "(", "self", ",", "engine", ")", ":", "super", "(", "XUnitFileWriter", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "engine", "=", "engine", "self", ".", "log", "=", "engine", ".", "log", ".", "getChild", "(", "self", ...
[ 512, 4 ]
[ 522, 107 ]
python
en
['en', 'error', 'th']
False
XUnitFileWriter.save_report
(self, fname)
:type fname: str
:type fname: str
def save_report(self, fname): """ :type fname: str """ try: if os.path.exists(fname): self.log.warning("File %s already exists, it will be overwritten", fname) else: dirname = os.path.dirname(fname) if dirname and no...
[ "def", "save_report", "(", "self", ",", "fname", ")", ":", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "self", ".", "log", ".", "warning", "(", "\"File %s already exists, it will be overwritten\"", ",", "fname", ")", "else",...
[ 524, 4 ]
[ 545, 74 ]
python
en
['en', 'error', 'th']
False
XUnitFileWriter.report_test_suite
(self, suite_name)
:type suite_name: str :type children: list[lxml.etree.Element]
:type suite_name: str :type children: list[lxml.etree.Element]
def report_test_suite(self, suite_name): """ :type suite_name: str :type children: list[lxml.etree.Element] """ self.add_test_suite(suite_name, attributes={"name": suite_name, "package_name": "bzt"})
[ "def", "report_test_suite", "(", "self", ",", "suite_name", ")", ":", "self", ".", "add_test_suite", "(", "suite_name", ",", "attributes", "=", "{", "\"name\"", ":", "suite_name", ",", "\"package_name\"", ":", "\"bzt\"", "}", ")" ]
[ 547, 4 ]
[ 552, 95 ]
python
en
['en', 'error', 'th']
False
XUnitFileWriter.report_test_case
(self, suite_name, case_name, children=None)
:type suite_name: str :type case_name: str :type children: list[lxml.etree.Element]
:type suite_name: str :type case_name: str :type children: list[lxml.etree.Element]
def report_test_case(self, suite_name, case_name, children=None): """ :type suite_name: str :type case_name: str :type children: list[lxml.etree.Element] """ children = children or [] if self.report_urls: system_out = etree.Element("system-out") ...
[ "def", "report_test_case", "(", "self", ",", "suite_name", ",", "case_name", ",", "children", "=", "None", ")", ":", "children", "=", "children", "or", "[", "]", "if", "self", ".", "report_urls", ":", "system_out", "=", "etree", ".", "Element", "(", "\"s...
[ 554, 4 ]
[ 565, 119 ]
python
en
['en', 'error', 'th']
False
_copy_file_contents
(src, dst, buffer_size=16*1024)
Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.
Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made to handle anything apart from regular files.
def _copy_file_contents(src, dst, buffer_size=16*1024): """Copy the file 'src' to 'dst'; both must be filenames. Any error opening either file, reading from 'src', or writing to 'dst', raises DistutilsFileError. Data is read/written in chunks of 'buffer_size' bytes (default 16k). No attempt is made t...
[ "def", "_copy_file_contents", "(", "src", ",", "dst", ",", "buffer_size", "=", "16", "*", "1024", ")", ":", "# Stolen from shutil module in the standard library, but with", "# custom error-handling added.", "fsrc", "=", "None", "fdst", "=", "None", "try", ":", "try", ...
[ 15, 0 ]
[ 64, 24 ]
python
en
['en', 'en', 'en']
True
copy_file
(src, dst, preserve_mode=1, preserve_times=1, update=0, link=None, verbose=1, dry_run=0)
Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered.) If 'preserve_mode' is true (the default), the file's mode (type and permission bits, or whatever is analogous on...
Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered.) If 'preserve_mode' is true (the default), the file's mode (type and permission bits, or whatever is analogous on...
def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0, link=None, verbose=1, dry_run=0): """Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is copied there with the same name; otherwise, it must be a filename. (If the file exists, it will be ruthlessly clobbered...
[ "def", "copy_file", "(", "src", ",", "dst", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "update", "=", "0", ",", "link", "=", "None", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "# XXX if the destination file...
[ 66, 0 ]
[ 161, 19 ]
python
en
['en', 'en', 'en']
True
move_file
(src, dst, verbose=1, dry_run=0)
Move a file 'src' to 'dst'. If 'dst' is a directory, the file will be moved into it with the same name; otherwise, 'src' is just renamed to 'dst'. Return the new full name of the file. Handles cross-device moves on Unix using 'copy_file()'. What about other systems???
Move a file 'src' to 'dst'. If 'dst' is a directory, the file will be moved into it with the same name; otherwise, 'src' is just renamed to 'dst'. Return the new full name of the file.
def move_file (src, dst, verbose=1, dry_run=0): """Move a file 'src' to 'dst'. If 'dst' is a directory, the file will be moved into it with the same name; otherwise, 'src' is just renamed to 'dst'. Return the new full name of the file. Handles cross-device moves on Unix...
[ "def", "move_file", "(", "src", ",", "dst", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "from", "os", ".", "path", "import", "exists", ",", "isfile", ",", "isdir", ",", "basename", ",", "dirname", "import", "errno", "if", "verbose",...
[ 165, 0 ]
[ 225, 14 ]
python
en
['en', 'en', 'en']
True
write_file
(filename, contents)
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it.
def write_file (filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ f = open(filename, "w") try: for line in contents: f.write(line + "\n") finally: f.close()
[ "def", "write_file", "(", "filename", ",", "contents", ")", ":", "f", "=", "open", "(", "filename", ",", "\"w\"", ")", "try", ":", "for", "line", "in", "contents", ":", "f", ".", "write", "(", "line", "+", "\"\\n\"", ")", "finally", ":", "f", ".", ...
[ 228, 0 ]
[ 237, 17 ]
python
en
['en', 'en', 'en']
True
DatabaseIntrospection.get_table_list
(self, cursor)
Returns a list of table and view names in the current database.
Returns a list of table and view names in the current database.
def get_table_list(self, cursor): """ Returns a list of table and view names in the current database. """ cursor.execute("SHOW FULL TABLES") return [TableInfo(row[0], {'BASE TABLE': 't', 'VIEW': 'v'}.get(row[1])) for row in cursor.fetchall()]
[ "def", "get_table_list", "(", "self", ",", "cursor", ")", ":", "cursor", ".", "execute", "(", "\"SHOW FULL TABLES\"", ")", "return", "[", "TableInfo", "(", "row", "[", "0", "]", ",", "{", "'BASE TABLE'", ":", "'t'", ",", "'VIEW'", ":", "'v'", "}", ".",...
[ 51, 4 ]
[ 57, 45 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_table_description
(self, cursor, table_name)
Returns a description of the table, with the DB-API cursor.description interface."
Returns a description of the table, with the DB-API cursor.description interface."
def get_table_description(self, cursor, table_name): """ Returns a description of the table, with the DB-API cursor.description interface." """ # information_schema database gives more accurate results for some figures: # - varchar length returned by cursor.description is an inte...
[ "def", "get_table_description", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "# information_schema database gives more accurate results for some figures:", "# - varchar length returned by cursor.description is an internal length,", "# not visible length (#5725)", "# - precisi...
[ 59, 4 ]
[ 97, 21 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_relations
(self, cursor, table_name)
Returns a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
Returns a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table.
def get_relations(self, cursor, table_name): """ Returns a dictionary of {field_name: (field_name_other_table, other_table)} representing all relationships to the given table. """ constraints = self.get_key_columns(cursor, table_name) relations = {} for my_fieldna...
[ "def", "get_relations", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "self", ".", "get_key_columns", "(", "cursor", ",", "table_name", ")", "relations", "=", "{", "}", "for", "my_fieldname", ",", "other_table", ",", "other_fie...
[ 99, 4 ]
[ 108, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_key_columns
(self, cursor, table_name)
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
Returns a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table.
def get_key_columns(self, cursor, table_name): """ Returns a list of (column_name, referenced_table_name, referenced_column_name) for all key columns in given table. """ key_columns = [] cursor.execute(""" SELECT column_name, referenced_table_name, referenced_...
[ "def", "get_key_columns", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "key_columns", "=", "[", "]", "cursor", ".", "execute", "(", "\"\"\"\n SELECT column_name, referenced_table_name, referenced_column_name\n FROM information_schema.key_column_u...
[ 110, 4 ]
[ 124, 26 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_storage_engine
(self, cursor, table_name)
Retrieves the storage engine for a given table. Returns the default storage engine if the table doesn't exist.
Retrieves the storage engine for a given table. Returns the default storage engine if the table doesn't exist.
def get_storage_engine(self, cursor, table_name): """ Retrieves the storage engine for a given table. Returns the default storage engine if the table doesn't exist. """ cursor.execute( "SELECT engine " "FROM information_schema.tables " "WHERE t...
[ "def", "get_storage_engine", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "cursor", ".", "execute", "(", "\"SELECT engine \"", "\"FROM information_schema.tables \"", "\"WHERE table_name = %s\"", ",", "[", "table_name", "]", ")", "result", "=", "cursor", ...
[ 153, 4 ]
[ 165, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseIntrospection.get_constraints
(self, cursor, table_name)
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns.
def get_constraints(self, cursor, table_name): """ Retrieves any constraints or keys (unique, pk, fk, check, index) across one or more columns. """ constraints = {} # Get the actual constraint names and columns name_query = """ SELECT kc.`constraint_name`, kc....
[ "def", "get_constraints", "(", "self", ",", "cursor", ",", "table_name", ")", ":", "constraints", "=", "{", "}", "# Get the actual constraint names and columns", "name_query", "=", "\"\"\"\n SELECT kc.`constraint_name`, kc.`column_name`,\n kc.`referenced_t...
[ 167, 4 ]
[ 225, 26 ]
python
en
['en', 'error', 'th']
False
clear_scheduled_invitation_emails
(email: str)
Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.
Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.
def clear_scheduled_invitation_emails(email: str) -> None: """Unlike most scheduled emails, invitation emails don't have an existing user object to key off of, so we filter by address here.""" items = ScheduledEmail.objects.filter( address__iexact=email, type=ScheduledEmail.INVITATION_REMINDER )...
[ "def", "clear_scheduled_invitation_emails", "(", "email", ":", "str", ")", "->", "None", ":", "items", "=", "ScheduledEmail", ".", "objects", ".", "filter", "(", "address__iexact", "=", "email", ",", "type", "=", "ScheduledEmail", ".", "INVITATION_REMINDER", ")"...
[ 382, 0 ]
[ 388, 18 ]
python
en
['en', 'en', 'en']
True
send_custom_email
(users: List[UserProfile], options: Dict[str, Any])
Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name") )
Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name") )
def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None: """ Can be used directly with from a management shell with send_custom_email(user_profile_list, dict( markdown_template_path="/path/to/markdown/file.md", subject="Email subject", from_name="Sender Name"...
[ "def", "send_custom_email", "(", "users", ":", "List", "[", "UserProfile", "]", ",", "options", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "with", "open", "(", "options", "[", "\"markdown_template_path\"", "]", ")", "as", "f", ":...
[ 456, 0 ]
[ 523, 17 ]
python
en
['en', 'error', 'th']
False
_subst_vars
(path, local_vars)
In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. If there is no corresponding value, leave the token unchanged.
In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`.
def _subst_vars(path, local_vars): """In the string `path`, replace tokens like {some.thing} with the corresponding value from the map `local_vars`. If there is no corresponding value, leave the token unchanged. """ def _replacer(matchobj): name = matchobj.group(1) if name in local_...
[ "def", "_subst_vars", "(", "path", ",", "local_vars", ")", ":", "def", "_replacer", "(", "matchobj", ")", ":", "name", "=", "matchobj", ".", "group", "(", "1", ")", "if", "name", "in", "local_vars", ":", "return", "local_vars", "[", "name", "]", "elif"...
[ 130, 0 ]
[ 143, 41 ]
python
en
['en', 'en', 'en']
True
_parse_makefile
(filename, vars=None)
Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.
Parse a Makefile-style file.
def _parse_makefile(filename, vars=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ # Regexes needed for parsing Makefile (and similar syntaxes...
[ "def", "_parse_makefile", "(", "filename", ",", "vars", "=", "None", ")", ":", "# Regexes needed for parsing Makefile (and similar syntaxes,", "# like old-style Setup files).", "_variable_rx", "=", "re", ".", "compile", "(", "r\"([a-zA-Z][a-zA-Z0-9_]+)\\s*=\\s*(.*)\"", ")", "...
[ 212, 0 ]
[ 327, 15 ]
python
en
['en', 'en', 'en']
True
get_makefile_filename
()
Return the path of the Makefile.
Return the path of the Makefile.
def get_makefile_filename(): """Return the path of the Makefile.""" if _PYTHON_BUILD: return os.path.join(_PROJECT_BASE, "Makefile") if hasattr(sys, 'abiflags'): config_dir_name = 'config-%s%s' % (_PY_VERSION_SHORT, sys.abiflags) else: config_dir_name = 'config' return os.pat...
[ "def", "get_makefile_filename", "(", ")", ":", "if", "_PYTHON_BUILD", ":", "return", "os", ".", "path", ".", "join", "(", "_PROJECT_BASE", ",", "\"Makefile\"", ")", "if", "hasattr", "(", "sys", ",", "'abiflags'", ")", ":", "config_dir_name", "=", "'config-%s...
[ 330, 0 ]
[ 338, 72 ]
python
en
['en', 'en', 'en']
True
_init_posix
(vars)
Initialize the module as appropriate for POSIX systems.
Initialize the module as appropriate for POSIX systems.
def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" # load the installed Makefile: makefile = get_makefile_filename() try: _parse_makefile(makefile, vars) except IOError as e: msg = "invalid Python installation: unable to open %s" % makefile i...
[ "def", "_init_posix", "(", "vars", ")", ":", "# load the installed Makefile:", "makefile", "=", "get_makefile_filename", "(", ")", "try", ":", "_parse_makefile", "(", "makefile", ",", "vars", ")", "except", "IOError", "as", "e", ":", "msg", "=", "\"invalid Pytho...
[ 341, 0 ]
[ 366, 44 ]
python
en
['en', 'en', 'en']
True
_init_non_posix
(vars)
Initialize the module as appropriate for NT
Initialize the module as appropriate for NT
def _init_non_posix(vars): """Initialize the module as appropriate for NT""" # set basic install directories vars['LIBDEST'] = get_path('stdlib') vars['BINLIBDEST'] = get_path('platstdlib') vars['INCLUDEPY'] = get_path('include') vars['SO'] = '.pyd' vars['EXE'] = '.exe' vars['VERSION'] =...
[ "def", "_init_non_posix", "(", "vars", ")", ":", "# set basic install directories", "vars", "[", "'LIBDEST'", "]", "=", "get_path", "(", "'stdlib'", ")", "vars", "[", "'BINLIBDEST'", "]", "=", "get_path", "(", "'platstdlib'", ")", "vars", "[", "'INCLUDEPY'", "...
[ 369, 0 ]
[ 378, 68 ]
python
en
['en', 'en', 'en']
True
parse_config_h
(fp, vars=None)
Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary.
Parse a config.h-style file.
def parse_config_h(fp, vars=None): """Parse a config.h-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ if vars is None: vars = {} define_rx = re.compile("#de...
[ "def", "parse_config_h", "(", "fp", ",", "vars", "=", "None", ")", ":", "if", "vars", "is", "None", ":", "vars", "=", "{", "}", "define_rx", "=", "re", ".", "compile", "(", "\"#define ([A-Z][A-Za-z0-9_]+) (.*)\\n\"", ")", "undef_rx", "=", "re", ".", "com...
[ 385, 0 ]
[ 413, 15 ]
python
en
['es', 'en', 'en']
True
get_config_h_filename
()
Return the path of pyconfig.h.
Return the path of pyconfig.h.
def get_config_h_filename(): """Return the path of pyconfig.h.""" if _PYTHON_BUILD: if os.name == "nt": inc_dir = os.path.join(_PROJECT_BASE, "PC") else: inc_dir = _PROJECT_BASE else: inc_dir = get_path('platinclude') return os.path.join(inc_dir, 'pyconfig...
[ "def", "get_config_h_filename", "(", ")", ":", "if", "_PYTHON_BUILD", ":", "if", "os", ".", "name", "==", "\"nt\"", ":", "inc_dir", "=", "os", ".", "path", ".", "join", "(", "_PROJECT_BASE", ",", "\"PC\"", ")", "else", ":", "inc_dir", "=", "_PROJECT_BASE...
[ 416, 0 ]
[ 425, 46 ]
python
en
['en', 'en', 'en']
True
get_scheme_names
()
Return a tuple containing the schemes names.
Return a tuple containing the schemes names.
def get_scheme_names(): """Return a tuple containing the schemes names.""" return tuple(sorted(_SCHEMES.sections()))
[ "def", "get_scheme_names", "(", ")", ":", "return", "tuple", "(", "sorted", "(", "_SCHEMES", ".", "sections", "(", ")", ")", ")" ]
[ 428, 0 ]
[ 430, 45 ]
python
en
['en', 'en', 'en']
True
get_path_names
()
Return a tuple containing the paths names.
Return a tuple containing the paths names.
def get_path_names(): """Return a tuple containing the paths names.""" # xxx see if we want a static list return _SCHEMES.options('posix_prefix')
[ "def", "get_path_names", "(", ")", ":", "# xxx see if we want a static list", "return", "_SCHEMES", ".", "options", "(", "'posix_prefix'", ")" ]
[ 433, 0 ]
[ 436, 43 ]
python
en
['en', 'en', 'en']
True
get_paths
(scheme=_get_default_scheme(), vars=None, expand=True)
Return a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform.
Return a mapping containing an install scheme.
def get_paths(scheme=_get_default_scheme(), vars=None, expand=True): """Return a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform. """ _ensure_cfg_read() if expand: return _expand_var...
[ "def", "get_paths", "(", "scheme", "=", "_get_default_scheme", "(", ")", ",", "vars", "=", "None", ",", "expand", "=", "True", ")", ":", "_ensure_cfg_read", "(", ")", "if", "expand", ":", "return", "_expand_vars", "(", "scheme", ",", "vars", ")", "else",...
[ 439, 0 ]
[ 449, 43 ]
python
en
['en', 'en', 'en']
True
get_path
(name, scheme=_get_default_scheme(), vars=None, expand=True)
Return a path corresponding to the scheme. ``scheme`` is the install scheme name.
Return a path corresponding to the scheme.
def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True): """Return a path corresponding to the scheme. ``scheme`` is the install scheme name. """ return get_paths(scheme, vars, expand)[name]
[ "def", "get_path", "(", "name", ",", "scheme", "=", "_get_default_scheme", "(", ")", ",", "vars", "=", "None", ",", "expand", "=", "True", ")", ":", "return", "get_paths", "(", "scheme", ",", "vars", ",", "expand", ")", "[", "name", "]" ]
[ 452, 0 ]
[ 457, 48 ]
python
en
['en', 'el-Latn', 'en']
True
get_config_vars
(*args)
With no arguments, return a dictionary of all configuration variables relevant for the current platform. On Unix, this means every variable defined in Python's installed Makefile; On Windows and Mac OS it's a much smaller set. With arguments, return a list of values that result from looking up eac...
With no arguments, return a dictionary of all configuration variables relevant for the current platform.
def get_config_vars(*args): """With no arguments, return a dictionary of all configuration variables relevant for the current platform. On Unix, this means every variable defined in Python's installed Makefile; On Windows and Mac OS it's a much smaller set. With arguments, return a list of values ...
[ "def", "get_config_vars", "(", "*", "args", ")", ":", "global", "_CONFIG_VARS", "if", "_CONFIG_VARS", "is", "None", ":", "_CONFIG_VARS", "=", "{", "}", "# Normalized versions of prefix and exec_prefix are handy to have;", "# in fact, these are the standard versions used most pl...
[ 460, 0 ]
[ 588, 27 ]
python
en
['en', 'en', 'en']
True
get_config_var
(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'.
def get_config_var(name): """Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) """ return get_config_vars().get(name)
[ "def", "get_config_var", "(", "name", ")", ":", "return", "get_config_vars", "(", ")", ".", "get", "(", "name", ")" ]
[ 591, 0 ]
[ 597, 38 ]
python
en
['en', 'en', 'en']
True
get_platform
()
Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included...
Return a string that identifies the current platform.
def get_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the...
[ "def", "get_platform", "(", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "# sniff sys.version for architecture.", "prefix", "=", "\" bit (\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "r...
[ 600, 0 ]
[ 759, 50 ]
python
en
['en', 'en', 'en']
True
_main
()
Display all information sysconfig detains.
Display all information sysconfig detains.
def _main(): """Display all information sysconfig detains.""" print('Platform: "%s"' % get_platform()) print('Python version: "%s"' % get_python_version()) print('Current installation scheme: "%s"' % _get_default_scheme()) print() _print_dict('Paths', get_paths()) print() _print_dict('Va...
[ "def", "_main", "(", ")", ":", "print", "(", "'Platform: \"%s\"'", "%", "get_platform", "(", ")", ")", "print", "(", "'Python version: \"%s\"'", "%", "get_python_version", "(", ")", ")", "print", "(", "'Current installation scheme: \"%s\"'", "%", "_get_default_schem...
[ 773, 0 ]
[ 781, 47 ]
python
en
['en', 'en', 'en']
True
show_formats
()
Print all possible values for the 'formats' option (used by the "--help-formats" command-line option).
Print all possible values for the 'formats' option (used by the "--help-formats" command-line option).
def show_formats(): """Print all possible values for the 'formats' option (used by the "--help-formats" command-line option). """ from distutils.fancy_getopt import FancyGetopt from distutils.archive_util import ARCHIVE_FORMATS formats = [] for format in ARCHIVE_FORMATS.keys(): forma...
[ "def", "show_formats", "(", ")", ":", "from", "distutils", ".", "fancy_getopt", "import", "FancyGetopt", "from", "distutils", ".", "archive_util", "import", "ARCHIVE_FORMATS", "formats", "=", "[", "]", "for", "format", "in", "ARCHIVE_FORMATS", ".", "keys", "(", ...
[ 20, 0 ]
[ 32, 57 ]
python
en
['en', 'en', 'en']
True
sdist.checking_metadata
(self)
Callable used for the check sub-command. Placed here so user_options can view it
Callable used for the check sub-command.
def checking_metadata(self): """Callable used for the check sub-command. Placed here so user_options can view it""" return self.metadata_check
[ "def", "checking_metadata", "(", "self", ")", ":", "return", "self", ".", "metadata_check" ]
[ 39, 4 ]
[ 43, 34 ]
python
en
['en', 'en', 'en']
True
sdist.check_metadata
(self)
Deprecated API.
Deprecated API.
def check_metadata(self): """Deprecated API.""" warn("distutils.command.sdist.check_metadata is deprecated, \ use the check command instead", PendingDeprecationWarning) check = self.distribution.get_command_obj('check') check.ensure_finalized() check.run()
[ "def", "check_metadata", "(", "self", ")", ":", "warn", "(", "\"distutils.command.sdist.check_metadata is deprecated, \\\n use the check command instead\"", ",", "PendingDeprecationWarning", ")", "check", "=", "self", ".", "distribution", ".", "get_command_obj", "(...
[ 161, 4 ]
[ 167, 19 ]
python
en
['en', 'pt', 'en']
False
sdist.get_file_list
(self)
Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options. ...
Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all depends on the user's options. ...
def get_file_list(self): """Figure out the list of files to include in the source distribution, and put it in 'self.filelist'. This might involve reading the manifest template (and writing the manifest), or just reading the manifest, or just using the default file set -- it all ...
[ "def", "get_file_list", "(", "self", ")", ":", "# new behavior when using a template:", "# the file list is recalculated every time because", "# even if MANIFEST.in or setup.py are not changed", "# the user might have added some files in the tree that", "# need to be included.", "#", "# Thi...
[ 169, 4 ]
[ 207, 29 ]
python
en
['en', 'en', 'en']
True
sdist.add_defaults
(self)
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_files. - all files defined as...
def add_defaults(self): """Add all the default files to self.filelist: - README or README.txt - setup.py - test/test*.py - all pure Python modules mentioned in setup script - all files pointed by package_data (build_py) - all files defined in data_file...
[ "def", "add_defaults", "(", "self", ")", ":", "self", ".", "_add_defaults_standards", "(", ")", "self", ".", "_add_defaults_optional", "(", ")", "self", ".", "_add_defaults_python", "(", ")", "self", ".", "_add_defaults_data_files", "(", ")", "self", ".", "_ad...
[ 209, 4 ]
[ 229, 36 ]
python
en
['en', 'en', 'en']
True
sdist._cs_path_exists
(fspath)
Case-sensitive path existence check >>> sdist._cs_path_exists(__file__) True >>> sdist._cs_path_exists(__file__.upper()) False
Case-sensitive path existence check
def _cs_path_exists(fspath): """ Case-sensitive path existence check >>> sdist._cs_path_exists(__file__) True >>> sdist._cs_path_exists(__file__.upper()) False """ if not os.path.exists(fspath): return False # make absolute so we alway...
[ "def", "_cs_path_exists", "(", "fspath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fspath", ")", ":", "return", "False", "# make absolute so we always have a directory", "abspath", "=", "os", ".", "path", ".", "abspath", "(", "fspath", "...
[ 232, 4 ]
[ 246, 48 ]
python
en
['en', 'error', 'th']
False
sdist.read_template
(self)
Read and parse manifest template file named by self.template. (usually "MANIFEST.in") The parsing and processing is done by 'self.filelist', which updates itself accordingly.
Read and parse manifest template file named by self.template.
def read_template(self): """Read and parse manifest template file named by self.template. (usually "MANIFEST.in") The parsing and processing is done by 'self.filelist', which updates itself accordingly. """ log.info("reading manifest template '%s'", self.template) templa...
[ "def", "read_template", "(", "self", ")", ":", "log", ".", "info", "(", "\"reading manifest template '%s'\"", ",", "self", ".", "template", ")", "template", "=", "TextFile", "(", "self", ".", "template", ",", "strip_comments", "=", "1", ",", "skip_blanks", "...
[ 323, 4 ]
[ 350, 28 ]
python
en
['en', 'en', 'en']
True
sdist.prune_file_list
(self)
Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, C...
Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp, or it aborted) * any RCS, C...
def prune_file_list(self): """Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically "build") * the release tree itself (only an issue if we ran "sdist" previously with --keep-temp,...
[ "def", "prune_file_list", "(", "self", ")", ":", "build", "=", "self", ".", "get_finalized_command", "(", "'build'", ")", "base_dir", "=", "self", ".", "distribution", ".", "get_fullname", "(", ")", "self", ".", "filelist", ".", "exclude_pattern", "(", "None...
[ 352, 4 ]
[ 374, 59 ]
python
en
['en', 'en', 'en']
True
sdist.write_manifest
(self)
Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'.
Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'.
def write_manifest(self): """Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ if self._manifest_is_not_generated(): log.info("not writing to manually maintaine...
[ "def", "write_manifest", "(", "self", ")", ":", "if", "self", ".", "_manifest_is_not_generated", "(", ")", ":", "log", ".", "info", "(", "\"not writing to manually maintained \"", "\"manifest file '%s'\"", "%", "self", ".", "manifest", ")", "return", "content", "=...
[ 376, 4 ]
[ 389, 66 ]
python
en
['en', 'en', 'en']
True
sdist.read_manifest
(self)
Read the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution.
Read the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution.
def read_manifest(self): """Read the manifest file (named by 'self.manifest') and use it to fill in 'self.filelist', the list of files to include in the source distribution. """ log.info("reading manifest file '%s'", self.manifest) with open(self.manifest) as manifest: ...
[ "def", "read_manifest", "(", "self", ")", ":", "log", ".", "info", "(", "\"reading manifest file '%s'\"", ",", "self", ".", "manifest", ")", "with", "open", "(", "self", ".", "manifest", ")", "as", "manifest", ":", "for", "line", "in", "manifest", ":", "...
[ 403, 4 ]
[ 415, 42 ]
python
en
['en', 'en', 'en']
True
sdist.make_release_tree
(self, base_dir, files)
Create the directory tree that will become the source distribution archive. All directories implied by the filenames in 'files' are created under 'base_dir', and then we hard link or copy (if hard linking is unavailable) those files into place. Essentially, this duplicates the developer...
Create the directory tree that will become the source distribution archive. All directories implied by the filenames in 'files' are created under 'base_dir', and then we hard link or copy (if hard linking is unavailable) those files into place. Essentially, this duplicates the developer...
def make_release_tree(self, base_dir, files): """Create the directory tree that will become the source distribution archive. All directories implied by the filenames in 'files' are created under 'base_dir', and then we hard link or copy (if hard linking is unavailable) those files into ...
[ "def", "make_release_tree", "(", "self", ",", "base_dir", ",", "files", ")", ":", "# Create all the directories under 'base_dir' necessary to", "# put 'files' there; the 'mkpath()' is just so we don't die", "# if the manifest happens to be empty.", "self", ".", "mkpath", "(", "base...
[ 417, 4 ]
[ 457, 59 ]
python
en
['en', 'en', 'en']
True
sdist.make_distribution
(self)
Create the source distribution(s). First, we create the release tree with 'make_release_tree()'; then, we create all required archive files (according to 'self.formats') from the release tree. Finally, we clean up by blowing away the release tree (unless 'self.keep_temp' is true). The ...
Create the source distribution(s). First, we create the release tree with 'make_release_tree()'; then, we create all required archive files (according to 'self.formats') from the release tree. Finally, we clean up by blowing away the release tree (unless 'self.keep_temp' is true). The ...
def make_distribution(self): """Create the source distribution(s). First, we create the release tree with 'make_release_tree()'; then, we create all required archive files (according to 'self.formats') from the release tree. Finally, we clean up by blowing away the release tree (unless ...
[ "def", "make_distribution", "(", "self", ")", ":", "# Don't warn about missing meta-data here -- should be (and is!)", "# done elsewhere.", "base_dir", "=", "self", ".", "distribution", ".", "get_fullname", "(", ")", "base_name", "=", "os", ".", "path", ".", "join", "...
[ 459, 4 ]
[ 487, 64 ]
python
en
['en', 'en', 'en']
True
sdist.get_archive_files
(self)
Return the list of archive files created when the command was run, or None if the command hasn't run yet.
Return the list of archive files created when the command was run, or None if the command hasn't run yet.
def get_archive_files(self): """Return the list of archive files created when the command was run, or None if the command hasn't run yet. """ return self.archive_files
[ "def", "get_archive_files", "(", "self", ")", ":", "return", "self", ".", "archive_files" ]
[ 489, 4 ]
[ 493, 33 ]
python
en
['en', 'en', 'en']
True
StreamAdminTest.test_stream_message_retention_days_on_stream_creation
(self)
Only admins can create streams with message_retention_days with value other than None.
Only admins can create streams with message_retention_days with value other than None.
def test_stream_message_retention_days_on_stream_creation(self) -> None: """ Only admins can create streams with message_retention_days with value other than None. """ admin = self.example_user("iago") streams_raw: List[StreamDict] = [ { "name...
[ "def", "test_stream_message_retention_days_on_stream_creation", "(", "self", ")", "->", "None", ":", "admin", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "streams_raw", ":", "List", "[", "StreamDict", "]", "=", "[", "{", "\"name\"", ":", "\"new_strea...
[ 1283, 4 ]
[ 1343, 67 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.set_up_stream_for_archiving
( self, stream_name: str, invite_only: bool = False, subscribed: bool = True )
Create a stream for archiving by an administrator.
Create a stream for archiving by an administrator.
def set_up_stream_for_archiving( self, stream_name: str, invite_only: bool = False, subscribed: bool = True ) -> Stream: """ Create a stream for archiving by an administrator. """ user_profile = self.example_user("hamlet") self.login_user(user_profile) stream ...
[ "def", "set_up_stream_for_archiving", "(", "self", ",", "stream_name", ":", "str", ",", "invite_only", ":", "bool", "=", "False", ",", "subscribed", ":", "bool", "=", "True", ")", "->", "Stream", ":", "user_profile", "=", "self", ".", "example_user", "(", ...
[ 1345, 4 ]
[ 1361, 21 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.archive_stream
(self, stream: Stream)
Archive the stream and assess the result.
Archive the stream and assess the result.
def archive_stream(self, stream: Stream) -> None: """ Archive the stream and assess the result. """ active_name = stream.name realm = stream.realm stream_id = stream.id # Simulate that a stream by the same name has already been # deactivated, just to exer...
[ "def", "archive_stream", "(", "self", ",", "stream", ":", "Stream", ")", "->", "None", ":", "active_name", "=", "stream", ".", "name", "realm", "=", "stream", ".", "realm", "stream_id", "=", "stream", ".", "id", "# Simulate that a stream by the same name has alr...
[ 1363, 4 ]
[ 1416, 95 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_you_must_be_realm_admin
(self)
You must be on the realm to create a stream.
You must be on the realm to create a stream.
def test_you_must_be_realm_admin(self) -> None: """ You must be on the realm to create a stream. """ user_profile = self.example_user("hamlet") self.login_user(user_profile) other_realm = do_create_realm(string_id="other", name="other") stream = self.make_stream(...
[ "def", "test_you_must_be_realm_admin", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "user_profile", ")", "other_realm", "=", "do_create_realm", "(", "string_id", "=...
[ 1418, 4 ]
[ 1435, 59 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_delete_public_stream
(self)
When an administrator deletes a public stream, that stream is not visible to users at all anymore.
When an administrator deletes a public stream, that stream is not visible to users at all anymore.
def test_delete_public_stream(self) -> None: """ When an administrator deletes a public stream, that stream is not visible to users at all anymore. """ stream = self.set_up_stream_for_archiving("newstream") self.archive_stream(stream)
[ "def", "test_delete_public_stream", "(", "self", ")", "->", "None", ":", "stream", "=", "self", ".", "set_up_stream_for_archiving", "(", "\"newstream\"", ")", "self", ".", "archive_stream", "(", "stream", ")" ]
[ 1437, 4 ]
[ 1443, 35 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_delete_private_stream
(self)
Administrators can delete private streams they are on.
Administrators can delete private streams they are on.
def test_delete_private_stream(self) -> None: """ Administrators can delete private streams they are on. """ stream = self.set_up_stream_for_archiving("newstream", invite_only=True) self.archive_stream(stream)
[ "def", "test_delete_private_stream", "(", "self", ")", "->", "None", ":", "stream", "=", "self", ".", "set_up_stream_for_archiving", "(", "\"newstream\"", ",", "invite_only", "=", "True", ")", "self", ".", "archive_stream", "(", "stream", ")" ]
[ 1445, 4 ]
[ 1450, 35 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_archive_streams_youre_not_on
(self)
Administrators can delete public streams they aren't on, including private streams in their realm.
Administrators can delete public streams they aren't on, including private streams in their realm.
def test_archive_streams_youre_not_on(self) -> None: """ Administrators can delete public streams they aren't on, including private streams in their realm. """ pub_stream = self.set_up_stream_for_archiving("pubstream", subscribed=False) self.archive_stream(pub_stream) ...
[ "def", "test_archive_streams_youre_not_on", "(", "self", ")", "->", "None", ":", "pub_stream", "=", "self", ".", "set_up_stream_for_archiving", "(", "\"pubstream\"", ",", "subscribed", "=", "False", ")", "self", ".", "archive_stream", "(", "pub_stream", ")", "priv...
[ 1452, 4 ]
[ 1463, 40 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_cant_remove_others_from_stream
(self)
If you're not an admin, you can't remove other people from streams.
If you're not an admin, you can't remove other people from streams.
def test_cant_remove_others_from_stream(self) -> None: """ If you're not an admin, you can't remove other people from streams. """ result = self.attempt_unsubscribe_of_principal( query_count=5, target_users=[self.example_user("cordelia")], is_realm_adm...
[ "def", "test_cant_remove_others_from_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "5", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "\"cordelia\"", ")", ...
[ 1539, 4 ]
[ 1552, 89 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_realm_admin_remove_others_from_public_stream
(self)
If you're a realm admin, you can remove people from public streams, even those you aren't on.
If you're a realm admin, you can remove people from public streams, even those you aren't on.
def test_realm_admin_remove_others_from_public_stream(self) -> None: """ If you're a realm admin, you can remove people from public streams, even those you aren't on. """ result = self.attempt_unsubscribe_of_principal( query_count=16, target_users=[self.ex...
[ "def", "test_realm_admin_remove_others_from_public_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "16", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "\"cordel...
[ 1554, 4 ]
[ 1569, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_realm_admin_remove_multiple_users_from_stream
(self)
If you're a realm admin, you can remove multiple users from a stream. TODO: We have too many queries for this situation--each additional user leads to 4 more queries. Fortunately, some of the extra work here is in do_mark_stream_messages_as_read, which gets d...
If you're a realm admin, you can remove multiple users from a stream.
def test_realm_admin_remove_multiple_users_from_stream(self) -> None: """ If you're a realm admin, you can remove multiple users from a stream. TODO: We have too many queries for this situation--each additional user leads to 4 more queries. Fortunately, some of the ...
[ "def", "test_realm_admin_remove_multiple_users_from_stream", "(", "self", ")", "->", "None", ":", "target_users", "=", "[", "self", ".", "example_user", "(", "name", ")", "for", "name", "in", "[", "\"cordelia\"", ",", "\"prospero\"", ",", "\"iago\"", ",", "\"ham...
[ 1571, 4 ]
[ 1596, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_realm_admin_remove_others_from_subbed_private_stream
(self)
If you're a realm admin, you can remove other people from private streams you are on.
If you're a realm admin, you can remove other people from private streams you are on.
def test_realm_admin_remove_others_from_subbed_private_stream(self) -> None: """ If you're a realm admin, you can remove other people from private streams you are on. """ result = self.attempt_unsubscribe_of_principal( query_count=17, target_users=[self.ex...
[ "def", "test_realm_admin_remove_others_from_subbed_private_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "17", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "...
[ 1598, 4 ]
[ 1613, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_realm_admin_remove_others_from_unsubbed_private_stream
(self)
If you're a realm admin, you can remove people from private streams you aren't on.
If you're a realm admin, you can remove people from private streams you aren't on.
def test_realm_admin_remove_others_from_unsubbed_private_stream(self) -> None: """ If you're a realm admin, you can remove people from private streams you aren't on. """ result = self.attempt_unsubscribe_of_principal( query_count=17, target_users=[self.exa...
[ "def", "test_realm_admin_remove_others_from_unsubbed_private_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "17", ",", "target_users", "=", "[", "self", ".", "example_user", "(", ...
[ 1615, 4 ]
[ 1631, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_stream_admin_remove_others_from_public_stream
(self)
You can remove others from public streams you're a stream administrator of.
You can remove others from public streams you're a stream administrator of.
def test_stream_admin_remove_others_from_public_stream(self) -> None: """ You can remove others from public streams you're a stream administrator of. """ result = self.attempt_unsubscribe_of_principal( query_count=16, target_users=[self.example_user("cordelia")], ...
[ "def", "test_stream_admin_remove_others_from_public_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "16", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "\"corde...
[ 1633, 4 ]
[ 1648, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_stream_admin_remove_multiple_users_from_stream
(self)
You can remove multiple users from public streams you're a stream administrator of.
You can remove multiple users from public streams you're a stream administrator of.
def test_stream_admin_remove_multiple_users_from_stream(self) -> None: """ You can remove multiple users from public streams you're a stream administrator of. """ target_users = [ self.example_user(name) for name in ["cordelia", "prospero", "othello", "hamlet", "ZOE"] ...
[ "def", "test_stream_admin_remove_multiple_users_from_stream", "(", "self", ")", "->", "None", ":", "target_users", "=", "[", "self", ".", "example_user", "(", "name", ")", "for", "name", "in", "[", "\"cordelia\"", ",", "\"prospero\"", ",", "\"othello\"", ",", "\...
[ 1650, 4 ]
[ 1669, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_stream_admin_remove_others_from_private_stream
(self)
You can remove others from private streams you're a stream administrator of.
You can remove others from private streams you're a stream administrator of.
def test_stream_admin_remove_others_from_private_stream(self) -> None: """ You can remove others from private streams you're a stream administrator of. """ result = self.attempt_unsubscribe_of_principal( query_count=17, target_users=[self.example_user("cordelia")]...
[ "def", "test_stream_admin_remove_others_from_private_stream", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "17", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "\"cord...
[ 1671, 4 ]
[ 1686, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_create_stream_policy_setting
(self)
When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then test that any user can create a stream. When realm.create_stream_policy setting is Realm.POLICY_ADMINS_ONLY then test that only admins can create a stream. When realm.create_stream_policy setting is Real...
When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then test that any user can create a stream.
def test_create_stream_policy_setting(self) -> None: """ When realm.create_stream_policy setting is Realm.POLICY_MEMBERS_ONLY then test that any user can create a stream. When realm.create_stream_policy setting is Realm.POLICY_ADMINS_ONLY then test that only admins can create a ...
[ "def", "test_create_stream_policy_setting", "(", "self", ")", "->", "None", ":", "user_profile", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "user_profile", ".", "date_joined", "=", "timezone_now", "(", ")", "user_profile", ".", "save", "(", ")", ...
[ 1729, 4 ]
[ 1809, 67 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_invite_to_stream_by_invite_period_threshold
(self)
Non admin users with account age greater or equal to the invite to stream threshold should be able to invite others to a stream.
Non admin users with account age greater or equal to the invite to stream threshold should be able to invite others to a stream.
def test_invite_to_stream_by_invite_period_threshold(self) -> None: """ Non admin users with account age greater or equal to the invite to stream threshold should be able to invite others to a stream. """ hamlet_user = self.example_user("hamlet") hamlet_user.date_joined =...
[ "def", "test_invite_to_stream_by_invite_period_threshold", "(", "self", ")", "->", "None", ":", "hamlet_user", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "hamlet_user", ".", "date_joined", "=", "timezone_now", "(", ")", "hamlet_user", ".", "save", "...
[ 1811, 4 ]
[ 1871, 9 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_remove_already_not_subbed
(self)
Trying to unsubscribe someone who already isn't subscribed to a stream fails gracefully.
Trying to unsubscribe someone who already isn't subscribed to a stream fails gracefully.
def test_remove_already_not_subbed(self) -> None: """ Trying to unsubscribe someone who already isn't subscribed to a stream fails gracefully. """ result = self.attempt_unsubscribe_of_principal( query_count=10, target_users=[self.example_user("cordelia")],...
[ "def", "test_remove_already_not_subbed", "(", "self", ")", "->", "None", ":", "result", "=", "self", ".", "attempt_unsubscribe_of_principal", "(", "query_count", "=", "10", ",", "target_users", "=", "[", "self", ".", "example_user", "(", "\"cordelia\"", ")", "]"...
[ 1873, 4 ]
[ 1888, 50 ]
python
en
['en', 'error', 'th']
False
StreamAdminTest.test_remove_invalid_user
(self)
Trying to unsubscribe an invalid user from a stream fails gracefully.
Trying to unsubscribe an invalid user from a stream fails gracefully.
def test_remove_invalid_user(self) -> None: """ Trying to unsubscribe an invalid user from a stream fails gracefully. """ admin = self.example_user("iago") self.login_user(admin) self.assertTrue(admin.is_realm_admin) stream_name = "hümbüǵ" self.make_strea...
[ "def", "test_remove_invalid_user", "(", "self", ")", "->", "None", ":", "admin", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login_user", "(", "admin", ")", "self", ".", "assertTrue", "(", "admin", ".", "is_realm_admin", ")", "str...
[ 1890, 4 ]
[ 1910, 9 ]
python
en
['en', 'error', 'th']
False
CustomCommand.handle
(self, client, parser)
To be implemented by subclasses. Should return a dictionary that is JSON serializable
To be implemented by subclasses. Should return a dictionary that is JSON serializable
def handle(self, client, parser): """To be implemented by subclasses. Should return a dictionary that is JSON serializable """ raise NotImplementedError()
[ "def", "handle", "(", "self", ",", "client", ",", "parser", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 61, 4 ]
[ 65, 35 ]
python
en
['en', 'en', 'en']
True
Factory.get_wheel_cache_entry
(self, link, name)
Look up the link in the wheel cache. If ``preparer.require_hashes`` is True, don't use the wheel cache, because cached wheels, always built locally, have different hashes than the files downloaded from the index server and thus throw false hash mismatches. Furthermore, cached wheels at ...
Look up the link in the wheel cache.
def get_wheel_cache_entry(self, link, name): # type: (Link, Optional[str]) -> Optional[CacheEntry] """Look up the link in the wheel cache. If ``preparer.require_hashes`` is True, don't use the wheel cache, because cached wheels, always built locally, have different hashes than t...
[ "def", "get_wheel_cache_entry", "(", "self", ",", "link", ",", "name", ")", ":", "# type: (Link, Optional[str]) -> Optional[CacheEntry]", "if", "self", ".", "_wheel_cache", "is", "None", "or", "self", ".", "preparer", ".", "require_hashes", ":", "return", "None", ...
[ 304, 4 ]
[ 320, 9 ]
python
en
['en', 'en', 'en']
True
compose_views
(thunks: List[Callable[[], HttpResponse]])
This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transaction when things go wrong in any one of the composed methods. TODO: Move th...
This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transaction when things go wrong in any one of the composed methods.
def compose_views(thunks: List[Callable[[], HttpResponse]]) -> HttpResponse: """ This takes a series of thunks and calls them in sequence, and it smushes all the json results into a single response when everything goes right. (This helps clients avoid extra latency hops.) It rolls back the transac...
[ "def", "compose_views", "(", "thunks", ":", "List", "[", "Callable", "[", "[", "]", ",", "HttpResponse", "]", "]", ")", "->", "HttpResponse", ":", "json_dict", ":", "Dict", "[", "str", ",", "Any", "]", "=", "{", "}", "with", "transaction", ".", "atom...
[ 351, 0 ]
[ 370, 34 ]
python
en
['en', 'error', 'th']
False
send_messages_for_new_subscribers
( user_profile: UserProfile, subscribers: Set[UserProfile], new_subscriptions: Dict[str, List[str]], email_to_user_profile: Dict[str, UserProfile], created_streams: List[Stream], announce: bool, )
If you are subscribing lots of new users to new streams, this function can be pretty expensive in terms of generating lots of queries and sending lots of messages. We isolate the code partly to make it easier to test things like excessive query counts by mocking this function so that it doesn'...
If you are subscribing lots of new users to new streams, this function can be pretty expensive in terms of generating lots of queries and sending lots of messages. We isolate the code partly to make it easier to test things like excessive query counts by mocking this function so that it doesn'...
def send_messages_for_new_subscribers( user_profile: UserProfile, subscribers: Set[UserProfile], new_subscriptions: Dict[str, List[str]], email_to_user_profile: Dict[str, UserProfile], created_streams: List[Stream], announce: bool, ) -> None: """ If you are subscribing lots of new users ...
[ "def", "send_messages_for_new_subscribers", "(", "user_profile", ":", "UserProfile", ",", "subscribers", ":", "Set", "[", "UserProfile", "]", ",", "new_subscriptions", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ",", "email_to_user_profile", ":",...
[ 563, 0 ]
[ 662, 71 ]
python
en
['en', 'error', 'th']
False
update_subscription_properties_backend
( request: HttpRequest, user_profile: UserProfile, subscription_data: List[Dict[str, Any]] = REQ( json_validator=check_list( check_dict( [ ("stream_id", check_int), ("property", check_string), ("value", check_uni...
This is the entry point to changing subscription properties. This is a bulk endpoint: requestors always provide a subscription_data list containing dictionaries for each stream of interest. Requests are of the form: [{"stream_id": "1", "property": "is_muted", "value": False}, {"stream_id": "...
This is the entry point to changing subscription properties. This is a bulk endpoint: requestors always provide a subscription_data list containing dictionaries for each stream of interest.
def update_subscription_properties_backend( request: HttpRequest, user_profile: UserProfile, subscription_data: List[Dict[str, Any]] = REQ( json_validator=check_list( check_dict( [ ("stream_id", check_int), ("property", check_string...
[ "def", "update_subscription_properties_backend", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "subscription_data", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "REQ", "(", "json_validator", "=", "check_lis...
[ 823, 0 ]
[ 884, 61 ]
python
en
['en', 'error', 'th']
False
score
(trained_model, X, y)
Compute RMSE and R^2 for a trained model. Parameters ---------- trainined_model : edbo.models Trained model. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array, torch.tensor Response values corresponding to X. Returns ---------- ...
Compute RMSE and R^2 for a trained model. Parameters ---------- trainined_model : edbo.models Trained model. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array, torch.tensor Response values corresponding to X. Returns ---------- ...
def score(trained_model, X, y): """Compute RMSE and R^2 for a trained model. Parameters ---------- trainined_model : edbo.models Trained model. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array, torch.tensor Response values corresponding t...
[ "def", "score", "(", "trained_model", ",", "X", ",", "y", ")", ":", "pred", "=", "np", ".", "array", "(", "trained_model", ".", "predict", "(", "X", ")", ")", "obs", "=", "np", ".", "array", "(", "y", ")", "RMSE", ",", "R2", "=", "model_performan...
[ 617, 0 ]
[ 639, 19 ]
python
en
['en', 'en', 'en']
True
cross_validate
(base_model, X, y, kfold=5, random_state=None, **kwargs)
Compute cross-validation scores for models. Parameters ---------- base_model : edbo.models Uninitialized model object. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array, torch.tensor Response values corresponding to domain points X. kfold :...
Compute cross-validation scores for models. Parameters ---------- base_model : edbo.models Uninitialized model object. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array, torch.tensor Response values corresponding to domain points X. kfold :...
def cross_validate(base_model, X, y, kfold=5, random_state=None, **kwargs): """Compute cross-validation scores for models. Parameters ---------- base_model : edbo.models Uninitialized model object. X : numpy.array, torch.tensor Domain points to be evaluated. y : numpy.array,...
[ "def", "cross_validate", "(", "base_model", ",", "X", ",", "y", ",", "kfold", "=", "5", ",", "random_state", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# CV Split ", "split", "=", "cv_split", "(", "X", ",", "n_splits", "=", "kfold", ",", "rand...
[ 643, 0 ]
[ 696, 17 ]
python
en
['en', 'en', 'en']
True
GP_Model.__init__
(self, X, y, training_iters=100, inference_type='MLE', learning_rate=0.1, noise_constraint=1e-5, gpu=False, nu=2.5, lengthscale_prior=None, outputscale_prior=None, noise_prior=None, n_restarts=0 )
Parameters ---------- X : torch.tensor Training domain values. y : torch.tensor Training response values. training_iters : int Number of iterations to run ADAM optimizer durring training. inference_type : str Estima...
Parameters ---------- X : torch.tensor Training domain values. y : torch.tensor Training response values. training_iters : int Number of iterations to run ADAM optimizer durring training. inference_type : str Estima...
def __init__(self, X, y, training_iters=100, inference_type='MLE', learning_rate=0.1, noise_constraint=1e-5, gpu=False, nu=2.5, lengthscale_prior=None, outputscale_prior=None, noise_prior=None, n_restarts=0 ): """ Parameters ...
[ "def", "__init__", "(", "self", ",", "X", ",", "y", ",", "training_iters", "=", "100", ",", "inference_type", "=", "'MLE'", ",", "learning_rate", "=", "0.1", ",", "noise_constraint", "=", "1e-5", ",", "gpu", "=", "False", ",", "nu", "=", "2.5", ",", ...
[ 36, 4 ]
[ 115, 42 ]
python
en
['en', 'ja', 'th']
False
GP_Model.mle
(self)
Uses maximum likelihood estimation to estimate model hyperparameters.
Uses maximum likelihood estimation to estimate model hyperparameters.
def mle(self): """Uses maximum likelihood estimation to estimate model hyperparameters. """ # Optimize MLL with user specified parameters loss = optimize_mll(self.model, self.likelihood, self.X, self.y, learning_rate=self.learning_rate, ...
[ "def", "mle", "(", "self", ")", ":", "# Optimize MLL with user specified parameters", "loss", "=", "optimize_mll", "(", "self", ".", "model", ",", "self", ".", "likelihood", ",", "self", ".", "X", ",", "self", ".", "y", ",", "learning_rate", "=", "self", "...
[ 118, 4 ]
[ 132, 36 ]
python
en
['eo', 'et', 'en']
False
GP_Model.fit
(self)
Train the gaussian process model.
Train the gaussian process model.
def fit(self): """Train the gaussian process model.""" if self.inference_type == 'MLE': self.mle() else: print('Please specify valid inference type.') sys.exit(0)
[ "def", "fit", "(", "self", ")", ":", "if", "self", ".", "inference_type", "==", "'MLE'", ":", "self", ".", "mle", "(", ")", "else", ":", "print", "(", "'Please specify valid inference type.'", ")", "sys", ".", "exit", "(", "0", ")" ]
[ 135, 4 ]
[ 142, 23 ]
python
en
['en', 'zh-Latn', 'en']
True
GP_Model.predict
(self, points)
Mean of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Predicted response values for points.
Mean of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Predicted response values for points.
def predict(self, points): """Mean of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Predicted response values ...
[ "def", "predict", "(", "self", ",", "points", ")", ":", "# Get into evaluation mode", "self", ".", "model", ".", "eval", "(", ")", "self", ".", "likelihood", ".", "eval", "(", ")", "# Make predictions", "points", "=", "to_torch", "(", "points", ",", "gpu",...
[ 145, 4 ]
[ 173, 27 ]
python
en
['en', 'en', 'en']
True
GP_Model.variance
(self, points)
Variance of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Model variance a points.
Variance of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Model variance a points.
def variance(self, points): """Variance of gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. Returns ---------- numpy.array Model variance a poi...
[ "def", "variance", "(", "self", ",", "points", ")", ":", "# Get into evaluation mode", "self", ".", "model", ".", "eval", "(", ")", "self", ".", "likelihood", ".", "eval", "(", ")", "# Compuate variance", "points", "=", "to_torch", "(", "points", ",", "gpu...
[ 176, 4 ]
[ 201, 26 ]
python
en
['en', 'en', 'en']
True