Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
CCWallet.coin_added
(self, coin: Coin, header_hash: bytes32, removals: List[Coin], height: uint32)
Notification from wallet state manager that wallet has been received.
Notification from wallet state manager that wallet has been received.
async def coin_added(self, coin: Coin, header_hash: bytes32, removals: List[Coin], height: uint32): """Notification from wallet state manager that wallet has been received.""" self.log.info(f"CC wallet has been notified that {coin} was added") search_for_parent: bool = True inner_puzzl...
[ "async", "def", "coin_added", "(", "self", ",", "coin", ":", "Coin", ",", "header_hash", ":", "bytes32", ",", "removals", ":", "List", "[", "Coin", "]", ",", "height", ":", "uint32", ")", ":", "self", ".", "log", ".", "info", "(", "f\"CC wallet has bee...
[ 282, 4 ]
[ 318, 13 ]
python
en
['en', 'en', 'en']
True
CCWallet.select_coins
(self, amount: uint64)
Returns a set of coins that can be used for generating a new transaction. Note: Must be called under wallet state manager lock
Returns a set of coins that can be used for generating a new transaction. Note: Must be called under wallet state manager lock
async def select_coins(self, amount: uint64) -> Set[Coin]: """ Returns a set of coins that can be used for generating a new transaction. Note: Must be called under wallet state manager lock """ spendable_am = await self.get_confirmed_balance() if amount > spendable_am: ...
[ "async", "def", "select_coins", "(", "self", ",", "amount", ":", "uint64", ")", "->", "Set", "[", "Coin", "]", ":", "spendable_am", "=", "await", "self", ".", "get_confirmed_balance", "(", ")", "if", "amount", ">", "spendable_am", ":", "error_msg", "=", ...
[ 494, 4 ]
[ 538, 25 ]
python
en
['en', 'error', 'th']
False
Stat.__getattr__
(self, id)
Calculate missing attribute
Calculate missing attribute
def __getattr__(self, id): """Calculate missing attribute""" if id[:4] == "_get": raise AttributeError(id) # calculate missing attribute v = getattr(self, "_get" + id)() setattr(self, id, v) return v
[ "def", "__getattr__", "(", "self", ",", "id", ")", ":", "if", "id", "[", ":", "4", "]", "==", "\"_get\"", ":", "raise", "AttributeError", "(", "id", ")", "# calculate missing attribute", "v", "=", "getattr", "(", "self", ",", "\"_get\"", "+", "id", ")"...
[ 41, 4 ]
[ 48, 16 ]
python
en
['en', 'co', 'en']
True
Stat._getextrema
(self)
Get min/max values for each band in the image
Get min/max values for each band in the image
def _getextrema(self): """Get min/max values for each band in the image""" def minmax(histogram): n = 255 x = 0 for i in range(256): if histogram[i]: n = min(n, i) x = max(x, i) return n, x # return...
[ "def", "_getextrema", "(", "self", ")", ":", "def", "minmax", "(", "histogram", ")", ":", "n", "=", "255", "x", "=", "0", "for", "i", "in", "range", "(", "256", ")", ":", "if", "histogram", "[", "i", "]", ":", "n", "=", "min", "(", "n", ",", ...
[ 50, 4 ]
[ 65, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getcount
(self)
Get total number of pixels in each layer
Get total number of pixels in each layer
def _getcount(self): """Get total number of pixels in each layer""" v = [] for i in range(0, len(self.h), 256): v.append(functools.reduce(operator.add, self.h[i : i + 256])) return v
[ "def", "_getcount", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "h", ")", ",", "256", ")", ":", "v", ".", "append", "(", "functools", ".", "reduce", "(", "operator", ".", "add"...
[ 67, 4 ]
[ 73, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getsum
(self)
Get sum of all pixels in each layer
Get sum of all pixels in each layer
def _getsum(self): """Get sum of all pixels in each layer""" v = [] for i in range(0, len(self.h), 256): layerSum = 0.0 for j in range(256): layerSum += j * self.h[i + j] v.append(layerSum) return v
[ "def", "_getsum", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "h", ")", ",", "256", ")", ":", "layerSum", "=", "0.0", "for", "j", "in", "range", "(", "256", ")", ":", "layerS...
[ 75, 4 ]
[ 84, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getsum2
(self)
Get squared sum of all pixels in each layer
Get squared sum of all pixels in each layer
def _getsum2(self): """Get squared sum of all pixels in each layer""" v = [] for i in range(0, len(self.h), 256): sum2 = 0.0 for j in range(256): sum2 += (j ** 2) * float(self.h[i + j]) v.append(sum2) return v
[ "def", "_getsum2", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "h", ")", ",", "256", ")", ":", "sum2", "=", "0.0", "for", "j", "in", "range", "(", "256", ")", ":", "sum2", ...
[ 86, 4 ]
[ 95, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getmean
(self)
Get average pixel level for each layer
Get average pixel level for each layer
def _getmean(self): """Get average pixel level for each layer""" v = [] for i in self.bands: v.append(self.sum[i] / self.count[i]) return v
[ "def", "_getmean", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "self", ".", "sum", "[", "i", "]", "/", "self", ".", "count", "[", "i", "]", ")", "return", "v" ]
[ 97, 4 ]
[ 103, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getmedian
(self)
Get median pixel level for each layer
Get median pixel level for each layer
def _getmedian(self): """Get median pixel level for each layer""" v = [] for i in self.bands: s = 0 half = self.count[i] // 2 b = i * 256 for j in range(256): s = s + self.h[b + j] if s > half: b...
[ "def", "_getmedian", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "s", "=", "0", "half", "=", "self", ".", "count", "[", "i", "]", "//", "2", "b", "=", "i", "*", "256", "for", "j", "in", "range", ...
[ 105, 4 ]
[ 118, 16 ]
python
en
['en', 'da', 'en']
True
Stat._getrms
(self)
Get RMS for each layer
Get RMS for each layer
def _getrms(self): """Get RMS for each layer""" v = [] for i in self.bands: v.append(math.sqrt(self.sum2[i] / self.count[i])) return v
[ "def", "_getrms", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "math", ".", "sqrt", "(", "self", ".", "sum2", "[", "i", "]", "/", "self", ".", "count", "[", "i", "]", ")", ...
[ 120, 4 ]
[ 126, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getvar
(self)
Get variance for each layer
Get variance for each layer
def _getvar(self): """Get variance for each layer""" v = [] for i in self.bands: n = self.count[i] v.append((self.sum2[i] - (self.sum[i] ** 2.0) / n) / n) return v
[ "def", "_getvar", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "n", "=", "self", ".", "count", "[", "i", "]", "v", ".", "append", "(", "(", "self", ".", "sum2", "[", "i", "]", "-", "(", "self", "...
[ 128, 4 ]
[ 135, 16 ]
python
en
['en', 'en', 'en']
True
Stat._getstddev
(self)
Get standard deviation for each layer
Get standard deviation for each layer
def _getstddev(self): """Get standard deviation for each layer""" v = [] for i in self.bands: v.append(math.sqrt(self.var[i])) return v
[ "def", "_getstddev", "(", "self", ")", ":", "v", "=", "[", "]", "for", "i", "in", "self", ".", "bands", ":", "v", ".", "append", "(", "math", ".", "sqrt", "(", "self", ".", "var", "[", "i", "]", ")", ")", "return", "v" ]
[ 137, 4 ]
[ 143, 16 ]
python
en
['en', 'en', 'en']
True
get_monitor_entries
(dataset_id)
Returns the ``monitor`` entries relevant to this dataset. Args: dataset_id (int): Parent dataset. Returns: list of tuples [(monitor_id, ra, decl)]
Returns the ``monitor`` entries relevant to this dataset.
def get_monitor_entries(dataset_id): """ Returns the ``monitor`` entries relevant to this dataset. Args: dataset_id (int): Parent dataset. Returns: list of tuples [(monitor_id, ra, decl)] """ query = """\ SELECT id ,ra ,decl FROM monitor WHERE dataset = %(datase...
[ "def", "get_monitor_entries", "(", "dataset_id", ")", ":", "query", "=", "\"\"\"\\\nSELECT id\n ,ra\n ,decl\n FROM monitor\n WHERE dataset = %(dataset_id)s\n\"\"\"", "qry_params", "=", "{", "'dataset_id'", ":", "dataset_id", "}", "cursor", "=", "execute", "(", "que...
[ 18, 0 ]
[ 39, 14 ]
python
en
['en', 'error', 'th']
False
associate_ms
(image_id)
Associate the monitoring sources, i.e., their forced fits, of the current image with the ones in the running catalog. These associations are treated separately from the normal associations and there will only be 1-to-1 associations. The runcat-monitoring source pairs will be inserted in a temp...
Associate the monitoring sources, i.e., their forced fits, of the current image with the ones in the running catalog. These associations are treated separately from the normal associations and there will only be 1-to-1 associations.
def associate_ms(image_id): """ Associate the monitoring sources, i.e., their forced fits, of the current image with the ones in the running catalog. These associations are treated separately from the normal associations and there will only be 1-to-1 associations. The runcat-monitoring source p...
[ "def", "associate_ms", "(", "image_id", ")", ":", "_del_tempruncat", "(", ")", "_insert_tempruncat", "(", "image_id", ")", "_insert_1_to_1_assoc", "(", ")", "_update_1_to_1_runcat", "(", ")", "n_updated", "=", "_update_1_to_1_runcat_flux", "(", ")", "if", "n_updated...
[ 41, 0 ]
[ 81, 21 ]
python
en
['en', 'error', 'th']
False
_insert_tempruncat
(image_id)
Here the associations of forced fits of the monitoring sources and their runningcatalog counterparts are inserted into the temporary table. We follow the implementation of the normal association procedure, except that we don't need to match with a De Ruiter radius, since the counterpart pairs ...
Here the associations of forced fits of the monitoring sources and their runningcatalog counterparts are inserted into the temporary table.
def _insert_tempruncat(image_id): """ Here the associations of forced fits of the monitoring sources and their runningcatalog counterparts are inserted into the temporary table. We follow the implementation of the normal association procedure, except that we don't need to match with a De Ruiter...
[ "def", "_insert_tempruncat", "(", "image_id", ")", ":", "# The query is as follows:", "# t0 searches for matches between the monitoring sources", "# (extract_type = 2) in the current image that have", "# a counterpart among the runningcatalog sources. This", "# matching is done by zone, decl, ra...
[ 83, 0 ]
[ 277, 75 ]
python
en
['en', 'error', 'th']
False
_insert_runcat_flux
()
Monitoring sources that were not yet fitted in this frequency band before, will be appended to it. Those have their first f_datapoint.
Monitoring sources that were not yet fitted in this frequency band before, will be appended to it. Those have their first f_datapoint.
def _insert_runcat_flux(): """Monitoring sources that were not yet fitted in this frequency band before, will be appended to it. Those have their first f_datapoint. """ query = """\ INSERT INTO runningcatalog_flux (runcat ,band ,stokes ,f_datapoints ,avg_f_peak ,avg_f_peak_sq ,avg_f_peak_...
[ "def", "_insert_runcat_flux", "(", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog_flux\n (runcat\n ,band\n ,stokes\n ,f_datapoints\n ,avg_f_peak\n ,avg_f_peak_sq\n ,avg_f_peak_weight\n ,avg_weighted_f_peak\n ,avg_weighted_f_peak_sq\n ,avg_f_int\n ,avg_f_int_sq\n ,avg_f_int_w...
[ 280, 0 ]
[ 322, 95 ]
python
en
['en', 'en', 'en']
True
_insert_new_runcat
(image_id)
Insert the fits of the monitoring sources as new sources into the runningcatalog
Insert the fits of the monitoring sources as new sources into the runningcatalog
def _insert_new_runcat(image_id): """Insert the fits of the monitoring sources as new sources into the runningcatalog """ query = """\ INSERT INTO runningcatalog (xtrsrc ,dataset ,datapoints ,zone ,wm_ra ,wm_decl ,avg_ra_err ,avg_decl_err ,wm_uncertainty_ew ,wm_uncertainty_ns ,avg...
[ "def", "_insert_new_runcat", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog\n (xtrsrc\n ,dataset\n ,datapoints\n ,zone\n ,wm_ra\n ,wm_decl\n ,avg_ra_err\n ,avg_decl_err\n ,wm_uncertainty_ew\n ,wm_uncertainty_ns\n ,avg_wra\n ,avg_wdecl\n ,avg_weight_ra\n ...
[ 326, 0 ]
[ 382, 79 ]
python
en
['en', 'en', 'en']
True
_update_monitor_runcats
(image_id)
Update ``runcat`` col of ``monitor`` table for newly extracted positions.
Update ``runcat`` col of ``monitor`` table for newly extracted positions.
def _update_monitor_runcats(image_id): """ Update ``runcat`` col of ``monitor`` table for newly extracted positions. """ query ="""\ UPDATE monitor SET runcat = (SELECT rc.id FROM runningcatalog rc JOIN extractedsource ex ON rc.xtrsrc = ex.id...
[ "def", "_update_monitor_runcats", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nUPDATE monitor\n SET runcat = (SELECT rc.id\n FROM runningcatalog rc\n JOIN extractedsource ex\n ON rc.xtrsrc = ex.id\n WHERE monitor.runca...
[ 384, 0 ]
[ 411, 75 ]
python
en
['en', 'error', 'th']
False
_insert_new_runcat_flux
(image_id)
Insert the fitted fluxes of the monitoring sources as new datapoints into the runningcatalog_flux. Extractedsources for which not a counterpart was found in the runningcatalog, i.e., those that do not have an entry in the tempruncat table (t0) will be added as a new source in the runningcatalog_flu...
Insert the fitted fluxes of the monitoring sources as new datapoints into the runningcatalog_flux.
def _insert_new_runcat_flux(image_id): """Insert the fitted fluxes of the monitoring sources as new datapoints into the runningcatalog_flux. Extractedsources for which not a counterpart was found in the runningcatalog, i.e., those that do not have an entry in the tempruncat table (t0) will be added...
[ "def", "_insert_new_runcat_flux", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO runningcatalog_flux\n (runcat\n ,band\n ,stokes\n ,f_datapoints\n ,avg_f_peak\n ,avg_f_peak_sq\n ,avg_f_peak_weight\n ,avg_weighted_f_peak\n ,avg_weighted_f_peak_sq\n ,avg_f_int\n ,avg_f_int_...
[ 415, 0 ]
[ 470, 83 ]
python
en
['en', 'en', 'en']
True
_insert_new_1_to_1_assoc
(image_id)
The forced fits of the monitoring sources which are new are appended to the assocxtrsource (light-curve) table as a type = 8 datapoint.
The forced fits of the monitoring sources which are new are appended to the assocxtrsource (light-curve) table as a type = 8 datapoint.
def _insert_new_1_to_1_assoc(image_id): """ The forced fits of the monitoring sources which are new are appended to the assocxtrsource (light-curve) table as a type = 8 datapoint. """ query = """\ INSERT INTO assocxtrsource (runcat ,xtrsrc ,type ,distance_arcsec ,r ,v_int ,eta_in...
[ "def", "_insert_new_1_to_1_assoc", "(", "image_id", ")", ":", "query", "=", "\"\"\"\\\nINSERT INTO assocxtrsource\n (runcat\n ,xtrsrc\n ,type\n ,distance_arcsec\n ,r\n ,v_int\n ,eta_int\n ,f_datapoints\n )\n SELECT rc.id\n ,rc.xtrsrc\n ,8 AS type\n ,0\n ,0\n ...
[ 473, 0 ]
[ 514, 94 ]
python
en
['en', 'error', 'th']
False
_insert_1_to_1_assoc
()
The runcat-monitoring pairs are appended to the assocxtrsource (light-curve) table as a type = 9 datapoint.
The runcat-monitoring pairs are appended to the assocxtrsource (light-curve) table as a type = 9 datapoint.
def _insert_1_to_1_assoc(): """ The runcat-monitoring pairs are appended to the assocxtrsource (light-curve) table as a type = 9 datapoint. """ cursor = execute(ONE_TO_ONE_ASSOC_QUERY, {'type': 9}, commit=True) cnt = cursor.rowcount logger.debug("Inserted %s runcat-monitoring source pairs in...
[ "def", "_insert_1_to_1_assoc", "(", ")", ":", "cursor", "=", "execute", "(", "ONE_TO_ONE_ASSOC_QUERY", ",", "{", "'type'", ":", "9", "}", ",", "commit", "=", "True", ")", "cnt", "=", "cursor", ".", "rowcount", "logger", ".", "debug", "(", "\"Inserted %s ru...
[ 516, 0 ]
[ 523, 86 ]
python
en
['en', 'error', 'th']
False
TestClvmCompilation.test_all_programs_listed
(self)
Checks to see if a new .clvm file was added to kale/wallet/puzzles, but not added to `wallet_program_files`
Checks to see if a new .clvm file was added to kale/wallet/puzzles, but not added to `wallet_program_files`
def test_all_programs_listed(self): """ Checks to see if a new .clvm file was added to kale/wallet/puzzles, but not added to `wallet_program_files` """ existing_files = list_files(CLVM_PROGRAM_ROOT, "*.clvm") existing_file_paths = set([Path(x).relative_to(CLVM_PROGRAM_ROOT) for x...
[ "def", "test_all_programs_listed", "(", "self", ")", ":", "existing_files", "=", "list_files", "(", "CLVM_PROGRAM_ROOT", ",", "\"*.clvm\"", ")", "existing_file_paths", "=", "set", "(", "[", "Path", "(", "x", ")", ".", "relative_to", "(", "CLVM_PROGRAM_ROOT", ")"...
[ 66, 4 ]
[ 80, 9 ]
python
en
['en', 'error', 'th']
False
TestClvmCompilation.test_all_programs_are_compiled
(self)
Checks to see if a new .clvm file was added without its .hex file
Checks to see if a new .clvm file was added without its .hex file
def test_all_programs_are_compiled(self): """Checks to see if a new .clvm file was added without its .hex file""" all_compiled = True msg = "Please compile your program with:\n" # Note that we cannot test all existing .clvm files - some are not # meant to be run as a "module" wi...
[ "def", "test_all_programs_are_compiled", "(", "self", ")", ":", "all_compiled", "=", "True", "msg", "=", "\"Please compile your program with:\\n\"", "# Note that we cannot test all existing .clvm files - some are not", "# meant to be run as a \"module\" with load_clvm; some are include fil...
[ 86, 4 ]
[ 104, 46 ]
python
en
['en', 'en', 'en']
True
TestClvmCompilation.test_all_compiled_programs_are_hashed
(self)
Checks to see if a .hex file is missing its .sha256tree file
Checks to see if a .hex file is missing its .sha256tree file
def test_all_compiled_programs_are_hashed(self): """Checks to see if a .hex file is missing its .sha256tree file""" all_hashed = True msg = "Please hash your program with:\n" for prog_path in wallet_program_files: try: hex = path_with_ext(prog_path, ".hex.sha2...
[ "def", "test_all_compiled_programs_are_hashed", "(", "self", ")", ":", "all_hashed", "=", "True", "msg", "=", "\"Please hash your program with:\\n\"", "for", "prog_path", "in", "wallet_program_files", ":", "try", ":", "hex", "=", "path_with_ext", "(", "prog_path", ","...
[ 116, 4 ]
[ 129, 40 ]
python
en
['en', 'en', 'en']
True
TestClvmCompilation.test_shatrees_match
(self)
Checks to see that all .sha256tree files match their .hex files
Checks to see that all .sha256tree files match their .hex files
def test_shatrees_match(self): """Checks to see that all .sha256tree files match their .hex files""" for prog_path in wallet_program_files: # load the .hex file as a program hex_filename = path_with_ext(prog_path, ".hex") clvm_hex = hex_filename.read_text() # .decode...
[ "def", "test_shatrees_match", "(", "self", ")", ":", "for", "prog_path", "in", "wallet_program_files", ":", "# load the .hex file as a program", "hex_filename", "=", "path_with_ext", "(", "prog_path", ",", "\".hex\"", ")", "clvm_hex", "=", "hex_filename", ".", "read_t...
[ 132, 4 ]
[ 154, 13 ]
python
en
['en', 'en', 'en']
True
ControllerAPIModule.has_encrypted_values
(obj)
Returns True if JSON-like python content in obj has $encrypted$ anywhere in the data as a value
Returns True if JSON-like python content in obj has $encrypted$ anywhere in the data as a value
def has_encrypted_values(obj): """Returns True if JSON-like python content in obj has $encrypted$ anywhere in the data as a value """ if isinstance(obj, dict): for val in obj.values(): if ControllerAPIModule.has_encrypted_values(val): retur...
[ "def", "has_encrypted_values", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "for", "val", "in", "obj", ".", "values", "(", ")", ":", "if", "ControllerAPIModule", ".", "has_encrypted_values", "(", "val", ")", ":", "return",...
[ 549, 4 ]
[ 563, 20 ]
python
en
['en', 'en', 'en']
True
ControllerAPIModule.fields_could_be_same
(old_field, new_field)
Treating $encrypted$ as a wild card, return False if the two values are KNOWN to be different return True if the two values are the same, or could potentially be the same, depending on the unknown $encrypted$ value or sub-values
Treating $encrypted$ as a wild card, return False if the two values are KNOWN to be different return True if the two values are the same, or could potentially be the same, depending on the unknown $encrypted$ value or sub-values
def fields_could_be_same(old_field, new_field): """Treating $encrypted$ as a wild card, return False if the two values are KNOWN to be different return True if the two values are the same, or could potentially be the same, depending on the unknown $encrypted$ value or sub-values ...
[ "def", "fields_could_be_same", "(", "old_field", ",", "new_field", ")", ":", "if", "isinstance", "(", "old_field", ",", "dict", ")", "and", "isinstance", "(", "new_field", ",", "dict", ")", ":", "if", "set", "(", "old_field", ".", "keys", "(", ")", ")", ...
[ 566, 4 ]
[ 582, 47 ]
python
en
['en', 'en', 'en']
True
register_handler
(handler)
Install application-specific GRIB image handler. :param handler: Handler object.
Install application-specific GRIB image handler.
def register_handler(handler): """ Install application-specific GRIB image handler. :param handler: Handler object. """ global _handler _handler = handler
[ "def", "register_handler", "(", "handler", ")", ":", "global", "_handler", "_handler", "=", "handler" ]
[ 17, 0 ]
[ 24, 22 ]
python
en
['en', 'error', 'th']
False
_get_base_page_action_menu_items
()
Retrieve the global list of menu items for the page action menu, which may then be customised on a per-request basis
Retrieve the global list of menu items for the page action menu, which may then be customised on a per-request basis
def _get_base_page_action_menu_items(): """ Retrieve the global list of menu items for the page action menu, which may then be customised on a per-request basis """ global BASE_PAGE_ACTION_MENU_ITEMS if BASE_PAGE_ACTION_MENU_ITEMS is None: BASE_PAGE_ACTION_MENU_ITEMS = [ Sav...
[ "def", "_get_base_page_action_menu_items", "(", ")", ":", "global", "BASE_PAGE_ACTION_MENU_ITEMS", "if", "BASE_PAGE_ACTION_MENU_ITEMS", "is", "None", ":", "BASE_PAGE_ACTION_MENU_ITEMS", "=", "[", "SaveDraftMenuItem", "(", "order", "=", "0", ")", ",", "DeleteMenuItem", "...
[ 292, 0 ]
[ 317, 38 ]
python
en
['en', 'error', 'th']
False
ActionMenuItem.is_shown
(self, request, context)
Whether this action should be shown on this request; permission checks etc should go here. By default, actions are shown for unlocked pages, hidden for locked pages request = the current request object context = dictionary containing at least: 'view' = 'create', 'edit' or ...
Whether this action should be shown on this request; permission checks etc should go here. By default, actions are shown for unlocked pages, hidden for locked pages
def is_shown(self, request, context): """ Whether this action should be shown on this request; permission checks etc should go here. By default, actions are shown for unlocked pages, hidden for locked pages request = the current request object context = dictionary containing at...
[ "def", "is_shown", "(", "self", ",", "request", ",", "context", ")", ":", "return", "(", "context", "[", "'view'", "]", "==", "'create'", "or", "not", "self", ".", "get_user_page_permissions_tester", "(", "context", ")", ".", "page_locked", "(", ")", ")" ]
[ 32, 4 ]
[ 50, 9 ]
python
en
['en', 'error', 'th']
False
ActionMenuItem.get_context
(self, request, parent_context)
Defines context for the template, overridable to use more data
Defines context for the template, overridable to use more data
def get_context(self, request, parent_context): """Defines context for the template, overridable to use more data""" context = parent_context.copy() context.update({ 'label': self.label, 'url': self.get_url(request, context), 'name': self.name, 'cl...
[ "def", "get_context", "(", "self", ",", "request", ",", "parent_context", ")", ":", "context", "=", "parent_context", ".", "copy", "(", ")", "context", ".", "update", "(", "{", "'label'", ":", "self", ".", "label", ",", "'url'", ":", "self", ".", "get_...
[ 52, 4 ]
[ 62, 22 ]
python
en
['en', 'en', 'en']
True
ShellExecutor.prepare
(self)
Configure Tasks :return:
Configure Tasks :return:
def prepare(self): """ Configure Tasks :return: """ self.env.set(self.settings.get('env')) self._load_tasks('prepare', self.prepare_tasks) self._load_tasks('startup', self.startup_tasks) self._load_tasks('check', self.check_tasks) self._load_tasks...
[ "def", "prepare", "(", "self", ")", ":", "self", ".", "env", ".", "set", "(", "self", ".", "settings", ".", "get", "(", "'env'", ")", ")", "self", ".", "_load_tasks", "(", "'prepare'", ",", "self", ".", "prepare_tasks", ")", "self", ".", "_load_tasks...
[ 88, 4 ]
[ 102, 24 ]
python
en
['en', 'error', 'th']
False
Task.__init__
(self, config, parent_log, working_dir, env)
:type env: Environment
:type env: Environment
def __init__(self, config, parent_log, working_dir, env): """ :type env: Environment """ self.log = parent_log.getChild(self.__class__.__name__) self.working_dir = working_dir self.env = env self.command = config.get("command", TaurusConfigError("Parameter is req...
[ "def", "__init__", "(", "self", ",", "config", ",", "parent_log", ",", "working_dir", ",", "env", ")", ":", "self", ".", "log", "=", "parent_log", ".", "getChild", "(", "self", ".", "__class__", ".", "__name__", ")", "self", ".", "working_dir", "=", "w...
[ 157, 4 ]
[ 172, 27 ]
python
en
['en', 'error', 'th']
False
Task.start
(self)
Start task
Start task
def start(self): """ Start task """ if self.process: self.check() self.log.info("Process already running: %s", self) return self.log.info("Starting shell command: %s", self) self.process = shell_exec(args=self.command, stdout=self.out,...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "process", ":", "self", ".", "check", "(", ")", "self", ".", "log", ".", "info", "(", "\"Process already running: %s\"", ",", "self", ")", "return", "self", ".", "log", ".", "info", "(", "\"St...
[ 174, 4 ]
[ 189, 31 ]
python
en
['en', 'error', 'th']
False
Task.shutdown
(self)
If task was not completed, kill process, provide output else provide output :return:
If task was not completed, kill process, provide output else provide output :return:
def shutdown(self): """ If task was not completed, kill process, provide output else provide output :return: """ self.check() if self.process and self.process.returncode is None: self.log.info("Background task was not completed, shutting it down: %s",...
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "check", "(", ")", "if", "self", ".", "process", "and", "self", ".", "process", ".", "returncode", "is", "None", ":", "self", ".", "log", ".", "info", "(", "\"Background task was not completed, shuttin...
[ 218, 4 ]
[ 233, 30 ]
python
en
['en', 'error', 'th']
False
InstructionCounts.add
(self, instruction, counts)
Add a list of counts or the given instruction.
Add a list of counts or the given instruction.
def add(self, instruction, counts): """Add a list of counts or the given instruction.""" if instruction in self._counts: existing = self._counts[instruction] self._counts[instruction] = [a + b for (a, b) in zip(existing, counts)] else: self._counts[instruction...
[ "def", "add", "(", "self", ",", "instruction", ",", "counts", ")", ":", "if", "instruction", "in", "self", ".", "_counts", ":", "existing", "=", "self", ".", "_counts", "[", "instruction", "]", "self", ".", "_counts", "[", "instruction", "]", "=", "[",...
[ 42, 4 ]
[ 48, 46 ]
python
en
['en', 'en', 'en']
True
InstructionCounts.count
(self, instruction, event)
The number of occurrences of the event for the given instruction.
The number of occurrences of the event for the given instruction.
def count(self, instruction, event): """The number of occurrences of the event for the given instruction.""" counts = self._counts.get(instruction) index = self._events.index(event) if counts: return counts[index] else: return 0
[ "def", "count", "(", "self", ",", "instruction", ",", "event", ")", ":", "counts", "=", "self", ".", "_counts", ".", "get", "(", "instruction", ")", "index", "=", "self", ".", "_events", ".", "index", "(", "event", ")", "if", "counts", ":", "return",...
[ 50, 4 ]
[ 57, 20 ]
python
en
['en', 'en', 'en']
True
InstructionCounts.aggregate
(self)
Aggregates event counts over all instructions.
Aggregates event counts over all instructions.
def aggregate(self): """Aggregates event counts over all instructions.""" return [sum(x) for x in zip(*self._counts.values())]
[ "def", "aggregate", "(", "self", ")", ":", "return", "[", "sum", "(", "x", ")", "for", "x", "in", "zip", "(", "*", "self", ".", "_counts", ".", "values", "(", ")", ")", "]" ]
[ 59, 4 ]
[ 61, 60 ]
python
en
['en', 'en', 'en']
True
InstructionCounts.aggregate_by_event
(self, event)
Aggregates event counts over all instructions for a given event.
Aggregates event counts over all instructions for a given event.
def aggregate_by_event(self, event): """Aggregates event counts over all instructions for a given event.""" return self.aggregate_by_index(self._events.index(event))
[ "def", "aggregate_by_event", "(", "self", ",", "event", ")", ":", "return", "self", ".", "aggregate_by_index", "(", "self", ".", "_events", ".", "index", "(", "event", ")", ")" ]
[ 63, 4 ]
[ 65, 65 ]
python
en
['en', 'en', 'en']
True
InstructionCounts.aggregate_by_index
(self, index)
Aggregates event counts over all instructions for the event at the given index.
Aggregates event counts over all instructions for the event at the given index.
def aggregate_by_index(self, index): """Aggregates event counts over all instructions for the event at the given index.""" return sum(x[index] for x in self._counts.values())
[ "def", "aggregate_by_index", "(", "self", ",", "index", ")", ":", "return", "sum", "(", "x", "[", "index", "]", "for", "x", "in", "self", ".", "_counts", ".", "values", "(", ")", ")" ]
[ 67, 4 ]
[ 69, 59 ]
python
en
['en', 'en', 'en']
True
Parser.parse
(self, file, demangle)
Parse the given file.
Parse the given file.
def parse(self, file, demangle): """Parse the given file.""" with open(file) as fh: if demangle: demangled = subprocess.check_output(["swift", "demangle"], stdin=fh) self._parse_lines(x.decode("utf-8") for x in demangled.splitlines()) else: ...
[ "def", "parse", "(", "self", ",", "file", ",", "demangle", ")", ":", "with", "open", "(", "file", ")", "as", "fh", ":", "if", "demangle", ":", "demangled", "=", "subprocess", ".", "check_output", "(", "[", "\"swift\"", ",", "\"demangle\"", "]", ",", ...
[ 173, 4 ]
[ 182, 27 ]
python
en
['en', 'en', 'en']
True
Parser._next_line
(self, line)
Parses a line of input.
Parses a line of input.
def _next_line(self, line): """Parses a line of input.""" if self._state is State.READING_HEADERS: self._state = self._read_headers(line) elif self._state is State.READING_INSTRUCTION: self._state = self._read_instruction(line) elif self._state is State.READING_CO...
[ "def", "_next_line", "(", "self", ",", "line", ")", ":", "if", "self", ".", "_state", "is", "State", ".", "READING_HEADERS", ":", "self", ".", "_state", "=", "self", ".", "_read_headers", "(", "line", ")", "elif", "self", ".", "_state", "is", "State", ...
[ 188, 4 ]
[ 200, 63 ]
python
en
['en', 'en', 'en']
True
parse
(version)
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
def parse(version): # type: (str) -> Union[LegacyVersion, Version] """ Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version. """ try: return Versi...
[ "def", "parse", "(", "version", ")", ":", "# type: (str) -> Union[LegacyVersion, Version]", "try", ":", "return", "Version", "(", "version", ")", "except", "InvalidVersion", ":", "return", "LegacyVersion", "(", "version", ")" ]
[ 48, 0 ]
[ 58, 37 ]
python
en
['en', 'error', 'th']
False
_parse_local_version
(local)
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
def _parse_local_version(local): # type: (str) -> Optional[LocalType] """ Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve"). """ if local is not None: return tuple( part.lower() if not part.isdigit() else int(part) for part in _local_version_sepa...
[ "def", "_parse_local_version", "(", "local", ")", ":", "# type: (str) -> Optional[LocalType]", "if", "local", "is", "not", "None", ":", "return", "tuple", "(", "part", ".", "lower", "(", ")", "if", "not", "part", ".", "isdigit", "(", ")", "else", "int", "(...
[ 481, 0 ]
[ 491, 15 ]
python
en
['en', 'error', 'th']
False
api_canarytoken_webhook
( request: HttpRequest, user_profile: UserProfile, message: Dict[str, Any] = REQ(argument_type="body"), user_specified_topic: Optional[str] = REQ("topic", default=None), )
Construct a response to a webhook event from a Thinkst canarytoken from canarytokens.org. Canarytokens from Thinkst's paid product have a different schema and should use the "thinkst" integration. See linked documentation below for a schema: https://help.canary.tools/hc/en-gb/articles/360002426577...
Construct a response to a webhook event from a Thinkst canarytoken from canarytokens.org. Canarytokens from Thinkst's paid product have a different schema and should use the "thinkst" integration. See linked documentation below for a schema:
def api_canarytoken_webhook( request: HttpRequest, user_profile: UserProfile, message: Dict[str, Any] = REQ(argument_type="body"), user_specified_topic: Optional[str] = REQ("topic", default=None), ) -> HttpResponse: """ Construct a response to a webhook event from a Thinkst canarytoken from ...
[ "def", "api_canarytoken_webhook", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "message", ":", "Dict", "[", "str", ",", "Any", "]", "=", "REQ", "(", "argument_type", "=", "\"body\"", ")", ",", "user_specified_topic", ":", ...
[ 14, 0 ]
[ 39, 25 ]
python
en
['en', 'error', 'th']
False
TestJobTemplateSerializerGetSummaryFields.test_copy_edit_standard
(self, mocker, job_template_factory)
Verify that the exact output of the access.py methods are put into the serializer user_capabilities
Verify that the exact output of the access.py methods are put into the serializer user_capabilities
def test_copy_edit_standard(self, mocker, job_template_factory): """Verify that the exact output of the access.py methods are put into the serializer user_capabilities""" jt_obj = job_template_factory('testJT', project='proj1', persisted=False).job_template jt_obj.admin_role = Role(id=9...
[ "def", "test_copy_edit_standard", "(", "self", ",", "mocker", ",", "job_template_factory", ")", ":", "jt_obj", "=", "job_template_factory", "(", "'testJT'", ",", "project", "=", "'proj1'", ",", "persisted", "=", "False", ")", ".", "job_template", "jt_obj", ".", ...
[ 89, 4 ]
[ 115, 64 ]
python
en
['en', 'en', 'en']
True
unicode_app.get_font_list
(self)
Get a list of all the fonts available on this system.
Get a list of all the fonts available on this system.
def get_font_list(self): '''Get a list of all the fonts available on this system. ''' fonts_path = CoreLabel.get_system_fonts_dir() flist = [] for fdir in fonts_path: for fpath in sorted(os.listdir(fdir)): if fpath.endswith('.ttf'): ...
[ "def", "get_font_list", "(", "self", ")", ":", "fonts_path", "=", "CoreLabel", ".", "get_system_fonts_dir", "(", ")", "flist", "=", "[", "]", "for", "fdir", "in", "fonts_path", ":", "for", "fpath", "in", "sorted", "(", "os", ".", "listdir", "(", "fdir", ...
[ 226, 4 ]
[ 238, 28 ]
python
en
['en', 'en', 'en']
True
newer_pairwise_group
(sources_groups, targets)
Walk both arguments in parallel, testing if each source group is newer than its corresponding target. Returns a pair of lists (sources_groups, targets) where sources is newer than target, according to the semantics of 'newer_group()'.
Walk both arguments in parallel, testing if each source group is newer than its corresponding target. Returns a pair of lists (sources_groups, targets) where sources is newer than target, according to the semantics of 'newer_group()'.
def newer_pairwise_group(sources_groups, targets): """Walk both arguments in parallel, testing if each source group is newer than its corresponding target. Returns a pair of lists (sources_groups, targets) where sources is newer than target, according to the semantics of 'newer_group()'. """ if ...
[ "def", "newer_pairwise_group", "(", "sources_groups", ",", "targets", ")", ":", "if", "len", "(", "sources_groups", ")", "!=", "len", "(", "targets", ")", ":", "raise", "ValueError", "(", "\"'sources_group' and 'targets' must be the same length\"", ")", "# build a pai...
[ 6, 0 ]
[ 24, 31 ]
python
en
['en', 'en', 'en']
True
_add_doc
(func, doc)
Add documentation to a function.
Add documentation to a function.
def _add_doc(func, doc): """Add documentation to a function.""" func.__doc__ = doc
[ "def", "_add_doc", "(", "func", ",", "doc", ")", ":", "func", ".", "__doc__", "=", "doc" ]
[ 74, 0 ]
[ 76, 22 ]
python
en
['en', 'en', 'en']
True
_import_module
(name)
Import module, returning the module after the last dot.
Import module, returning the module after the last dot.
def _import_module(name): """Import module, returning the module after the last dot.""" __import__(name) return sys.modules[name]
[ "def", "_import_module", "(", "name", ")", ":", "__import__", "(", "name", ")", "return", "sys", ".", "modules", "[", "name", "]" ]
[ 79, 0 ]
[ 82, 28 ]
python
en
['en', 'en', 'en']
True
add_move
(move)
Add an item to six.moves.
Add an item to six.moves.
def add_move(move): """Add an item to six.moves.""" setattr(_MovedItems, move.name, move)
[ "def", "add_move", "(", "move", ")", ":", "setattr", "(", "_MovedItems", ",", "move", ".", "name", ",", "move", ")" ]
[ 485, 0 ]
[ 487, 41 ]
python
en
['en', 'en', 'en']
True
remove_move
(name)
Remove item from six.moves.
Remove item from six.moves.
def remove_move(name): """Remove item from six.moves.""" try: delattr(_MovedItems, name) except AttributeError: try: del moves.__dict__[name] except KeyError: raise AttributeError("no such move, %r" % (name,))
[ "def", "remove_move", "(", "name", ")", ":", "try", ":", "delattr", "(", "_MovedItems", ",", "name", ")", "except", "AttributeError", ":", "try", ":", "del", "moves", ".", "__dict__", "[", "name", "]", "except", "KeyError", ":", "raise", "AttributeError", ...
[ 490, 0 ]
[ 498, 62 ]
python
en
['en', 'en', 'en']
True
with_metaclass
(meta, *bases)
Create a base class with a metaclass.
Create a base class with a metaclass.
def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" # This requires a bit of explanation: the basic idea is to make a dummy # metaclass for one level of class instantiation that replaces itself with # the actual metaclass. class metaclass(meta): def __new__(cls, na...
[ "def", "with_metaclass", "(", "meta", ",", "*", "bases", ")", ":", "# This requires a bit of explanation: the basic idea is to make a dummy", "# metaclass for one level of class instantiation that replaces itself with", "# the actual metaclass.", "class", "metaclass", "(", "meta", ")...
[ 799, 0 ]
[ 808, 61 ]
python
en
['en', 'en', 'en']
True
add_metaclass
(metaclass)
Class decorator for creating a class with a metaclass.
Class decorator for creating a class with a metaclass.
def add_metaclass(metaclass): """Class decorator for creating a class with a metaclass.""" def wrapper(cls): orig_vars = cls.__dict__.copy() slots = orig_vars.get('__slots__') if slots is not None: if isinstance(slots, str): slots = [slots] for slo...
[ "def", "add_metaclass", "(", "metaclass", ")", ":", "def", "wrapper", "(", "cls", ")", ":", "orig_vars", "=", "cls", ".", "__dict__", ".", "copy", "(", ")", "slots", "=", "orig_vars", ".", "get", "(", "'__slots__'", ")", "if", "slots", "is", "not", "...
[ 811, 0 ]
[ 824, 18 ]
python
en
['en', 'en', 'en']
True
python_2_unicode_compatible
(klass)
A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class.
A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing.
def python_2_unicode_compatible(klass): """ A decorator that defines __unicode__ and __str__ methods under Python 2. Under Python 3 it does nothing. To support Python 2 and 3 with a single code base, define a __str__ method returning text and apply this decorator to the class. """ if PY2: ...
[ "def", "python_2_unicode_compatible", "(", "klass", ")", ":", "if", "PY2", ":", "if", "'__str__'", "not", "in", "klass", ".", "__dict__", ":", "raise", "ValueError", "(", "\"@python_2_unicode_compatible cannot be applied \"", "\"to %s because it doesn't define __str__().\""...
[ 827, 0 ]
[ 842, 16 ]
python
en
['en', 'error', 'th']
False
_SixMetaPathImporter.is_package
(self, fullname)
Return true, if the named module is a package. We need this method to get correct spec objects with Python 3.4 (see PEP451)
Return true, if the named module is a package.
def is_package(self, fullname): """ Return true, if the named module is a package. We need this method to get correct spec objects with Python 3.4 (see PEP451) """ return hasattr(self.__get_module(fullname), "__path__")
[ "def", "is_package", "(", "self", ",", "fullname", ")", ":", "return", "hasattr", "(", "self", ".", "__get_module", "(", "fullname", ")", ",", "\"__path__\"", ")" ]
[ 208, 4 ]
[ 215, 63 ]
python
en
['en', 'error', 'th']
False
_SixMetaPathImporter.get_code
(self, fullname)
Return None Required, if is_package is implemented
Return None
def get_code(self, fullname): """Return None Required, if is_package is implemented""" self.__get_module(fullname) # eventually raises ImportError return None
[ "def", "get_code", "(", "self", ",", "fullname", ")", ":", "self", ".", "__get_module", "(", "fullname", ")", "# eventually raises ImportError", "return", "None" ]
[ 217, 4 ]
[ 222, 19 ]
python
en
['en', 'co', 'en']
False
TestWorkflowJobTemplateNodeSerializerCharPrompts.test_change_single_field
(self, WFJT_serializer)
Test that a single prompt field can be changed without affecting other fields
Test that a single prompt field can be changed without affecting other fields
def test_change_single_field(self, WFJT_serializer): "Test that a single prompt field can be changed without affecting other fields" internal_value = WFJT_serializer.to_internal_value({'job_type': 'check'}) assert internal_value['job_type'] == 'check' WFJT_serializer.instance.job_type = ...
[ "def", "test_change_single_field", "(", "self", ",", "WFJT_serializer", ")", ":", "internal_value", "=", "WFJT_serializer", ".", "to_internal_value", "(", "{", "'job_type'", ":", "'check'", "}", ")", "assert", "internal_value", "[", "'job_type'", "]", "==", "'chec...
[ 133, 4 ]
[ 138, 61 ]
python
en
['en', 'en', 'en']
True
TestWorkflowJobTemplateNodeSerializerCharPrompts.test_null_single_field
(self, WFJT_serializer)
Test that a single prompt field can be removed without affecting other fields
Test that a single prompt field can be removed without affecting other fields
def test_null_single_field(self, WFJT_serializer): "Test that a single prompt field can be removed without affecting other fields" internal_value = WFJT_serializer.to_internal_value({'job_type': None}) assert internal_value['job_type'] is None WFJT_serializer.instance.job_type = None ...
[ "def", "test_null_single_field", "(", "self", ",", "WFJT_serializer", ")", ":", "internal_value", "=", "WFJT_serializer", ".", "to_internal_value", "(", "{", "'job_type'", ":", "None", "}", ")", "assert", "internal_value", "[", "'job_type'", "]", "is", "None", "...
[ 140, 4 ]
[ 145, 61 ]
python
en
['en', 'en', 'en']
True
normalize_eols
(raw_contents)
Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment. Return the resulting block of text with normalized `\n` EOL sequences ready to be written to disk using current platform's native EOLs.
Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment.
def normalize_eols(raw_contents): """ Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment. Return the resulting block of text with normalized `\n` EOL sequences ready to be written to disk using current platform's native EOLs. """ lines_...
[ "def", "normalize_eols", "(", "raw_contents", ")", ":", "lines_list", "=", "raw_contents", ".", "splitlines", "(", ")", "# Ensure last line has its EOL", "if", "lines_list", "and", "lines_list", "[", "-", "1", "]", ":", "lines_list", ".", "append", "(", "''", ...
[ 159, 0 ]
[ 171, 32 ]
python
en
['en', 'error', 'th']
False
write_pot_file
(potfile, msgs)
Write the :param potfile: POT file with the :param msgs: contents, previously making sure its format is valid.
Write the :param potfile: POT file with the :param msgs: contents, previously making sure its format is valid.
def write_pot_file(potfile, msgs): """ Write the :param potfile: POT file with the :param msgs: contents, previously making sure its format is valid. """ pot_lines = msgs.splitlines() if os.path.exists(potfile): # Strip the header lines = dropwhile(len, pot_lines) else: ...
[ "def", "write_pot_file", "(", "potfile", ",", "msgs", ")", ":", "pot_lines", "=", "msgs", ".", "splitlines", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "potfile", ")", ":", "# Strip the header", "lines", "=", "dropwhile", "(", "len", ",", "...
[ 174, 0 ]
[ 195, 22 ]
python
en
['en', 'error', 'th']
False
BuildFile.work_path
(self)
Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version.
Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version.
def work_path(self): """ Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version. """ if not self.is_templatized: return self.path extension = { 'djangojs': 'c', 'django...
[ "def", "work_path", "(", "self", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "self", ".", "path", "extension", "=", "{", "'djangojs'", ":", "'c'", ",", "'django'", ":", "'py'", ",", "}", ".", "get", "(", "self", ".", "domain"...
[ 87, 4 ]
[ 99, 64 ]
python
en
['en', 'error', 'th']
False
BuildFile.preprocess
(self)
Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility.
Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility.
def preprocess(self): """ Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility. """ if not self.is_templatized: return encoding = settings.FILE_CHARSET if self.command.settings_available else 'utf-8' with io....
[ "def", "preprocess", "(", "self", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "encoding", "=", "settings", ".", "FILE_CHARSET", "if", "self", ".", "command", ".", "settings_available", "else", "'utf-8'", "with", "io", ".", "open", ...
[ 101, 4 ]
[ 119, 29 ]
python
en
['en', 'error', 'th']
False
BuildFile.postprocess_messages
(self, msgs)
Postprocess messages generated by xgettext GNU gettext utility. Transform paths as if these messages were generated from original translatable files rather than from preprocessed versions.
Postprocess messages generated by xgettext GNU gettext utility.
def postprocess_messages(self, msgs): """ Postprocess messages generated by xgettext GNU gettext utility. Transform paths as if these messages were generated from original translatable files rather than from preprocessed versions. """ if not self.is_templatized: ...
[ "def", "postprocess_messages", "(", "self", ",", "msgs", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "msgs", "# Remove '.py' suffix", "if", "os", ".", "name", "==", "'nt'", ":", "# Preserve '.\\' prefix on Windows to respect gettext behavior",...
[ 121, 4 ]
[ 145, 9 ]
python
en
['en', 'error', 'th']
False
BuildFile.cleanup
(self)
Remove a preprocessed copy of a translatable file (if any).
Remove a preprocessed copy of a translatable file (if any).
def cleanup(self): """ Remove a preprocessed copy of a translatable file (if any). """ if self.is_templatized: # This check is needed for the case of a symlinked file and its # source being processed inside a single group (locale dir); # removing eithe...
[ "def", "cleanup", "(", "self", ")", ":", "if", "self", ".", "is_templatized", ":", "# This check is needed for the case of a symlinked file and its", "# source being processed inside a single group (locale dir);", "# removing either of those two removes both.", "if", "os", ".", "pa...
[ 147, 4 ]
[ 156, 41 ]
python
en
['en', 'error', 'th']
False
Command.build_potfiles
(self)
Build pot files and apply msguniq to them.
Build pot files and apply msguniq to them.
def build_potfiles(self): """ Build pot files and apply msguniq to them. """ file_list = self.find_files(".") self.remove_potfiles() self.process_files(file_list) potfiles = [] for path in self.locale_paths: potfile = os.path.join(path, '%s.pot...
[ "def", "build_potfiles", "(", "self", ")", ":", "file_list", "=", "self", ".", "find_files", "(", "\".\"", ")", "self", ".", "remove_potfiles", "(", ")", "self", ".", "process_files", "(", "file_list", ")", "potfiles", "=", "[", "]", "for", "path", "in",...
[ 395, 4 ]
[ 419, 23 ]
python
en
['en', 'error', 'th']
False
Command.find_files
(self, root)
Helper method to get all files in the given root. Also check that there is a matching locale dir for each file.
Helper method to get all files in the given root. Also check that there is a matching locale dir for each file.
def find_files(self, root): """ Helper method to get all files in the given root. Also check that there is a matching locale dir for each file. """ def is_ignored(path, ignore_patterns): """ Check if the given path should be ignored or not. ""...
[ "def", "find_files", "(", "self", ",", "root", ")", ":", "def", "is_ignored", "(", "path", ",", "ignore_patterns", ")", ":", "\"\"\"\n Check if the given path should be ignored or not.\n \"\"\"", "filename", "=", "os", ".", "path", ".", "basename",...
[ 427, 4 ]
[ 486, 32 ]
python
en
['en', 'error', 'th']
False
Command.process_files
(self, file_list)
Group translatable files by locale directory and run pot file build process for each group.
Group translatable files by locale directory and run pot file build process for each group.
def process_files(self, file_list): """ Group translatable files by locale directory and run pot file build process for each group. """ file_groups = {} for translatable in file_list: file_group = file_groups.setdefault(translatable.locale_dir, []) ...
[ "def", "process_files", "(", "self", ",", "file_list", ")", ":", "file_groups", "=", "{", "}", "for", "translatable", "in", "file_list", ":", "file_group", "=", "file_groups", ".", "setdefault", "(", "translatable", ".", "locale_dir", ",", "[", "]", ")", "...
[ 488, 4 ]
[ 498, 54 ]
python
en
['en', 'error', 'th']
False
Command.process_locale_dir
(self, locale_dir, files)
Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory. Uses the xgettext GNU gettext utility.
Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory.
def process_locale_dir(self, locale_dir, files): """ Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory. Uses the xgettext GNU gettext utility. """ build_files = [] for translatable in files: ...
[ "def", "process_locale_dir", "(", "self", ",", "locale_dir", ",", "files", ")", ":", "build_files", "=", "[", "]", "for", "translatable", "in", "files", ":", "if", "self", ".", "verbosity", ">", "1", ":", "self", ".", "stdout", ".", "write", "(", "'pro...
[ 500, 4 ]
[ 593, 32 ]
python
en
['en', 'error', 'th']
False
Command.write_po_file
(self, potfile, locale)
Creates or updates the PO file for self.domain and :param locale:. Uses contents of the existing :param potfile:. Uses msgmerge, and msgattrib GNU gettext utilities.
Creates or updates the PO file for self.domain and :param locale:. Uses contents of the existing :param potfile:.
def write_po_file(self, potfile, locale): """ Creates or updates the PO file for self.domain and :param locale:. Uses contents of the existing :param potfile:. Uses msgmerge, and msgattrib GNU gettext utilities. """ basedir = os.path.join(os.path.dirname(potfile), locale...
[ "def", "write_po_file", "(", "self", ",", "potfile", ",", "locale", ")", ":", "basedir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "potfile", ")", ",", "locale", ",", "'LC_MESSAGES'", ")", "if", "not", "os", ...
[ 595, 4 ]
[ 635, 45 ]
python
en
['en', 'error', 'th']
False
Command.copy_plural_forms
(self, msgs, locale)
Copies plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file.
Copies plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file.
def copy_plural_forms(self, msgs, locale): """ Copies plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file. """ django_dir = os.path.normpath(os.path.join(...
[ "def", "copy_plural_forms", "(", "self", ",", "msgs", ",", "locale", ")", ":", "django_dir", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "upath", "(", "django", ".", "__...
[ 637, 4 ]
[ 666, 19 ]
python
en
['en', 'error', 'th']
False
TypesPrintTest.check_signature
( self, signature: str, retval: T, func: Callable[..., T], *args: Any, **kwargs: Any )
Checks if print_types outputs `signature` when func is called with *args and **kwargs. Do not decorate func with print_types before passing into this function. func will be decorated with print_types within this function.
Checks if print_types outputs `signature` when func is called with *args and **kwargs. Do not decorate func with print_types before passing into this function. func will be decorated with print_types within this function.
def check_signature( self, signature: str, retval: T, func: Callable[..., T], *args: Any, **kwargs: Any ) -> None: """ Checks if print_types outputs `signature` when func is called with *args and **kwargs. Do not decorate func with print_types before passing into this function. ...
[ "def", "check_signature", "(", "self", ",", "signature", ":", "str", ",", "retval", ":", "T", ",", "func", ":", "Callable", "[", "...", ",", "T", "]", ",", "*", "args", ":", "Any", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "t...
[ 27, 4 ]
[ 41, 40 ]
python
en
['en', 'error', 'th']
False
make_safe_digest
(string: str, hash_func: Callable[[bytes], Any] = hashlib.sha1)
return a hex digest of `string`.
return a hex digest of `string`.
def make_safe_digest(string: str, hash_func: Callable[[bytes], Any] = hashlib.sha1) -> str: """ return a hex digest of `string`. """ # hashlib.sha1, md5, etc. expect bytes, so non-ASCII strings must # be encoded. return hash_func(string.encode("utf-8")).hexdigest()
[ "def", "make_safe_digest", "(", "string", ":", "str", ",", "hash_func", ":", "Callable", "[", "[", "bytes", "]", ",", "Any", "]", "=", "hashlib", ".", "sha1", ")", "->", "str", ":", "# hashlib.sha1, md5, etc. expect bytes, so non-ASCII strings must", "# be encoded...
[ 88, 0 ]
[ 94, 56 ]
python
en
['en', 'error', 'th']
False
log_statsd_event
(name: str)
Sends a single event to statsd with the desired name and the current timestamp This can be used to provide vertical lines in generated graphs, for example when doing a prod deploy, bankruptcy request, or other one-off events Note that to draw this event as a vertical line in graphite you can ...
Sends a single event to statsd with the desired name and the current timestamp
def log_statsd_event(name: str) -> None: """ Sends a single event to statsd with the desired name and the current timestamp This can be used to provide vertical lines in generated graphs, for example when doing a prod deploy, bankruptcy request, or other one-off events Note that to draw this e...
[ "def", "log_statsd_event", "(", "name", ":", "str", ")", "->", "None", ":", "event_name", "=", "f\"events.{name}\"", "statsd", ".", "incr", "(", "event_name", ")" ]
[ 97, 0 ]
[ 109, 27 ]
python
en
['en', 'error', 'th']
False
query_chunker
( queries: List[Any], id_collector: Optional[Set[int]] = None, chunk_size: int = 1000, db_chunk_size: Optional[int] = None, )
This merges one or more Django ascending-id queries into a generator that returns chunks of chunk_size row objects during each yield, preserving id order across all results.. Queries should satisfy these conditions: - They should be Django filters. - They should return Django objects w...
This merges one or more Django ascending-id queries into a generator that returns chunks of chunk_size row objects during each yield, preserving id order across all results..
def query_chunker( queries: List[Any], id_collector: Optional[Set[int]] = None, chunk_size: int = 1000, db_chunk_size: Optional[int] = None, ) -> Iterator[Any]: """ This merges one or more Django ascending-id queries into a generator that returns chunks of chunk_size row objects during e...
[ "def", "query_chunker", "(", "queries", ":", "List", "[", "Any", "]", ",", "id_collector", ":", "Optional", "[", "Set", "[", "int", "]", "]", "=", "None", ",", "chunk_size", ":", "int", "=", "1000", ",", "db_chunk_size", ":", "Optional", "[", "int", ...
[ 124, 0 ]
[ 181, 51 ]
python
en
['en', 'error', 'th']
False
split_by
(array: List[Any], group_size: int, filler: Any)
Group elements into list of size `group_size` and fill empty cells with `filler`. Recipe from https://docs.python.org/3/library/itertools.html
Group elements into list of size `group_size` and fill empty cells with `filler`. Recipe from https://docs.python.org/3/library/itertools.html
def split_by(array: List[Any], group_size: int, filler: Any) -> List[List[Any]]: """ Group elements into list of size `group_size` and fill empty cells with `filler`. Recipe from https://docs.python.org/3/library/itertools.html """ args = [iter(array)] * group_size return list(map(list, zip_long...
[ "def", "split_by", "(", "array", ":", "List", "[", "Any", "]", ",", "group_size", ":", "int", ",", "filler", ":", "Any", ")", "->", "List", "[", "List", "[", "Any", "]", "]", ":", "args", "=", "[", "iter", "(", "array", ")", "]", "*", "group_si...
[ 197, 0 ]
[ 203, 64 ]
python
en
['en', 'error', 'th']
False
StatsDWrapper._our_gauge
(self, stat: str, value: float, rate: float = 1, delta: bool = False)
Set a gauge value.
Set a gauge value.
def _our_gauge(self, stat: str, value: float, rate: float = 1, delta: bool = False) -> None: """Set a gauge value.""" from django_statsd.clients import statsd if delta: value_str = f"{value:+g}|g" else: value_str = f"{value:g}|g" statsd._send(stat, value_...
[ "def", "_our_gauge", "(", "self", ",", "stat", ":", "str", ",", "value", ":", "float", ",", "rate", ":", "float", "=", "1", ",", "delta", ":", "bool", "=", "False", ")", "->", "None", ":", "from", "django_statsd", ".", "clients", "import", "statsd", ...
[ 31, 4 ]
[ 39, 43 ]
python
en
['en', 'da', 'en']
True
reverse_remove_duplicate_renditions
(*args, **kwargs)
This is a no-op. The migration removes duplicates, we cannot recreate those duplicates.
This is a no-op. The migration removes duplicates, we cannot recreate those duplicates.
def reverse_remove_duplicate_renditions(*args, **kwargs): """This is a no-op. The migration removes duplicates, we cannot recreate those duplicates.""" pass
[ "def", "reverse_remove_duplicate_renditions", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pass" ]
[ 27, 0 ]
[ 29, 8 ]
python
en
['en', 'en', 'en']
True
fwhm
(lambda_, d, alpha1=1.3)
The nominal Full Width Half Maximum (FWHM) of a LOFAR Station beam. :param lambda_: wavelength in meters :param d: station diameter. :param alpha1: depends on the tapering intrinsic to the layout of the station, and any additional tapering which may be used to form the ...
The nominal Full Width Half Maximum (FWHM) of a LOFAR Station beam.
def fwhm(lambda_, d, alpha1=1.3): """ The nominal Full Width Half Maximum (FWHM) of a LOFAR Station beam. :param lambda_: wavelength in meters :param d: station diameter. :param alpha1: depends on the tapering intrinsic to the layout of the station, and any additional tapering which...
[ "def", "fwhm", "(", "lambda_", ",", "d", ",", "alpha1", "=", "1.3", ")", ":", "return", "alpha1", "*", "lambda_", "/", "d" ]
[ 10, 0 ]
[ 24, 31 ]
python
en
['en', 'error', 'th']
False
fov
(fwhm)
The Field of View (FoV) of a LOFAR station :param fwhm: nominal Full Width Half Maximum, caulculated with :func:`fwhm`.
The Field of View (FoV) of a LOFAR station
def fov(fwhm): """ The Field of View (FoV) of a LOFAR station :param fwhm: nominal Full Width Half Maximum, caulculated with :func:`fwhm`. """ return math.pi * ((fwhm / 2) ** 2)
[ "def", "fov", "(", "fwhm", ")", ":", "return", "math", ".", "pi", "*", "(", "(", "fwhm", "/", "2", ")", "**", "2", ")" ]
[ 27, 0 ]
[ 34, 38 ]
python
en
['en', 'error', 'th']
False
SNMPOptions.__init__
(self, port=161, timeout=3, nretries=1)
:param port: Port number for SNMP communication :param timeout: time in seconds to wait for the request to wait before giving up :param nretries: The maximum number of retries each connection should attempt :type port: Int :type timeout: Int :type nretries: Int ...
:param port: Port number for SNMP communication :param timeout: time in seconds to wait for the request to wait before giving up :param nretries: The maximum number of retries each connection should attempt :type port: Int :type timeout: Int :type nretries: Int ...
def __init__(self, port=161, timeout=3, nretries=1): """ :param port: Port number for SNMP communication :param timeout: time in seconds to wait for the request to wait before giving up :param nretries: The maximum number of retries each connection should attempt :type port:...
[ "def", "__init__", "(", "self", ",", "port", "=", "161", ",", "timeout", "=", "3", ",", "nretries", "=", "1", ")", ":", "if", "PY2", ":", "super", "(", "SNMPOptions", ",", "self", ")", ".", "__init__", "(", "ProtocolEnum", ".", "SNMP", ")", "else",...
[ 129, 4 ]
[ 145, 32 ]
python
en
['en', 'ja', 'th']
False
duration_string
(duration)
Version of str(timedelta) which is not English specific.
Version of str(timedelta) which is not English specific.
def duration_string(duration): """Version of str(timedelta) which is not English specific.""" days, hours, minutes, seconds, microseconds = _get_duration_components(duration) string = '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds) if days: string = '{} '.format(days) + string if mic...
[ "def", "duration_string", "(", "duration", ")", ":", "days", ",", "hours", ",", "minutes", ",", "seconds", ",", "microseconds", "=", "_get_duration_components", "(", "duration", ")", "string", "=", "'{:02d}:{:02d}:{:02d}'", ".", "format", "(", "hours", ",", "m...
[ 17, 0 ]
[ 27, 17 ]
python
en
['en', 'en', 'en']
True
BotTest.test_bot_add_subscription
(self)
Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message event or invitation email is sent when add_subs...
Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message event or invitation email is sent when add_subs...
def test_bot_add_subscription(self) -> None: """ Calling POST /json/users/me/subscriptions should successfully add streams, and a stream to the list of subscriptions and confirm the right number of events are generated. When 'principals' has a bot, no notification message...
[ "def", "test_bot_add_subscription", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "iago", "=", "self", ".", "example_user", "(", "\"iago\"", ")", "self", ".", "login_user", "(", "hamlet", ")", "# N...
[ 370, 4 ]
[ 415, 42 ]
python
en
['en', 'error', 'th']
False
BotTest.test_deactivate_bogus_bot
(self)
Deleting a bogus bot will succeed silently.
Deleting a bogus bot will succeed silently.
def test_deactivate_bogus_bot(self) -> None: """Deleting a bogus bot will succeed silently.""" self.login("hamlet") self.assert_num_bots_equal(0) self.create_bot() self.assert_num_bots_equal(1) invalid_user_id = 1000 result = self.client_delete(f"/json/bots/{inval...
[ "def", "test_deactivate_bogus_bot", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_num_bots_equal", "(", "0", ")", "self", ".", "create_bot", "(", ")", "self", ".", "assert_num_bots_equal", "(", "1", ...
[ 571, 4 ]
[ 580, 37 ]
python
en
['en', 'en', 'en']
True
BotTest.test_bot_deactivation_attacks
(self)
You cannot deactivate somebody else's bot.
You cannot deactivate somebody else's bot.
def test_bot_deactivation_attacks(self) -> None: """You cannot deactivate somebody else's bot.""" self.login("hamlet") self.assert_num_bots_equal(0) self.create_bot() self.assert_num_bots_equal(1) # Have Othello try to deactivate both Hamlet and # Hamlet's bot. ...
[ "def", "test_bot_deactivation_attacks", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "assert_num_bots_equal", "(", "0", ")", "self", ".", "create_bot", "(", ")", "self", ".", "assert_num_bots_equal", "(", "1...
[ 631, 4 ]
[ 657, 37 ]
python
en
['en', 'en', 'en']
True
BotTest.test_patch_bogus_bot
(self)
Deleting a bogus bot will succeed silently.
Deleting a bogus bot will succeed silently.
def test_patch_bogus_bot(self) -> None: """Deleting a bogus bot will succeed silently.""" self.login("hamlet") self.create_bot() bot_info = { "full_name": "Fred", } invalid_user_id = 1000 result = self.client_patch(f"/json/bots/{invalid_user_id}", bot_...
[ "def", "test_patch_bogus_bot", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "create_bot", "(", ")", "bot_info", "=", "{", "\"full_name\"", ":", "\"Fred\"", ",", "}", "invalid_user_id", "=", "1000", "result...
[ 1383, 4 ]
[ 1393, 37 ]
python
en
['en', 'en', 'en']
True
ThreadGroupHandler.groups
(self, jmx)
Get wrappers for thread groups that are enabled
Get wrappers for thread groups that are enabled
def groups(self, jmx): """ Get wrappers for thread groups that are enabled """ for _class in self.CLASSES: for group in jmx.get(_class.XPATH): if group.get("enabled") != "false": yield _class(group, self.log)
[ "def", "groups", "(", "self", ",", "jmx", ")", ":", "for", "_class", "in", "self", ".", "CLASSES", ":", "for", "group", "in", "jmx", ".", "get", "(", "_class", ".", "XPATH", ")", ":", "if", "group", ".", "get", "(", "\"enabled\"", ")", "!=", "\"f...
[ 177, 4 ]
[ 184, 49 ]
python
en
['en', 'error', 'th']
False
ThreadGroupHandler.convert
(self, source, target_gtype, load, concurrency, iterations)
Convert a thread group to ThreadGroup/ConcurrencyThreadGroup for applying of load
Convert a thread group to ThreadGroup/ConcurrencyThreadGroup for applying of load
def convert(self, source, target_gtype, load, concurrency, iterations): """ Convert a thread group to ThreadGroup/ConcurrencyThreadGroup for applying of load """ msg = "Converting %s (%s) to %s and apply load parameters" self.log.debug(msg, source.gtype, source.get_testname(), ta...
[ "def", "convert", "(", "self", ",", "source", ",", "target_gtype", ",", "load", ",", "concurrency", ",", "iterations", ")", ":", "msg", "=", "\"Converting %s (%s) to %s and apply load parameters\"", "self", ".", "log", ".", "debug", "(", "msg", ",", "source", ...
[ 186, 4 ]
[ 228, 77 ]
python
en
['en', 'error', 'th']
False
WagtailAPIRouter.get_model_endpoint
(self, model)
Finds the endpoint in the API that represents a model Returns a (name, endpoint_class) tuple. Or None if an endpoint is not found.
Finds the endpoint in the API that represents a model
def get_model_endpoint(self, model): """ Finds the endpoint in the API that represents a model Returns a (name, endpoint_class) tuple. Or None if an endpoint is not found. """ for name, class_ in self._endpoints.items(): if issubclass(model, class_.model): ...
[ "def", "get_model_endpoint", "(", "self", ",", "model", ")", ":", "for", "name", ",", "class_", "in", "self", ".", "_endpoints", ".", "items", "(", ")", ":", "if", "issubclass", "(", "model", ",", "class_", ".", "model", ")", ":", "return", "name", "...
[ 19, 4 ]
[ 28, 35 ]
python
en
['en', 'error', 'th']
False
WagtailAPIRouter.get_model_listing_urlpath
(self, model)
Returns a URL path (excluding scheme and hostname) to the listing page of a model Returns None if the model is not represented by any endpoints.
Returns a URL path (excluding scheme and hostname) to the listing page of a model
def get_model_listing_urlpath(self, model): """ Returns a URL path (excluding scheme and hostname) to the listing page of a model Returns None if the model is not represented by any endpoints. """ endpoint = self.get_model_endpoint(model) if endpoint: ...
[ "def", "get_model_listing_urlpath", "(", "self", ",", "model", ")", ":", "endpoint", "=", "self", ".", "get_model_endpoint", "(", "model", ")", "if", "endpoint", ":", "endpoint_name", ",", "endpoint_class", "=", "endpoint", "[", "0", "]", ",", "endpoint", "[...
[ 30, 4 ]
[ 42, 91 ]
python
en
['en', 'error', 'th']
False
WagtailAPIRouter.get_object_detail_urlpath
(self, model, pk)
Returns a URL path (excluding scheme and hostname) to the detail page of an object. Returns None if the object is not represented by any endpoints.
Returns a URL path (excluding scheme and hostname) to the detail page of an object.
def get_object_detail_urlpath(self, model, pk): """ Returns a URL path (excluding scheme and hostname) to the detail page of an object. Returns None if the object is not represented by any endpoints. """ endpoint = self.get_model_endpoint(model) if endpoint: ...
[ "def", "get_object_detail_urlpath", "(", "self", ",", "model", ",", "pk", ")", ":", "endpoint", "=", "self", ".", "get_model_endpoint", "(", "model", ")", "if", "endpoint", ":", "endpoint_name", ",", "endpoint_class", "=", "endpoint", "[", "0", "]", ",", "...
[ 44, 4 ]
[ 56, 95 ]
python
en
['en', 'error', 'th']
False
WagtailAPIRouter.urls
(self)
A shortcut to allow quick registration of the API in a URLconf. Use with Django's include() function: path('api/', include(myapi.urls)),
A shortcut to allow quick registration of the API in a URLconf.
def urls(self): """ A shortcut to allow quick registration of the API in a URLconf. Use with Django's include() function: path('api/', include(myapi.urls)), """ return self.get_urlpatterns(), self.url_namespace, self.url_namespace
[ "def", "urls", "(", "self", ")", ":", "return", "self", ".", "get_urlpatterns", "(", ")", ",", "self", ".", "url_namespace", ",", "self", ".", "url_namespace" ]
[ 81, 4 ]
[ 89, 77 ]
python
en
['en', 'error', 'th']
False
DockerSwitch.start
( self, controllers )
Start the switch
Start the switch
def start( self, controllers ): """Start the switch""" pass
[ "def", "start", "(", "self", ",", "controllers", ")", ":", "pass" ]
[ 124, 4 ]
[ 126, 12 ]
python
en
['en', 'en', 'en']
True
hexstr_to_bytes
(input_str: str)
Converts a hex string into bytes, removing the 0x if it's present.
Converts a hex string into bytes, removing the 0x if it's present.
def hexstr_to_bytes(input_str: str) -> bytes: """ Converts a hex string into bytes, removing the 0x if it's present. """ if input_str.startswith("0x") or input_str.startswith("0X"): return bytes.fromhex(input_str[2:]) return bytes.fromhex(input_str)
[ "def", "hexstr_to_bytes", "(", "input_str", ":", "str", ")", "->", "bytes", ":", "if", "input_str", ".", "startswith", "(", "\"0x\"", ")", "or", "input_str", ".", "startswith", "(", "\"0X\"", ")", ":", "return", "bytes", ".", "fromhex", "(", "input_str", ...
[ 4, 0 ]
[ 10, 35 ]
python
en
['en', 'error', 'th']
False
make_sized_bytes
(size: int)
Create a streamable type that subclasses "bytes" but requires instances to be a certain, fixed size.
Create a streamable type that subclasses "bytes" but requires instances to be a certain, fixed size.
def make_sized_bytes(size: int): """ Create a streamable type that subclasses "bytes" but requires instances to be a certain, fixed size. """ name = "bytes%d" % size def __new__(cls, v): v = bytes(v) if not isinstance(v, bytes) or len(v) != size: raise ValueError("ba...
[ "def", "make_sized_bytes", "(", "size", ":", "int", ")", ":", "name", "=", "\"bytes%d\"", "%", "size", "def", "__new__", "(", "cls", ",", "v", ")", ":", "v", "=", "bytes", "(", "v", ")", "if", "not", "isinstance", "(", "v", ",", "bytes", ")", "or...
[ 13, 0 ]
[ 64, 42 ]
python
en
['en', 'error', 'th']
False
Local.check
(self)
Check executors for finish. Return True if all of them has finished.
Check executors for finish. Return True if all of them has finished.
def check(self): """ Check executors for finish. Return True if all of them has finished. """ finished = True self._start_modules() for executor in self.executors: if executor in self.finished_modules: continue if executor not in ...
[ "def", "check", "(", "self", ")", ":", "finished", "=", "True", "self", ".", "_start_modules", "(", ")", "for", "executor", "in", "self", ".", "executors", ":", "if", "executor", "in", "self", ".", "finished_modules", ":", "continue", "if", "executor", "...
[ 107, 4 ]
[ 129, 23 ]
python
en
['en', 'error', 'th']
False
Local.shutdown
(self)
Call shutdown on executors
Call shutdown on executors
def shutdown(self): """ Call shutdown on executors """ exc_info = exc_value = None for executor in self.started_modules: self.log.debug("Shutdown %s", executor) try: executor.shutdown() except BaseException as exc: ...
[ "def", "shutdown", "(", "self", ")", ":", "exc_info", "=", "exc_value", "=", "None", "for", "executor", "in", "self", ".", "started_modules", ":", "self", ".", "log", ".", "debug", "(", "\"Shutdown %s\"", ",", "executor", ")", "try", ":", "executor", "."...
[ 131, 4 ]
[ 148, 40 ]
python
en
['en', 'error', 'th']
False
Local.post_process
(self)
Post-process executors
Post-process executors
def post_process(self): """ Post-process executors """ exc_info = exc_value = None for executor in self.executors: self.log.debug("Post-process %s", executor) try: executor.post_process() if executor in self.started_modules ...
[ "def", "post_process", "(", "self", ")", ":", "exc_info", "=", "exc_value", "=", "None", "for", "executor", "in", "self", ".", "executors", ":", "self", ".", "log", ".", "debug", "(", "\"Post-process %s\"", ",", "executor", ")", "try", ":", "executor", "...
[ 150, 4 ]
[ 175, 40 ]
python
en
['en', 'error', 'th']
False
check_inputs
(in1, in2, flags)
Perform checking on the user provided inputs and diagnose any abnormalities
Perform checking on the user provided inputs and diagnose any abnormalities
def check_inputs(in1, in2, flags): """ Perform checking on the user provided inputs and diagnose any abnormalities """ in1_kind, in1_err = classify_input_file(in1) in2_kind, in2_err = classify_input_file(in2) output_file = find_benchmark_flag('--benchmark_out=', flags) output_type = find_ben...
[ "def", "check_inputs", "(", "in1", ",", "in2", ",", "flags", ")", ":", "in1_kind", ",", "in1_err", "=", "classify_input_file", "(", "in1", ")", "in2_kind", ",", "in2_err", "=", "classify_input_file", "(", "in2", ")", "output_file", "=", "find_benchmark_flag", ...
[ 15, 0 ]
[ 32, 19 ]
python
en
['en', 'error', 'th']
False
MirroredMessageUsersTest.test_zephyr_mirror_new_recipient
(self, ignored: object)
Test mirror dummy user creation for PM recipients
Test mirror dummy user creation for PM recipients
def test_zephyr_mirror_new_recipient(self, ignored: object) -> None: """Test mirror dummy user creation for PM recipients""" client = get_client(name="zephyr_mirror") user = self.mit_user("starnine") sender = self.mit_user("sipbtest") new_user_email = "bob_the_new_user@mit.edu" ...
[ "def", "test_zephyr_mirror_new_recipient", "(", "self", ",", "ignored", ":", "object", ")", "->", "None", ":", "client", "=", "get_client", "(", "name", "=", "\"zephyr_mirror\"", ")", "user", "=", "self", ".", "mit_user", "(", "\"starnine\"", ")", "sender", ...
[ 62, 4 ]
[ 87, 44 ]
python
de
['nb', 'de', 'en']
False