repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
StackStorm/pybind
pybind/slxos/v17s_1_02/isis_state/interface_brief/isis_intf_brief/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/isis_state/interface_brief/isis_intf_brief/__init__.py#L147-L170
def _set_circuit_type(self, v, load=False): """ Setter method for circuit_type, mapped from YANG variable /isis_state/interface_brief/isis_intf_brief/circuit_type (isis-circ-type) If this variable is read-only (config: false) in the source YANG file, then _set_circuit_type is considered as a private ...
[ "def", "_set_circuit_type", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "b...
Setter method for circuit_type, mapped from YANG variable /isis_state/interface_brief/isis_intf_brief/circuit_type (isis-circ-type) If this variable is read-only (config: false) in the source YANG file, then _set_circuit_type is considered as a private method. Backends looking to populate this variable shou...
[ "Setter", "method", "for", "circuit_type", "mapped", "from", "YANG", "variable", "/", "isis_state", "/", "interface_brief", "/", "isis_intf_brief", "/", "circuit_type", "(", "isis", "-", "circ", "-", "type", ")", "If", "this", "variable", "is", "read", "-", ...
python
train
nalourie/django-macros
build/lib/macros/templatetags/macros.py
https://github.com/nalourie/django-macros/blob/94b836f5d4073bc0752491c36dfb03e79098ab27/build/lib/macros/templatetags/macros.py#L267-L279
def do_usemacro(parser, token): """ The function taking a parsed template tag and returning a UseMacroNode. """ tag_name, macro_name, args, kwargs = parse_macro_params(token) try: macro = parser._macros[macro_name] except (AttributeError, KeyError): raise template.TemplateSyntaxE...
[ "def", "do_usemacro", "(", "parser", ",", "token", ")", ":", "tag_name", ",", "macro_name", ",", "args", ",", "kwargs", "=", "parse_macro_params", "(", "token", ")", "try", ":", "macro", "=", "parser", ".", "_macros", "[", "macro_name", "]", "except", "(...
The function taking a parsed template tag and returning a UseMacroNode.
[ "The", "function", "taking", "a", "parsed", "template", "tag", "and", "returning", "a", "UseMacroNode", "." ]
python
train
contains-io/rcli
rcli/dispatcher.py
https://github.com/contains-io/rcli/blob/cdd6191a0e0a19bc767f84921650835d099349cf/rcli/dispatcher.py#L126-L144
def _get_parsed_args(command_name, doc, argv): # type: (str, str, typing.List[str]) -> typing.Dict[str, typing.Any] """Parse the docstring with docopt. Args: command_name: The name of the subcommand to parse. doc: A docopt-parseable string. argv: The list of arguments to pass to doc...
[ "def", "_get_parsed_args", "(", "command_name", ",", "doc", ",", "argv", ")", ":", "# type: (str, str, typing.List[str]) -> typing.Dict[str, typing.Any]", "_LOGGER", ".", "debug", "(", "'Parsing docstring: \"\"\"%s\"\"\" with arguments %s.'", ",", "doc", ",", "argv", ")", "...
Parse the docstring with docopt. Args: command_name: The name of the subcommand to parse. doc: A docopt-parseable string. argv: The list of arguments to pass to docopt during parsing. Returns: The docopt results dictionary. If the subcommand has the same name as the pri...
[ "Parse", "the", "docstring", "with", "docopt", "." ]
python
train
bmuller/kademlia
kademlia/network.py
https://github.com/bmuller/kademlia/blob/4a8d445c9ee8f3ca10f56107e4445daed4933c8a/kademlia/network.py#L102-L113
def bootstrappable_neighbors(self): """ Get a :class:`list` of (ip, port) :class:`tuple` pairs suitable for use as an argument to the bootstrap method. The server should have been bootstrapped already - this is just a utility for getting some neighbors and then storing t...
[ "def", "bootstrappable_neighbors", "(", "self", ")", ":", "neighbors", "=", "self", ".", "protocol", ".", "router", ".", "find_neighbors", "(", "self", ".", "node", ")", "return", "[", "tuple", "(", "n", ")", "[", "-", "2", ":", "]", "for", "n", "in"...
Get a :class:`list` of (ip, port) :class:`tuple` pairs suitable for use as an argument to the bootstrap method. The server should have been bootstrapped already - this is just a utility for getting some neighbors and then storing them if this server is going down for a while. When it c...
[ "Get", "a", ":", "class", ":", "list", "of", "(", "ip", "port", ")", ":", "class", ":", "tuple", "pairs", "suitable", "for", "use", "as", "an", "argument", "to", "the", "bootstrap", "method", "." ]
python
train
LEMS/pylems
lems/model/model.py
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/model.py#L328-L347
def resolve(self): """ Resolves references in this model. """ model = self.copy() for ct in model.component_types: model.resolve_component_type(ct) for c in model.components: if c.id not in model.fat_components: model.add...
[ "def", "resolve", "(", "self", ")", ":", "model", "=", "self", ".", "copy", "(", ")", "for", "ct", "in", "model", ".", "component_types", ":", "model", ".", "resolve_component_type", "(", "ct", ")", "for", "c", "in", "model", ".", "components", ":", ...
Resolves references in this model.
[ "Resolves", "references", "in", "this", "model", "." ]
python
train
michaeljoseph/changes
changes/version.py
https://github.com/michaeljoseph/changes/blob/a8beb409671c58cdf28ee913bad0a5c7d5374ade/changes/version.py#L59-L67
def increment_version(context): """Increments the __version__ attribute of your module's __init__.""" attributes.replace_attribute( context.module_name, '__version__', context.new_version, dry_run=context.dry_run ) log.info( 'Bumped version from %s to %s' % (context.current_version, con...
[ "def", "increment_version", "(", "context", ")", ":", "attributes", ".", "replace_attribute", "(", "context", ".", "module_name", ",", "'__version__'", ",", "context", ".", "new_version", ",", "dry_run", "=", "context", ".", "dry_run", ")", "log", ".", "info",...
Increments the __version__ attribute of your module's __init__.
[ "Increments", "the", "__version__", "attribute", "of", "your", "module", "s", "__init__", "." ]
python
train
bharadwaj-raju/libdesktop
libdesktop/system.py
https://github.com/bharadwaj-raju/libdesktop/blob/4d6b815755c76660b6ef4d2db6f54beff38c0db7/libdesktop/system.py#L56-L174
def get_name(): '''Get desktop environment or OS. Get the OS name or desktop environment. **List of Possible Values** +-------------------------+---------------+ | Windows | windows | +-------------------------+---------------+ | Mac OS X | mac | +-------------------------+---------------+ | G...
[ "def", "get_name", "(", ")", ":", "if", "sys", ".", "platform", "in", "[", "'win32'", ",", "'cygwin'", "]", ":", "return", "'windows'", "elif", "sys", ".", "platform", "==", "'darwin'", ":", "return", "'mac'", "else", ":", "desktop_session", "=", "os", ...
Get desktop environment or OS. Get the OS name or desktop environment. **List of Possible Values** +-------------------------+---------------+ | Windows | windows | +-------------------------+---------------+ | Mac OS X | mac | +-------------------------+---------------+ | GNOME 3+ | gnome ...
[ "Get", "desktop", "environment", "or", "OS", "." ]
python
train
pybel/pybel-tools
src/pybel_tools/filters/node_deletion.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/filters/node_deletion.py#L54-L60
def remove_nodes_by_function_namespace(graph: BELGraph, func: str, namespace: Strings) -> None: """Remove nodes with the given function and namespace. This might be useful to exclude information learned about distant species, such as excluding all information from MGI and RGD in diseases where mice and rat...
[ "def", "remove_nodes_by_function_namespace", "(", "graph", ":", "BELGraph", ",", "func", ":", "str", ",", "namespace", ":", "Strings", ")", "->", "None", ":", "remove_filtered_nodes", "(", "graph", ",", "function_namespace_inclusion_builder", "(", "func", ",", "na...
Remove nodes with the given function and namespace. This might be useful to exclude information learned about distant species, such as excluding all information from MGI and RGD in diseases where mice and rats don't give much insight to the human disease mechanism.
[ "Remove", "nodes", "with", "the", "given", "function", "and", "namespace", "." ]
python
valid
vtkiorg/vtki
vtki/renderer.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/renderer.py#L774-L791
def _remove_mapper_from_plotter(plotter, actor, reset_camera): """removes this actor's mapper from the given plotter's _scalar_bar_mappers""" try: mapper = actor.GetMapper() except AttributeError: return for name in list(plotter._scalar_bar_mappers.keys()): try: plott...
[ "def", "_remove_mapper_from_plotter", "(", "plotter", ",", "actor", ",", "reset_camera", ")", ":", "try", ":", "mapper", "=", "actor", ".", "GetMapper", "(", ")", "except", "AttributeError", ":", "return", "for", "name", "in", "list", "(", "plotter", ".", ...
removes this actor's mapper from the given plotter's _scalar_bar_mappers
[ "removes", "this", "actor", "s", "mapper", "from", "the", "given", "plotter", "s", "_scalar_bar_mappers" ]
python
train
allenai/allennlp
allennlp/semparse/contexts/table_question_context.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/table_question_context.py#L342-L357
def _string_in_table(self, candidate: str) -> List[str]: """ Checks if the string occurs in the table, and if it does, returns the names of the columns under which it occurs. If it does not, returns an empty list. """ candidate_column_names: List[str] = [] # First check i...
[ "def", "_string_in_table", "(", "self", ",", "candidate", ":", "str", ")", "->", "List", "[", "str", "]", ":", "candidate_column_names", ":", "List", "[", "str", "]", "=", "[", "]", "# First check if the entire candidate occurs as a cell.", "if", "candidate", "i...
Checks if the string occurs in the table, and if it does, returns the names of the columns under which it occurs. If it does not, returns an empty list.
[ "Checks", "if", "the", "string", "occurs", "in", "the", "table", "and", "if", "it", "does", "returns", "the", "names", "of", "the", "columns", "under", "which", "it", "occurs", ".", "If", "it", "does", "not", "returns", "an", "empty", "list", "." ]
python
train
tradenity/python-sdk
tradenity/resources/discount_coupon.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/discount_coupon.py#L634-L654
def get_discount_coupon_by_id(cls, discount_coupon_id, **kwargs): """Find DiscountCoupon Return single instance of DiscountCoupon by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get...
[ "def", "get_discount_coupon_by_id", "(", "cls", ",", "discount_coupon_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_get_disco...
Find DiscountCoupon Return single instance of DiscountCoupon by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.get_discount_coupon_by_id(discount_coupon_id, async=True) >>> result = t...
[ "Find", "DiscountCoupon" ]
python
train
titusjan/argos
argos/collect/collector.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/collect/collector.py#L159-L167
def _setColumnCountForContents(self): """ Sets the column count given the current axes and selected RTI. Returns the newly set column count. """ numRtiDims = self.rti.nDims if self.rti and self.rti.isSliceable else 0 colCount = self.COL_FIRST_COMBO + max(numRtiDims, len(self...
[ "def", "_setColumnCountForContents", "(", "self", ")", ":", "numRtiDims", "=", "self", ".", "rti", ".", "nDims", "if", "self", ".", "rti", "and", "self", ".", "rti", ".", "isSliceable", "else", "0", "colCount", "=", "self", ".", "COL_FIRST_COMBO", "+", "...
Sets the column count given the current axes and selected RTI. Returns the newly set column count.
[ "Sets", "the", "column", "count", "given", "the", "current", "axes", "and", "selected", "RTI", ".", "Returns", "the", "newly", "set", "column", "count", "." ]
python
train
dnephin/PyStaticConfiguration
staticconf/config.py
https://github.com/dnephin/PyStaticConfiguration/blob/229733270bc0dc0d9690ba850dbfb470e535c212/staticconf/config.py#L276-L286
def has_duplicate_keys(config_data, base_conf, raise_error): """Compare two dictionaries for duplicate keys. if raise_error is True then raise on exception, otherwise log return True.""" duplicate_keys = set(base_conf) & set(config_data) if not duplicate_keys: return msg = "Duplicate keys in...
[ "def", "has_duplicate_keys", "(", "config_data", ",", "base_conf", ",", "raise_error", ")", ":", "duplicate_keys", "=", "set", "(", "base_conf", ")", "&", "set", "(", "config_data", ")", "if", "not", "duplicate_keys", ":", "return", "msg", "=", "\"Duplicate ke...
Compare two dictionaries for duplicate keys. if raise_error is True then raise on exception, otherwise log return True.
[ "Compare", "two", "dictionaries", "for", "duplicate", "keys", ".", "if", "raise_error", "is", "True", "then", "raise", "on", "exception", "otherwise", "log", "return", "True", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/vasp/inputs.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/vasp/inputs.py#L1022-L1037
def monkhorst_automatic(kpts=(2, 2, 2), shift=(0, 0, 0)): """ Convenient static constructor for an automatic Monkhorst pack Kpoint grid. Args: kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice vectors. Defaults to (2,2,2) shift: Shift t...
[ "def", "monkhorst_automatic", "(", "kpts", "=", "(", "2", ",", "2", ",", "2", ")", ",", "shift", "=", "(", "0", ",", "0", ",", "0", ")", ")", ":", "return", "Kpoints", "(", "\"Automatic kpoint scheme\"", ",", "0", ",", "Kpoints", ".", "supported_mode...
Convenient static constructor for an automatic Monkhorst pack Kpoint grid. Args: kpts: Subdivisions N_1, N_2 and N_3 along reciprocal lattice vectors. Defaults to (2,2,2) shift: Shift to be applied to the kpoints. Defaults to (0,0,0). Returns: ...
[ "Convenient", "static", "constructor", "for", "an", "automatic", "Monkhorst", "pack", "Kpoint", "grid", "." ]
python
train
pypa/pipenv
pipenv/vendor/attr/_make.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/attr/_make.py#L711-L727
def _add_method_dunders(self, method): """ Add __module__ and __qualname__ to a *method* if possible. """ try: method.__module__ = self._cls.__module__ except AttributeError: pass try: method.__qualname__ = ".".join( (s...
[ "def", "_add_method_dunders", "(", "self", ",", "method", ")", ":", "try", ":", "method", ".", "__module__", "=", "self", ".", "_cls", ".", "__module__", "except", "AttributeError", ":", "pass", "try", ":", "method", ".", "__qualname__", "=", "\".\"", ".",...
Add __module__ and __qualname__ to a *method* if possible.
[ "Add", "__module__", "and", "__qualname__", "to", "a", "*", "method", "*", "if", "possible", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xnodewidget/xnode.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L1718-L1731
def setDisabledPenColor(self, color): """ Sets the pen color to be used when drawing this node as disabled. :param color | <QColor> """ color = QColor(color) if self._palette is None: self._palette = XNodePalette(self._scenePalette) ...
[ "def", "setDisabledPenColor", "(", "self", ",", "color", ")", ":", "color", "=", "QColor", "(", "color", ")", "if", "self", ".", "_palette", "is", "None", ":", "self", ".", "_palette", "=", "XNodePalette", "(", "self", ".", "_scenePalette", ")", "self", ...
Sets the pen color to be used when drawing this node as disabled. :param color | <QColor>
[ "Sets", "the", "pen", "color", "to", "be", "used", "when", "drawing", "this", "node", "as", "disabled", ".", ":", "param", "color", "|", "<QColor", ">" ]
python
train
vilmibm/done
parsedatetime/parsedatetime.py
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime.py#L872-L943
def _evalModifier2(self, modifier, chunk1 , chunk2, sourceTime): """ Evaluate the C{modifier} string and following text (passed in as C{chunk1} and C{chunk2}) and if they match any known modifiers calculate the delta and apply it to C{sourceTime}. @type modifier: string...
[ "def", "_evalModifier2", "(", "self", ",", "modifier", ",", "chunk1", ",", "chunk2", ",", "sourceTime", ")", ":", "offset", "=", "self", ".", "ptc", ".", "Modifiers", "[", "modifier", "]", "digit", "=", "r'\\d+'", "self", ".", "modifier2Flag", "=", "Fals...
Evaluate the C{modifier} string and following text (passed in as C{chunk1} and C{chunk2}) and if they match any known modifiers calculate the delta and apply it to C{sourceTime}. @type modifier: string @param modifier: modifier text to apply to C{sourceTime} @type ch...
[ "Evaluate", "the", "C", "{", "modifier", "}", "string", "and", "following", "text", "(", "passed", "in", "as", "C", "{", "chunk1", "}", "and", "C", "{", "chunk2", "}", ")", "and", "if", "they", "match", "any", "known", "modifiers", "calculate", "the", ...
python
train
audreyr/cookiecutter
cookiecutter/prompt.py
https://github.com/audreyr/cookiecutter/blob/3bc7b987e4ae9dcee996ae0b00375c1325b8d866/cookiecutter/prompt.py#L113-L136
def read_user_dict(var_name, default_value): """Prompt the user to provide a dictionary of data. :param str var_name: Variable as specified in the context :param default_value: Value that will be returned if no input is provided :return: A Python dictionary to use in the context. """ # Please s...
[ "def", "read_user_dict", "(", "var_name", ",", "default_value", ")", ":", "# Please see http://click.pocoo.org/4/api/#click.prompt", "if", "not", "isinstance", "(", "default_value", ",", "dict", ")", ":", "raise", "TypeError", "default_display", "=", "'default'", "user_...
Prompt the user to provide a dictionary of data. :param str var_name: Variable as specified in the context :param default_value: Value that will be returned if no input is provided :return: A Python dictionary to use in the context.
[ "Prompt", "the", "user", "to", "provide", "a", "dictionary", "of", "data", "." ]
python
train
Genida/archan
src/archan/dsm.py
https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/dsm.py#L15-L21
def validate_rows_length(data, length, message=None, exception=MatrixError): """Validate that all rows have the same length.""" if message is None: message = 'All rows must have the same length (same number of columns)' for row in data: if len(row) != length: raise exception(mess...
[ "def", "validate_rows_length", "(", "data", ",", "length", ",", "message", "=", "None", ",", "exception", "=", "MatrixError", ")", ":", "if", "message", "is", "None", ":", "message", "=", "'All rows must have the same length (same number of columns)'", "for", "row",...
Validate that all rows have the same length.
[ "Validate", "that", "all", "rows", "have", "the", "same", "length", "." ]
python
train
inveniosoftware-attic/invenio-knowledge
docs/_ext/flask_app.py
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/docs/_ext/flask_app.py#L23-L33
def setup(sphinx): """Setup Sphinx object.""" from flask import has_app_context from invenio_base.factory import create_app PACKAGES = ['invenio_base', 'invenio.modules.accounts', 'invenio.modules.records', 'invenio_knowledge'] if not has_app_context(): app = create_app(PACK...
[ "def", "setup", "(", "sphinx", ")", ":", "from", "flask", "import", "has_app_context", "from", "invenio_base", ".", "factory", "import", "create_app", "PACKAGES", "=", "[", "'invenio_base'", ",", "'invenio.modules.accounts'", ",", "'invenio.modules.records'", ",", "...
Setup Sphinx object.
[ "Setup", "Sphinx", "object", "." ]
python
train
pygobject/pgi
pgi/codegen/funcgen.py
https://github.com/pygobject/pgi/blob/2090435df6241a15ec2a78379a36b738b728652c/pgi/codegen/funcgen.py#L23-L36
def may_be_null_is_nullable(): """If may_be_null returns nullable or if NULL can be passed in. This can still be wrong if the specific typelib is older than the linked libgirepository. https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47 """ repo = GIRepository() repo.require("GLib", "2....
[ "def", "may_be_null_is_nullable", "(", ")", ":", "repo", "=", "GIRepository", "(", ")", "repo", ".", "require", "(", "\"GLib\"", ",", "\"2.0\"", ",", "0", ")", "info", "=", "repo", ".", "find_by_name", "(", "\"GLib\"", ",", "\"spawn_sync\"", ")", "# this a...
If may_be_null returns nullable or if NULL can be passed in. This can still be wrong if the specific typelib is older than the linked libgirepository. https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47
[ "If", "may_be_null", "returns", "nullable", "or", "if", "NULL", "can", "be", "passed", "in", "." ]
python
train
thebigmunch/gmusicapi-wrapper
gmusicapi_wrapper/utils.py
https://github.com/thebigmunch/gmusicapi-wrapper/blob/8708683cd33955def1378fc28319ef37805b851d/gmusicapi_wrapper/utils.py#L253-L301
def filter_local_songs(filepaths, include_filters=None, exclude_filters=None, all_includes=False, all_excludes=False): """Match a local file against a set of metadata filters. Parameters: filepaths (list): Filepaths to filter. include_filters (list): A list of ``(field, pattern)`` tuples. Fields are any vali...
[ "def", "filter_local_songs", "(", "filepaths", ",", "include_filters", "=", "None", ",", "exclude_filters", "=", "None", ",", "all_includes", "=", "False", ",", "all_excludes", "=", "False", ")", ":", "matched_songs", "=", "[", "]", "filtered_songs", "=", "[",...
Match a local file against a set of metadata filters. Parameters: filepaths (list): Filepaths to filter. include_filters (list): A list of ``(field, pattern)`` tuples. Fields are any valid mutagen metadata fields. Patterns are Python regex patterns. Local songs are filtered out if the given metadata fie...
[ "Match", "a", "local", "file", "against", "a", "set", "of", "metadata", "filters", "." ]
python
valid
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_swift.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavgen_swift.py#L304-L316
def camel_case_from_underscores(string): """Generate a CamelCase string from an underscore_string""" components = string.split('_') string = '' for component in components: if component in abbreviations: string += component else: string += component[0].upper() +...
[ "def", "camel_case_from_underscores", "(", "string", ")", ":", "components", "=", "string", ".", "split", "(", "'_'", ")", "string", "=", "''", "for", "component", "in", "components", ":", "if", "component", "in", "abbreviations", ":", "string", "+=", "compo...
Generate a CamelCase string from an underscore_string
[ "Generate", "a", "CamelCase", "string", "from", "an", "underscore_string" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_span.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_span.py#L68-L81
def monitor_session_span_command_src_tengigabitethernet_val(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") monitor = ET.SubElement(config, "monitor", xmlns="urn:brocade.com:mgmt:brocade-span") session = ET.SubElement(monitor, "session") session_...
[ "def", "monitor_session_span_command_src_tengigabitethernet_val", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "monitor", "=", "ET", ".", "SubElement", "(", "config", ",", "\"monitor\"", ",", "xml...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
kakwa/ldapcherry
ldapcherry/__init__.py
https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/__init__.py#L531-L552
def _parse_params(self, params): """ get user attributes @dict params: form parameters @rtype: dict, {<type>: {<attr>: <value>}} """ ret = {'attrs': {}, 'roles': {}, 'groups': {}} for p in params: # each form attributes is prefixed with type, ex: attr.uidNumbe...
[ "def", "_parse_params", "(", "self", ",", "params", ")", ":", "ret", "=", "{", "'attrs'", ":", "{", "}", ",", "'roles'", ":", "{", "}", ",", "'groups'", ":", "{", "}", "}", "for", "p", "in", "params", ":", "# each form attributes is prefixed with type, e...
get user attributes @dict params: form parameters @rtype: dict, {<type>: {<attr>: <value>}}
[ "get", "user", "attributes" ]
python
train
kakwa/ldapcherry
ldapcherry/backend/backendLdap.py
https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/backend/backendLdap.py#L179-L192
def _normalize_group_attrs(self, attrs): """Normalize the attributes used to set groups If it's a list of one element, it just become this element. It raises an error if the attribute doesn't exist or if it's multivaluated. """ for key in self.group_attrs_keys: ...
[ "def", "_normalize_group_attrs", "(", "self", ",", "attrs", ")", ":", "for", "key", "in", "self", ".", "group_attrs_keys", ":", "if", "key", "not", "in", "attrs", ":", "raise", "MissingGroupAttr", "(", "key", ")", "if", "type", "(", "attrs", "[", "key", ...
Normalize the attributes used to set groups If it's a list of one element, it just become this element. It raises an error if the attribute doesn't exist or if it's multivaluated.
[ "Normalize", "the", "attributes", "used", "to", "set", "groups", "If", "it", "s", "a", "list", "of", "one", "element", "it", "just", "become", "this", "element", ".", "It", "raises", "an", "error", "if", "the", "attribute", "doesn", "t", "exist", "or", ...
python
train
MolSSI-BSE/basis_set_exchange
basis_set_exchange/api.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/api.py#L398-L404
def get_basis_family(basis_name, data_dir=None): '''Lookup a family by a basis set name ''' data_dir = fix_data_dir(data_dir) bs_data = _get_basis_metadata(basis_name, data_dir) return bs_data['family']
[ "def", "get_basis_family", "(", "basis_name", ",", "data_dir", "=", "None", ")", ":", "data_dir", "=", "fix_data_dir", "(", "data_dir", ")", "bs_data", "=", "_get_basis_metadata", "(", "basis_name", ",", "data_dir", ")", "return", "bs_data", "[", "'family'", "...
Lookup a family by a basis set name
[ "Lookup", "a", "family", "by", "a", "basis", "set", "name" ]
python
train
Fantomas42/django-blog-zinnia
zinnia/templatetags/zinnia.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/templatetags/zinnia.py#L435-L442
def user_admin_urlname(action): """ Return the admin URLs for the user app used. """ user = get_user_model() return 'admin:%s_%s_%s' % ( user._meta.app_label, user._meta.model_name, action)
[ "def", "user_admin_urlname", "(", "action", ")", ":", "user", "=", "get_user_model", "(", ")", "return", "'admin:%s_%s_%s'", "%", "(", "user", ".", "_meta", ".", "app_label", ",", "user", ".", "_meta", ".", "model_name", ",", "action", ")" ]
Return the admin URLs for the user app used.
[ "Return", "the", "admin", "URLs", "for", "the", "user", "app", "used", "." ]
python
train
SBRG/ssbio
ssbio/biopython/Bio/Struct/Hydrogenate.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/Hydrogenate.py#L243-L325
def _add_1(self, hydrogen_name, heavy_atom, bonds): """ Adds the missing proton to single protonated heavy_atoms. """ residue = heavy_atom.parent ffld = self.ffld[self.selection[residue]] bnd_len = self.bondfield.length anchor = bonds[0] ...
[ "def", "_add_1", "(", "self", ",", "hydrogen_name", ",", "heavy_atom", ",", "bonds", ")", ":", "residue", "=", "heavy_atom", ".", "parent", "ffld", "=", "self", ".", "ffld", "[", "self", ".", "selection", "[", "residue", "]", "]", "bnd_len", "=", "self...
Adds the missing proton to single protonated heavy_atoms.
[ "Adds", "the", "missing", "proton", "to", "single", "protonated", "heavy_atoms", "." ]
python
train
inasafe/inasafe
safe/report/processors/default.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L60-L90
def layout_item(layout, item_id, item_class): """Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout t...
[ "def", "layout_item", "(", "layout", ",", "item_id", ",", "item_class", ")", ":", "item", "=", "layout", ".", "itemById", "(", "item_id", ")", "if", "item", "is", "None", ":", "# no match!", "return", "item", "if", "issubclass", "(", "item_class", ",", "...
Fetch a specific item according to its type in a layout. There's some sip casting conversion issues with QgsLayout::itemById. Don't use it, and use this function instead. See https://github.com/inasafe/inasafe/issues/4271 :param layout: The layout to look in. :type layout: QgsLayout :param it...
[ "Fetch", "a", "specific", "item", "according", "to", "its", "type", "in", "a", "layout", "." ]
python
train
wiheto/teneto
teneto/classes/network.py
https://github.com/wiheto/teneto/blob/80d7a83a9adc1714589b020627c45bd5b66248ab/teneto/classes/network.py#L227-L243
def network_from_edgelist(self, edgelist): """ Defines a network from an array. Parameters ---------- edgelist : list of lists. A list of lists which are 3 or 4 in length. For binary networks each sublist should be [i, j ,t] where i and j are node indicies and t is t...
[ "def", "network_from_edgelist", "(", "self", ",", "edgelist", ")", ":", "teneto", ".", "utils", ".", "check_TemporalNetwork_input", "(", "edgelist", ",", "'edgelist'", ")", "if", "len", "(", "edgelist", "[", "0", "]", ")", "==", "4", ":", "colnames", "=", ...
Defines a network from an array. Parameters ---------- edgelist : list of lists. A list of lists which are 3 or 4 in length. For binary networks each sublist should be [i, j ,t] where i and j are node indicies and t is the temporal index. For weighted networks each subli...
[ "Defines", "a", "network", "from", "an", "array", "." ]
python
train
ergoithz/browsepy
browsepy/compat.py
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/compat.py#L84-L97
def getcwd(fs_encoding=FS_ENCODING, cwd_fnc=os.getcwd): ''' Get current work directory's absolute path. Like os.getcwd but garanteed to return an unicode-str object. :param fs_encoding: filesystem encoding, defaults to autodetected :type fs_encoding: str :param cwd_fnc: callable used to get the...
[ "def", "getcwd", "(", "fs_encoding", "=", "FS_ENCODING", ",", "cwd_fnc", "=", "os", ".", "getcwd", ")", ":", "path", "=", "fsdecode", "(", "cwd_fnc", "(", ")", ",", "fs_encoding", "=", "fs_encoding", ")", "return", "os", ".", "path", ".", "abspath", "(...
Get current work directory's absolute path. Like os.getcwd but garanteed to return an unicode-str object. :param fs_encoding: filesystem encoding, defaults to autodetected :type fs_encoding: str :param cwd_fnc: callable used to get the path, defaults to os.getcwd :type cwd_fnc: Callable :return...
[ "Get", "current", "work", "directory", "s", "absolute", "path", ".", "Like", "os", ".", "getcwd", "but", "garanteed", "to", "return", "an", "unicode", "-", "str", "object", "." ]
python
train
ubc/ubcpi
ubcpi/persistence.py
https://github.com/ubc/ubcpi/blob/7b6de03f93f3a4a8af4b92dfde7c69eeaf21f46e/ubcpi/persistence.py#L134-L145
def add_answer(self, vote, rationale): """ Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option """ self.raw_answers.append({ VOTE_KEY: vote, RATIONALE_KE...
[ "def", "add_answer", "(", "self", ",", "vote", ",", "rationale", ")", ":", "self", ".", "raw_answers", ".", "append", "(", "{", "VOTE_KEY", ":", "vote", ",", "RATIONALE_KEY", ":", "rationale", ",", "}", ")" ]
Add an answer Args: vote (int): the option that student voted for rationale (str): the reason why the student vote for the option
[ "Add", "an", "answer" ]
python
train
heikomuller/sco-datastore
scodata/funcdata.py
https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/funcdata.py#L178-L236
def create_object(self, filename, read_only=False): """Create a functional data object for the given file. Expects the file to be a valid functional data file. Expects exactly one file that has suffix mgh/mgz or nii/nii.gz. Parameters ---------- filename : string ...
[ "def", "create_object", "(", "self", ",", "filename", ",", "read_only", "=", "False", ")", ":", "# Get the file name, i.e., last component of the given absolute path", "prop_name", "=", "os", ".", "path", ".", "basename", "(", "os", ".", "path", ".", "normpath", "...
Create a functional data object for the given file. Expects the file to be a valid functional data file. Expects exactly one file that has suffix mgh/mgz or nii/nii.gz. Parameters ---------- filename : string Name of the (uploaded) file read_only : boolean, o...
[ "Create", "a", "functional", "data", "object", "for", "the", "given", "file", ".", "Expects", "the", "file", "to", "be", "a", "valid", "functional", "data", "file", ".", "Expects", "exactly", "one", "file", "that", "has", "suffix", "mgh", "/", "mgz", "or...
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/pathlib2.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/pathlib2.py#L595-L602
def select_from(self, parent_path): """Iterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.""" path_cls = type(parent_path) is_dir = path_cls.is_dir exists = path_cls.exists listdir = parent_path._accessor.listdir ...
[ "def", "select_from", "(", "self", ",", "parent_path", ")", ":", "path_cls", "=", "type", "(", "parent_path", ")", "is_dir", "=", "path_cls", ".", "is_dir", "exists", "=", "path_cls", ".", "exists", "listdir", "=", "parent_path", ".", "_accessor", ".", "li...
Iterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.
[ "Iterate", "over", "all", "child", "paths", "of", "parent_path", "matched", "by", "this", "selector", ".", "This", "can", "contain", "parent_path", "itself", "." ]
python
train
IdentityPython/pysaml2
src/saml2/mdstore.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/mdstore.py#L548-L585
def service(self, entity_id, typ, service, binding=None): """ Get me all services with a specified entity ID and type, that supports the specified version of binding. :param entity_id: The EntityId :param typ: Type of service (idp, attribute_authority, ...) :param service: which...
[ "def", "service", "(", "self", ",", "entity_id", ",", "typ", ",", "service", ",", "binding", "=", "None", ")", ":", "try", ":", "srvs", "=", "[", "]", "for", "t", "in", "self", "[", "entity_id", "]", "[", "typ", "]", ":", "try", ":", "srvs", "....
Get me all services with a specified entity ID and type, that supports the specified version of binding. :param entity_id: The EntityId :param typ: Type of service (idp, attribute_authority, ...) :param service: which service that is sought for :param binding: A binding identifi...
[ "Get", "me", "all", "services", "with", "a", "specified", "entity", "ID", "and", "type", "that", "supports", "the", "specified", "version", "of", "binding", "." ]
python
train
alefnula/tea
tea/shell/__init__.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L260-L273
def gcopy(pattern, destination): """Copy all file found by glob.glob(pattern) to destination directory. Args: pattern (str): Glob pattern destination (str): Path to the destination directory. Returns: bool: True if the operation is successful, False otherwise. """ for item ...
[ "def", "gcopy", "(", "pattern", ",", "destination", ")", ":", "for", "item", "in", "glob", ".", "glob", "(", "pattern", ")", ":", "if", "not", "copy", "(", "item", ",", "destination", ")", ":", "return", "False", "return", "True" ]
Copy all file found by glob.glob(pattern) to destination directory. Args: pattern (str): Glob pattern destination (str): Path to the destination directory. Returns: bool: True if the operation is successful, False otherwise.
[ "Copy", "all", "file", "found", "by", "glob", ".", "glob", "(", "pattern", ")", "to", "destination", "directory", "." ]
python
train
Koed00/django-q
django_q/tasks.py
https://github.com/Koed00/django-q/blob/c84fd11a67c9a47d821786dfcdc189bb258c6f54/django_q/tasks.py#L561-L568
def current(self): """ get the index of the currently executing chain element :return int: current chain index """ if not self.started: return None return count_group(self.group, cached=self.cached)
[ "def", "current", "(", "self", ")", ":", "if", "not", "self", ".", "started", ":", "return", "None", "return", "count_group", "(", "self", ".", "group", ",", "cached", "=", "self", ".", "cached", ")" ]
get the index of the currently executing chain element :return int: current chain index
[ "get", "the", "index", "of", "the", "currently", "executing", "chain", "element", ":", "return", "int", ":", "current", "chain", "index" ]
python
train
dropbox/stone
stone/ir/data_types.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/ir/data_types.py#L1370-L1384
def set_attributes(self, doc, fields, # pylint: disable=arguments-differ parent_type=None, catch_all_field=None): """ :param UnionField catch_all_field: The field designated as the catch-all. This field should be a member of the list of fields. See :meth:`Composite.set_...
[ "def", "set_attributes", "(", "self", ",", "doc", ",", "fields", ",", "# pylint: disable=arguments-differ", "parent_type", "=", "None", ",", "catch_all_field", "=", "None", ")", ":", "if", "parent_type", ":", "assert", "isinstance", "(", "parent_type", ",", "Uni...
:param UnionField catch_all_field: The field designated as the catch-all. This field should be a member of the list of fields. See :meth:`Composite.set_attributes` for parameter definitions.
[ ":", "param", "UnionField", "catch_all_field", ":", "The", "field", "designated", "as", "the", "catch", "-", "all", ".", "This", "field", "should", "be", "a", "member", "of", "the", "list", "of", "fields", "." ]
python
train
BoboTiG/python-mss
mss/linux.py
https://github.com/BoboTiG/python-mss/blob/56347f781edb38a0e7a5104080bd683f49c6f074/mss/linux.py#L399-L443
def grab(self, monitor): # type: (Monitor) -> ScreenShot """ Retrieve all pixels from a monitor. Pixels have to be RGB. """ # Convert PIL bbox style if isinstance(monitor, tuple): monitor = { "left": monitor[0], "top": monitor[1], ...
[ "def", "grab", "(", "self", ",", "monitor", ")", ":", "# type: (Monitor) -> ScreenShot", "# Convert PIL bbox style", "if", "isinstance", "(", "monitor", ",", "tuple", ")", ":", "monitor", "=", "{", "\"left\"", ":", "monitor", "[", "0", "]", ",", "\"top\"", "...
Retrieve all pixels from a monitor. Pixels have to be RGB.
[ "Retrieve", "all", "pixels", "from", "a", "monitor", ".", "Pixels", "have", "to", "be", "RGB", "." ]
python
train
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L2597-L2603
def zunionstore(self, dest, keys, aggregate=None): """ Union multiple sorted sets specified by ``keys`` into a new sorted set, ``dest``. Scores in the destination will be aggregated based on the ``aggregate``, or SUM if none is provided. """ return self._zaggregate('ZUNIO...
[ "def", "zunionstore", "(", "self", ",", "dest", ",", "keys", ",", "aggregate", "=", "None", ")", ":", "return", "self", ".", "_zaggregate", "(", "'ZUNIONSTORE'", ",", "dest", ",", "keys", ",", "aggregate", ")" ]
Union multiple sorted sets specified by ``keys`` into a new sorted set, ``dest``. Scores in the destination will be aggregated based on the ``aggregate``, or SUM if none is provided.
[ "Union", "multiple", "sorted", "sets", "specified", "by", "keys", "into", "a", "new", "sorted", "set", "dest", ".", "Scores", "in", "the", "destination", "will", "be", "aggregated", "based", "on", "the", "aggregate", "or", "SUM", "if", "none", "is", "provi...
python
train
sanand0/xmljson
xmljson/__init__.py
https://github.com/sanand0/xmljson/blob/2ecc2065fe7c87b3d282d362289927f13ce7f8b0/xmljson/__init__.py#L149-L173
def data(self, root): '''Convert etree.Element into a dictionary''' value = self.dict() children = [node for node in root if isinstance(node.tag, basestring)] for attr, attrval in root.attrib.items(): attr = attr if self.attr_prefix is None else self.attr_prefix + attr ...
[ "def", "data", "(", "self", ",", "root", ")", ":", "value", "=", "self", ".", "dict", "(", ")", "children", "=", "[", "node", "for", "node", "in", "root", "if", "isinstance", "(", "node", ".", "tag", ",", "basestring", ")", "]", "for", "attr", ",...
Convert etree.Element into a dictionary
[ "Convert", "etree", ".", "Element", "into", "a", "dictionary" ]
python
train
gamechanger/schemer
schemer/validators.py
https://github.com/gamechanger/schemer/blob/1d1dd7da433d3b84ce5a80ded5a84ab4a65825ee/schemer/validators.py#L24-L32
def gte(min_value): """ Validates that a field value is greater than or equal to the value given to this validator. """ def validate(value): if value < min_value: return e("{} is not greater than or equal to {}", value, min_value) return validate
[ "def", "gte", "(", "min_value", ")", ":", "def", "validate", "(", "value", ")", ":", "if", "value", "<", "min_value", ":", "return", "e", "(", "\"{} is not greater than or equal to {}\"", ",", "value", ",", "min_value", ")", "return", "validate" ]
Validates that a field value is greater than or equal to the value given to this validator.
[ "Validates", "that", "a", "field", "value", "is", "greater", "than", "or", "equal", "to", "the", "value", "given", "to", "this", "validator", "." ]
python
train
aouyar/PyMunin
pysysinfo/postgresql.py
https://github.com/aouyar/PyMunin/blob/4f58a64b6b37c85a84cc7e1e07aafaa0321b249d/pysysinfo/postgresql.py#L114-L124
def _simpleQuery(self, query): """Executes simple query which returns a single column. @param query: Query string. @return: Query result string. """ cur = self._conn.cursor() cur.execute(query) row = cur.fetchone() return util.parse_...
[ "def", "_simpleQuery", "(", "self", ",", "query", ")", ":", "cur", "=", "self", ".", "_conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "query", ")", "row", "=", "cur", ".", "fetchone", "(", ")", "return", "util", ".", "parse_value", "("...
Executes simple query which returns a single column. @param query: Query string. @return: Query result string.
[ "Executes", "simple", "query", "which", "returns", "a", "single", "column", "." ]
python
train
mardix/pylot
pylot/utils.py
https://github.com/mardix/pylot/blob/506a33a56ebdfc0925b94015e8cf98ccb16a143c/pylot/utils.py#L20-L24
def get_base_dir(): """ Return the base directory """ return os.path.split(os.path.abspath(os.path.dirname(__file__)))[0]
[ "def", "get_base_dir", "(", ")", ":", "return", "os", ".", "path", ".", "split", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", ")", "[", "0", "]" ]
Return the base directory
[ "Return", "the", "base", "directory" ]
python
train
rbit/pydtls
dtls/sslconnection.py
https://github.com/rbit/pydtls/blob/41a71fccd990347d0de5f42418fea1e4e733359c/dtls/sslconnection.py#L778-L811
def shutdown(self): """Shut down the DTLS connection This method attemps to complete a bidirectional shutdown between peers. For non-blocking sockets, it should be called repeatedly until it no longer raises continuation request exceptions. """ if hasattr(self, "_listen...
[ "def", "shutdown", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"_listening\"", ")", ":", "# Listening server-side sockets cannot be shut down", "return", "try", ":", "self", ".", "_wrap_socket_library_call", "(", "lambda", ":", "SSL_shutdown", "(", ...
Shut down the DTLS connection This method attemps to complete a bidirectional shutdown between peers. For non-blocking sockets, it should be called repeatedly until it no longer raises continuation request exceptions.
[ "Shut", "down", "the", "DTLS", "connection" ]
python
train
brechtm/rinohtype
src/rinoh/text.py
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/text.py#L262-L273
def y_offset(self, container): """Vertical baseline offset (up is positive).""" offset = (self.parent.y_offset(container)\ if hasattr(self.parent, 'y_offset') else 0) if self.is_script(container): style = self._style(container) offset += (self.parent.hei...
[ "def", "y_offset", "(", "self", ",", "container", ")", ":", "offset", "=", "(", "self", ".", "parent", ".", "y_offset", "(", "container", ")", "if", "hasattr", "(", "self", ".", "parent", ",", "'y_offset'", ")", "else", "0", ")", "if", "self", ".", ...
Vertical baseline offset (up is positive).
[ "Vertical", "baseline", "offset", "(", "up", "is", "positive", ")", "." ]
python
train
rochacbruno/dynaconf
dynaconf/contrib/flask_dynaconf.py
https://github.com/rochacbruno/dynaconf/blob/5a7cc8f8252251cbdf4f4112965801f9dfe2831d/dynaconf/contrib/flask_dynaconf.py#L102-L107
def init_app(self, app, **kwargs): """kwargs holds initial dynaconf configuration""" self.kwargs.update(kwargs) self.settings = self.dynaconf_instance or LazySettings(**self.kwargs) app.config = self.make_config(app) app.dynaconf = self.settings
[ "def", "init_app", "(", "self", ",", "app", ",", "*", "*", "kwargs", ")", ":", "self", ".", "kwargs", ".", "update", "(", "kwargs", ")", "self", ".", "settings", "=", "self", ".", "dynaconf_instance", "or", "LazySettings", "(", "*", "*", "self", ".",...
kwargs holds initial dynaconf configuration
[ "kwargs", "holds", "initial", "dynaconf", "configuration" ]
python
train
tomplus/kubernetes_asyncio
kubernetes_asyncio/client/api/version_api.py
https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/version_api.py#L35-L54
def get_code(self, **kwargs): # noqa: E501 """get_code # noqa: E501 get the code version # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_code(async_req=True) >>...
[ "def", "get_code", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "get_code_with_http_info", "(", ...
get_code # noqa: E501 get the code version # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_code(async_req=True) >>> result = thread.get() :param async_req bool ...
[ "get_code", "#", "noqa", ":", "E501" ]
python
train
jmbeach/KEP.py
src/keppy/channel.py
https://github.com/jmbeach/KEP.py/blob/68cda64ab649640a486534867c81274c41e39446/src/keppy/channel.py#L19-L24
def parse_devices(self): """Creates an array of Device objects from the channel""" devices = [] for device in self._channel_dict["devices"]: devices.append(Device(device, self._is_sixteen_bit, self._ignore_list)) return devices
[ "def", "parse_devices", "(", "self", ")", ":", "devices", "=", "[", "]", "for", "device", "in", "self", ".", "_channel_dict", "[", "\"devices\"", "]", ":", "devices", ".", "append", "(", "Device", "(", "device", ",", "self", ".", "_is_sixteen_bit", ",", ...
Creates an array of Device objects from the channel
[ "Creates", "an", "array", "of", "Device", "objects", "from", "the", "channel" ]
python
train
carpedm20/fbchat
fbchat/_client.py
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L1343-L1359
def send(self, message, thread_id=None, thread_type=ThreadType.USER): """ Sends a message to a thread :param message: Message to send :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type message: models.M...
[ "def", "send", "(", "self", ",", "message", ",", "thread_id", "=", "None", ",", "thread_type", "=", "ThreadType", ".", "USER", ")", ":", "thread_id", ",", "thread_type", "=", "self", ".", "_getThread", "(", "thread_id", ",", "thread_type", ")", "data", "...
Sends a message to a thread :param message: Message to send :param thread_id: User/Group ID to send to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type message: models.Message :type thread_type: models.ThreadType :return: :ref:`Message ID <int...
[ "Sends", "a", "message", "to", "a", "thread" ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/flask/app.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/app.py#L1463-L1481
def full_dispatch_request(self): """Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling. .. versionadded:: 0.7 """ self.try_trigger_before_first_request_functions() try: ...
[ "def", "full_dispatch_request", "(", "self", ")", ":", "self", ".", "try_trigger_before_first_request_functions", "(", ")", "try", ":", "request_started", ".", "send", "(", "self", ")", "rv", "=", "self", ".", "preprocess_request", "(", ")", "if", "rv", "is", ...
Dispatches the request and on top of that performs request pre and postprocessing as well as HTTP exception catching and error handling. .. versionadded:: 0.7
[ "Dispatches", "the", "request", "and", "on", "top", "of", "that", "performs", "request", "pre", "and", "postprocessing", "as", "well", "as", "HTTP", "exception", "catching", "and", "error", "handling", "." ]
python
test
rosenbrockc/fortpy
fortpy/stats/calltree.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/stats/calltree.py#L49-L64
def _call_fan(branch, calls, executable): """Appends a list of callees to the branch for each parent in the call list that calls this executable. """ #Since we don't keep track of the specific logic in the executables #it is possible that we could get a infinite recursion of executables #that ke...
[ "def", "_call_fan", "(", "branch", ",", "calls", ",", "executable", ")", ":", "#Since we don't keep track of the specific logic in the executables", "#it is possible that we could get a infinite recursion of executables", "#that keep calling each other.", "if", "executable", "in", "b...
Appends a list of callees to the branch for each parent in the call list that calls this executable.
[ "Appends", "a", "list", "of", "callees", "to", "the", "branch", "for", "each", "parent", "in", "the", "call", "list", "that", "calls", "this", "executable", "." ]
python
train
bunq/sdk_python
bunq/sdk/model/generated/object_.py
https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/object_.py#L3552-L3642
def get_referenced_object(self): """ :rtype: core.BunqModel :raise: BunqException """ if self._BunqMeTab is not None: return self._BunqMeTab if self._BunqMeTabResultResponse is not None: return self._BunqMeTabResultResponse if self._Bunq...
[ "def", "get_referenced_object", "(", "self", ")", ":", "if", "self", ".", "_BunqMeTab", "is", "not", "None", ":", "return", "self", ".", "_BunqMeTab", "if", "self", ".", "_BunqMeTabResultResponse", "is", "not", "None", ":", "return", "self", ".", "_BunqMeTab...
:rtype: core.BunqModel :raise: BunqException
[ ":", "rtype", ":", "core", ".", "BunqModel", ":", "raise", ":", "BunqException" ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/gallery/gallery_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/gallery/gallery_client.py#L671-L695
def get_asset_from_new_extension_draft(self, publisher_name, draft_id, asset_type, **kwargs): """GetAssetFromNewExtensionDraft. [Preview API] :param str publisher_name: :param str draft_id: :param str asset_type: :rtype: object """ route_values = {} ...
[ "def", "get_asset_from_new_extension_draft", "(", "self", ",", "publisher_name", ",", "draft_id", ",", "asset_type", ",", "*", "*", "kwargs", ")", ":", "route_values", "=", "{", "}", "if", "publisher_name", "is", "not", "None", ":", "route_values", "[", "'publ...
GetAssetFromNewExtensionDraft. [Preview API] :param str publisher_name: :param str draft_id: :param str asset_type: :rtype: object
[ "GetAssetFromNewExtensionDraft", ".", "[", "Preview", "API", "]", ":", "param", "str", "publisher_name", ":", ":", "param", "str", "draft_id", ":", ":", "param", "str", "asset_type", ":", ":", "rtype", ":", "object" ]
python
train
GibbsConsulting/django-plotly-dash
django_plotly_dash/dash_wrapper.py
https://github.com/GibbsConsulting/django-plotly-dash/blob/773ed081fc2ea3cc7607590322a14686a7a79bc5/django_plotly_dash/dash_wrapper.py#L187-L209
def form_dash_instance(self, replacements=None, ndid=None, base_pathname=None): 'Construct a Dash instance taking into account state' if ndid is None: ndid = self._uid rd = WrappedDash(base_pathname=base_pathname, expanded_callbacks=self._expanded_callbacks...
[ "def", "form_dash_instance", "(", "self", ",", "replacements", "=", "None", ",", "ndid", "=", "None", ",", "base_pathname", "=", "None", ")", ":", "if", "ndid", "is", "None", ":", "ndid", "=", "self", ".", "_uid", "rd", "=", "WrappedDash", "(", "base_p...
Construct a Dash instance taking into account state
[ "Construct", "a", "Dash", "instance", "taking", "into", "account", "state" ]
python
train
sernst/cauldron
cauldron/cli/server/routes/display.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/display.py#L10-L28
def view(route: str): """ Retrieves the contents of the file specified by the view route if it exists. """ project = cauldron.project.get_internal_project() results_path = project.results_path if project else None if not project or not results_path: return '', 204 path = os.path...
[ "def", "view", "(", "route", ":", "str", ")", ":", "project", "=", "cauldron", ".", "project", ".", "get_internal_project", "(", ")", "results_path", "=", "project", ".", "results_path", "if", "project", "else", "None", "if", "not", "project", "or", "not",...
Retrieves the contents of the file specified by the view route if it exists.
[ "Retrieves", "the", "contents", "of", "the", "file", "specified", "by", "the", "view", "route", "if", "it", "exists", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Script/SConsOptions.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Script/SConsOptions.py#L529-L982
def Parser(version): """ Returns an options parser object initialized with the standard SCons options. """ formatter = SConsIndentedHelpFormatter(max_help_position=30) op = SConsOptionParser(option_class=SConsOption, add_help_option=False, ...
[ "def", "Parser", "(", "version", ")", ":", "formatter", "=", "SConsIndentedHelpFormatter", "(", "max_help_position", "=", "30", ")", "op", "=", "SConsOptionParser", "(", "option_class", "=", "SConsOption", ",", "add_help_option", "=", "False", ",", "formatter", ...
Returns an options parser object initialized with the standard SCons options.
[ "Returns", "an", "options", "parser", "object", "initialized", "with", "the", "standard", "SCons", "options", "." ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgetdelegate.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgetdelegate.py#L87-L108
def paint(self, painter, option, index): """Use the painter and style option to render the item specified by the item index. :param painter: the painter to paint :type painter: :class:`QtGui.QPainter` :param option: the options for painting :type option: :class:`QtGui.QStyleOpti...
[ "def", "paint", "(", "self", ",", "painter", ",", "option", ",", "index", ")", ":", "if", "self", ".", "_widget", "is", "None", ":", "return", "super", "(", "WidgetDelegate", ",", "self", ")", ".", "paint", "(", "painter", ",", "option", ",", "index"...
Use the painter and style option to render the item specified by the item index. :param painter: the painter to paint :type painter: :class:`QtGui.QPainter` :param option: the options for painting :type option: :class:`QtGui.QStyleOptionViewItem` :param index: the index to paint...
[ "Use", "the", "painter", "and", "style", "option", "to", "render", "the", "item", "specified", "by", "the", "item", "index", "." ]
python
train
onicagroup/runway
runway/commands/runway/gen_sample.py
https://github.com/onicagroup/runway/blob/3f3549ec3bf6e39b9f27d9738a1847f3a4369e7f/runway/commands/runway/gen_sample.py#L18-L25
def generate_sample_module(module_dir): """Generate skeleton sample module.""" if os.path.isdir(module_dir): LOGGER.error("Error generating sample module -- directory %s " "already exists!", module_dir) sys.exit(1) os.mkdir(module_dir)
[ "def", "generate_sample_module", "(", "module_dir", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "module_dir", ")", ":", "LOGGER", ".", "error", "(", "\"Error generating sample module -- directory %s \"", "\"already exists!\"", ",", "module_dir", ")", "sys"...
Generate skeleton sample module.
[ "Generate", "skeleton", "sample", "module", "." ]
python
train
theolind/pymysensors
mysensors/handler.py
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L218-L225
def handle_heartbeat_response(msg): """Process an internal heartbeat response message.""" if not msg.gateway.is_sensor(msg.node_id): return None handle_smartsleep(msg) msg.gateway.sensors[msg.node_id].heartbeat = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_heartbeat_response", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "handle_smartsleep", "(", "msg", ")", "msg", ".", "gateway", ".", "sensors", "[", "msg...
Process an internal heartbeat response message.
[ "Process", "an", "internal", "heartbeat", "response", "message", "." ]
python
train
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1093-L1103
def load_level(self): """|coro| Load the players XP and level""" data = yield from self.auth.get("https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6playerprofile/playerprofile/progressions?profile_ids=%s" % (self.spaceid, self.platform_url, self.id)) if "player_profiles" i...
[ "def", "load_level", "(", "self", ")", ":", "data", "=", "yield", "from", "self", ".", "auth", ".", "get", "(", "\"https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6playerprofile/playerprofile/progressions?profile_ids=%s\"", "%", "(", "self", ".", "spaceid", ...
|coro| Load the players XP and level
[ "|coro|" ]
python
train
davidblaisonneau-orange/foreman
foreman/api.py
https://github.com/davidblaisonneau-orange/foreman/blob/acb8fd8d74657cfac3b25c82e9c6028b93eb6c92/foreman/api.py#L208-L221
def delete(self, obj, id): """ Function delete Delete an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the server response """ self.url = '{}{}/{}'.format(self.base_url, obj, id) ...
[ "def", "delete", "(", "self", ",", "obj", ",", "id", ")", ":", "self", ".", "url", "=", "'{}{}/{}'", ".", "format", "(", "self", ".", "base_url", ",", "obj", ",", "id", ")", "self", ".", "method", "=", "'DELETE'", "self", ".", "resp", "=", "reque...
Function delete Delete an object by id @param obj: object name ('hosts', 'puppetclasses'...) @param id: the id of the object (name or id) @return RETURN: the server response
[ "Function", "delete", "Delete", "an", "object", "by", "id" ]
python
train
curious-containers/cc-core
cc_core/commons/input_references.py
https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/input_references.py#L242-L267
def resolve_input_references(to_resolve, inputs_to_reference): """ Resolves input references given in the string to_resolve by using the inputs_to_reference. See http://www.commonwl.org/user_guide/06-params/index.html for more information. Example: "$(inputs.my_file.nameroot).md" -> "filename.md" ...
[ "def", "resolve_input_references", "(", "to_resolve", ",", "inputs_to_reference", ")", ":", "splitted", "=", "split_input_references", "(", "to_resolve", ")", "result", "=", "[", "]", "for", "part", "in", "splitted", ":", "if", "is_input_reference", "(", "part", ...
Resolves input references given in the string to_resolve by using the inputs_to_reference. See http://www.commonwl.org/user_guide/06-params/index.html for more information. Example: "$(inputs.my_file.nameroot).md" -> "filename.md" :param to_resolve: The path to match :param inputs_to_reference: I...
[ "Resolves", "input", "references", "given", "in", "the", "string", "to_resolve", "by", "using", "the", "inputs_to_reference", "." ]
python
train
IdentityPython/SATOSA
src/satosa/backends/openid_connect.py
https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/backends/openid_connect.py#L238-L272
def _create_client(provider_metadata, client_metadata, verify_ssl=True): """ Create a pyoidc client instance. :param provider_metadata: provider configuration information :type provider_metadata: Mapping[str, Union[str, Sequence[str]]] :param client_metadata: client metadata :type client_metadat...
[ "def", "_create_client", "(", "provider_metadata", ",", "client_metadata", ",", "verify_ssl", "=", "True", ")", ":", "client", "=", "oic", ".", "Client", "(", "client_authn_method", "=", "CLIENT_AUTHN_METHOD", ",", "verify_ssl", "=", "verify_ssl", ")", "# Provider...
Create a pyoidc client instance. :param provider_metadata: provider configuration information :type provider_metadata: Mapping[str, Union[str, Sequence[str]]] :param client_metadata: client metadata :type client_metadata: Mapping[str, Union[str, Sequence[str]]] :return: client instance to use for co...
[ "Create", "a", "pyoidc", "client", "instance", ".", ":", "param", "provider_metadata", ":", "provider", "configuration", "information", ":", "type", "provider_metadata", ":", "Mapping", "[", "str", "Union", "[", "str", "Sequence", "[", "str", "]]]", ":", "para...
python
train
has2k1/mizani
mizani/utils.py
https://github.com/has2k1/mizani/blob/312d0550ee0136fd1b0384829b33f3b2065f47c8/mizani/utils.py#L194-L224
def multitype_sort(a): """ Sort elements of multiple types x is assumed to contain elements of different types, such that plain sort would raise a `TypeError`. Parameters ---------- a : array-like Array of items to be sorted Returns ------- out : list Items sor...
[ "def", "multitype_sort", "(", "a", ")", ":", "types", "=", "defaultdict", "(", "list", ")", "numbers", "=", "{", "int", ",", "float", ",", "complex", "}", "for", "x", "in", "a", ":", "t", "=", "type", "(", "x", ")", "if", "t", "in", "numbers", ...
Sort elements of multiple types x is assumed to contain elements of different types, such that plain sort would raise a `TypeError`. Parameters ---------- a : array-like Array of items to be sorted Returns ------- out : list Items sorted within their type groups.
[ "Sort", "elements", "of", "multiple", "types" ]
python
valid
google/grr
grr/server/grr_response_server/gui/api_plugins/config.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/gui/api_plugins/config.py#L140-L146
def Handle(self, args, token=None): """Renders specified config option.""" if not args.name: raise ValueError("Name not specified.") return ApiConfigOption().InitFromConfigOption(args.name)
[ "def", "Handle", "(", "self", ",", "args", ",", "token", "=", "None", ")", ":", "if", "not", "args", ".", "name", ":", "raise", "ValueError", "(", "\"Name not specified.\"", ")", "return", "ApiConfigOption", "(", ")", ".", "InitFromConfigOption", "(", "arg...
Renders specified config option.
[ "Renders", "specified", "config", "option", "." ]
python
train
allenai/allennlp
allennlp/semparse/contexts/sql_context_utils.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/contexts/sql_context_utils.py#L16-L23
def format_grammar_string(grammar_dictionary: Dict[str, List[str]]) -> str: """ Formats a dictionary of production rules into the string format expected by the Parsimonious Grammar class. """ grammar_string = '\n'.join([f"{nonterminal} = {' / '.join(right_hand_side)}" ...
[ "def", "format_grammar_string", "(", "grammar_dictionary", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ")", "->", "str", ":", "grammar_string", "=", "'\\n'", ".", "join", "(", "[", "f\"{nonterminal} = {' / '.join(right_hand_side)}\"", "for", "non...
Formats a dictionary of production rules into the string format expected by the Parsimonious Grammar class.
[ "Formats", "a", "dictionary", "of", "production", "rules", "into", "the", "string", "format", "expected", "by", "the", "Parsimonious", "Grammar", "class", "." ]
python
train
mushkevych/scheduler
synergy/system/time_helper.py
https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/synergy/system/time_helper.py#L98-L135
def increment_timeperiod(time_qualifier, timeperiod, delta=1): """ method performs simple increment/decrement of the timeperiods For instance: 2010010119 with delta=1 -> 2010010120 Or 2010010000 with delta=-1 -> 2009120000, etc""" pattern = define_pattern(timeperiod) t = datetime.strptime(timeperio...
[ "def", "increment_timeperiod", "(", "time_qualifier", ",", "timeperiod", ",", "delta", "=", "1", ")", ":", "pattern", "=", "define_pattern", "(", "timeperiod", ")", "t", "=", "datetime", ".", "strptime", "(", "timeperiod", ",", "pattern", ")", "if", "time_qu...
method performs simple increment/decrement of the timeperiods For instance: 2010010119 with delta=1 -> 2010010120 Or 2010010000 with delta=-1 -> 2009120000, etc
[ "method", "performs", "simple", "increment", "/", "decrement", "of", "the", "timeperiods", "For", "instance", ":", "2010010119", "with", "delta", "=", "1", "-", ">", "2010010120", "Or", "2010010000", "with", "delta", "=", "-", "1", "-", ">", "2009120000", ...
python
train
serhatbolsu/robotframework-appiumlibrary
AppiumLibrary/keywords/_waiting.py
https://github.com/serhatbolsu/robotframework-appiumlibrary/blob/91c808cf0602af6be8135ac529fa488fded04a85/AppiumLibrary/keywords/_waiting.py#L48-L70
def wait_until_page_does_not_contain(self, text, timeout=None, error=None): """Waits until `text` disappears from current page. Fails if `timeout` expires before the `text` disappears. See `introduction` for more information about `timeout` and its default value. `error` can be...
[ "def", "wait_until_page_does_not_contain", "(", "self", ",", "text", ",", "timeout", "=", "None", ",", "error", "=", "None", ")", ":", "def", "check_present", "(", ")", ":", "present", "=", "self", ".", "_is_text_present", "(", "text", ")", "if", "not", ...
Waits until `text` disappears from current page. Fails if `timeout` expires before the `text` disappears. See `introduction` for more information about `timeout` and its default value. `error` can be used to override the default error message. See also `Wait Until Page Contain...
[ "Waits", "until", "text", "disappears", "from", "current", "page", "." ]
python
train
SergeySatskiy/cdm-pythonparser
cdmpyparser.py
https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L500-L510
def _onClass(self, name, line, pos, absPosition, keywordLine, keywordPos, colonLine, colonPos, level): """Memorizes a class""" self.__flushLevel(level) c = Class(name, line, pos, absPosition, keywordLine, keywordPos, colonLine, colonPos) ...
[ "def", "_onClass", "(", "self", ",", "name", ",", "line", ",", "pos", ",", "absPosition", ",", "keywordLine", ",", "keywordPos", ",", "colonLine", ",", "colonPos", ",", "level", ")", ":", "self", ".", "__flushLevel", "(", "level", ")", "c", "=", "Class...
Memorizes a class
[ "Memorizes", "a", "class" ]
python
train
pantsbuild/pants
src/python/pants/subsystem/subsystem.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/subsystem/subsystem.py#L98-L111
def scoped_instance(cls, optionable): """Returns an instance of this subsystem for exclusive use by the given `optionable`. :API: public :param optionable: An optionable type or instance to scope this subsystem under. :type: :class:`pants.option.optionable.Optionable` :returns: The scoped subsyste...
[ "def", "scoped_instance", "(", "cls", ",", "optionable", ")", ":", "if", "not", "isinstance", "(", "optionable", ",", "Optionable", ")", "and", "not", "issubclass", "(", "optionable", ",", "Optionable", ")", ":", "raise", "TypeError", "(", "'Can only scope an ...
Returns an instance of this subsystem for exclusive use by the given `optionable`. :API: public :param optionable: An optionable type or instance to scope this subsystem under. :type: :class:`pants.option.optionable.Optionable` :returns: The scoped subsystem instance. :rtype: :class:`pants.subsyst...
[ "Returns", "an", "instance", "of", "this", "subsystem", "for", "exclusive", "use", "by", "the", "given", "optionable", "." ]
python
train
decryptus/sonicprobe
sonicprobe/libs/daemonize.py
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/daemonize.py#L107-L139
def take_file_lock(own_file, lock_file, own_content): """ Atomically "move" @own_file to @lock_file if the latter does not exists, else just remove @own_file. @own_file: filepath of the temporary file that contains our PID @lock_file: destination filepath @own_content: content of @own_file ...
[ "def", "take_file_lock", "(", "own_file", ",", "lock_file", ",", "own_content", ")", ":", "try", ":", "try", ":", "os", ".", "link", "(", "own_file", ",", "lock_file", ")", "finally", ":", "os", ".", "unlink", "(", "own_file", ")", "except", "OSError", ...
Atomically "move" @own_file to @lock_file if the latter does not exists, else just remove @own_file. @own_file: filepath of the temporary file that contains our PID @lock_file: destination filepath @own_content: content of @own_file Return True if the lock has been successfully taken, else False. ...
[ "Atomically", "move", "@own_file", "to", "@lock_file", "if", "the", "latter", "does", "not", "exists", "else", "just", "remove", "@own_file", "." ]
python
train
phaethon/kamene
kamene/contrib/gtp.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gtp.py#L399-L413
def IE_Dispatcher(s): """Choose the correct Information Element class.""" if len(s) < 1: return Raw(s) # Get the IE type ietype = ord(s[0]) cls = ietypecls.get(ietype, Raw) # if ietype greater than 128 are TLVs if cls == Raw and ietype & 128 == 128: cls = IE_NotImplementedTLV return cls(s)
[ "def", "IE_Dispatcher", "(", "s", ")", ":", "if", "len", "(", "s", ")", "<", "1", ":", "return", "Raw", "(", "s", ")", "# Get the IE type", "ietype", "=", "ord", "(", "s", "[", "0", "]", ")", "cls", "=", "ietypecls", ".", "get", "(", "ietype", ...
Choose the correct Information Element class.
[ "Choose", "the", "correct", "Information", "Element", "class", "." ]
python
train
woolfson-group/isambard
isambard/ampal/pseudo_atoms.py
https://github.com/woolfson-group/isambard/blob/ebc33b48a28ad217e18f93b910dfba46e6e71e07/isambard/ampal/pseudo_atoms.py#L275-L288
def rise_per_residue(self): """The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a point on the Primitive. Element i is the distance between primitive[i] and primitive[i + 1]. The final value ...
[ "def", "rise_per_residue", "(", "self", ")", ":", "rprs", "=", "[", "distance", "(", "self", "[", "i", "]", "[", "'CA'", "]", ",", "self", "[", "i", "+", "1", "]", "[", "'CA'", "]", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")"...
The rise per residue at each point on the Primitive. Notes ----- Each element of the returned list is the rise per residue, at a point on the Primitive. Element i is the distance between primitive[i] and primitive[i + 1]. The final value is None.
[ "The", "rise", "per", "residue", "at", "each", "point", "on", "the", "Primitive", "." ]
python
train
log2timeline/plaso
plaso/output/mediator.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/mediator.py#L148-L217
def GetMACBRepresentation(self, event): """Retrieves the MACB representation. Args: event (EventObject): event. Returns: str: MACB representation. """ data_type = getattr(event, 'data_type', None) if not data_type: return '....' # The filestat parser is somewhat limited....
[ "def", "GetMACBRepresentation", "(", "self", ",", "event", ")", ":", "data_type", "=", "getattr", "(", "event", ",", "'data_type'", ",", "None", ")", "if", "not", "data_type", ":", "return", "'....'", "# The filestat parser is somewhat limited.", "if", "data_type"...
Retrieves the MACB representation. Args: event (EventObject): event. Returns: str: MACB representation.
[ "Retrieves", "the", "MACB", "representation", "." ]
python
train
shoebot/shoebot
lib/web/google.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/google.py#L212-L218
def search(q, start=0, wait=10, asynchronous=False, cached=False): """ Returns a Google web query formatted as a GoogleSearch list object. """ service = GOOGLE_SEARCH return GoogleSearch(q, start, service, "", wait, asynchronous, cached)
[ "def", "search", "(", "q", ",", "start", "=", "0", ",", "wait", "=", "10", ",", "asynchronous", "=", "False", ",", "cached", "=", "False", ")", ":", "service", "=", "GOOGLE_SEARCH", "return", "GoogleSearch", "(", "q", ",", "start", ",", "service", ",...
Returns a Google web query formatted as a GoogleSearch list object.
[ "Returns", "a", "Google", "web", "query", "formatted", "as", "a", "GoogleSearch", "list", "object", "." ]
python
valid
mitodl/edx-api-client
edx_api/ccx.py
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/ccx.py#L20-L55
def create(self, master_course_id, coach_email, max_students_allowed, title, modules=None): """ Creates a CCX Args: master_course_id (str): edx course id of the master course coach_email (str): email of the user to make a coach. This user must exist on edx. m...
[ "def", "create", "(", "self", ",", "master_course_id", ",", "coach_email", ",", "max_students_allowed", ",", "title", ",", "modules", "=", "None", ")", ":", "payload", "=", "{", "'master_course_id'", ":", "master_course_id", ",", "'coach_email'", ":", "coach_ema...
Creates a CCX Args: master_course_id (str): edx course id of the master course coach_email (str): email of the user to make a coach. This user must exist on edx. max_students_allowed (int): Maximum number of students to allow in this ccx. title (str): Title of th...
[ "Creates", "a", "CCX" ]
python
train
thumbor-community/redis
tc_redis/storages/redis_storage.py
https://github.com/thumbor-community/redis/blob/e434c151b2d32b2209ce9935493258ee29fb1d1d/tc_redis/storages/redis_storage.py#L55-L75
def on_redis_error(self, fname, exc_type, exc_value): '''Callback executed when there is a redis error. :param string fname: Function name that was being called. :param type exc_type: Exception type :param Exception exc_value: The current exception :returns: Default value or rai...
[ "def", "on_redis_error", "(", "self", ",", "fname", ",", "exc_type", ",", "exc_value", ")", ":", "if", "self", ".", "shared_client", ":", "Storage", ".", "storage", "=", "None", "else", ":", "self", ".", "storage", "=", "None", "if", "self", ".", "cont...
Callback executed when there is a redis error. :param string fname: Function name that was being called. :param type exc_type: Exception type :param Exception exc_value: The current exception :returns: Default value or raise the current exception
[ "Callback", "executed", "when", "there", "is", "a", "redis", "error", "." ]
python
train
librosa/librosa
librosa/util/matching.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/util/matching.py#L63-L113
def __match_intervals(intervals_from, intervals_to, strict=True): # pragma: no cover '''Numba-accelerated interval matching algorithm. ''' # sort index of the interval starts start_index = np.argsort(intervals_to[:, 0]) # sort index of the interval ends end_index = np.argsort(intervals_to[:, ...
[ "def", "__match_intervals", "(", "intervals_from", ",", "intervals_to", ",", "strict", "=", "True", ")", ":", "# pragma: no cover", "# sort index of the interval starts", "start_index", "=", "np", ".", "argsort", "(", "intervals_to", "[", ":", ",", "0", "]", ")", ...
Numba-accelerated interval matching algorithm.
[ "Numba", "-", "accelerated", "interval", "matching", "algorithm", "." ]
python
test
wmayner/pyphi
pyphi/models/actual_causation.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/actual_causation.py#L254-L257
def irreducible_effects(self): """The set of irreducible effects in this |Account|.""" return tuple(link for link in self if link.direction is Direction.EFFECT)
[ "def", "irreducible_effects", "(", "self", ")", ":", "return", "tuple", "(", "link", "for", "link", "in", "self", "if", "link", ".", "direction", "is", "Direction", ".", "EFFECT", ")" ]
The set of irreducible effects in this |Account|.
[ "The", "set", "of", "irreducible", "effects", "in", "this", "|Account|", "." ]
python
train
wonambi-python/wonambi
wonambi/trans/select.py
https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/trans/select.py#L529-L607
def _concat(bundles, cat=(0, 0, 0, 0)): """Prepare event or epoch start and end times for concatenation.""" chan = sorted(set([x['chan'] for x in bundles])) cycle = sorted(set([x['cycle'] for x in bundles])) stage = sorted(set([x['stage'] for x in bundles])) evt_type = sorted(set([x['name'] for x in...
[ "def", "_concat", "(", "bundles", ",", "cat", "=", "(", "0", ",", "0", ",", "0", ",", "0", ")", ")", ":", "chan", "=", "sorted", "(", "set", "(", "[", "x", "[", "'chan'", "]", "for", "x", "in", "bundles", "]", ")", ")", "cycle", "=", "sorte...
Prepare event or epoch start and end times for concatenation.
[ "Prepare", "event", "or", "epoch", "start", "and", "end", "times", "for", "concatenation", "." ]
python
train
tensorpack/tensorpack
examples/FasterRCNN/model_fpn.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/model_fpn.py#L166-L219
def generate_fpn_proposals( multilevel_pred_boxes, multilevel_label_logits, image_shape2d): """ Args: multilevel_pred_boxes: #lvl HxWxAx4 boxes multilevel_label_logits: #lvl tensors of shape HxWxA Returns: boxes: kx4 float scores: k logits """ num_lvl = len(c...
[ "def", "generate_fpn_proposals", "(", "multilevel_pred_boxes", ",", "multilevel_label_logits", ",", "image_shape2d", ")", ":", "num_lvl", "=", "len", "(", "cfg", ".", "FPN", ".", "ANCHOR_STRIDES", ")", "assert", "len", "(", "multilevel_pred_boxes", ")", "==", "num...
Args: multilevel_pred_boxes: #lvl HxWxAx4 boxes multilevel_label_logits: #lvl tensors of shape HxWxA Returns: boxes: kx4 float scores: k logits
[ "Args", ":", "multilevel_pred_boxes", ":", "#lvl", "HxWxAx4", "boxes", "multilevel_label_logits", ":", "#lvl", "tensors", "of", "shape", "HxWxA" ]
python
train
jobovy/galpy
galpy/orbit/OrbitTop.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/OrbitTop.py#L1245-L1304
def _setupaA(self,pot=None,type='staeckel',**kwargs): """ NAME: _setupaA PURPOSE: set up an actionAngle module for this Orbit INPUT: pot - potential type= ('staeckel') type of actionAngle module to use 1) 'adiabatic' ...
[ "def", "_setupaA", "(", "self", ",", "pot", "=", "None", ",", "type", "=", "'staeckel'", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "self", ",", "'_aA'", ")", ":", "if", "not", "self", ".", "_resetaA", "(", "pot", "=", "pot", ",", ...
NAME: _setupaA PURPOSE: set up an actionAngle module for this Orbit INPUT: pot - potential type= ('staeckel') type of actionAngle module to use 1) 'adiabatic' 2) 'staeckel' 3) 'isochroneApprox' 4) 'spheri...
[ "NAME", ":", "_setupaA", "PURPOSE", ":", "set", "up", "an", "actionAngle", "module", "for", "this", "Orbit", "INPUT", ":", "pot", "-", "potential", "type", "=", "(", "staeckel", ")", "type", "of", "actionAngle", "module", "to", "use", "1", ")", "adiabati...
python
train
snare/scruffy
scruffy/state.py
https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/state.py#L54-L59
def save(self): """ Save the state to a file. """ with open(self.path, 'w') as f: f.write(yaml.dump(dict(self.d)))
[ "def", "save", "(", "self", ")", ":", "with", "open", "(", "self", ".", "path", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "yaml", ".", "dump", "(", "dict", "(", "self", ".", "d", ")", ")", ")" ]
Save the state to a file.
[ "Save", "the", "state", "to", "a", "file", "." ]
python
test
fermiPy/fermipy
fermipy/diffuse/diffuse_src_manager.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/diffuse/diffuse_src_manager.py#L134-L152
def make_ring_filelist(self, sourcekeys, rings, galprop_run): """ Make a list of all the template files for a merged component Parameters ---------- sourcekeys : list-like of str The names of the componenents to merge rings : list-like of int The indices...
[ "def", "make_ring_filelist", "(", "self", ",", "sourcekeys", ",", "rings", ",", "galprop_run", ")", ":", "flist", "=", "[", "]", "for", "sourcekey", "in", "sourcekeys", ":", "for", "ring", "in", "rings", ":", "flist", "+=", "[", "self", ".", "make_ring_f...
Make a list of all the template files for a merged component Parameters ---------- sourcekeys : list-like of str The names of the componenents to merge rings : list-like of int The indices of the rings to merge galprop_run : str String identi...
[ "Make", "a", "list", "of", "all", "the", "template", "files", "for", "a", "merged", "component" ]
python
train
monarch-initiative/dipper
dipper/sources/MGI.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/MGI.py#L1343-L1429
def _process_mrk_marker_view(self, limit): """ This is the definition of markers (as in genes, but other genomic loci types as well). It looks up the identifiers in the hashmap This includes their labels, specific class, and identifiers TODO should we use the mrk_mouse_vi...
[ "def", "_process_mrk_marker_view", "(", "self", ",", "limit", ")", ":", "if", "self", ".", "test_mode", ":", "graph", "=", "self", ".", "testgraph", "else", ":", "graph", "=", "self", ".", "graph", "model", "=", "Model", "(", "graph", ")", "geno", "=",...
This is the definition of markers (as in genes, but other genomic loci types as well). It looks up the identifiers in the hashmap This includes their labels, specific class, and identifiers TODO should we use the mrk_mouse_view instead? Triples: <marker_id> a owl:Class O...
[ "This", "is", "the", "definition", "of", "markers", "(", "as", "in", "genes", "but", "other", "genomic", "loci", "types", "as", "well", ")", ".", "It", "looks", "up", "the", "identifiers", "in", "the", "hashmap", "This", "includes", "their", "labels", "s...
python
train
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L758-L761
def delete_issue_link_type(self, issue_link_type_id): """Delete the specified issue link type.""" url = 'rest/api/2/issueLinkType/{issueLinkTypeId}'.format(issueLinkTypeId=issue_link_type_id) return self.delete(url)
[ "def", "delete_issue_link_type", "(", "self", ",", "issue_link_type_id", ")", ":", "url", "=", "'rest/api/2/issueLinkType/{issueLinkTypeId}'", ".", "format", "(", "issueLinkTypeId", "=", "issue_link_type_id", ")", "return", "self", ".", "delete", "(", "url", ")" ]
Delete the specified issue link type.
[ "Delete", "the", "specified", "issue", "link", "type", "." ]
python
train
mdsol/rwslib
rwslib/builders/metadata.py
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L125-L130
def build(self, builder): """Build XML by appending to builder""" builder.start("BasicDefinitions", {}) for child in self.measurement_units: child.build(builder) builder.end("BasicDefinitions")
[ "def", "build", "(", "self", ",", "builder", ")", ":", "builder", ".", "start", "(", "\"BasicDefinitions\"", ",", "{", "}", ")", "for", "child", "in", "self", ".", "measurement_units", ":", "child", ".", "build", "(", "builder", ")", "builder", ".", "e...
Build XML by appending to builder
[ "Build", "XML", "by", "appending", "to", "builder" ]
python
train
globality-corp/microcosm-flask
microcosm_flask/swagger/definitions.py
https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/swagger/definitions.py#L295-L307
def build_response(description, resource=None): """ Build a response definition. """ response = swagger.Response( description=description, ) if resource is not None: response.schema = swagger.JsonReference({ "$ref": "#/definitions/{}".format(type_name(name_for(resour...
[ "def", "build_response", "(", "description", ",", "resource", "=", "None", ")", ":", "response", "=", "swagger", ".", "Response", "(", "description", "=", "description", ",", ")", "if", "resource", "is", "not", "None", ":", "response", ".", "schema", "=", ...
Build a response definition.
[ "Build", "a", "response", "definition", "." ]
python
train
HewlettPackard/python-hpOneView
hpOneView/resources/settings/firmware_bundles.py
https://github.com/HewlettPackard/python-hpOneView/blob/3c6219723ef25e6e0c83d44a89007f89bc325b89/hpOneView/resources/settings/firmware_bundles.py#L48-L62
def upload(self, file_path, timeout=-1): """ Upload an SPP ISO image file or a hotfix file to the appliance. The API supports upload of one hotfix at a time into the system. For the successful upload of a hotfix, ensure its original name and extension are not altered. Args: ...
[ "def", "upload", "(", "self", ",", "file_path", ",", "timeout", "=", "-", "1", ")", ":", "return", "self", ".", "_client", ".", "upload", "(", "file_path", ",", "timeout", "=", "timeout", ")" ]
Upload an SPP ISO image file or a hotfix file to the appliance. The API supports upload of one hotfix at a time into the system. For the successful upload of a hotfix, ensure its original name and extension are not altered. Args: file_path: Full path to firmware. timeout...
[ "Upload", "an", "SPP", "ISO", "image", "file", "or", "a", "hotfix", "file", "to", "the", "appliance", ".", "The", "API", "supports", "upload", "of", "one", "hotfix", "at", "a", "time", "into", "the", "system", ".", "For", "the", "successful", "upload", ...
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/nbformat/v3/rwbase.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/nbformat/v3/rwbase.py#L51-L62
def _join_lines(lines): """join lines that have been written by splitlines() Has logic to protect against `splitlines()`, which should have been `splitlines(True)` """ if lines and lines[0].endswith(('\n', '\r')): # created by splitlines(True) return u''.join(lines) else: ...
[ "def", "_join_lines", "(", "lines", ")", ":", "if", "lines", "and", "lines", "[", "0", "]", ".", "endswith", "(", "(", "'\\n'", ",", "'\\r'", ")", ")", ":", "# created by splitlines(True)", "return", "u''", ".", "join", "(", "lines", ")", "else", ":", ...
join lines that have been written by splitlines() Has logic to protect against `splitlines()`, which should have been `splitlines(True)`
[ "join", "lines", "that", "have", "been", "written", "by", "splitlines", "()", "Has", "logic", "to", "protect", "against", "splitlines", "()", "which", "should", "have", "been", "splitlines", "(", "True", ")" ]
python
test
edx/edx-enterprise
enterprise/api/v1/views.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/api/v1/views.py#L124-L145
def contains_content_items(self, request, pk, course_run_ids, program_uuids): """ Return whether or not the specified content is available to the EnterpriseCustomer. Multiple course_run_ids and/or program_uuids query parameters can be sent to this view to check for their existence in th...
[ "def", "contains_content_items", "(", "self", ",", "request", ",", "pk", ",", "course_run_ids", ",", "program_uuids", ")", ":", "enterprise_customer", "=", "self", ".", "get_object", "(", ")", "# Maintain plus characters in course key.", "course_run_ids", "=", "[", ...
Return whether or not the specified content is available to the EnterpriseCustomer. Multiple course_run_ids and/or program_uuids query parameters can be sent to this view to check for their existence in the EnterpriseCustomerCatalogs associated with this EnterpriseCustomer. At least one course ...
[ "Return", "whether", "or", "not", "the", "specified", "content", "is", "available", "to", "the", "EnterpriseCustomer", "." ]
python
valid
mongolab/mongoctl
mongoctl/users.py
https://github.com/mongolab/mongoctl/blob/fab15216127ad4bf8ea9aa8a95d75504c0ef01a2/mongoctl/users.py#L195-L206
def prepend_global_admin_user(other_users, server): """ When making lists of administrative users -- e.g., seeding a new server -- it's useful to put the credentials supplied on the command line at the head of the queue. """ cred0 = get_global_login_user(server, "admin") if cred0 and cred0["...
[ "def", "prepend_global_admin_user", "(", "other_users", ",", "server", ")", ":", "cred0", "=", "get_global_login_user", "(", "server", ",", "\"admin\"", ")", "if", "cred0", "and", "cred0", "[", "\"username\"", "]", "and", "cred0", "[", "\"password\"", "]", ":"...
When making lists of administrative users -- e.g., seeding a new server -- it's useful to put the credentials supplied on the command line at the head of the queue.
[ "When", "making", "lists", "of", "administrative", "users", "--", "e", ".", "g", ".", "seeding", "a", "new", "server", "--", "it", "s", "useful", "to", "put", "the", "credentials", "supplied", "on", "the", "command", "line", "at", "the", "head", "of", ...
python
train
beregond/super_state_machine
super_state_machine/utils.py
https://github.com/beregond/super_state_machine/blob/31ad527f4e6b7a01e315ce865735ca18957c223e/super_state_machine/utils.py#L127-L142
def translate(self, value): """Translate value to enum instance. If value is already enum instance, check if this value belongs to base enum. """ if self._check_if_already_proper(value): return value try: return self.search_table[value] ...
[ "def", "translate", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_check_if_already_proper", "(", "value", ")", ":", "return", "value", "try", ":", "return", "self", ".", "search_table", "[", "value", "]", "except", "KeyError", ":", "raise", "...
Translate value to enum instance. If value is already enum instance, check if this value belongs to base enum.
[ "Translate", "value", "to", "enum", "instance", "." ]
python
train
skelsec/minikerberos
minikerberos/communication.py
https://github.com/skelsec/minikerberos/blob/caf14c1d0132119d6e8a8f05120efb7d0824b2c6/minikerberos/communication.py#L215-L285
def get_TGT(self, override_etype = None, decrypt_tgt = True): """ decrypt_tgt: used for asreproast attacks Steps performed: 1. Send and empty (no encrypted timestamp) AS_REQ with all the encryption types we support 2. Depending on the response (either error or AS_REP with TGT) we either send another AS_REQ ...
[ "def", "get_TGT", "(", "self", ",", "override_etype", "=", "None", ",", "decrypt_tgt", "=", "True", ")", ":", "logger", ".", "debug", "(", "'Generating initial TGT without authentication data'", ")", "now", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ...
decrypt_tgt: used for asreproast attacks Steps performed: 1. Send and empty (no encrypted timestamp) AS_REQ with all the encryption types we support 2. Depending on the response (either error or AS_REP with TGT) we either send another AS_REQ with the encrypted data or return the TGT (or fail miserably) 3. PR...
[ "decrypt_tgt", ":", "used", "for", "asreproast", "attacks", "Steps", "performed", ":", "1", ".", "Send", "and", "empty", "(", "no", "encrypted", "timestamp", ")", "AS_REQ", "with", "all", "the", "encryption", "types", "we", "support", "2", ".", "Depending", ...
python
train
lingthio/Flask-User
flask_user/user_manager__utils.py
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/user_manager__utils.py#L54-L72
def make_safe_url(self, url): """Makes a URL safe by removing optional hostname and port. Example: | ``make_safe_url('https://hostname:80/path1/path2?q1=v1&q2=v2#fragment')`` | returns ``'/path1/path2?q1=v1&q2=v2#fragment'`` Override this method if you need to allow a ...
[ "def", "make_safe_url", "(", "self", ",", "url", ")", ":", "# Split the URL into scheme, netloc, path, query and fragment", "parts", "=", "list", "(", "urlsplit", "(", "url", ")", ")", "# Clear scheme and netloc and rebuild URL", "parts", "[", "0", "]", "=", "''", "...
Makes a URL safe by removing optional hostname and port. Example: | ``make_safe_url('https://hostname:80/path1/path2?q1=v1&q2=v2#fragment')`` | returns ``'/path1/path2?q1=v1&q2=v2#fragment'`` Override this method if you need to allow a list of safe hostnames.
[ "Makes", "a", "URL", "safe", "by", "removing", "optional", "hostname", "and", "port", "." ]
python
train
rpcope1/PythonConfluenceAPI
PythonConfluenceAPI/api.py
https://github.com/rpcope1/PythonConfluenceAPI/blob/b7f0ca2a390f964715fdf3a60b5b0c5ef7116d40/PythonConfluenceAPI/api.py#L463-L501
def get_content_comments(self, content_id, expand=None, parent_version=None, start=None, limit=None, location=None, depth=None, callback=None): """ Returns the comments associated with a piece of content. :param content_id (string): A string containing the id of the ...
[ "def", "get_content_comments", "(", "self", ",", "content_id", ",", "expand", "=", "None", ",", "parent_version", "=", "None", ",", "start", "=", "None", ",", "limit", "=", "None", ",", "location", "=", "None", ",", "depth", "=", "None", ",", "callback",...
Returns the comments associated with a piece of content. :param content_id (string): A string containing the id of the content to retrieve children for. :param expand (string): OPTIONAL: a comma separated list of properties to expand on the children. We can also specify s...
[ "Returns", "the", "comments", "associated", "with", "a", "piece", "of", "content", ".", ":", "param", "content_id", "(", "string", ")", ":", "A", "string", "containing", "the", "id", "of", "the", "content", "to", "retrieve", "children", "for", ".", ":", ...
python
train
klahnakoski/pyLibrary
mo_collections/matrix.py
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L226-L232
def items(self): """ ITERATE THROUGH ALL coord, value PAIRS """ for c in self._all_combos(): _, value = _getitem(self.cube, c) yield c, value
[ "def", "items", "(", "self", ")", ":", "for", "c", "in", "self", ".", "_all_combos", "(", ")", ":", "_", ",", "value", "=", "_getitem", "(", "self", ".", "cube", ",", "c", ")", "yield", "c", ",", "value" ]
ITERATE THROUGH ALL coord, value PAIRS
[ "ITERATE", "THROUGH", "ALL", "coord", "value", "PAIRS" ]
python
train
iktakahiro/slackpy
slackpy/slackpy.py
https://github.com/iktakahiro/slackpy/blob/23c0a2a33e408d0e8d24bc704d7021e85d6ae39a/slackpy/slackpy.py#L90-L117
def __send_notification(self, message, title, title_link='', color='good', fields='', log_level=LogLv.INFO): """Send a message to a channel. Args: title: Message title. title_link: Link of the message title. message: Message body. ...
[ "def", "__send_notification", "(", "self", ",", "message", ",", "title", ",", "title_link", "=", "''", ",", "color", "=", "'good'", ",", "fields", "=", "''", ",", "log_level", "=", "LogLv", ".", "INFO", ")", ":", "if", "log_level", "<", "self", ".", ...
Send a message to a channel. Args: title: Message title. title_link: Link of the message title. message: Message body. color: Message line color on Slack. This parameter should be one of the following values: 'good', 'warning', 'danger' or any hex col...
[ "Send", "a", "message", "to", "a", "channel", ".", "Args", ":", "title", ":", "Message", "title", ".", "title_link", ":", "Link", "of", "the", "message", "title", ".", "message", ":", "Message", "body", ".", "color", ":", "Message", "line", "color", "o...
python
train