partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
download_selenium_server
Downloads the Selenium Server JAR file from its online location and stores it locally.
seleniumbase/utilities/selenium_grid/download_selenium_server.py
def download_selenium_server(): """ Downloads the Selenium Server JAR file from its online location and stores it locally. """ try: local_file = open(JAR_FILE, 'wb') remote_file = urlopen(SELENIUM_JAR) print('Downloading the Selenium Server JAR file...\n') local_file....
def download_selenium_server(): """ Downloads the Selenium Server JAR file from its online location and stores it locally. """ try: local_file = open(JAR_FILE, 'wb') remote_file = urlopen(SELENIUM_JAR) print('Downloading the Selenium Server JAR file...\n') local_file....
[ "Downloads", "the", "Selenium", "Server", "JAR", "file", "from", "its", "online", "location", "and", "stores", "it", "locally", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/utilities/selenium_grid/download_selenium_server.py#L20-L35
[ "def", "download_selenium_server", "(", ")", ":", "try", ":", "local_file", "=", "open", "(", "JAR_FILE", ",", "'wb'", ")", "remote_file", "=", "urlopen", "(", "SELENIUM_JAR", ")", "print", "(", "'Downloading the Selenium Server JAR file...\\n'", ")", "local_file", ...
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.begin
At the start of the run, we want to record the test execution information in the database.
seleniumbase/plugins/db_reporting_plugin.py
def begin(self): """ At the start of the run, we want to record the test execution information in the database. """ exec_payload = ExecutionQueryPayload() exec_payload.execution_start_time = int(time.time() * 1000) self.execution_start_time = exec_payload.execution_start_time...
def begin(self): """ At the start of the run, we want to record the test execution information in the database. """ exec_payload = ExecutionQueryPayload() exec_payload.execution_start_time = int(time.time() * 1000) self.execution_start_time = exec_payload.execution_start_time...
[ "At", "the", "start", "of", "the", "run", "we", "want", "to", "record", "the", "test", "execution", "information", "in", "the", "database", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L49-L57
[ "def", "begin", "(", "self", ")", ":", "exec_payload", "=", "ExecutionQueryPayload", "(", ")", "exec_payload", ".", "execution_start_time", "=", "int", "(", "time", ".", "time", "(", ")", "*", "1000", ")", "self", ".", "execution_start_time", "=", "exec_payl...
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.finalize
At the end of the run, we want to update the DB row with the execution time.
seleniumbase/plugins/db_reporting_plugin.py
def finalize(self, result): """ At the end of the run, we want to update the DB row with the execution time. """ runtime = int(time.time() * 1000) - self.execution_start_time self.testcase_manager.update_execution_data(self.execution_guid, ...
def finalize(self, result): """ At the end of the run, we want to update the DB row with the execution time. """ runtime = int(time.time() * 1000) - self.execution_start_time self.testcase_manager.update_execution_data(self.execution_guid, ...
[ "At", "the", "end", "of", "the", "run", "we", "want", "to", "update", "the", "DB", "row", "with", "the", "execution", "time", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L79-L84
[ "def", "finalize", "(", "self", ",", "result", ")", ":", "runtime", "=", "int", "(", "time", ".", "time", "(", ")", "*", "1000", ")", "-", "self", ".", "execution_start_time", "self", ".", "testcase_manager", ".", "update_execution_data", "(", "self", "....
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.addSuccess
After test completion, we want to record testcase run information.
seleniumbase/plugins/db_reporting_plugin.py
def addSuccess(self, test, capt): """ After test completion, we want to record testcase run information. """ self.__insert_test_result(constants.State.PASS, test)
def addSuccess(self, test, capt): """ After test completion, we want to record testcase run information. """ self.__insert_test_result(constants.State.PASS, test)
[ "After", "test", "completion", "we", "want", "to", "record", "testcase", "run", "information", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L86-L90
[ "def", "addSuccess", "(", "self", ",", "test", ",", "capt", ")", ":", "self", ".", "__insert_test_result", "(", "constants", ".", "State", ".", "PASS", ",", "test", ")" ]
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.addError
After a test error, we want to record testcase run information.
seleniumbase/plugins/db_reporting_plugin.py
def addError(self, test, err, capt=None): """ After a test error, we want to record testcase run information. """ self.__insert_test_result(constants.State.ERROR, test, err)
def addError(self, test, err, capt=None): """ After a test error, we want to record testcase run information. """ self.__insert_test_result(constants.State.ERROR, test, err)
[ "After", "a", "test", "error", "we", "want", "to", "record", "testcase", "run", "information", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L92-L96
[ "def", "addError", "(", "self", ",", "test", ",", "err", ",", "capt", "=", "None", ")", ":", "self", ".", "__insert_test_result", "(", "constants", ".", "State", ".", "ERROR", ",", "test", ",", "err", ")" ]
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.handleError
After a test error, we want to record testcase run information. "Error" also encompasses any states other than Pass or Fail, so we check for those first.
seleniumbase/plugins/db_reporting_plugin.py
def handleError(self, test, err, capt=None): """ After a test error, we want to record testcase run information. "Error" also encompasses any states other than Pass or Fail, so we check for those first. """ if err[0] == errors.BlockedTest: self.__insert_test_r...
def handleError(self, test, err, capt=None): """ After a test error, we want to record testcase run information. "Error" also encompasses any states other than Pass or Fail, so we check for those first. """ if err[0] == errors.BlockedTest: self.__insert_test_r...
[ "After", "a", "test", "error", "we", "want", "to", "record", "testcase", "run", "information", ".", "Error", "also", "encompasses", "any", "states", "other", "than", "Pass", "or", "Fail", "so", "we", "check", "for", "those", "first", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L98-L120
[ "def", "handleError", "(", "self", ",", "test", ",", "err", ",", "capt", "=", "None", ")", ":", "if", "err", "[", "0", "]", "==", "errors", ".", "BlockedTest", ":", "self", ".", "__insert_test_result", "(", "constants", ".", "State", ".", "BLOCKED", ...
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
DBReporting.addFailure
After a test failure, we want to record testcase run information.
seleniumbase/plugins/db_reporting_plugin.py
def addFailure(self, test, err, capt=None, tbinfo=None): """ After a test failure, we want to record testcase run information. """ self.__insert_test_result(constants.State.FAILURE, test, err)
def addFailure(self, test, err, capt=None, tbinfo=None): """ After a test failure, we want to record testcase run information. """ self.__insert_test_result(constants.State.FAILURE, test, err)
[ "After", "a", "test", "failure", "we", "want", "to", "record", "testcase", "run", "information", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L122-L126
[ "def", "addFailure", "(", "self", ",", "test", ",", "err", ",", "capt", "=", "None", ",", "tbinfo", "=", "None", ")", ":", "self", ".", "__insert_test_result", "(", "constants", ".", "State", ".", "FAILURE", ",", "test", ",", "err", ")" ]
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
_add_chrome_proxy_extension
Implementation of https://stackoverflow.com/a/35293284 for https://stackoverflow.com/questions/12848327/ (Run Selenium on a proxy server that requires authentication.)
seleniumbase/core/browser_launcher.py
def _add_chrome_proxy_extension( chrome_options, proxy_string, proxy_user, proxy_pass): """ Implementation of https://stackoverflow.com/a/35293284 for https://stackoverflow.com/questions/12848327/ (Run Selenium on a proxy server that requires authentication.) """ if not "".join(sys.argv)...
def _add_chrome_proxy_extension( chrome_options, proxy_string, proxy_user, proxy_pass): """ Implementation of https://stackoverflow.com/a/35293284 for https://stackoverflow.com/questions/12848327/ (Run Selenium on a proxy server that requires authentication.) """ if not "".join(sys.argv)...
[ "Implementation", "of", "https", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "35293284", "for", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "12848327", "/", "(", "Run", "Selenium", "on", "a", "proxy", "server", "tha...
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/core/browser_launcher.py#L63-L85
[ "def", "_add_chrome_proxy_extension", "(", "chrome_options", ",", "proxy_string", ",", "proxy_user", ",", "proxy_pass", ")", ":", "if", "not", "\"\"", ".", "join", "(", "sys", ".", "argv", ")", "==", "\"-c\"", ":", "# Single-threaded", "proxy_helper", ".", "cr...
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
get_local_driver
Spins up a new web browser and returns the driver. Can also be used to spin up additional browsers for the same test.
seleniumbase/core/browser_launcher.py
def get_local_driver( browser_name, headless, proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent, disable_csp): ''' Spins up a new web browser and returns the driver. Can also be used to spin up additional browsers for the same test. ''' downloads_path = download_helper.get...
def get_local_driver( browser_name, headless, proxy_string, proxy_auth, proxy_user, proxy_pass, user_agent, disable_csp): ''' Spins up a new web browser and returns the driver. Can also be used to spin up additional browsers for the same test. ''' downloads_path = download_helper.get...
[ "Spins", "up", "a", "new", "web", "browser", "and", "returns", "the", "driver", ".", "Can", "also", "be", "used", "to", "spin", "up", "additional", "browsers", "for", "the", "same", "test", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/core/browser_launcher.py#L398-L520
[ "def", "get_local_driver", "(", "browser_name", ",", "headless", ",", "proxy_string", ",", "proxy_auth", ",", "proxy_user", ",", "proxy_pass", ",", "user_agent", ",", "disable_csp", ")", ":", "downloads_path", "=", "download_helper", ".", "get_downloads_folder", "("...
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
S3Logging.configure
Get the options.
seleniumbase/plugins/s3_logging_plugin.py
def configure(self, options, conf): """ Get the options. """ super(S3Logging, self).configure(options, conf) self.options = options
def configure(self, options, conf): """ Get the options. """ super(S3Logging, self).configure(options, conf) self.options = options
[ "Get", "the", "options", "." ]
seleniumbase/SeleniumBase
python
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/s3_logging_plugin.py#L18-L21
[ "def", "configure", "(", "self", ",", "options", ",", "conf", ")", ":", "super", "(", "S3Logging", ",", "self", ")", ".", "configure", "(", "options", ",", "conf", ")", "self", ".", "options", "=", "options" ]
62e5b43ee1f90a9ed923841bdd53b1b38358f43a
train
JSONWebTokenAPIView.get_serializer
Return the serializer instance that should be used for validating and deserializing input, and for serializing output.
rest_framework_jwt/views.py
def get_serializer(self, *args, **kwargs): """ Return the serializer instance that should be used for validating and deserializing input, and for serializing output. """ serializer_class = self.get_serializer_class() kwargs['context'] = self.get_serializer_context() ...
def get_serializer(self, *args, **kwargs): """ Return the serializer instance that should be used for validating and deserializing input, and for serializing output. """ serializer_class = self.get_serializer_class() kwargs['context'] = self.get_serializer_context() ...
[ "Return", "the", "serializer", "instance", "that", "should", "be", "used", "for", "validating", "and", "deserializing", "input", "and", "for", "serializing", "output", "." ]
GetBlimp/django-rest-framework-jwt
python
https://github.com/GetBlimp/django-rest-framework-jwt/blob/0a0bd402ec21fd6b9a5f715d114411836fbb2923/rest_framework_jwt/views.py#L45-L52
[ "def", "get_serializer", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "serializer_class", "=", "self", ".", "get_serializer_class", "(", ")", "kwargs", "[", "'context'", "]", "=", "self", ".", "get_serializer_context", "(", ")", "retur...
0a0bd402ec21fd6b9a5f715d114411836fbb2923
train
BaseJSONWebTokenAuthentication.authenticate_credentials
Returns an active user that matches the payload's user id and email.
rest_framework_jwt/authentication.py
def authenticate_credentials(self, payload): """ Returns an active user that matches the payload's user id and email. """ User = get_user_model() username = jwt_get_username_from_payload(payload) if not username: msg = _('Invalid payload.') raise ...
def authenticate_credentials(self, payload): """ Returns an active user that matches the payload's user id and email. """ User = get_user_model() username = jwt_get_username_from_payload(payload) if not username: msg = _('Invalid payload.') raise ...
[ "Returns", "an", "active", "user", "that", "matches", "the", "payload", "s", "user", "id", "and", "email", "." ]
GetBlimp/django-rest-framework-jwt
python
https://github.com/GetBlimp/django-rest-framework-jwt/blob/0a0bd402ec21fd6b9a5f715d114411836fbb2923/rest_framework_jwt/authentication.py#L47-L68
[ "def", "authenticate_credentials", "(", "self", ",", "payload", ")", ":", "User", "=", "get_user_model", "(", ")", "username", "=", "jwt_get_username_from_payload", "(", "payload", ")", "if", "not", "username", ":", "msg", "=", "_", "(", "'Invalid payload.'", ...
0a0bd402ec21fd6b9a5f715d114411836fbb2923
train
_parse_row
Scan a single row from an Excel file, and return the list of ranges corresponding to each consecutive span of non-empty cells in this row. If all cells are empty, return an empty list. Each "range" in the list is a tuple of the form `(startcol, endcol)`. For example, if the row is the following: ...
datatable/xls.py
def _parse_row(rowvalues, rowtypes): """ Scan a single row from an Excel file, and return the list of ranges corresponding to each consecutive span of non-empty cells in this row. If all cells are empty, return an empty list. Each "range" in the list is a tuple of the form `(startcol, endcol)`. ...
def _parse_row(rowvalues, rowtypes): """ Scan a single row from an Excel file, and return the list of ranges corresponding to each consecutive span of non-empty cells in this row. If all cells are empty, return an empty list. Each "range" in the list is a tuple of the form `(startcol, endcol)`. ...
[ "Scan", "a", "single", "row", "from", "an", "Excel", "file", "and", "return", "the", "list", "of", "ranges", "corresponding", "to", "each", "consecutive", "span", "of", "non", "-", "empty", "cells", "in", "this", "row", ".", "If", "all", "cells", "are", ...
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/xls.py#L106-L147
[ "def", "_parse_row", "(", "rowvalues", ",", "rowtypes", ")", ":", "n", "=", "len", "(", "rowvalues", ")", "assert", "n", "==", "len", "(", "rowtypes", ")", "if", "not", "n", ":", "return", "[", "]", "range_start", "=", "None", "ranges", "=", "[", "...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
_combine_ranges
This function takes a list of row-ranges (as returned by `_parse_row`) ordered by rows, and produces a list of distinct rectangular ranges within this grid. Within this function we define a 2d-range as a rectangular set of cells such that: - there are no empty rows / columns within this rectangle...
datatable/xls.py
def _combine_ranges(ranges): """ This function takes a list of row-ranges (as returned by `_parse_row`) ordered by rows, and produces a list of distinct rectangular ranges within this grid. Within this function we define a 2d-range as a rectangular set of cells such that: - there are no e...
def _combine_ranges(ranges): """ This function takes a list of row-ranges (as returned by `_parse_row`) ordered by rows, and produces a list of distinct rectangular ranges within this grid. Within this function we define a 2d-range as a rectangular set of cells such that: - there are no e...
[ "This", "function", "takes", "a", "list", "of", "row", "-", "ranges", "(", "as", "returned", "by", "_parse_row", ")", "ordered", "by", "rows", "and", "produces", "a", "list", "of", "distinct", "rectangular", "ranges", "within", "this", "grid", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/xls.py#L150-L197
[ "def", "_combine_ranges", "(", "ranges", ")", ":", "ranges2d", "=", "[", "]", "for", "irow", ",", "rowranges", "in", "enumerate", "(", "ranges", ")", ":", "ja", "=", "0", "jb", "=", "0", "while", "jb", "<", "len", "(", "rowranges", ")", ":", "bcol0...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
_collapse_ranges
Within the `ranges` list find those 2d-ranges that overlap with `ranges[ja]` and merge them into `ranges[ja]`. Finally, return the new index of the ja-th range within the `ranges` list.
datatable/xls.py
def _collapse_ranges(ranges, ja): """ Within the `ranges` list find those 2d-ranges that overlap with `ranges[ja]` and merge them into `ranges[ja]`. Finally, return the new index of the ja-th range within the `ranges` list. """ arow0, _, acol0, acol1 = ranges[ja] jb = 0 while jb < len(ra...
def _collapse_ranges(ranges, ja): """ Within the `ranges` list find those 2d-ranges that overlap with `ranges[ja]` and merge them into `ranges[ja]`. Finally, return the new index of the ja-th range within the `ranges` list. """ arow0, _, acol0, acol1 = ranges[ja] jb = 0 while jb < len(ra...
[ "Within", "the", "ranges", "list", "find", "those", "2d", "-", "ranges", "that", "overlap", "with", "ranges", "[", "ja", "]", "and", "merge", "them", "into", "ranges", "[", "ja", "]", ".", "Finally", "return", "the", "new", "index", "of", "the", "ja", ...
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/xls.py#L200-L222
[ "def", "_collapse_ranges", "(", "ranges", ",", "ja", ")", ":", "arow0", ",", "_", ",", "acol0", ",", "acol1", "=", "ranges", "[", "ja", "]", "jb", "=", "0", "while", "jb", "<", "len", "(", "ranges", ")", ":", "if", "jb", "==", "ja", ":", "jb", ...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
find_linked_dynamic_libraries
This function attempts to locate the required link libraries, and returns them as a list of absolute paths.
ci/setup_utils.py
def find_linked_dynamic_libraries(): """ This function attempts to locate the required link libraries, and returns them as a list of absolute paths. """ with TaskContext("Find the required dynamic libraries") as log: llvm = get_llvm() libs = required_link_libraries() resolved...
def find_linked_dynamic_libraries(): """ This function attempts to locate the required link libraries, and returns them as a list of absolute paths. """ with TaskContext("Find the required dynamic libraries") as log: llvm = get_llvm() libs = required_link_libraries() resolved...
[ "This", "function", "attempts", "to", "locate", "the", "required", "link", "libraries", "and", "returns", "them", "as", "a", "list", "of", "absolute", "paths", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/setup_utils.py#L589-L626
[ "def", "find_linked_dynamic_libraries", "(", ")", ":", "with", "TaskContext", "(", "\"Find the required dynamic libraries\"", ")", "as", "log", ":", "llvm", "=", "get_llvm", "(", ")", "libs", "=", "required_link_libraries", "(", ")", "resolved", "=", "[", "]", "...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
Terminal.wait_for_keypresses
Listen to user's keystrokes and return them to caller one at a time. The produced values are instances of blessed.keyboard.Keystroke class. If the user did not press anything with the last `refresh_rate` seconds the generator will yield `None`, allowing the caller to perform any updates...
datatable/utils/terminal.py
def wait_for_keypresses(self, refresh_rate=1): """ Listen to user's keystrokes and return them to caller one at a time. The produced values are instances of blessed.keyboard.Keystroke class. If the user did not press anything with the last `refresh_rate` seconds the generator wi...
def wait_for_keypresses(self, refresh_rate=1): """ Listen to user's keystrokes and return them to caller one at a time. The produced values are instances of blessed.keyboard.Keystroke class. If the user did not press anything with the last `refresh_rate` seconds the generator wi...
[ "Listen", "to", "user", "s", "keystrokes", "and", "return", "them", "to", "caller", "one", "at", "a", "time", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/terminal.py#L144-L159
[ "def", "wait_for_keypresses", "(", "self", ",", "refresh_rate", "=", "1", ")", ":", "if", "not", "self", ".", "_enable_keyboard", ":", "return", "with", "self", ".", "_blessed_term", ".", "cbreak", "(", ")", ":", "while", "True", ":", "yield", "self", "....
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
normalize_slice
Return the slice tuple normalized for an ``n``-element object. :param e: a slice object representing a selector :param n: number of elements in a sequence to which ``e`` is applied :returns: tuple ``(start, count, step)`` derived from ``e``.
datatable/utils/misc.py
def normalize_slice(e, n): """ Return the slice tuple normalized for an ``n``-element object. :param e: a slice object representing a selector :param n: number of elements in a sequence to which ``e`` is applied :returns: tuple ``(start, count, step)`` derived from ``e``. """ if n == 0: ...
def normalize_slice(e, n): """ Return the slice tuple normalized for an ``n``-element object. :param e: a slice object representing a selector :param n: number of elements in a sequence to which ``e`` is applied :returns: tuple ``(start, count, step)`` derived from ``e``. """ if n == 0: ...
[ "Return", "the", "slice", "tuple", "normalized", "for", "an", "n", "-", "element", "object", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/misc.py#L65-L127
[ "def", "normalize_slice", "(", "e", ",", "n", ")", ":", "if", "n", "==", "0", ":", "return", "(", "0", ",", "0", ",", "1", ")", "step", "=", "e", ".", "step", "if", "step", "is", "None", ":", "step", "=", "1", "if", "step", "==", "0", ":", ...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
normalize_range
Return the range tuple normalized for an ``n``-element object. The semantics of a range is slightly different than that of a slice. In particular, a range is similar to a list in meaning (and on Py2 it was eagerly expanded into a list). Thus we do not allow the range to generate indices that would be ...
datatable/utils/misc.py
def normalize_range(e, n): """ Return the range tuple normalized for an ``n``-element object. The semantics of a range is slightly different than that of a slice. In particular, a range is similar to a list in meaning (and on Py2 it was eagerly expanded into a list). Thus we do not allow the range...
def normalize_range(e, n): """ Return the range tuple normalized for an ``n``-element object. The semantics of a range is slightly different than that of a slice. In particular, a range is similar to a list in meaning (and on Py2 it was eagerly expanded into a list). Thus we do not allow the range...
[ "Return", "the", "range", "tuple", "normalized", "for", "an", "n", "-", "element", "object", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/misc.py#L130-L166
[ "def", "normalize_range", "(", "e", ",", "n", ")", ":", "if", "e", ".", "step", ">", "0", ":", "count", "=", "max", "(", "0", ",", "(", "e", ".", "stop", "-", "e", ".", "start", "-", "1", ")", "//", "e", ".", "step", "+", "1", ")", "else"...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
load_module
Import and return the requested module.
datatable/utils/misc.py
def load_module(module): """ Import and return the requested module. """ try: m = importlib.import_module(module) return m except ModuleNotFoundError: # pragma: no cover raise TImportError("Module `%s` is not installed. It is required for " "runnin...
def load_module(module): """ Import and return the requested module. """ try: m = importlib.import_module(module) return m except ModuleNotFoundError: # pragma: no cover raise TImportError("Module `%s` is not installed. It is required for " "runnin...
[ "Import", "and", "return", "the", "requested", "module", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/misc.py#L170-L179
[ "def", "load_module", "(", "module", ")", ":", "try", ":", "m", "=", "importlib", ".", "import_module", "(", "module", ")", "return", "m", "except", "ModuleNotFoundError", ":", "# pragma: no cover", "raise", "TImportError", "(", "\"Module `%s` is not installed. It i...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
humanize_bytes
Convert given number of bytes into a human readable representation, i.e. add prefix such as KB, MB, GB, etc. The `size` argument must be a non-negative integer. :param size: integer representing byte size of something :return: string representation of the size, in human-readable form
datatable/utils/misc.py
def humanize_bytes(size): """ Convert given number of bytes into a human readable representation, i.e. add prefix such as KB, MB, GB, etc. The `size` argument must be a non-negative integer. :param size: integer representing byte size of something :return: string representation of the size, in ...
def humanize_bytes(size): """ Convert given number of bytes into a human readable representation, i.e. add prefix such as KB, MB, GB, etc. The `size` argument must be a non-negative integer. :param size: integer representing byte size of something :return: string representation of the size, in ...
[ "Convert", "given", "number", "of", "bytes", "into", "a", "human", "readable", "representation", "i", ".", "e", ".", "add", "prefix", "such", "as", "KB", "MB", "GB", "etc", ".", "The", "size", "argument", "must", "be", "a", "non", "-", "negative", "int...
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/utils/misc.py#L182-L208
[ "def", "humanize_bytes", "(", "size", ")", ":", "if", "size", "==", "0", ":", "return", "\"0\"", "if", "size", "is", "None", ":", "return", "\"\"", "assert", "size", ">=", "0", ",", "\"`size` cannot be negative, got %d\"", "%", "size", "suffixes", "=", "\"...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
DataFrameWidget._fetch_data
Retrieve frame data within the current view window. This method will adjust the view window if it goes out-of-bounds.
datatable/widget.py
def _fetch_data(self): """ Retrieve frame data within the current view window. This method will adjust the view window if it goes out-of-bounds. """ self._view_col0 = clamp(self._view_col0, 0, self._max_col0) self._view_row0 = clamp(self._view_row0, 0, self._max_row0) ...
def _fetch_data(self): """ Retrieve frame data within the current view window. This method will adjust the view window if it goes out-of-bounds. """ self._view_col0 = clamp(self._view_col0, 0, self._max_col0) self._view_row0 = clamp(self._view_row0, 0, self._max_row0) ...
[ "Retrieve", "frame", "data", "within", "the", "current", "view", "window", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/widget.py#L323-L339
[ "def", "_fetch_data", "(", "self", ")", ":", "self", ".", "_view_col0", "=", "clamp", "(", "self", ".", "_view_col0", ",", "0", ",", "self", ".", "_max_col0", ")", "self", ".", "_view_row0", "=", "clamp", "(", "self", ".", "_view_row0", ",", "0", ","...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
get_files
Return the list of all source/header files in `c/` directory. The files will have pathnames relative to the current folder, for example "c/csv/reader_utils.cc".
ci/make_fast.py
def get_files(): """ Return the list of all source/header files in `c/` directory. The files will have pathnames relative to the current folder, for example "c/csv/reader_utils.cc". """ sources = [] headers = ["datatable/include/datatable.h"] assert os.path.isfile(headers[0]) for di...
def get_files(): """ Return the list of all source/header files in `c/` directory. The files will have pathnames relative to the current folder, for example "c/csv/reader_utils.cc". """ sources = [] headers = ["datatable/include/datatable.h"] assert os.path.isfile(headers[0]) for di...
[ "Return", "the", "list", "of", "all", "source", "/", "header", "files", "in", "c", "/", "directory", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/make_fast.py#L15-L32
[ "def", "get_files", "(", ")", ":", "sources", "=", "[", "]", "headers", "=", "[", "\"datatable/include/datatable.h\"", "]", "assert", "os", ".", "path", ".", "isfile", "(", "headers", "[", "0", "]", ")", "for", "dirpath", ",", "_", ",", "filenames", "i...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
find_includes
Find user includes (no system includes) requested from given source file. All .h files will be given relative to the current folder, e.g. ["c/rowindex.h", "c/column.h"].
ci/make_fast.py
def find_includes(filename): """ Find user includes (no system includes) requested from given source file. All .h files will be given relative to the current folder, e.g. ["c/rowindex.h", "c/column.h"]. """ includes = [] with open(filename, "r", encoding="utf-8") as inp: for line in...
def find_includes(filename): """ Find user includes (no system includes) requested from given source file. All .h files will be given relative to the current folder, e.g. ["c/rowindex.h", "c/column.h"]. """ includes = [] with open(filename, "r", encoding="utf-8") as inp: for line in...
[ "Find", "user", "includes", "(", "no", "system", "includes", ")", "requested", "from", "given", "source", "file", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/make_fast.py#L35-L53
[ "def", "find_includes", "(", "filename", ")", ":", "includes", "=", "[", "]", "with", "open", "(", "filename", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ")", "as", "inp", ":", "for", "line", "in", "inp", ":", "line", "=", "line", ".", "strip",...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
build_headermap
Construct dictionary {header_file : set_of_included_files}. This function operates on "real" set of includes, in the sense that it parses each header file to check which files are included from there.
ci/make_fast.py
def build_headermap(headers): """ Construct dictionary {header_file : set_of_included_files}. This function operates on "real" set of includes, in the sense that it parses each header file to check which files are included from there. """ # TODO: what happens if some headers are circularly depe...
def build_headermap(headers): """ Construct dictionary {header_file : set_of_included_files}. This function operates on "real" set of includes, in the sense that it parses each header file to check which files are included from there. """ # TODO: what happens if some headers are circularly depe...
[ "Construct", "dictionary", "{", "header_file", ":", "set_of_included_files", "}", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/make_fast.py#L56-L78
[ "def", "build_headermap", "(", "headers", ")", ":", "# TODO: what happens if some headers are circularly dependent?", "headermap", "=", "{", "}", "for", "hfile", "in", "headers", ":", "headermap", "[", "hfile", "]", "=", "None", "for", "hfile", "in", "headers", ":...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
build_sourcemap
Similar to build_headermap(), but builds a dictionary of includes from the "source" files (i.e. ".c/.cc" files).
ci/make_fast.py
def build_sourcemap(sources): """ Similar to build_headermap(), but builds a dictionary of includes from the "source" files (i.e. ".c/.cc" files). """ sourcemap = {} for sfile in sources: inc = find_includes(sfile) sourcemap[sfile] = set(inc) return sourcemap
def build_sourcemap(sources): """ Similar to build_headermap(), but builds a dictionary of includes from the "source" files (i.e. ".c/.cc" files). """ sourcemap = {} for sfile in sources: inc = find_includes(sfile) sourcemap[sfile] = set(inc) return sourcemap
[ "Similar", "to", "build_headermap", "()", "but", "builds", "a", "dictionary", "of", "includes", "from", "the", "source", "files", "(", "i", ".", "e", ".", ".", "c", "/", ".", "cc", "files", ")", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/ci/make_fast.py#L81-L90
[ "def", "build_sourcemap", "(", "sources", ")", ":", "sourcemap", "=", "{", "}", "for", "sfile", "in", "sources", ":", "inc", "=", "find_includes", "(", "sfile", ")", "sourcemap", "[", "sfile", "]", "=", "set", "(", "inc", ")", "return", "sourcemap" ]
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
get_c_sources
Find all C/C++ source files in the `folder` directory.
setup.py
def get_c_sources(folder, include_headers=False): """Find all C/C++ source files in the `folder` directory.""" allowed_extensions = [".c", ".C", ".cc", ".cpp", ".cxx", ".c++"] if include_headers: allowed_extensions += [".h", ".hpp"] sources = [] for root, _, files in os.walk(folder): ...
def get_c_sources(folder, include_headers=False): """Find all C/C++ source files in the `folder` directory.""" allowed_extensions = [".c", ".C", ".cc", ".cpp", ".cxx", ".c++"] if include_headers: allowed_extensions += [".h", ".hpp"] sources = [] for root, _, files in os.walk(folder): ...
[ "Find", "all", "C", "/", "C", "++", "source", "files", "in", "the", "folder", "directory", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/setup.py#L61-L76
[ "def", "get_c_sources", "(", "folder", ",", "include_headers", "=", "False", ")", ":", "allowed_extensions", "=", "[", "\".c\"", ",", "\".C\"", ",", "\".cc\"", ",", "\".cpp\"", ",", "\".cxx\"", ",", "\".c++\"", "]", "if", "include_headers", ":", "allowed_exten...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
GenericReader._get_destination
Invoked from the C level, this function will return either the name of the folder where the datatable is to be saved; or None, indicating that the datatable should be read into RAM. This function may also raise an exception if it determines that it cannot find a good strategy to handle a...
datatable/fread.py
def _get_destination(self, estimated_size): """ Invoked from the C level, this function will return either the name of the folder where the datatable is to be saved; or None, indicating that the datatable should be read into RAM. This function may also raise an exception if it de...
def _get_destination(self, estimated_size): """ Invoked from the C level, this function will return either the name of the folder where the datatable is to be saved; or None, indicating that the datatable should be read into RAM. This function may also raise an exception if it de...
[ "Invoked", "from", "the", "C", "level", "this", "function", "will", "return", "either", "the", "name", "of", "the", "folder", "where", "the", "datatable", "is", "to", "be", "saved", ";", "or", "None", "indicating", "that", "the", "datatable", "should", "be...
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/fread.py#L685-L735
[ "def", "_get_destination", "(", "self", ",", "estimated_size", ")", ":", "global", "_psutil_load_attempted", "if", "not", "_psutil_load_attempted", ":", "_psutil_load_attempted", "=", "True", "try", ":", "import", "psutil", "except", "ImportError", ":", "psutil", "=...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
save_nff
Save Frame in binary NFF/Jay format. :param dest: destination where the Frame should be saved. :param _strategy: one of "mmap", "write" or "auto"
datatable/nff.py
def save_nff(self, dest, _strategy="auto"): """ Save Frame in binary NFF/Jay format. :param dest: destination where the Frame should be saved. :param _strategy: one of "mmap", "write" or "auto" """ if _strategy not in ("auto", "write", "mmap"): raise TValueError("Invalid parameter _stra...
def save_nff(self, dest, _strategy="auto"): """ Save Frame in binary NFF/Jay format. :param dest: destination where the Frame should be saved. :param _strategy: one of "mmap", "write" or "auto" """ if _strategy not in ("auto", "write", "mmap"): raise TValueError("Invalid parameter _stra...
[ "Save", "Frame", "in", "binary", "NFF", "/", "Jay", "format", "." ]
h2oai/datatable
python
https://github.com/h2oai/datatable/blob/dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564/datatable/nff.py#L24-L61
[ "def", "save_nff", "(", "self", ",", "dest", ",", "_strategy", "=", "\"auto\"", ")", ":", "if", "_strategy", "not", "in", "(", "\"auto\"", ",", "\"write\"", ",", "\"mmap\"", ")", ":", "raise", "TValueError", "(", "\"Invalid parameter _strategy: only 'write' / 'm...
dd5fba74d2ca85b66f82ae3c1e0b6ea2fd792564
train
IMetricsService.event
Send an event.
warehouse/metrics/interfaces.py
def event( title, text, alert_type=None, aggregation_key=None, source_type_name=None, date_happened=None, priority=None, tags=None, hostname=None, ): """ Send an event. """
def event( title, text, alert_type=None, aggregation_key=None, source_type_name=None, date_happened=None, priority=None, tags=None, hostname=None, ): """ Send an event. """
[ "Send", "an", "event", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/metrics/interfaces.py#L80-L93
[ "def", "event", "(", "title", ",", "text", ",", "alert_type", "=", "None", ",", "aggregation_key", "=", "None", ",", "source_type_name", "=", "None", ",", "date_happened", "=", "None", ",", "priority", "=", "None", ",", "tags", "=", "None", ",", "hostnam...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
user_projects
Return all the projects for which the user is a sole owner
warehouse/manage/views.py
def user_projects(request): """ Return all the projects for which the user is a sole owner """ projects_owned = ( request.db.query(Project.id) .join(Role.project) .filter(Role.role_name == "Owner", Role.user == request.user) .subquery() ) with_sole_owner = ( requ...
def user_projects(request): """ Return all the projects for which the user is a sole owner """ projects_owned = ( request.db.query(Project.id) .join(Role.project) .filter(Role.role_name == "Owner", Role.user == request.user) .subquery() ) with_sole_owner = ( requ...
[ "Return", "all", "the", "projects", "for", "which", "the", "user", "is", "a", "sole", "owner" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/manage/views.py#L45-L73
[ "def", "user_projects", "(", "request", ")", ":", "projects_owned", "=", "(", "request", ".", "db", ".", "query", "(", "Project", ".", "id", ")", ".", "join", "(", "Role", ".", "project", ")", ".", "filter", "(", "Role", ".", "role_name", "==", "\"Ow...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
merge
Merge one or more revisions. Takes one or more revisions or "heads" for all heads and merges them into a single revision.
warehouse/cli/db/merge.py
def merge(config, revisions, **kwargs): """ Merge one or more revisions. Takes one or more revisions or "heads" for all heads and merges them into a single revision. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: ale...
def merge(config, revisions, **kwargs): """ Merge one or more revisions. Takes one or more revisions or "heads" for all heads and merges them into a single revision. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: ale...
[ "Merge", "one", "or", "more", "revisions", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/merge.py#L30-L40
[ "def", "merge", "(", "config", ",", "revisions", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config", ":",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
column_windows
Return a series of WHERE clauses against a given column that break it into windows. Result is an iterable of tuples, consisting of ((start, end), whereclause), where (start, end) are the ids. Requires a database that supports window functions, i.e. Postgresql, SQL Server, Oracle. Enhance this...
warehouse/utils/db/windowed_query.py
def column_windows(session, column, windowsize): """ Return a series of WHERE clauses against a given column that break it into windows. Result is an iterable of tuples, consisting of ((start, end), whereclause), where (start, end) are the ids. Requires a database that supports window function...
def column_windows(session, column, windowsize): """ Return a series of WHERE clauses against a given column that break it into windows. Result is an iterable of tuples, consisting of ((start, end), whereclause), where (start, end) are the ids. Requires a database that supports window function...
[ "Return", "a", "series", "of", "WHERE", "clauses", "against", "a", "given", "column", "that", "break", "it", "into", "windows", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/utils/db/windowed_query.py#L19-L56
[ "def", "column_windows", "(", "session", ",", "column", ",", "windowsize", ")", ":", "def", "int_for_range", "(", "start_id", ",", "end_id", ")", ":", "if", "end_id", ":", "return", "and_", "(", "column", ">=", "start_id", ",", "column", "<", "end_id", "...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
windowed_query
Break a Query into windows on a given column.
warehouse/utils/db/windowed_query.py
def windowed_query(q, column, windowsize): """" Break a Query into windows on a given column. """ for whereclause in column_windows(q.session, column, windowsize): for row in q.filter(whereclause).order_by(column): yield row
def windowed_query(q, column, windowsize): """" Break a Query into windows on a given column. """ for whereclause in column_windows(q.session, column, windowsize): for row in q.filter(whereclause).order_by(column): yield row
[ "Break", "a", "Query", "into", "windows", "on", "a", "given", "column", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/utils/db/windowed_query.py#L59-L66
[ "def", "windowed_query", "(", "q", ",", "column", ",", "windowsize", ")", ":", "for", "whereclause", "in", "column_windows", "(", "q", ".", "session", ",", "column", ",", "windowsize", ")", ":", "for", "row", "in", "q", ".", "filter", "(", "whereclause",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
filter_query
Filters given query with the below regex and returns lists of quoted and unquoted strings
warehouse/views.py
def filter_query(s): """ Filters given query with the below regex and returns lists of quoted and unquoted strings """ matches = re.findall(r'(?:"([^"]*)")|([^"]*)', s) result_quoted = [t[0].strip() for t in matches if t[0]] result_unquoted = [t[1].strip() for t in matches if t[1]] retur...
def filter_query(s): """ Filters given query with the below regex and returns lists of quoted and unquoted strings """ matches = re.findall(r'(?:"([^"]*)")|([^"]*)', s) result_quoted = [t[0].strip() for t in matches if t[0]] result_unquoted = [t[1].strip() for t in matches if t[1]] retur...
[ "Filters", "given", "query", "with", "the", "below", "regex", "and", "returns", "lists", "of", "quoted", "and", "unquoted", "strings" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/views.py#L444-L452
[ "def", "filter_query", "(", "s", ")", ":", "matches", "=", "re", ".", "findall", "(", "r'(?:\"([^\"]*)\")|([^\"]*)'", ",", "s", ")", "result_quoted", "=", "[", "t", "[", "0", "]", ".", "strip", "(", ")", "for", "t", "in", "matches", "if", "t", "[", ...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
form_query
Returns a multi match query
warehouse/views.py
def form_query(query_type, query): """ Returns a multi match query """ fields = [ field + "^" + str(SEARCH_BOOSTS[field]) if field in SEARCH_BOOSTS else field for field in SEARCH_FIELDS ] return Q("multi_match", fields=fields, query=query, type=query_type)
def form_query(query_type, query): """ Returns a multi match query """ fields = [ field + "^" + str(SEARCH_BOOSTS[field]) if field in SEARCH_BOOSTS else field for field in SEARCH_FIELDS ] return Q("multi_match", fields=fields, query=query, type=query_type)
[ "Returns", "a", "multi", "match", "query" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/views.py#L455-L463
[ "def", "form_query", "(", "query_type", ",", "query", ")", ":", "fields", "=", "[", "field", "+", "\"^\"", "+", "str", "(", "SEARCH_BOOSTS", "[", "field", "]", ")", "if", "field", "in", "SEARCH_BOOSTS", "else", "field", "for", "field", "in", "SEARCH_FIEL...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
run_migrations_offline
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
warehouse/migrations/env.py
def run_migrations_offline(): """ Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit ...
def run_migrations_offline(): """ Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit ...
[ "Run", "migrations", "in", "offline", "mode", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/migrations/env.py#L19-L35
[ "def", "run_migrations_offline", "(", ")", ":", "url", "=", "context", ".", "config", ".", "get_main_option", "(", "\"sqlalchemy.url\"", ")", "context", ".", "configure", "(", "url", "=", "url", ",", "compare_server_default", "=", "True", ")", "with", "context...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
run_migrations_online
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
warehouse/migrations/env.py
def run_migrations_online(): """ Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ connectable = context.config.attributes.get("connection", None) if connectable is None: options = context.config.get_secti...
def run_migrations_online(): """ Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context. """ connectable = context.config.attributes.get("connection", None) if connectable is None: options = context.config.get_secti...
[ "Run", "migrations", "in", "online", "mode", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/migrations/env.py#L38-L59
[ "def", "run_migrations_online", "(", ")", ":", "connectable", "=", "context", ".", "config", ".", "attributes", ".", "get", "(", "\"connection\"", ",", "None", ")", "if", "connectable", "is", "None", ":", "options", "=", "context", ".", "config", ".", "get...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
branches
Show current branch points.
warehouse/cli/db/branches.py
def branches(config, **kwargs): """ Show current branch points. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.branches(alembic_config, **kwargs)
def branches(config, **kwargs): """ Show current branch points. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.branches(alembic_config, **kwargs)
[ "Show", "current", "branch", "points", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/branches.py#L21-L28
[ "def", "branches", "(", "config", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config", ":", "alembic", "."...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
upgrade
Upgrade database.
warehouse/cli/db/upgrade.py
def upgrade(config, revision, **kwargs): """ Upgrade database. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.upgrade(alembic_config, revision, **kwargs)
def upgrade(config, revision, **kwargs): """ Upgrade database. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.upgrade(alembic_config, revision, **kwargs)
[ "Upgrade", "database", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/upgrade.py#L22-L29
[ "def", "upgrade", "(", "config", ",", "revision", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config", ":"...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
is_safe_url
Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url.
warehouse/utils/http.py
def is_safe_url(url, host=None): """ Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url. """ if url is not None: url = url.strip() if not url: return False # Chrome ...
def is_safe_url(url, host=None): """ Return ``True`` if the url is a safe redirection (i.e. it doesn't point to a different host and uses a safe scheme). Always returns ``False`` on an empty url. """ if url is not None: url = url.strip() if not url: return False # Chrome ...
[ "Return", "True", "if", "the", "url", "is", "a", "safe", "redirection", "(", "i", ".", "e", ".", "it", "doesn", "t", "point", "to", "a", "different", "host", "and", "uses", "a", "safe", "scheme", ")", ".", "Always", "returns", "False", "on", "an", ...
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/utils/http.py#L22-L53
[ "def", "is_safe_url", "(", "url", ",", "host", "=", "None", ")", ":", "if", "url", "is", "not", "None", ":", "url", "=", "url", ".", "strip", "(", ")", "if", "not", "url", ":", "return", "False", "# Chrome treats \\ completely as /", "url", "=", "url",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
_clean_for_xml
Sanitize any user-submitted data to ensure that it can be used in XML
warehouse/legacy/api/xmlrpc/views.py
def _clean_for_xml(data): """ Sanitize any user-submitted data to ensure that it can be used in XML """ # If data is None or an empty string, don't bother if data: # This turns a string like "Hello…" into "Hello&#8230;" data = data.encode("ascii", "xmlcharrefreplace").decode("ascii") ...
def _clean_for_xml(data): """ Sanitize any user-submitted data to ensure that it can be used in XML """ # If data is None or an empty string, don't bother if data: # This turns a string like "Hello…" into "Hello&#8230;" data = data.encode("ascii", "xmlcharrefreplace").decode("ascii") ...
[ "Sanitize", "any", "user", "-", "submitted", "data", "to", "ensure", "that", "it", "can", "be", "used", "in", "XML" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/legacy/api/xmlrpc/views.py#L79-L89
[ "def", "_clean_for_xml", "(", "data", ")", ":", "# If data is None or an empty string, don't bother", "if", "data", ":", "# This turns a string like \"Hello…\" into \"Hello&#8230;\"", "data", "=", "data", ".", "encode", "(", "\"ascii\"", ",", "\"xmlcharrefreplace\"", ")", "...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
submit_xmlrpc_metrics
Submit metrics.
warehouse/legacy/api/xmlrpc/views.py
def submit_xmlrpc_metrics(method=None): """ Submit metrics. """ def decorator(f): def wrapped(context, request): metrics = request.find_service(IMetricsService, context=None) metrics.increment("warehouse.xmlrpc.call", tags=[f"rpc_method:{method}"]) with metri...
def submit_xmlrpc_metrics(method=None): """ Submit metrics. """ def decorator(f): def wrapped(context, request): metrics = request.find_service(IMetricsService, context=None) metrics.increment("warehouse.xmlrpc.call", tags=[f"rpc_method:{method}"]) with metri...
[ "Submit", "metrics", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/legacy/api/xmlrpc/views.py#L92-L108
[ "def", "submit_xmlrpc_metrics", "(", "method", "=", "None", ")", ":", "def", "decorator", "(", "f", ")", ":", "def", "wrapped", "(", "context", ",", "request", ")", ":", "metrics", "=", "request", ".", "find_service", "(", "IMetricsService", ",", "context"...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
xmlrpc_method
Support multiple endpoints serving the same views by chaining calls to xmlrpc_method
warehouse/legacy/api/xmlrpc/views.py
def xmlrpc_method(**kwargs): """ Support multiple endpoints serving the same views by chaining calls to xmlrpc_method """ # Add some default arguments kwargs.update( require_csrf=False, require_methods=["POST"], decorator=(submit_xmlrpc_metrics(method=kwargs["method"]),),...
def xmlrpc_method(**kwargs): """ Support multiple endpoints serving the same views by chaining calls to xmlrpc_method """ # Add some default arguments kwargs.update( require_csrf=False, require_methods=["POST"], decorator=(submit_xmlrpc_metrics(method=kwargs["method"]),),...
[ "Support", "multiple", "endpoints", "serving", "the", "same", "views", "by", "chaining", "calls", "to", "xmlrpc_method" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/legacy/api/xmlrpc/views.py#L111-L130
[ "def", "xmlrpc_method", "(", "*", "*", "kwargs", ")", ":", "# Add some default arguments", "kwargs", ".", "update", "(", "require_csrf", "=", "False", ",", "require_methods", "=", "[", "\"POST\"", "]", ",", "decorator", "=", "(", "submit_xmlrpc_metrics", "(", ...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
current
Display the current revision for a database.
warehouse/cli/db/current.py
def current(config, **kwargs): """ Display the current revision for a database. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.current(alembic_config, **kwargs)
def current(config, **kwargs): """ Display the current revision for a database. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.current(alembic_config, **kwargs)
[ "Display", "the", "current", "revision", "for", "a", "database", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/current.py#L21-L28
[ "def", "current", "(", "config", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config", ":", "alembic", ".",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
_is_valid_dist_file
Perform some basic checks to see whether the indicated file could be a valid distribution file.
warehouse/forklift/legacy.py
def _is_valid_dist_file(filename, filetype): """ Perform some basic checks to see whether the indicated file could be a valid distribution file. """ # If our file is a zipfile, then ensure that it's members are only # compressed with supported compression methods. if zipfile.is_zipfile(file...
def _is_valid_dist_file(filename, filetype): """ Perform some basic checks to see whether the indicated file could be a valid distribution file. """ # If our file is a zipfile, then ensure that it's members are only # compressed with supported compression methods. if zipfile.is_zipfile(file...
[ "Perform", "some", "basic", "checks", "to", "see", "whether", "the", "indicated", "file", "could", "be", "a", "valid", "distribution", "file", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/forklift/legacy.py#L555-L635
[ "def", "_is_valid_dist_file", "(", "filename", ",", "filetype", ")", ":", "# If our file is a zipfile, then ensure that it's members are only", "# compressed with supported compression methods.", "if", "zipfile", ".", "is_zipfile", "(", "filename", ")", ":", "with", "zipfile", ...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
_is_duplicate_file
Check to see if file already exists, and if it's content matches. A file is considered to exist if its filename *or* blake2 digest are present in a file row in the database. Returns: - True: This file is a duplicate and all further processing should halt. - False: This file exists, but it is not a ...
warehouse/forklift/legacy.py
def _is_duplicate_file(db_session, filename, hashes): """ Check to see if file already exists, and if it's content matches. A file is considered to exist if its filename *or* blake2 digest are present in a file row in the database. Returns: - True: This file is a duplicate and all further proce...
def _is_duplicate_file(db_session, filename, hashes): """ Check to see if file already exists, and if it's content matches. A file is considered to exist if its filename *or* blake2 digest are present in a file row in the database. Returns: - True: This file is a duplicate and all further proce...
[ "Check", "to", "see", "if", "file", "already", "exists", "and", "if", "it", "s", "content", "matches", ".", "A", "file", "is", "considered", "to", "exist", "if", "its", "filename", "*", "or", "*", "blake2", "digest", "are", "present", "in", "a", "file"...
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/forklift/legacy.py#L638-L667
[ "def", "_is_duplicate_file", "(", "db_session", ",", "filename", ",", "hashes", ")", ":", "file_", "=", "(", "db_session", ".", "query", "(", "File", ")", ".", "filter", "(", "(", "File", ".", "filename", "==", "filename", ")", "|", "(", "File", ".", ...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
shell
Open up a Python shell with Warehouse preconfigured in it.
warehouse/cli/shell.py
def shell(config, type_): """ Open up a Python shell with Warehouse preconfigured in it. """ # Imported here because we don't want to trigger an import from anything # but warehouse.cli at the module scope. from warehouse.db import Session if type_ is None: type_ = autodetect() ...
def shell(config, type_): """ Open up a Python shell with Warehouse preconfigured in it. """ # Imported here because we don't want to trigger an import from anything # but warehouse.cli at the module scope. from warehouse.db import Session if type_ is None: type_ = autodetect() ...
[ "Open", "up", "a", "Python", "shell", "with", "Warehouse", "preconfigured", "in", "it", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/shell.py#L60-L81
[ "def", "shell", "(", "config", ",", "type_", ")", ":", "# Imported here because we don't want to trigger an import from anything", "# but warehouse.cli at the module scope.", "from", "warehouse", ".", "db", "import", "Session", "if", "type_", "is", "None", ":", "type_", "...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
_email
This decorator is used to turn an e function into an email sending function! The name parameter is the name of the email we're going to be sending (used to locate the templates on the file system). The allow_unverified kwarg flags whether we will send this email to an unverified email or not. We gener...
warehouse/email/__init__.py
def _email(name, *, allow_unverified=False): """ This decorator is used to turn an e function into an email sending function! The name parameter is the name of the email we're going to be sending (used to locate the templates on the file system). The allow_unverified kwarg flags whether we will se...
def _email(name, *, allow_unverified=False): """ This decorator is used to turn an e function into an email sending function! The name parameter is the name of the email we're going to be sending (used to locate the templates on the file system). The allow_unverified kwarg flags whether we will se...
[ "This", "decorator", "is", "used", "to", "turn", "an", "e", "function", "into", "an", "email", "sending", "function!" ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/email/__init__.py#L64-L121
[ "def", "_email", "(", "name", ",", "*", ",", "allow_unverified", "=", "False", ")", ":", "def", "inner", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "wrapper", "(", "request", ",", "user_or_users", ",", "*", "*", "kw...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
history
List changeset scripts in chronological order.
warehouse/cli/db/history.py
def history(config, revision_range, **kwargs): """ List changeset scripts in chronological order. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.history(alembic_config, revision_range, **kwargs)
def history(config, revision_range, **kwargs): """ List changeset scripts in chronological order. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.history(alembic_config, revision_range, **kwargs)
[ "List", "changeset", "scripts", "in", "chronological", "order", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/history.py#L22-L29
[ "def", "history", "(", "config", ",", "revision_range", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
reindex
Recreate the Search Index.
warehouse/cli/search.py
def reindex(config): """ Recreate the Search Index. """ request = config.task(_reindex).get_request() config.task(_reindex).run(request)
def reindex(config): """ Recreate the Search Index. """ request = config.task(_reindex).get_request() config.task(_reindex).run(request)
[ "Recreate", "the", "Search", "Index", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/search.py#L28-L34
[ "def", "reindex", "(", "config", ")", ":", "request", "=", "config", ".", "task", "(", "_reindex", ")", ".", "get_request", "(", ")", "config", ".", "task", "(", "_reindex", ")", ".", "run", "(", "request", ")" ]
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
heads
Show current available heads.
warehouse/cli/db/heads.py
def heads(config, **kwargs): """ Show current available heads. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.heads(alembic_config, **kwargs)
def heads(config, **kwargs): """ Show current available heads. """ with alembic_lock( config.registry["sqlalchemy.engine"], config.alembic_config() ) as alembic_config: alembic.command.heads(alembic_config, **kwargs)
[ "Show", "current", "available", "heads", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/heads.py#L27-L34
[ "def", "heads", "(", "config", ",", "*", "*", "kwargs", ")", ":", "with", "alembic_lock", "(", "config", ".", "registry", "[", "\"sqlalchemy.engine\"", "]", ",", "config", ".", "alembic_config", "(", ")", ")", "as", "alembic_config", ":", "alembic", ".", ...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
reindex
Recreate the Search Index.
warehouse/search/tasks.py
def reindex(self, request): """ Recreate the Search Index. """ r = redis.StrictRedis.from_url(request.registry.settings["celery.scheduler_url"]) try: with SearchLock(r, timeout=30 * 60, blocking_timeout=30): p = urllib.parse.urlparse(request.registry.settings["elasticsearch.url"]...
def reindex(self, request): """ Recreate the Search Index. """ r = redis.StrictRedis.from_url(request.registry.settings["celery.scheduler_url"]) try: with SearchLock(r, timeout=30 * 60, blocking_timeout=30): p = urllib.parse.urlparse(request.registry.settings["elasticsearch.url"]...
[ "Recreate", "the", "Search", "Index", "." ]
pypa/warehouse
python
https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/search/tasks.py#L121-L205
[ "def", "reindex", "(", "self", ",", "request", ")", ":", "r", "=", "redis", ".", "StrictRedis", ".", "from_url", "(", "request", ".", "registry", ".", "settings", "[", "\"celery.scheduler_url\"", "]", ")", "try", ":", "with", "SearchLock", "(", "r", ",",...
396e77a0caf6efeccb5a5f86e2c8a27e575bf86d
train
OutputListApi.get
API endpoint to retrieve a list of links to transaction outputs. Returns: A :obj:`list` of :cls:`str` of links to outputs.
bigchaindb/web/views/outputs.py
def get(self): """API endpoint to retrieve a list of links to transaction outputs. Returns: A :obj:`list` of :cls:`str` of links to outputs. """ parser = reqparse.RequestParser() parser.add_argument('public_key', type=parameters.valid_ed25519, ...
def get(self): """API endpoint to retrieve a list of links to transaction outputs. Returns: A :obj:`list` of :cls:`str` of links to outputs. """ parser = reqparse.RequestParser() parser.add_argument('public_key', type=parameters.valid_ed25519, ...
[ "API", "endpoint", "to", "retrieve", "a", "list", "of", "links", "to", "transaction", "outputs", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/outputs.py#L12-L30
[ "def", "get", "(", "self", ")", ":", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", ".", "add_argument", "(", "'public_key'", ",", "type", "=", "parameters", ".", "valid_ed25519", ",", "required", "=", "True", ")", "parser", ".", "a...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_show_config
Show the current configuration
bigchaindb/commands/bigchaindb.py
def run_show_config(args): """Show the current configuration""" # TODO Proposal: remove the "hidden" configuration. Only show config. If # the system needs to be configured, then display information on how to # configure the system. config = copy.deepcopy(bigchaindb.config) del config['CONFIGURE...
def run_show_config(args): """Show the current configuration""" # TODO Proposal: remove the "hidden" configuration. Only show config. If # the system needs to be configured, then display information on how to # configure the system. config = copy.deepcopy(bigchaindb.config) del config['CONFIGURE...
[ "Show", "the", "current", "configuration" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L45-L52
[ "def", "run_show_config", "(", "args", ")", ":", "# TODO Proposal: remove the \"hidden\" configuration. Only show config. If", "# the system needs to be configured, then display information on how to", "# configure the system.", "config", "=", "copy", ".", "deepcopy", "(", "bigchaindb"...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_configure
Run a script to configure the current node.
bigchaindb/commands/bigchaindb.py
def run_configure(args): """Run a script to configure the current node.""" config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH config_file_exists = False # if the config path is `-` then it's stdout if config_path != '-': config_file_exists = os.path.exists(config_path)...
def run_configure(args): """Run a script to configure the current node.""" config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH config_file_exists = False # if the config path is `-` then it's stdout if config_path != '-': config_file_exists = os.path.exists(config_path)...
[ "Run", "a", "script", "to", "configure", "the", "current", "node", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L56-L101
[ "def", "run_configure", "(", "args", ")", ":", "config_path", "=", "args", ".", "config", "or", "bigchaindb", ".", "config_utils", ".", "CONFIG_DEFAULT_PATH", "config_file_exists", "=", "False", "# if the config path is `-` then it's stdout", "if", "config_path", "!=", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_election_new_upsert_validator
Initiates an election to add/update/remove a validator to an existing BigchainDB network :param args: dict args = { 'public_key': the public key of the proposed peer, (str) 'power': the proposed validator power for the new peer, (str) 'node_id': the node_id of the new peer (str) ...
bigchaindb/commands/bigchaindb.py
def run_election_new_upsert_validator(args, bigchain): """Initiates an election to add/update/remove a validator to an existing BigchainDB network :param args: dict args = { 'public_key': the public key of the proposed peer, (str) 'power': the proposed validator power for the new peer, ...
def run_election_new_upsert_validator(args, bigchain): """Initiates an election to add/update/remove a validator to an existing BigchainDB network :param args: dict args = { 'public_key': the public key of the proposed peer, (str) 'power': the proposed validator power for the new peer, ...
[ "Initiates", "an", "election", "to", "add", "/", "update", "/", "remove", "a", "validator", "to", "an", "existing", "BigchainDB", "network" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L143-L164
[ "def", "run_election_new_upsert_validator", "(", "args", ",", "bigchain", ")", ":", "new_validator", "=", "{", "'public_key'", ":", "{", "'value'", ":", "public_key_from_base64", "(", "args", ".", "public_key", ")", ",", "'type'", ":", "'ed25519-base16'", "}", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_election_approve
Approve an election :param args: dict args = { 'election_id': the election_id of the election (str) 'sk': the path to the private key of the signer (str) } :param bigchain: an instance of BigchainDB :return: success log message or `False` in case of error
bigchaindb/commands/bigchaindb.py
def run_election_approve(args, bigchain): """Approve an election :param args: dict args = { 'election_id': the election_id of the election (str) 'sk': the path to the private key of the signer (str) } :param bigchain: an instance of BigchainDB :return: success log messag...
def run_election_approve(args, bigchain): """Approve an election :param args: dict args = { 'election_id': the election_id of the election (str) 'sk': the path to the private key of the signer (str) } :param bigchain: an instance of BigchainDB :return: success log messag...
[ "Approve", "an", "election" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L181-L216
[ "def", "run_election_approve", "(", "args", ",", "bigchain", ")", ":", "key", "=", "load_node_key", "(", "args", ".", "sk", ")", "tx", "=", "bigchain", ".", "get_transaction", "(", "args", ".", "election_id", ")", "voting_powers", "=", "[", "v", ".", "am...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_election_show
Retrieves information about an election :param args: dict args = { 'election_id': the transaction_id for an election (str) } :param bigchain: an instance of BigchainDB
bigchaindb/commands/bigchaindb.py
def run_election_show(args, bigchain): """Retrieves information about an election :param args: dict args = { 'election_id': the transaction_id for an election (str) } :param bigchain: an instance of BigchainDB """ election = bigchain.get_transaction(args.election_id) if...
def run_election_show(args, bigchain): """Retrieves information about an election :param args: dict args = { 'election_id': the transaction_id for an election (str) } :param bigchain: an instance of BigchainDB """ election = bigchain.get_transaction(args.election_id) if...
[ "Retrieves", "information", "about", "an", "election" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L219-L238
[ "def", "run_election_show", "(", "args", ",", "bigchain", ")", ":", "election", "=", "bigchain", ".", "get_transaction", "(", "args", ".", "election_id", ")", "if", "not", "election", ":", "logger", ".", "error", "(", "f'No election found with election_id {args.el...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_drop
Drop the database
bigchaindb/commands/bigchaindb.py
def run_drop(args): """Drop the database""" dbname = bigchaindb.config['database']['name'] if not args.yes: response = input_on_stderr('Do you want to drop `{}` database? [y/n]: '.format(dbname)) if response != 'y': return conn = backend.connect() dbname = bigchaindb.co...
def run_drop(args): """Drop the database""" dbname = bigchaindb.config['database']['name'] if not args.yes: response = input_on_stderr('Do you want to drop `{}` database? [y/n]: '.format(dbname)) if response != 'y': return conn = backend.connect() dbname = bigchaindb.co...
[ "Drop", "the", "database" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L254-L268
[ "def", "run_drop", "(", "args", ")", ":", "dbname", "=", "bigchaindb", ".", "config", "[", "'database'", "]", "[", "'name'", "]", "if", "not", "args", ".", "yes", ":", "response", "=", "input_on_stderr", "(", "'Do you want to drop `{}` database? [y/n]: '", "."...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_start
Start the processes to run the node
bigchaindb/commands/bigchaindb.py
def run_start(args): """Start the processes to run the node""" # Configure Logging setup_logging() logger.info('BigchainDB Version %s', bigchaindb.__version__) run_recover(bigchaindb.lib.BigchainDB()) if not args.skip_initialize_database: logger.info('Initializing database') _...
def run_start(args): """Start the processes to run the node""" # Configure Logging setup_logging() logger.info('BigchainDB Version %s', bigchaindb.__version__) run_recover(bigchaindb.lib.BigchainDB()) if not args.skip_initialize_database: logger.info('Initializing database') _...
[ "Start", "the", "processes", "to", "run", "the", "node" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L276-L291
[ "def", "run_start", "(", "args", ")", ":", "# Configure Logging", "setup_logging", "(", ")", "logger", ".", "info", "(", "'BigchainDB Version %s'", ",", "bigchaindb", ".", "__version__", ")", "run_recover", "(", "bigchaindb", ".", "lib", ".", "BigchainDB", "(", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
run_tendermint_version
Show the supported Tendermint version(s)
bigchaindb/commands/bigchaindb.py
def run_tendermint_version(args): """Show the supported Tendermint version(s)""" supported_tm_ver = { 'description': 'BigchainDB supports the following Tendermint version(s)', 'tendermint': __tm_supported_versions__, } print(json.dumps(supported_tm_ver, indent=4, sort_keys=True))
def run_tendermint_version(args): """Show the supported Tendermint version(s)""" supported_tm_ver = { 'description': 'BigchainDB supports the following Tendermint version(s)', 'tendermint': __tm_supported_versions__, } print(json.dumps(supported_tm_ver, indent=4, sort_keys=True))
[ "Show", "the", "supported", "Tendermint", "version", "(", "s", ")" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/bigchaindb.py#L294-L300
[ "def", "run_tendermint_version", "(", "args", ")", ":", "supported_tm_ver", "=", "{", "'description'", ":", "'BigchainDB supports the following Tendermint version(s)'", ",", "'tendermint'", ":", "__tm_supported_versions__", ",", "}", "print", "(", "json", ".", "dumps", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
text_search
Return all the assets that match the text search. The results are sorted by text score. For more information about the behavior of text search on MongoDB see https://docs.mongodb.com/manual/reference/operator/query/text/#behavior Args: search (str): Text search string to query the text index ...
bigchaindb/backend/query.py
def text_search(conn, search, *, language='english', case_sensitive=False, diacritic_sensitive=False, text_score=False, limit=0, table=None): """Return all the assets that match the text search. The results are sorted by text score. For more information about the behavior of text search on ...
def text_search(conn, search, *, language='english', case_sensitive=False, diacritic_sensitive=False, text_score=False, limit=0, table=None): """Return all the assets that match the text search. The results are sorted by text score. For more information about the behavior of text search on ...
[ "Return", "all", "the", "assets", "that", "match", "the", "text", "search", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/query.py#L217-L246
[ "def", "text_search", "(", "conn", ",", "search", ",", "*", ",", "language", "=", "'english'", ",", "case_sensitive", "=", "False", ",", "diacritic_sensitive", "=", "False", ",", "text_score", "=", "False", ",", "limit", "=", "0", ",", "table", "=", "Non...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
main
Main function
docs/server/generate_http_server_api_documentation.py
def main(): """ Main function """ ctx = {} def pretty_json(data): return json.dumps(data, indent=2, sort_keys=True) client = server.create_app().test_client() host = 'example.com:9984' # HTTP Index res = client.get('/', environ_overrides={'HTTP_HOST': host}) res_data = json....
def main(): """ Main function """ ctx = {} def pretty_json(data): return json.dumps(data, indent=2, sort_keys=True) client = server.create_app().test_client() host = 'example.com:9984' # HTTP Index res = client.get('/', environ_overrides={'HTTP_HOST': host}) res_data = json....
[ "Main", "function" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/docs/server/generate_http_server_api_documentation.py#L110-L197
[ "def", "main", "(", ")", ":", "ctx", "=", "{", "}", "def", "pretty_json", "(", "data", ")", ":", "return", "json", ".", "dumps", "(", "data", ",", "indent", "=", "2", ",", "sort_keys", "=", "True", ")", "client", "=", "server", ".", "create_app", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
serialize
Serialize a dict into a JSON formatted string. This function enforces rules like the separator and order of keys. This ensures that all dicts are serialized in the same way. This is specially important for hashing data. We need to make sure that everyone serializes their data in the sa...
bigchaindb/common/utils.py
def serialize(data): """Serialize a dict into a JSON formatted string. This function enforces rules like the separator and order of keys. This ensures that all dicts are serialized in the same way. This is specially important for hashing data. We need to make sure that everyone ser...
def serialize(data): """Serialize a dict into a JSON formatted string. This function enforces rules like the separator and order of keys. This ensures that all dicts are serialized in the same way. This is specially important for hashing data. We need to make sure that everyone ser...
[ "Serialize", "a", "dict", "into", "a", "JSON", "formatted", "string", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/utils.py#L23-L42
[ "def", "serialize", "(", "data", ")", ":", "return", "rapidjson", ".", "dumps", "(", "data", ",", "skipkeys", "=", "False", ",", "ensure_ascii", "=", "False", ",", "sort_keys", "=", "True", ")" ]
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
validate_txn_obj
Validate value of `key` in `obj` using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. key (str): key to be validated in `obj`. validation_fun (function): function used to validate the value of `k...
bigchaindb/common/utils.py
def validate_txn_obj(obj_name, obj, key, validation_fun): """Validate value of `key` in `obj` using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. key (str): key to be validated in `obj`. validation_fun ...
def validate_txn_obj(obj_name, obj, key, validation_fun): """Validate value of `key` in `obj` using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. key (str): key to be validated in `obj`. validation_fun ...
[ "Validate", "value", "of", "key", "in", "obj", "using", "validation_fun", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/utils.py#L58-L81
[ "def", "validate_txn_obj", "(", "obj_name", ",", "obj", ",", "key", ",", "validation_fun", ")", ":", "backend", "=", "bigchaindb", ".", "config", "[", "'database'", "]", "[", "'backend'", "]", "if", "backend", "==", "'localmongodb'", ":", "data", "=", "obj...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
validate_all_keys_in_obj
Validate all (nested) keys in `obj` by using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. validation_fun (function): function used to validate the value of `key`. Returns: None: indica...
bigchaindb/common/utils.py
def validate_all_keys_in_obj(obj_name, obj, validation_fun): """Validate all (nested) keys in `obj` by using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. validation_fun (function): function used to validate the va...
def validate_all_keys_in_obj(obj_name, obj, validation_fun): """Validate all (nested) keys in `obj` by using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. validation_fun (function): function used to validate the va...
[ "Validate", "all", "(", "nested", ")", "keys", "in", "obj", "by", "using", "validation_fun", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/utils.py#L92-L112
[ "def", "validate_all_keys_in_obj", "(", "obj_name", ",", "obj", ",", "validation_fun", ")", ":", "for", "key", ",", "value", "in", "obj", ".", "items", "(", ")", ":", "validation_fun", "(", "obj_name", ",", "key", ")", "if", "isinstance", "(", "value", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
validate_all_values_for_key_in_obj
Validate value for all (nested) occurrence of `key` in `obj` using `validation_fun`. Args: obj (dict): dictionary object. key (str): key whose value is to be validated. validation_fun (function): function used to validate the value of `key`. Rais...
bigchaindb/common/utils.py
def validate_all_values_for_key_in_obj(obj, key, validation_fun): """Validate value for all (nested) occurrence of `key` in `obj` using `validation_fun`. Args: obj (dict): dictionary object. key (str): key whose value is to be validated. validation_fun (function)...
def validate_all_values_for_key_in_obj(obj, key, validation_fun): """Validate value for all (nested) occurrence of `key` in `obj` using `validation_fun`. Args: obj (dict): dictionary object. key (str): key whose value is to be validated. validation_fun (function)...
[ "Validate", "value", "for", "all", "(", "nested", ")", "occurrence", "of", "key", "in", "obj", "using", "validation_fun", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/utils.py#L115-L134
[ "def", "validate_all_values_for_key_in_obj", "(", "obj", ",", "key", ",", "validation_fun", ")", ":", "for", "vkey", ",", "value", "in", "obj", ".", "items", "(", ")", ":", "if", "vkey", "==", "key", ":", "validation_fun", "(", "value", ")", "elif", "isi...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
validate_key
Check if `key` contains ".", "$" or null characters. https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names Args: obj_name (str): object name to use when raising exception key (str): key to validated Returns: None: validation successfu...
bigchaindb/common/utils.py
def validate_key(obj_name, key): """Check if `key` contains ".", "$" or null characters. https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names Args: obj_name (str): object name to use when raising exception key (str): key to validated Returns...
def validate_key(obj_name, key): """Check if `key` contains ".", "$" or null characters. https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names Args: obj_name (str): object name to use when raising exception key (str): key to validated Returns...
[ "Check", "if", "key", "contains", ".", "$", "or", "null", "characters", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/utils.py#L145-L164
[ "def", "validate_key", "(", "obj_name", ",", "key", ")", ":", "if", "re", ".", "search", "(", "r'^[$]|\\.|\\x00'", ",", "key", ")", ":", "error_str", "=", "(", "'Invalid key name \"{}\" in {} object. The '", "'key name cannot contain characters '", "'\".\", \"$\" or nul...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
create_app
Return an instance of the Flask application. Args: debug (bool): a flag to activate the debug mode for the app (default: False). threads (int): number of threads to use Return: an instance of the Flask application.
bigchaindb/web/server.py
def create_app(*, debug=False, threads=1, bigchaindb_factory=None): """Return an instance of the Flask application. Args: debug (bool): a flag to activate the debug mode for the app (default: False). threads (int): number of threads to use Return: an instance of the Flas...
def create_app(*, debug=False, threads=1, bigchaindb_factory=None): """Return an instance of the Flask application. Args: debug (bool): a flag to activate the debug mode for the app (default: False). threads (int): number of threads to use Return: an instance of the Flas...
[ "Return", "an", "instance", "of", "the", "Flask", "application", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/server.py#L62-L87
[ "def", "create_app", "(", "*", ",", "debug", "=", "False", ",", "threads", "=", "1", ",", "bigchaindb_factory", "=", "None", ")", ":", "if", "not", "bigchaindb_factory", ":", "bigchaindb_factory", "=", "BigchainDB", "app", "=", "Flask", "(", "__name__", ")...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
create_server
Wrap and return an application ready to be run. Args: settings (dict): a dictionary containing the settings, more info here http://docs.gunicorn.org/en/latest/settings.html Return: an initialized instance of the application.
bigchaindb/web/server.py
def create_server(settings, log_config=None, bigchaindb_factory=None): """Wrap and return an application ready to be run. Args: settings (dict): a dictionary containing the settings, more info here http://docs.gunicorn.org/en/latest/settings.html Return: an initialized instance...
def create_server(settings, log_config=None, bigchaindb_factory=None): """Wrap and return an application ready to be run. Args: settings (dict): a dictionary containing the settings, more info here http://docs.gunicorn.org/en/latest/settings.html Return: an initialized instance...
[ "Wrap", "and", "return", "an", "application", "ready", "to", "be", "run", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/server.py#L90-L117
[ "def", "create_server", "(", "settings", ",", "log_config", "=", "None", ",", "bigchaindb_factory", "=", "None", ")", ":", "settings", "=", "copy", ".", "deepcopy", "(", "settings", ")", "if", "not", "settings", ".", "get", "(", "'workers'", ")", ":", "s...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
setup_logging
Function to configure log hadlers. .. important:: Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the state of :obj:`bigchaindb.config` at the mo...
bigchaindb/log.py
def setup_logging(): """Function to configure log hadlers. .. important:: Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the state of :obj:`...
def setup_logging(): """Function to configure log hadlers. .. important:: Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the state of :obj:`...
[ "Function", "to", "configure", "log", "hadlers", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/log.py#L72-L129
[ "def", "setup_logging", "(", ")", ":", "logging_configs", "=", "DEFAULT_LOGGING_CONFIG", "new_logging_configs", "=", "bigchaindb", ".", "config", "[", "'log'", "]", "if", "'file'", "in", "new_logging_configs", ":", "filename", "=", "new_logging_configs", "[", "'file...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
get_api_v1_info
Return a dict with all the information specific for the v1 of the api.
bigchaindb/web/views/info.py
def get_api_v1_info(api_prefix): """Return a dict with all the information specific for the v1 of the api. """ websocket_root = base_ws_uri() + EVENTS_ENDPOINT docs_url = [ 'https://docs.bigchaindb.com/projects/server/en/v', version.__version__, '/http-client-server-api.html'...
def get_api_v1_info(api_prefix): """Return a dict with all the information specific for the v1 of the api. """ websocket_root = base_ws_uri() + EVENTS_ENDPOINT docs_url = [ 'https://docs.bigchaindb.com/projects/server/en/v', version.__version__, '/http-client-server-api.html'...
[ "Return", "a", "dict", "with", "all", "the", "information", "specific", "for", "the", "v1", "of", "the", "api", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/info.py#L36-L56
[ "def", "get_api_v1_info", "(", "api_prefix", ")", ":", "websocket_root", "=", "base_ws_uri", "(", ")", "+", "EVENTS_ENDPOINT", "docs_url", "=", "[", "'https://docs.bigchaindb.com/projects/server/en/v'", ",", "version", ".", "__version__", ",", "'/http-client-server-api.ht...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
configure_bigchaindb
Decorator to be used by command line functions, such that the configuration of bigchaindb is performed before the execution of the command. Args: command: The command to decorate. Returns: The command wrapper function.
bigchaindb/commands/utils.py
def configure_bigchaindb(command): """Decorator to be used by command line functions, such that the configuration of bigchaindb is performed before the execution of the command. Args: command: The command to decorate. Returns: The command wrapper function. """ @functools.w...
def configure_bigchaindb(command): """Decorator to be used by command line functions, such that the configuration of bigchaindb is performed before the execution of the command. Args: command: The command to decorate. Returns: The command wrapper function. """ @functools.w...
[ "Decorator", "to", "be", "used", "by", "command", "line", "functions", "such", "that", "the", "configuration", "of", "bigchaindb", "is", "performed", "before", "the", "execution", "of", "the", "command", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/utils.py#L20-L50
[ "def", "configure_bigchaindb", "(", "command", ")", ":", "@", "functools", ".", "wraps", "(", "command", ")", "def", "configure", "(", "args", ")", ":", "config_from_cmdline", "=", "None", "try", ":", "if", "args", ".", "log_level", "is", "not", "None", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
input_on_stderr
Output a string to stderr and wait for input. Args: prompt (str): the message to display. default: the default value to return if the user leaves the field empty convert (callable): a callable to be used to convert the value the user inserted. If None, the type of ...
bigchaindb/commands/utils.py
def input_on_stderr(prompt='', default=None, convert=None): """Output a string to stderr and wait for input. Args: prompt (str): the message to display. default: the default value to return if the user leaves the field empty convert (callable): a callable to be used to conve...
def input_on_stderr(prompt='', default=None, convert=None): """Output a string to stderr and wait for input. Args: prompt (str): the message to display. default: the default value to return if the user leaves the field empty convert (callable): a callable to be used to conve...
[ "Output", "a", "string", "to", "stderr", "and", "wait", "for", "input", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/utils.py#L82-L96
[ "def", "input_on_stderr", "(", "prompt", "=", "''", ",", "default", "=", "None", ",", "convert", "=", "None", ")", ":", "print", "(", "prompt", ",", "end", "=", "''", ",", "file", "=", "sys", ".", "stderr", ")", "value", "=", "builtins", ".", "inpu...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
start
Utility function to execute a subcommand. The function will look up in the ``scope`` if there is a function called ``run_<parser.args.command>`` and will run it using ``parser.args`` as first positional argument. Args: parser: an ArgumentParser instance. argv: the list of command line ...
bigchaindb/commands/utils.py
def start(parser, argv, scope): """Utility function to execute a subcommand. The function will look up in the ``scope`` if there is a function called ``run_<parser.args.command>`` and will run it using ``parser.args`` as first positional argument. Args: parser: an ArgumentParser instance. ...
def start(parser, argv, scope): """Utility function to execute a subcommand. The function will look up in the ``scope`` if there is a function called ``run_<parser.args.command>`` and will run it using ``parser.args`` as first positional argument. Args: parser: an ArgumentParser instance. ...
[ "Utility", "function", "to", "execute", "a", "subcommand", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/commands/utils.py#L99-L137
[ "def", "start", "(", "parser", ",", "argv", ",", "scope", ")", ":", "args", "=", "parser", ".", "parse_args", "(", "argv", ")", "if", "not", "args", ".", "command", ":", "parser", ".", "print_help", "(", ")", "raise", "SystemExit", "(", ")", "# look ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
AssetListApi.get
API endpoint to perform a text search on the assets. Args: search (str): Text search string to query the text index limit (int, optional): Limit the number of returned documents. Return: A list of assets that match the query.
bigchaindb/web/views/assets.py
def get(self): """API endpoint to perform a text search on the assets. Args: search (str): Text search string to query the text index limit (int, optional): Limit the number of returned documents. Return: A list of assets that match the query. """ ...
def get(self): """API endpoint to perform a text search on the assets. Args: search (str): Text search string to query the text index limit (int, optional): Limit the number of returned documents. Return: A list of assets that match the query. """ ...
[ "API", "endpoint", "to", "perform", "a", "text", "search", "on", "the", "assets", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/assets.py#L21-L54
[ "def", "get", "(", "self", ")", ":", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", ".", "add_argument", "(", "'search'", ",", "type", "=", "str", ",", "required", "=", "True", ")", "parser", ".", "add_argument", "(", "'limit'", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.init_chain
Initialize chain upon genesis or a migration
bigchaindb/core.py
def init_chain(self, genesis): """Initialize chain upon genesis or a migration""" app_hash = '' height = 0 known_chain = self.bigchaindb.get_latest_abci_chain() if known_chain is not None: chain_id = known_chain['chain_id'] if known_chain['is_synced']: ...
def init_chain(self, genesis): """Initialize chain upon genesis or a migration""" app_hash = '' height = 0 known_chain = self.bigchaindb.get_latest_abci_chain() if known_chain is not None: chain_id = known_chain['chain_id'] if known_chain['is_synced']: ...
[ "Initialize", "chain", "upon", "genesis", "or", "a", "migration" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L68-L111
[ "def", "init_chain", "(", "self", ",", "genesis", ")", ":", "app_hash", "=", "''", "height", "=", "0", "known_chain", "=", "self", ".", "bigchaindb", ".", "get_latest_abci_chain", "(", ")", "if", "known_chain", "is", "not", "None", ":", "chain_id", "=", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.info
Return height of the latest committed block.
bigchaindb/core.py
def info(self, request): """Return height of the latest committed block.""" self.abort_if_abci_chain_is_not_synced() # Check if BigchainDB supports the Tendermint version if not (hasattr(request, 'version') and tendermint_version_is_compatible(request.version)): logger.erro...
def info(self, request): """Return height of the latest committed block.""" self.abort_if_abci_chain_is_not_synced() # Check if BigchainDB supports the Tendermint version if not (hasattr(request, 'version') and tendermint_version_is_compatible(request.version)): logger.erro...
[ "Return", "height", "of", "the", "latest", "committed", "block", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L113-L135
[ "def", "info", "(", "self", ",", "request", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "# Check if BigchainDB supports the Tendermint version", "if", "not", "(", "hasattr", "(", "request", ",", "'version'", ")", "and", "tendermint_version_is...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.check_tx
Validate the transaction before entry into the mempool. Args: raw_tx: a raw string (in bytes) transaction.
bigchaindb/core.py
def check_tx(self, raw_transaction): """Validate the transaction before entry into the mempool. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('check_tx: %s', raw_transaction) transaction...
def check_tx(self, raw_transaction): """Validate the transaction before entry into the mempool. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('check_tx: %s', raw_transaction) transaction...
[ "Validate", "the", "transaction", "before", "entry", "into", "the", "mempool", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L137-L154
[ "def", "check_tx", "(", "self", ",", "raw_transaction", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "logger", ".", "debug", "(", "'check_tx: %s'", ",", "raw_transaction", ")", "transaction", "=", "decode_transaction", "(", "raw_transaction"...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.begin_block
Initialize list of transaction. Args: req_begin_block: block object which contains block header and block hash.
bigchaindb/core.py
def begin_block(self, req_begin_block): """Initialize list of transaction. Args: req_begin_block: block object which contains block header and block hash. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.chain is None else self.chain['...
def begin_block(self, req_begin_block): """Initialize list of transaction. Args: req_begin_block: block object which contains block header and block hash. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.chain is None else self.chain['...
[ "Initialize", "list", "of", "transaction", ".", "Args", ":", "req_begin_block", ":", "block", "object", "which", "contains", "block", "header", "and", "block", "hash", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L156-L171
[ "def", "begin_block", "(", "self", ",", "req_begin_block", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "chain_shift", "=", "0", "if", "self", ".", "chain", "is", "None", "else", "self", ".", "chain", "[", "'height'", "]", "logger", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.deliver_tx
Validate the transaction before mutating the state. Args: raw_tx: a raw string (in bytes) transaction.
bigchaindb/core.py
def deliver_tx(self, raw_transaction): """Validate the transaction before mutating the state. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('deliver_tx: %s', raw_transaction) transaction = self....
def deliver_tx(self, raw_transaction): """Validate the transaction before mutating the state. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('deliver_tx: %s', raw_transaction) transaction = self....
[ "Validate", "the", "transaction", "before", "mutating", "the", "state", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L173-L193
[ "def", "deliver_tx", "(", "self", ",", "raw_transaction", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "logger", ".", "debug", "(", "'deliver_tx: %s'", ",", "raw_transaction", ")", "transaction", "=", "self", ".", "bigchaindb", ".", "is_...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.end_block
Calculate block hash using transaction ids and previous block hash to be stored in the next block. Args: height (int): new height of the chain.
bigchaindb/core.py
def end_block(self, request_end_block): """Calculate block hash using transaction ids and previous block hash to be stored in the next block. Args: height (int): new height of the chain. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.c...
def end_block(self, request_end_block): """Calculate block hash using transaction ids and previous block hash to be stored in the next block. Args: height (int): new height of the chain. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.c...
[ "Calculate", "block", "hash", "using", "transaction", "ids", "and", "previous", "block", "hash", "to", "be", "stored", "in", "the", "next", "block", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L195-L229
[ "def", "end_block", "(", "self", ",", "request_end_block", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "chain_shift", "=", "0", "if", "self", ".", "chain", "is", "None", "else", "self", ".", "chain", "[", "'height'", "]", "height", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
App.commit
Store the new height and along with block hash.
bigchaindb/core.py
def commit(self): """Store the new height and along with block hash.""" self.abort_if_abci_chain_is_not_synced() data = self.block_txn_hash.encode('utf-8') # register a new block only when new transactions are received if self.block_txn_ids: self.bigchaindb.store_b...
def commit(self): """Store the new height and along with block hash.""" self.abort_if_abci_chain_is_not_synced() data = self.block_txn_hash.encode('utf-8') # register a new block only when new transactions are received if self.block_txn_ids: self.bigchaindb.store_b...
[ "Store", "the", "new", "height", "and", "along", "with", "block", "hash", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/core.py#L231-L260
[ "def", "commit", "(", "self", ")", ":", "self", ".", "abort_if_abci_chain_is_not_synced", "(", ")", "data", "=", "self", ".", "block_txn_hash", ".", "encode", "(", "'utf-8'", ")", "# register a new block only when new transactions are received", "if", "self", ".", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
ValidatorElection.validate
For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21
bigchaindb/upsert_validator/validator_election.py
def validate(self, bigchain, current_transactions=[]): """For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21 """ current_validators = self.get_validators(bigchain) super(ValidatorElection, self).validate(bigchain, current_transactions=current_transactions)...
def validate(self, bigchain, current_transactions=[]): """For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21 """ current_validators = self.get_validators(bigchain) super(ValidatorElection, self).validate(bigchain, current_transactions=current_transactions)...
[ "For", "more", "details", "refer", "BEP", "-", "21", ":", "https", ":", "//", "github", ".", "com", "/", "bigchaindb", "/", "BEPs", "/", "tree", "/", "master", "/", "21" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/upsert_validator/validator_election.py#L20-L32
[ "def", "validate", "(", "self", ",", "bigchain", ",", "current_transactions", "=", "[", "]", ")", ":", "current_validators", "=", "self", ".", "get_validators", "(", "bigchain", ")", "super", "(", "ValidatorElection", ",", "self", ")", ".", "validate", "(", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Exchange.get_subscriber_queue
Create a new queue for a specific combination of event types and return it. Returns: a :class:`multiprocessing.Queue`. Raises: RuntimeError if called after `run`
bigchaindb/events.py
def get_subscriber_queue(self, event_types=None): """Create a new queue for a specific combination of event types and return it. Returns: a :class:`multiprocessing.Queue`. Raises: RuntimeError if called after `run` """ try: self.start...
def get_subscriber_queue(self, event_types=None): """Create a new queue for a specific combination of event types and return it. Returns: a :class:`multiprocessing.Queue`. Raises: RuntimeError if called after `run` """ try: self.start...
[ "Create", "a", "new", "queue", "for", "a", "specific", "combination", "of", "event", "types", "and", "return", "it", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/events.py#L63-L84
[ "def", "get_subscriber_queue", "(", "self", ",", "event_types", "=", "None", ")", ":", "try", ":", "self", ".", "started_queue", ".", "get", "(", "timeout", "=", "1", ")", "raise", "RuntimeError", "(", "'Cannot create a new subscriber queue while Exchange is running...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Exchange.dispatch
Given an event, send it to all the subscribers. Args event (:class:`~bigchaindb.events.EventTypes`): the event to dispatch to all the subscribers.
bigchaindb/events.py
def dispatch(self, event): """Given an event, send it to all the subscribers. Args event (:class:`~bigchaindb.events.EventTypes`): the event to dispatch to all the subscribers. """ for event_types, queues in self.queues.items(): if event.type & e...
def dispatch(self, event): """Given an event, send it to all the subscribers. Args event (:class:`~bigchaindb.events.EventTypes`): the event to dispatch to all the subscribers. """ for event_types, queues in self.queues.items(): if event.type & e...
[ "Given", "an", "event", "send", "it", "to", "all", "the", "subscribers", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/events.py#L86-L97
[ "def", "dispatch", "(", "self", ",", "event", ")", ":", "for", "event_types", ",", "queues", "in", "self", ".", "queues", ".", "items", "(", ")", ":", "if", "event", ".", "type", "&", "event_types", ":", "for", "queue", "in", "queues", ":", "queue", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Exchange.run
Start the exchange
bigchaindb/events.py
def run(self): """Start the exchange""" self.started_queue.put('STARTED') while True: event = self.publisher_queue.get() if event == POISON_PILL: return else: self.dispatch(event)
def run(self): """Start the exchange""" self.started_queue.put('STARTED') while True: event = self.publisher_queue.get() if event == POISON_PILL: return else: self.dispatch(event)
[ "Start", "the", "exchange" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/events.py#L99-L108
[ "def", "run", "(", "self", ")", ":", "self", ".", "started_queue", ".", "put", "(", "'STARTED'", ")", "while", "True", ":", "event", "=", "self", ".", "publisher_queue", ".", "get", "(", ")", "if", "event", "==", "POISON_PILL", ":", "return", "else", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
init_database
Initialize the configured backend for use with BigchainDB. Creates a database with :attr:`dbname` with any required tables and supporting indexes. Args: connection (:class:`~bigchaindb.backend.connection.Connection`): an existing connection to use to initialize the database. ...
bigchaindb/backend/schema.py
def init_database(connection=None, dbname=None): """Initialize the configured backend for use with BigchainDB. Creates a database with :attr:`dbname` with any required tables and supporting indexes. Args: connection (:class:`~bigchaindb.backend.connection.Connection`): an existing ...
def init_database(connection=None, dbname=None): """Initialize the configured backend for use with BigchainDB. Creates a database with :attr:`dbname` with any required tables and supporting indexes. Args: connection (:class:`~bigchaindb.backend.connection.Connection`): an existing ...
[ "Initialize", "the", "configured", "backend", "for", "use", "with", "BigchainDB", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/schema.py#L65-L84
[ "def", "init_database", "(", "connection", "=", "None", ",", "dbname", "=", "None", ")", ":", "connection", "=", "connection", "or", "connect", "(", ")", "dbname", "=", "dbname", "or", "bigchaindb", ".", "config", "[", "'database'", "]", "[", "'name'", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
validate_language_key
Validate all nested "language" key in `obj`. Args: obj (dict): dictionary whose "language" key is to be validated. Returns: None: validation successful Raises: ValidationError: will raise exception in case language is not valid.
bigchaindb/backend/schema.py
def validate_language_key(obj, key): """Validate all nested "language" key in `obj`. Args: obj (dict): dictionary whose "language" key is to be validated. Returns: None: validation successful Raises: ValidationError: will raise exception in case language is...
def validate_language_key(obj, key): """Validate all nested "language" key in `obj`. Args: obj (dict): dictionary whose "language" key is to be validated. Returns: None: validation successful Raises: ValidationError: will raise exception in case language is...
[ "Validate", "all", "nested", "language", "key", "in", "obj", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/schema.py#L87-L106
[ "def", "validate_language_key", "(", "obj", ",", "key", ")", ":", "backend", "=", "bigchaindb", ".", "config", "[", "'database'", "]", "[", "'backend'", "]", "if", "backend", "==", "'localmongodb'", ":", "data", "=", "obj", ".", "get", "(", "key", ",", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
BlockApi.get
API endpoint to get details about a block. Args: block_id (str): the id of the block. Return: A JSON string containing the data about the block.
bigchaindb/web/views/blocks.py
def get(self, block_id): """API endpoint to get details about a block. Args: block_id (str): the id of the block. Return: A JSON string containing the data about the block. """ pool = current_app.config['bigchain_pool'] with pool() as bigchain:...
def get(self, block_id): """API endpoint to get details about a block. Args: block_id (str): the id of the block. Return: A JSON string containing the data about the block. """ pool = current_app.config['bigchain_pool'] with pool() as bigchain:...
[ "API", "endpoint", "to", "get", "details", "about", "a", "block", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/blocks.py#L16-L34
[ "def", "get", "(", "self", ",", "block_id", ")", ":", "pool", "=", "current_app", ".", "config", "[", "'bigchain_pool'", "]", "with", "pool", "(", ")", "as", "bigchain", ":", "block", "=", "bigchain", ".", "get_block", "(", "block_id", "=", "block_id", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
BlockListApi.get
API endpoint to get the related blocks for a transaction. Return: A ``list`` of ``block_id``s that contain the given transaction. The list may be filtered when provided a status query parameter: "valid", "invalid", "undecided".
bigchaindb/web/views/blocks.py
def get(self): """API endpoint to get the related blocks for a transaction. Return: A ``list`` of ``block_id``s that contain the given transaction. The list may be filtered when provided a status query parameter: "valid", "invalid", "undecided". """ p...
def get(self): """API endpoint to get the related blocks for a transaction. Return: A ``list`` of ``block_id``s that contain the given transaction. The list may be filtered when provided a status query parameter: "valid", "invalid", "undecided". """ p...
[ "API", "endpoint", "to", "get", "the", "related", "blocks", "for", "a", "transaction", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/blocks.py#L38-L57
[ "def", "get", "(", "self", ")", ":", "parser", "=", "reqparse", ".", "RequestParser", "(", ")", "parser", ".", "add_argument", "(", "'transaction_id'", ",", "type", "=", "str", ",", "required", "=", "True", ")", "args", "=", "parser", ".", "parse_args", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
key_pair_from_ed25519_key
Generate base58 encode public-private key pair from a hex encoded private key
bigchaindb/common/crypto.py
def key_pair_from_ed25519_key(hex_private_key): """Generate base58 encode public-private key pair from a hex encoded private key""" priv_key = crypto.Ed25519SigningKey(bytes.fromhex(hex_private_key)[:32], encoding='bytes') public_key = priv_key.get_verifying_key() return CryptoKeypair(private_key=priv_k...
def key_pair_from_ed25519_key(hex_private_key): """Generate base58 encode public-private key pair from a hex encoded private key""" priv_key = crypto.Ed25519SigningKey(bytes.fromhex(hex_private_key)[:32], encoding='bytes') public_key = priv_key.get_verifying_key() return CryptoKeypair(private_key=priv_k...
[ "Generate", "base58", "encode", "public", "-", "private", "key", "pair", "from", "a", "hex", "encoded", "private", "key" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/crypto.py#L39-L44
[ "def", "key_pair_from_ed25519_key", "(", "hex_private_key", ")", ":", "priv_key", "=", "crypto", ".", "Ed25519SigningKey", "(", "bytes", ".", "fromhex", "(", "hex_private_key", ")", "[", ":", "32", "]", ",", "encoding", "=", "'bytes'", ")", "public_key", "=", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
public_key_from_ed25519_key
Generate base58 public key from hex encoded public key
bigchaindb/common/crypto.py
def public_key_from_ed25519_key(hex_public_key): """Generate base58 public key from hex encoded public key""" public_key = crypto.Ed25519VerifyingKey(bytes.fromhex(hex_public_key), encoding='bytes') return public_key.encode(encoding='base58').decode('utf-8')
def public_key_from_ed25519_key(hex_public_key): """Generate base58 public key from hex encoded public key""" public_key = crypto.Ed25519VerifyingKey(bytes.fromhex(hex_public_key), encoding='bytes') return public_key.encode(encoding='base58').decode('utf-8')
[ "Generate", "base58", "public", "key", "from", "hex", "encoded", "public", "key" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/crypto.py#L47-L50
[ "def", "public_key_from_ed25519_key", "(", "hex_public_key", ")", ":", "public_key", "=", "crypto", ".", "Ed25519VerifyingKey", "(", "bytes", ".", "fromhex", "(", "hex_public_key", ")", ",", "encoding", "=", "'bytes'", ")", "return", "public_key", ".", "encode", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
_fulfillment_to_details
Encode a fulfillment as a details dictionary Args: fulfillment: Crypto-conditions Fulfillment object
bigchaindb/common/transaction.py
def _fulfillment_to_details(fulfillment): """Encode a fulfillment as a details dictionary Args: fulfillment: Crypto-conditions Fulfillment object """ if fulfillment.type_name == 'ed25519-sha-256': return { 'type': 'ed25519-sha-256', 'public_key': base58.b58encod...
def _fulfillment_to_details(fulfillment): """Encode a fulfillment as a details dictionary Args: fulfillment: Crypto-conditions Fulfillment object """ if fulfillment.type_name == 'ed25519-sha-256': return { 'type': 'ed25519-sha-256', 'public_key': base58.b58encod...
[ "Encode", "a", "fulfillment", "as", "a", "details", "dictionary" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L161-L185
[ "def", "_fulfillment_to_details", "(", "fulfillment", ")", ":", "if", "fulfillment", ".", "type_name", "==", "'ed25519-sha-256'", ":", "return", "{", "'type'", ":", "'ed25519-sha-256'", ",", "'public_key'", ":", "base58", ".", "b58encode", "(", "fulfillment", ".",...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
_fulfillment_from_details
Load a fulfillment for a signing spec dictionary Args: data: tx.output[].condition.details dictionary
bigchaindb/common/transaction.py
def _fulfillment_from_details(data, _depth=0): """Load a fulfillment for a signing spec dictionary Args: data: tx.output[].condition.details dictionary """ if _depth == 100: raise ThresholdTooDeep() if data['type'] == 'ed25519-sha-256': public_key = base58.b58decode(data['p...
def _fulfillment_from_details(data, _depth=0): """Load a fulfillment for a signing spec dictionary Args: data: tx.output[].condition.details dictionary """ if _depth == 100: raise ThresholdTooDeep() if data['type'] == 'ed25519-sha-256': public_key = base58.b58decode(data['p...
[ "Load", "a", "fulfillment", "for", "a", "signing", "spec", "dictionary" ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L188-L208
[ "def", "_fulfillment_from_details", "(", "data", ",", "_depth", "=", "0", ")", ":", "if", "_depth", "==", "100", ":", "raise", "ThresholdTooDeep", "(", ")", "if", "data", "[", "'type'", "]", "==", "'ed25519-sha-256'", ":", "public_key", "=", "base58", ".",...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Input.to_dict
Transforms the object to a Python dictionary. Note: If an Input hasn't been signed yet, this method returns a dictionary representation. Returns: dict: The Input as an alternative serialization format.
bigchaindb/common/transaction.py
def to_dict(self): """Transforms the object to a Python dictionary. Note: If an Input hasn't been signed yet, this method returns a dictionary representation. Returns: dict: The Input as an alternative serialization format. """ ...
def to_dict(self): """Transforms the object to a Python dictionary. Note: If an Input hasn't been signed yet, this method returns a dictionary representation. Returns: dict: The Input as an alternative serialization format. """ ...
[ "Transforms", "the", "object", "to", "a", "Python", "dictionary", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L92-L118
[ "def", "to_dict", "(", "self", ")", ":", "try", ":", "fulfillment", "=", "self", ".", "fulfillment", ".", "serialize_uri", "(", ")", "except", "(", "TypeError", ",", "AttributeError", ",", "ASN1EncodeError", ",", "ASN1DecodeError", ")", ":", "fulfillment", "...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Input.from_dict
Transforms a Python dictionary to an Input object. Note: Optionally, this method can also serialize a Cryptoconditions- Fulfillment that is not yet signed. Args: data (dict): The Input to be transformed. Returns: :cla...
bigchaindb/common/transaction.py
def from_dict(cls, data): """Transforms a Python dictionary to an Input object. Note: Optionally, this method can also serialize a Cryptoconditions- Fulfillment that is not yet signed. Args: data (dict): The Input to be transformed. ...
def from_dict(cls, data): """Transforms a Python dictionary to an Input object. Note: Optionally, this method can also serialize a Cryptoconditions- Fulfillment that is not yet signed. Args: data (dict): The Input to be transformed. ...
[ "Transforms", "a", "Python", "dictionary", "to", "an", "Input", "object", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L129-L158
[ "def", "from_dict", "(", "cls", ",", "data", ")", ":", "fulfillment", "=", "data", "[", "'fulfillment'", "]", "if", "not", "isinstance", "(", "fulfillment", ",", "(", "Fulfillment", ",", "type", "(", "None", ")", ")", ")", ":", "try", ":", "fulfillment...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
TransactionLink.to_dict
Transforms the object to a Python dictionary. Returns: (dict|None): The link as an alternative serialization format.
bigchaindb/common/transaction.py
def to_dict(self): """Transforms the object to a Python dictionary. Returns: (dict|None): The link as an alternative serialization format. """ if self.txid is None and self.output is None: return None else: return { 'tr...
def to_dict(self): """Transforms the object to a Python dictionary. Returns: (dict|None): The link as an alternative serialization format. """ if self.txid is None and self.output is None: return None else: return { 'tr...
[ "Transforms", "the", "object", "to", "a", "Python", "dictionary", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L263-L275
[ "def", "to_dict", "(", "self", ")", ":", "if", "self", ".", "txid", "is", "None", "and", "self", ".", "output", "is", "None", ":", "return", "None", "else", ":", "return", "{", "'transaction_id'", ":", "self", ".", "txid", ",", "'output_index'", ":", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7
train
Output.to_dict
Transforms the object to a Python dictionary. Note: A dictionary serialization of the Input the Output was derived from is always provided. Returns: dict: The Output as an alternative serialization format.
bigchaindb/common/transaction.py
def to_dict(self): """Transforms the object to a Python dictionary. Note: A dictionary serialization of the Input the Output was derived from is always provided. Returns: dict: The Output as an alternative serialization format. ""...
def to_dict(self): """Transforms the object to a Python dictionary. Note: A dictionary serialization of the Input the Output was derived from is always provided. Returns: dict: The Output as an alternative serialization format. ""...
[ "Transforms", "the", "object", "to", "a", "Python", "dictionary", "." ]
bigchaindb/bigchaindb
python
https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L329-L357
[ "def", "to_dict", "(", "self", ")", ":", "# TODO FOR CC: It must be able to recognize a hashlock condition", "# and fulfillment!", "condition", "=", "{", "}", "try", ":", "condition", "[", "'details'", "]", "=", "_fulfillment_to_details", "(", "self", ".", ...
835fdfcf598918f76139e3b88ee33dd157acaaa7