repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
blockadeio/analyst_toolbench
blockade/cli/aws_serverless.py
https://github.com/blockadeio/analyst_toolbench/blob/159b6f8cf8a91c5ff050f1579636ea90ab269863/blockade/cli/aws_serverless.py#L389-L461
def generate_handler(): """Create the Blockade user and give them permissions.""" logger.debug("[#] Setting up user, group and permissions") client = boto3.client("iam", region_name=PRIMARY_REGION) # Create the user try: response = client.create_user( UserName=BLOCKADE_USER ...
[ "def", "generate_handler", "(", ")", ":", "logger", ".", "debug", "(", "\"[#] Setting up user, group and permissions\"", ")", "client", "=", "boto3", ".", "client", "(", "\"iam\"", ",", "region_name", "=", "PRIMARY_REGION", ")", "# Create the user", "try", ":", "r...
Create the Blockade user and give them permissions.
[ "Create", "the", "Blockade", "user", "and", "give", "them", "permissions", "." ]
python
train
42.506849
cloudera/impyla
impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py
https://github.com/cloudera/impyla/blob/547fa2ba3b6151e2a98b3544301471a643212dc3/impala/_thrift_gen/hive_metastore/ThriftHiveMetastore.py#L1712-L1719
def get_schema(self, db_name, table_name): """ Parameters: - db_name - table_name """ self.send_get_schema(db_name, table_name) return self.recv_get_schema()
[ "def", "get_schema", "(", "self", ",", "db_name", ",", "table_name", ")", ":", "self", ".", "send_get_schema", "(", "db_name", ",", "table_name", ")", "return", "self", ".", "recv_get_schema", "(", ")" ]
Parameters: - db_name - table_name
[ "Parameters", ":", "-", "db_name", "-", "table_name" ]
python
train
22.5
mitsei/dlkit
dlkit/json_/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/managers.py#L895-L910
def get_composition_search_session(self): """Gets a composition search session. return: (osid.repository.CompositionSearchSession) - a ``CompositionSearchSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_composition_search(...
[ "def", "get_composition_search_session", "(", "self", ")", ":", "if", "not", "self", ".", "supports_composition_search", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ".", "CompositionSearchSessi...
Gets a composition search session. return: (osid.repository.CompositionSearchSession) - a ``CompositionSearchSession`` raise: OperationFailed - unable to complete request raise: Unimplemented - ``supports_composition_search()`` is ``false`` *compliance:...
[ "Gets", "a", "composition", "search", "session", "." ]
python
train
42.125
CenturyLinkCloud/clc-python-sdk
src/clc/APIv2/network.py
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/network.py#L102-L116
def Create(alias=None,location=None,session=None): """Claims a new network within a given account. https://www.ctl.io/api-docs/v2/#networks-claim-network Returns operation id and link to check status """ if not alias: alias = clc.v2.Account.GetAlias(session=session) if not location: location = clc.v2.A...
[ "def", "Create", "(", "alias", "=", "None", ",", "location", "=", "None", ",", "session", "=", "None", ")", ":", "if", "not", "alias", ":", "alias", "=", "clc", ".", "v2", ".", "Account", ".", "GetAlias", "(", "session", "=", "session", ")", "if", ...
Claims a new network within a given account. https://www.ctl.io/api-docs/v2/#networks-claim-network Returns operation id and link to check status
[ "Claims", "a", "new", "network", "within", "a", "given", "account", "." ]
python
train
33.866667
gersolar/stations
stations/models.py
https://github.com/gersolar/stations/blob/b5cf99f1906282d88738b90c9ce44caa8d613e1b/stations/models.py#L143-L150
def go_inactive(self, dt=datetime.utcnow().replace(tzinfo=pytz.UTC)): """Make the configuration object inactive. Keyword arguments: dt -- datetime of the moment when the configuration go inactive """ self.end = dt self.save()
[ "def", "go_inactive", "(", "self", ",", "dt", "=", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "UTC", ")", ")", ":", "self", ".", "end", "=", "dt", "self", ".", "save", "(", ")" ]
Make the configuration object inactive. Keyword arguments: dt -- datetime of the moment when the configuration go inactive
[ "Make", "the", "configuration", "object", "inactive", "." ]
python
train
29.25
log2timeline/plaso
plaso/parsers/winreg_plugins/programscache.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/programscache.py#L39-L160
def _ParseValueData(self, parser_mediator, registry_key, registry_value): """Extracts event objects from a Explorer ProgramsCache value data. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. registry_key (dfwinr...
[ "def", "_ParseValueData", "(", "self", ",", "parser_mediator", ",", "registry_key", ",", "registry_value", ")", ":", "value_data", "=", "registry_value", ".", "data", "value_data_size", "=", "len", "(", "value_data", ")", "if", "value_data_size", "<", "4", ":", ...
Extracts event objects from a Explorer ProgramsCache value data. Args: parser_mediator (ParserMediator): mediates interactions between parsers and other components, such as storage and dfvfs. registry_key (dfwinreg.WinRegistryKey): Windows Registry key. registry_value (dfwinreg.WinRegis...
[ "Extracts", "event", "objects", "from", "a", "Explorer", "ProgramsCache", "value", "data", "." ]
python
train
36
Erotemic/utool
utool/util_cache.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_cache.py#L678-L691
def cachestr_repr(val): """ Representation of an object as a cache string. """ try: memview = memoryview(val) return memview.tobytes() except Exception: try: return to_json(val) except Exception: # SUPER HACK if repr(val.__class__) ...
[ "def", "cachestr_repr", "(", "val", ")", ":", "try", ":", "memview", "=", "memoryview", "(", "val", ")", "return", "memview", ".", "tobytes", "(", ")", "except", "Exception", ":", "try", ":", "return", "to_json", "(", "val", ")", "except", "Exception", ...
Representation of an object as a cache string.
[ "Representation", "of", "an", "object", "as", "a", "cache", "string", "." ]
python
train
28.928571
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py#L1078-L1143
def init_user_ns(self): """Initialize all user-visible namespaces to their minimum defaults. Certain history lists are also initialized here, as they effectively act as user namespaces. Notes ----- All data structures here are only filled in, they are NOT reset by this ...
[ "def", "init_user_ns", "(", "self", ")", ":", "# This function works in two parts: first we put a few things in", "# user_ns, and we sync that contents into user_ns_hidden so that these", "# initial variables aren't shown by %who. After the sync, we add the", "# rest of what we *do* want the user...
Initialize all user-visible namespaces to their minimum defaults. Certain history lists are also initialized here, as they effectively act as user namespaces. Notes ----- All data structures here are only filled in, they are NOT reset by this method. If they were not e...
[ "Initialize", "all", "user", "-", "visible", "namespaces", "to", "their", "minimum", "defaults", "." ]
python
test
41.939394
saltstack/salt
salt/states/keystone_endpoint.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone_endpoint.py#L146-L184
def absent(name, service_name, auth=None, **kwargs): ''' Ensure an endpoint does not exists name Interface name url URL of the endpoint service_name Service name or ID region The region name to assign the endpoint ''' ret = {'name': name, 'c...
[ "def", "absent", "(", "name", ",", "service_name", ",", "auth", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}...
Ensure an endpoint does not exists name Interface name url URL of the endpoint service_name Service name or ID region The region name to assign the endpoint
[ "Ensure", "an", "endpoint", "does", "not", "exists" ]
python
train
22.871795
frmdstryr/enamlx
enamlx/qt/qt_graphics_view.py
https://github.com/frmdstryr/enamlx/blob/9582e29c88dc0c0340f912b49168b7307a47ed4f/enamlx/qt/qt_graphics_view.py#L337-L348
def mouseMoveEvent(self, event): """ Handle the mouse move event for a drag operation. """ #if event.buttons() & Qt.LeftButton and self._drag_origin is not None: #dist = (event.pos() - self._drag_origin).manhattanLength() #if dist >= QApplication.startDragDistance(): ...
[ "def", "mouseMoveEvent", "(", "self", ",", "event", ")", ":", "#if event.buttons() & Qt.LeftButton and self._drag_origin is not None:", "#dist = (event.pos() - self._drag_origin).manhattanLength()", "#if dist >= QApplication.startDragDistance():", "#self.do_drag(event.widget())", "#self._dra...
Handle the mouse move event for a drag operation.
[ "Handle", "the", "mouse", "move", "event", "for", "a", "drag", "operation", "." ]
python
train
42.75
robotools/fontParts
Lib/fontParts/base/glyph.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/glyph.py#L932-L937
def _get_components(self): """ Subclasses may override this method. """ return tuple([self._getitem__components(i) for i in range(self._len__components())])
[ "def", "_get_components", "(", "self", ")", ":", "return", "tuple", "(", "[", "self", ".", "_getitem__components", "(", "i", ")", "for", "i", "in", "range", "(", "self", ".", "_len__components", "(", ")", ")", "]", ")" ]
Subclasses may override this method.
[ "Subclasses", "may", "override", "this", "method", "." ]
python
train
34
Aluriak/bubble-tools
bubbletools/_bubble.py
https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/_bubble.py#L16-L36
def lines_from_tree(tree, nodes_and_set:bool=False) -> iter: """Yield lines of bubble describing given BubbleTree""" NODE = 'NODE\t{}' INCL = 'IN\t{}\t{}' EDGE = 'EDGE\t{}\t{}\t1.0' SET = 'SET\t{}' if nodes_and_set: for node in tree.nodes(): yield NODE.format(node) ...
[ "def", "lines_from_tree", "(", "tree", ",", "nodes_and_set", ":", "bool", "=", "False", ")", "->", "iter", ":", "NODE", "=", "'NODE\\t{}'", "INCL", "=", "'IN\\t{}\\t{}'", "EDGE", "=", "'EDGE\\t{}\\t{}\\t1.0'", "SET", "=", "'SET\\t{}'", "if", "nodes_and_set", "...
Yield lines of bubble describing given BubbleTree
[ "Yield", "lines", "of", "bubble", "describing", "given", "BubbleTree" ]
python
train
29.190476
pyviz/holoviews
holoviews/ipython/widgets.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/ipython/widgets.py#L209-L226
def progress(iterator, enum=False, length=None): """ A helper utility to display a progress bar when iterating over a collection of a fixed length or a generator (with a declared length). If enum=True, then equivalent to enumerate with a progress bar. """ progress = ProgressBar() length...
[ "def", "progress", "(", "iterator", ",", "enum", "=", "False", ",", "length", "=", "None", ")", ":", "progress", "=", "ProgressBar", "(", ")", "length", "=", "len", "(", "iterator", ")", "if", "length", "is", "None", "else", "length", "gen", "=", "en...
A helper utility to display a progress bar when iterating over a collection of a fixed length or a generator (with a declared length). If enum=True, then equivalent to enumerate with a progress bar.
[ "A", "helper", "utility", "to", "display", "a", "progress", "bar", "when", "iterating", "over", "a", "collection", "of", "a", "fixed", "length", "or", "a", "generator", "(", "with", "a", "declared", "length", ")", "." ]
python
train
29.944444
inveniosoftware/invenio-accounts
invenio_accounts/hash.py
https://github.com/inveniosoftware/invenio-accounts/blob/b0d2f0739b00dbefea22ca15d7d374a1b4a63aec/invenio_accounts/hash.py#L82-L94
def mysql_aes_decrypt(encrypted_val, key): """Mysql AES decrypt value with secret key. :param encrypted_val: Encrypted value. :param key: The AES key. :returns: The AES value decrypted. """ assert isinstance(encrypted_val, binary_type) \ or isinstance(encrypted_val, text_type) asser...
[ "def", "mysql_aes_decrypt", "(", "encrypted_val", ",", "key", ")", ":", "assert", "isinstance", "(", "encrypted_val", ",", "binary_type", ")", "or", "isinstance", "(", "encrypted_val", ",", "text_type", ")", "assert", "isinstance", "(", "key", ",", "binary_type"...
Mysql AES decrypt value with secret key. :param encrypted_val: Encrypted value. :param key: The AES key. :returns: The AES value decrypted.
[ "Mysql", "AES", "decrypt", "value", "with", "secret", "key", "." ]
python
train
41.615385
codelv/enaml-web
web/impl/lxml_toolkit_object.py
https://github.com/codelv/enaml-web/blob/88f1131a7b3ba9e83467b4f44bc3bab6f0de7559/web/impl/lxml_toolkit_object.py#L34-L42
def create_widget(self): """ Create the toolkit widget for the proxy object. This method is called during the top-down pass, just before the 'init_widget()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute. """ self....
[ "def", "create_widget", "(", "self", ")", ":", "self", ".", "widget", "=", "SubElement", "(", "self", ".", "parent_widget", "(", ")", ",", "self", ".", "declaration", ".", "tag", ")" ]
Create the toolkit widget for the proxy object. This method is called during the top-down pass, just before the 'init_widget()' method is called. This method should create the toolkit widget and assign it to the 'widget' attribute.
[ "Create", "the", "toolkit", "widget", "for", "the", "proxy", "object", "." ]
python
test
41.666667
meraki-analytics/datapipelines-python
datapipelines/pipelines.py
https://github.com/meraki-analytics/datapipelines-python/blob/dc38d7976a012039a15d67cd8b07ae77eb1e4a4c/datapipelines/pipelines.py#L170-L199
def get(self, query: Mapping[str, Any], context: PipelineContext = None) -> T: """Gets a query from the data source. 1) Extracts the query from the data source. 2) Inserts the result into any data sinks. 3) Transforms the result into the requested type if it wasn't already. 4) I...
[ "def", "get", "(", "self", ",", "query", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "context", ":", "PipelineContext", "=", "None", ")", "->", "T", ":", "result", "=", "self", ".", "_source", ".", "get", "(", "self", ".", "_source_type", ","...
Gets a query from the data source. 1) Extracts the query from the data source. 2) Inserts the result into any data sinks. 3) Transforms the result into the requested type if it wasn't already. 4) Inserts the transformed result into any data sinks. Args: query: The q...
[ "Gets", "a", "query", "from", "the", "data", "source", "." ]
python
train
43.333333
mrcagney/gtfstk
gtfstk/feed.py
https://github.com/mrcagney/gtfstk/blob/c91494e6fefc02523889655a0dc92d1c0eee8d03/gtfstk/feed.py#L225-L233
def trips(self, val): """ Update ``self._trips_i`` if ``self.trips`` changes. """ self._trips = val if val is not None and not val.empty: self._trips_i = self._trips.set_index("trip_id") else: self._trips_i = None
[ "def", "trips", "(", "self", ",", "val", ")", ":", "self", ".", "_trips", "=", "val", "if", "val", "is", "not", "None", "and", "not", "val", ".", "empty", ":", "self", ".", "_trips_i", "=", "self", ".", "_trips", ".", "set_index", "(", "\"trip_id\"...
Update ``self._trips_i`` if ``self.trips`` changes.
[ "Update", "self", ".", "_trips_i", "if", "self", ".", "trips", "changes", "." ]
python
train
30.777778
numenta/htmresearch
htmresearch/algorithms/apical_dependent_temporal_memory.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/algorithms/apical_dependent_temporal_memory.py#L888-L933
def compute(self, activeColumns, basalInput, apicalInput=(), basalGrowthCandidates=None, apicalGrowthCandidates=None, learn=True): """ Perform one timestep. Use the basal and apical input to form a set of predictions, then a...
[ "def", "compute", "(", "self", ",", "activeColumns", ",", "basalInput", ",", "apicalInput", "=", "(", ")", ",", "basalGrowthCandidates", "=", "None", ",", "apicalGrowthCandidates", "=", "None", ",", "learn", "=", "True", ")", ":", "activeColumns", "=", "np",...
Perform one timestep. Use the basal and apical input to form a set of predictions, then activate the specified columns, then learn. @param activeColumns (numpy array) List of active columns @param basalInput (numpy array) List of active input bits for the basal dendrite segments @param apical...
[ "Perform", "one", "timestep", ".", "Use", "the", "basal", "and", "apical", "input", "to", "form", "a", "set", "of", "predictions", "then", "activate", "the", "specified", "columns", "then", "learn", "." ]
python
train
36.217391
twisted/axiom
axiom/batch.py
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L956-L967
def call(self, itemMethod): """ Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked. """ item = itemMethod.im_self method = itemMethod.im_func.func_name return self.batchController.getProcess().a...
[ "def", "call", "(", "self", ",", "itemMethod", ")", ":", "item", "=", "itemMethod", ".", "im_self", "method", "=", "itemMethod", ".", "im_func", ".", "func_name", "return", "self", ".", "batchController", ".", "getProcess", "(", ")", ".", "addCallback", "(...
Invoke the given bound item method in the batch process. Return a Deferred which fires when the method has been invoked.
[ "Invoke", "the", "given", "bound", "item", "method", "in", "the", "batch", "process", "." ]
python
train
39.166667
xingjiepan/cylinder_fitting
cylinder_fitting/fitting.py
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L21-L24
def calc_A(Ys): '''Return the matrix A from a list of Y vectors.''' return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3))) for Y in Ys)
[ "def", "calc_A", "(", "Ys", ")", ":", "return", "sum", "(", "np", ".", "dot", "(", "np", ".", "reshape", "(", "Y", ",", "(", "3", ",", "1", ")", ")", ",", "np", ".", "reshape", "(", "Y", ",", "(", "1", ",", "3", ")", ")", ")", "for", "Y...
Return the matrix A from a list of Y vectors.
[ "Return", "the", "matrix", "A", "from", "a", "list", "of", "Y", "vectors", "." ]
python
train
40
trailofbits/manticore
manticore/platforms/evm.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L2434-L2457
def create_contract(self, price=0, address=None, caller=None, balance=0, init=None, gas=None): """ Create a contract account. Sends a transaction to initialize the contract :param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Ye...
[ "def", "create_contract", "(", "self", ",", "price", "=", "0", ",", "address", "=", "None", ",", "caller", "=", "None", ",", "balance", "=", "0", ",", "init", "=", "None", ",", "gas", "=", "None", ")", ":", "expected_address", "=", "self", ".", "cr...
Create a contract account. Sends a transaction to initialize the contract :param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Yellow Paper as possible. :param balance: the initial balance of the account in Wei :param init: the ...
[ "Create", "a", "contract", "account", ".", "Sends", "a", "transaction", "to", "initialize", "the", "contract" ]
python
valid
65.5
assamite/creamas
creamas/core/agent.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/core/agent.py#L251-L257
async def random_connection(self): """Connect to random agent from current :attr:`connections`. :returns: :class:`aiomas.Proxy` object for the connected agent. """ addr = choice(list(self._connections.keys())) return await self.env.connect(addr)
[ "async", "def", "random_connection", "(", "self", ")", ":", "addr", "=", "choice", "(", "list", "(", "self", ".", "_connections", ".", "keys", "(", ")", ")", ")", "return", "await", "self", ".", "env", ".", "connect", "(", "addr", ")" ]
Connect to random agent from current :attr:`connections`. :returns: :class:`aiomas.Proxy` object for the connected agent.
[ "Connect", "to", "random", "agent", "from", "current", ":", "attr", ":", "connections", "." ]
python
train
40
odlgroup/odl
doc/source/guide/code/functional_indepth_example.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/doc/source/guide/code/functional_indepth_example.py#L34-L56
def gradient(self): """The gradient operator.""" # First we store the functional in a variable functional = self # The class corresponding to the gradient operator. class MyGradientOperator(odl.Operator): """Class implementing the gradient operator.""" ...
[ "def", "gradient", "(", "self", ")", ":", "# First we store the functional in a variable", "functional", "=", "self", "# The class corresponding to the gradient operator.", "class", "MyGradientOperator", "(", "odl", ".", "Operator", ")", ":", "\"\"\"Class implementing the gradi...
The gradient operator.
[ "The", "gradient", "operator", "." ]
python
train
32.869565
CityOfZion/neo-python
neo/Core/TX/Transaction.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/TX/Transaction.py#L374-L382
def SystemFee(self): """ Get the system fee. Returns: Fixed8: currently fixed to 0. """ tx_name = TransactionType.ToName(self.Type) return Fixed8.FromDecimal(settings.ALL_FEES.get(tx_name, 0))
[ "def", "SystemFee", "(", "self", ")", ":", "tx_name", "=", "TransactionType", ".", "ToName", "(", "self", ".", "Type", ")", "return", "Fixed8", ".", "FromDecimal", "(", "settings", ".", "ALL_FEES", ".", "get", "(", "tx_name", ",", "0", ")", ")" ]
Get the system fee. Returns: Fixed8: currently fixed to 0.
[ "Get", "the", "system", "fee", "." ]
python
train
27.222222
mbedmicro/pyOCD
pyocd/flash/flash_builder.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/flash/flash_builder.py#L526-L545
def _analyze_pages_with_partial_read(self): """! @brief Estimate how many pages are the same by reading data. Pages are analyzed by reading the first 32 bytes and comparing with data to be programmed. """ # Quickly estimate how many pages are the same as current flash contents. ...
[ "def", "_analyze_pages_with_partial_read", "(", "self", ")", ":", "# Quickly estimate how many pages are the same as current flash contents.", "# Init the flash algo in case it is required in order to access the flash memory.", "self", ".", "_enable_read_access", "(", ")", "for", "page",...
! @brief Estimate how many pages are the same by reading data. Pages are analyzed by reading the first 32 bytes and comparing with data to be programmed.
[ "!", "@brief", "Estimate", "how", "many", "pages", "are", "the", "same", "by", "reading", "data", "." ]
python
train
49.75
bast/flanders
cmake/autocmake/generate.py
https://github.com/bast/flanders/blob/792f9eed8511cb553e67a25b6c5ce60fd6ae97bc/cmake/autocmake/generate.py#L172-L183
def align_options(options): """ Indents flags and aligns help texts. """ l = 0 for opt in options: if len(opt[0]) > l: l = len(opt[0]) s = [] for opt in options: s.append(' {0}{1} {2}'.format(opt[0], ' ' * (l - len(opt[0])), opt[1])) return '\n'.join(s)
[ "def", "align_options", "(", "options", ")", ":", "l", "=", "0", "for", "opt", "in", "options", ":", "if", "len", "(", "opt", "[", "0", "]", ")", ">", "l", ":", "l", "=", "len", "(", "opt", "[", "0", "]", ")", "s", "=", "[", "]", "for", "...
Indents flags and aligns help texts.
[ "Indents", "flags", "and", "aligns", "help", "texts", "." ]
python
train
25.333333
hthiery/python-lacrosse
pylacrosse/lacrosse.py
https://github.com/hthiery/python-lacrosse/blob/d588e68f12b3343e736ff986e5f994777b122fda/pylacrosse/lacrosse.py#L187-L207
def _refresh(self): """Background refreshing thread.""" while not self._stopevent.isSet(): line = self._serial.readline() #this is for python2/python3 compatibility. Is there a better way? try: line = line.encode().decode('utf-8') except A...
[ "def", "_refresh", "(", "self", ")", ":", "while", "not", "self", ".", "_stopevent", ".", "isSet", "(", ")", ":", "line", "=", "self", ".", "_serial", ".", "readline", "(", ")", "#this is for python2/python3 compatibility. Is there a better way?", "try", ":", ...
Background refreshing thread.
[ "Background", "refreshing", "thread", "." ]
python
train
37.142857
CalebBell/thermo
thermo/viscosity.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/viscosity.py#L1454-L1501
def load_all_methods(self): r'''Method which picks out coefficients for the specified chemical from the various dictionaries and DataFrames storing it. All data is stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`, :obj:`all_methods` and obj:`all_methods_P` as a set of...
[ "def", "load_all_methods", "(", "self", ")", ":", "methods", ",", "methods_P", "=", "[", "]", ",", "[", "]", "Tmins", ",", "Tmaxs", "=", "[", "]", ",", "[", "]", "if", "self", ".", "CASRN", "in", "_VDISaturationDict", ":", "methods", ".", "append", ...
r'''Method which picks out coefficients for the specified chemical from the various dictionaries and DataFrames storing it. All data is stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`, :obj:`all_methods` and obj:`all_methods_P` as a set of methods for which the data ...
[ "r", "Method", "which", "picks", "out", "coefficients", "for", "the", "specified", "chemical", "from", "the", "various", "dictionaries", "and", "DataFrames", "storing", "it", ".", "All", "data", "is", "stored", "as", "attributes", ".", "This", "method", "also"...
python
valid
53.083333
datacamp/pythonwhat
pythonwhat/checks/check_funcs.py
https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_funcs.py#L52-L71
def check_part(state, name, part_msg, missing_msg=None, expand_msg=None): """Return child state with name part as its ast tree""" if missing_msg is None: missing_msg = "Are you sure you defined the {{part}}? " if expand_msg is None: expand_msg = "Did you correctly specify the {{part}}? " ...
[ "def", "check_part", "(", "state", ",", "name", ",", "part_msg", ",", "missing_msg", "=", "None", ",", "expand_msg", "=", "None", ")", ":", "if", "missing_msg", "is", "None", ":", "missing_msg", "=", "\"Are you sure you defined the {{part}}? \"", "if", "expand_m...
Return child state with name part as its ast tree
[ "Return", "child", "state", "with", "name", "part", "as", "its", "ast", "tree" ]
python
test
34.65
Robpol86/sphinxcontrib-imgur
sphinxcontrib/imgur/sphinx_api.py
https://github.com/Robpol86/sphinxcontrib-imgur/blob/5c178481d645147d10acb096793eda41c12c57af/sphinxcontrib/imgur/sphinx_api.py#L143-L173
def setup(app, version): """Called by Sphinx during phase 0 (initialization). :param sphinx.application.Sphinx app: Sphinx application object. :param str version: Version of sphinxcontrib-imgur. :returns: Extension metadata. :rtype: dict """ app.add_config_value('imgur_api_cache_ttl', 1728...
[ "def", "setup", "(", "app", ",", "version", ")", ":", "app", ".", "add_config_value", "(", "'imgur_api_cache_ttl'", ",", "172800", ",", "False", ")", "app", ".", "add_config_value", "(", "'imgur_client_id'", ",", "None", ",", "False", ")", "app", ".", "add...
Called by Sphinx during phase 0 (initialization). :param sphinx.application.Sphinx app: Sphinx application object. :param str version: Version of sphinxcontrib-imgur. :returns: Extension metadata. :rtype: dict
[ "Called", "by", "Sphinx", "during", "phase", "0", "(", "initialization", ")", "." ]
python
train
46.83871
SeattleTestbed/seash
pyreadline/modes/emacs.py
https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/emacs.py#L324-L330
def forward_search_history(self, e): # (C-s) u'''Search forward starting at the current line and moving down through the the history as necessary. This is an incremental search.''' log("fwd_search_history") self._init_incremental_search(self._history.forward_search_history,...
[ "def", "forward_search_history", "(", "self", ",", "e", ")", ":", "# (C-s)\r", "log", "(", "\"fwd_search_history\"", ")", "self", ".", "_init_incremental_search", "(", "self", ".", "_history", ".", "forward_search_history", ",", "e", ")", "self", ".", "finalize"...
u'''Search forward starting at the current line and moving down through the the history as necessary. This is an incremental search.
[ "u", "Search", "forward", "starting", "at", "the", "current", "line", "and", "moving", "down", "through", "the", "the", "history", "as", "necessary", ".", "This", "is", "an", "incremental", "search", "." ]
python
train
48.857143
openvax/mhctools
mhctools/iedb.py
https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/iedb.py#L191-L241
def predict_subsequences(self, sequence_dict, peptide_lengths=None): """Given a dictionary mapping unique keys to amino acid sequences, run MHC binding predictions on all candidate epitopes extracted from sequences and return a EpitopeCollection. Parameters ---------- fa...
[ "def", "predict_subsequences", "(", "self", ",", "sequence_dict", ",", "peptide_lengths", "=", "None", ")", ":", "sequence_dict", "=", "check_sequence_dictionary", "(", "sequence_dict", ")", "peptide_lengths", "=", "self", ".", "_check_peptide_lengths", "(", "peptide_...
Given a dictionary mapping unique keys to amino acid sequences, run MHC binding predictions on all candidate epitopes extracted from sequences and return a EpitopeCollection. Parameters ---------- fasta_dictionary : dict or string Mapping of protein identifiers to pr...
[ "Given", "a", "dictionary", "mapping", "unique", "keys", "to", "amino", "acid", "sequences", "run", "MHC", "binding", "predictions", "on", "all", "candidate", "epitopes", "extracted", "from", "sequences", "and", "return", "a", "EpitopeCollection", "." ]
python
valid
46.862745
bcbio/bcbio-nextgen
bcbio/heterogeneity/__init__.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/__init__.py#L59-L67
def _ready_for_het_analysis(items): """Check if a sample has input information for heterogeneity analysis. We currently require a tumor/normal sample containing both CNV and variant calls. """ paired = vcfutils.get_paired_bams([dd.get_align_bam(d) for d in items], items) has_het = any(dd.get_hetcal...
[ "def", "_ready_for_het_analysis", "(", "items", ")", ":", "paired", "=", "vcfutils", ".", "get_paired_bams", "(", "[", "dd", ".", "get_align_bam", "(", "d", ")", "for", "d", "in", "items", "]", ",", "items", ")", "has_het", "=", "any", "(", "dd", ".", ...
Check if a sample has input information for heterogeneity analysis. We currently require a tumor/normal sample containing both CNV and variant calls.
[ "Check", "if", "a", "sample", "has", "input", "information", "for", "heterogeneity", "analysis", "." ]
python
train
50.777778
scour-project/scour
scour/scour.py
https://github.com/scour-project/scour/blob/049264eba6b1a54ae5ba1d6a5077d8e7b80e8835/scour/scour.py#L3041-L3069
def optimizeTransforms(element, options): """ Attempts to optimise transform specifications on the given node and its children. Returns the number of bytes saved after performing these reductions. """ num = 0 for transformAttr in ['transform', 'patternTransform', 'gradientTransform']: ...
[ "def", "optimizeTransforms", "(", "element", ",", "options", ")", ":", "num", "=", "0", "for", "transformAttr", "in", "[", "'transform'", ",", "'patternTransform'", ",", "'gradientTransform'", "]", ":", "val", "=", "element", ".", "getAttribute", "(", "transfo...
Attempts to optimise transform specifications on the given node and its children. Returns the number of bytes saved after performing these reductions.
[ "Attempts", "to", "optimise", "transform", "specifications", "on", "the", "given", "node", "and", "its", "children", "." ]
python
train
31.862069
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L6614-L6678
def Runtime_callFunctionOn(self, functionDeclaration, **kwargs): """ Function path: Runtime.callFunctionOn Domain: Runtime Method name: callFunctionOn Parameters: Required arguments: 'functionDeclaration' (type: string) -> Declaration of the function to call. Optional arguments: 'objec...
[ "def", "Runtime_callFunctionOn", "(", "self", ",", "functionDeclaration", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "functionDeclaration", ",", "(", "str", ",", ")", ")", ",", "\"Argument 'functionDeclaration' must be of type '['str']'. Received ty...
Function path: Runtime.callFunctionOn Domain: Runtime Method name: callFunctionOn Parameters: Required arguments: 'functionDeclaration' (type: string) -> Declaration of the function to call. Optional arguments: 'objectId' (type: RemoteObjectId) -> Identifier of the object to call function ...
[ "Function", "path", ":", "Runtime", ".", "callFunctionOn", "Domain", ":", "Runtime", "Method", "name", ":", "callFunctionOn", "Parameters", ":", "Required", "arguments", ":", "functionDeclaration", "(", "type", ":", "string", ")", "-", ">", "Declaration", "of", ...
python
train
63.384615
brocade/pynos
pynos/versions/base/yang/brocade_sflow.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/yang/brocade_sflow.py#L94-L105
def sflow_profile_profile_sampling_rate(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") sflow_profile = ET.SubElement(config, "sflow-profile", xmlns="urn:brocade.com:mgmt:brocade-sflow") profile_name_key = ET.SubElement(sflow_profile, "profile-name") ...
[ "def", "sflow_profile_profile_sampling_rate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "sflow_profile", "=", "ET", ".", "SubElement", "(", "config", ",", "\"sflow-profile\"", ",", "xmlns", "...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
51.166667
cloudnativelabs/kube-shell
kubeshell/parser.py
https://github.com/cloudnativelabs/kube-shell/blob/adc801d165e87fe62f82b074ec49996954c3fbe8/kubeshell/parser.py#L92-L128
def treewalk(self, root, parsed, unparsed): """ Recursively walks the syntax tree at root and returns the items parsed, unparsed and possible suggestions """ suggestions = dict() if not unparsed: logger.debug("no tokens left unparsed. returning %s, %s", parsed, suggestions) ...
[ "def", "treewalk", "(", "self", ",", "root", ",", "parsed", ",", "unparsed", ")", ":", "suggestions", "=", "dict", "(", ")", "if", "not", "unparsed", ":", "logger", ".", "debug", "(", "\"no tokens left unparsed. returning %s, %s\"", ",", "parsed", ",", "sugg...
Recursively walks the syntax tree at root and returns the items parsed, unparsed and possible suggestions
[ "Recursively", "walks", "the", "syntax", "tree", "at", "root", "and", "returns", "the", "items", "parsed", "unparsed", "and", "possible", "suggestions" ]
python
train
56
SBRG/ssbio
ssbio/core/modelpro.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/core/modelpro.py#L222-L241
def true_num_reactions(model, custom_spont_id=None): """Return the number of reactions associated with a gene. Args: model (Model): custom_spont_id (str): Optional custom spontaneous ID if it does not match the regular expression ``[Ss](_|)0001`` Returns: int: Number of reactions a...
[ "def", "true_num_reactions", "(", "model", ",", "custom_spont_id", "=", "None", ")", ":", "true_num", "=", "0", "for", "rxn", "in", "model", ".", "reactions", ":", "if", "len", "(", "rxn", ".", "genes", ")", "==", "0", ":", "continue", "if", "len", "...
Return the number of reactions associated with a gene. Args: model (Model): custom_spont_id (str): Optional custom spontaneous ID if it does not match the regular expression ``[Ss](_|)0001`` Returns: int: Number of reactions associated with a gene
[ "Return", "the", "number", "of", "reactions", "associated", "with", "a", "gene", "." ]
python
train
30.6
Pelagicore/qface
qface/idl/domain.py
https://github.com/Pelagicore/qface/blob/7f60e91e3a91a7cb04cfacbc9ce80f43df444853/qface/idl/domain.py#L209-L215
def is_valid(self): '''checks if type is a valid type''' return (self.is_primitive and self.name) \ or (self.is_complex and self.name) \ or (self.is_list and self.nested) \ or (self.is_map and self.nested) \ or (self.is_model and self.nested)
[ "def", "is_valid", "(", "self", ")", ":", "return", "(", "self", ".", "is_primitive", "and", "self", ".", "name", ")", "or", "(", "self", ".", "is_complex", "and", "self", ".", "name", ")", "or", "(", "self", ".", "is_list", "and", "self", ".", "ne...
checks if type is a valid type
[ "checks", "if", "type", "is", "a", "valid", "type" ]
python
train
42.857143
aluzzardi/wssh
wssh/server.py
https://github.com/aluzzardi/wssh/blob/4ccde12af67a0d7a121294ec6c4a5ec3c17de425/wssh/server.py#L125-L135
def _forward_outbound(self, channel): """ Forward outbound traffic (ssh -> websockets) """ try: while True: wait_read(channel.fileno()) data = channel.recv(1024) if not len(data): return self._websocket.send(...
[ "def", "_forward_outbound", "(", "self", ",", "channel", ")", ":", "try", ":", "while", "True", ":", "wait_read", "(", "channel", ".", "fileno", "(", ")", ")", "data", "=", "channel", ".", "recv", "(", "1024", ")", "if", "not", "len", "(", "data", ...
Forward outbound traffic (ssh -> websockets)
[ "Forward", "outbound", "traffic", "(", "ssh", "-", ">", "websockets", ")" ]
python
train
34.454545
globus/globus-cli
globus_cli/commands/endpoint/deactivate.py
https://github.com/globus/globus-cli/blob/336675ff24da64c5ee487243f39ae39fc49a7e14/globus_cli/commands/endpoint/deactivate.py#L11-L17
def endpoint_deactivate(endpoint_id): """ Executor for `globus endpoint deactivate` """ client = get_client() res = client.endpoint_deactivate(endpoint_id) formatted_print(res, text_format=FORMAT_TEXT_RAW, response_key="message")
[ "def", "endpoint_deactivate", "(", "endpoint_id", ")", ":", "client", "=", "get_client", "(", ")", "res", "=", "client", ".", "endpoint_deactivate", "(", "endpoint_id", ")", "formatted_print", "(", "res", ",", "text_format", "=", "FORMAT_TEXT_RAW", ",", "respons...
Executor for `globus endpoint deactivate`
[ "Executor", "for", "globus", "endpoint", "deactivate" ]
python
train
35.285714
StackStorm/pybind
pybind/nos/v6_0_2f/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/__init__.py#L6942-L6963
def _set_radius_server(self, v, load=False): """ Setter method for radius_server, mapped from YANG variable /radius_server (container) If this variable is read-only (config: false) in the source YANG file, then _set_radius_server is considered as a private method. Backends looking to populate this v...
[ "def", "_set_radius_server", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "...
Setter method for radius_server, mapped from YANG variable /radius_server (container) If this variable is read-only (config: false) in the source YANG file, then _set_radius_server is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_radius_...
[ "Setter", "method", "for", "radius_server", "mapped", "from", "YANG", "variable", "/", "radius_server", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file", "th...
python
train
78.5
Rockhopper-Technologies/enlighten
examples/context_manager.py
https://github.com/Rockhopper-Technologies/enlighten/blob/857855f940e6c1bb84d0be849b999a18fff5bf5a/examples/context_manager.py#L19-L33
def process_files(): """ Use Manager and Counter as context managers """ with enlighten.Manager() as manager: with manager.counter(total=SPLINES, desc='Reticulating:', unit='splines') as retic: for num in range(SPLINES): # pylint: disable=unused-variable time.sleep(...
[ "def", "process_files", "(", ")", ":", "with", "enlighten", ".", "Manager", "(", ")", "as", "manager", ":", "with", "manager", ".", "counter", "(", "total", "=", "SPLINES", ",", "desc", "=", "'Reticulating:'", ",", "unit", "=", "'splines'", ")", "as", ...
Use Manager and Counter as context managers
[ "Use", "Manager", "and", "Counter", "as", "context", "managers" ]
python
train
43.733333
fboender/ansible-cmdb
lib/mako/pygen.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/lib/mako/pygen.py#L70-L139
def writeline(self, line): """print a line of python, indenting it according to the current indent level. this also adjusts the indentation counter according to the content of the line. """ if not self.in_indent_lines: self._flush_adjusted_lines() ...
[ "def", "writeline", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "in_indent_lines", ":", "self", ".", "_flush_adjusted_lines", "(", ")", "self", ".", "in_indent_lines", "=", "True", "if", "(", "line", "is", "None", "or", "re", ".", "ma...
print a line of python, indenting it according to the current indent level. this also adjusts the indentation counter according to the content of the line.
[ "print", "a", "line", "of", "python", "indenting", "it", "according", "to", "the", "current", "indent", "level", "." ]
python
train
36.928571
caseyjlaw/rtpipe
rtpipe/RT.py
https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/RT.py#L541-L581
def make_transient(std, DMmax, Amin=6., Amax=20., rmax=20., rmin=0., DMmin=0.): """ Produce a mock transient pulse source for the purposes of characterizing the detection success of the current pipeline. Assumes - Code to inject the transients does so by inserting at an array index - Noise lev...
[ "def", "make_transient", "(", "std", ",", "DMmax", ",", "Amin", "=", "6.", ",", "Amax", "=", "20.", ",", "rmax", "=", "20.", ",", "rmin", "=", "0.", ",", "DMmin", "=", "0.", ")", ":", "rad_arcmin", "=", "math", ".", "pi", "/", "(", "180", "*", ...
Produce a mock transient pulse source for the purposes of characterizing the detection success of the current pipeline. Assumes - Code to inject the transients does so by inserting at an array index - Noise level at the center of the data array is characteristic of the noise level throughout...
[ "Produce", "a", "mock", "transient", "pulse", "source", "for", "the", "purposes", "of", "characterizing", "the", "detection", "success", "of", "the", "current", "pipeline", ".", "Assumes", "-", "Code", "to", "inject", "the", "transients", "does", "so", "by", ...
python
train
38.073171
tensorflow/tensorboard
tensorboard/plugins/audio/audio_demo.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/audio/audio_demo.py#L208-L234
def bisine_wahwah_wave(frequency): """Emit two sine waves with balance oscillating left and right.""" # # This is clearly intended to build on the bisine wave defined above, # so we can start by generating that. waves_a = bisine_wave(frequency) # # Then, by reversing axis 2, we swap the stereo channels. B...
[ "def", "bisine_wahwah_wave", "(", "frequency", ")", ":", "#", "# This is clearly intended to build on the bisine wave defined above,", "# so we can start by generating that.", "waves_a", "=", "bisine_wave", "(", "frequency", ")", "#", "# Then, by reversing axis 2, we swap the stereo ...
Emit two sine waves with balance oscillating left and right.
[ "Emit", "two", "sine", "waves", "with", "balance", "oscillating", "left", "and", "right", "." ]
python
train
41.296296
fermiPy/fermipy
fermipy/irfs.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/irfs.py#L710-L737
def create_avg_rsp(rsp_fn, skydir, ltc, event_class, event_types, x, egy, cth_bins, npts=None): """Calculate the weighted response function. """ if npts is None: npts = int(np.ceil(np.max(cth_bins[1:] - cth_bins[:-1]) / 0.05)) wrsp = np.zeros((len(x), len(egy), len(cth_bins) ...
[ "def", "create_avg_rsp", "(", "rsp_fn", ",", "skydir", ",", "ltc", ",", "event_class", ",", "event_types", ",", "x", ",", "egy", ",", "cth_bins", ",", "npts", "=", "None", ")", ":", "if", "npts", "is", "None", ":", "npts", "=", "int", "(", "np", "....
Calculate the weighted response function.
[ "Calculate", "the", "weighted", "response", "function", "." ]
python
train
38.464286
pivotal-energy-solutions/django-datatable-view
datatableview/views/xeditable.py
https://github.com/pivotal-energy-solutions/django-datatable-view/blob/00b77a9b5051c34e258c51b06c020e92edf15034/datatableview/views/xeditable.py#L32-L62
def get_ajax_xeditable_choices(self, request, *args, **kwargs): """ AJAX GET handler for xeditable queries asking for field choice lists. """ field_name = request.GET.get(self.xeditable_fieldname_param) if not field_name: return HttpResponseBadRequest("Field name must be given") ...
[ "def", "get_ajax_xeditable_choices", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "field_name", "=", "request", ".", "GET", ".", "get", "(", "self", ".", "xeditable_fieldname_param", ")", "if", "not", "field_name", ":",...
AJAX GET handler for xeditable queries asking for field choice lists.
[ "AJAX", "GET", "handler", "for", "xeditable", "queries", "asking", "for", "field", "choice", "lists", "." ]
python
train
44.322581
blockstack/zone-file-py
blockstack_zones/record_processors.py
https://github.com/blockstack/zone-file-py/blob/c1078c8c3c28f0881bc9a3af53d4972c4a6862d0/blockstack_zones/record_processors.py#L91-L124
def process_rr(data, record_type, record_keys, field, template): """ Meta method: Replace $field in template with the serialized $record_type records, using @record_key from each datum. """ if data is None: return template.replace(field, "") if type(record_keys) == list: pas...
[ "def", "process_rr", "(", "data", ",", "record_type", ",", "record_keys", ",", "field", ",", "template", ")", ":", "if", "data", "is", "None", ":", "return", "template", ".", "replace", "(", "field", ",", "\"\"", ")", "if", "type", "(", "record_keys", ...
Meta method: Replace $field in template with the serialized $record_type records, using @record_key from each datum.
[ "Meta", "method", ":", "Replace", "$field", "in", "template", "with", "the", "serialized", "$record_type", "records", "using" ]
python
test
30.441176
inveniosoftware/invenio-migrator
invenio_migrator/legacy/access.py
https://github.com/inveniosoftware/invenio-migrator/blob/6902c6968a39b747d15e32363f43b7dffe2622c2/invenio_migrator/legacy/access.py#L80-L95
def get(query, *args, **kwargs): """Get action definitions to dump.""" run_sql = _get_run_sql() actions = [ dict(id=row[0], name=row[1], allowedkeywords=row[2], optional=row[3]) for action in query.split(',') for row in run_sql( 'select id,...
[ "def", "get", "(", "query", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "run_sql", "=", "_get_run_sql", "(", ")", "actions", "=", "[", "dict", "(", "id", "=", "row", "[", "0", "]", ",", "name", "=", "row", "[", "1", "]", ",", "allowe...
Get action definitions to dump.
[ "Get", "action", "definitions", "to", "dump", "." ]
python
test
30.25
rgmining/ria
ria/bipartite.py
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L363-L389
def add_review(self, reviewer, product, review, date=None): """Add a new review from a given reviewer to a given product. Args: reviewer: an instance of Reviewer. product: an instance of Product. review: a float value. date: date the review issued. Retur...
[ "def", "add_review", "(", "self", ",", "reviewer", ",", "product", ",", "review", ",", "date", "=", "None", ")", ":", "if", "not", "isinstance", "(", "reviewer", ",", "self", ".", "_reviewer_cls", ")", ":", "raise", "TypeError", "(", "\"Type of given revie...
Add a new review from a given reviewer to a given product. Args: reviewer: an instance of Reviewer. product: an instance of Product. review: a float value. date: date the review issued. Returns: the added new review object. Raises: T...
[ "Add", "a", "new", "review", "from", "a", "given", "reviewer", "to", "a", "given", "product", "." ]
python
train
38.925926
saltstack/salt
salt/scripts.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/scripts.py#L454-L474
def salt_ssh(): ''' Execute the salt-ssh system ''' import salt.cli.ssh if '' in sys.path: sys.path.remove('') try: client = salt.cli.ssh.SaltSSH() _install_signal_handlers(client) client.run() except SaltClientError as err: trace = traceback.format_ex...
[ "def", "salt_ssh", "(", ")", ":", "import", "salt", ".", "cli", ".", "ssh", "if", "''", "in", "sys", ".", "path", ":", "sys", ".", "path", ".", "remove", "(", "''", ")", "try", ":", "client", "=", "salt", ".", "cli", ".", "ssh", ".", "SaltSSH",...
Execute the salt-ssh system
[ "Execute", "the", "salt", "-", "ssh", "system" ]
python
train
26.095238
AtomHash/evernode
evernode/classes/base_response.py
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L55-L69
def quick_response(self, status_code): """ Quickly construct response using a status code """ translator = Translator(environ=self.environ) if status_code == 404: self.status(404) self.message(translator.trans('http_messages.404')) elif status_code == 401: ...
[ "def", "quick_response", "(", "self", ",", "status_code", ")", ":", "translator", "=", "Translator", "(", "environ", "=", "self", ".", "environ", ")", "if", "status_code", "==", "404", ":", "self", ".", "status", "(", "404", ")", "self", ".", "message", ...
Quickly construct response using a status code
[ "Quickly", "construct", "response", "using", "a", "status", "code" ]
python
train
43.8
softlayer/softlayer-python
SoftLayer/managers/user.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/managers/user.py#L69-L74
def get_current_user(self, objectmask=None): """Calls SoftLayer_Account::getCurrentUser""" if objectmask is None: objectmask = "mask[userStatus[name], parent[id, username]]" return self.account_service.getCurrentUser(mask=objectmask)
[ "def", "get_current_user", "(", "self", ",", "objectmask", "=", "None", ")", ":", "if", "objectmask", "is", "None", ":", "objectmask", "=", "\"mask[userStatus[name], parent[id, username]]\"", "return", "self", ".", "account_service", ".", "getCurrentUser", "(", "mas...
Calls SoftLayer_Account::getCurrentUser
[ "Calls", "SoftLayer_Account", "::", "getCurrentUser" ]
python
train
44.166667
saltstack/salt
salt/cache/redis_cache.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cache/redis_cache.py#L268-L278
def _get_key_redis_key(bank, key): ''' Return the Redis key given the bank name and the key name. ''' opts = _get_redis_keys_opts() return '{prefix}{separator}{bank}/{key}'.format( prefix=opts['key_prefix'], separator=opts['separator'], bank=bank, key=key )
[ "def", "_get_key_redis_key", "(", "bank", ",", "key", ")", ":", "opts", "=", "_get_redis_keys_opts", "(", ")", "return", "'{prefix}{separator}{bank}/{key}'", ".", "format", "(", "prefix", "=", "opts", "[", "'key_prefix'", "]", ",", "separator", "=", "opts", "[...
Return the Redis key given the bank name and the key name.
[ "Return", "the", "Redis", "key", "given", "the", "bank", "name", "and", "the", "key", "name", "." ]
python
train
27.545455
maybelinot/df2gspread
df2gspread/df2gspread.py
https://github.com/maybelinot/df2gspread/blob/f4cef3800704aceff2ed08a623a594b558d44898/df2gspread/df2gspread.py#L24-L148
def upload(df, gfile="/New Spreadsheet", wks_name=None, col_names=True, row_names=True, clean=True, credentials=None, start_cell = 'A1', df_size = False, new_sheet_dimensions = (1000,100)): ''' Upload given Pandas DataFrame to Google Drive and returns gspread Worksheet object ...
[ "def", "upload", "(", "df", ",", "gfile", "=", "\"/New Spreadsheet\"", ",", "wks_name", "=", "None", ",", "col_names", "=", "True", ",", "row_names", "=", "True", ",", "clean", "=", "True", ",", "credentials", "=", "None", ",", "start_cell", "=", "'A1'",...
Upload given Pandas DataFrame to Google Drive and returns gspread Worksheet object :param df: Pandas DataFrame :param gfile: path to Google Spreadsheet or gspread ID :param wks_name: worksheet name :param col_names: passing top row to column names for Pandas DataFrame :p...
[ "Upload", "given", "Pandas", "DataFrame", "to", "Google", "Drive", "and", "returns", "gspread", "Worksheet", "object" ]
python
train
42.912
ihgazni2/edict
edict/edict.py
https://github.com/ihgazni2/edict/blob/44a08ccc10b196aa3854619b4c51ddb246778a34/edict/edict.py#L1382-L1399
def is_leaf(obj): ''' the below is for nested-dict any type is not dict will be treated as a leaf empty dict will be treated as a leaf from edict.edict import * is_leaf(1) is_leaf({1:2}) is_leaf({}) ''' if(is_dict(obj)): length = obj.__len__() ...
[ "def", "is_leaf", "(", "obj", ")", ":", "if", "(", "is_dict", "(", "obj", ")", ")", ":", "length", "=", "obj", ".", "__len__", "(", ")", "if", "(", "length", "==", "0", ")", ":", "return", "(", "True", ")", "else", ":", "return", "(", "False", ...
the below is for nested-dict any type is not dict will be treated as a leaf empty dict will be treated as a leaf from edict.edict import * is_leaf(1) is_leaf({1:2}) is_leaf({})
[ "the", "below", "is", "for", "nested", "-", "dict", "any", "type", "is", "not", "dict", "will", "be", "treated", "as", "a", "leaf", "empty", "dict", "will", "be", "treated", "as", "a", "leaf", "from", "edict", ".", "edict", "import", "*", "is_leaf", ...
python
train
23.5
luckydonald/pytgbot
code_generation/output/pytgbot/api_types/receivable/passport.py
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/passport.py#L419-L445
def from_array(array): """ Deserialize a new EncryptedPassportElement from a given dictionary. :return: new EncryptedPassportElement instance. :rtype: EncryptedPassportElement """ if array is None or not array: return None # end if assert_type...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "from", "pytgbot", ".", "api...
Deserialize a new EncryptedPassportElement from a given dictionary. :return: new EncryptedPassportElement instance. :rtype: EncryptedPassportElement
[ "Deserialize", "a", "new", "EncryptedPassportElement", "from", "a", "given", "dictionary", "." ]
python
train
57.296296
PythonCharmers/python-future
src/future/backports/urllib/request.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/backports/urllib/request.py#L2115-L2120
def http_error_307(self, url, fp, errcode, errmsg, headers, data=None): """Error 307 -- relocated, but turn POST into error.""" if data is None: return self.http_error_302(url, fp, errcode, errmsg, headers, data) else: return self.http_error_default(url, fp, errcode, errm...
[ "def", "http_error_307", "(", "self", ",", "url", ",", "fp", ",", "errcode", ",", "errmsg", ",", "headers", ",", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "return", "self", ".", "http_error_302", "(", "url", ",", "fp", ",", "e...
Error 307 -- relocated, but turn POST into error.
[ "Error", "307", "--", "relocated", "but", "turn", "POST", "into", "error", "." ]
python
train
54.5
dadadel/pyment
pyment/docstring.py
https://github.com/dadadel/pyment/blob/3d1bdf87d083ff56230bd0bf7c5252e20552b7b6/pyment/docstring.py#L439-L448
def get_key_section_header(self, key, spaces): """Get the key of the header section :param key: the key name :param spaces: spaces to set at the beginning of the header """ header = super(NumpydocTools, self).get_key_section_header(key, spaces) header = spaces + header ...
[ "def", "get_key_section_header", "(", "self", ",", "key", ",", "spaces", ")", ":", "header", "=", "super", "(", "NumpydocTools", ",", "self", ")", ".", "get_key_section_header", "(", "key", ",", "spaces", ")", "header", "=", "spaces", "+", "header", "+", ...
Get the key of the header section :param key: the key name :param spaces: spaces to set at the beginning of the header
[ "Get", "the", "key", "of", "the", "header", "section" ]
python
train
37.5
sunlightlabs/name-cleaver
name_cleaver/cleaver.py
https://github.com/sunlightlabs/name-cleaver/blob/48d3838fd9521235bd1586017fa4b31236ffc88e/name_cleaver/cleaver.py#L265-L280
def compare(cls, match, subject): """ Accepts two OrganizationName objects and returns an arbitrary, numerical score based upon how well the names match. """ if match.expand().lower() == subject.expand().lower(): return 4 elif match.kernel().lower() ==...
[ "def", "compare", "(", "cls", ",", "match", ",", "subject", ")", ":", "if", "match", ".", "expand", "(", ")", ".", "lower", "(", ")", "==", "subject", ".", "expand", "(", ")", ".", "lower", "(", ")", ":", "return", "4", "elif", "match", ".", "k...
Accepts two OrganizationName objects and returns an arbitrary, numerical score based upon how well the names match.
[ "Accepts", "two", "OrganizationName", "objects", "and", "returns", "an", "arbitrary", "numerical", "score", "based", "upon", "how", "well", "the", "names", "match", "." ]
python
train
41.5625
DataONEorg/d1_python
lib_client/src/d1_client/solr_client.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_client/src/d1_client/solr_client.py#L232-L256
def get_field_min_max(self, name, **query_dict): """Returns the minimum and maximum values of the specified field. This requires two search calls to the service, each requesting a single value of a single field. @param name(string) Name of the field @param q(string) Query identi...
[ "def", "get_field_min_max", "(", "self", ",", "name", ",", "*", "*", "query_dict", ")", ":", "param_dict", "=", "query_dict", ".", "copy", "(", ")", "param_dict", ".", "update", "(", "{", "'rows'", ":", "1", ",", "'fl'", ":", "name", ",", "'sort'", "...
Returns the minimum and maximum values of the specified field. This requires two search calls to the service, each requesting a single value of a single field. @param name(string) Name of the field @param q(string) Query identifying range of records for min and max values @param...
[ "Returns", "the", "minimum", "and", "maximum", "values", "of", "the", "specified", "field", ".", "This", "requires", "two", "search", "calls", "to", "the", "service", "each", "requesting", "a", "single", "value", "of", "a", "single", "field", "." ]
python
train
39.6
wandb/client
wandb/vendor/prompt_toolkit/buffer.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/buffer.py#L551-L566
def transform_region(self, from_, to, transform_callback): """ Transform a part of the input string. :param from_: (int) start position. :param to: (int) end position. :param transform_callback: Callable which accepts a string and returns the transformed string. ...
[ "def", "transform_region", "(", "self", ",", "from_", ",", "to", ",", "transform_callback", ")", ":", "assert", "from_", "<", "to", "self", ".", "text", "=", "''", ".", "join", "(", "[", "self", ".", "text", "[", ":", "from_", "]", "+", "transform_ca...
Transform a part of the input string. :param from_: (int) start position. :param to: (int) end position. :param transform_callback: Callable which accepts a string and returns the transformed string.
[ "Transform", "a", "part", "of", "the", "input", "string", "." ]
python
train
30.8125
p3trus/slave
slave/transport.py
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/transport.py#L514-L519
def _check_status(self, ibsta): """Checks ibsta value.""" if ibsta & 0x4000: raise LinuxGpib.Timeout() elif ibsta & 0x8000: raise LinuxGpib.Error(self.error_status)
[ "def", "_check_status", "(", "self", ",", "ibsta", ")", ":", "if", "ibsta", "&", "0x4000", ":", "raise", "LinuxGpib", ".", "Timeout", "(", ")", "elif", "ibsta", "&", "0x8000", ":", "raise", "LinuxGpib", ".", "Error", "(", "self", ".", "error_status", "...
Checks ibsta value.
[ "Checks", "ibsta", "value", "." ]
python
train
34.5
nirum/tableprint
tableprint/printer.py
https://github.com/nirum/tableprint/blob/50ab4b96706fce8ee035a4d48cb456e3271eab3d/tableprint/printer.py#L276-L284
def dataframe(df, **kwargs): """Print table with data from the given pandas DataFrame Parameters ---------- df : DataFrame A pandas DataFrame with the table to print """ table(df.values, list(df.columns), **kwargs)
[ "def", "dataframe", "(", "df", ",", "*", "*", "kwargs", ")", ":", "table", "(", "df", ".", "values", ",", "list", "(", "df", ".", "columns", ")", ",", "*", "*", "kwargs", ")" ]
Print table with data from the given pandas DataFrame Parameters ---------- df : DataFrame A pandas DataFrame with the table to print
[ "Print", "table", "with", "data", "from", "the", "given", "pandas", "DataFrame" ]
python
train
26.555556
WhyNotHugo/python-barcode
barcode/writer.py
https://github.com/WhyNotHugo/python-barcode/blob/0b237016f32b4d0f3425dab10d52e291070c0558/barcode/writer.py#L145-L159
def set_options(self, options): """Sets the given options as instance attributes (only if they are known). :parameters: options : Dict All known instance attributes and more if the childclass has defined them before this call. :rtype: None ...
[ "def", "set_options", "(", "self", ",", "options", ")", ":", "for", "key", ",", "val", "in", "options", ".", "items", "(", ")", ":", "key", "=", "key", ".", "lstrip", "(", "'_'", ")", "if", "hasattr", "(", "self", ",", "key", ")", ":", "setattr",...
Sets the given options as instance attributes (only if they are known). :parameters: options : Dict All known instance attributes and more if the childclass has defined them before this call. :rtype: None
[ "Sets", "the", "given", "options", "as", "instance", "attributes", "(", "only", "if", "they", "are", "known", ")", "." ]
python
train
31
MIT-LCP/wfdb-python
wfdb/io/annotation.py
https://github.com/MIT-LCP/wfdb-python/blob/cc8c9e9e44f10af961b7a9d8ae03708b31ac8a8c/wfdb/io/annotation.py#L463-L527
def get_available_label_stores(self, usefield='tryall'): """ Get the label store values that may be used for writing this annotation. Available store values include: - the undefined values in the standard wfdb labels - the store values not used in the current a...
[ "def", "get_available_label_stores", "(", "self", ",", "usefield", "=", "'tryall'", ")", ":", "# Figure out which field to use to get available labels stores.", "if", "usefield", "==", "'tryall'", ":", "if", "self", ".", "label_store", "is", "not", "None", ":", "usefi...
Get the label store values that may be used for writing this annotation. Available store values include: - the undefined values in the standard wfdb labels - the store values not used in the current annotation object. - the store values whose standard wfdb symbols/desc...
[ "Get", "the", "label", "store", "values", "that", "may", "be", "used", "for", "writing", "this", "annotation", "." ]
python
train
50.153846
TheGhouls/oct
oct/results/graphs.py
https://github.com/TheGhouls/oct/blob/7e9bddeb3b8495a26442b1c86744e9fb187fe88f/oct/results/graphs.py#L9-L18
def get_local_time(index): """Localize datetime for better output in graphs :param pandas.DateTimeIndex index: pandas datetime index :return: aware time objet :rtype: datetime.time """ dt = index.to_pydatetime() dt = dt.replace(tzinfo=pytz.utc) return dt.astimezone(tzlocal()).time()
[ "def", "get_local_time", "(", "index", ")", ":", "dt", "=", "index", ".", "to_pydatetime", "(", ")", "dt", "=", "dt", ".", "replace", "(", "tzinfo", "=", "pytz", ".", "utc", ")", "return", "dt", ".", "astimezone", "(", "tzlocal", "(", ")", ")", "."...
Localize datetime for better output in graphs :param pandas.DateTimeIndex index: pandas datetime index :return: aware time objet :rtype: datetime.time
[ "Localize", "datetime", "for", "better", "output", "in", "graphs" ]
python
train
30.7
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/textio.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L943-L948
def black(cls): "Make the text foreground color black." wAttributes = cls._get_text_attributes() wAttributes &= ~win32.FOREGROUND_MASK #wAttributes |= win32.FOREGROUND_BLACK cls._set_text_attributes(wAttributes)
[ "def", "black", "(", "cls", ")", ":", "wAttributes", "=", "cls", ".", "_get_text_attributes", "(", ")", "wAttributes", "&=", "~", "win32", ".", "FOREGROUND_MASK", "#wAttributes |= win32.FOREGROUND_BLACK", "cls", ".", "_set_text_attributes", "(", "wAttributes", ")" ...
Make the text foreground color black.
[ "Make", "the", "text", "foreground", "color", "black", "." ]
python
train
41.166667
numenta/nupic
src/nupic/database/client_jobs_dao.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/database/client_jobs_dao.py#L2667-L2698
def modelsGetResultAndStatus(self, modelIDs): """ Get the results string and other status fields for a set of models. WARNING!!!: The order of the results are NOT necessarily in the same order as the order of the model IDs passed in!!! For each model, this returns a tuple containing: (modelID, re...
[ "def", "modelsGetResultAndStatus", "(", "self", ",", "modelIDs", ")", ":", "assert", "isinstance", "(", "modelIDs", ",", "self", ".", "_SEQUENCE_TYPES", ")", ",", "(", "\"Wrong modelIDs type: %r\"", ")", "%", "type", "(", "modelIDs", ")", "assert", "len", "(",...
Get the results string and other status fields for a set of models. WARNING!!!: The order of the results are NOT necessarily in the same order as the order of the model IDs passed in!!! For each model, this returns a tuple containing: (modelID, results, status, updateCounter, numRecords, completionRe...
[ "Get", "the", "results", "string", "and", "other", "status", "fields", "for", "a", "set", "of", "models", "." ]
python
valid
43.65625
gwpy/gwpy
gwpy/timeseries/core.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/timeseries/core.py#L256-L262
def duration(self): """Duration of this series in seconds :type: `~astropy.units.Quantity` scalar """ return units.Quantity(self.span[1] - self.span[0], self.xunit, dtype=float)
[ "def", "duration", "(", "self", ")", ":", "return", "units", ".", "Quantity", "(", "self", ".", "span", "[", "1", "]", "-", "self", ".", "span", "[", "0", "]", ",", "self", ".", "xunit", ",", "dtype", "=", "float", ")" ]
Duration of this series in seconds :type: `~astropy.units.Quantity` scalar
[ "Duration", "of", "this", "series", "in", "seconds" ]
python
train
33.428571
jaraco/jaraco.path
jaraco/path.py
https://github.com/jaraco/jaraco.path/blob/39e4da09f325382e21b0917b1b5cd027edce8728/jaraco/path.py#L46-L50
def splitext_files_only(filepath): "Custom version of splitext that doesn't perform splitext on directories" return ( (filepath, '') if os.path.isdir(filepath) else os.path.splitext(filepath) )
[ "def", "splitext_files_only", "(", "filepath", ")", ":", "return", "(", "(", "filepath", ",", "''", ")", "if", "os", ".", "path", ".", "isdir", "(", "filepath", ")", "else", "os", ".", "path", ".", "splitext", "(", "filepath", ")", ")" ]
Custom version of splitext that doesn't perform splitext on directories
[ "Custom", "version", "of", "splitext", "that", "doesn", "t", "perform", "splitext", "on", "directories" ]
python
valid
39.6
SheffieldML/GPy
GPy/util/mocap.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/mocap.py#L328-L428
def read_bonedata(self, fid): """Read bone data from an acclaim skeleton file stream.""" bone_count = 0 lin = self.read_line(fid) while lin[0]!=':': parts = lin.split() if parts[0] == 'begin': bone_count += 1 self.vertices.append(v...
[ "def", "read_bonedata", "(", "self", ",", "fid", ")", ":", "bone_count", "=", "0", "lin", "=", "self", ".", "read_line", "(", "fid", ")", "while", "lin", "[", "0", "]", "!=", "':'", ":", "parts", "=", "lin", ".", "split", "(", ")", "if", "parts",...
Read bone data from an acclaim skeleton file stream.
[ "Read", "bone", "data", "from", "an", "acclaim", "skeleton", "file", "stream", "." ]
python
train
41.663366
AguaClara/aguaclara
aguaclara/research/peristaltic_pump.py
https://github.com/AguaClara/aguaclara/blob/8dd4e734768b166a7fc2b60388a24df2f93783fc/aguaclara/research/peristaltic_pump.py#L78-L101
def vol_per_rev_LS(id_number): """Look up the volume per revolution output by a Masterflex L/S pump through L/S tubing of the given ID number. :param id_number: Identification number of the L/S tubing. Valid numbers are 13-18, 24, 35, and 36. :type id_number: int :return: Volume per revolution out...
[ "def", "vol_per_rev_LS", "(", "id_number", ")", ":", "tubing_data_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "\"data\"", ",", "\"LS_tubing.txt\"", ")", "df", "=", "pd", ".", "read_csv", ...
Look up the volume per revolution output by a Masterflex L/S pump through L/S tubing of the given ID number. :param id_number: Identification number of the L/S tubing. Valid numbers are 13-18, 24, 35, and 36. :type id_number: int :return: Volume per revolution output by a Masterflex L/S pump through t...
[ "Look", "up", "the", "volume", "per", "revolution", "output", "by", "a", "Masterflex", "L", "/", "S", "pump", "through", "L", "/", "S", "tubing", "of", "the", "given", "ID", "number", "." ]
python
train
37.75
huge-success/sanic
sanic/blueprints.py
https://github.com/huge-success/sanic/blob/6a4a3f617fdbe1d3ee8bdc9d1b12ad2d0b34acdd/sanic/blueprints.py#L166-L207
def route( self, uri, methods=frozenset({"GET"}), host=None, strict_slashes=None, stream=False, version=None, name=None, ): """Create a blueprint route from a decorated function. :param uri: endpoint at which the route will be accessib...
[ "def", "route", "(", "self", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "\"GET\"", "}", ")", ",", "host", "=", "None", ",", "strict_slashes", "=", "None", ",", "stream", "=", "False", ",", "version", "=", "None", ",", "name", "=", "Non...
Create a blueprint route from a decorated function. :param uri: endpoint at which the route will be accessible. :param methods: list of acceptable HTTP methods. :param host: IP Address of FQDN for the sanic server to use. :param strict_slashes: Enforce the API urls are requested with a ...
[ "Create", "a", "blueprint", "route", "from", "a", "decorated", "function", "." ]
python
train
29.857143
decryptus/sonicprobe
sonicprobe/libs/xys.py
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/xys.py#L514-L527
def isIn(val, schema, name = None): # pylint: disable-msg=W0613 """ !~~isIn(data) """ if name is None: name = schema if not _lists.has_key(name): return False try: return val in _lists[name] except TypeError: return False
[ "def", "isIn", "(", "val", ",", "schema", ",", "name", "=", "None", ")", ":", "# pylint: disable-msg=W0613", "if", "name", "is", "None", ":", "name", "=", "schema", "if", "not", "_lists", ".", "has_key", "(", "name", ")", ":", "return", "False", "try",...
!~~isIn(data)
[ "!~~isIn", "(", "data", ")" ]
python
train
19.285714
google/flatbuffers
python/flatbuffers/builder.py
https://github.com/google/flatbuffers/blob/6cc30b3272d79c85db7d4871ac0aa69541dc89de/python/flatbuffers/builder.py#L498-L509
def assertStructIsInline(self, obj): """ Structs are always stored inline, so need to be created right where they are used. You'll get this error if you created it elsewhere. """ N.enforce_number(obj, N.UOffsetTFlags) if obj != self.Offset(): msg = ("...
[ "def", "assertStructIsInline", "(", "self", ",", "obj", ")", ":", "N", ".", "enforce_number", "(", "obj", ",", "N", ".", "UOffsetTFlags", ")", "if", "obj", "!=", "self", ".", "Offset", "(", ")", ":", "msg", "=", "(", "\"flatbuffers: Tried to write a Struct...
Structs are always stored inline, so need to be created right where they are used. You'll get this error if you created it elsewhere.
[ "Structs", "are", "always", "stored", "inline", "so", "need", "to", "be", "created", "right", "where", "they", "are", "used", ".", "You", "ll", "get", "this", "error", "if", "you", "created", "it", "elsewhere", "." ]
python
train
40.5
sony/nnabla
python/src/nnabla/parametric_functions.py
https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/parametric_functions.py#L1910-L2017
def fixed_point_quantized_convolution(inp, outmaps, kernel, pad=None, stride=None, dilation=None, group=1, w_init=None, b_init=None, base_axis=1, fix_parameters=False, rng=None, with_bias=True, ...
[ "def", "fixed_point_quantized_convolution", "(", "inp", ",", "outmaps", ",", "kernel", ",", "pad", "=", "None", ",", "stride", "=", "None", ",", "dilation", "=", "None", ",", "group", "=", "1", ",", "w_init", "=", "None", ",", "b_init", "=", "None", ",...
Fixed-Point Quantized Convolution. Fixed-Point Quantized Convolution is the convolution function, except the definition of the inner product is modified. The input-output relation of this function is as follows: .. math:: y_{n, a, b} = \sum_{m} \sum_{i} \sum_{j} Q(w_{n, m, i, j}) x_{m, a + i,...
[ "Fixed", "-", "Point", "Quantized", "Convolution", "." ]
python
train
51.805556
tanghaibao/goatools
goatools/parsers/ncbi_gene_file_reader.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/parsers/ncbi_gene_file_reader.py#L112-L144
def get_nts(self): """Read csv/tsv file and return specified data in a list of lists.""" data = [] nt_obj = None with open(self.fin) as fin_stream: for lnum, line in enumerate(fin_stream, 1): try: line = line.rstrip('\r\n') # chomp ...
[ "def", "get_nts", "(", "self", ")", ":", "data", "=", "[", "]", "nt_obj", "=", "None", "with", "open", "(", "self", ".", "fin", ")", "as", "fin_stream", ":", "for", "lnum", ",", "line", "in", "enumerate", "(", "fin_stream", ",", "1", ")", ":", "t...
Read csv/tsv file and return specified data in a list of lists.
[ "Read", "csv", "/", "tsv", "file", "and", "return", "specified", "data", "in", "a", "list", "of", "lists", "." ]
python
train
50
nesaro/pydsl
pydsl/contrib/grammar/calc_ply.py
https://github.com/nesaro/pydsl/blob/00b4fffd72036b80335e1a44a888fac57917ab41/pydsl/contrib/grammar/calc_ply.py#L66-L74
def p_expression_binop(t): '''expression : expression PLUS expression | expression MINUS expression | expression TIMES expression | expression DIVIDE expression''' if t[2] == '+' : t[0] = t[1] + t[3] elif t[2] == '-': t[0] = t[1] - t[3] elif t[2] ==...
[ "def", "p_expression_binop", "(", "t", ")", ":", "if", "t", "[", "2", "]", "==", "'+'", ":", "t", "[", "0", "]", "=", "t", "[", "1", "]", "+", "t", "[", "3", "]", "elif", "t", "[", "2", "]", "==", "'-'", ":", "t", "[", "0", "]", "=", ...
expression : expression PLUS expression | expression MINUS expression | expression TIMES expression | expression DIVIDE expression
[ "expression", ":", "expression", "PLUS", "expression", "|", "expression", "MINUS", "expression", "|", "expression", "TIMES", "expression", "|", "expression", "DIVIDE", "expression" ]
python
train
41.888889
johnnoone/aioconsul
aioconsul/client/query_endpoint.py
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/query_endpoint.py#L56-L180
async def create(self, query, *, dc=None): """Creates a new prepared query Parameters: Query (Object): Query definition dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. Returns: Object: New query ...
[ "async", "def", "create", "(", "self", ",", "query", ",", "*", ",", "dc", "=", "None", ")", ":", "if", "\"Token\"", "in", "query", ":", "# in case of a full token object...", "query", "[", "\"Token\"", "]", "=", "extract_attr", "(", "query", "[", "\"Token\...
Creates a new prepared query Parameters: Query (Object): Query definition dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. Returns: Object: New query ID The create operation expects a body that d...
[ "Creates", "a", "new", "prepared", "query" ]
python
train
48.464
assemblerflow/flowcraft
flowcraft/templates/process_assembly_mapping.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/templates/process_assembly_mapping.py#L560-L628
def main(sample_id, assembly_file, coverage_file, coverage_bp_file, bam_file, opts, gsize): """Main executor of the process_assembly_mapping template. Parameters ---------- sample_id : str Sample Identification string. assembly_file : str Path to assembly file in Fasta form...
[ "def", "main", "(", "sample_id", ",", "assembly_file", ",", "coverage_file", ",", "coverage_bp_file", ",", "bam_file", ",", "opts", ",", "gsize", ")", ":", "min_assembly_coverage", ",", "max_contigs", "=", "opts", "logger", ".", "info", "(", "\"Starting assembly...
Main executor of the process_assembly_mapping template. Parameters ---------- sample_id : str Sample Identification string. assembly_file : str Path to assembly file in Fasta format. coverage_file : str Path to TSV file with coverage information for each contig. coverage...
[ "Main", "executor", "of", "the", "process_assembly_mapping", "template", "." ]
python
test
41.724638
petl-developers/petl
petl/util/counting.py
https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/util/counting.py#L58-L84
def valuecounter(table, *field, **kwargs): """ Find distinct values for the given field and count the number of occurrences. Returns a :class:`dict` mapping values to counts. E.g.:: >>> import petl as etl >>> table = [['foo', 'bar'], ... ['a', True], ... ['...
[ "def", "valuecounter", "(", "table", ",", "*", "field", ",", "*", "*", "kwargs", ")", ":", "missing", "=", "kwargs", ".", "get", "(", "'missing'", ",", "None", ")", "counter", "=", "Counter", "(", ")", "for", "v", "in", "values", "(", "table", ",",...
Find distinct values for the given field and count the number of occurrences. Returns a :class:`dict` mapping values to counts. E.g.:: >>> import petl as etl >>> table = [['foo', 'bar'], ... ['a', True], ... ['b'], ... ['b', True], ... ...
[ "Find", "distinct", "values", "for", "the", "given", "field", "and", "count", "the", "number", "of", "occurrences", ".", "Returns", "a", ":", "class", ":", "dict", "mapping", "values", "to", "counts", ".", "E", ".", "g", ".", "::" ]
python
train
30.592593
wonambi-python/wonambi
wonambi/ioeeg/wonambi.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/ioeeg/wonambi.py#L120-L168
def write_wonambi(data, filename, subj_id='', dtype='float64'): """Write file in simple Wonambi format. Parameters ---------- data : instance of ChanTime data with only one trial filename : path to file file to export to (the extensions .won and .dat will be added) subj_id : str...
[ "def", "write_wonambi", "(", "data", ",", "filename", ",", "subj_id", "=", "''", ",", "dtype", "=", "'float64'", ")", ":", "filename", "=", "Path", "(", "filename", ")", "json_file", "=", "filename", ".", "with_suffix", "(", "'.won'", ")", "memmap_file", ...
Write file in simple Wonambi format. Parameters ---------- data : instance of ChanTime data with only one trial filename : path to file file to export to (the extensions .won and .dat will be added) subj_id : str subject id dtype : str numpy dtype in which you wa...
[ "Write", "file", "in", "simple", "Wonambi", "format", "." ]
python
train
31.163265
happyleavesaoc/python-limitlessled
limitlessled/util.py
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/util.py#L48-L59
def steps(current, target, max_steps): """ Steps between two values. :param current: Current value (0.0-1.0). :param target: Target value (0.0-1.0). :param max_steps: Maximum number of steps. """ if current < 0 or current > 1.0: raise ValueError("current value %s is out of bounds (0.0-1...
[ "def", "steps", "(", "current", ",", "target", ",", "max_steps", ")", ":", "if", "current", "<", "0", "or", "current", ">", "1.0", ":", "raise", "ValueError", "(", "\"current value %s is out of bounds (0.0-1.0)\"", ",", "current", ")", "if", "target", "<", "...
Steps between two values. :param current: Current value (0.0-1.0). :param target: Target value (0.0-1.0). :param max_steps: Maximum number of steps.
[ "Steps", "between", "two", "values", "." ]
python
train
41.916667
alpacahq/pipeline-live
pipeline_live/engine.py
https://github.com/alpacahq/pipeline-live/blob/6f42d64354a17e2546ca74f18004454f2019bd83/pipeline_live/engine.py#L341-L369
def _validate_compute_chunk_params( self, dates, symbols, initial_workspace): """ Verify that the values passed to compute_chunk are well-formed. """ root = self._root_mask_term clsname = type(self).__name__ # Writing this out explicitly so this errors in tes...
[ "def", "_validate_compute_chunk_params", "(", "self", ",", "dates", ",", "symbols", ",", "initial_workspace", ")", ":", "root", "=", "self", ".", "_root_mask_term", "clsname", "=", "type", "(", "self", ")", ".", "__name__", "# Writing this out explicitly so this err...
Verify that the values passed to compute_chunk are well-formed.
[ "Verify", "that", "the", "values", "passed", "to", "compute_chunk", "are", "well", "-", "formed", "." ]
python
train
37.413793
Alignak-monitoring/alignak
alignak/objects/host.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/host.py#L275-L302
def convert_conf_for_unreachable(params): """ The 'u' state for UNREACHABLE has been rewritten in 'x' in: * flap_detection_options * notification_options * snapshot_criteria So convert value from config file to keep compatibility with Nagios :param params: param...
[ "def", "convert_conf_for_unreachable", "(", "params", ")", ":", "if", "params", "is", "None", ":", "return", "for", "prop", "in", "[", "'flap_detection_options'", ",", "'notification_options'", ",", "'snapshot_criteria'", ",", "'stalking_options'", "]", ":", "if", ...
The 'u' state for UNREACHABLE has been rewritten in 'x' in: * flap_detection_options * notification_options * snapshot_criteria So convert value from config file to keep compatibility with Nagios :param params: parameters of the host before put in properties :type param...
[ "The", "u", "state", "for", "UNREACHABLE", "has", "been", "rewritten", "in", "x", "in", ":", "*", "flap_detection_options", "*", "notification_options", "*", "snapshot_criteria" ]
python
train
36.964286
opencobra/cobrapy
cobra/util/array.py
https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/util/array.py#L18-L71
def create_stoichiometric_matrix(model, array_type='dense', dtype=None): """Return a stoichiometric array representation of the given model. The the columns represent the reactions and rows represent metabolites. S[i,j] therefore contains the quantity of metabolite `i` produced (negative for consumed) ...
[ "def", "create_stoichiometric_matrix", "(", "model", ",", "array_type", "=", "'dense'", ",", "dtype", "=", "None", ")", ":", "if", "array_type", "not", "in", "(", "'DataFrame'", ",", "'dense'", ")", "and", "not", "dok_matrix", ":", "raise", "ValueError", "("...
Return a stoichiometric array representation of the given model. The the columns represent the reactions and rows represent metabolites. S[i,j] therefore contains the quantity of metabolite `i` produced (negative for consumed) by reaction `j`. Parameters ---------- model : cobra.Model ...
[ "Return", "a", "stoichiometric", "array", "representation", "of", "the", "given", "model", "." ]
python
valid
35.851852
wavefrontHQ/python-client
wavefront_api_client/api/user_api.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/user_api.py#L610-L631
def grant_permission_to_users(self, permission, **kwargs): # noqa: E501 """Grants a specific user permission to multiple users # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True ...
[ "def", "grant_permission_to_users", "(", "self", ",", "permission", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", "....
Grants a specific user permission to multiple users # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.grant_permission_to_users(permission, async_req=True) >>> r...
[ "Grants", "a", "specific", "user", "permission", "to", "multiple", "users", "#", "noqa", ":", "E501" ]
python
train
53.136364
thanethomson/statik
statik/templating.py
https://github.com/thanethomson/statik/blob/56b1b5a2cb05a97afa81f428bfcefc833e935b8d/statik/templating.py#L197-L210
def create_template(self, s, provider_name=None): """Creates a template from the given string based on the specified provider or the provider with highest precedence. Args: s: The string to convert to a template. provider_name: The name of the provider to use to create t...
[ "def", "create_template", "(", "self", ",", "s", ",", "provider_name", "=", "None", ")", ":", "if", "provider_name", "is", "None", ":", "provider_name", "=", "self", ".", "supported_providers", "[", "0", "]", "return", "template_exception_handler", "(", "lambd...
Creates a template from the given string based on the specified provider or the provider with highest precedence. Args: s: The string to convert to a template. provider_name: The name of the provider to use to create the template.
[ "Creates", "a", "template", "from", "the", "given", "string", "based", "on", "the", "specified", "provider", "or", "the", "provider", "with", "highest", "precedence", "." ]
python
train
41.285714
openid/python-openid
openid/extensions/ax.py
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/ax.py#L72-L86
def _checkMode(self, ax_args): """Raise an exception if the mode in the attribute exchange arguments does not match what is expected for this class. @raises NotAXMessage: When there is no mode value in ax_args at all. @raises AXError: When mode does not match. """ mode ...
[ "def", "_checkMode", "(", "self", ",", "ax_args", ")", ":", "mode", "=", "ax_args", ".", "get", "(", "'mode'", ")", "if", "mode", "!=", "self", ".", "mode", ":", "if", "not", "mode", ":", "raise", "NotAXMessage", "(", ")", "else", ":", "raise", "AX...
Raise an exception if the mode in the attribute exchange arguments does not match what is expected for this class. @raises NotAXMessage: When there is no mode value in ax_args at all. @raises AXError: When mode does not match.
[ "Raise", "an", "exception", "if", "the", "mode", "in", "the", "attribute", "exchange", "arguments", "does", "not", "match", "what", "is", "expected", "for", "this", "class", "." ]
python
train
35.733333
HDI-Project/ballet
ballet/validation/feature_api/checks.py
https://github.com/HDI-Project/ballet/blob/6f4d4b87b8234cb6bb38b9e9484a58ef8fe8fdb2/ballet/validation/feature_api/checks.py#L61-L64
def check(self, feature): """Check that fit can be called on reference data""" mapper = feature.as_dataframe_mapper() mapper.fit(self.X, y=self.y)
[ "def", "check", "(", "self", ",", "feature", ")", ":", "mapper", "=", "feature", ".", "as_dataframe_mapper", "(", ")", "mapper", ".", "fit", "(", "self", ".", "X", ",", "y", "=", "self", ".", "y", ")" ]
Check that fit can be called on reference data
[ "Check", "that", "fit", "can", "be", "called", "on", "reference", "data" ]
python
train
41.75
pybel/pybel-tools
src/pybel_tools/utils.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L268-L277
def get_circulations(elements: T) -> Iterable[T]: """Iterate over all possible circulations of an ordered collection (tuple or list). Example: >>> list(get_circulations([1, 2, 3])) [[1, 2, 3], [2, 3, 1], [3, 1, 2]] """ for i in range(len(elements)): yield elements[i:] + elements[:i]
[ "def", "get_circulations", "(", "elements", ":", "T", ")", "->", "Iterable", "[", "T", "]", ":", "for", "i", "in", "range", "(", "len", "(", "elements", ")", ")", ":", "yield", "elements", "[", "i", ":", "]", "+", "elements", "[", ":", "i", "]" ]
Iterate over all possible circulations of an ordered collection (tuple or list). Example: >>> list(get_circulations([1, 2, 3])) [[1, 2, 3], [2, 3, 1], [3, 1, 2]]
[ "Iterate", "over", "all", "possible", "circulations", "of", "an", "ordered", "collection", "(", "tuple", "or", "list", ")", "." ]
python
valid
30.8
tdryer/hangups
hangups/client.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/client.py#L400-L436
async def _pb_request(self, endpoint, request_pb, response_pb): """Send a Protocol Buffer formatted chat API request. Args: endpoint (str): The chat API endpoint to use. request_pb: The request body as a Protocol Buffer message. response_pb: The response body as a Pr...
[ "async", "def", "_pb_request", "(", "self", ",", "endpoint", ",", "request_pb", ",", "response_pb", ")", ":", "logger", ".", "debug", "(", "'Sending Protocol Buffer request %s:\\n%s'", ",", "endpoint", ",", "request_pb", ")", "res", "=", "await", "self", ".", ...
Send a Protocol Buffer formatted chat API request. Args: endpoint (str): The chat API endpoint to use. request_pb: The request body as a Protocol Buffer message. response_pb: The response body as a Protocol Buffer message. Raises: NetworkError: If the re...
[ "Send", "a", "Protocol", "Buffer", "formatted", "chat", "API", "request", "." ]
python
valid
43.918919
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L1132-L1136
def dynamic_content_item_show(self, id, **kwargs): "https://developer.zendesk.com/rest_api/docs/core/dynamic_content#show-item" api_path = "/api/v2/dynamic_content/items/{id}.json" api_path = api_path.format(id=id) return self.call(api_path, **kwargs)
[ "def", "dynamic_content_item_show", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/dynamic_content/items/{id}.json\"", "api_path", "=", "api_path", ".", "format", "(", "id", "=", "id", ")", "return", "self", ".", "call",...
https://developer.zendesk.com/rest_api/docs/core/dynamic_content#show-item
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "dynamic_content#show", "-", "item" ]
python
train
55.8
OpenAgInitiative/openag_python
openag/cli/db/__init__.py
https://github.com/OpenAgInitiative/openag_python/blob/f6202340292bbf7185e1a7d4290188c0dacbb8d0/openag/cli/db/__init__.py#L177-L195
def update_module_types(): """ Download the repositories for all of the firmware_module_type records and update them using the `module.json` files from the repositories themselves. Currently only works for git repositories. """ local_url = config["local_server"]["url"] server = Server(local_...
[ "def", "update_module_types", "(", ")", ":", "local_url", "=", "config", "[", "\"local_server\"", "]", "[", "\"url\"", "]", "server", "=", "Server", "(", "local_url", ")", "db", "=", "server", "[", "FIRMWARE_MODULE_TYPE", "]", "temp_folder", "=", "mkdtemp", ...
Download the repositories for all of the firmware_module_type records and update them using the `module.json` files from the repositories themselves. Currently only works for git repositories.
[ "Download", "the", "repositories", "for", "all", "of", "the", "firmware_module_type", "records", "and", "update", "them", "using", "the", "module", ".", "json", "files", "from", "the", "repositories", "themselves", ".", "Currently", "only", "works", "for", "git"...
python
train
34.473684
elastic/elasticsearch-dsl-py
elasticsearch_dsl/update_by_query.py
https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/update_by_query.py#L78-L89
def update_from_dict(self, d): """ Apply options from a serialized body to the current instance. Modifies the object in-place. Used mostly by ``from_dict``. """ d = d.copy() if 'query' in d: self.query._proxied = Q(d.pop('query')) if 'script' in d: ...
[ "def", "update_from_dict", "(", "self", ",", "d", ")", ":", "d", "=", "d", ".", "copy", "(", ")", "if", "'query'", "in", "d", ":", "self", ".", "query", ".", "_proxied", "=", "Q", "(", "d", ".", "pop", "(", "'query'", ")", ")", "if", "'script'"...
Apply options from a serialized body to the current instance. Modifies the object in-place. Used mostly by ``from_dict``.
[ "Apply", "options", "from", "a", "serialized", "body", "to", "the", "current", "instance", ".", "Modifies", "the", "object", "in", "-", "place", ".", "Used", "mostly", "by", "from_dict", "." ]
python
train
32.666667
pantsbuild/pants
src/python/pants/cache/artifact_cache.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/cache/artifact_cache.py#L78-L104
def insert(self, cache_key, paths, overwrite=False): """Cache the output of a build. By default, checks cache.has(key) first, only proceeding to create and insert an artifact if it is not already in the cache (though `overwrite` can be used to skip the check and unconditionally insert). :param Cac...
[ "def", "insert", "(", "self", ",", "cache_key", ",", "paths", ",", "overwrite", "=", "False", ")", ":", "missing_files", "=", "[", "f", "for", "f", "in", "paths", "if", "not", "os", ".", "path", ".", "exists", "(", "f", ")", "]", "if", "missing_fil...
Cache the output of a build. By default, checks cache.has(key) first, only proceeding to create and insert an artifact if it is not already in the cache (though `overwrite` can be used to skip the check and unconditionally insert). :param CacheKey cache_key: A CacheKey object. :param list<str> pat...
[ "Cache", "the", "output", "of", "a", "build", "." ]
python
train
41.037037
Metatab/metapack
metapack/appurl.py
https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L136-L149
def resolve_url(self, resource_name): """Return a URL to a local copy of a resource, suitable for get_generator()""" if self.target_format == 'csv' and self.target_file != DEFAULT_METATAB_FILE: # For CSV packages, need to get the package and open it to get the resoruce URL, becuase ...
[ "def", "resolve_url", "(", "self", ",", "resource_name", ")", ":", "if", "self", ".", "target_format", "==", "'csv'", "and", "self", ".", "target_file", "!=", "DEFAULT_METATAB_FILE", ":", "# For CSV packages, need to get the package and open it to get the resoruce URL, becu...
Return a URL to a local copy of a resource, suitable for get_generator()
[ "Return", "a", "URL", "to", "a", "local", "copy", "of", "a", "resource", "suitable", "for", "get_generator", "()" ]
python
train
48.071429
googleapis/google-cloud-python
api_core/google/api_core/datetime_helpers.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/datetime_helpers.py#L229-L267
def from_rfc3339(cls, stamp): """Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (str): RFC 3339 stamp, with up to nanosecond precision Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp string ...
[ "def", "from_rfc3339", "(", "cls", ",", "stamp", ")", ":", "with_nanos", "=", "_RFC3339_NANOS", ".", "match", "(", "stamp", ")", "if", "with_nanos", "is", "None", ":", "raise", "ValueError", "(", "\"Timestamp: {}, does not match pattern: {}\"", ".", "format", "(...
Parse RFC 3339-compliant timestamp, preserving nanoseconds. Args: stamp (str): RFC 3339 stamp, with up to nanosecond precision Returns: :class:`DatetimeWithNanoseconds`: an instance matching the timestamp string Raises: ValueError: if `stamp...
[ "Parse", "RFC", "3339", "-", "compliant", "timestamp", "preserving", "nanoseconds", "." ]
python
train
30.230769