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
tommikaikkonen/prettyprinter
prettyprinter/prettyprinter.py
https://github.com/tommikaikkonen/prettyprinter/blob/6b405884b8085eaf867e81c02b7b662b463ac5a0/prettyprinter/prettyprinter.py#L462-L544
def register_pretty(type=None, predicate=None): """Returns a decorator that registers the decorated function as the pretty printer for instances of ``type``. :param type: the type to register the pretty printer for, or a ``str`` to indicate the module and name, e.g.: ``'collections.Counter...
[ "def", "register_pretty", "(", "type", "=", "None", ",", "predicate", "=", "None", ")", ":", "if", "type", "is", "None", "and", "predicate", "is", "None", ":", "raise", "ValueError", "(", "\"You must provide either the 'type' or 'predicate' argument.\"", ")", "if"...
Returns a decorator that registers the decorated function as the pretty printer for instances of ``type``. :param type: the type to register the pretty printer for, or a ``str`` to indicate the module and name, e.g.: ``'collections.Counter'``. :param predicate: a predicate function that ta...
[ "Returns", "a", "decorator", "that", "registers", "the", "decorated", "function", "as", "the", "pretty", "printer", "for", "instances", "of", "type", "." ]
python
train
33.698795
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L900-L904
def update_ipsec_site_connection(self, ipsecsite_conn, body=None): """Updates an IPsecSiteConnection.""" return self.put( self.ipsec_site_connection_path % (ipsecsite_conn), body=body )
[ "def", "update_ipsec_site_connection", "(", "self", ",", "ipsecsite_conn", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "ipsec_site_connection_path", "%", "(", "ipsecsite_conn", ")", ",", "body", "=", "body", ")" ]
Updates an IPsecSiteConnection.
[ "Updates", "an", "IPsecSiteConnection", "." ]
python
train
43.4
RudolfCardinal/pythonlib
cardinal_pythonlib/rnc_text.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_text.py#L540-L549
def dictlist_convert_to_float(dict_list: Iterable[Dict], key: str) -> None: """ Process an iterable of dictionaries. For each dictionary ``d``, convert (in place) ``d[key]`` to a float. If that fails, convert it to ``None``. """ for d in dict_list: try: d[key] = float(d[key]) ...
[ "def", "dictlist_convert_to_float", "(", "dict_list", ":", "Iterable", "[", "Dict", "]", ",", "key", ":", "str", ")", "->", "None", ":", "for", "d", "in", "dict_list", ":", "try", ":", "d", "[", "key", "]", "=", "float", "(", "d", "[", "key", "]", ...
Process an iterable of dictionaries. For each dictionary ``d``, convert (in place) ``d[key]`` to a float. If that fails, convert it to ``None``.
[ "Process", "an", "iterable", "of", "dictionaries", ".", "For", "each", "dictionary", "d", "convert", "(", "in", "place", ")", "d", "[", "key", "]", "to", "a", "float", ".", "If", "that", "fails", "convert", "it", "to", "None", "." ]
python
train
36
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L2304-L2325
def PlayWaveFile(filePath: str = r'C:\Windows\Media\notify.wav', isAsync: bool = False, isLoop: bool = False) -> bool: """ Call PlaySound from Win32. filePath: str, if emtpy, stop playing the current sound. isAsync: bool, if True, the sound is played asynchronously and returns immediately. isLoop: b...
[ "def", "PlayWaveFile", "(", "filePath", ":", "str", "=", "r'C:\\Windows\\Media\\notify.wav'", ",", "isAsync", ":", "bool", "=", "False", ",", "isLoop", ":", "bool", "=", "False", ")", "->", "bool", ":", "if", "filePath", ":", "SND_ASYNC", "=", "0x0001", "S...
Call PlaySound from Win32. filePath: str, if emtpy, stop playing the current sound. isAsync: bool, if True, the sound is played asynchronously and returns immediately. isLoop: bool, if True, the sound plays repeatedly until PlayWaveFile(None) is called again, must also set isAsync to True. Return bool, ...
[ "Call", "PlaySound", "from", "Win32", ".", "filePath", ":", "str", "if", "emtpy", "stop", "playing", "the", "current", "sound", ".", "isAsync", ":", "bool", "if", "True", "the", "sound", "is", "played", "asynchronously", "and", "returns", "immediately", ".",...
python
valid
45.045455
owncloud/pyocclient
owncloud/owncloud.py
https://github.com/owncloud/pyocclient/blob/b9e1f04cdbde74588e86f1bebb6144571d82966c/owncloud/owncloud.py#L1440-L1467
def get_config(self): """Returns ownCloud config information :returns: array of tuples (key, value) for each information e.g. [('version', '1.7'), ('website', 'ownCloud'), ('host', 'cloud.example.com'), ('contact', ''), ('ssl', 'false')] :raises: HTTPResponseError in case...
[ "def", "get_config", "(", "self", ")", ":", "path", "=", "'config'", "res", "=", "self", ".", "_make_ocs_request", "(", "'GET'", ",", "''", ",", "path", ")", "if", "res", ".", "status_code", "==", "200", ":", "tree", "=", "ET", ".", "fromstring", "("...
Returns ownCloud config information :returns: array of tuples (key, value) for each information e.g. [('version', '1.7'), ('website', 'ownCloud'), ('host', 'cloud.example.com'), ('contact', ''), ('ssl', 'false')] :raises: HTTPResponseError in case an HTTP error status was returne...
[ "Returns", "ownCloud", "config", "information", ":", "returns", ":", "array", "of", "tuples", "(", "key", "value", ")", "for", "each", "information", "e", ".", "g", ".", "[", "(", "version", "1", ".", "7", ")", "(", "website", "ownCloud", ")", "(", "...
python
train
36.107143
CartoDB/cartoframes
cartoframes/context.py
https://github.com/CartoDB/cartoframes/blob/c94238a545f3dec45963dac3892540942b6f0df8/cartoframes/context.py#L934-L969
def _geom_type(self, source): """gets geometry type(s) of specified layer""" if isinstance(source, AbstractLayer): query = source.orig_query else: query = 'SELECT * FROM "{table}"'.format(table=source) resp = self.sql_client.send( utils.minify_sql(( ...
[ "def", "_geom_type", "(", "self", ",", "source", ")", ":", "if", "isinstance", "(", "source", ",", "AbstractLayer", ")", ":", "query", "=", "source", ".", "orig_query", "else", ":", "query", "=", "'SELECT * FROM \"{table}\"'", ".", "format", "(", "table", ...
gets geometry type(s) of specified layer
[ "gets", "geometry", "type", "(", "s", ")", "of", "specified", "layer" ]
python
train
48.527778
inveniosoftware/kwalitee
kwalitee/kwalitee.py
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/kwalitee.py#L92-L126
def _check_1st_line(line, **kwargs): """First line check. Check that the first line has a known component name followed by a colon and then a short description of the commit. :param line: first line :type line: str :param components: list of known component names :type line: list :para...
[ "def", "_check_1st_line", "(", "line", ",", "*", "*", "kwargs", ")", ":", "components", "=", "kwargs", ".", "get", "(", "\"components\"", ",", "(", ")", ")", "max_first_line", "=", "kwargs", ".", "get", "(", "\"max_first_line\"", ",", "50", ")", "errors"...
First line check. Check that the first line has a known component name followed by a colon and then a short description of the commit. :param line: first line :type line: str :param components: list of known component names :type line: list :param max_first_line: maximum length of the firs...
[ "First", "line", "check", "." ]
python
train
28
andreafrancia/trash-cli
trashcli/put.py
https://github.com/andreafrancia/trash-cli/blob/5abecd53e1d84f2a5fd3fc60d2f5d71e518826c5/trashcli/put.py#L273-L308
def describe(path): """ Return a textual description of the file pointed by this path. Options: - "symbolic link" - "directory" - "'.' directory" - "'..' directory" - "regular file" - "regular empty file" - "non existent" - "entry" """ if os.path.islink(path):...
[ "def", "describe", "(", "path", ")", ":", "if", "os", ".", "path", ".", "islink", "(", "path", ")", ":", "return", "'symbolic link'", "elif", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "path", "==", "'.'", ":", "return", "'direct...
Return a textual description of the file pointed by this path. Options: - "symbolic link" - "directory" - "'.' directory" - "'..' directory" - "regular file" - "regular empty file" - "non existent" - "entry"
[ "Return", "a", "textual", "description", "of", "the", "file", "pointed", "by", "this", "path", ".", "Options", ":", "-", "symbolic", "link", "-", "directory", "-", ".", "directory", "-", "..", "directory", "-", "regular", "file", "-", "regular", "empty", ...
python
valid
26.555556
CitrineInformatics/pif-dft
dfttopif/parsers/pwscf.py
https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L171-L183
def get_pp_name(self): '''Determine the pseudopotential names from the output''' ppnames = [] # Find the number of atom types natomtypes = int(self._get_line('number of atomic types', self.outputf).split()[5]) # Find the pseudopotential names with open(self.outputf) as fp...
[ "def", "get_pp_name", "(", "self", ")", ":", "ppnames", "=", "[", "]", "# Find the number of atom types", "natomtypes", "=", "int", "(", "self", ".", "_get_line", "(", "'number of atomic types'", ",", "self", ".", "outputf", ")", ".", "split", "(", ")", "[",...
Determine the pseudopotential names from the output
[ "Determine", "the", "pseudopotential", "names", "from", "the", "output" ]
python
train
50
google/textfsm
textfsm/clitable.py
https://github.com/google/textfsm/blob/63a2aaece33e07947aa80963dca99b893964633b/textfsm/clitable.py#L288-L313
def _ParseCmdItem(self, cmd_input, template_file=None): """Creates Texttable with output of command. Args: cmd_input: String, Device response. template_file: File object, template to parse with. Returns: TextTable containing command output. Raises: CliTableError: A template wa...
[ "def", "_ParseCmdItem", "(", "self", ",", "cmd_input", ",", "template_file", "=", "None", ")", ":", "# Build FSM machine from the template.", "fsm", "=", "textfsm", ".", "TextFSM", "(", "template_file", ")", "if", "not", "self", ".", "_keys", ":", "self", ".",...
Creates Texttable with output of command. Args: cmd_input: String, Device response. template_file: File object, template to parse with. Returns: TextTable containing command output. Raises: CliTableError: A template was not found for the given command.
[ "Creates", "Texttable", "with", "output", "of", "command", "." ]
python
train
27.923077
UCL-INGI/INGInious
base-containers/base/inginious/feedback.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/base-containers/base/inginious/feedback.py#L108-L116
def tag(value): """ Add a tag with generated id. :param value: everything working with the str() function """ rdict = load_feedback() tests = rdict.setdefault("tests", {}) tests["*auto-tag-" + str(hash(str(value)))] = str(value) save_feedback(rdict)
[ "def", "tag", "(", "value", ")", ":", "rdict", "=", "load_feedback", "(", ")", "tests", "=", "rdict", ".", "setdefault", "(", "\"tests\"", ",", "{", "}", ")", "tests", "[", "\"*auto-tag-\"", "+", "str", "(", "hash", "(", "str", "(", "value", ")", "...
Add a tag with generated id. :param value: everything working with the str() function
[ "Add", "a", "tag", "with", "generated", "id", ".", ":", "param", "value", ":", "everything", "working", "with", "the", "str", "()", "function" ]
python
train
30.333333
aiortc/aioice
aioice/ice.py
https://github.com/aiortc/aioice/blob/a04d810d94ec2d00eca9ce01eacca74b3b086616/aioice/ice.py#L656-L661
def check_state(self, pair, state): """ Updates the state of a check. """ self.__log_info('Check %s %s -> %s', pair, pair.state, state) pair.state = state
[ "def", "check_state", "(", "self", ",", "pair", ",", "state", ")", ":", "self", ".", "__log_info", "(", "'Check %s %s -> %s'", ",", "pair", ",", "pair", ".", "state", ",", "state", ")", "pair", ".", "state", "=", "state" ]
Updates the state of a check.
[ "Updates", "the", "state", "of", "a", "check", "." ]
python
train
31.5
SmileyChris/easy-thumbnails
easy_thumbnails/files.py
https://github.com/SmileyChris/easy-thumbnails/blob/b08ab44883bf7b221a98dadb9b589cb95d35b0bf/easy_thumbnails/files.py#L461-L488
def get_existing_thumbnail(self, thumbnail_options, high_resolution=False): """ Return a ``ThumbnailFile`` containing an existing thumbnail for a set of thumbnail options, or ``None`` if not found. """ thumbnail_options = self.get_options(thumbnail_options) names = [ ...
[ "def", "get_existing_thumbnail", "(", "self", ",", "thumbnail_options", ",", "high_resolution", "=", "False", ")", ":", "thumbnail_options", "=", "self", ".", "get_options", "(", "thumbnail_options", ")", "names", "=", "[", "self", ".", "get_thumbnail_name", "(", ...
Return a ``ThumbnailFile`` containing an existing thumbnail for a set of thumbnail options, or ``None`` if not found.
[ "Return", "a", "ThumbnailFile", "containing", "an", "existing", "thumbnail", "for", "a", "set", "of", "thumbnail", "options", "or", "None", "if", "not", "found", "." ]
python
train
46.607143
benoitkugler/abstractDataLibrary
pyDLib/Core/controller.py
https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/controller.py#L129-L153
def launch_background_job(self, job, on_error=None, on_success=None): """Launch the callable job in background thread. Succes or failure are controlled by on_error and on_success """ if not self.main.mode_online: self.sortie_erreur_GUI( "Local mode activated. ...
[ "def", "launch_background_job", "(", "self", ",", "job", ",", "on_error", "=", "None", ",", "on_success", "=", "None", ")", ":", "if", "not", "self", ".", "main", ".", "mode_online", ":", "self", ".", "sortie_erreur_GUI", "(", "\"Local mode activated. Can't ru...
Launch the callable job in background thread. Succes or failure are controlled by on_error and on_success
[ "Launch", "the", "callable", "job", "in", "background", "thread", ".", "Succes", "or", "failure", "are", "controlled", "by", "on_error", "and", "on_success" ]
python
train
33.64
fabioz/PyDev.Debugger
_pydevd_bundle/pydevd_dont_trace.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydevd_bundle/pydevd_dont_trace.py#L84-L101
def clear_trace_filter_cache(): ''' Clear the trace filter cache. Call this after reloading. ''' global should_trace_hook try: # Need to temporarily disable a hook because otherwise # _filename_to_ignored_lines.clear() will never complete. old_hook = should_trace_hook ...
[ "def", "clear_trace_filter_cache", "(", ")", ":", "global", "should_trace_hook", "try", ":", "# Need to temporarily disable a hook because otherwise", "# _filename_to_ignored_lines.clear() will never complete.", "old_hook", "=", "should_trace_hook", "should_trace_hook", "=", "None", ...
Clear the trace filter cache. Call this after reloading.
[ "Clear", "the", "trace", "filter", "cache", ".", "Call", "this", "after", "reloading", "." ]
python
train
27.111111
hazelcast/hazelcast-python-client
hazelcast/proxy/transactional_multi_map.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/proxy/transactional_multi_map.py#L50-L59
def remove_all(self, key): """ Transactional implementation of :func:`MultiMap.remove_all(key) <hazelcast.proxy.multi_map.MultiMap.remove_all>` :param key: (object), the key of the entries to remove. :return: (list), the collection of the values associated with the key. ...
[ "def", "remove_all", "(", "self", ",", "key", ")", ":", "check_not_none", "(", "key", ",", "\"key can't be none\"", ")", "return", "self", ".", "_encode_invoke", "(", "transactional_multi_map_remove_codec", ",", "key", "=", "self", ".", "_to_data", "(", "key", ...
Transactional implementation of :func:`MultiMap.remove_all(key) <hazelcast.proxy.multi_map.MultiMap.remove_all>` :param key: (object), the key of the entries to remove. :return: (list), the collection of the values associated with the key.
[ "Transactional", "implementation", "of", ":", "func", ":", "MultiMap", ".", "remove_all", "(", "key", ")", "<hazelcast", ".", "proxy", ".", "multi_map", ".", "MultiMap", ".", "remove_all", ">" ]
python
train
46
tensorflow/mesh
mesh_tensorflow/ops.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L4431-L4453
def pretty_print_counters(counters): """print counters hierarchically. Each counter is a pair of a string and a number. The string can have slashes, meaning that the number also counts towards each prefix. e.g. "parameters/trainable" counts towards both "parameters" and "parameters/trainable". Args: ...
[ "def", "pretty_print_counters", "(", "counters", ")", ":", "totals", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "(", "name", ",", "val", ")", "in", "counters", ":", "prefixes", "=", "[", "name", "[", ":", "i", "]", "for", "i", "i...
print counters hierarchically. Each counter is a pair of a string and a number. The string can have slashes, meaning that the number also counts towards each prefix. e.g. "parameters/trainable" counts towards both "parameters" and "parameters/trainable". Args: counters: a list of (string, number) pair...
[ "print", "counters", "hierarchically", "." ]
python
train
31.521739
JukeboxPipeline/jukebox-core
src/jukeboxcore/reftrack.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/reftrack.py#L1579-L1588
def fetch_reference_restriction(self, ): """Fetch whether referencing is restricted :returns: True, if referencing is restricted :rtype: :class:`bool` :raises: None """ inter = self.get_refobjinter() restricted = self.status() is not None return restricte...
[ "def", "fetch_reference_restriction", "(", "self", ",", ")", ":", "inter", "=", "self", ".", "get_refobjinter", "(", ")", "restricted", "=", "self", ".", "status", "(", ")", "is", "not", "None", "return", "restricted", "or", "inter", ".", "fetch_action_restr...
Fetch whether referencing is restricted :returns: True, if referencing is restricted :rtype: :class:`bool` :raises: None
[ "Fetch", "whether", "referencing", "is", "restricted" ]
python
train
36.5
ianmiell/shutit
shutit_pexpect.py
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L671-L691
def whoami(self, note=None, loglevel=logging.DEBUG): """Returns the current user by executing "whoami". @param note: See send() @return: the output of "whoami" @rtype: string """ shutit = self.shutit shutit.handle_note(note) res = self.send_and_get_output(' command whoami',...
[ "def", "whoami", "(", "self", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "note", ")", "res", "=", "self", ".", "send_and_get_output", "(", ...
Returns the current user by executing "whoami". @param note: See send() @return: the output of "whoami" @rtype: string
[ "Returns", "the", "current", "user", "by", "executing", "whoami", "." ]
python
train
30.190476
saltstack/salt
salt/modules/mount.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1585-L1639
def _filesystems(config='/etc/filesystems', leading_key=True): ''' Return the contents of the filesystems in an OrderedDict config File containing filesystem infomation leading_key True return dictionary keyed by 'name' and value as dictionary with other keys, values (name excluded)...
[ "def", "_filesystems", "(", "config", "=", "'/etc/filesystems'", ",", "leading_key", "=", "True", ")", ":", "ret", "=", "OrderedDict", "(", ")", "lines", "=", "[", "]", "parsing_block", "=", "False", "if", "not", "os", ".", "path", ".", "isfile", "(", ...
Return the contents of the filesystems in an OrderedDict config File containing filesystem infomation leading_key True return dictionary keyed by 'name' and value as dictionary with other keys, values (name excluded) OrderedDict({ '/dir' : OrderedDict({'dev': '/dev/hd8', ......
[ "Return", "the", "contents", "of", "the", "filesystems", "in", "an", "OrderedDict" ]
python
train
35.690909
aio-libs/aiomysql
aiomysql/cursors.py
https://github.com/aio-libs/aiomysql/blob/131fb9f914739ff01a24b402d29bfd719f2d1a8b/aiomysql/cursors.py#L323-L363
async def callproc(self, procname, args=()): """Execute stored procedure procname with args Compatibility warning: PEP-249 specifies that any modified parameters must be returned. This is currently impossible as they are only available by storing them in a server variable and th...
[ "async", "def", "callproc", "(", "self", ",", "procname", ",", "args", "=", "(", ")", ")", ":", "conn", "=", "self", ".", "_get_db", "(", ")", "if", "self", ".", "_echo", ":", "logger", ".", "info", "(", "\"CALL %s\"", ",", "procname", ")", "logger...
Execute stored procedure procname with args Compatibility warning: PEP-249 specifies that any modified parameters must be returned. This is currently impossible as they are only available by storing them in a server variable and then retrieved by a query. Since stored procedures...
[ "Execute", "stored", "procedure", "procname", "with", "args" ]
python
train
45.317073
benoitbryon/rst2rst
rst2rst/writer.py
https://github.com/benoitbryon/rst2rst/blob/976eef709aacb1facc8dca87cf7032f01d53adfe/rst2rst/writer.py#L156-L159
def indent(self, levels, first_line=None): """Increase indentation by ``levels`` levels.""" self._indentation_levels.append(levels) self._indent_first_line.append(first_line)
[ "def", "indent", "(", "self", ",", "levels", ",", "first_line", "=", "None", ")", ":", "self", ".", "_indentation_levels", ".", "append", "(", "levels", ")", "self", ".", "_indent_first_line", ".", "append", "(", "first_line", ")" ]
Increase indentation by ``levels`` levels.
[ "Increase", "indentation", "by", "levels", "levels", "." ]
python
train
48.75
pandas-dev/pandas
pandas/core/computation/scope.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/computation/scope.py#L243-L260
def update(self, level): """Update the current scope by going back `level` levels. Parameters ---------- level : int or None, optional, default None """ sl = level + 1 # add sl frames to the scope starting with the # most distant and overwriting with mor...
[ "def", "update", "(", "self", ",", "level", ")", ":", "sl", "=", "level", "+", "1", "# add sl frames to the scope starting with the", "# most distant and overwriting with more current", "# makes sure that we can capture variable scope", "stack", "=", "inspect", ".", "stack", ...
Update the current scope by going back `level` levels. Parameters ---------- level : int or None, optional, default None
[ "Update", "the", "current", "scope", "by", "going", "back", "level", "levels", "." ]
python
train
28.944444
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/lib/inputhook.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/lib/inputhook.py#L232-L261
def enable_qt4(self, app=None): """Enable event loop integration with PyQt4. Parameters ---------- app : Qt Application, optional. Running application to use. If not given, we probe Qt for an existing application object, and create a new one if none is f...
[ "def", "enable_qt4", "(", "self", ",", "app", "=", "None", ")", ":", "from", "IPython", ".", "lib", ".", "inputhookqt4", "import", "create_inputhook_qt4", "app", ",", "inputhook_qt4", "=", "create_inputhook_qt4", "(", "self", ",", "app", ")", "self", ".", ...
Enable event loop integration with PyQt4. Parameters ---------- app : Qt Application, optional. Running application to use. If not given, we probe Qt for an existing application object, and create a new one if none is found. Notes ----- ...
[ "Enable", "event", "loop", "integration", "with", "PyQt4", ".", "Parameters", "----------", "app", ":", "Qt", "Application", "optional", ".", "Running", "application", "to", "use", ".", "If", "not", "given", "we", "probe", "Qt", "for", "an", "existing", "app...
python
test
35.033333
acutesoftware/AIKIF
aikif/core_data.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/core_data.py#L158-L166
def links_to(self, other, tpe): """ adds a link from this thing to other thing using type (is_a, has_a, uses, contains, part_of) """ if self.check_type(tpe): self.links.append([other, tpe]) else: raise Exception('aikif.core_data cannot process this...
[ "def", "links_to", "(", "self", ",", "other", ",", "tpe", ")", ":", "if", "self", ".", "check_type", "(", "tpe", ")", ":", "self", ".", "links", ".", "append", "(", "[", "other", ",", "tpe", "]", ")", "else", ":", "raise", "Exception", "(", "'aik...
adds a link from this thing to other thing using type (is_a, has_a, uses, contains, part_of)
[ "adds", "a", "link", "from", "this", "thing", "to", "other", "thing", "using", "type", "(", "is_a", "has_a", "uses", "contains", "part_of", ")" ]
python
train
36.222222
DocNow/twarc
twarc/decorators.py
https://github.com/DocNow/twarc/blob/47dd87d0c00592a4d583412c9d660ba574fc6f26/twarc/decorators.py#L96-L108
def catch_gzip_errors(f): """ A decorator to handle gzip encoding errors which have been known to happen during hydration. """ def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except requests.exceptions.ContentDecodingError as e: log.warn...
[ "def", "catch_gzip_errors", "(", "f", ")", ":", "def", "new_f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "f", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "requests", ".", ...
A decorator to handle gzip encoding errors which have been known to happen during hydration.
[ "A", "decorator", "to", "handle", "gzip", "encoding", "errors", "which", "have", "been", "known", "to", "happen", "during", "hydration", "." ]
python
train
32.846154
scanny/python-pptx
pptx/chart/xmlwriter.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/xmlwriter.py#L1676-L1687
def yVal_xml(self): """ Return the ``<c:yVal>`` element for this series as unicode text. This element contains the Y values for this series. """ return self._yVal_tmpl.format(**{ 'nsdecls': '', 'numRef_xml': self.numRef_xml( self._series...
[ "def", "yVal_xml", "(", "self", ")", ":", "return", "self", ".", "_yVal_tmpl", ".", "format", "(", "*", "*", "{", "'nsdecls'", ":", "''", ",", "'numRef_xml'", ":", "self", ".", "numRef_xml", "(", "self", ".", "_series", ".", "y_values_ref", ",", "self"...
Return the ``<c:yVal>`` element for this series as unicode text. This element contains the Y values for this series.
[ "Return", "the", "<c", ":", "yVal", ">", "element", "for", "this", "series", "as", "unicode", "text", ".", "This", "element", "contains", "the", "Y", "values", "for", "this", "series", "." ]
python
train
34.583333
happyleavesaoc/python-voobly
voobly/__init__.py
https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/voobly/__init__.py#L375-L378
def get_user_matches(session, user_id, from_timestamp=None, limit=None): """Get recent matches by user.""" return get_recent_matches(session, '{}{}/{}/Matches/games/matches/user/{}/0'.format( session.auth.base_url, PROFILE_URL, user_id, user_id), from_timestamp, limit)
[ "def", "get_user_matches", "(", "session", ",", "user_id", ",", "from_timestamp", "=", "None", ",", "limit", "=", "None", ")", ":", "return", "get_recent_matches", "(", "session", ",", "'{}{}/{}/Matches/games/matches/user/{}/0'", ".", "format", "(", "session", "."...
Get recent matches by user.
[ "Get", "recent", "matches", "by", "user", "." ]
python
train
70.5
cablehead/vanilla
vanilla/core.py
https://github.com/cablehead/vanilla/blob/c9f5b86f45720a30e8840fb68b1429b919c4ca66/vanilla/core.py#L327-L333
def throw_to(self, target, *a): self.ready.append((getcurrent(), ())) """ if len(a) == 1 and isinstance(a[0], preserve_exception): return target.throw(a[0].typ, a[0].val, a[0].tb) """ return target.throw(*a)
[ "def", "throw_to", "(", "self", ",", "target", ",", "*", "a", ")", ":", "self", ".", "ready", ".", "append", "(", "(", "getcurrent", "(", ")", ",", "(", ")", ")", ")", "return", "target", ".", "throw", "(", "*", "a", ")" ]
if len(a) == 1 and isinstance(a[0], preserve_exception): return target.throw(a[0].typ, a[0].val, a[0].tb)
[ "if", "len", "(", "a", ")", "==", "1", "and", "isinstance", "(", "a", "[", "0", "]", "preserve_exception", ")", ":", "return", "target", ".", "throw", "(", "a", "[", "0", "]", ".", "typ", "a", "[", "0", "]", ".", "val", "a", "[", "0", "]", ...
python
train
36.142857
ladybug-tools/ladybug
ladybug/futil.py
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/futil.py#L146-L171
def bat_to_sh(file_path): """Convert honeybee .bat file to .sh file. WARNING: This is a very simple function and doesn't handle any edge cases. """ sh_file = file_path[:-4] + '.sh' with open(file_path, 'rb') as inf, open(sh_file, 'wb') as outf: outf.write('#!/usr/bin/env bash\n\n') ...
[ "def", "bat_to_sh", "(", "file_path", ")", ":", "sh_file", "=", "file_path", "[", ":", "-", "4", "]", "+", "'.sh'", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", "inf", ",", "open", "(", "sh_file", ",", "'wb'", ")", "as", "outf", ":", ...
Convert honeybee .bat file to .sh file. WARNING: This is a very simple function and doesn't handle any edge cases.
[ "Convert", "honeybee", ".", "bat", "file", "to", ".", "sh", "file", "." ]
python
train
33.346154
andrenarchy/krypy
krypy/linsys.py
https://github.com/andrenarchy/krypy/blob/4883ec9a61d64ea56489e15c35cc40f0633ab2f1/krypy/linsys.py#L897-L905
def operations(nsteps): '''Returns the number of operations needed for nsteps of GMRES''' return {'A': 1 + nsteps, 'M': 2 + nsteps, 'Ml': 2 + nsteps, 'Mr': 1 + nsteps, 'ip_B': 2 + nsteps + nsteps*(nsteps+1)/2, 'axpy': 4 + 2*...
[ "def", "operations", "(", "nsteps", ")", ":", "return", "{", "'A'", ":", "1", "+", "nsteps", ",", "'M'", ":", "2", "+", "nsteps", ",", "'Ml'", ":", "2", "+", "nsteps", ",", "'Mr'", ":", "1", "+", "nsteps", ",", "'ip_B'", ":", "2", "+", "nsteps"...
Returns the number of operations needed for nsteps of GMRES
[ "Returns", "the", "number", "of", "operations", "needed", "for", "nsteps", "of", "GMRES" ]
python
train
39.777778
bcbio/bcbio-nextgen
bcbio/structural/titancna.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/titancna.py#L86-L95
def _run_select_solution(ploidy_outdirs, work_dir, data): """Select optimal """ out_file = os.path.join(work_dir, "optimalClusters.txt") if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: ploidy_inputs = " ".join(["--ploidyRun%s=%s" % (p, d) for...
[ "def", "_run_select_solution", "(", "ploidy_outdirs", ",", "work_dir", ",", "data", ")", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "\"optimalClusters.txt\"", ")", "if", "not", "utils", ".", "file_exists", "(", "out_file", ")...
Select optimal
[ "Select", "optimal" ]
python
train
52.2
fake-name/WebRequest
WebRequest/WebRequestClass.py
https://github.com/fake-name/WebRequest/blob/b6c94631ff88b5f81f26a9f99a2d5c706810b11f/WebRequest/WebRequestClass.py#L279-L290
def getFileAndName(self, *args, **kwargs): ''' Give a requested page (note: the arguments for this call are forwarded to getpage()), return the content at the target URL and the filename for the target content as a 2-tuple (pgctnt, hName) for the content at the target URL. The filename specified in the conte...
[ "def", "getFileAndName", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pgctnt", ",", "hName", ",", "mime", "=", "self", ".", "getFileNameMime", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "pgctnt", ",", "hName" ]
Give a requested page (note: the arguments for this call are forwarded to getpage()), return the content at the target URL and the filename for the target content as a 2-tuple (pgctnt, hName) for the content at the target URL. The filename specified in the content-disposition header is used, if present. Otherwis...
[ "Give", "a", "requested", "page", "(", "note", ":", "the", "arguments", "for", "this", "call", "are", "forwarded", "to", "getpage", "()", ")", "return", "the", "content", "at", "the", "target", "URL", "and", "the", "filename", "for", "the", "target", "co...
python
train
43.75
Dallinger/Dallinger
dallinger/recruiters.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L885-L913
def open_recruitment(self, n=1): """Return initial experiment URL list. """ logger.info("Multi recruitment running for {} participants".format(n)) recruitments = [] messages = {} remaining = n for recruiter, count in self.recruiters(n): if not count: ...
[ "def", "open_recruitment", "(", "self", ",", "n", "=", "1", ")", ":", "logger", ".", "info", "(", "\"Multi recruitment running for {} participants\"", ".", "format", "(", "n", ")", ")", "recruitments", "=", "[", "]", "messages", "=", "{", "}", "remaining", ...
Return initial experiment URL list.
[ "Return", "initial", "experiment", "URL", "list", "." ]
python
train
34.448276
allenai/allennlp
allennlp/training/metrics/conll_coref_scores.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metrics/conll_coref_scores.py#L188-L205
def muc(clusters, mention_to_gold): """ Counts the mentions in each predicted cluster which need to be re-allocated in order for each predicted cluster to be contained by the respective gold cluster. <http://aclweb.org/anthology/M/M95/M95-1005.pdf> """ true_p, all_p = 0, ...
[ "def", "muc", "(", "clusters", ",", "mention_to_gold", ")", ":", "true_p", ",", "all_p", "=", "0", ",", "0", "for", "cluster", "in", "clusters", ":", "all_p", "+=", "len", "(", "cluster", ")", "-", "1", "true_p", "+=", "len", "(", "cluster", ")", "...
Counts the mentions in each predicted cluster which need to be re-allocated in order for each predicted cluster to be contained by the respective gold cluster. <http://aclweb.org/anthology/M/M95/M95-1005.pdf>
[ "Counts", "the", "mentions", "in", "each", "predicted", "cluster", "which", "need", "to", "be", "re", "-", "allocated", "in", "order", "for", "each", "predicted", "cluster", "to", "be", "contained", "by", "the", "respective", "gold", "cluster", ".", "<http",...
python
train
38.555556
prompt-toolkit/pymux
pymux/commands/commands.py
https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/commands/commands.py#L211-L232
def select_window(pymux, variables): """ Select a window. E.g: select-window -t :3 """ window_id = variables['<target-window>'] def invalid_window(): raise CommandException('Invalid window: %s' % window_id) if window_id.startswith(':'): try: number = int(window_id[...
[ "def", "select_window", "(", "pymux", ",", "variables", ")", ":", "window_id", "=", "variables", "[", "'<target-window>'", "]", "def", "invalid_window", "(", ")", ":", "raise", "CommandException", "(", "'Invalid window: %s'", "%", "window_id", ")", "if", "window...
Select a window. E.g: select-window -t :3
[ "Select", "a", "window", ".", "E", ".", "g", ":", "select", "-", "window", "-", "t", ":", "3" ]
python
train
27
pandas-dev/pandas
pandas/core/groupby/groupby.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/groupby/groupby.py#L1457-L1462
def rolling(self, *args, **kwargs): """ Return a rolling grouper, providing rolling functionality per group. """ from pandas.core.window import RollingGroupby return RollingGroupby(self, *args, **kwargs)
[ "def", "rolling", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "window", "import", "RollingGroupby", "return", "RollingGroupby", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Return a rolling grouper, providing rolling functionality per group.
[ "Return", "a", "rolling", "grouper", "providing", "rolling", "functionality", "per", "group", "." ]
python
train
39.666667
senaite/senaite.jsonapi
src/senaite/jsonapi/api.py
https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L573-L601
def get_search_results(portal_type=None, uid=None, **kw): """Search the catalog and return the results :returns: Catalog search results :rtype: iterable """ # If we have an UID, return the object immediately if uid is not None: logger.info("UID '%s' found, returning the object immediat...
[ "def", "get_search_results", "(", "portal_type", "=", "None", ",", "uid", "=", "None", ",", "*", "*", "kw", ")", ":", "# If we have an UID, return the object immediately", "if", "uid", "is", "not", "None", ":", "logger", ".", "info", "(", "\"UID '%s' found, retu...
Search the catalog and return the results :returns: Catalog search results :rtype: iterable
[ "Search", "the", "catalog", "and", "return", "the", "results" ]
python
train
32.034483
mallamanis/experimenter
experimenter/experimentlogger.py
https://github.com/mallamanis/experimenter/blob/2ed5ce85084cc47251ccba3aae0cb3431fbe4259/experimenter/experimentlogger.py#L46-L63
def record_results(self, results): """ Record the results of this experiment, by updating the tag. :param results: A dictionary containing the results of the experiment. :type results: dict """ repository = Repo(self.__repository_directory, search_parent_directories=True)...
[ "def", "record_results", "(", "self", ",", "results", ")", ":", "repository", "=", "Repo", "(", "self", ".", "__repository_directory", ",", "search_parent_directories", "=", "True", ")", "for", "tag", "in", "repository", ".", "tags", ":", "if", "tag", ".", ...
Record the results of this experiment, by updating the tag. :param results: A dictionary containing the results of the experiment. :type results: dict
[ "Record", "the", "results", "of", "this", "experiment", "by", "updating", "the", "tag", ".", ":", "param", "results", ":", "A", "dictionary", "containing", "the", "results", "of", "the", "experiment", ".", ":", "type", "results", ":", "dict" ]
python
valid
45.166667
CiscoTestAutomation/yang
ncdiff/src/yang/ncdiff/model.py
https://github.com/CiscoTestAutomation/yang/blob/c70ec5ac5a91f276c4060009203770ece92e76b4/ncdiff/src/yang/ncdiff/model.py#L285-L316
def get_datatype_str(self, element, length): '''get_datatype_str High-level api: Produce a string that indicates the data type of a node. Parameters ---------- element : `Element` A node in model tree. length : `int` String length that has been...
[ "def", "get_datatype_str", "(", "self", ",", "element", ",", "length", ")", ":", "spaces", "=", "' '", "*", "(", "self", ".", "get_width", "(", "element", ")", "-", "length", ")", "type_info", "=", "element", ".", "get", "(", "'type'", ")", "ret", "=...
get_datatype_str High-level api: Produce a string that indicates the data type of a node. Parameters ---------- element : `Element` A node in model tree. length : `int` String length that has been consumed. Returns ------- str...
[ "get_datatype_str" ]
python
train
28.03125
GoogleCloudPlatform/compute-image-packages
packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py
https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/sles_12/utils.py#L32-L45
def EnableNetworkInterfaces( self, interfaces, logger, dhclient_script=None): """Enable the list of network interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. dhclient_script: string, the path ...
[ "def", "EnableNetworkInterfaces", "(", "self", ",", "interfaces", ",", "logger", ",", "dhclient_script", "=", "None", ")", ":", "interfaces_to_up", "=", "[", "i", "for", "i", "in", "interfaces", "if", "i", "!=", "'eth0'", "]", "if", "interfaces_to_up", ":", ...
Enable the list of network interfaces. Args: interfaces: list of string, the output device names to enable. logger: logger object, used to write to SysLog and serial port. dhclient_script: string, the path to a dhclient script used by dhclient.
[ "Enable", "the", "list", "of", "network", "interfaces", "." ]
python
train
43.428571
draperjames/qtpandas
qtpandas/ui/fallback/easygui/boxes/base_boxes.py
https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/ui/fallback/easygui/boxes/base_boxes.py#L828-L916
def fileopenbox(msg=None, title=None, default='*', filetypes=None, multiple=False): """ A dialog to get a file name. **About the "default" argument** The "default" argument specifies a filepath that (normally) contains one or more wildcards. fileopenbox will display only files that match the d...
[ "def", "fileopenbox", "(", "msg", "=", "None", ",", "title", "=", "None", ",", "default", "=", "'*'", ",", "filetypes", "=", "None", ",", "multiple", "=", "False", ")", ":", "localRoot", "=", "Tk", "(", ")", "localRoot", ".", "withdraw", "(", ")", ...
A dialog to get a file name. **About the "default" argument** The "default" argument specifies a filepath that (normally) contains one or more wildcards. fileopenbox will display only files that match the default filepath. If omitted, defaults to "\*" (all files in the current directory). WIN...
[ "A", "dialog", "to", "get", "a", "file", "name", "." ]
python
train
34.966292
limix/limix-core
limix_core/covar/lowrank.py
https://github.com/limix/limix-core/blob/5c590b4d351409f83ca320844b4897ce92203814/limix_core/covar/lowrank.py#L83-L90
def setCovariance(self, cov): """ makes lowrank approximation of cov """ assert cov.shape[0]==self.dim, 'Dimension mismatch.' S, U = la.eigh(cov) U = U[:,::-1] S = S[::-1] _X = U[:, :self.rank] * sp.sqrt(S[:self.rank]) self.X = _X
[ "def", "setCovariance", "(", "self", ",", "cov", ")", ":", "assert", "cov", ".", "shape", "[", "0", "]", "==", "self", ".", "dim", ",", "'Dimension mismatch.'", "S", ",", "U", "=", "la", ".", "eigh", "(", "cov", ")", "U", "=", "U", "[", ":", ",...
makes lowrank approximation of cov
[ "makes", "lowrank", "approximation", "of", "cov" ]
python
train
34.875
tensorflow/lucid
lucid/optvis/objectives.py
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/optvis/objectives.py#L165-L170
def channel(layer, n_channel, batch=None): """Visualize a single channel""" if batch is None: return lambda T: tf.reduce_mean(T(layer)[..., n_channel]) else: return lambda T: tf.reduce_mean(T(layer)[batch, ..., n_channel])
[ "def", "channel", "(", "layer", ",", "n_channel", ",", "batch", "=", "None", ")", ":", "if", "batch", "is", "None", ":", "return", "lambda", "T", ":", "tf", ".", "reduce_mean", "(", "T", "(", "layer", ")", "[", "...", ",", "n_channel", "]", ")", ...
Visualize a single channel
[ "Visualize", "a", "single", "channel" ]
python
train
38.5
RedHatInsights/insights-core
insights/core/plugins.py
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/plugins.py#L414-L425
def adjust_for_length(self, key, r, kwargs): """ Converts the response to a string and compares its length to a max length specified in settings. If the response is too long, an error is logged, and an abbreviated response is returned instead. """ length = len(str(kwargs)...
[ "def", "adjust_for_length", "(", "self", ",", "key", ",", "r", ",", "kwargs", ")", ":", "length", "=", "len", "(", "str", "(", "kwargs", ")", ")", "if", "length", ">", "settings", ".", "defaults", "[", "\"max_detail_length\"", "]", ":", "self", ".", ...
Converts the response to a string and compares its length to a max length specified in settings. If the response is too long, an error is logged, and an abbreviated response is returned instead.
[ "Converts", "the", "response", "to", "a", "string", "and", "compares", "its", "length", "to", "a", "max", "length", "specified", "in", "settings", ".", "If", "the", "response", "is", "too", "long", "an", "error", "is", "logged", "and", "an", "abbreviated",...
python
train
42.583333
typemytype/booleanOperations
Lib/booleanOperations/flatten.py
https://github.com/typemytype/booleanOperations/blob/b7d9fc95c155824662f4a0020e653c77b7723d24/Lib/booleanOperations/flatten.py#L419-L447
def _convertPointsToSegments(points, willBeReversed=False): """ Compile points into InputSegment objects. """ # get the last on curve previousOnCurve = None for point in reversed(points): if point.segmentType is not None: previousOnCurve = point.coordinates break ...
[ "def", "_convertPointsToSegments", "(", "points", ",", "willBeReversed", "=", "False", ")", ":", "# get the last on curve", "previousOnCurve", "=", "None", "for", "point", "in", "reversed", "(", "points", ")", ":", "if", "point", ".", "segmentType", "is", "not",...
Compile points into InputSegment objects.
[ "Compile", "points", "into", "InputSegment", "objects", "." ]
python
train
30.310345
manns/pyspread
pyspread/src/gui/_main_window.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L1170-L1193
def OnApprove(self, event): """File approve event handler""" if not self.main_window.safe_mode: return msg = _(u"You are going to approve and trust a file that\n" u"you have not created yourself.\n" u"After proceeding, the file is executed.\n \n" ...
[ "def", "OnApprove", "(", "self", ",", "event", ")", ":", "if", "not", "self", ".", "main_window", ".", "safe_mode", ":", "return", "msg", "=", "_", "(", "u\"You are going to approve and trust a file that\\n\"", "u\"you have not created yourself.\\n\"", "u\"After proceed...
File approve event handler
[ "File", "approve", "event", "handler" ]
python
train
39.041667
chaimleib/intervaltree
intervaltree/intervaltree.py
https://github.com/chaimleib/intervaltree/blob/ffb2b1667f8b832e89324a75a175be8440504c9d/intervaltree/intervaltree.py#L645-L708
def merge_overlaps(self, data_reducer=None, data_initializer=None, strict=True): """ Finds all intervals with overlapping ranges and merges them into a single interval. If provided, uses data_reducer and data_initializer with similar semantics to Python's built-in reduce(reducer_...
[ "def", "merge_overlaps", "(", "self", ",", "data_reducer", "=", "None", ",", "data_initializer", "=", "None", ",", "strict", "=", "True", ")", ":", "if", "not", "self", ":", "return", "sorted_intervals", "=", "sorted", "(", "self", ".", "all_intervals", ")...
Finds all intervals with overlapping ranges and merges them into a single interval. If provided, uses data_reducer and data_initializer with similar semantics to Python's built-in reduce(reducer_func[, initializer]), as follows: If data_reducer is set to a function, combines the data ...
[ "Finds", "all", "intervals", "with", "overlapping", "ranges", "and", "merges", "them", "into", "a", "single", "interval", ".", "If", "provided", "uses", "data_reducer", "and", "data_initializer", "with", "similar", "semantics", "to", "Python", "s", "built", "-",...
python
train
45.5
thautwarm/RBNF
rbnf/auto_lexer/__init__.py
https://github.com/thautwarm/RBNF/blob/cceec88c90f7ec95c160cfda01bfc532610985e0/rbnf/auto_lexer/__init__.py#L246-L270
def regex_lexer(regex_pat): """ generate token names' cache """ if isinstance(regex_pat, str): regex_pat = re.compile(regex_pat) def f(inp_str, pos): m = regex_pat.match(inp_str, pos) return m.group() if m else None elif hasattr(regex_pat, 'match'): ...
[ "def", "regex_lexer", "(", "regex_pat", ")", ":", "if", "isinstance", "(", "regex_pat", ",", "str", ")", ":", "regex_pat", "=", "re", ".", "compile", "(", "regex_pat", ")", "def", "f", "(", "inp_str", ",", "pos", ")", ":", "m", "=", "regex_pat", ".",...
generate token names' cache
[ "generate", "token", "names", "cache" ]
python
train
26.76
broadinstitute/fiss
firecloud/fiss.py
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/fiss.py#L257-L261
def entity_list(args): """ List entities in a workspace. """ r = fapi.get_entities_with_type(args.project, args.workspace) fapi._check_response_code(r, 200) return [ '{0}\t{1}'.format(e['entityType'], e['name']) for e in r.json() ]
[ "def", "entity_list", "(", "args", ")", ":", "r", "=", "fapi", ".", "get_entities_with_type", "(", "args", ".", "project", ",", "args", ".", "workspace", ")", "fapi", ".", "_check_response_code", "(", "r", ",", "200", ")", "return", "[", "'{0}\\t{1}'", "...
List entities in a workspace.
[ "List", "entities", "in", "a", "workspace", "." ]
python
train
48.6
tbielawa/bitmath
bitmath/__init__.py
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1351-L1391
def listdir(search_base, followlinks=False, filter='*', relpath=False, bestprefix=False, system=NIST): """This is a generator which recurses the directory tree `search_base`, yielding 2-tuples of: * The absolute/relative path to a discovered file * A bitmath instance representing the "apparent size" of...
[ "def", "listdir", "(", "search_base", ",", "followlinks", "=", "False", ",", "filter", "=", "'*'", ",", "relpath", "=", "False", ",", "bestprefix", "=", "False", ",", "system", "=", "NIST", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "o...
This is a generator which recurses the directory tree `search_base`, yielding 2-tuples of: * The absolute/relative path to a discovered file * A bitmath instance representing the "apparent size" of the file. - `search_base` - The directory to begin walking down. - `followlinks` - Whether or not to follow symb...
[ "This", "is", "a", "generator", "which", "recurses", "the", "directory", "tree", "search_base", "yielding", "2", "-", "tuples", "of", ":" ]
python
train
43
SeleniumHQ/selenium
py/selenium/webdriver/remote/webelement.py
https://github.com/SeleniumHQ/selenium/blob/df40c28b41d4b3953f90eaff84838a9ac052b84a/py/selenium/webdriver/remote/webelement.py#L545-L554
def size(self): """The size of the element.""" size = {} if self._w3c: size = self._execute(Command.GET_ELEMENT_RECT)['value'] else: size = self._execute(Command.GET_ELEMENT_SIZE)['value'] new_size = {"height": size["height"], "width": ...
[ "def", "size", "(", "self", ")", ":", "size", "=", "{", "}", "if", "self", ".", "_w3c", ":", "size", "=", "self", ".", "_execute", "(", "Command", ".", "GET_ELEMENT_RECT", ")", "[", "'value'", "]", "else", ":", "size", "=", "self", ".", "_execute",...
The size of the element.
[ "The", "size", "of", "the", "element", "." ]
python
train
34.9
pandas-dev/pandas
pandas/core/sparse/series.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/sparse/series.py#L554-L571
def combine_first(self, other): """ Combine Series values, choosing the calling Series's values first. Result index will be the union of the two indexes Parameters ---------- other : Series Returns ------- y : Series """ if isinst...
[ "def", "combine_first", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "SparseSeries", ")", ":", "other", "=", "other", ".", "to_dense", "(", ")", "dense_combined", "=", "self", ".", "to_dense", "(", ")", ".", "combine_first"...
Combine Series values, choosing the calling Series's values first. Result index will be the union of the two indexes Parameters ---------- other : Series Returns ------- y : Series
[ "Combine", "Series", "values", "choosing", "the", "calling", "Series", "s", "values", "first", ".", "Result", "index", "will", "be", "the", "union", "of", "the", "two", "indexes" ]
python
train
27.611111
doraemonext/wechat-python-sdk
wechat_sdk/lib/crypto/base.py
https://github.com/doraemonext/wechat-python-sdk/blob/bf6f6f3d4a5440feb73a51937059d7feddc335a0/wechat_sdk/lib/crypto/base.py#L45-L75
def decrypt(self, text, appid): """对解密后的明文进行补位删除 @param text: 密文 @return: 删除填充补位后的明文 """ try: cryptor = AES.new(self.key, self.mode, self.key[:16]) # 使用BASE64对密文进行解码,然后AES-CBC解密 plain_text = cryptor.decrypt(base64.b64decode(text)) exce...
[ "def", "decrypt", "(", "self", ",", "text", ",", "appid", ")", ":", "try", ":", "cryptor", "=", "AES", ".", "new", "(", "self", ".", "key", ",", "self", ".", "mode", ",", "self", ".", "key", "[", ":", "16", "]", ")", "# 使用BASE64对密文进行解码,然后AES-CBC解密"...
对解密后的明文进行补位删除 @param text: 密文 @return: 删除填充补位后的明文
[ "对解密后的明文进行补位删除" ]
python
valid
31.967742
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/uri_parser.py#L53-L66
def _rpartition(entity, sep): """Python2.4 doesn't have an rpartition method so we provide our own that mimics str.rpartition from later releases. Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after ...
[ "def", "_rpartition", "(", "entity", ",", "sep", ")", ":", "idx", "=", "entity", ".", "rfind", "(", "sep", ")", "if", "idx", "==", "-", "1", ":", "return", "''", ",", "''", ",", "entity", "return", "entity", "[", ":", "idx", "]", ",", "sep", ",...
Python2.4 doesn't have an rpartition method so we provide our own that mimics str.rpartition from later releases. Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is no...
[ "Python2", ".", "4", "doesn", "t", "have", "an", "rpartition", "method", "so", "we", "provide", "our", "own", "that", "mimics", "str", ".", "rpartition", "from", "later", "releases", "." ]
python
train
40.642857
rocky/python3-trepan
trepan/processor/cmdfns.py
https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/processor/cmdfns.py#L103-L118
def get_int(errmsg, arg, default=1, cmdname=None): """If arg is an int, use that otherwise take default.""" if arg: try: # eval() is used so we will allow arithmetic expressions, # variables etc. default = int(eval(arg)) except (SyntaxError, NameError, ValueEr...
[ "def", "get_int", "(", "errmsg", ",", "arg", ",", "default", "=", "1", ",", "cmdname", "=", "None", ")", ":", "if", "arg", ":", "try", ":", "# eval() is used so we will allow arithmetic expressions,", "# variables etc.", "default", "=", "int", "(", "eval", "("...
If arg is an int, use that otherwise take default.
[ "If", "arg", "is", "an", "int", "use", "that", "otherwise", "take", "default", "." ]
python
test
37.625
InfoAgeTech/django-core
django_core/utils/date_parsers.py
https://github.com/InfoAgeTech/django-core/blob/9664a145473b75120bf71e1644e9c8086e7e8955/django_core/utils/date_parsers.py#L117-L133
def parse_date(dt, ignoretz=True, as_tz=None): """ :param dt: string datetime to convert into datetime object. :return: date object if the string can be parsed into a date. Otherwise, return None. :see: http://labix.org/python-dateutil Examples: >>> parse_date('2011-12-30') dateti...
[ "def", "parse_date", "(", "dt", ",", "ignoretz", "=", "True", ",", "as_tz", "=", "None", ")", ":", "dttm", "=", "parse_datetime", "(", "dt", ",", "ignoretz", "=", "ignoretz", ")", "return", "None", "if", "dttm", "is", "None", "else", "dttm", ".", "da...
:param dt: string datetime to convert into datetime object. :return: date object if the string can be parsed into a date. Otherwise, return None. :see: http://labix.org/python-dateutil Examples: >>> parse_date('2011-12-30') datetime.date(2011, 12, 30) >>> parse_date('12/30/2011') ...
[ ":", "param", "dt", ":", "string", "datetime", "to", "convert", "into", "datetime", "object", ".", ":", "return", ":", "date", "object", "if", "the", "string", "can", "be", "parsed", "into", "a", "date", ".", "Otherwise", "return", "None", "." ]
python
train
29.176471
pycontribs/jira
jira/client.py
https://github.com/pycontribs/jira/blob/397db5d78441ed6a680a9b7db4c62030ade1fd8a/jira/client.py#L2716-L2724
def delete_user_avatar(self, username, avatar): """Delete a user's avatar. :param username: the user to delete the avatar from :param avatar: ID of the avatar to remove """ params = {'username': username} url = self._get_url('user/avatar/' + avatar) return self._...
[ "def", "delete_user_avatar", "(", "self", ",", "username", ",", "avatar", ")", ":", "params", "=", "{", "'username'", ":", "username", "}", "url", "=", "self", ".", "_get_url", "(", "'user/avatar/'", "+", "avatar", ")", "return", "self", ".", "_session", ...
Delete a user's avatar. :param username: the user to delete the avatar from :param avatar: ID of the avatar to remove
[ "Delete", "a", "user", "s", "avatar", "." ]
python
train
38.444444
cocagne/txdbus
doc/examples/fd_server.py
https://github.com/cocagne/txdbus/blob/eb424918764b7b93eecd2a4e2e5c2d0b2944407b/doc/examples/fd_server.py#L56-L63
def dbus_readBytesFD(self, fd, byte_count): """ Reads byte_count bytes from fd and returns them. """ f = os.fdopen(fd, 'rb') result = f.read(byte_count) f.close() return bytearray(result)
[ "def", "dbus_readBytesFD", "(", "self", ",", "fd", ",", "byte_count", ")", ":", "f", "=", "os", ".", "fdopen", "(", "fd", ",", "'rb'", ")", "result", "=", "f", ".", "read", "(", "byte_count", ")", "f", ".", "close", "(", ")", "return", "bytearray",...
Reads byte_count bytes from fd and returns them.
[ "Reads", "byte_count", "bytes", "from", "fd", "and", "returns", "them", "." ]
python
train
29.5
danilobellini/audiolazy
audiolazy/lazy_stream.py
https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_stream.py#L299-L318
def peek(self, n=None, constructor=list): """ Sees/peeks the next few items in the Stream, without removing them. Besides that this functions keeps the Stream items, it's the same to the ``Stream.take()`` method. See Also -------- Stream.take : Returns the n first elements from the S...
[ "def", "peek", "(", "self", ",", "n", "=", "None", ",", "constructor", "=", "list", ")", ":", "return", "self", ".", "copy", "(", ")", ".", "take", "(", "n", "=", "n", ",", "constructor", "=", "constructor", ")" ]
Sees/peeks the next few items in the Stream, without removing them. Besides that this functions keeps the Stream items, it's the same to the ``Stream.take()`` method. See Also -------- Stream.take : Returns the n first elements from the Stream, removing them. Note ---- When appl...
[ "Sees", "/", "peeks", "the", "next", "few", "items", "in", "the", "Stream", "without", "removing", "them", "." ]
python
train
30.25
openego/ding0
ding0/grid/mv_grid/solvers/savings.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/solvers/savings.py#L206-L247
def solve(self, graph, timeout, debug=False, anim=None): """Solves the CVRP problem using Clarke and Wright Savings methods Parameters ---------- graph: :networkx:`NetworkX Graph Obj< >` A NetworkX graaph is used. timeout: int max processing time in secon...
[ "def", "solve", "(", "self", ",", "graph", ",", "timeout", ",", "debug", "=", "False", ",", "anim", "=", "None", ")", ":", "savings_list", "=", "self", ".", "compute_savings_list", "(", "graph", ")", "solution", "=", "SavingsSolution", "(", "graph", ")",...
Solves the CVRP problem using Clarke and Wright Savings methods Parameters ---------- graph: :networkx:`NetworkX Graph Obj< >` A NetworkX graaph is used. timeout: int max processing time in seconds debug: bool, defaults to False If True, infor...
[ "Solves", "the", "CVRP", "problem", "using", "Clarke", "and", "Wright", "Savings", "methods" ]
python
train
25.928571
miyakogi/wdom
wdom/node.py
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L509-L516
def replaceWith(self, *nodes: Union[AbstractNode, str]) -> None: """Replace this node with nodes. If nodes contains ``str``, it will be converted to Text node. """ if self.parentNode: node = _to_node_list(nodes) self.parentNode.replaceChild(node, self)
[ "def", "replaceWith", "(", "self", ",", "*", "nodes", ":", "Union", "[", "AbstractNode", ",", "str", "]", ")", "->", "None", ":", "if", "self", ".", "parentNode", ":", "node", "=", "_to_node_list", "(", "nodes", ")", "self", ".", "parentNode", ".", "...
Replace this node with nodes. If nodes contains ``str``, it will be converted to Text node.
[ "Replace", "this", "node", "with", "nodes", "." ]
python
train
37.75
JoeVirtual/KonFoo
konfoo/core.py
https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L2647-L2690
def _set_alignment(self, group_size, bit_offset=0, auto_align=False): """ Sets the alignment of the ``Decimal`` field. :param int group_size: size of the aligned `Field` group in bytes, can be between ``1`` and ``8``. :param int bit_offset: bit offset of the `Decimal` field within t...
[ "def", "_set_alignment", "(", "self", ",", "group_size", ",", "bit_offset", "=", "0", ",", "auto_align", "=", "False", ")", ":", "# Field alignment offset", "field_offset", "=", "int", "(", "bit_offset", ")", "# Auto alignment", "if", "auto_align", ":", "# Field...
Sets the alignment of the ``Decimal`` field. :param int group_size: size of the aligned `Field` group in bytes, can be between ``1`` and ``8``. :param int bit_offset: bit offset of the `Decimal` field within the aligned `Field` group, can be between ``0`` and ``63``. :pa...
[ "Sets", "the", "alignment", "of", "the", "Decimal", "field", "." ]
python
train
37.681818
apache/spark
python/pyspark/sql/session.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/session.py#L382-L412
def _inferSchema(self, rdd, samplingRatio=None, names=None): """ Infer schema from an RDD of Row or tuple. :param rdd: an RDD of Row or tuple :param samplingRatio: sampling ratio, or no sampling (default) :return: :class:`pyspark.sql.types.StructType` """ first =...
[ "def", "_inferSchema", "(", "self", ",", "rdd", ",", "samplingRatio", "=", "None", ",", "names", "=", "None", ")", ":", "first", "=", "rdd", ".", "first", "(", ")", "if", "not", "first", ":", "raise", "ValueError", "(", "\"The first row in RDD is empty, \"...
Infer schema from an RDD of Row or tuple. :param rdd: an RDD of Row or tuple :param samplingRatio: sampling ratio, or no sampling (default) :return: :class:`pyspark.sql.types.StructType`
[ "Infer", "schema", "from", "an", "RDD", "of", "Row", "or", "tuple", "." ]
python
train
43.741935
kgori/treeCl
treeCl/collection.py
https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/collection.py#L598-L638
def analyse_cache_dir(self, jobhandler=None, batchsize=1, **kwargs): """ Scan the cache directory and launch analysis for all unscored alignments using associated task handler. KWargs are passed to the tree calculating task managed by the TaskInterface in self.task_interface. Exa...
[ "def", "analyse_cache_dir", "(", "self", ",", "jobhandler", "=", "None", ",", "batchsize", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "jobhandler", "is", "None", ":", "jobhandler", "=", "SequentialJobHandler", "(", ")", "files", "=", "glob", ".",...
Scan the cache directory and launch analysis for all unscored alignments using associated task handler. KWargs are passed to the tree calculating task managed by the TaskInterface in self.task_interface. Example kwargs: TreeCollectionTaskInterface: scale=1, guide_tree=None, ...
[ "Scan", "the", "cache", "directory", "and", "launch", "analysis", "for", "all", "unscored", "alignments", "using", "associated", "task", "handler", ".", "KWargs", "are", "passed", "to", "the", "tree", "calculating", "task", "managed", "by", "the", "TaskInterface...
python
train
45.341463
eclipse/unide.python
src/unide/util.py
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/util.py#L51-L65
def loads(data, validate=False, **kwargs): """Load a PPMP message from the JSON-formatted string in `data`. When `validate` is set, raise `ValidationError`. Additional keyword arguments are the same that are accepted by `json.loads`, e.g. `indent` to get a pretty output. """ d = json.loads(data,...
[ "def", "loads", "(", "data", ",", "validate", "=", "False", ",", "*", "*", "kwargs", ")", ":", "d", "=", "json", ".", "loads", "(", "data", ",", "*", "*", "kwargs", ")", "content_spec", "=", "d", "[", "\"content-spec\"", "]", "Payload", "=", "CONTE...
Load a PPMP message from the JSON-formatted string in `data`. When `validate` is set, raise `ValidationError`. Additional keyword arguments are the same that are accepted by `json.loads`, e.g. `indent` to get a pretty output.
[ "Load", "a", "PPMP", "message", "from", "the", "JSON", "-", "formatted", "string", "in", "data", ".", "When", "validate", "is", "set", "raise", "ValidationError", ".", "Additional", "keyword", "arguments", "are", "the", "same", "that", "are", "accepted", "by...
python
train
37.2
sdispater/cleo
cleo/commands/command.py
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L142-L146
def confirm(self, question, default=False, true_answer_regex="(?i)^y"): """ Confirm a question with the user. """ return self._io.confirm(question, default, true_answer_regex)
[ "def", "confirm", "(", "self", ",", "question", ",", "default", "=", "False", ",", "true_answer_regex", "=", "\"(?i)^y\"", ")", ":", "return", "self", ".", "_io", ".", "confirm", "(", "question", ",", "default", ",", "true_answer_regex", ")" ]
Confirm a question with the user.
[ "Confirm", "a", "question", "with", "the", "user", "." ]
python
train
40.6
exekias/droplet
droplet/sudo.py
https://github.com/exekias/droplet/blob/aeac573a2c1c4b774e99d5414a1c79b1bb734941/droplet/sudo.py#L29-L56
def set_euid(): """ Set settings.DROPLET_USER effective UID for the current process This adds some security, but nothing magic, an attacker can still gain root access, but at least we only elevate privileges when needed See root context manager """ current = os.geteuid() logger.debug("...
[ "def", "set_euid", "(", ")", ":", "current", "=", "os", ".", "geteuid", "(", ")", "logger", ".", "debug", "(", "\"Current EUID is %s\"", "%", "current", ")", "if", "settings", ".", "DROPLET_USER", "is", "None", ":", "logger", ".", "info", "(", "\"Not cha...
Set settings.DROPLET_USER effective UID for the current process This adds some security, but nothing magic, an attacker can still gain root access, but at least we only elevate privileges when needed See root context manager
[ "Set", "settings", ".", "DROPLET_USER", "effective", "UID", "for", "the", "current", "process" ]
python
train
34.25
pyblish/pyblish-qml
pyblish_qml/vendor/mock.py
https://github.com/pyblish/pyblish-qml/blob/6095d18b2ec0afd0409a9b1a17e53b0658887283/pyblish_qml/vendor/mock.py#L243-L258
def _instance_callable(obj): """Given an object, return True if the object is callable. For classes, return True if instances would be callable.""" if not isinstance(obj, ClassTypes): # already an instance return getattr(obj, '__call__', None) is not None klass = obj # uses __bases_...
[ "def", "_instance_callable", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "ClassTypes", ")", ":", "# already an instance", "return", "getattr", "(", "obj", ",", "'__call__'", ",", "None", ")", "is", "not", "None", "klass", "=", "obj", ...
Given an object, return True if the object is callable. For classes, return True if instances would be callable.
[ "Given", "an", "object", "return", "True", "if", "the", "object", "is", "callable", ".", "For", "classes", "return", "True", "if", "instances", "would", "be", "callable", "." ]
python
train
34.1875
sixty-north/cosmic-ray
scripts/cosmic_ray_tooling.py
https://github.com/sixty-north/cosmic-ray/blob/c654e074afbb7b7fcbc23359083c1287c0d3e991/scripts/cosmic_ray_tooling.py#L49-L54
def read_version(version_file): "Read the `(version-string, version-info)` from `version_file`." vars = {} with open(version_file) as f: exec(f.read(), {}, vars) return (vars['__version__'], vars['__version_info__'])
[ "def", "read_version", "(", "version_file", ")", ":", "vars", "=", "{", "}", "with", "open", "(", "version_file", ")", "as", "f", ":", "exec", "(", "f", ".", "read", "(", ")", ",", "{", "}", ",", "vars", ")", "return", "(", "vars", "[", "'__versi...
Read the `(version-string, version-info)` from `version_file`.
[ "Read", "the", "(", "version", "-", "string", "version", "-", "info", ")", "from", "version_file", "." ]
python
train
39.166667
helixyte/everest
everest/repositories/state.py
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/state.py#L113-L135
def set_state_data(cls, entity, data): """ Sets the state data for the given entity to the given data. This also works for unmanaged entities. """ attr_names = get_domain_class_attribute_names(type(entity)) nested_items = [] for attr, new_attr_value in iteritems_...
[ "def", "set_state_data", "(", "cls", ",", "entity", ",", "data", ")", ":", "attr_names", "=", "get_domain_class_attribute_names", "(", "type", "(", "entity", ")", ")", "nested_items", "=", "[", "]", "for", "attr", ",", "new_attr_value", "in", "iteritems_", "...
Sets the state data for the given entity to the given data. This also works for unmanaged entities.
[ "Sets", "the", "state", "data", "for", "the", "given", "entity", "to", "the", "given", "data", "." ]
python
train
42.391304
boriel/zxbasic
api/symboltable.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/api/symboltable.py#L812-L819
def check_classes(self, scope=-1): """ Check if pending identifiers are defined or not. If not, returns a syntax error. If no scope is given, the current one is checked. """ for entry in self[scope].values(): if entry.class_ is None: syntax_error(entry...
[ "def", "check_classes", "(", "self", ",", "scope", "=", "-", "1", ")", ":", "for", "entry", "in", "self", "[", "scope", "]", ".", "values", "(", ")", ":", "if", "entry", ".", "class_", "is", "None", ":", "syntax_error", "(", "entry", ".", "lineno",...
Check if pending identifiers are defined or not. If not, returns a syntax error. If no scope is given, the current one is checked.
[ "Check", "if", "pending", "identifiers", "are", "defined", "or", "not", ".", "If", "not", "returns", "a", "syntax", "error", ".", "If", "no", "scope", "is", "given", "the", "current", "one", "is", "checked", "." ]
python
train
45.125
fp12/achallonge
challonge/tournament.py
https://github.com/fp12/achallonge/blob/25780b3c48b66400a50ff9f884e4287afd4c89e4/challonge/tournament.py#L511-L531
async def get_participant(self, p_id: int, force_update=False) -> Participant: """ get a participant by its id |methcoro| Args: p_id: participant id force_update (dfault=False): True to force an update to the Challonge API Returns: Participant: None...
[ "async", "def", "get_participant", "(", "self", ",", "p_id", ":", "int", ",", "force_update", "=", "False", ")", "->", "Participant", ":", "found_p", "=", "self", ".", "_find_participant", "(", "p_id", ")", "if", "force_update", "or", "found_p", "is", "Non...
get a participant by its id |methcoro| Args: p_id: participant id force_update (dfault=False): True to force an update to the Challonge API Returns: Participant: None if not found Raises: APIException
[ "get", "a", "participant", "by", "its", "id" ]
python
train
27.380952
DAI-Lab/Copulas
copulas/__init__.py
https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/__init__.py#L38-L41
def import_object(object_name): """Import an object from its Fully Qualified Name.""" package, name = object_name.rsplit('.', 1) return getattr(importlib.import_module(package), name)
[ "def", "import_object", "(", "object_name", ")", ":", "package", ",", "name", "=", "object_name", ".", "rsplit", "(", "'.'", ",", "1", ")", "return", "getattr", "(", "importlib", ".", "import_module", "(", "package", ")", ",", "name", ")" ]
Import an object from its Fully Qualified Name.
[ "Import", "an", "object", "from", "its", "Fully", "Qualified", "Name", "." ]
python
train
48
mattupstate/flask-security
flask_security/utils.py
https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/utils.py#L501-L517
def capture_reset_password_requests(reset_password_sent_at=None): """Testing utility for capturing password reset requests. :param reset_password_sent_at: An optional datetime object to set the user's `reset_password_sent_at` to """ reset_requests = [] def _on(ap...
[ "def", "capture_reset_password_requests", "(", "reset_password_sent_at", "=", "None", ")", ":", "reset_requests", "=", "[", "]", "def", "_on", "(", "app", ",", "*", "*", "data", ")", ":", "reset_requests", ".", "append", "(", "data", ")", "reset_password_instr...
Testing utility for capturing password reset requests. :param reset_password_sent_at: An optional datetime object to set the user's `reset_password_sent_at` to
[ "Testing", "utility", "for", "capturing", "password", "reset", "requests", "." ]
python
train
30.058824
eandersson/amqpstorm
amqpstorm/channel0.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/channel0.py#L140-L166
def _send_start_ok(self, frame_in): """Send Start OK frame. :param specification.Connection.Start frame_in: Amqp frame. :return: """ mechanisms = try_utf8_decode(frame_in.mechanisms) if 'EXTERNAL' in mechanisms: mechanism = 'EXTERNAL' credentials ...
[ "def", "_send_start_ok", "(", "self", ",", "frame_in", ")", ":", "mechanisms", "=", "try_utf8_decode", "(", "frame_in", ".", "mechanisms", ")", "if", "'EXTERNAL'", "in", "mechanisms", ":", "mechanism", "=", "'EXTERNAL'", "credentials", "=", "'\\0\\0'", "elif", ...
Send Start OK frame. :param specification.Connection.Start frame_in: Amqp frame. :return:
[ "Send", "Start", "OK", "frame", "." ]
python
train
34.333333
seantis/suitable
suitable/api.py
https://github.com/seantis/suitable/blob/b056afb753f2b89909edfb6e00ec7c55691135ff/suitable/api.py#L280-L295
def valid_return_codes(self, *codes): """ Sets codes which are considered valid when returned from command modules. The default is (0, ). Should be used as a context:: with api.valid_return_codes(0, 1): api.shell('test -e /tmp/log && rm /tmp/log') """ ...
[ "def", "valid_return_codes", "(", "self", ",", "*", "codes", ")", ":", "previous_codes", "=", "self", ".", "_valid_return_codes", "self", ".", "_valid_return_codes", "=", "codes", "yield", "self", ".", "_valid_return_codes", "=", "previous_codes" ]
Sets codes which are considered valid when returned from command modules. The default is (0, ). Should be used as a context:: with api.valid_return_codes(0, 1): api.shell('test -e /tmp/log && rm /tmp/log')
[ "Sets", "codes", "which", "are", "considered", "valid", "when", "returned", "from", "command", "modules", ".", "The", "default", "is", "(", "0", ")", "." ]
python
train
28.5
estnltk/estnltk
estnltk/mw_verbs/utils.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/utils.py#L127-L164
def matches(self, tokenJson): '''Determines whether given token (tokenJson) satisfies all the rules listed in the WordTemplate. If the rules describe tokenJson[ANALYSIS], it is required that at least one item in the list tokenJson[ANALYSIS] satisfies all the rules (but it...
[ "def", "matches", "(", "self", ",", "tokenJson", ")", ":", "if", "self", ".", "otherRules", "!=", "None", ":", "otherMatches", "=", "[", "]", "for", "field", "in", "self", ".", "otherRules", ":", "match", "=", "field", "in", "tokenJson", "and", "(", ...
Determines whether given token (tokenJson) satisfies all the rules listed in the WordTemplate. If the rules describe tokenJson[ANALYSIS], it is required that at least one item in the list tokenJson[ANALYSIS] satisfies all the rules (but it is not required that all the items should...
[ "Determines", "whether", "given", "token", "(", "tokenJson", ")", "satisfies", "all", "the", "rules", "listed", "in", "the", "WordTemplate", ".", "If", "the", "rules", "describe", "tokenJson", "[", "ANALYSIS", "]", "it", "is", "required", "that", "at", "leas...
python
train
49.026316
crytic/slither
slither/core/cfg/node.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/core/cfg/node.py#L433-L449
def is_conditional(self, include_loop=True): """ Check if the node is a conditional node A conditional node is either a IF or a require/assert or a RETURN bool Returns: bool: True if the node is a conditional node """ if self.contains_if(include_loop) ...
[ "def", "is_conditional", "(", "self", ",", "include_loop", "=", "True", ")", ":", "if", "self", ".", "contains_if", "(", "include_loop", ")", "or", "self", ".", "contains_require_or_assert", "(", ")", ":", "return", "True", "if", "self", ".", "irs", ":", ...
Check if the node is a conditional node A conditional node is either a IF or a require/assert or a RETURN bool Returns: bool: True if the node is a conditional node
[ "Check", "if", "the", "node", "is", "a", "conditional", "node", "A", "conditional", "node", "is", "either", "a", "IF", "or", "a", "require", "/", "assert", "or", "a", "RETURN", "bool", "Returns", ":", "bool", ":", "True", "if", "the", "node", "is", "...
python
train
38.705882
yakupadakli/python-unsplash
unsplash/photo.py
https://github.com/yakupadakli/python-unsplash/blob/6e43dce3225237e1b8111fd475fb98b1ea33972c/unsplash/photo.py#L80-L109
def search(self, query, category=None, orientation=None, page=1, per_page=10): """ Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s. Note: If supplying multiple category ID’s, the resulting photos will be t...
[ "def", "search", "(", "self", ",", "query", ",", "category", "=", "None", ",", "orientation", "=", "None", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "if", "orientation", "and", "orientation", "not", "in", "self", ".", "orientation_va...
Get a single page from a photo search. Optionally limit your search to a set of categories by supplying the category ID’s. Note: If supplying multiple category ID’s, the resulting photos will be those that match all of the given categories, not ones that match any category. :pa...
[ "Get", "a", "single", "page", "from", "a", "photo", "search", ".", "Optionally", "limit", "your", "search", "to", "a", "set", "of", "categories", "by", "supplying", "the", "category", "ID’s", "." ]
python
train
47.633333
jmoiron/johnny-cache
johnny/transaction.py
https://github.com/jmoiron/johnny-cache/blob/d96ea94c5dfcde517ff8f65d6ba4e435d8a0168c/johnny/transaction.py#L81-L93
def set(self, key, val, timeout=None, using=None): """ Set will be using the generational key, so if another thread bumps this key, the localstore version will still be invalid. If the key is bumped during a transaction it will be new to the global cache on commit, so it will sti...
[ "def", "set", "(", "self", ",", "key", ",", "val", ",", "timeout", "=", "None", ",", "using", "=", "None", ")", ":", "if", "timeout", "is", "None", ":", "timeout", "=", "self", ".", "timeout", "if", "self", ".", "is_managed", "(", "using", "=", "...
Set will be using the generational key, so if another thread bumps this key, the localstore version will still be invalid. If the key is bumped during a transaction it will be new to the global cache on commit, so it will still be a bump.
[ "Set", "will", "be", "using", "the", "generational", "key", "so", "if", "another", "thread", "bumps", "this", "key", "the", "localstore", "version", "will", "still", "be", "invalid", ".", "If", "the", "key", "is", "bumped", "during", "a", "transaction", "i...
python
train
43.153846
UCL-INGI/INGInious
inginious/frontend/user_manager.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/user_manager.py#L518-L523
def user_saw_task(self, username, courseid, taskid): """ Set in the database that the user has viewed this task """ self._database.user_tasks.update({"username": username, "courseid": courseid, "taskid": taskid}, {"$setOnInsert": {"username": username, "courseid"...
[ "def", "user_saw_task", "(", "self", ",", "username", ",", "courseid", ",", "taskid", ")", ":", "self", ".", "_database", ".", "user_tasks", ".", "update", "(", "{", "\"username\"", ":", "username", ",", "\"courseid\"", ":", "courseid", ",", "\"taskid\"", ...
Set in the database that the user has viewed this task
[ "Set", "in", "the", "database", "that", "the", "user", "has", "viewed", "this", "task" ]
python
train
90
googleapis/google-cloud-python
logging/docs/snippets.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/docs/snippets.py#L104-L112
def client_list_entries_multi_project( client, to_delete ): # pylint: disable=unused-argument """List entries via client across multiple projects.""" # [START client_list_entries_multi_project] PROJECT_IDS = ["one-project", "another-project"] for entry in client.list_entries(project_ids=PROJECT_ID...
[ "def", "client_list_entries_multi_project", "(", "client", ",", "to_delete", ")", ":", "# pylint: disable=unused-argument", "# [START client_list_entries_multi_project]", "PROJECT_IDS", "=", "[", "\"one-project\"", ",", "\"another-project\"", "]", "for", "entry", "in", "clien...
List entries via client across multiple projects.
[ "List", "entries", "via", "client", "across", "multiple", "projects", "." ]
python
train
40.333333
mikedh/trimesh
trimesh/primitives.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/primitives.py#L548-L556
def is_oriented(self): """ Returns whether or not the current box is rotated at all. """ if util.is_shape(self.primitive.transform, (4, 4)): return not np.allclose(self.primitive.transform[ 0:3, 0:3], np.eye(3)) else: ret...
[ "def", "is_oriented", "(", "self", ")", ":", "if", "util", ".", "is_shape", "(", "self", ".", "primitive", ".", "transform", ",", "(", "4", ",", "4", ")", ")", ":", "return", "not", "np", ".", "allclose", "(", "self", ".", "primitive", ".", "transf...
Returns whether or not the current box is rotated at all.
[ "Returns", "whether", "or", "not", "the", "current", "box", "is", "rotated", "at", "all", "." ]
python
train
35.666667
c0fec0de/anytree
anytree/importer/jsonimporter.py
https://github.com/c0fec0de/anytree/blob/775477e206a75e697983e70dae6372b5a7e42dcf/anytree/importer/jsonimporter.py#L60-L62
def import_(self, data): """Read JSON from `data`.""" return self.__import(json.loads(data, **self.kwargs))
[ "def", "import_", "(", "self", ",", "data", ")", ":", "return", "self", ".", "__import", "(", "json", ".", "loads", "(", "data", ",", "*", "*", "self", ".", "kwargs", ")", ")" ]
Read JSON from `data`.
[ "Read", "JSON", "from", "data", "." ]
python
train
40.333333
simpleai-team/simpleai
simpleai/search/models.py
https://github.com/simpleai-team/simpleai/blob/2836befa7e970013f62e0ee75562652aacac6f65/simpleai/search/models.py#L102-L117
def expand(self, local_search=False): '''Create successors.''' new_nodes = [] for action in self.problem.actions(self.state): new_state = self.problem.result(self.state, action) cost = self.problem.cost(self.state, action, ...
[ "def", "expand", "(", "self", ",", "local_search", "=", "False", ")", ":", "new_nodes", "=", "[", "]", "for", "action", "in", "self", ".", "problem", ".", "actions", "(", "self", ".", "state", ")", ":", "new_state", "=", "self", ".", "problem", ".", ...
Create successors.
[ "Create", "successors", "." ]
python
train
49.4375
rcarmo/pngcanvas
pngcanvas.py
https://github.com/rcarmo/pngcanvas/blob/e2eaa0d5ba353005b3b658f6ee453c1956340670/pngcanvas.py#L237-L251
def dump(self): """Dump the image data""" scan_lines = bytearray() for y in range(self.height): scan_lines.append(0) # filter type 0 (None) scan_lines.extend( self.canvas[(y * self.width * 4):((y + 1) * self.width * 4)] ) # image repre...
[ "def", "dump", "(", "self", ")", ":", "scan_lines", "=", "bytearray", "(", ")", "for", "y", "in", "range", "(", "self", ".", "height", ")", ":", "scan_lines", ".", "append", "(", "0", ")", "# filter type 0 (None)", "scan_lines", ".", "extend", "(", "se...
Dump the image data
[ "Dump", "the", "image", "data" ]
python
train
46.266667
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/bluez_dbus/gatt.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/bluez_dbus/gatt.py#L111-L117
def list_descriptors(self): """Return list of GATT descriptors that have been discovered for this characteristic. """ paths = self._props.Get(_CHARACTERISTIC_INTERFACE, 'Descriptors') return map(BluezGattDescriptor, get_provider()._get_objects_by_path(paths))
[ "def", "list_descriptors", "(", "self", ")", ":", "paths", "=", "self", ".", "_props", ".", "Get", "(", "_CHARACTERISTIC_INTERFACE", ",", "'Descriptors'", ")", "return", "map", "(", "BluezGattDescriptor", ",", "get_provider", "(", ")", ".", "_get_objects_by_path...
Return list of GATT descriptors that have been discovered for this characteristic.
[ "Return", "list", "of", "GATT", "descriptors", "that", "have", "been", "discovered", "for", "this", "characteristic", "." ]
python
valid
44.571429
user-cont/conu
conu/backend/k8s/client.py
https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/k8s/client.py#L52-L71
def get_apps_api(): """ Create instance of Apps V1 API of kubernetes: https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md :return: instance of client """ global apps_api if apps_api is None: config.load_kube_config() if API_KEY is not None: ...
[ "def", "get_apps_api", "(", ")", ":", "global", "apps_api", "if", "apps_api", "is", "None", ":", "config", ".", "load_kube_config", "(", ")", "if", "API_KEY", "is", "not", "None", ":", "# Configure API key authorization: BearerToken", "configuration", "=", "client...
Create instance of Apps V1 API of kubernetes: https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/AppsV1Api.md :return: instance of client
[ "Create", "instance", "of", "Apps", "V1", "API", "of", "kubernetes", ":", "https", ":", "//", "github", ".", "com", "/", "kubernetes", "-", "client", "/", "python", "/", "blob", "/", "master", "/", "kubernetes", "/", "docs", "/", "AppsV1Api", ".", "md"...
python
train
34.45
tipsi/tipsi_tools
tipsi_tools/unix.py
https://github.com/tipsi/tipsi_tools/blob/1aba960c9890ceef2fb5e215b98b1646056ee58e/tipsi_tools/unix.py#L143-L148
def interpolate_sysenv(line, defaults={}): ''' Format line system environment variables + defaults ''' map = ChainMap(os.environ, defaults) return line.format(**map)
[ "def", "interpolate_sysenv", "(", "line", ",", "defaults", "=", "{", "}", ")", ":", "map", "=", "ChainMap", "(", "os", ".", "environ", ",", "defaults", ")", "return", "line", ".", "format", "(", "*", "*", "map", ")" ]
Format line system environment variables + defaults
[ "Format", "line", "system", "environment", "variables", "+", "defaults" ]
python
train
30
singularityhub/sregistry-cli
sregistry/main/google_build/query.py
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_build/query.py#L78-L105
def container_query(self, query, quiet=False): '''search for a specific container. This function would likely be similar to the above, but have different filter criteria from the user (based on the query) ''' results = self._list_containers() matches = [] for result in results: ...
[ "def", "container_query", "(", "self", ",", "query", ",", "quiet", "=", "False", ")", ":", "results", "=", "self", ".", "_list_containers", "(", ")", "matches", "=", "[", "]", "for", "result", "in", "results", ":", "for", "key", ",", "val", "in", "re...
search for a specific container. This function would likely be similar to the above, but have different filter criteria from the user (based on the query)
[ "search", "for", "a", "specific", "container", ".", "This", "function", "would", "likely", "be", "similar", "to", "the", "above", "but", "have", "different", "filter", "criteria", "from", "the", "user", "(", "based", "on", "the", "query", ")" ]
python
test
43.535714
indico/indico-plugins
chat/indico_chat/notifications.py
https://github.com/indico/indico-plugins/blob/fe50085cc63be9b8161b09539e662e7b04e4b38e/chat/indico_chat/notifications.py#L23-L31
def notify_created(room, event, user): """Notifies about the creation of a chatroom. :param room: the chatroom :param event: the event :param user: the user performing the action """ tpl = get_plugin_template_module('emails/created.txt', chatroom=room, event=event, user=user) _send(event, t...
[ "def", "notify_created", "(", "room", ",", "event", ",", "user", ")", ":", "tpl", "=", "get_plugin_template_module", "(", "'emails/created.txt'", ",", "chatroom", "=", "room", ",", "event", "=", "event", ",", "user", "=", "user", ")", "_send", "(", "event"...
Notifies about the creation of a chatroom. :param room: the chatroom :param event: the event :param user: the user performing the action
[ "Notifies", "about", "the", "creation", "of", "a", "chatroom", "." ]
python
train
35
andycasey/sick
sick/plot.py
https://github.com/andycasey/sick/blob/6c37686182794c4cafea45abf7062b30b789b1a2/sick/plot.py#L150-L263
def chains(xs, labels=None, truths=None, truth_color=u"#4682b4", burn=None, alpha=0.5, fig=None): """ Create a plot showing the walker values for each parameter at every step. :param xs: The samples. This should be a 3D :class:`numpy.ndarray` of size (``n_walkers``, ``n_steps``, ``n_pa...
[ "def", "chains", "(", "xs", ",", "labels", "=", "None", ",", "truths", "=", "None", ",", "truth_color", "=", "u\"#4682b4\"", ",", "burn", "=", "None", ",", "alpha", "=", "0.5", ",", "fig", "=", "None", ")", ":", "n_walkers", ",", "n_steps", ",", "K...
Create a plot showing the walker values for each parameter at every step. :param xs: The samples. This should be a 3D :class:`numpy.ndarray` of size (``n_walkers``, ``n_steps``, ``n_parameters``). :type xs: :class:`numpy.ndarray` :param labels: [optional] Labels for all t...
[ "Create", "a", "plot", "showing", "the", "walker", "values", "for", "each", "parameter", "at", "every", "step", "." ]
python
train
24.719298
trailofbits/manticore
manticore/platforms/evm.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/evm.py#L699-L708
def read_code(self, address, size=1): """ Read size byte from bytecode. If less than size bytes are available result will be pad with \x00 """ assert address < len(self.bytecode) value = self.bytecode[address:address + size] if len(value) < size: value...
[ "def", "read_code", "(", "self", ",", "address", ",", "size", "=", "1", ")", ":", "assert", "address", "<", "len", "(", "self", ".", "bytecode", ")", "value", "=", "self", ".", "bytecode", "[", "address", ":", "address", "+", "size", "]", "if", "le...
Read size byte from bytecode. If less than size bytes are available result will be pad with \x00
[ "Read", "size", "byte", "from", "bytecode", ".", "If", "less", "than", "size", "bytes", "are", "available", "result", "will", "be", "pad", "with", "\\", "x00" ]
python
valid
38.8
bitesofcode/projex
projex/security.py
https://github.com/bitesofcode/projex/blob/d31743ec456a41428709968ab11a2cf6c6c76247/projex/security.py#L228-L238
def pad(text, bits=32): """ Pads the inputted text to ensure it fits the proper block length for encryption. :param text | <str> bits | <int> :return <str> """ return text + (bits - len(text) % bits) * chr(bits - len(text) % bits)
[ "def", "pad", "(", "text", ",", "bits", "=", "32", ")", ":", "return", "text", "+", "(", "bits", "-", "len", "(", "text", ")", "%", "bits", ")", "*", "chr", "(", "bits", "-", "len", "(", "text", ")", "%", "bits", ")" ]
Pads the inputted text to ensure it fits the proper block length for encryption. :param text | <str> bits | <int> :return <str>
[ "Pads", "the", "inputted", "text", "to", "ensure", "it", "fits", "the", "proper", "block", "length", "for", "encryption", ".", ":", "param", "text", "|", "<str", ">", "bits", "|", "<int", ">", ":", "return", "<str", ">" ]
python
train
25.727273
markuskiller/textblob-de
textblob_de/ext/_pattern/text/tree.py
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1207-L1211
def tree(string, token=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]): """ Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string. """ return Text(string, token)
[ "def", "tree", "(", "string", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "ANCHOR", ",", "LEMMA", "]", ")", ":", "return", "Text", "(", "string", ",", "token", ")" ]
Transforms the output of parse() into a Text object. The token parameter lists the order of tags in each token in the input string.
[ "Transforms", "the", "output", "of", "parse", "()", "into", "a", "Text", "object", ".", "The", "token", "parameter", "lists", "the", "order", "of", "tags", "in", "each", "token", "in", "the", "input", "string", "." ]
python
train
50.2
sentinel-hub/sentinelhub-py
sentinelhub/aws.py
https://github.com/sentinel-hub/sentinelhub-py/blob/08a83b7f1e289187159a643336995d8369860fea/sentinelhub/aws.py#L163-L175
def url_to_tile(url): """ Extracts tile name, date and AWS index from tile url on AWS. :param url: class input parameter 'metafiles' :type url: str :return: Name of tile, date and AWS index which uniquely identifies tile on AWS :rtype: (str, str, int) """ ...
[ "def", "url_to_tile", "(", "url", ")", ":", "info", "=", "url", ".", "strip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "name", "=", "''", ".", "join", "(", "info", "[", "-", "7", ":", "-", "4", "]", ")", "date", "=", "'-'", ".", "joi...
Extracts tile name, date and AWS index from tile url on AWS. :param url: class input parameter 'metafiles' :type url: str :return: Name of tile, date and AWS index which uniquely identifies tile on AWS :rtype: (str, str, int)
[ "Extracts", "tile", "name", "date", "and", "AWS", "index", "from", "tile", "url", "on", "AWS", "." ]
python
train
35.153846
dnanexus/dx-toolkit
src/python/dxpy/utils/resolver.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/utils/resolver.py#L288-L314
def split_unescaped(char, string, include_empty_strings=False): ''' :param char: The character on which to split the string :type char: string :param string: The string to split :type string: string :returns: List of substrings of *string* :rtype: list of strings Splits *string* wheneve...
[ "def", "split_unescaped", "(", "char", ",", "string", ",", "include_empty_strings", "=", "False", ")", ":", "words", "=", "[", "]", "pos", "=", "len", "(", "string", ")", "lastpos", "=", "pos", "while", "pos", ">=", "0", ":", "pos", "=", "get_last_pos_...
:param char: The character on which to split the string :type char: string :param string: The string to split :type string: string :returns: List of substrings of *string* :rtype: list of strings Splits *string* whenever *char* appears without an odd number of backslashes ('\\') preceding i...
[ ":", "param", "char", ":", "The", "character", "on", "which", "to", "split", "the", "string", ":", "type", "char", ":", "string", ":", "param", "string", ":", "The", "string", "to", "split", ":", "type", "string", ":", "string", ":", "returns", ":", ...
python
train
31.148148
blockstack/blockstack-core
blockstack/lib/fast_sync.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L114-L180
def fast_sync_sign_snapshot( snapshot_path, private_key, first=False ): """ Append a signature to the end of a snapshot path with the given private key. If first is True, then don't expect the signature trailer. Return True on success Return False on error """ if not os.path.exists...
[ "def", "fast_sync_sign_snapshot", "(", "snapshot_path", ",", "private_key", ",", "first", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "snapshot_path", ")", ":", "log", ".", "error", "(", "\"No such file or directory: {}\"", ".",...
Append a signature to the end of a snapshot path with the given private key. If first is True, then don't expect the signature trailer. Return True on success Return False on error
[ "Append", "a", "signature", "to", "the", "end", "of", "a", "snapshot", "path", "with", "the", "given", "private", "key", "." ]
python
train
29.179104
facetoe/zenpy
zenpy/lib/api.py
https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L834-L838
def skips(self, user): """ Skips for user. Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/ticket_skips>`__. """ return self._get(self._build_url(self.endpoint.skips(id=user)))
[ "def", "skips", "(", "self", ",", "user", ")", ":", "return", "self", ".", "_get", "(", "self", ".", "_build_url", "(", "self", ".", "endpoint", ".", "skips", "(", "id", "=", "user", ")", ")", ")" ]
Skips for user. Zendesk API `Reference <https://developer.zendesk.com/rest_api/docs/core/ticket_skips>`__.
[ "Skips", "for", "user", ".", "Zendesk", "API", "Reference", "<https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "core", "/", "ticket_skips", ">", "__", "." ]
python
train
45.8