nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
ym2011/POC-EXP
206b22d3a6b2a172359678df33bbc5b2ad04b6c3
K8/Web-Exp/sqlmap/lib/techniques/error/use.py
python
_formatPartialContent
(value)
return value
Prepares (possibly hex-encoded) partial content for safe console output
Prepares (possibly hex-encoded) partial content for safe console output
[ "Prepares", "(", "possibly", "hex", "-", "encoded", ")", "partial", "content", "for", "safe", "console", "output" ]
def _formatPartialContent(value): """ Prepares (possibly hex-encoded) partial content for safe console output """ if value and isinstance(value, basestring): try: value = hexdecode(value) except: pass finally: value = safecharencode(value) return value
[ "def", "_formatPartialContent", "(", "value", ")", ":", "if", "value", "and", "isinstance", "(", "value", ",", "basestring", ")", ":", "try", ":", "value", "=", "hexdecode", "(", "value", ")", "except", ":", "pass", "finally", ":", "value", "=", "safecha...
https://github.com/ym2011/POC-EXP/blob/206b22d3a6b2a172359678df33bbc5b2ad04b6c3/K8/Web-Exp/sqlmap/lib/techniques/error/use.py#L250-L263
microsoft/unilm
65f15af2a307ebb64cfb25adf54375b002e6fe8d
infoxlm/fairseq/examples/roberta/multiprocessing_bpe_encoder.py
python
MultiprocessingEncoder.encode_lines
(self, lines)
return ["PASS", enc_lines]
Encode a set of lines. All lines will be encoded together.
Encode a set of lines. All lines will be encoded together.
[ "Encode", "a", "set", "of", "lines", ".", "All", "lines", "will", "be", "encoded", "together", "." ]
def encode_lines(self, lines): """ Encode a set of lines. All lines will be encoded together. """ enc_lines = [] for line in lines: line = line.strip() if len(line) == 0 and not self.args.keep_empty: return ["EMPTY", None] tokens = self.encode(line) enc_lines.append(" ".join(tokens)) return ["PASS", enc_lines]
[ "def", "encode_lines", "(", "self", ",", "lines", ")", ":", "enc_lines", "=", "[", "]", "for", "line", "in", "lines", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "len", "(", "line", ")", "==", "0", "and", "not", "self", ".", "args", ...
https://github.com/microsoft/unilm/blob/65f15af2a307ebb64cfb25adf54375b002e6fe8d/infoxlm/fairseq/examples/roberta/multiprocessing_bpe_encoder.py#L107-L118
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/scipy/stats/stats.py
python
signaltonoise
(a, axis=0, ddof=0)
return np.where(sd == 0, 0, m/sd)
The signal-to-noise ratio of the input data. Returns the signal-to-noise ratio of `a`, here defined as the mean divided by the standard deviation. Parameters ---------- a : array_like An array_like object containing the sample data. axis : int or None, optional If axis is equal to None, the array is first ravel'd. If axis is an integer, this is the axis over which to operate. Default is 0. ddof : int, optional Degrees of freedom correction for standard deviation. Default is 0. Returns ------- s2n : ndarray The mean to standard deviation ratio(s) along `axis`, or 0 where the standard deviation is 0.
The signal-to-noise ratio of the input data.
[ "The", "signal", "-", "to", "-", "noise", "ratio", "of", "the", "input", "data", "." ]
def signaltonoise(a, axis=0, ddof=0): """ The signal-to-noise ratio of the input data. Returns the signal-to-noise ratio of `a`, here defined as the mean divided by the standard deviation. Parameters ---------- a : array_like An array_like object containing the sample data. axis : int or None, optional If axis is equal to None, the array is first ravel'd. If axis is an integer, this is the axis over which to operate. Default is 0. ddof : int, optional Degrees of freedom correction for standard deviation. Default is 0. Returns ------- s2n : ndarray The mean to standard deviation ratio(s) along `axis`, or 0 where the standard deviation is 0. """ a = np.asanyarray(a) m = a.mean(axis) sd = a.std(axis=axis, ddof=ddof) return np.where(sd == 0, 0, m/sd)
[ "def", "signaltonoise", "(", "a", ",", "axis", "=", "0", ",", "ddof", "=", "0", ")", ":", "a", "=", "np", ".", "asanyarray", "(", "a", ")", "m", "=", "a", ".", "mean", "(", "axis", ")", "sd", "=", "a", ".", "std", "(", "axis", "=", "axis", ...
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/scipy/stats/stats.py#L1864-L1891
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Lib/idlelib/configDialog.py
python
ConfigDialog.VarChanged_winHeight
(self, *params)
[]
def VarChanged_winHeight(self, *params): value = self.winHeight.get() self.AddChangedItem('main', 'EditorWindow', 'height', value)
[ "def", "VarChanged_winHeight", "(", "self", ",", "*", "params", ")", ":", "value", "=", "self", ".", "winHeight", ".", "get", "(", ")", "self", ".", "AddChangedItem", "(", "'main'", ",", "'EditorWindow'", ",", "'height'", ",", "value", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Lib/idlelib/configDialog.py#L593-L595
mgear-dev/mgear
06ddc26c5adb5eab07ca470c7fafa77404c8a1de
scripts/mgear/maya/shifter/component/shoulder_ms_01/guide.py
python
Guide.addParameters
(self)
Add the configurations settings
Add the configurations settings
[ "Add", "the", "configurations", "settings" ]
def addParameters(self): """Add the configurations settings""" self.pUseIndex = self.addParam("useIndex", "bool", False) self.pParentJointIndex = self.addParam( "parentJointIndex", "long", -1, None, None)
[ "def", "addParameters", "(", "self", ")", ":", "self", ".", "pUseIndex", "=", "self", ".", "addParam", "(", "\"useIndex\"", ",", "\"bool\"", ",", "False", ")", "self", ".", "pParentJointIndex", "=", "self", ".", "addParam", "(", "\"parentJointIndex\"", ",", ...
https://github.com/mgear-dev/mgear/blob/06ddc26c5adb5eab07ca470c7fafa77404c8a1de/scripts/mgear/maya/shifter/component/shoulder_ms_01/guide.py#L52-L58
GiulioRossetti/cdlib
b2c6311b99725bb2b029556f531d244a2af14a2a
cdlib/algorithms/crisp_partition.py
python
label_propagation
(g_original: object)
return NodeClustering( coms, g_original, "Label Propagation", method_parameters={"": ""} )
The Label Propagation algorithm (LPA) detects communities using network structure alone. The algorithm doesn’t require a pre-defined objective function or prior information about the communities. It works as follows: -Every node is initialized with a unique label (an identifier) -These labels propagate through the network -At every iteration of propagation, each node updates its label to the one that the maximum numbers of its neighbours belongs to. Ties are broken uniformly and randomly. -LPA reaches convergence when each node has the majority label of its neighbours. **Supported Graph Types** ========== ======== ======== Undirected Directed Weighted ========== ======== ======== Yes No No ========== ======== ======== :param g_original: a networkx/igraph object :return: EdgeClustering object :Example: >>> from cdlib import algorithms >>> import networkx as nx >>> G = nx.karate_club_graph() >>> coms = algorithms.label_propagation(G) :References: Cordasco, G., & Gargano, L. (2010, December). Community detection via semi-synchronous label propagation algorithms. In 2010 IEEE international workshop on: business applications of social network analysis (BASNA) (pp. 1-8). IEEE.
The Label Propagation algorithm (LPA) detects communities using network structure alone. The algorithm doesn’t require a pre-defined objective function or prior information about the communities. It works as follows: -Every node is initialized with a unique label (an identifier) -These labels propagate through the network -At every iteration of propagation, each node updates its label to the one that the maximum numbers of its neighbours belongs to. Ties are broken uniformly and randomly. -LPA reaches convergence when each node has the majority label of its neighbours.
[ "The", "Label", "Propagation", "algorithm", "(", "LPA", ")", "detects", "communities", "using", "network", "structure", "alone", ".", "The", "algorithm", "doesn’t", "require", "a", "pre", "-", "defined", "objective", "function", "or", "prior", "information", "ab...
def label_propagation(g_original: object) -> NodeClustering: """ The Label Propagation algorithm (LPA) detects communities using network structure alone. The algorithm doesn’t require a pre-defined objective function or prior information about the communities. It works as follows: -Every node is initialized with a unique label (an identifier) -These labels propagate through the network -At every iteration of propagation, each node updates its label to the one that the maximum numbers of its neighbours belongs to. Ties are broken uniformly and randomly. -LPA reaches convergence when each node has the majority label of its neighbours. **Supported Graph Types** ========== ======== ======== Undirected Directed Weighted ========== ======== ======== Yes No No ========== ======== ======== :param g_original: a networkx/igraph object :return: EdgeClustering object :Example: >>> from cdlib import algorithms >>> import networkx as nx >>> G = nx.karate_club_graph() >>> coms = algorithms.label_propagation(G) :References: Cordasco, G., & Gargano, L. (2010, December). Community detection via semi-synchronous label propagation algorithms. In 2010 IEEE international workshop on: business applications of social network analysis (BASNA) (pp. 1-8). IEEE. """ g = convert_graph_formats(g_original, nx.Graph) coms = list(nx.algorithms.community.label_propagation_communities(g)) coms = [list(x) for x in coms] return NodeClustering( coms, g_original, "Label Propagation", method_parameters={"": ""} )
[ "def", "label_propagation", "(", "g_original", ":", "object", ")", "->", "NodeClustering", ":", "g", "=", "convert_graph_formats", "(", "g_original", ",", "nx", ".", "Graph", ")", "coms", "=", "list", "(", "nx", ".", "algorithms", ".", "community", ".", "l...
https://github.com/GiulioRossetti/cdlib/blob/b2c6311b99725bb2b029556f531d244a2af14a2a/cdlib/algorithms/crisp_partition.py#L1143-L1184
huawei-noah/vega
d9f13deede7f2b584e4b1d32ffdb833856129989
vega/modules/operators/functions/pytorch_to_tf.py
python
assign_weights
(pt_state_dict, pretrained_prefix=None)
return [_var.assign(_value) for _var, _value in vars_values]
Load pytorch state_dict and assign to tensorflow model.
Load pytorch state_dict and assign to tensorflow model.
[ "Load", "pytorch", "state_dict", "and", "assign", "to", "tensorflow", "model", "." ]
def assign_weights(pt_state_dict, pretrained_prefix=None): """Load pytorch state_dict and assign to tensorflow model.""" import tensorflow as tf vars = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES) vars.pop(0) pt_state_dict = {k: v for k, v in pt_state_dict.items() if 'num_batches_tracked' not in k} def _filter_vars_by_keys(var): for key in pretrained_prefix.keys(): if var.name.startswith(key): return True def _filter_state_by_keys(state): for key in pretrained_prefix.values(): if state.startswith(key): return True if pretrained_prefix: vars = list(filter(_filter_vars_by_keys, vars)) pt_state_dict = {k: v for k, v in pt_state_dict.items() if _filter_state_by_keys(k)} if not pt_state_dict or not vars: raise ValueError("pertrained weight is None, please check the pretrained_prefix: {}".format(pretrained_prefix)) vars_values = load_weight(pt_state_dict, vars) return [_var.assign(_value) for _var, _value in vars_values]
[ "def", "assign_weights", "(", "pt_state_dict", ",", "pretrained_prefix", "=", "None", ")", ":", "import", "tensorflow", "as", "tf", "vars", "=", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "GLOBAL_VARIABLES", ")", "vars", ".", "pop", "(", ...
https://github.com/huawei-noah/vega/blob/d9f13deede7f2b584e4b1d32ffdb833856129989/vega/modules/operators/functions/pytorch_to_tf.py#L60-L84
timkpaine/tributary
90acb236d96a23c0c4794fd0f2da82c66060f737
tributary/streaming/output/email.py
python
make_email
(html, from_, subject="", attachments=None)
return message
Helper function to make emails html (str): content from_ (str): address to send the email from subject (str): subject of email attachments (list) : attachments to send
Helper function to make emails
[ "Helper", "function", "to", "make", "emails" ]
def make_email(html, from_, subject="", attachments=None): """Helper function to make emails html (str): content from_ (str): address to send the email from subject (str): subject of email attachments (list) : attachments to send """ message = emails.html(charset="utf-8", subject=subject, html=html, mail_from=from_) soup = BeautifulSoup(html, "html.parser") # strip markdown links for item in soup.findAll("a", {"class": "anchor-link"}): item.decompose() # strip matplotlib base outs for item in soup.find_all( "div", class_="output_text output_subarea output_execute_result" ): for c in item.contents: if "<matplotlib" in str(c): item.decompose() # remove dataframe table borders for item in soup.findAll("table", {"border": 1}): item["border"] = 0 item["cellspacing"] = 0 item["cellpadding"] = 0 # extract imgs for outlook imgs = soup.find_all("img") imgs_to_attach = {} # attach main part for i, img in enumerate(imgs): if not img.get("localdata"): continue imgs_to_attach[img.get("cell_id") + "_" + str(i) + ".png"] = base64.b64decode( img.get("localdata") ) img["src"] = "cid:" + img.get("cell_id") + "_" + str(i) + ".png" # encoders.encode_base64(part) del img["localdata"] # assemble email soup soup = str(soup) message = emails.html(charset="utf-8", subject=subject, html=soup, mail_from=from_) for img, data in imgs_to_attach.items(): message.attach(filename=img, content_disposition="inline", data=data) return message
[ "def", "make_email", "(", "html", ",", "from_", ",", "subject", "=", "\"\"", ",", "attachments", "=", "None", ")", ":", "message", "=", "emails", ".", "html", "(", "charset", "=", "\"utf-8\"", ",", "subject", "=", "subject", ",", "html", "=", "html", ...
https://github.com/timkpaine/tributary/blob/90acb236d96a23c0c4794fd0f2da82c66060f737/tributary/streaming/output/email.py#L10-L61
dansanderson/picotool
d8c51e58416f8010dc8c0fba3df5f0424b5bb852
pico8/util.py
python
BaseSection.to_lines
(self)
Generates lines of ASCII-encoded hexadecimal strings. Yields: One line of a hex string.
Generates lines of ASCII-encoded hexadecimal strings.
[ "Generates", "lines", "of", "ASCII", "-", "encoded", "hexadecimal", "strings", "." ]
def to_lines(self): """Generates lines of ASCII-encoded hexadecimal strings. Yields: One line of a hex string. """ for start_i in range(0, len(self._data), self.HEX_LINE_LENGTH_BYTES): end_i = start_i + self.HEX_LINE_LENGTH_BYTES if end_i > len(self._data): end_i = len(self._data) yield bytes(bytes_to_hex(bytes(self._data[start_i:end_i])), encoding='ascii') + b'\n'
[ "def", "to_lines", "(", "self", ")", ":", "for", "start_i", "in", "range", "(", "0", ",", "len", "(", "self", ".", "_data", ")", ",", "self", ".", "HEX_LINE_LENGTH_BYTES", ")", ":", "end_i", "=", "start_i", "+", "self", ".", "HEX_LINE_LENGTH_BYTES", "i...
https://github.com/dansanderson/picotool/blob/d8c51e58416f8010dc8c0fba3df5f0424b5bb852/pico8/util.py#L112-L123
ninja-ide/ninja-ide
87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0
ninja_ide/gui/ide.py
python
IDE.change_toolsdock_visibility
(self)
Switch the tools dock visibility
Switch the tools dock visibility
[ "Switch", "the", "tools", "dock", "visibility" ]
def change_toolsdock_visibility(self): """Switch the tools dock visibility""" tools_dock = IDE.get_service("tools_dock").buttons_widget if tools_dock.isVisible(): tools_dock.hide() else: tools_dock.show()
[ "def", "change_toolsdock_visibility", "(", "self", ")", ":", "tools_dock", "=", "IDE", ".", "get_service", "(", "\"tools_dock\"", ")", ".", "buttons_widget", "if", "tools_dock", ".", "isVisible", "(", ")", ":", "tools_dock", ".", "hide", "(", ")", "else", ":...
https://github.com/ninja-ide/ninja-ide/blob/87d91131bd19fdc3dcfd91eb97ad1e41c49c60c0/ninja_ide/gui/ide.py#L455-L461
cclib/cclib
81cd4a81cc4a3bbed7016b3e417ca9bff8ad3a92
cclib/parser/qchemparser.py
python
QChem.generate_formula_histogram
(self)
return histogram
From the atomnos, generate a histogram that represents the molecular formula.
From the atomnos, generate a histogram that represents the molecular formula.
[ "From", "the", "atomnos", "generate", "a", "histogram", "that", "represents", "the", "molecular", "formula", "." ]
def generate_formula_histogram(self): """From the atomnos, generate a histogram that represents the molecular formula. """ histogram = dict() for element in self.atomelements: if element in histogram.keys(): histogram[element] += 1 else: histogram[element] = 1 return histogram
[ "def", "generate_formula_histogram", "(", "self", ")", ":", "histogram", "=", "dict", "(", ")", "for", "element", "in", "self", ".", "atomelements", ":", "if", "element", "in", "histogram", ".", "keys", "(", ")", ":", "histogram", "[", "element", "]", "+...
https://github.com/cclib/cclib/blob/81cd4a81cc4a3bbed7016b3e417ca9bff8ad3a92/cclib/parser/qchemparser.py#L412-L423
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/lib-python/3/datetime.py
python
datetime.__repr__
(self)
return s
Convert to formal string, for repr().
Convert to formal string, for repr().
[ "Convert", "to", "formal", "string", "for", "repr", "()", "." ]
def __repr__(self): """Convert to formal string, for repr().""" L = [self._year, self._month, self._day, # These are never zero self._hour, self._minute, self._second, self._microsecond] if L[-1] == 0: del L[-1] if L[-1] == 0: del L[-1] s = ", ".join(map(str, L)) s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s) if self._tzinfo is not None: assert s[-1:] == ")" s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")" return s
[ "def", "__repr__", "(", "self", ")", ":", "L", "=", "[", "self", ".", "_year", ",", "self", ".", "_month", ",", "self", ".", "_day", ",", "# These are never zero", "self", ".", "_hour", ",", "self", ".", "_minute", ",", "self", ".", "_second", ",", ...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/lib-python/3/datetime.py#L1555-L1568
Azure/azure-devops-cli-extension
11334cd55806bef0b99c3bee5a438eed71e44037
azure-devops/azext_devops/devops_sdk/v6_0/feature_management/feature_management_client.py
python
FeatureManagementClient.get_features
(self, target_contribution_id=None)
return self._deserialize('[ContributedFeature]', self._unwrap_collection(response))
GetFeatures. [Preview API] Get a list of all defined features :param str target_contribution_id: Optional target contribution. If null/empty, return all features. If specified include the features that target the specified contribution. :rtype: [ContributedFeature]
GetFeatures. [Preview API] Get a list of all defined features :param str target_contribution_id: Optional target contribution. If null/empty, return all features. If specified include the features that target the specified contribution. :rtype: [ContributedFeature]
[ "GetFeatures", ".", "[", "Preview", "API", "]", "Get", "a", "list", "of", "all", "defined", "features", ":", "param", "str", "target_contribution_id", ":", "Optional", "target", "contribution", ".", "If", "null", "/", "empty", "return", "all", "features", "....
def get_features(self, target_contribution_id=None): """GetFeatures. [Preview API] Get a list of all defined features :param str target_contribution_id: Optional target contribution. If null/empty, return all features. If specified include the features that target the specified contribution. :rtype: [ContributedFeature] """ query_parameters = {} if target_contribution_id is not None: query_parameters['targetContributionId'] = self._serialize.query('target_contribution_id', target_contribution_id, 'str') response = self._send(http_method='GET', location_id='c4209f25-7a27-41dd-9f04-06080c7b6afd', version='6.0-preview.1', query_parameters=query_parameters) return self._deserialize('[ContributedFeature]', self._unwrap_collection(response))
[ "def", "get_features", "(", "self", ",", "target_contribution_id", "=", "None", ")", ":", "query_parameters", "=", "{", "}", "if", "target_contribution_id", "is", "not", "None", ":", "query_parameters", "[", "'targetContributionId'", "]", "=", "self", ".", "_ser...
https://github.com/Azure/azure-devops-cli-extension/blob/11334cd55806bef0b99c3bee5a438eed71e44037/azure-devops/azext_devops/devops_sdk/v6_0/feature_management/feature_management_client.py#L43-L56
KvasirSecurity/Kvasir
a5b3775184a8343240e1154a1f762f75df04dc0a
controllers/hosts.py
python
mass_vulndata
()
Add a vulndata to a lot of hosts TODO: This!
Add a vulndata to a lot of hosts TODO: This!
[ "Add", "a", "vulndata", "to", "a", "lot", "of", "hosts", "TODO", ":", "This!" ]
def mass_vulndata(): """ Add a vulndata to a lot of hosts TODO: This! """ host_ids = [] if request.vars.has_key('host_ids'): for z in request.vars.host_ids.split('|'): if z is not '': host_ids.append(z) form=SQLFORM.factory( Field('vulndata', 'reference t_vulndata', label=T('Vulnerability')), buttons=[], _id="mass_asset_form") if form.validate(): pass
[ "def", "mass_vulndata", "(", ")", ":", "host_ids", "=", "[", "]", "if", "request", ".", "vars", ".", "has_key", "(", "'host_ids'", ")", ":", "for", "z", "in", "request", ".", "vars", ".", "host_ids", ".", "split", "(", "'|'", ")", ":", "if", "z", ...
https://github.com/KvasirSecurity/Kvasir/blob/a5b3775184a8343240e1154a1f762f75df04dc0a/controllers/hosts.py#L746-L762
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/fixtures/models.py
python
FixtureDataItem.remove_group
(self, group)
return self.remove_owner(group, 'group')
[]
def remove_group(self, group): return self.remove_owner(group, 'group')
[ "def", "remove_group", "(", "self", ",", "group", ")", ":", "return", "self", ".", "remove_owner", "(", "group", ",", "'group'", ")" ]
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/fixtures/models.py#L283-L284
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/Python3/operator.py
python
ixor
(a, b)
return a
Same as a ^= b.
Same as a ^= b.
[ "Same", "as", "a", "^", "=", "b", "." ]
def ixor(a, b): "Same as a ^= b." a ^= b return a
[ "def", "ixor", "(", "a", ",", "b", ")", ":", "a", "^=", "b", "return", "a" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/Python3/operator.py#L405-L408
HymanLiuTS/flaskTs
286648286976e85d9b9a5873632331efcafe0b21
flasky/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py
python
ActionChains.context_click
(self, on_element=None)
return self
Performs a context-click (right click) on an element. :Args: - on_element: The element to context-click. If None, clicks on current mouse position.
Performs a context-click (right click) on an element.
[ "Performs", "a", "context", "-", "click", "(", "right", "click", ")", "on", "an", "element", "." ]
def context_click(self, on_element=None): """ Performs a context-click (right click) on an element. :Args: - on_element: The element to context-click. If None, clicks on current mouse position. """ if on_element: self.move_to_element(on_element) self._actions.append(lambda: self._driver.execute( Command.CLICK, {'button': 2})) return self
[ "def", "context_click", "(", "self", ",", "on_element", "=", "None", ")", ":", "if", "on_element", ":", "self", ".", "move_to_element", "(", "on_element", ")", "self", ".", "_actions", ".", "append", "(", "lambda", ":", "self", ".", "_driver", ".", "exec...
https://github.com/HymanLiuTS/flaskTs/blob/286648286976e85d9b9a5873632331efcafe0b21/flasky/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.py#L104-L116
realpython/book2-exercises
cde325eac8e6d8cff2316601c2e5b36bb46af7d0
web2py/venv/lib/python2.7/site-packages/pip/utils/__init__.py
python
ask
(message, options)
Ask the message interactively, with the given possible responses
Ask the message interactively, with the given possible responses
[ "Ask", "the", "message", "interactively", "with", "the", "given", "possible", "responses" ]
def ask(message, options): """Ask the message interactively, with the given possible responses""" while 1: if os.environ.get('PIP_NO_INPUT'): raise Exception( 'No input was expected ($PIP_NO_INPUT set); question: %s' % message ) response = input(message) response = response.strip().lower() if response not in options: print( 'Your response (%r) was not one of the expected responses: ' '%s' % (response, ', '.join(options)) ) else: return response
[ "def", "ask", "(", "message", ",", "options", ")", ":", "while", "1", ":", "if", "os", ".", "environ", ".", "get", "(", "'PIP_NO_INPUT'", ")", ":", "raise", "Exception", "(", "'No input was expected ($PIP_NO_INPUT set); question: %s'", "%", "message", ")", "re...
https://github.com/realpython/book2-exercises/blob/cde325eac8e6d8cff2316601c2e5b36bb46af7d0/web2py/venv/lib/python2.7/site-packages/pip/utils/__init__.py#L150-L166
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/pymongo/message.py
python
_batched_op_msg_impl
( operation, command, docs, check_keys, ack, opts, ctx, buf)
return to_send, length
Create a batched OP_MSG write.
Create a batched OP_MSG write.
[ "Create", "a", "batched", "OP_MSG", "write", "." ]
def _batched_op_msg_impl( operation, command, docs, check_keys, ack, opts, ctx, buf): """Create a batched OP_MSG write.""" max_bson_size = ctx.max_bson_size max_write_batch_size = ctx.max_write_batch_size max_message_size = ctx.max_message_size flags = b"\x00\x00\x00\x00" if ack else b"\x02\x00\x00\x00" # Flags buf.write(flags) # Type 0 Section buf.write(b"\x00") buf.write(_dict_to_bson(command, False, opts)) # Type 1 Section buf.write(b"\x01") size_location = buf.tell() # Save space for size buf.write(b"\x00\x00\x00\x00") try: buf.write(_OP_MSG_MAP[operation]) except KeyError: raise InvalidOperation('Unknown command') if operation in (_UPDATE, _DELETE): check_keys = False to_send = [] idx = 0 for doc in docs: # Encode the current operation value = _dict_to_bson(doc, check_keys, opts) doc_length = len(value) new_message_size = buf.tell() + doc_length # Does first document exceed max_message_size? doc_too_large = (idx == 0 and (new_message_size > max_message_size)) # When OP_MSG is used unacknowleged we have to check # document size client side or applications won't be notified. # Otherwise we let the server deal with documents that are too large # since ordered=False causes those documents to be skipped instead of # halting the bulk write operation. unacked_doc_too_large = (not ack and (doc_length > max_bson_size)) if doc_too_large or unacked_doc_too_large: write_op = list(_FIELD_MAP.keys())[operation] _raise_document_too_large( write_op, len(value), max_bson_size) # We have enough data, return this batch. if new_message_size > max_message_size: break buf.write(value) to_send.append(doc) idx += 1 # We have enough documents, return this batch. if idx == max_write_batch_size: break # Write type 1 section size length = buf.tell() buf.seek(size_location) buf.write(_pack_int(length - size_location)) return to_send, length
[ "def", "_batched_op_msg_impl", "(", "operation", ",", "command", ",", "docs", ",", "check_keys", ",", "ack", ",", "opts", ",", "ctx", ",", "buf", ")", ":", "max_bson_size", "=", "ctx", ".", "max_bson_size", "max_write_batch_size", "=", "ctx", ".", "max_write...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/pymongo/message.py#L1168-L1230
IJDykeman/wangTiles
7c1ee2095ebdf7f72bce07d94c6484915d5cae8b
experimental_code/tiles_3d/venv_mac/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py
python
WorkingSet.subscribe
(self, callback, existing=True)
Invoke `callback` for all distributions If `existing=True` (default), call on all existing ones, as well.
Invoke `callback` for all distributions
[ "Invoke", "callback", "for", "all", "distributions" ]
def subscribe(self, callback, existing=True): """Invoke `callback` for all distributions If `existing=True` (default), call on all existing ones, as well. """ if callback in self.callbacks: return self.callbacks.append(callback) if not existing: return for dist in self: callback(dist)
[ "def", "subscribe", "(", "self", ",", "callback", ",", "existing", "=", "True", ")", ":", "if", "callback", "in", "self", ".", "callbacks", ":", "return", "self", ".", "callbacks", ".", "append", "(", "callback", ")", "if", "not", "existing", ":", "ret...
https://github.com/IJDykeman/wangTiles/blob/7c1ee2095ebdf7f72bce07d94c6484915d5cae8b/experimental_code/tiles_3d/venv_mac/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L975-L987
GoogleCloudPlatform/PerfKitBenchmarker
6e3412d7d5e414b8ca30ed5eaf970cef1d919a67
perfkitbenchmarker/linux_benchmarks/unixbench_benchmark.py
python
Cleanup
(benchmark_spec)
Cleanup UnixBench on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark.
Cleanup UnixBench on the target vm.
[ "Cleanup", "UnixBench", "on", "the", "target", "vm", "." ]
def Cleanup(benchmark_spec): """Cleanup UnixBench on the target vm. Args: benchmark_spec: The benchmark specification. Contains all data that is required to run the benchmark. """ pass
[ "def", "Cleanup", "(", "benchmark_spec", ")", ":", "pass" ]
https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/6e3412d7d5e414b8ca30ed5eaf970cef1d919a67/perfkitbenchmarker/linux_benchmarks/unixbench_benchmark.py#L189-L196
pyansys/pymapdl
c07291fc062b359abf0e92b95a92d753a95ef3d7
ansys/mapdl/core/_commands/post1_/animation.py
python
Animation.andata
( self, delay="", ncycl="", rsltdat="", min_="", max_="", incr="", frclst="", autocont="", autocntr="", **kwargs, )
return self.run(command, **kwargs)
Displays animated graphics data for nonlinear problems. APDL Command: ANDATA Parameters ---------- delay Time delay during animation (defaults to 0.5 seconds). ncycl Number of animation cycles (defaults to 5). Available in non-UI mode only. rsltdat The type of results data to be used for the animation sequence. This can be: 0 - Current load step data (default). 1 - Range of load step data. 2 - Range of results data. min\_ The range minimum value. If left blank or 0, defaults to the first data point. max\_ The range maximum value. If left blank or 0, defaults to the last data point. incr The increment between result data (defaults to 1). frclst Key to force the last sub step in a selected load step to be included in the animation (defaults to 0). autocont A value of 1 enables automatic scaling of contour values based on the overall subset range of values. The default value is 0 (no automatic scaling). autocntr A value of 1 disables automatic centering of displaced plots. The default value is 0 (allow automatic centering). Notes ----- Use the ANDATA command to create animations for nonlinear problems. The command works by displaying an individual graphical image for each result data set from the results file. For information about creating animations for linear problems, see the ANIM command. The command operates only on graphic display platforms supporting the /SEG command. It uses a macro to produce an animation based on the last plot action command (for example, PLDISP). The results file must have more than one set of results. The command implicitly issues /DSCALE, 1 for default displacement scaling. Large displacements may not give good results. This command functions only in the postprocessor.
Displays animated graphics data for nonlinear problems.
[ "Displays", "animated", "graphics", "data", "for", "nonlinear", "problems", "." ]
def andata( self, delay="", ncycl="", rsltdat="", min_="", max_="", incr="", frclst="", autocont="", autocntr="", **kwargs, ): """Displays animated graphics data for nonlinear problems. APDL Command: ANDATA Parameters ---------- delay Time delay during animation (defaults to 0.5 seconds). ncycl Number of animation cycles (defaults to 5). Available in non-UI mode only. rsltdat The type of results data to be used for the animation sequence. This can be: 0 - Current load step data (default). 1 - Range of load step data. 2 - Range of results data. min\_ The range minimum value. If left blank or 0, defaults to the first data point. max\_ The range maximum value. If left blank or 0, defaults to the last data point. incr The increment between result data (defaults to 1). frclst Key to force the last sub step in a selected load step to be included in the animation (defaults to 0). autocont A value of 1 enables automatic scaling of contour values based on the overall subset range of values. The default value is 0 (no automatic scaling). autocntr A value of 1 disables automatic centering of displaced plots. The default value is 0 (allow automatic centering). Notes ----- Use the ANDATA command to create animations for nonlinear problems. The command works by displaying an individual graphical image for each result data set from the results file. For information about creating animations for linear problems, see the ANIM command. The command operates only on graphic display platforms supporting the /SEG command. It uses a macro to produce an animation based on the last plot action command (for example, PLDISP). The results file must have more than one set of results. The command implicitly issues /DSCALE, 1 for default displacement scaling. Large displacements may not give good results. This command functions only in the postprocessor. """ command = f"ANDATA,{delay},{ncycl},{rsltdat},{min_},{max_},{incr},{frclst},{autocont},,{autocntr}" return self.run(command, **kwargs)
[ "def", "andata", "(", "self", ",", "delay", "=", "\"\"", ",", "ncycl", "=", "\"\"", ",", "rsltdat", "=", "\"\"", ",", "min_", "=", "\"\"", ",", "max_", "=", "\"\"", ",", "incr", "=", "\"\"", ",", "frclst", "=", "\"\"", ",", "autocont", "=", "\"\"...
https://github.com/pyansys/pymapdl/blob/c07291fc062b359abf0e92b95a92d753a95ef3d7/ansys/mapdl/core/_commands/post1_/animation.py#L91-L170
rwightman/gen-efficientnet-pytorch
2d6623e956fbc9ac9c2f86ace2619e22ce7e2960
geffnet/gen_efficientnet.py
python
efficientnet_lite3
(pretrained=False, **kwargs)
return model
EfficientNet-Lite3
EfficientNet-Lite3
[ "EfficientNet", "-", "Lite3" ]
def efficientnet_lite3(pretrained=False, **kwargs): """ EfficientNet-Lite3 """ model = _gen_efficientnet_lite( 'efficientnet_lite3', channel_multiplier=1.2, depth_multiplier=1.4, pretrained=pretrained, **kwargs) return model
[ "def", "efficientnet_lite3", "(", "pretrained", "=", "False", ",", "*", "*", "kwargs", ")", ":", "model", "=", "_gen_efficientnet_lite", "(", "'efficientnet_lite3'", ",", "channel_multiplier", "=", "1.2", ",", "depth_multiplier", "=", "1.4", ",", "pretrained", "...
https://github.com/rwightman/gen-efficientnet-pytorch/blob/2d6623e956fbc9ac9c2f86ace2619e22ce7e2960/geffnet/gen_efficientnet.py#L964-L968
phonopy/phonopy
816586d0ba8177482ecf40e52f20cbdee2260d51
phonopy/harmonic/dynamical_matrix.py
python
DynamicalMatrixGL._get_c_recip_dipole_dipole
(self, q_cart, q_dir_cart)
return dd
Reciprocal part of Eq.(71) on the right hand side. This is subtracted from supercell force constants to create short-range force constants. Only once at commensurate points. This is added to interpolated short range force constants to create full force constants. Called many times.
Reciprocal part of Eq.(71) on the right hand side.
[ "Reciprocal", "part", "of", "Eq", ".", "(", "71", ")", "on", "the", "right", "hand", "side", "." ]
def _get_c_recip_dipole_dipole(self, q_cart, q_dir_cart): """Reciprocal part of Eq.(71) on the right hand side. This is subtracted from supercell force constants to create short-range force constants. Only once at commensurate points. This is added to interpolated short range force constants to create full force constants. Called many times. """ import phonopy._phonopy as phonoc pos = self._pcell.positions num_atom = len(pos) volume = self._pcell.volume dd = np.zeros((num_atom, 3, num_atom, 3), dtype=self._dtype_complex, order="C") phonoc.recip_dipole_dipole( dd.view(dtype="double"), self._dd_q0.view(dtype="double"), self._G_list, q_cart, q_dir_cart, self._born, self._dielectric, np.array(pos, dtype="double", order="C"), self._unit_conversion * 4.0 * np.pi / volume, self._Lambda, self._symprec, ) return dd
[ "def", "_get_c_recip_dipole_dipole", "(", "self", ",", "q_cart", ",", "q_dir_cart", ")", ":", "import", "phonopy", ".", "_phonopy", "as", "phonoc", "pos", "=", "self", ".", "_pcell", ".", "positions", "num_atom", "=", "len", "(", "pos", ")", "volume", "=",...
https://github.com/phonopy/phonopy/blob/816586d0ba8177482ecf40e52f20cbdee2260d51/phonopy/harmonic/dynamical_matrix.py#L739-L769
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/expressions/matpow.py
python
MatPow._entry
(self, i, j)
[]
def _entry(self, i, j): if self.exp.is_Integer: # Make an explicity MatMul out of the MatPow return MatMul(*[self.base for k in range(self.exp)])._entry(i, j)
[ "def", "_entry", "(", "self", ",", "i", ",", "j", ")", ":", "if", "self", ".", "exp", ".", "is_Integer", ":", "# Make an explicity MatMul out of the MatPow", "return", "MatMul", "(", "*", "[", "self", ".", "base", "for", "k", "in", "range", "(", "self", ...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/matrices/expressions/matpow.py#L29-L32
TencentCloud/tencentcloud-sdk-python
3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2
tencentcloud/vod/v20180717/vod_client.py
python
VodClient.ModifySubAppIdInfo
(self, request)
该接口用于修改子应用信息,但不允许修改主应用信息。 :param request: Request instance for ModifySubAppIdInfo. :type request: :class:`tencentcloud.vod.v20180717.models.ModifySubAppIdInfoRequest` :rtype: :class:`tencentcloud.vod.v20180717.models.ModifySubAppIdInfoResponse`
该接口用于修改子应用信息,但不允许修改主应用信息。
[ "该接口用于修改子应用信息,但不允许修改主应用信息。" ]
def ModifySubAppIdInfo(self, request): """该接口用于修改子应用信息,但不允许修改主应用信息。 :param request: Request instance for ModifySubAppIdInfo. :type request: :class:`tencentcloud.vod.v20180717.models.ModifySubAppIdInfoRequest` :rtype: :class:`tencentcloud.vod.v20180717.models.ModifySubAppIdInfoResponse` """ try: params = request._serialize() body = self.call("ModifySubAppIdInfo", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.ModifySubAppIdInfoResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "ModifySubAppIdInfo", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"ModifySubAppIdInfo\"", ",", "params", ")", "response", "=", "json", ".", "loa...
https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/vod/v20180717/vod_client.py#L2864-L2889
ni/nidaqmx-python
62fc6b48cbbb330fe1bcc9aedadc86610a1269b6
nidaqmx/_task_modules/timing.py
python
Timing.samp_clk_timebase_active_edge
(self)
return Edge(val.value)
:class:`nidaqmx.constants.Edge`: Specifies on which edge to recognize a Sample Clock Timebase pulse. This property is useful primarily when the signal you use as the Sample Clock Timebase is not a periodic clock.
:class:`nidaqmx.constants.Edge`: Specifies on which edge to recognize a Sample Clock Timebase pulse. This property is useful primarily when the signal you use as the Sample Clock Timebase is not a periodic clock.
[ ":", "class", ":", "nidaqmx", ".", "constants", ".", "Edge", ":", "Specifies", "on", "which", "edge", "to", "recognize", "a", "Sample", "Clock", "Timebase", "pulse", ".", "This", "property", "is", "useful", "primarily", "when", "the", "signal", "you", "use...
def samp_clk_timebase_active_edge(self): """ :class:`nidaqmx.constants.Edge`: Specifies on which edge to recognize a Sample Clock Timebase pulse. This property is useful primarily when the signal you use as the Sample Clock Timebase is not a periodic clock. """ val = ctypes.c_int() cfunc = lib_importer.windll.DAQmxGetSampClkTimebaseActiveEdge if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return Edge(val.value)
[ "def", "samp_clk_timebase_active_edge", "(", "self", ")", ":", "val", "=", "ctypes", ".", "c_int", "(", ")", "cfunc", "=", "lib_importer", ".", "windll", ".", "DAQmxGetSampClkTimebaseActiveEdge", "if", "cfunc", ".", "argtypes", "is", "None", ":", "with", "cfun...
https://github.com/ni/nidaqmx-python/blob/62fc6b48cbbb330fe1bcc9aedadc86610a1269b6/nidaqmx/_task_modules/timing.py#L1776-L1796
n0fate/chainbreaker
6f5a2c74bb922769e2f3d05f7ead6f36d2750277
pyDes.py
python
DES.__des_crypt
(self, block, crypt_type)
return self.final
Crypt the block of data through DES bit-manipulation
Crypt the block of data through DES bit-manipulation
[ "Crypt", "the", "block", "of", "data", "through", "DES", "bit", "-", "manipulation" ]
def __des_crypt(self, block, crypt_type): """Crypt the block of data through DES bit-manipulation""" block = self.__permutate(DES.__ip, block) self.L = block[:32] self.R = block[32:] # Encryption starts from Kn[1] through to Kn[16] if crypt_type == DES.ENCRYPT: iteration = 0 iteration_adjustment = 1 # Decryption starts from Kn[16] down to Kn[1] else: iteration = 15 iteration_adjustment = -1 i = 0 while i < 16: # Make a copy of R[i-1], this will later become L[i] tempR = self.R[:] # Permutate R[i - 1] to start creating R[i] self.R = self.__permutate(DES.__expansion_table, self.R) # Exclusive or R[i - 1] with K[i], create B[1] to B[8] whilst here self.R = map(lambda x, y: x ^ y, self.R, self.Kn[iteration]) B = [self.R[:6], self.R[6:12], self.R[12:18], self.R[18:24], self.R[24:30], self.R[30:36], self.R[36:42], self.R[42:]] # Optimization: Replaced below commented code with above # j = 0 # B = [] # while j < len(self.R): # self.R[j] = self.R[j] ^ self.Kn[iteration][j] # j += 1 # if j % 6 == 0: # B.append(self.R[j-6:j]) # Permutate B[1] to B[8] using the S-Boxes j = 0 Bn = [0] * 32 pos = 0 while j < 8: # Work out the offsets m = (B[j][0] << 1) + B[j][5] n = (B[j][1] << 3) + (B[j][2] << 2) + (B[j][3] << 1) + B[j][4] # Find the permutation value v = DES.__sbox[j][(m << 4) + n] # Turn value into bits, add it to result: Bn Bn[pos] = (v & 8) >> 3 Bn[pos + 1] = (v & 4) >> 2 Bn[pos + 2] = (v & 2) >> 1 Bn[pos + 3] = v & 1 pos += 4 j += 1 # Permutate the concatination of B[1] to B[8] (Bn) self.R = self.__permutate(DES.__p, Bn) # Xor with L[i - 1] self.R = map(lambda x, y: x ^ y, self.R, self.L) # Optimization: This now replaces the below commented code # j = 0 # while j < len(self.R): # self.R[j] = self.R[j] ^ self.L[j] # j += 1 # L[i] becomes R[i - 1] self.L = tempR i += 1 iteration += iteration_adjustment # Final permutation of R[16]L[16] self.final = self.__permutate(DES.__fp, self.R + self.L) return self.final
[ "def", "__des_crypt", "(", "self", ",", "block", ",", "crypt_type", ")", ":", "block", "=", "self", ".", "__permutate", "(", "DES", ".", "__ip", ",", "block", ")", "self", ".", "L", "=", "block", "[", ":", "32", "]", "self", ".", "R", "=", "block...
https://github.com/n0fate/chainbreaker/blob/6f5a2c74bb922769e2f3d05f7ead6f36d2750277/pyDes.py#L304-L380
khast3x/h8mail
0a371eb2e6ff786865e6608e46ee3ac5103a4dbc
h8mail/utils/run.py
python
parse_args
(args)
return parser.parse_args(args)
Seperate functions to make it easier to run tests Pass args as an array
Seperate functions to make it easier to run tests Pass args as an array
[ "Seperate", "functions", "to", "make", "it", "easier", "to", "run", "tests", "Pass", "args", "as", "an", "array" ]
def parse_args(args): """ Seperate functions to make it easier to run tests Pass args as an array """ parser = argparse.ArgumentParser( description="Email information and password lookup tool", prog="h8mail" ) parser.add_argument( "-t", "--targets", dest="user_targets", help="Either string inputs or files. Supports email pattern matching from input or file, filepath globing and multiple arguments", nargs="+", ) parser.add_argument( "-u", "--url", dest="user_urls", help="Either string inputs or files. Supports URL pattern matching from input or file, filepath globing and multiple arguments. Parse URLs page for emails. Requires http:// or https:// in URL.", nargs="+", ) parser.add_argument( "-q", "--custom-query", dest="user_query", help='Perform a custom query. Supports username, password, ip, hash, domain. Performs an implicit "loose" search when searching locally', ) parser.add_argument( "--loose", dest="loose", help="Allow loose search by disabling email pattern recognition. Use spaces as pattern seperators", action="store_true", default=False, ) parser.add_argument( "-c", "--config", dest="config_file", help="Configuration file for API keys. Accepts keys from Snusbase, WeLeakInfo, Leak-Lookup, HaveIBeenPwned, Emailrep, Dehashed and hunterio", nargs="+", ) parser.add_argument( "-o", "--output", dest="output_file", help="File to write CSV output" ) parser.add_argument( "-j", "--json", dest="output_json", help="File to write JSON output" ) parser.add_argument( "-bc", "--breachcomp", dest="bc_path", help="Path to the breachcompilation torrent folder. Uses the query.sh script included in the torrent", ) parser.add_argument( "-sk", "--skip-defaults", dest="skip_defaults", help="Skips Scylla and HunterIO check. Ideal for local scans", action="store_true", default=False, ) parser.add_argument( "-k", "--apikey", dest="cli_apikeys", help='Pass config options. Supported format: "K=V,K=V"', nargs="+", ) parser.add_argument( "-lb", "--local-breach", dest="local_breach_src", help="Local cleartext breaches to scan for targets. Uses multiprocesses, one separate process per file, on separate worker pool by arguments. Supports file or folder as input, and filepath globing", nargs="+", ) parser.add_argument( "-gz", "--gzip", dest="local_gzip_src", help="Local tar.gz (gzip) compressed breaches to scans for targets. Uses multiprocesses, one separate process per file. Supports file or folder as input, and filepath globing. Looks for 'gz' in filename", nargs="+", ) parser.add_argument( "-sf", "--single-file", dest="single_file", help="If breach contains big cleartext or tar.gz files, set this flag to view the progress bar. Disables concurrent file searching for stability", action="store_true", default=False, ), parser.add_argument( "-ch", "--chase", dest="chase_limit", help="Add related emails from hunter.io to ongoing target list. Define number of emails per target to chase. Requires hunter.io private API key if used without power-chase", type=int, nargs="?", ), parser.add_argument( "--power-chase", dest="power_chase", help="Add related emails from ALL API services to ongoing target list. Use with --chase", action="store_true", default=False, ), parser.add_argument( "--hide", dest="hide", help="Only shows the first 4 characters of found passwords to output. Ideal for demonstrations", action="store_true", default=False, ), parser.add_argument( "--debug", dest="debug", help="Print request debug information", action="store_true", default=False, ), parser.add_argument( "--gen-config", "-g", dest="gen_config", help="Generates a configuration file template in the current working directory & exits. Will overwrite existing h8mail_config.ini file", action="store_true", default=False, ), return parser.parse_args(args)
[ "def", "parse_args", "(", "args", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Email information and password lookup tool\"", ",", "prog", "=", "\"h8mail\"", ")", "parser", ".", "add_argument", "(", "\"-t\"", ",", "\"--ta...
https://github.com/khast3x/h8mail/blob/0a371eb2e6ff786865e6608e46ee3ac5103a4dbc/h8mail/utils/run.py#L228-L358
CedricGuillemet/Imogen
ee417b42747ed5b46cb11b02ef0c3630000085b3
bin/Lib/platform.py
python
mac_ver
(release='', versioninfo=('', '', ''), machine='')
return release, versioninfo, machine
Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the parameter values which default to ''. All tuple entries are strings.
Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version).
[ "Get", "MacOS", "version", "information", "and", "return", "it", "as", "tuple", "(", "release", "versioninfo", "machine", ")", "with", "versioninfo", "being", "a", "tuple", "(", "version", "dev_stage", "non_release_version", ")", "." ]
def mac_ver(release='', versioninfo=('', '', ''), machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the parameter values which default to ''. All tuple entries are strings. """ # First try reading the information from an XML file which should # always be present info = _mac_ver_xml() if info is not None: return info # If that also doesn't work return the default values return release, versioninfo, machine
[ "def", "mac_ver", "(", "release", "=", "''", ",", "versioninfo", "=", "(", "''", ",", "''", ",", "''", ")", ",", "machine", "=", "''", ")", ":", "# First try reading the information from an XML file which should", "# always be present", "info", "=", "_mac_ver_xml"...
https://github.com/CedricGuillemet/Imogen/blob/ee417b42747ed5b46cb11b02ef0c3630000085b3/bin/Lib/platform.py#L601-L618
openstack/cinder
23494a6d6c51451688191e1847a458f1d3cdcaa5
cinder/api/contrib/volume_actions.py
python
VolumeActionsController._begin_detaching
(self, req, id, body)
Update volume status to 'detaching'.
Update volume status to 'detaching'.
[ "Update", "volume", "status", "to", "detaching", "." ]
def _begin_detaching(self, req, id, body): """Update volume status to 'detaching'.""" context = req.environ['cinder.context'] # Not found exception will be handled at the wsgi level volume = self.volume_api.get(context, id) self.volume_api.begin_detaching(context, volume)
[ "def", "_begin_detaching", "(", "self", ",", "req", ",", "id", ",", "body", ")", ":", "context", "=", "req", ".", "environ", "[", "'cinder.context'", "]", "# Not found exception will be handled at the wsgi level", "volume", "=", "self", ".", "volume_api", ".", "...
https://github.com/openstack/cinder/blob/23494a6d6c51451688191e1847a458f1d3cdcaa5/cinder/api/contrib/volume_actions.py#L135-L141
tensorflow/ranking
94cccec8b4e71d2cc4489c61e2623522738c2924
tensorflow_ranking/python/losses_impl.py
python
SoftmaxLoss.compute
(self, labels, logits, weights, reduction, mask=None)
return tf.compat.v1.losses.compute_weighted_loss( losses, weights, reduction=reduction)
See `_RankingLoss`.
See `_RankingLoss`.
[ "See", "_RankingLoss", "." ]
def compute(self, labels, logits, weights, reduction, mask=None): """See `_RankingLoss`.""" logits = self.get_logits(logits) labels, logits = self.precompute(labels, logits, weights, mask) losses, weights = self._compute_unreduced_loss_impl(labels, logits, mask) return tf.compat.v1.losses.compute_weighted_loss( losses, weights, reduction=reduction)
[ "def", "compute", "(", "self", ",", "labels", ",", "logits", ",", "weights", ",", "reduction", ",", "mask", "=", "None", ")", ":", "logits", "=", "self", ".", "get_logits", "(", "logits", ")", "labels", ",", "logits", "=", "self", ".", "precompute", ...
https://github.com/tensorflow/ranking/blob/94cccec8b4e71d2cc4489c61e2623522738c2924/tensorflow_ranking/python/losses_impl.py#L1021-L1027
python-provy/provy
ca3d5e96a2210daf3c1fd4b96e047efff152db14
provy/more/centos/database/mysql.py
python
MySQLRole.has_grant
(self, privileges, on, username, login_from, with_grant_option)
return False
Returns :data:`True` if the user has the specified privileges on the specified object in the given location. :param privileges: Privileges that are being verified. :type privileges: :class:`str` :param on: Database object that the user holds privileges on. :type on: :class:`str` :param username: Name of the user to be verify. :type username: :class:`str` :param login_from: Locations that this user can login from. Defaults to '%' (anywhere). :type login_from: :class:`str` :param with_grant_option: Indicates if we are verifying against grant option. :type with_grant_option: :class:`bool` :return: Whether the user has the privileges or not. :rtype: :class:`bool` Example: :: class MySampleRole(Role): def provision(self): with self.using(MySQLRole) as role: if role.has_grant('ALL PRIVILEGES', 'database', 'user', login_from='%', with_grant_option=True): pass
Returns :data:`True` if the user has the specified privileges on the specified object in the given location.
[ "Returns", ":", "data", ":", "True", "if", "the", "user", "has", "the", "specified", "privileges", "on", "the", "specified", "object", "in", "the", "given", "location", "." ]
def has_grant(self, privileges, on, username, login_from, with_grant_option): ''' Returns :data:`True` if the user has the specified privileges on the specified object in the given location. :param privileges: Privileges that are being verified. :type privileges: :class:`str` :param on: Database object that the user holds privileges on. :type on: :class:`str` :param username: Name of the user to be verify. :type username: :class:`str` :param login_from: Locations that this user can login from. Defaults to '%' (anywhere). :type login_from: :class:`str` :param with_grant_option: Indicates if we are verifying against grant option. :type with_grant_option: :class:`bool` :return: Whether the user has the privileges or not. :rtype: :class:`bool` Example: :: class MySampleRole(Role): def provision(self): with self.using(MySQLRole) as role: if role.has_grant('ALL PRIVILEGES', 'database', 'user', login_from='%', with_grant_option=True): pass ''' grants = self.get_user_grants(username, login_from) grant_option_string = self._get_grant_option_string(with_grant_option) privileges = self._get_privileges(privileges) grant_strings = self._get_possible_grant_strings(on, username, privileges, login_from, grant_option_string) for grant_string in grant_strings: if grant_string in grants: return True return False
[ "def", "has_grant", "(", "self", ",", "privileges", ",", "on", ",", "username", ",", "login_from", ",", "with_grant_option", ")", ":", "grants", "=", "self", ".", "get_user_grants", "(", "username", ",", "login_from", ")", "grant_option_string", "=", "self", ...
https://github.com/python-provy/provy/blob/ca3d5e96a2210daf3c1fd4b96e047efff152db14/provy/more/centos/database/mysql.py#L253-L293
tomplus/kubernetes_asyncio
f028cc793e3a2c519be6a52a49fb77ff0b014c9b
kubernetes_asyncio/client/models/v1_attached_volume.py
python
V1AttachedVolume.__eq__
(self, other)
return self.to_dict() == other.to_dict()
Returns true if both objects are equal
Returns true if both objects are equal
[ "Returns", "true", "if", "both", "objects", "are", "equal" ]
def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, V1AttachedVolume): return False return self.to_dict() == other.to_dict()
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "V1AttachedVolume", ")", ":", "return", "False", "return", "self", ".", "to_dict", "(", ")", "==", "other", ".", "to_dict", "(", ")" ]
https://github.com/tomplus/kubernetes_asyncio/blob/f028cc793e3a2c519be6a52a49fb77ff0b014c9b/kubernetes_asyncio/client/models/v1_attached_volume.py#L140-L145
privacyidea/privacyidea
9490c12ddbf77a34ac935b082d09eb583dfafa2c
privacyidea/lib/policy.py
python
Match.user
(cls, g, scope, action, user_object)
return cls(g, name=None, scope=scope, realm=None, active=True, resolver=None, user=None, user_object=user_object, client=g.client_ip, action=action, adminrealm=None, time=None, sort_by_priority=True, serial=g.serial)
Match active policies with a scope, an action and a user object (which may be None). The client IP is matched implicitly. :param g: context object :param scope: the policy scope. SCOPE.ADMIN cannot be passed, ``admin`` must be used instead. :param action: the policy action :param user_object: the user object to match. Might also be None, which means that the policy attributes ``user``, ``realm`` and ``resolver`` are ignored. :type user_object: User or None :rtype: ``Match``
Match active policies with a scope, an action and a user object (which may be None). The client IP is matched implicitly.
[ "Match", "active", "policies", "with", "a", "scope", "an", "action", "and", "a", "user", "object", "(", "which", "may", "be", "None", ")", ".", "The", "client", "IP", "is", "matched", "implicitly", "." ]
def user(cls, g, scope, action, user_object): """ Match active policies with a scope, an action and a user object (which may be None). The client IP is matched implicitly. :param g: context object :param scope: the policy scope. SCOPE.ADMIN cannot be passed, ``admin`` must be used instead. :param action: the policy action :param user_object: the user object to match. Might also be None, which means that the policy attributes ``user``, ``realm`` and ``resolver`` are ignored. :type user_object: User or None :rtype: ``Match`` """ if scope == SCOPE.ADMIN: raise MatchingError("Match.user cannot be used for policies with scope ADMIN") if not (user_object is None or isinstance(user_object, User)): raise MatchingError("Invalid user") # Username, realm and resolver will be extracted from the user_object parameter return cls(g, name=None, scope=scope, realm=None, active=True, resolver=None, user=None, user_object=user_object, client=g.client_ip, action=action, adminrealm=None, time=None, sort_by_priority=True, serial=g.serial)
[ "def", "user", "(", "cls", ",", "g", ",", "scope", ",", "action", ",", "user_object", ")", ":", "if", "scope", "==", "SCOPE", ".", "ADMIN", ":", "raise", "MatchingError", "(", "\"Match.user cannot be used for policies with scope ADMIN\"", ")", "if", "not", "("...
https://github.com/privacyidea/privacyidea/blob/9490c12ddbf77a34ac935b082d09eb583dfafa2c/privacyidea/lib/policy.py#L2727-L2750
filerock/FileRock-Client
37214f701666e76e723595f8f9ed238a42f6eb06
filerockclient/serversession/server_session.py
python
ServerSession.connect
(self)
Make the client connect to the server.
Make the client connect to the server.
[ "Make", "the", "client", "connect", "to", "the", "server", "." ]
def connect(self): """Make the client connect to the server.""" self._input_queue.put(Command('CONNECT'), 'usercommand')
[ "def", "connect", "(", "self", ")", ":", "self", ".", "_input_queue", ".", "put", "(", "Command", "(", "'CONNECT'", ")", ",", "'usercommand'", ")" ]
https://github.com/filerock/FileRock-Client/blob/37214f701666e76e723595f8f9ed238a42f6eb06/filerockclient/serversession/server_session.py#L432-L434
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-build/python-libs/gdata/samples/authsub/secure_authsub.py
python
HealthAuthSubHelper.GetNextUrl
(self, req)
return next_url
Computes the current URL the web app is running from. Args: req: mod_python mp_request instance to build the URL from. Returns: A string representing the web app's URL.
Computes the current URL the web app is running from.
[ "Computes", "the", "current", "URL", "the", "web", "app", "is", "running", "from", "." ]
def GetNextUrl(self, req): """Computes the current URL the web app is running from. Args: req: mod_python mp_request instance to build the URL from. Returns: A string representing the web app's URL. """ if req.is_https(): next_url = 'https://' else: next_url = 'http://' next_url += req.hostname + req.unparsed_uri return next_url
[ "def", "GetNextUrl", "(", "self", ",", "req", ")", ":", "if", "req", ".", "is_https", "(", ")", ":", "next_url", "=", "'https://'", "else", ":", "next_url", "=", "'http://'", "next_url", "+=", "req", ".", "hostname", "+", "req", ".", "unparsed_uri", "r...
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-build/python-libs/gdata/samples/authsub/secure_authsub.py#L48-L62
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_hxb2/lib/python3.5/site-packages/redis/client.py
python
StrictRedis.pipeline
(self, transaction=True, shard_hint=None)
return StrictPipeline( self.connection_pool, self.response_callbacks, transaction, shard_hint)
Return a new pipeline object that can queue multiple commands for later execution. ``transaction`` indicates whether all commands should be executed atomically. Apart from making a group of operations atomic, pipelines are useful for reducing the back-and-forth overhead between the client and server.
Return a new pipeline object that can queue multiple commands for later execution. ``transaction`` indicates whether all commands should be executed atomically. Apart from making a group of operations atomic, pipelines are useful for reducing the back-and-forth overhead between the client and server.
[ "Return", "a", "new", "pipeline", "object", "that", "can", "queue", "multiple", "commands", "for", "later", "execution", ".", "transaction", "indicates", "whether", "all", "commands", "should", "be", "executed", "atomically", ".", "Apart", "from", "making", "a",...
def pipeline(self, transaction=True, shard_hint=None): """ Return a new pipeline object that can queue multiple commands for later execution. ``transaction`` indicates whether all commands should be executed atomically. Apart from making a group of operations atomic, pipelines are useful for reducing the back-and-forth overhead between the client and server. """ return StrictPipeline( self.connection_pool, self.response_callbacks, transaction, shard_hint)
[ "def", "pipeline", "(", "self", ",", "transaction", "=", "True", ",", "shard_hint", "=", "None", ")", ":", "return", "StrictPipeline", "(", "self", ".", "connection_pool", ",", "self", ".", "response_callbacks", ",", "transaction", ",", "shard_hint", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/redis/client.py#L557-L569
InQuest/omnibus
88dbf5d02f87eaa79a1cfc13d403cf854ee44c40
omnibus-cli.py
python
Console.do_quit
(self, _)
return self._STOP_AND_EXIT
Exit Omnibus shell.
Exit Omnibus shell.
[ "Exit", "Omnibus", "shell", "." ]
def do_quit(self, _): """Exit Omnibus shell.""" self._should_quit = True if self.session is not None: running('Clearing artifact cache ...') self.session.flush() warning('Closing Omnibus shell ...') return self._STOP_AND_EXIT
[ "def", "do_quit", "(", "self", ",", "_", ")", ":", "self", ".", "_should_quit", "=", "True", "if", "self", ".", "session", "is", "not", "None", ":", "running", "(", "'Clearing artifact cache ...'", ")", "self", ".", "session", ".", "flush", "(", ")", "...
https://github.com/InQuest/omnibus/blob/88dbf5d02f87eaa79a1cfc13d403cf854ee44c40/omnibus-cli.py#L119-L128
cackharot/suds-py3
1d92cc6297efee31bfd94b50b99c431505d7de21
suds/mx/typer.py
python
Typer.genprefix
(cls, node, ns)
Generate a prefix. @param node: An XML node on which the prefix will be used. @type node: L{sax.element.Element} @param ns: A namespace needing an unique prefix. @type ns: (prefix, uri) @return: The I{ns} with a new prefix.
Generate a prefix.
[ "Generate", "a", "prefix", "." ]
def genprefix(cls, node, ns): """ Generate a prefix. @param node: An XML node on which the prefix will be used. @type node: L{sax.element.Element} @param ns: A namespace needing an unique prefix. @type ns: (prefix, uri) @return: The I{ns} with a new prefix. """ for n in range(1, 1024): p = 'ns%d' % n u = node.resolvePrefix(p, default=None) if u is None or u == ns[1]: return (p, ns[1]) raise Exception('auto prefix, exhausted')
[ "def", "genprefix", "(", "cls", ",", "node", ",", "ns", ")", ":", "for", "n", "in", "range", "(", "1", ",", "1024", ")", ":", "p", "=", "'ns%d'", "%", "n", "u", "=", "node", ".", "resolvePrefix", "(", "p", ",", "default", "=", "None", ")", "i...
https://github.com/cackharot/suds-py3/blob/1d92cc6297efee31bfd94b50b99c431505d7de21/suds/mx/typer.py#L98-L112
OpenCobolIDE/OpenCobolIDE
c78d0d335378e5fe0a5e74f53c19b68b55e85388
open_cobol_ide/extlibs/pyqode/core/panels/search_and_replace.py
python
SearchAndReplacePanel._set_widget_background_color
(widget, color)
Changes the base color of a widget (background). :param widget: widget to modify :param color: the color to apply
Changes the base color of a widget (background). :param widget: widget to modify :param color: the color to apply
[ "Changes", "the", "base", "color", "of", "a", "widget", "(", "background", ")", ".", ":", "param", "widget", ":", "widget", "to", "modify", ":", "param", "color", ":", "the", "color", "to", "apply" ]
def _set_widget_background_color(widget, color): """ Changes the base color of a widget (background). :param widget: widget to modify :param color: the color to apply """ pal = widget.palette() pal.setColor(pal.Base, color) widget.setPalette(pal)
[ "def", "_set_widget_background_color", "(", "widget", ",", "color", ")", ":", "pal", "=", "widget", ".", "palette", "(", ")", "pal", ".", "setColor", "(", "pal", ".", "Base", ",", "color", ")", "widget", ".", "setPalette", "(", "pal", ")" ]
https://github.com/OpenCobolIDE/OpenCobolIDE/blob/c78d0d335378e5fe0a5e74f53c19b68b55e85388/open_cobol_ide/extlibs/pyqode/core/panels/search_and_replace.py#L336-L344
buntine/SwervinMervin
e5ae51a0e4ed62783024b7e7b096398e21b6d54a
swervin_mervin/segment.py
python
Segment.should_ignore
(self, segment)
return self.top["camera"]["z"] <= s.CAMERA_DEPTH or\ self.top["screen"]["y"] <= segment.top["screen"]["y"] or\ self.bottom["screen"]["y"] >= self.top["screen"]["y"]
Returns true if this segment will be projected behind a hill, or behind us, etc.
Returns true if this segment will be projected behind a hill, or behind us, etc.
[ "Returns", "true", "if", "this", "segment", "will", "be", "projected", "behind", "a", "hill", "or", "behind", "us", "etc", "." ]
def should_ignore(self, segment): """Returns true if this segment will be projected behind a hill, or behind us, etc.""" return self.top["camera"]["z"] <= s.CAMERA_DEPTH or\ self.top["screen"]["y"] <= segment.top["screen"]["y"] or\ self.bottom["screen"]["y"] >= self.top["screen"]["y"]
[ "def", "should_ignore", "(", "self", ",", "segment", ")", ":", "return", "self", ".", "top", "[", "\"camera\"", "]", "[", "\"z\"", "]", "<=", "s", ".", "CAMERA_DEPTH", "or", "self", ".", "top", "[", "\"screen\"", "]", "[", "\"y\"", "]", "<=", "segmen...
https://github.com/buntine/SwervinMervin/blob/e5ae51a0e4ed62783024b7e7b096398e21b6d54a/swervin_mervin/segment.py#L27-L31
nschaetti/EchoTorch
cba209c49e0fda73172d2e853b85c747f9f5117e
echotorch/data/datasets/MarkovChainDataset.py
python
MarkovChainDataset.__getitem__
(self, idx)
return inputs, outputs, markov_chain
Get item :param idx: :return:
Get item :param idx: :return:
[ "Get", "item", ":", "param", "idx", ":", ":", "return", ":" ]
def __getitem__(self, idx): """ Get item :param idx: :return: """ # Generate a Markov chain with # specified length markov_chain = self._generate_markov_chain( length=self._sample_length, start_state=np.random.randint(low=0, high=self.n_states-1) ) # Length of each state with morphing state_lenght_and_morph = self._states_length + 2 * self._morphing_length # Length of sample to get for each state state_sample_length = self._states_length + 4 * self._morphing_length # Empty tensor for the result inputs = torch.zeros(self._total_length, 1) # Outputs with each state at time t outputs = torch.zeros(self._total_length, self.n_states) # Save the list of samples list_of_state_samples = list() # For each state in the Markov chain for state_i in range(self._sample_length): # State current_state = int(markov_chain[state_i].item()) # Get state dataset state_dataset = self.states[current_state] # Get a random sample state_sample = state_dataset[np.random.randint(len(state_dataset))] # State sample's length and minimum length minimum_length = (state_sample_length + self._random_start) # Check that the sample has # the minimum size if state_sample.size(0) >= minimum_length: # Random start if self._random_start > 0: random_start = np.random.randint(0, self._random_start) else: random_start = 0 # end if # Get a random part state_part = state_sample[random_start:random_start+state_sample_length] # Add to the list list_of_state_samples.append(state_part) else: raise Exception("State sample length is not enough ({} vs {})!".format(state_sample_length, minimum_length)) # end if # end for # Go through time to compose the sample for t in range(self._total_length): # In which state we are state_step = math.floor(t / state_lenght_and_morph) last_step = state_step - 1 next_step = state_step + 1 # Bounds state_start_time = state_step * state_lenght_and_morph state_end_time = (state_step + 1) * state_lenght_and_morph # Position in the state state_position = t - state_start_time # Are we in the morphing period if self._morphing_length > 0: if t - state_start_time < self._morphing_length and state_step > 0: m = -(1.0 / (2.0 * self._morphing_length)) * state_position + 0.5 last_state_position = state_sample_length - self._morphing_length + state_position inputs[t] = m * list_of_state_samples[last_step][last_state_position] inputs[t] += (1.0 - m) * list_of_state_samples[state_step][state_position] elif state_end_time - t < self._morphing_length and state_step != self._sample_length - 1: m = (1.0 / (2.0 * self._morphing_length)) * (state_end_time - t) next_state_position = state_sample_length - (self._morphing_length + self._states_length) inputs[t] = m * list_of_state_samples[next_step][next_state_position] inputs[t] += (1.0 - m) * list_of_state_samples[state_step][state_position] else: inputs[t] = list_of_state_samples[state_step][state_position] # end if else: inputs[t] = list_of_state_samples[state_step][state_position] # end if # Outputs outputs[t, int(markov_chain[state_step].item())] = 1.0 # end for return inputs, outputs, markov_chain
[ "def", "__getitem__", "(", "self", ",", "idx", ")", ":", "# Generate a Markov chain with", "# specified length", "markov_chain", "=", "self", ".", "_generate_markov_chain", "(", "length", "=", "self", ".", "_sample_length", ",", "start_state", "=", "np", ".", "ran...
https://github.com/nschaetti/EchoTorch/blob/cba209c49e0fda73172d2e853b85c747f9f5117e/echotorch/data/datasets/MarkovChainDataset.py#L117-L216
pyqt/examples
843bb982917cecb2350b5f6d7f42c9b7fb142ec1
src/pyqt-official/mainwindows/application/application.py
python
MainWindow.saveAs
(self)
return False
[]
def saveAs(self): fileName, _ = QFileDialog.getSaveFileName(self) if fileName: return self.saveFile(fileName) return False
[ "def", "saveAs", "(", "self", ")", ":", "fileName", ",", "_", "=", "QFileDialog", ".", "getSaveFileName", "(", "self", ")", "if", "fileName", ":", "return", "self", ".", "saveFile", "(", "fileName", ")", "return", "False" ]
https://github.com/pyqt/examples/blob/843bb982917cecb2350b5f6d7f42c9b7fb142ec1/src/pyqt-official/mainwindows/application/application.py#L96-L101
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/ext/tornado/escape.py
python
linkify
(text, shorten=False, extra_params="", require_protocol=False, permitted_protocols=["http", "https"])
return _URL_RE.sub(make_link, text)
Converts plain text into HTML with links. For example: ``linkify("Hello http://tornadoweb.org!")`` would return ``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!`` Parameters: * ``shorten``: Long urls will be shortened for display. * ``extra_params``: Extra text to include in the link tag, or a callable taking the link as an argument and returning the extra text e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``, or:: def extra_params_cb(url): if url.startswith("http://example.com"): return 'class="internal"' else: return 'class="external" rel="nofollow"' linkify(text, extra_params=extra_params_cb) * ``require_protocol``: Only linkify urls which include a protocol. If this is False, urls such as www.facebook.com will also be linkified. * ``permitted_protocols``: List (or set) of protocols which should be linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp", "mailto"])``. It is very unsafe to include protocols such as ``javascript``.
Converts plain text into HTML with links.
[ "Converts", "plain", "text", "into", "HTML", "with", "links", "." ]
def linkify(text, shorten=False, extra_params="", require_protocol=False, permitted_protocols=["http", "https"]): """Converts plain text into HTML with links. For example: ``linkify("Hello http://tornadoweb.org!")`` would return ``Hello <a href="http://tornadoweb.org">http://tornadoweb.org</a>!`` Parameters: * ``shorten``: Long urls will be shortened for display. * ``extra_params``: Extra text to include in the link tag, or a callable taking the link as an argument and returning the extra text e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``, or:: def extra_params_cb(url): if url.startswith("http://example.com"): return 'class="internal"' else: return 'class="external" rel="nofollow"' linkify(text, extra_params=extra_params_cb) * ``require_protocol``: Only linkify urls which include a protocol. If this is False, urls such as www.facebook.com will also be linkified. * ``permitted_protocols``: List (or set) of protocols which should be linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp", "mailto"])``. It is very unsafe to include protocols such as ``javascript``. """ if extra_params and not callable(extra_params): extra_params = " " + extra_params.strip() def make_link(m): url = m.group(1) proto = m.group(2) if require_protocol and not proto: return url # not protocol, no linkify if proto and proto not in permitted_protocols: return url # bad protocol, no linkify href = m.group(1) if not proto: href = "http://" + href # no proto specified, use http if callable(extra_params): params = " " + extra_params(href).strip() else: params = extra_params # clip long urls. max_len is just an approximation max_len = 30 if shorten and len(url) > max_len: before_clip = url if proto: proto_len = len(proto) + 1 + len(m.group(3) or "") # +1 for : else: proto_len = 0 parts = url[proto_len:].split("/") if len(parts) > 1: # Grab the whole host part plus the first bit of the path # The path is usually not that interesting once shortened # (no more slug, etc), so it really just provides a little # extra indication of shortening. url = url[:proto_len] + parts[0] + "/" + \ parts[1][:8].split('?')[0].split('.')[0] if len(url) > max_len * 1.5: # still too long url = url[:max_len] if url != before_clip: amp = url.rfind('&') # avoid splitting html char entities if amp > max_len - 5: url = url[:amp] url += "..." if len(url) >= len(before_clip): url = before_clip else: # full url is visible on mouse-over (for those who don't # have a status bar, such as Safari by default) params += ' title="%s"' % href return u'<a href="%s"%s>%s</a>' % (href, params, url) # First HTML-escape so that our strings are all safe. # The regex is modified to avoid character entites other than &amp; so # that we won't pick up &quot;, etc. text = _unicode(xhtml_escape(text)) return _URL_RE.sub(make_link, text)
[ "def", "linkify", "(", "text", ",", "shorten", "=", "False", ",", "extra_params", "=", "\"\"", ",", "require_protocol", "=", "False", ",", "permitted_protocols", "=", "[", "\"http\"", ",", "\"https\"", "]", ")", ":", "if", "extra_params", "and", "not", "ca...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/ext/tornado/escape.py#L281-L374
nadineproject/nadine
c41c8ef7ffe18f1853029c97eecc329039b4af6c
nadine/management/commands/install_demo.py
python
Command.handle
(self, *args, **options)
[]
def handle(self, *args, **options): if settings.PRODUCTION: raise Exception('Will not install the demo on production.') self.delete_all(BillingLog) self.delete_all(Bill) self.delete_all(Transaction) self.delete_all(CoworkingDay) self.delete_all(MembershipPlan) self.delete_all(Membership) self.delete_all(UserProfile) self.delete_all(User) self.delete_all(Industry) self.delete_all(Neighborhood) self.delete_all(IncomingMail) self.delete_all(OutgoingMail) self.delete_all(MailingList) call_command('syncdb', interactive=False) call_command('migrate', interactive=False) basic_plan = MembershipPlan.objects.create(name='Basic', description='An occasional user', monthly_rate='50', daily_rate='25', dropin_allowance='5') resident_plan = MembershipPlan.objects.create(name='Resident', description='A frequent user', monthly_rate='500', daily_rate='20', has_desk=True) knitters_ml = MailingList.objects.create(name='Knitters', description='Knitters of the space', email_address='knitters@example.com', username='knitters', password='1234', pop_host='pop.example.com', smtp_host='smtp.example.com', ) gamers_ml = MailingList.objects.create(name='Game players', description='People who play board games', email_address='gamers@example.com', username='gamers', password='1234', pop_host='pop.example.com', smtp_host='smtp.example.com', ) alice = self.create_user('alice', '1234', 'Alice', 'Templeton', is_staff=True, is_superuser=True, email='alice@example.com') knitters_ml.moderators.add(alice) terry = self.create_user('terry', '1234', 'Terry', 'Moofty', email='terry@example.com') Membership.objects.create(user=terry, membership_plan=resident_plan, start_date=timezone.now().date() - timedelta(days=400), daily_rate=0, has_desk=True) knitters_ml.subscribers.add(terry) bob = self.create_user('bob', '1234', 'Bob', 'Stilton', email='bob@example.com') Membership.objects.create(user=bob, membership_plan=basic_plan, start_date=timezone.now().date() - timedelta(days=92), daily_rate=25) knitters_ml.subscribers.add(bob)
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "if", "settings", ".", "PRODUCTION", ":", "raise", "Exception", "(", "'Will not install the demo on production.'", ")", "self", ".", "delete_all", "(", "BillingLog", ")", "se...
https://github.com/nadineproject/nadine/blob/c41c8ef7ffe18f1853029c97eecc329039b4af6c/nadine/management/commands/install_demo.py#L25-L61
uqfoundation/mystic
154e6302d1f2f94e8f13e88ecc5f24241cc28ac7
mystic/scripts.py
python
_get_history
(source, ids=None)
return params, costs
get params and cost from the given source source is the name of the trajectory logfile (or solver instance) if provided, ids are the list of 'run ids' to select
get params and cost from the given source
[ "get", "params", "and", "cost", "from", "the", "given", "source" ]
def _get_history(source, ids=None): """get params and cost from the given source source is the name of the trajectory logfile (or solver instance) if provided, ids are the list of 'run ids' to select """ try: # if it's a logfile, it might be multi-id from mystic.munge import read_trajectories step, param, cost = read_trajectories(source) if not step: step = [(i,) for i in range(len(cost))] except: # it's not a logfile, so read and return from mystic.munge import read_history param, cost = read_history(source) return [param],[cost] # split (i,id) into iteration and id multinode = len(step[0]) - 1 if step else 0 #XXX: no step info, so give up if multinode: id = [(i[1] or 0) for i in step] else: id = [0 for i in step] params = [[] for i in range(max(id) + 1)] costs = [[] for i in range(len(params))] # populate params for each id with the corresponding (param,cost) for i in range(len(id)): if ids is None or id[i] in ids: # take only the selected 'id' params[id[i]].append(param[i]) costs[id[i]].append(cost[i]) params = [r for r in params if len(r)] # only keep selected 'ids' costs = [r for r in costs if len(r)] # only keep selected 'ids' # convert to support format from mystic.munge import raw_to_support for i in range(len(params)): params[i], costs[i] = raw_to_support(params[i], costs[i]) return params, costs
[ "def", "_get_history", "(", "source", ",", "ids", "=", "None", ")", ":", "try", ":", "# if it's a logfile, it might be multi-id", "from", "mystic", ".", "munge", "import", "read_trajectories", "step", ",", "param", ",", "cost", "=", "read_trajectories", "(", "so...
https://github.com/uqfoundation/mystic/blob/154e6302d1f2f94e8f13e88ecc5f24241cc28ac7/mystic/scripts.py#L125-L159
paulvangentcom/python_corona_simulation
a5dddd3e13d2bb768a9294d85ab27329be9a21dd
config.py
python
Configuration.set_self_isolation
(self, self_isolate_proportion=0.9, isolation_bounds = [0.02, 0.02, 0.09, 0.98], traveling_infects=False)
sets self-isolation scenario to active
sets self-isolation scenario to active
[ "sets", "self", "-", "isolation", "scenario", "to", "active" ]
def set_self_isolation(self, self_isolate_proportion=0.9, isolation_bounds = [0.02, 0.02, 0.09, 0.98], traveling_infects=False): '''sets self-isolation scenario to active''' self.self_isolate = True self.isolation_bounds = isolation_bounds self.self_isolate_proportion = self_isolate_proportion #set roaming bounds to outside isolated area self.xbounds = [0.1, 1.1] self.ybounds = [0.02, 0.98] #update plot bounds everything is shown self.x_plot = [0, 1.1] self.y_plot = [0, 1] #update whether traveling agents also infect self.traveling_infects = traveling_infects
[ "def", "set_self_isolation", "(", "self", ",", "self_isolate_proportion", "=", "0.9", ",", "isolation_bounds", "=", "[", "0.02", ",", "0.02", ",", "0.09", ",", "0.98", "]", ",", "traveling_infects", "=", "False", ")", ":", "self", ".", "self_isolate", "=", ...
https://github.com/paulvangentcom/python_corona_simulation/blob/a5dddd3e13d2bb768a9294d85ab27329be9a21dd/config.py#L153-L168
ym2011/POC-EXP
206b22d3a6b2a172359678df33bbc5b2ad04b6c3
K8/Web-Exp/sqlmap/thirdparty/oset/_abc.py
python
MutableSet.clear
(self)
This is slow (creates N new iterators!) but effective.
This is slow (creates N new iterators!) but effective.
[ "This", "is", "slow", "(", "creates", "N", "new", "iterators!", ")", "but", "effective", "." ]
def clear(self): """This is slow (creates N new iterators!) but effective.""" try: while True: self.pop() except KeyError: pass
[ "def", "clear", "(", "self", ")", ":", "try", ":", "while", "True", ":", "self", ".", "pop", "(", ")", "except", "KeyError", ":", "pass" ]
https://github.com/ym2011/POC-EXP/blob/206b22d3a6b2a172359678df33bbc5b2ad04b6c3/K8/Web-Exp/sqlmap/thirdparty/oset/_abc.py#L373-L379
mit-han-lab/once-for-all
4f6fce3652ee4553ea811d38f32f90ac8b1bc378
ofa/utils/layers.py
python
ResNetBottleneckBlock.config
(self)
return { 'name': ResNetBottleneckBlock.__name__, 'in_channels': self.in_channels, 'out_channels': self.out_channels, 'kernel_size': self.kernel_size, 'stride': self.stride, 'expand_ratio': self.expand_ratio, 'mid_channels': self.mid_channels, 'act_func': self.act_func, 'groups': self.groups, 'downsample_mode': self.downsample_mode, }
[]
def config(self): return { 'name': ResNetBottleneckBlock.__name__, 'in_channels': self.in_channels, 'out_channels': self.out_channels, 'kernel_size': self.kernel_size, 'stride': self.stride, 'expand_ratio': self.expand_ratio, 'mid_channels': self.mid_channels, 'act_func': self.act_func, 'groups': self.groups, 'downsample_mode': self.downsample_mode, }
[ "def", "config", "(", "self", ")", ":", "return", "{", "'name'", ":", "ResNetBottleneckBlock", ".", "__name__", ",", "'in_channels'", ":", "self", ".", "in_channels", ",", "'out_channels'", ":", "self", ".", "out_channels", ",", "'kernel_size'", ":", "self", ...
https://github.com/mit-han-lab/once-for-all/blob/4f6fce3652ee4553ea811d38f32f90ac8b1bc378/ofa/utils/layers.py#L632-L644
coala/coala
37af7fd5de3ed148b8096cfc80e4717fb840bf2c
coalib/results/result_actions/PrintMoreInfoAction.py
python
PrintMoreInfoAction.apply
(self, result, original_file_dict, file_diff_dict)
return file_diff_dict
Print (M)ore info
Print (M)ore info
[ "Print", "(", "M", ")", "ore", "info" ]
def apply(self, result, original_file_dict, file_diff_dict): """ Print (M)ore info """ print(result.additional_info) return file_diff_dict
[ "def", "apply", "(", "self", ",", "result", ",", "original_file_dict", ",", "file_diff_dict", ")", ":", "print", "(", "result", ".", "additional_info", ")", "return", "file_diff_dict" ]
https://github.com/coala/coala/blob/37af7fd5de3ed148b8096cfc80e4717fb840bf2c/coalib/results/result_actions/PrintMoreInfoAction.py#L19-L25
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/packages/site-packages/sphinx/writers/texinfo.py
python
TexinfoTranslator.collect_rellinks
(self)
Collect the relative links (next, previous, up) for each "node".
Collect the relative links (next, previous, up) for each "node".
[ "Collect", "the", "relative", "links", "(", "next", "previous", "up", ")", "for", "each", "node", "." ]
def collect_rellinks(self): """Collect the relative links (next, previous, up) for each "node".""" rellinks = self.rellinks node_menus = self.node_menus for id, entries in node_menus.items(): rellinks[id] = ['', '', ''] # up's for id, entries in node_menus.items(): for e in entries: rellinks[e][2] = id # next's and prev's for id, entries in node_menus.items(): for i, id in enumerate(entries): # First child's prev is empty if i != 0: rellinks[id][1] = entries[i-1] # Last child's next is empty if i != len(entries) - 1: rellinks[id][0] = entries[i+1] # top's next is its first child try: first = node_menus['Top'][0] except IndexError: pass else: rellinks['Top'][0] = first rellinks[first][1] = 'Top'
[ "def", "collect_rellinks", "(", "self", ")", ":", "rellinks", "=", "self", ".", "rellinks", "node_menus", "=", "self", ".", "node_menus", "for", "id", ",", "entries", "in", "node_menus", ".", "items", "(", ")", ":", "rellinks", "[", "id", "]", "=", "["...
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/site-packages/sphinx/writers/texinfo.py#L305-L331
viewfinderco/viewfinder
453845b5d64ab5b3b826c08b02546d1ca0a07c14
backend/www/auth_viewfinder.py
python
LoginResetViewfinderHandler._Finish
(cls, handler, client, user_dict, ident_dict, device_dict)
Invoked by VerifyViewfinderHandler to complete the login action.
Invoked by VerifyViewfinderHandler to complete the login action.
[ "Invoked", "by", "VerifyViewfinderHandler", "to", "complete", "the", "login", "action", "." ]
def _Finish(cls, handler, client, user_dict, ident_dict, device_dict): """Invoked by VerifyViewfinderHandler to complete the login action.""" handler._AuthUser(user_dict, ident_dict, device_dict, confirmed=True)
[ "def", "_Finish", "(", "cls", ",", "handler", ",", "client", ",", "user_dict", ",", "ident_dict", ",", "device_dict", ")", ":", "handler", ".", "_AuthUser", "(", "user_dict", ",", "ident_dict", ",", "device_dict", ",", "confirmed", "=", "True", ")" ]
https://github.com/viewfinderco/viewfinder/blob/453845b5d64ab5b3b826c08b02546d1ca0a07c14/backend/www/auth_viewfinder.py#L264-L266
mnemosyne-proj/mnemosyne
e39e364e56343437f2e485e0b06ca714de2f2d2e
mnemosyne/libmnemosyne/controllers/default_controller.py
python
DefaultController.create_new_cards
(self, fact_data, card_type, grade, tag_names, check_for_duplicates=True, save=True)
return cards
Create a new set of sister cards. If the grade is 2 or higher, we perform a initial review with that grade and move the cards into the long term retention process. For other grades, we treat the card as still unseen and keep its grade at -1. This puts the card on equal footing with ungraded cards created during the import process. These ungraded cards are pulled in at the end of the review process, either in the order they were added, on in random order.
Create a new set of sister cards. If the grade is 2 or higher, we perform a initial review with that grade and move the cards into the long term retention process. For other grades, we treat the card as still unseen and keep its grade at -1. This puts the card on equal footing with ungraded cards created during the import process. These ungraded cards are pulled in at the end of the review process, either in the order they were added, on in random order.
[ "Create", "a", "new", "set", "of", "sister", "cards", ".", "If", "the", "grade", "is", "2", "or", "higher", "we", "perform", "a", "initial", "review", "with", "that", "grade", "and", "move", "the", "cards", "into", "the", "long", "term", "retention", "...
def create_new_cards(self, fact_data, card_type, grade, tag_names, check_for_duplicates=True, save=True): """Create a new set of sister cards. If the grade is 2 or higher, we perform a initial review with that grade and move the cards into the long term retention process. For other grades, we treat the card as still unseen and keep its grade at -1. This puts the card on equal footing with ungraded cards created during the import process. These ungraded cards are pulled in at the end of the review process, either in the order they were added, on in random order. """ assert grade in [-1, 2, 3, 4, 5] # Use -1 for yet to learn cards. assert card_type.is_fact_data_valid(fact_data) db = self.database() tag_names = self._retain_only_child_tags(tag_names) tags = db.get_or_create_tags_with_names(tag_names) fact = Fact(fact_data) if check_for_duplicates: duplicates = db.duplicates_for_fact(fact, card_type) if len(duplicates) != 0: answer = None for duplicate in duplicates: # Duplicates only checks equality of unique keys. if duplicate.data == fact_data: answer = self.main_widget().show_question(\ _("Identical card is already in database."), _("&Do not add"), _("&Add anyway"), "") break if answer is None: question = \ _("There is already data present for this card:\n\n") existing_fact_data = {} for fact_key in card_type.fact_keys(): existing_fact_data[fact_key] = "" for duplicate in duplicates: if duplicate.data == fact.data: continue for fact_key in fact_data: if fact_key in duplicate.data and \ duplicate[fact_key] not in \ existing_fact_data[fact_key]: if len(existing_fact_data[fact_key]) != 0: existing_fact_data[fact_key] += " / " existing_fact_data[fact_key] += \ duplicate[fact_key] for fact_key, fact_key_name in \ card_type.fact_keys_and_names: question += _(fact_key_name) + ": " + \ existing_fact_data[fact_key] + "\n" answer = self.main_widget().show_question(question, _("&Do not add"), _("&Add anyway"), _("&Merge and edit")) if answer == 0: # Do not add. return if answer == 2: # Merge and edit. db.add_fact(fact) for duplicate in duplicates: for card in db.cards_from_fact(duplicate): tags.update(card.tags) cards = card_type.create_sister_cards(fact) for card in cards: card.tags = tags db.add_card(card) if grade >= 2: self.scheduler().set_initial_grade(cards, grade) for card in cards: db.update_card(card, repetition_only=True) merged_fact_data = copy.copy(fact.data) for duplicate in duplicates: for fact_key in fact_data: if fact_key in duplicate.data and \ duplicate[fact_key] not in \ merged_fact_data[fact_key]: merged_fact_data[fact_key] += " / " \ + duplicate[fact_key] self.delete_facts_and_their_cards(duplicates) card = db.cards_from_fact(fact)[0] card.fact.data = merged_fact_data card.tags = tags self.component_manager.current("edit_card_dialog")\ (card, component_manager=self.component_manager, allow_cancel=False).activate() return db.cards_from_fact(fact) # Create cards. cards = card_type.create_sister_cards(fact) db.add_fact(fact) for card in cards: card.tags = tags db.add_card(card) if grade >= 2: self.scheduler().set_initial_grade(cards, grade) for card in cards: db.update_card(card, repetition_only=True) if save: db.save() if self.review_controller().learning_ahead == True: self.reset_study_mode() return cards
[ "def", "create_new_cards", "(", "self", ",", "fact_data", ",", "card_type", ",", "grade", ",", "tag_names", ",", "check_for_duplicates", "=", "True", ",", "save", "=", "True", ")", ":", "assert", "grade", "in", "[", "-", "1", ",", "2", ",", "3", ",", ...
https://github.com/mnemosyne-proj/mnemosyne/blob/e39e364e56343437f2e485e0b06ca714de2f2d2e/mnemosyne/libmnemosyne/controllers/default_controller.py#L152-L250
Qirky/FoxDot
76318f9630bede48ff3994146ed644affa27bfa4
FoxDot/lib/Extensions/SonicPi/__init__.py
python
GenerateSonicPiData
(sonic_pi_dir)
Generate the sonic-pi json metadata from a sonic-pi source repo
Generate the sonic-pi json metadata from a sonic-pi source repo
[ "Generate", "the", "sonic", "-", "pi", "json", "metadata", "from", "a", "sonic", "-", "pi", "source", "repo" ]
def GenerateSonicPiData(sonic_pi_dir): """ Generate the sonic-pi json metadata from a sonic-pi source repo """ synthinfo = os.path.join(sonic_pi_dir, 'app/server/sonicpi/lib/sonicpi/synths/synthinfo') datastr = check_output(["ruby", RUBY_SCRIPT, synthinfo]) ref = check_output(["git", "rev-parse", "HEAD"], cwd=sonic_pi_dir).strip() data = json.loads(datastr) data['__ref__'] = ref with open(SONIC_PI_FILE, 'w') as ofile: json.dump(data, ofile, separators=(',', ':'))
[ "def", "GenerateSonicPiData", "(", "sonic_pi_dir", ")", ":", "synthinfo", "=", "os", ".", "path", ".", "join", "(", "sonic_pi_dir", ",", "'app/server/sonicpi/lib/sonicpi/synths/synthinfo'", ")", "datastr", "=", "check_output", "(", "[", "\"ruby\"", ",", "RUBY_SCRIPT...
https://github.com/Qirky/FoxDot/blob/76318f9630bede48ff3994146ed644affa27bfa4/FoxDot/lib/Extensions/SonicPi/__init__.py#L112-L121
rdehuyss/micropython-ota-updater
be4ec89994b2ac63a006113fb5cff21aa7202204
main.py
python
connectToWifiAndUpdate
()
[]
def connectToWifiAndUpdate(): import time, machine, network, gc, app.secrets as secrets time.sleep(1) print('Memory free', gc.mem_free()) from app.ota_updater import OTAUpdater sta_if = network.WLAN(network.STA_IF) if not sta_if.isconnected(): print('connecting to network...') sta_if.active(True) sta_if.connect(secrets.WIFI_SSID, secrets.WIFI_PASSWORD) while not sta_if.isconnected(): pass print('network config:', sta_if.ifconfig()) otaUpdater = OTAUpdater('https://github.com/rdehuyss/micropython-ota-updater', main_dir='app', secrets_file="secrets.py") hasUpdated = otaUpdater.install_update_if_available() if hasUpdated: machine.reset() else: del(otaUpdater) gc.collect()
[ "def", "connectToWifiAndUpdate", "(", ")", ":", "import", "time", ",", "machine", ",", "network", ",", "gc", ",", "app", ".", "secrets", "as", "secrets", "time", ".", "sleep", "(", "1", ")", "print", "(", "'Memory free'", ",", "gc", ".", "mem_free", "(...
https://github.com/rdehuyss/micropython-ota-updater/blob/be4ec89994b2ac63a006113fb5cff21aa7202204/main.py#L3-L24
containernet/containernet
7b2ae38d691b2ed8da2b2700b85ed03562271d01
examples/miniedit.py
python
customOvs.setSwitchIP
(self, ip)
Set management IP address
Set management IP address
[ "Set", "management", "IP", "address" ]
def setSwitchIP(self, ip): "Set management IP address" self.switchIP = ip
[ "def", "setSwitchIP", "(", "self", ",", "ip", ")", ":", "self", ".", "switchIP", "=", "ip" ]
https://github.com/containernet/containernet/blob/7b2ae38d691b2ed8da2b2700b85ed03562271d01/examples/miniedit.py#L167-L169
qutip/qutip
52d01da181a21b810c3407812c670f35fdc647e8
qutip/superop_reps.py
python
chi_to_choi
(q_oper)
return Qobj((B * q_oper * B.dag()) / q_oper.shape[0], superrep='choi')
Converts a Chi matrix to a Choi matrix. NOTE: this is only supported for qubits right now. Need to extend to Heisenberg-Weyl for other subsystem dimensions.
Converts a Chi matrix to a Choi matrix.
[ "Converts", "a", "Chi", "matrix", "to", "a", "Choi", "matrix", "." ]
def chi_to_choi(q_oper): """ Converts a Chi matrix to a Choi matrix. NOTE: this is only supported for qubits right now. Need to extend to Heisenberg-Weyl for other subsystem dimensions. """ nq = _nq(q_oper.dims) B = _pauli_basis(nq) # Force the basis change to match the dimensions of # the input. B.dims = q_oper.dims # We normally should not multiply objects of different # superreps, so Qobj warns about that. Here, however, we're actively # converting between, so the superrep of B is irrelevant. # To suppress warnings, we pretend that B is also a chi. B.superrep = 'chi' # The Chi matrix has tr(chi) == d², so we need to divide out # by that to get back to the Choi form. return Qobj((B * q_oper * B.dag()) / q_oper.shape[0], superrep='choi')
[ "def", "chi_to_choi", "(", "q_oper", ")", ":", "nq", "=", "_nq", "(", "q_oper", ".", "dims", ")", "B", "=", "_pauli_basis", "(", "nq", ")", "# Force the basis change to match the dimensions of", "# the input.", "B", ".", "dims", "=", "q_oper", ".", "dims", "...
https://github.com/qutip/qutip/blob/52d01da181a21b810c3407812c670f35fdc647e8/qutip/superop_reps.py#L251-L272
ntalekt/homeassistant
8fb6da881564430a3324125ddc2bd43cb7c8680f
custom_components/monitor_docker/sensor.py
python
DockerSensor.icon
(self)
return self._var_icon
Icon to use in the frontend.
Icon to use in the frontend.
[ "Icon", "to", "use", "in", "the", "frontend", "." ]
def icon(self): """Icon to use in the frontend.""" return self._var_icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_var_icon" ]
https://github.com/ntalekt/homeassistant/blob/8fb6da881564430a3324125ddc2bd43cb7c8680f/custom_components/monitor_docker/sensor.py#L178-L180
KalleHallden/AutoTimer
2d954216700c4930baa154e28dbddc34609af7ce
env/lib/python2.7/site-packages/pip/_vendor/chardet/sjisprober.py
python
SJISProber.__init__
(self)
[]
def __init__(self): super(SJISProber, self).__init__() self.coding_sm = CodingStateMachine(SJIS_SM_MODEL) self.distribution_analyzer = SJISDistributionAnalysis() self.context_analyzer = SJISContextAnalysis() self.reset()
[ "def", "__init__", "(", "self", ")", ":", "super", "(", "SJISProber", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "coding_sm", "=", "CodingStateMachine", "(", "SJIS_SM_MODEL", ")", "self", ".", "distribution_analyzer", "=", "SJISDistributionAnaly...
https://github.com/KalleHallden/AutoTimer/blob/2d954216700c4930baa154e28dbddc34609af7ce/env/lib/python2.7/site-packages/pip/_vendor/chardet/sjisprober.py#L37-L42
citronneur/rdpy
cef16a9f64d836a3221a344ca7d571644280d829
rdpy/core/type.py
python
String.__init__
(self, value = "", readLen = None, conditional = lambda:True, optional = False, constant = False, unicode = False, until = None)
@param value: python string use for inner value @param readLen: length use to read in stream (SimpleType) if 0 read entire stream @param conditional : Callable object Read and Write operation depend on return of this function @param optional: If there is no enough byte in current stream And optional is True, read type is ignored @param constant: Check if object value doesn't change after read operation @param unicode: Encode and decode value as unicode @param until: read until sequence is readed or write sequence at the end of string
[]
def __init__(self, value = "", readLen = None, conditional = lambda:True, optional = False, constant = False, unicode = False, until = None): """ @param value: python string use for inner value @param readLen: length use to read in stream (SimpleType) if 0 read entire stream @param conditional : Callable object Read and Write operation depend on return of this function @param optional: If there is no enough byte in current stream And optional is True, read type is ignored @param constant: Check if object value doesn't change after read operation @param unicode: Encode and decode value as unicode @param until: read until sequence is readed or write sequence at the end of string """ Type.__init__(self, conditional = conditional, optional = optional, constant = constant) CallableValue.__init__(self, value) #type use to know read length self._readLen = readLen self._unicode = unicode self._until = until
[ "def", "__init__", "(", "self", ",", "value", "=", "\"\"", ",", "readLen", "=", "None", ",", "conditional", "=", "lambda", ":", "True", ",", "optional", "=", "False", ",", "constant", "=", "False", ",", "unicode", "=", "False", ",", "until", "=", "No...
https://github.com/citronneur/rdpy/blob/cef16a9f64d836a3221a344ca7d571644280d829/rdpy/core/type.py#L744-L761
AutodeskRoboticsLab/Mimic
85447f0d346be66988303a6a054473d92f1ed6f4
mimic/scripts/mimic_external_axes.py
python
get_external_axis_info
(robot_name, external_axis_name)
return info
Get's all of the external axis settings for the input external axis name :param robot_name: string, name of robot :param external_axis_name: string, name of external axis :return info: dict, dictionary of input external axis setting
Get's all of the external axis settings for the input external axis name :param robot_name: string, name of robot :param external_axis_name: string, name of external axis :return info: dict, dictionary of input external axis setting
[ "Get", "s", "all", "of", "the", "external", "axis", "settings", "for", "the", "input", "external", "axis", "name", ":", "param", "robot_name", ":", "string", "name", "of", "robot", ":", "param", "external_axis_name", ":", "string", "name", "of", "external", ...
def get_external_axis_info(robot_name, external_axis_name): """ Get's all of the external axis settings for the input external axis name :param robot_name: string, name of robot :param external_axis_name: string, name of external axis :return info: dict, dictionary of input external axis setting """ info = {} info['Robot Name'] = robot_name info['Axis Name'] = external_axis_name external_axis_path = _get_external_axis_path(robot_name, external_axis_name) info['Axis Number'] = _get_external_axis_number(external_axis_path) driving_attr_ctrl, driving_attr_name = _get_external_axis_connections(external_axis_path) info['Driving Controller'] = driving_attr_ctrl info['Driving Attribute'] = driving_attr_name info['Position Limit Min'] = _get_external_axis_limits_min(external_axis_path) info['Position Limit Max'] = _get_external_axis_limits_max(external_axis_path) info['Velocity Limit'] = _get_external_axis_velocity_limit(external_axis_path) info['Ignore'] = _get_external_axis_ignore(external_axis_path) return info
[ "def", "get_external_axis_info", "(", "robot_name", ",", "external_axis_name", ")", ":", "info", "=", "{", "}", "info", "[", "'Robot Name'", "]", "=", "robot_name", "info", "[", "'Axis Name'", "]", "=", "external_axis_name", "external_axis_path", "=", "_get_extern...
https://github.com/AutodeskRoboticsLab/Mimic/blob/85447f0d346be66988303a6a054473d92f1ed6f4/mimic/scripts/mimic_external_axes.py#L56-L85
koalalorenzo/python-digitalocean
ebea58fddf2ceea35c027bfa66f2fa9f5debfd64
digitalocean/LoadBalancer.py
python
LoadBalancer.__str__
(self)
return "%s" % (self.id)
[]
def __str__(self): return "%s" % (self.id)
[ "def", "__str__", "(", "self", ")", ":", "return", "\"%s\"", "%", "(", "self", ".", "id", ")" ]
https://github.com/koalalorenzo/python-digitalocean/blob/ebea58fddf2ceea35c027bfa66f2fa9f5debfd64/digitalocean/LoadBalancer.py#L379-L380
Jajcus/pyxmpp2
59e5fd7c8837991ac265dc6aad23a6bd256768a7
pyxmpp2/ext/muc/muccore.py
python
MucXBase.free
(self)
Unlink and free the XML node owned by `self`.
Unlink and free the XML node owned by `self`.
[ "Unlink", "and", "free", "the", "XML", "node", "owned", "by", "self", "." ]
def free(self): """ Unlink and free the XML node owned by `self`. """ if not self.borrowed: self.xmlnode.unlinkNode() self.xmlnode.freeNode() self.xmlnode=None
[ "def", "free", "(", "self", ")", ":", "if", "not", "self", ".", "borrowed", ":", "self", ".", "xmlnode", ".", "unlinkNode", "(", ")", "self", ".", "xmlnode", ".", "freeNode", "(", ")", "self", ".", "xmlnode", "=", "None" ]
https://github.com/Jajcus/pyxmpp2/blob/59e5fd7c8837991ac265dc6aad23a6bd256768a7/pyxmpp2/ext/muc/muccore.py#L105-L112
IntelPython/sdc
1ebf55c00ef38dfbd401a70b3945e352a5a38b87
sdc/utilities/utils.py
python
is_assign
(inst)
return isinstance(inst, ir.Assign)
[]
def is_assign(inst): return isinstance(inst, ir.Assign)
[ "def", "is_assign", "(", "inst", ")", ":", "return", "isinstance", "(", "inst", ",", "ir", ".", "Assign", ")" ]
https://github.com/IntelPython/sdc/blob/1ebf55c00ef38dfbd401a70b3945e352a5a38b87/sdc/utilities/utils.py#L551-L552
wakatime/legacy-python-cli
9b64548b16ab5ef16603d9a6c2620a16d0df8d46
wakatime/packages/ntlm_auth/session_security.py
python
SessionSecurity._seal_message
(self, message)
return encrypted_message
[MS-NLMP] v28.0 2016-07-14 3.4.3 Message Confidentiality Will generate an encrypted message using RC4 based on the ClientSealingKey @param message: The message to be sealed (encrypted) @return encrypted_message: The encrypted message
[MS-NLMP] v28.0 2016-07-14
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
def _seal_message(self, message): """ [MS-NLMP] v28.0 2016-07-14 3.4.3 Message Confidentiality Will generate an encrypted message using RC4 based on the ClientSealingKey @param message: The message to be sealed (encrypted) @return encrypted_message: The encrypted message """ encrypted_message = self.outgoing_handle.update(message) return encrypted_message
[ "def", "_seal_message", "(", "self", ",", "message", ")", ":", "encrypted_message", "=", "self", ".", "outgoing_handle", ".", "update", "(", "message", ")", "return", "encrypted_message" ]
https://github.com/wakatime/legacy-python-cli/blob/9b64548b16ab5ef16603d9a6c2620a16d0df8d46/wakatime/packages/ntlm_auth/session_security.py#L159-L170
Cog-Creators/Red-DiscordBot
b05933274a11fb097873ab0d1b246d37b06aa306
redbot/core/config.py
python
Config.member_from_ids
(self, guild_id: int, member_id: int)
return self._get_base_group(self.MEMBER, str(guild_id), str(member_id))
Returns a `Group` for the ids which represent a member. Parameters ---------- guild_id : int The id of the guild of the member member_id : int The id of the member Returns ------- `Group <redbot.core.config.Group>` The member's Group object.
Returns a `Group` for the ids which represent a member.
[ "Returns", "a", "Group", "for", "the", "ids", "which", "represent", "a", "member", "." ]
def member_from_ids(self, guild_id: int, member_id: int) -> Group: """Returns a `Group` for the ids which represent a member. Parameters ---------- guild_id : int The id of the guild of the member member_id : int The id of the member Returns ------- `Group <redbot.core.config.Group>` The member's Group object. """ return self._get_base_group(self.MEMBER, str(guild_id), str(member_id))
[ "def", "member_from_ids", "(", "self", ",", "guild_id", ":", "int", ",", "member_id", ":", "int", ")", "->", "Group", ":", "return", "self", ".", "_get_base_group", "(", "self", ".", "MEMBER", ",", "str", "(", "guild_id", ")", ",", "str", "(", "member_...
https://github.com/Cog-Creators/Red-DiscordBot/blob/b05933274a11fb097873ab0d1b246d37b06aa306/redbot/core/config.py#L1078-L1094
edisonlz/fastor
342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3
base/site-packages/tencentcloud/vpc/v20170312/vpc_client.py
python
VpcClient.UnassignPrivateIpAddresses
(self, request)
本接口(UnassignPrivateIpAddresses)用于弹性网卡退还内网 IP。 * 退还弹性网卡上的辅助内网IP,接口自动解关联弹性公网 IP。不能退还弹性网卡的主内网IP。 :param request: 调用UnassignPrivateIpAddresses所需参数的结构体。 :type request: :class:`tencentcloud.vpc.v20170312.models.UnassignPrivateIpAddressesRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.UnassignPrivateIpAddressesResponse`
本接口(UnassignPrivateIpAddresses)用于弹性网卡退还内网 IP。 * 退还弹性网卡上的辅助内网IP,接口自动解关联弹性公网 IP。不能退还弹性网卡的主内网IP。
[ "本接口(UnassignPrivateIpAddresses)用于弹性网卡退还内网", "IP。", "*", "退还弹性网卡上的辅助内网IP,接口自动解关联弹性公网", "IP。不能退还弹性网卡的主内网IP。" ]
def UnassignPrivateIpAddresses(self, request): """本接口(UnassignPrivateIpAddresses)用于弹性网卡退还内网 IP。 * 退还弹性网卡上的辅助内网IP,接口自动解关联弹性公网 IP。不能退还弹性网卡的主内网IP。 :param request: 调用UnassignPrivateIpAddresses所需参数的结构体。 :type request: :class:`tencentcloud.vpc.v20170312.models.UnassignPrivateIpAddressesRequest` :rtype: :class:`tencentcloud.vpc.v20170312.models.UnassignPrivateIpAddressesResponse` """ try: params = request._serialize() body = self.call("UnassignPrivateIpAddresses", params) response = json.loads(body) if "Error" not in response["Response"]: model = models.UnassignPrivateIpAddressesResponse() model._deserialize(response["Response"]) return model else: code = response["Response"]["Error"]["Code"] message = response["Response"]["Error"]["Message"] reqid = response["Response"]["RequestId"] raise TencentCloudSDKException(code, message, reqid) except Exception as e: if isinstance(e, TencentCloudSDKException): raise e else: raise TencentCloudSDKException(e.message, e.message)
[ "def", "UnassignPrivateIpAddresses", "(", "self", ",", "request", ")", ":", "try", ":", "params", "=", "request", ".", "_serialize", "(", ")", "body", "=", "self", ".", "call", "(", "\"UnassignPrivateIpAddresses\"", ",", "params", ")", "response", "=", "json...
https://github.com/edisonlz/fastor/blob/342078a18363ac41d3c6b1ab29dbdd44fdb0b7b3/base/site-packages/tencentcloud/vpc/v20170312/vpc_client.py#L2516-L2542
PMEAL/OpenPNM
c9514b858d1361b2090b2f9579280cbcd476c9b0
openpnm/topotools/_topotools.py
python
stitch_pores
(network, pores1, pores2, mode='gabriel')
r""" Stitches together pores in a network with disconnected clusters Parameters ---------- network : OpenPNM Network The network to operate upon pores1 and pores2: array_like The pore indices of the disconnected clusters to be joined mode : str Dictates which tesselation method is used to identify which pores to stitch together. Options are: =========== ===================================================== mode meaning =========== ===================================================== 'gabriel' Uses the gabriel tesselation method 'delaunay' Uses the delaunay tesselation method =========== ===================================================== Returns ------- None The network is operated on 'in-place' so nothing is returned.
r""" Stitches together pores in a network with disconnected clusters
[ "r", "Stitches", "together", "pores", "in", "a", "network", "with", "disconnected", "clusters" ]
def stitch_pores(network, pores1, pores2, mode='gabriel'): r""" Stitches together pores in a network with disconnected clusters Parameters ---------- network : OpenPNM Network The network to operate upon pores1 and pores2: array_like The pore indices of the disconnected clusters to be joined mode : str Dictates which tesselation method is used to identify which pores to stitch together. Options are: =========== ===================================================== mode meaning =========== ===================================================== 'gabriel' Uses the gabriel tesselation method 'delaunay' Uses the delaunay tesselation method =========== ===================================================== Returns ------- None The network is operated on 'in-place' so nothing is returned. """ from openpnm.network import Delaunay, Gabriel pores1 = network._parse_indices(pores1) pores2 = network._parse_indices(pores2) C1 = network.coords[pores1, :] C2 = network.coords[pores2, :] crds = np.vstack((C1, C2)) if mode == 'delaunay': net = Delaunay(points=crds, settings={'trim': False}) if mode == 'gabriel': net = Gabriel(points=crds, settings={'trim': False}) net.set_label(pores=range(len(pores1)), label='pore.one') net.set_label(pores=range(len(pores2)), label='pore.two') Ts = net.find_neighbor_throats(pores=net.pores('one'), mode='xor') conns = net.conns[Ts] mapped_conns = np.vstack((pores1[conns[:, 0]], pores2[conns[:, 1] - len(pores1)])).T mapped_conns = np.sort(mapped_conns, axis=1) extend(network=network, conns=mapped_conns, labels='stitched')
[ "def", "stitch_pores", "(", "network", ",", "pores1", ",", "pores2", ",", "mode", "=", "'gabriel'", ")", ":", "from", "openpnm", ".", "network", "import", "Delaunay", ",", "Gabriel", "pores1", "=", "network", ".", "_parse_indices", "(", "pores1", ")", "por...
https://github.com/PMEAL/OpenPNM/blob/c9514b858d1361b2090b2f9579280cbcd476c9b0/openpnm/topotools/_topotools.py#L787-L831
pyparallel/pyparallel
11e8c6072d48c8f13641925d17b147bf36ee0ba3
Lib/site-packages/pip-7.1.2-py3.3.egg/pip/utils/__init__.py
python
backup_dir
(dir, ext='.bak')
return dir + extension
Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc)
Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc)
[ "Figure", "out", "the", "name", "of", "a", "directory", "to", "back", "up", "the", "given", "dir", "to", "(", "adding", ".", "bak", ".", "bak2", "etc", ")" ]
def backup_dir(dir, ext='.bak'): """Figure out the name of a directory to back up the given dir to (adding .bak, .bak2, etc)""" n = 1 extension = ext while os.path.exists(dir + extension): n += 1 extension = ext + str(n) return dir + extension
[ "def", "backup_dir", "(", "dir", ",", "ext", "=", "'.bak'", ")", ":", "n", "=", "1", "extension", "=", "ext", "while", "os", ".", "path", ".", "exists", "(", "dir", "+", "extension", ")", ":", "n", "+=", "1", "extension", "=", "ext", "+", "str", ...
https://github.com/pyparallel/pyparallel/blob/11e8c6072d48c8f13641925d17b147bf36ee0ba3/Lib/site-packages/pip-7.1.2-py3.3.egg/pip/utils/__init__.py#L120-L128
PowerScript/KatanaFramework
0f6ad90a88de865d58ec26941cb4460501e75496
lib/scapy/scapy/arch/windows/__init__.py
python
show_interfaces
(resolve_mac=True)
return ifaces.show(resolve_mac)
Print list of available network interfaces
Print list of available network interfaces
[ "Print", "list", "of", "available", "network", "interfaces" ]
def show_interfaces(resolve_mac=True): """Print list of available network interfaces""" return ifaces.show(resolve_mac)
[ "def", "show_interfaces", "(", "resolve_mac", "=", "True", ")", ":", "return", "ifaces", ".", "show", "(", "resolve_mac", ")" ]
https://github.com/PowerScript/KatanaFramework/blob/0f6ad90a88de865d58ec26941cb4460501e75496/lib/scapy/scapy/arch/windows/__init__.py#L229-L231
CvvT/dumpDex
92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1
python/idaapi.py
python
handle_debug_event
(*args)
return _idaapi.handle_debug_event(*args)
handle_debug_event(ev, rqflags) -> int
handle_debug_event(ev, rqflags) -> int
[ "handle_debug_event", "(", "ev", "rqflags", ")", "-", ">", "int" ]
def handle_debug_event(*args): """ handle_debug_event(ev, rqflags) -> int """ return _idaapi.handle_debug_event(*args)
[ "def", "handle_debug_event", "(", "*", "args", ")", ":", "return", "_idaapi", ".", "handle_debug_event", "(", "*", "args", ")" ]
https://github.com/CvvT/dumpDex/blob/92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1/python/idaapi.py#L3397-L3401
inkandswitch/livebook
93c8d467734787366ad084fc3566bf5cbe249c51
public/pypyjs/modules/shutil.py
python
copystat
(src, dst)
Copy all stat info (mode bits, atime, mtime, flags) from src to dst
Copy all stat info (mode bits, atime, mtime, flags) from src to dst
[ "Copy", "all", "stat", "info", "(", "mode", "bits", "atime", "mtime", "flags", ")", "from", "src", "to", "dst" ]
def copystat(src, dst): """Copy all stat info (mode bits, atime, mtime, flags) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) if hasattr(os, 'chflags') and hasattr(st, 'st_flags'): try: os.chflags(dst, st.st_flags) except OSError, why: for err in 'EOPNOTSUPP', 'ENOTSUP': if hasattr(errno, err) and why.errno == getattr(errno, err): break else: raise
[ "def", "copystat", "(", "src", ",", "dst", ")", ":", "st", "=", "os", ".", "stat", "(", "src", ")", "mode", "=", "stat", ".", "S_IMODE", "(", "st", ".", "st_mode", ")", "if", "hasattr", "(", "os", ",", "'utime'", ")", ":", "os", ".", "utime", ...
https://github.com/inkandswitch/livebook/blob/93c8d467734787366ad084fc3566bf5cbe249c51/public/pypyjs/modules/shutil.py#L93-L109
standardebooks/tools
f57af3c5938a9aeed9e97e82b2c130424f6033e5
se/images.py
python
_float_to_str
(float_value: float)
return "{0:.2f}".format(round(float_value, 2))
[]
def _float_to_str(float_value: float) -> str: return "{0:.2f}".format(round(float_value, 2))
[ "def", "_float_to_str", "(", "float_value", ":", "float", ")", "->", "str", ":", "return", "\"{0:.2f}\"", ".", "format", "(", "round", "(", "float_value", ",", "2", ")", ")" ]
https://github.com/standardebooks/tools/blob/f57af3c5938a9aeed9e97e82b2c130424f6033e5/se/images.py#L402-L403
cvjena/semantic-embeddings
0d4177422bafbba685fb6a0f976675864f31e09f
utils.py
python
l2norm
(x)
return K.tf.nn.l2_normalize(x, -1)
L2-normalizes a tensor along the last axis.
L2-normalizes a tensor along the last axis.
[ "L2", "-", "normalizes", "a", "tensor", "along", "the", "last", "axis", "." ]
def l2norm(x): """ L2-normalizes a tensor along the last axis. """ return K.tf.nn.l2_normalize(x, -1)
[ "def", "l2norm", "(", "x", ")", ":", "return", "K", ".", "tf", ".", "nn", ".", "l2_normalize", "(", "x", ",", "-", "1", ")" ]
https://github.com/cvjena/semantic-embeddings/blob/0d4177422bafbba685fb6a0f976675864f31e09f/utils.py#L125-L127
hyperspy/hyperspy
1ffb3fab33e607045a37f30c1463350b72617e10
hyperspy/io_plugins/sur.py
python
DigitalSurfHandler._build_general_1D_data
(self,)
Build general 1D Data objects. Currently work with spectra
Build general 1D Data objects. Currently work with spectra
[ "Build", "general", "1D", "Data", "objects", ".", "Currently", "work", "with", "spectra" ]
def _build_general_1D_data(self,): """Build general 1D Data objects. Currently work with spectra""" #Check that the object contained only one object. #Probably overkill at this point but better safe than sorry if len(self._list_sur_file_content) != 1: raise MountainsMapFileError("Corrupt file") #We get the dictionary with all the data hypdic = self._list_sur_file_content[0] #Add the axe to the signal dict self.signal_dict['axes'].append(\ self._build_Xax(hypdic,ind=0,nav=False)) #We reshape the data in the correct format self.signal_dict['data'] = hypdic['_62_points'] #Build the metadata self._set_metadata_and_original_metadata(hypdic)
[ "def", "_build_general_1D_data", "(", "self", ",", ")", ":", "#Check that the object contained only one object.", "#Probably overkill at this point but better safe than sorry", "if", "len", "(", "self", ".", "_list_sur_file_content", ")", "!=", "1", ":", "raise", "MountainsMa...
https://github.com/hyperspy/hyperspy/blob/1ffb3fab33e607045a37f30c1463350b72617e10/hyperspy/io_plugins/sur.py#L695-L714
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-darwin/x64/tornado/auth.py
python
GoogleOAuth2Mixin._on_access_token
(self, future, response_fut)
Callback function for the exchange to the access token.
Callback function for the exchange to the access token.
[ "Callback", "function", "for", "the", "exchange", "to", "the", "access", "token", "." ]
def _on_access_token(self, future, response_fut): """Callback function for the exchange to the access token.""" try: response = response_fut.result() except Exception as e: future.set_exception(AuthError('Google auth error: %s' % str(e))) return args = escape.json_decode(response.body) future_set_result_unless_cancelled(future, args)
[ "def", "_on_access_token", "(", "self", ",", "future", ",", "response_fut", ")", ":", "try", ":", "response", "=", "response_fut", ".", "result", "(", ")", "except", "Exception", "as", "e", ":", "future", ".", "set_exception", "(", "AuthError", "(", "'Goog...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-darwin/x64/tornado/auth.py#L982-L991
citronneur/rdpy
cef16a9f64d836a3221a344ca7d571644280d829
rdpy/protocol/rdp/rdp.py
python
RDPClientObserver.__init__
(self, controller)
@param controller: RDP controller use to interact with protocol
[]
def __init__(self, controller): """ @param controller: RDP controller use to interact with protocol """ self._controller = controller self._controller.addClientObserver(self)
[ "def", "__init__", "(", "self", ",", "controller", ")", ":", "self", ".", "_controller", "=", "controller", "self", ".", "_controller", ".", "addClientObserver", "(", "self", ")" ]
https://github.com/citronneur/rdpy/blob/cef16a9f64d836a3221a344ca7d571644280d829/rdpy/protocol/rdp/rdp.py#L635-L640
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/app_manager/suite_xml/post_process/remote_requests.py
python
RemoteRequestFactory.get_smart_link_function
(self)
return f"concat('{prefix}', $domain, '{suffix}'{params})"
[]
def get_smart_link_function(self): # Returns XPath that will evaluate to a URL. # For example, return value could be # concat('https://www.cchq.org/a/', $domain, '/app/v1/123/smartlink/', '?arg1=', $arg1, '&arg2=', $arg2) # Which could evaluate to # https://www.cchq.org/a/mydomain/app/v1/123/smartlink/?arg1=abd&arg2=def app_id = self.app.upstream_app_id if is_linked_app(self.app) else self.app.origin_id url = absolute_reverse("session_endpoint", args=["---", app_id, self.module.session_endpoint_id]) prefix, suffix = url.split("---") params = "" argument_ids = self.endpoint_argument_ids if argument_ids: params = f", '?{argument_ids[-1]}=', ${argument_ids[-1]}" for argument_id in argument_ids[:-1]: params += f", '&{argument_id}=', ${argument_id}" return f"concat('{prefix}', $domain, '{suffix}'{params})"
[ "def", "get_smart_link_function", "(", "self", ")", ":", "# Returns XPath that will evaluate to a URL.", "# For example, return value could be", "# concat('https://www.cchq.org/a/', $domain, '/app/v1/123/smartlink/', '?arg1=', $arg1, '&arg2=', $arg2)", "# Which could evaluate to", "# https:/...
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/app_manager/suite_xml/post_process/remote_requests.py#L298-L313
celery/django-celery-beat
fa73034be892052893e4ef17926ef3a5d4a21ea2
django_celery_beat/utils.py
python
is_database_scheduler
(scheduler)
return ( scheduler == 'django' or issubclass(symbol_by_name(scheduler), DatabaseScheduler) )
Return true if Celery is configured to use the db scheduler.
Return true if Celery is configured to use the db scheduler.
[ "Return", "true", "if", "Celery", "is", "configured", "to", "use", "the", "db", "scheduler", "." ]
def is_database_scheduler(scheduler): """Return true if Celery is configured to use the db scheduler.""" if not scheduler: return False from kombu.utils import symbol_by_name from .schedulers import DatabaseScheduler return ( scheduler == 'django' or issubclass(symbol_by_name(scheduler), DatabaseScheduler) )
[ "def", "is_database_scheduler", "(", "scheduler", ")", ":", "if", "not", "scheduler", ":", "return", "False", "from", "kombu", ".", "utils", "import", "symbol_by_name", "from", ".", "schedulers", "import", "DatabaseScheduler", "return", "(", "scheduler", "==", "...
https://github.com/celery/django-celery-beat/blob/fa73034be892052893e4ef17926ef3a5d4a21ea2/django_celery_beat/utils.py#L39-L48
out0fmemory/GoAgent-Always-Available
c4254984fea633ce3d1893fe5901debd9f22c2a9
server/lib/google/appengine/ext/ndb/model.py
python
Model._get_property_for
(self, p, indexed=True, depth=0)
return prop
Internal helper to get the Property for a protobuf-level property.
Internal helper to get the Property for a protobuf-level property.
[ "Internal", "helper", "to", "get", "the", "Property", "for", "a", "protobuf", "-", "level", "property", "." ]
def _get_property_for(self, p, indexed=True, depth=0): """Internal helper to get the Property for a protobuf-level property.""" parts = p.name().split('.') if len(parts) <= depth: # Apparently there's an unstructured value here. # Assume it is a None written for a missing value. # (It could also be that a schema change turned an unstructured # value into a structured one. In that case, too, it seems # better to return None than to return an unstructured value, # since the latter doesn't match the current schema.) return None next = parts[depth] prop = self._properties.get(next) if prop is None: prop = self._fake_property(p, next, indexed) return prop
[ "def", "_get_property_for", "(", "self", ",", "p", ",", "indexed", "=", "True", ",", "depth", "=", "0", ")", ":", "parts", "=", "p", ".", "name", "(", ")", ".", "split", "(", "'.'", ")", "if", "len", "(", "parts", ")", "<=", "depth", ":", "# Ap...
https://github.com/out0fmemory/GoAgent-Always-Available/blob/c4254984fea633ce3d1893fe5901debd9f22c2a9/server/lib/google/appengine/ext/ndb/model.py#L3231-L3246
Source-Python-Dev-Team/Source.Python
d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb
addons/source-python/packages/site-packages/pygments/formatter.py
python
Formatter.get_style_defs
(self, arg='')
return ''
Return the style definitions for the current style as a string. ``arg`` is an additional argument whose meaning depends on the formatter used. Note that ``arg`` can also be a list or tuple for some formatters like the html formatter.
Return the style definitions for the current style as a string.
[ "Return", "the", "style", "definitions", "for", "the", "current", "style", "as", "a", "string", "." ]
def get_style_defs(self, arg=''): """ Return the style definitions for the current style as a string. ``arg`` is an additional argument whose meaning depends on the formatter used. Note that ``arg`` can also be a list or tuple for some formatters like the html formatter. """ return ''
[ "def", "get_style_defs", "(", "self", ",", "arg", "=", "''", ")", ":", "return", "''" ]
https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/site-packages/pygments/formatter.py#L77-L85
reingart/pyfpdf
cb3340806c140b6e63eb4ce9d6230be84fba456e
fpdf/fpdf.py
python
FPDF.get_y
(self)
return self.y
Get y position
Get y position
[ "Get", "y", "position" ]
def get_y(self): "Get y position" return self.y
[ "def", "get_y", "(", "self", ")", ":", "return", "self", ".", "y" ]
https://github.com/reingart/pyfpdf/blob/cb3340806c140b6e63eb4ce9d6230be84fba456e/fpdf/fpdf.py#L1085-L1087
zbarge/stocklook
d40bf60566681acd1e970818450228602bb7d8a5
stocklook/crypto/gdax/order_mm.py
python
GdaxMMOrder.op_order
(self)
return self._op_order
Applies only to sell orders. Returns the opposite side of the trade. Used to calculate stop-outs and profit/loss. :return:
Applies only to sell orders. Returns the opposite side of the trade. Used to calculate stop-outs and profit/loss. :return:
[ "Applies", "only", "to", "sell", "orders", ".", "Returns", "the", "opposite", "side", "of", "the", "trade", ".", "Used", "to", "calculate", "stop", "-", "outs", "and", "profit", "/", "loss", ".", ":", "return", ":" ]
def op_order(self): """ Applies only to sell orders. Returns the opposite side of the trade. Used to calculate stop-outs and profit/loss. :return: """ return self._op_order
[ "def", "op_order", "(", "self", ")", ":", "return", "self", ".", "_op_order" ]
https://github.com/zbarge/stocklook/blob/d40bf60566681acd1e970818450228602bb7d8a5/stocklook/crypto/gdax/order_mm.py#L98-L104
carla-simulator/scenario_runner
f4d00d88eda4212a1e119515c96281a4be5c234e
srunner/scenariomanager/weather_sim.py
python
Weather.update
(self, delta_time=0)
If the weather animation is true, the new sun position is calculated w.r.t delta_time Nothing happens if animation or datetime are None. Args: delta_time (float): Time passed since self.datetime [seconds].
If the weather animation is true, the new sun position is calculated w.r.t delta_time
[ "If", "the", "weather", "animation", "is", "true", "the", "new", "sun", "position", "is", "calculated", "w", ".", "r", ".", "t", "delta_time" ]
def update(self, delta_time=0): """ If the weather animation is true, the new sun position is calculated w.r.t delta_time Nothing happens if animation or datetime are None. Args: delta_time (float): Time passed since self.datetime [seconds]. """ if not self.animation or not self.datetime: return self.datetime = self.datetime + datetime.timedelta(seconds=delta_time) self._observer_location.date = self.datetime self._sun.compute(self._observer_location) self.carla_weather.sun_altitude_angle = math.degrees(self._sun.alt) self.carla_weather.sun_azimuth_angle = math.degrees(self._sun.az)
[ "def", "update", "(", "self", ",", "delta_time", "=", "0", ")", ":", "if", "not", "self", ".", "animation", "or", "not", "self", ".", "datetime", ":", "return", "self", ".", "datetime", "=", "self", ".", "datetime", "+", "datetime", ".", "timedelta", ...
https://github.com/carla-simulator/scenario_runner/blob/f4d00d88eda4212a1e119515c96281a4be5c234e/srunner/scenariomanager/weather_sim.py#L71-L88
wistbean/fxxkpython
88e16d79d8dd37236ba6ecd0d0ff11d63143968c
vip/qyxuan/projects/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/util/ssl_.py
python
assert_fingerprint
(cert, fingerprint)
Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons.
Checks if given fingerprint matches the supplied certificate.
[ "Checks", "if", "given", "fingerprint", "matches", "the", "supplied", "certificate", "." ]
def assert_fingerprint(cert, fingerprint): """ Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. """ fingerprint = fingerprint.replace(':', '').lower() digest_length = len(fingerprint) hashfunc = HASHFUNC_MAP.get(digest_length) if not hashfunc: raise SSLError( 'Fingerprint of invalid length: {0}'.format(fingerprint)) # We need encode() here for py32; works on py2 and p33. fingerprint_bytes = unhexlify(fingerprint.encode()) cert_digest = hashfunc(cert).digest() if not _const_compare_digest(cert_digest, fingerprint_bytes): raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".' .format(fingerprint, hexlify(cert_digest)))
[ "def", "assert_fingerprint", "(", "cert", ",", "fingerprint", ")", ":", "fingerprint", "=", "fingerprint", ".", "replace", "(", "':'", ",", "''", ")", ".", "lower", "(", ")", "digest_length", "=", "len", "(", "fingerprint", ")", "hashfunc", "=", "HASHFUNC_...
https://github.com/wistbean/fxxkpython/blob/88e16d79d8dd37236ba6ecd0d0ff11d63143968c/vip/qyxuan/projects/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/util/ssl_.py#L163-L187
jgagneastro/coffeegrindsize
22661ebd21831dba4cf32bfc6ba59fe3d49f879c
App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/arrays/base.py
python
ExtensionArray.dropna
(self)
return self[~self.isna()]
Return ExtensionArray without NA values Returns ------- valid : ExtensionArray
Return ExtensionArray without NA values
[ "Return", "ExtensionArray", "without", "NA", "values" ]
def dropna(self): """ Return ExtensionArray without NA values Returns ------- valid : ExtensionArray """ return self[~self.isna()]
[ "def", "dropna", "(", "self", ")", ":", "return", "self", "[", "~", "self", ".", "isna", "(", ")", "]" ]
https://github.com/jgagneastro/coffeegrindsize/blob/22661ebd21831dba4cf32bfc6ba59fe3d49f879c/App/dist/coffeegrindsize.app/Contents/Resources/lib/python3.7/pandas/core/arrays/base.py#L473-L481
magenta/magenta
be6558f1a06984faff6d6949234f5fe9ad0ffdb5
magenta/models/rl_tuner/note_rnn_loader.py
python
NoteRNNLoader.build_graph
(self)
Constructs the portion of the graph that belongs to this model.
Constructs the portion of the graph that belongs to this model.
[ "Constructs", "the", "portion", "of", "the", "graph", "that", "belongs", "to", "this", "model", "." ]
def build_graph(self): """Constructs the portion of the graph that belongs to this model.""" tf.logging.info('Initializing melody RNN graph for scope %s', self.scope) with self.graph.as_default(): with tf.device(lambda op: ''): with tf.variable_scope(self.scope): # Make an LSTM cell with the number and size of layers specified in # hparams. if self.note_rnn_type == 'basic_rnn': self.cell = events_rnn_graph.make_rnn_cell( self.hparams.rnn_layer_sizes) else: self.cell = rl_tuner_ops.make_rnn_cell(self.hparams.rnn_layer_sizes) # Shape of melody_sequence is batch size, melody length, number of # output note actions. self.melody_sequence = tf.placeholder(tf.float32, [None, None, self.hparams.one_hot_length], name='melody_sequence') self.lengths = tf.placeholder(tf.int32, [None], name='lengths') self.initial_state = tf.placeholder(tf.float32, [None, self.cell.state_size], name='initial_state') if self.training_file_list is not None: # Set up a tf queue to read melodies from the training data tfrecord (self.train_sequence, self.train_labels, self.train_lengths) = sequence_example_lib.get_padded_batch( self.training_file_list, self.hparams.batch_size, self.hparams.one_hot_length) # Closure function is used so that this part of the graph can be # re-run in multiple places, such as __call__. def run_network_on_melody(m_seq, lens, initial_state, swap_memory=True, parallel_iterations=1): """Internal function that defines the RNN network structure. Args: m_seq: A batch of melody sequences of one-hot notes. lens: Lengths of the melody_sequences. initial_state: Vector representing the initial state of the RNN. swap_memory: Uses more memory and is faster. parallel_iterations: Argument to tf.nn.dynamic_rnn. Returns: Output of network (either softmax or logits) and RNN state. """ outputs, final_state = tf.nn.dynamic_rnn( self.cell, m_seq, sequence_length=lens, initial_state=initial_state, swap_memory=swap_memory, parallel_iterations=parallel_iterations) outputs_flat = tf.reshape(outputs, [-1, self.hparams.rnn_layer_sizes[-1]]) if self.note_rnn_type == 'basic_rnn': linear_layer = tf_slim.layers.linear else: linear_layer = tf_slim.layers.legacy_linear logits_flat = linear_layer( outputs_flat, self.hparams.one_hot_length) return logits_flat, final_state (self.logits, self.state_tensor) = run_network_on_melody( self.melody_sequence, self.lengths, self.initial_state) self.softmax = tf.nn.softmax(self.logits) self.run_network_on_melody = run_network_on_melody if self.training_file_list is not None: # Does not recreate the model architecture but rather uses it to feed # data from the training queue through the model. with tf.variable_scope(self.scope, reuse=True): zero_state = self.cell.zero_state( batch_size=self.hparams.batch_size, dtype=tf.float32) (self.train_logits, self.train_state) = run_network_on_melody( self.train_sequence, self.train_lengths, zero_state) self.train_softmax = tf.nn.softmax(self.train_logits)
[ "def", "build_graph", "(", "self", ")", ":", "tf", ".", "logging", ".", "info", "(", "'Initializing melody RNN graph for scope %s'", ",", "self", ".", "scope", ")", "with", "self", ".", "graph", ".", "as_default", "(", ")", ":", "with", "tf", ".", "device"...
https://github.com/magenta/magenta/blob/be6558f1a06984faff6d6949234f5fe9ad0ffdb5/magenta/models/rl_tuner/note_rnn_loader.py#L175-L260
hatRiot/zarp
2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad
src/lib/scapy/fields.py
python
Emph.__eq__
(self, other)
return self.fld == other
[]
def __eq__(self, other): return self.fld == other
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "fld", "==", "other" ]
https://github.com/hatRiot/zarp/blob/2e772350a01c2aeed3f4da9685cd0cc5d6b3ecad/src/lib/scapy/fields.py#L108-L109
hubblestack/hubble
763142474edcecdec5fd25591dc29c3536e8f969
hubblestack/modules/mount.py
python
remount
(name, device, mkmnt=False, fstype="", opts="defaults", user=None)
return mount(name, device, mkmnt, fstype, opts, user=user)
Attempt to remount a device, if the device is not already mounted, mount is called CLI Example: .. code-block:: bash salt '*' mount.remount /mnt/foo /dev/sdz1 True
Attempt to remount a device, if the device is not already mounted, mount is called
[ "Attempt", "to", "remount", "a", "device", "if", "the", "device", "is", "not", "already", "mounted", "mount", "is", "called" ]
def remount(name, device, mkmnt=False, fstype="", opts="defaults", user=None): """ Attempt to remount a device, if the device is not already mounted, mount is called CLI Example: .. code-block:: bash salt '*' mount.remount /mnt/foo /dev/sdz1 True """ force_mount = False if __grains__["os"] in ["MacOS", "Darwin"]: if opts == "defaults": opts = "noowners" if fstype == "smbfs": force_mount = True if "AIX" in __grains__["os"]: if opts == "defaults": opts = [] if isinstance(opts, str): opts = opts.split(",") mnts = active() if name in mnts: # The mount point is mounted, attempt to remount it with the given data if "remount" not in opts and __grains__["os"] not in [ "OpenBSD", "MacOS", "Darwin", ]: opts.append("remount") if force_mount: # We need to force the mount but first we should unmount umount(name, device, user=user) lopts = ",".join(opts) args = "-o {0}".format(lopts) if fstype: # use of fstype on AIX differs from typical Linux use of # -t functionality AIX uses -v vfsname, -t fstype mounts # all with fstype in /etc/filesystems if "AIX" in __grains__["os"]: args += " -v {0}".format(fstype) elif "solaris" in __grains__["os"].lower(): args += " -F {0}".format(fstype) else: args += " -t {0}".format(fstype) if __grains__["os"] not in ["OpenBSD", "MacOS", "Darwin"] or force_mount: cmd = "mount {0} {1} {2} ".format(args, device, name) else: cmd = "mount -u {0} {1} {2} ".format(args, device, name) out = __mods__["cmd.run_all"](cmd, runas=user, python_shell=False) if out["retcode"]: return out["stderr"] return True # Mount a filesystem that isn't already return mount(name, device, mkmnt, fstype, opts, user=user)
[ "def", "remount", "(", "name", ",", "device", ",", "mkmnt", "=", "False", ",", "fstype", "=", "\"\"", ",", "opts", "=", "\"defaults\"", ",", "user", "=", "None", ")", ":", "force_mount", "=", "False", "if", "__grains__", "[", "\"os\"", "]", "in", "["...
https://github.com/hubblestack/hubble/blob/763142474edcecdec5fd25591dc29c3536e8f969/hubblestack/modules/mount.py#L1297-L1356
gramps-project/gramps
04d4651a43eb210192f40a9f8c2bad8ee8fa3753
gramps/plugins/lib/libgedcom.py
python
GedcomParser.__event_note
(self, line, state)
@param line: The current line in GedLine format @type line: GedLine @param state: The current state @type state: CurrentState
[]
def __event_note(self, line, state): """ @param line: The current line in GedLine format @type line: GedLine @param state: The current state @type state: CurrentState """ self.__parse_note(line, state.event, state)
[ "def", "__event_note", "(", "self", ",", "line", ",", "state", ")", ":", "self", ".", "__parse_note", "(", "line", ",", "state", ".", "event", ",", "state", ")" ]
https://github.com/gramps-project/gramps/blob/04d4651a43eb210192f40a9f8c2bad8ee8fa3753/gramps/plugins/lib/libgedcom.py#L5862-L5869
deluge-torrent/deluge
2316088f5c0dd6cb044d9d4832fa7d56dcc79cdc
deluge/ui/gtk3/mainwindow.py
python
MainWindow.quit
(self, shutdown=False, restart=False)
Quits the GtkUI application. Args: shutdown (bool): Whether or not to shutdown the daemon as well. restart (bool): Whether or not to restart the application after closing.
Quits the GtkUI application.
[ "Quits", "the", "GtkUI", "application", "." ]
def quit(self, shutdown=False, restart=False): # noqa: A003 python builtin """Quits the GtkUI application. Args: shutdown (bool): Whether or not to shutdown the daemon as well. restart (bool): Whether or not to restart the application after closing. """ def quit_gtkui(): def stop_gtk_reactor(result=None): self.restart = restart try: reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close') except ReactorNotRunning: log.debug('Attempted to stop the reactor but it is not running...') if shutdown: client.daemon.shutdown().addCallback(stop_gtk_reactor) elif not client.is_standalone() and client.connected(): client.disconnect().addCallback(stop_gtk_reactor) else: stop_gtk_reactor() if self.config['lock_tray'] and not self.visible(): dialog = PasswordDialog(_('Enter your password to Quit Deluge...')) def on_dialog_response(response_id): if response_id == Gtk.ResponseType.OK: if ( self.config['tray_password'] == sha(decode_bytes(dialog.get_password()).encode()).hexdigest() ): quit_gtkui() dialog.run().addCallback(on_dialog_response) else: quit_gtkui()
[ "def", "quit", "(", "self", ",", "shutdown", "=", "False", ",", "restart", "=", "False", ")", ":", "# noqa: A003 python builtin", "def", "quit_gtkui", "(", ")", ":", "def", "stop_gtk_reactor", "(", "result", "=", "None", ")", ":", "self", ".", "restart", ...
https://github.com/deluge-torrent/deluge/blob/2316088f5c0dd6cb044d9d4832fa7d56dcc79cdc/deluge/ui/gtk3/mainwindow.py#L228-L265
TurboGears/tg2
f40a82d016d70ce560002593b4bb8f83b57f87b3
tg/util/decorators.py
python
no_warn
(f, *args, **kwargs)
return update_wrapper(_f, f)
Decorator that suppresses warnings inside the decorated function
Decorator that suppresses warnings inside the decorated function
[ "Decorator", "that", "suppresses", "warnings", "inside", "the", "decorated", "function" ]
def no_warn(f, *args, **kwargs): """Decorator that suppresses warnings inside the decorated function""" def _f(*args, **kwargs): warnings.simplefilter("ignore") f(*args, **kwargs) warnings.resetwarnings() return update_wrapper(_f, f)
[ "def", "no_warn", "(", "f", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "_f", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "simplefilter", "(", "\"ignore\"", ")", "f", "(", "*", "args", ",", "*", "*", ...
https://github.com/TurboGears/tg2/blob/f40a82d016d70ce560002593b4bb8f83b57f87b3/tg/util/decorators.py#L5-L11
numba/llvmlite
aeddf447d4befc336b26bde8c46042553a13cf75
llvmlite/binding/executionengine.py
python
create_mcjit_compiler
(module, target_machine)
return ExecutionEngine(engine, module=module)
Create a MCJIT ExecutionEngine from the given *module* and *target_machine*.
Create a MCJIT ExecutionEngine from the given *module* and *target_machine*.
[ "Create", "a", "MCJIT", "ExecutionEngine", "from", "the", "given", "*", "module", "*", "and", "*", "target_machine", "*", "." ]
def create_mcjit_compiler(module, target_machine): """ Create a MCJIT ExecutionEngine from the given *module* and *target_machine*. """ with ffi.OutputString() as outerr: engine = ffi.lib.LLVMPY_CreateMCJITCompiler( module, target_machine, outerr) if not engine: raise RuntimeError(str(outerr)) target_machine._owned = True return ExecutionEngine(engine, module=module)
[ "def", "create_mcjit_compiler", "(", "module", ",", "target_machine", ")", ":", "with", "ffi", ".", "OutputString", "(", ")", "as", "outerr", ":", "engine", "=", "ffi", ".", "lib", ".", "LLVMPY_CreateMCJITCompiler", "(", "module", ",", "target_machine", ",", ...
https://github.com/numba/llvmlite/blob/aeddf447d4befc336b26bde8c46042553a13cf75/llvmlite/binding/executionengine.py#L12-L24
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_process.py
python
OpenShiftCLI._replace
(self, fname, force=False)
return self.openshift_cmd(cmd)
replace the current object with oc replace
replace the current object with oc replace
[ "replace", "the", "current", "object", "with", "oc", "replace" ]
def _replace(self, fname, force=False): '''replace the current object with oc replace''' # We are removing the 'resourceVersion' to handle # a race condition when modifying oc objects yed = Yedit(fname) results = yed.delete('metadata.resourceVersion') if results[0]: yed.write() cmd = ['replace', '-f', fname] if force: cmd.append('--force') return self.openshift_cmd(cmd)
[ "def", "_replace", "(", "self", ",", "fname", ",", "force", "=", "False", ")", ":", "# We are removing the 'resourceVersion' to handle", "# a race condition when modifying oc objects", "yed", "=", "Yedit", "(", "fname", ")", "results", "=", "yed", ".", "delete", "("...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/library/oc_process.py#L933-L945
saghul/evergreen
22f22f45892f397c23c3e09e6ea1ad4c00b3add8
evergreen/locks.py
python
Barrier.n_waiting
(self)
return 0
Return the number of threads currently waiting at the barrier.
Return the number of threads currently waiting at the barrier.
[ "Return", "the", "number", "of", "threads", "currently", "waiting", "at", "the", "barrier", "." ]
def n_waiting(self): """Return the number of threads currently waiting at the barrier.""" # We don't need synchronization here since this is an ephemeral result # anyway. It returns the correct value in the steady state. if self._state == 0: return self._count return 0
[ "def", "n_waiting", "(", "self", ")", ":", "# We don't need synchronization here since this is an ephemeral result", "# anyway. It returns the correct value in the steady state.", "if", "self", ".", "_state", "==", "0", ":", "return", "self", ".", "_count", "return", "0" ]
https://github.com/saghul/evergreen/blob/22f22f45892f397c23c3e09e6ea1ad4c00b3add8/evergreen/locks.py#L366-L372
jupyter/kernel_gateway
440fef1cd29c829e2141bb4c76ed5f9572b428e1
kernel_gateway/services/kernels/pool.py
python
ManagedKernelPool.release
(self, kernel_id)
Puts a kernel back into the pool of kernels available to handle requests. Parameters ---------- kernel_id : str Kernel to return to the pool
Puts a kernel back into the pool of kernels available to handle requests.
[ "Puts", "a", "kernel", "back", "into", "the", "pool", "of", "kernels", "available", "to", "handle", "requests", "." ]
def release(self, kernel_id): """Puts a kernel back into the pool of kernels available to handle requests. Parameters ---------- kernel_id : str Kernel to return to the pool """ self.kernel_pool.append(kernel_id) self.kernel_semaphore.release()
[ "def", "release", "(", "self", ",", "kernel_id", ")", ":", "self", ".", "kernel_pool", ".", "append", "(", "kernel_id", ")", "self", ".", "kernel_semaphore", ".", "release", "(", ")" ]
https://github.com/jupyter/kernel_gateway/blob/440fef1cd29c829e2141bb4c76ed5f9572b428e1/kernel_gateway/services/kernels/pool.py#L100-L110
python/cpython
e13cdca0f5224ec4e23bdd04bb3120506964bc8b
Lib/idlelib/colorizer.py
python
ColorDelegator.recolorize_main
(self)
Evaluate text and apply colorizing tags.
Evaluate text and apply colorizing tags.
[ "Evaluate", "text", "and", "apply", "colorizing", "tags", "." ]
def recolorize_main(self): "Evaluate text and apply colorizing tags." next = "1.0" while todo_tag_range := self.tag_nextrange("TODO", next): self.tag_remove("SYNC", todo_tag_range[0], todo_tag_range[1]) sync_tag_range = self.tag_prevrange("SYNC", todo_tag_range[0]) head = sync_tag_range[1] if sync_tag_range else "1.0" chars = "" next = head lines_to_get = 1 ok = False while not ok: mark = next next = self.index(mark + "+%d lines linestart" % lines_to_get) lines_to_get = min(lines_to_get * 2, 100) ok = "SYNC" in self.tag_names(next + "-1c") line = self.get(mark, next) ##print head, "get", mark, next, "->", repr(line) if not line: return for tag in self.tagdefs: self.tag_remove(tag, mark, next) chars += line self._add_tags_in_section(chars, head) if "SYNC" in self.tag_names(next + "-1c"): head = next chars = "" else: ok = False if not ok: # We're in an inconsistent state, and the call to # update may tell us to stop. It may also change # the correct value for "next" (since this is a # line.col string, not a true mark). So leave a # crumb telling the next invocation to resume here # in case update tells us to leave. self.tag_add("TODO", next) self.update() if self.stop_colorizing: if DEBUG: print("colorizing stopped") return
[ "def", "recolorize_main", "(", "self", ")", ":", "next", "=", "\"1.0\"", "while", "todo_tag_range", ":=", "self", ".", "tag_nextrange", "(", "\"TODO\"", ",", "next", ")", ":", "self", ".", "tag_remove", "(", "\"SYNC\"", ",", "todo_tag_range", "[", "0", "]"...
https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/idlelib/colorizer.py#L274-L316
PowerScript/KatanaFramework
0f6ad90a88de865d58ec26941cb4460501e75496
lib/scapy/scapy/contrib/gsm_um.py
python
partialRelease
()
return packet
PARTIAL RELEASE Section 9.1.26
PARTIAL RELEASE Section 9.1.26
[ "PARTIAL", "RELEASE", "Section", "9", ".", "1", ".", "26" ]
def partialRelease(): """PARTIAL RELEASE Section 9.1.26""" a = TpPd(pd=0x6) b = MessageType(mesType=0xa) # 00001010 c = ChannelDescription() packet = a / b / c return packet
[ "def", "partialRelease", "(", ")", ":", "a", "=", "TpPd", "(", "pd", "=", "0x6", ")", "b", "=", "MessageType", "(", "mesType", "=", "0xa", ")", "# 00001010", "c", "=", "ChannelDescription", "(", ")", "packet", "=", "a", "/", "b", "/", "c", "return"...
https://github.com/PowerScript/KatanaFramework/blob/0f6ad90a88de865d58ec26941cb4460501e75496/lib/scapy/scapy/contrib/gsm_um.py#L914-L920
sfepy/sfepy
02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25
examples/diffusion/laplace_iga_interactive.py
python
create_patch
(R1, R2, C1, C2, order=2, viewpatch=False)
Create a single 2d NURBS-patch of the area between two coplanar nested circles using igakit. Parameters ---------- R1 : float Radius of the inner circle. R2 : float Radius of the outer circle. C1 : list of two floats Coordinates of the center of the inner circle given as [x1, y1]. C2 : list of two floats Coordinates of the center of the outer circle given as [x2, y2]. order : int, optional Degree of the NURBS basis functions. The default is 2. viewpatch : bool, optional When set to True, display the NURBS patch. The default is False. Returns ------- None.
Create a single 2d NURBS-patch of the area between two coplanar nested circles using igakit.
[ "Create", "a", "single", "2d", "NURBS", "-", "patch", "of", "the", "area", "between", "two", "coplanar", "nested", "circles", "using", "igakit", "." ]
def create_patch(R1, R2, C1, C2, order=2, viewpatch=False): """ Create a single 2d NURBS-patch of the area between two coplanar nested circles using igakit. Parameters ---------- R1 : float Radius of the inner circle. R2 : float Radius of the outer circle. C1 : list of two floats Coordinates of the center of the inner circle given as [x1, y1]. C2 : list of two floats Coordinates of the center of the outer circle given as [x2, y2]. order : int, optional Degree of the NURBS basis functions. The default is 2. viewpatch : bool, optional When set to True, display the NURBS patch. The default is False. Returns ------- None. """ from sfepy.discrete.iga.domain_generators import create_from_igakit import sfepy.discrete.iga.io as io from igakit.cad import circle, ruled from igakit.plot import plt as iplt from numpy import pi # Assert the inner circle is inside the outer one inter_centers = nm.sqrt((C2[0]-C1[0])**2 + (C2[1]-C1[1])**2) assert R2>R1, "Outer circle should have a larger radius than the inner one" assert inter_centers<R2-R1, "Circles are not nested" # Geometry Creation centers_direction = [C2[0]-C1[0], C2[1]-C1[1]] if centers_direction[0]==0 and centers_direction[1]==0: start_angle = 0.0 else: start_angle = nm.arctan2(centers_direction[1], centers_direction[0]) c1 = circle(radius=R1, center=C1, angle=(start_angle, start_angle + 2*pi)) c2 = circle(radius=R2, center=C2, angle=(start_angle, start_angle + 2*pi)) srf = ruled(c1,c2).transpose() # make the radial direction first # Refinement insert_U = insert_uniformly(srf.knots[0], 6) insert_V = insert_uniformly(srf.knots[1], 6) srf.refine(0, insert_U).refine(1, insert_V) # Setting the NURBS-surface degree srf.elevate(0, order-srf.degree[0] if order-srf.degree[0] > 0 else 0) srf.elevate(1, order-srf.degree[1] if order-srf.degree[1] > 0 else 0) # Sfepy .iga file creation nurbs, bmesh, regions = create_from_igakit(srf, verbose=True) # Save .iga file in sfepy/meshes/iga filename_domain = data_dir + '/meshes/iga/concentric_circles.iga' io.write_iga_data(filename_domain, None, nurbs.knots, nurbs.degrees, nurbs.cps, nurbs.weights, nurbs.cs, nurbs.conn, bmesh.cps, bmesh.weights, bmesh.conn, regions) if viewpatch: try: iplt.use('mayavi') iplt.figure() iplt.plot(srf) iplt.show() except ImportError: iplt.use('matplotlib') iplt.figure() iplt.plot(srf) iplt.show()
[ "def", "create_patch", "(", "R1", ",", "R2", ",", "C1", ",", "C2", ",", "order", "=", "2", ",", "viewpatch", "=", "False", ")", ":", "from", "sfepy", ".", "discrete", ".", "iga", ".", "domain_generators", "import", "create_from_igakit", "import", "sfepy"...
https://github.com/sfepy/sfepy/blob/02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25/examples/diffusion/laplace_iga_interactive.py#L58-L133