repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
dbarsam/python-vsgen
vsgen/util/entrypoints.py
entrypoint
def entrypoint(section, option): """ Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available. """ try: ...
python
def entrypoint(section, option): """ Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available. """ try: ...
[ "def", "entrypoint", "(", "section", ",", "option", ")", ":", "try", ":", "return", "entrypoints", "(", "section", ")", "[", "option", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'Cannot resolve type \"{}\" to a recognised vsgen \"{}\" type.'", ".", ...
Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available.
[ "Returns", "the", "the", "entry", "point", "object", "given", "a", "section", "option", "pair", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/entrypoints.py#L22-L33
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_declared.py
infer_declared
def infer_declared(ms, namespace=None): '''Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, th...
python
def infer_declared(ms, namespace=None): '''Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, th...
[ "def", "infer_declared", "(", "ms", ",", "namespace", "=", "None", ")", ":", "conditions", "=", "[", "]", "for", "m", "in", "ms", ":", "for", "cav", "in", "m", ".", "caveats", ":", "if", "cav", ".", "location", "is", "None", "or", "cav", ".", "lo...
Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, the information is omitted from the map. When the...
[ "Retrieves", "any", "declared", "information", "from", "the", "given", "macaroons", "and", "returns", "it", "as", "a", "key", "-", "value", "map", ".", "Information", "is", "declared", "with", "a", "first", "party", "caveat", "as", "created", "by", "declared...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_declared.py#L15-L32
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_declared.py
infer_declared_from_conditions
def infer_declared_from_conditions(conds, namespace=None): ''' like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons. ''' conflicts = [] # If we can't resolve that standard namespace, then we'll look for # just bare...
python
def infer_declared_from_conditions(conds, namespace=None): ''' like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons. ''' conflicts = [] # If we can't resolve that standard namespace, then we'll look for # just bare...
[ "def", "infer_declared_from_conditions", "(", "conds", ",", "namespace", "=", "None", ")", ":", "conflicts", "=", "[", "]", "if", "namespace", "is", "None", ":", "namespace", "=", "Namespace", "(", ")", "prefix", "=", "namespace", ".", "resolve", "(", "STD...
like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons.
[ "like", "infer_declared", "except", "that", "it", "is", "passed", "a", "set", "of", "first", "party", "caveat", "conditions", "as", "a", "list", "of", "string", "rather", "than", "a", "set", "of", "macaroons", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_declared.py#L35-L69
train
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
GwBasePattern._pre_activate_injection
def _pre_activate_injection(self): """ Injects functions before the activation routine of child classes gets called """ # Let's be sure that this plugins class is registered and available on application level under # application.plugins.classes. This allows to reuse this class fo...
python
def _pre_activate_injection(self): """ Injects functions before the activation routine of child classes gets called """ # Let's be sure that this plugins class is registered and available on application level under # application.plugins.classes. This allows to reuse this class fo...
[ "def", "_pre_activate_injection", "(", "self", ")", ":", "if", "not", "self", ".", "app", ".", "plugins", ".", "classes", ".", "exist", "(", "self", ".", "__class__", ".", "__name__", ")", ":", "self", ".", "app", ".", "plugins", ".", "classes", ".", ...
Injects functions before the activation routine of child classes gets called
[ "Injects", "functions", "before", "the", "activation", "routine", "of", "child", "classes", "gets", "called" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L135-L146
train
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.register
def register(self, signal, description): """ Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used fo...
python
def register(self, signal, description): """ Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used fo...
[ "def", "register", "(", "self", ",", "signal", ",", "description", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "register", "(", "signal", ",", "self", ".", "_plugin", ",", "description", ")" ]
Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used for documentation.
[ "Registers", "a", "new", "signal", ".", "Only", "registered", "signals", "are", "allowed", "to", "be", "send", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L248-L257
train
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.get
def get(self, signal=None): """ Returns a single signal or a dictionary of signals for this plugin. """ return self.__app.signals.get(signal, self._plugin)
python
def get(self, signal=None): """ Returns a single signal or a dictionary of signals for this plugin. """ return self.__app.signals.get(signal, self._plugin)
[ "def", "get", "(", "self", ",", "signal", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "get", "(", "signal", ",", "self", ".", "_plugin", ")" ]
Returns a single signal or a dictionary of signals for this plugin.
[ "Returns", "a", "single", "signal", "or", "a", "dictionary", "of", "signals", "for", "this", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L294-L298
train
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.get_receiver
def get_receiver(self, receiver=None): """ Returns a single receiver or a dictionary of receivers for this plugin. """ return self.__app.signals.get_receiver(receiver, self._plugin)
python
def get_receiver(self, receiver=None): """ Returns a single receiver or a dictionary of receivers for this plugin. """ return self.__app.signals.get_receiver(receiver, self._plugin)
[ "def", "get_receiver", "(", "self", ",", "receiver", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "get_receiver", "(", "receiver", ",", "self", ".", "_plugin", ")" ]
Returns a single receiver or a dictionary of receivers for this plugin.
[ "Returns", "a", "single", "receiver", "or", "a", "dictionary", "of", "receivers", "for", "this", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L300-L304
train
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.validate
def validate(mcs, bases, attributes): """Check attributes.""" if bases[0] is object: return None mcs.check_model_cls(attributes) mcs.check_include_exclude(attributes) mcs.check_properties(attributes)
python
def validate(mcs, bases, attributes): """Check attributes.""" if bases[0] is object: return None mcs.check_model_cls(attributes) mcs.check_include_exclude(attributes) mcs.check_properties(attributes)
[ "def", "validate", "(", "mcs", ",", "bases", ",", "attributes", ")", ":", "if", "bases", "[", "0", "]", "is", "object", ":", "return", "None", "mcs", ".", "check_model_cls", "(", "attributes", ")", "mcs", ".", "check_include_exclude", "(", "attributes", ...
Check attributes.
[ "Check", "attributes", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L18-L24
train
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.get_properties
def get_properties(attributes): """Return tuple of names of defined properties. :type attributes: dict :rtype: list """ return [key for key, value in six.iteritems(attributes) if isinstance(value, property)]
python
def get_properties(attributes): """Return tuple of names of defined properties. :type attributes: dict :rtype: list """ return [key for key, value in six.iteritems(attributes) if isinstance(value, property)]
[ "def", "get_properties", "(", "attributes", ")", ":", "return", "[", "key", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "attributes", ")", "if", "isinstance", "(", "value", ",", "property", ")", "]" ]
Return tuple of names of defined properties. :type attributes: dict :rtype: list
[ "Return", "tuple", "of", "names", "of", "defined", "properties", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L76-L83
train
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.check_properties
def check_properties(mcs, attributes): """Check whether intersections exist. :type attributes: dict """ include, exclude = mcs.get_prepared_include_exclude(attributes) properties = mcs.get_properties(attributes) intersections = list( set(properties).intersect...
python
def check_properties(mcs, attributes): """Check whether intersections exist. :type attributes: dict """ include, exclude = mcs.get_prepared_include_exclude(attributes) properties = mcs.get_properties(attributes) intersections = list( set(properties).intersect...
[ "def", "check_properties", "(", "mcs", ",", "attributes", ")", ":", "include", ",", "exclude", "=", "mcs", ".", "get_prepared_include_exclude", "(", "attributes", ")", "properties", "=", "mcs", ".", "get_properties", "(", "attributes", ")", "intersections", "=",...
Check whether intersections exist. :type attributes: dict
[ "Check", "whether", "intersections", "exist", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L86-L103
train
SandstoneHPC/sandstone-ide
sandstone/lib/filesystem/filewatcher.py
FilesystemEventHandler.on_deleted
def on_deleted(self, event): """ Event Handler when a file is deleted """ key = 'filesystem:file_deleted' data = { 'filepath': event.src_path, 'is_directory': event.is_directory, 'dirpath': os.path.dirname(event.src_path) } bms...
python
def on_deleted(self, event): """ Event Handler when a file is deleted """ key = 'filesystem:file_deleted' data = { 'filepath': event.src_path, 'is_directory': event.is_directory, 'dirpath': os.path.dirname(event.src_path) } bms...
[ "def", "on_deleted", "(", "self", ",", "event", ")", ":", "key", "=", "'filesystem:file_deleted'", "data", "=", "{", "'filepath'", ":", "event", ".", "src_path", ",", "'is_directory'", ":", "event", ".", "is_directory", ",", "'dirpath'", ":", "os", ".", "p...
Event Handler when a file is deleted
[ "Event", "Handler", "when", "a", "file", "is", "deleted" ]
7a47947fb07281c3e3018042863dc67e7e56dc04
https://github.com/SandstoneHPC/sandstone-ide/blob/7a47947fb07281c3e3018042863dc67e7e56dc04/sandstone/lib/filesystem/filewatcher.py#L27-L39
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/agent/_agent.py
read_auth_info
def read_auth_info(agent_file_content): '''Loads agent authentication information from the specified content string, as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor. @param agent_file_content The agent file content (str)...
python
def read_auth_info(agent_file_content): '''Loads agent authentication information from the specified content string, as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor. @param agent_file_content The agent file content (str)...
[ "def", "read_auth_info", "(", "agent_file_content", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "agent_file_content", ")", "return", "AuthInfo", "(", "key", "=", "bakery", ".", "PrivateKey", ".", "deserialize", "(", "data", "[", "'key'", ...
Loads agent authentication information from the specified content string, as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor. @param agent_file_content The agent file content (str) @return AuthInfo The authentication inform...
[ "Loads", "agent", "authentication", "information", "from", "the", "specified", "content", "string", "as", "read", "from", "an", "agents", "file", ".", "The", "returned", "information", "is", "suitable", "for", "passing", "as", "an", "argument", "to", "the", "A...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/agent/_agent.py#L37-L60
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/agent/_agent.py
AgentInteractor.interact
def interact(self, client, location, interaction_required_err): '''Implement Interactor.interact by obtaining obtaining a macaroon from the discharger, discharging it with the local private key using the discharged macaroon as a discharge token''' p = interaction_required_err.int...
python
def interact(self, client, location, interaction_required_err): '''Implement Interactor.interact by obtaining obtaining a macaroon from the discharger, discharging it with the local private key using the discharged macaroon as a discharge token''' p = interaction_required_err.int...
[ "def", "interact", "(", "self", ",", "client", ",", "location", ",", "interaction_required_err", ")", ":", "p", "=", "interaction_required_err", ".", "interaction_method", "(", "'agent'", ",", "InteractionInfo", ")", "if", "p", ".", "login_url", "is", "None", ...
Implement Interactor.interact by obtaining obtaining a macaroon from the discharger, discharging it with the local private key using the discharged macaroon as a discharge token
[ "Implement", "Interactor", ".", "interact", "by", "obtaining", "obtaining", "a", "macaroon", "from", "the", "discharger", "discharging", "it", "with", "the", "local", "private", "key", "using", "the", "discharged", "macaroon", "as", "a", "discharge", "token" ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/agent/_agent.py#L98-L130
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/agent/_agent.py
AgentInteractor.legacy_interact
def legacy_interact(self, client, location, visit_url): '''Implement LegacyInteractor.legacy_interact by obtaining the discharge macaroon using the client's private key ''' agent = self._find_agent(location) # Shallow-copy the client so that we don't unexpectedly side-effect ...
python
def legacy_interact(self, client, location, visit_url): '''Implement LegacyInteractor.legacy_interact by obtaining the discharge macaroon using the client's private key ''' agent = self._find_agent(location) # Shallow-copy the client so that we don't unexpectedly side-effect ...
[ "def", "legacy_interact", "(", "self", ",", "client", ",", "location", ",", "visit_url", ")", ":", "agent", "=", "self", ".", "_find_agent", "(", "location", ")", "client", "=", "copy", ".", "copy", "(", "client", ")", "client", ".", "key", "=", "self"...
Implement LegacyInteractor.legacy_interact by obtaining the discharge macaroon using the client's private key
[ "Implement", "LegacyInteractor", ".", "legacy_interact", "by", "obtaining", "the", "discharge", "macaroon", "using", "the", "client", "s", "private", "key" ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/agent/_agent.py#L143-L166
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_time.py
expiry_time
def expiry_time(ns, cavs): ''' Returns the minimum time of any time-before caveats found in the given list or None if no such caveats were found. The ns parameter is :param ns: used to determine the standard namespace prefix - if the standard namespace is not found, the empty prefix is assumed. ...
python
def expiry_time(ns, cavs): ''' Returns the minimum time of any time-before caveats found in the given list or None if no such caveats were found. The ns parameter is :param ns: used to determine the standard namespace prefix - if the standard namespace is not found, the empty prefix is assumed. ...
[ "def", "expiry_time", "(", "ns", ",", "cavs", ")", ":", "prefix", "=", "ns", ".", "resolve", "(", "STD_NAMESPACE", ")", "time_before_cond", "=", "condition_with_prefix", "(", "prefix", ",", "COND_TIME_BEFORE", ")", "t", "=", "None", "for", "cav", "in", "ca...
Returns the minimum time of any time-before caveats found in the given list or None if no such caveats were found. The ns parameter is :param ns: used to determine the standard namespace prefix - if the standard namespace is not found, the empty prefix is assumed. :param cavs: a list of pymacaroons...
[ "Returns", "the", "minimum", "time", "of", "any", "time", "-", "before", "caveats", "found", "in", "the", "given", "list", "or", "None", "if", "no", "such", "caveats", "were", "found", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_time.py#L40-L67
train
Phyks/libbmc
libbmc/tools.py
replace_all
def replace_all(text, replace_dict): """ Replace multiple strings in a text. .. note:: Replacements are made successively, without any warranty on the order \ in which they are made. :param text: Text to replace in. :param replace_dict: Dictionary mapping strings to replace with ...
python
def replace_all(text, replace_dict): """ Replace multiple strings in a text. .. note:: Replacements are made successively, without any warranty on the order \ in which they are made. :param text: Text to replace in. :param replace_dict: Dictionary mapping strings to replace with ...
[ "def", "replace_all", "(", "text", ",", "replace_dict", ")", ":", "for", "i", ",", "j", "in", "replace_dict", ".", "items", "(", ")", ":", "text", "=", "text", ".", "replace", "(", "i", ",", "j", ")", "return", "text" ]
Replace multiple strings in a text. .. note:: Replacements are made successively, without any warranty on the order \ in which they are made. :param text: Text to replace in. :param replace_dict: Dictionary mapping strings to replace with their \ substitution. :returns: T...
[ "Replace", "multiple", "strings", "in", "a", "text", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/tools.py#L16-L36
train
Phyks/libbmc
libbmc/tools.py
map_or_apply
def map_or_apply(function, param): """ Map the function on ``param``, or apply it, depending whether ``param`` \ is a list or an item. :param function: The function to apply. :param param: The parameter to feed the function with (list or item). :returns: The computed value or ``None``. ...
python
def map_or_apply(function, param): """ Map the function on ``param``, or apply it, depending whether ``param`` \ is a list or an item. :param function: The function to apply. :param param: The parameter to feed the function with (list or item). :returns: The computed value or ``None``. ...
[ "def", "map_or_apply", "(", "function", ",", "param", ")", ":", "try", ":", "if", "isinstance", "(", "param", ",", "list", ")", ":", "return", "[", "next", "(", "iter", "(", "function", "(", "i", ")", ")", ")", "for", "i", "in", "param", "]", "el...
Map the function on ``param``, or apply it, depending whether ``param`` \ is a list or an item. :param function: The function to apply. :param param: The parameter to feed the function with (list or item). :returns: The computed value or ``None``.
[ "Map", "the", "function", "on", "param", "or", "apply", "it", "depending", "whether", "param", "\\", "is", "a", "list", "or", "an", "item", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/tools.py#L39-L54
train
Phyks/libbmc
libbmc/tools.py
batch
def batch(iterable, size): """ Get items from a sequence a batch at a time. .. note: Adapted from https://code.activestate.com/recipes/303279-getting-items-in-batches/. .. note: All batches must be exhausted immediately. :params iterable: An iterable to get batches from...
python
def batch(iterable, size): """ Get items from a sequence a batch at a time. .. note: Adapted from https://code.activestate.com/recipes/303279-getting-items-in-batches/. .. note: All batches must be exhausted immediately. :params iterable: An iterable to get batches from...
[ "def", "batch", "(", "iterable", ",", "size", ")", ":", "item", "=", "iter", "(", "iterable", ")", "while", "True", ":", "batch_iterator", "=", "islice", "(", "item", ",", "size", ")", "try", ":", "yield", "chain", "(", "[", "next", "(", "batch_itera...
Get items from a sequence a batch at a time. .. note: Adapted from https://code.activestate.com/recipes/303279-getting-items-in-batches/. .. note: All batches must be exhausted immediately. :params iterable: An iterable to get batches from. :params size: Size of the batches...
[ "Get", "items", "from", "a", "sequence", "a", "batch", "at", "a", "time", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/tools.py#L87-L114
train
Phyks/libbmc
libbmc/tools.py
slugify
def slugify(value): """ Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens to have nice filenames. From Django's "django/template/defaultfilters.py". >>> slugify("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su q...
python
def slugify(value): """ Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens to have nice filenames. From Django's "django/template/defaultfilters.py". >>> slugify("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su q...
[ "def", "slugify", "(", "value", ")", ":", "try", ":", "unicode_type", "=", "unicode", "except", "NameError", ":", "unicode_type", "=", "str", "if", "not", "isinstance", "(", "value", ",", "unicode_type", ")", ":", "value", "=", "unicode_type", "(", "value"...
Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens to have nice filenames. From Django's "django/template/defaultfilters.py". >>> slugify("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro. ortez ce vieux ...
[ "Normalizes", "string", "converts", "to", "lowercase", "removes", "non", "-", "alpha", "characters", "and", "converts", "spaces", "to", "hyphens", "to", "have", "nice", "filenames", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/tools.py#L131-L150
train
Phyks/libbmc
libbmc/citations/repositories/arxiv.py
get_plaintext_citations
def get_plaintext_citations(arxiv_id): """ Get the citations of a given preprint, in plain text. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1...
python
def get_plaintext_citations(arxiv_id): """ Get the citations of a given preprint, in plain text. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1...
[ "def", "get_plaintext_citations", "(", "arxiv_id", ")", ":", "plaintext_citations", "=", "[", "]", "bbl_files", "=", "arxiv", ".", "get_bbl", "(", "arxiv_id", ")", "for", "bbl_file", "in", "bbl_files", ":", "plaintext_citations", ".", "extend", "(", "bbl", "."...
Get the citations of a given preprint, in plain text. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1401.2910`` or ``1401.2910v1``) in \ a c...
[ "Get", "the", "citations", "of", "a", "given", "preprint", "in", "plain", "text", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/repositories/arxiv.py#L9-L28
train
Phyks/libbmc
libbmc/citations/repositories/arxiv.py
get_cited_dois
def get_cited_dois(arxiv_id): """ Get the DOIs of the papers cited in a .bbl file. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1401.2910`` or ...
python
def get_cited_dois(arxiv_id): """ Get the DOIs of the papers cited in a .bbl file. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1401.2910`` or ...
[ "def", "get_cited_dois", "(", "arxiv_id", ")", ":", "dois", "=", "{", "}", "bbl_files", "=", "arxiv", ".", "get_bbl", "(", "arxiv_id", ")", "for", "bbl_file", "in", "bbl_files", ":", "dois", ".", "update", "(", "bbl", ".", "get_cited_dois", "(", "bbl_fil...
Get the DOIs of the papers cited in a .bbl file. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1401.2910`` or ``1401.2910v1``) in \ a canoni...
[ "Get", "the", "DOIs", "of", "the", "papers", "cited", "in", "a", ".", "bbl", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/repositories/arxiv.py#L31-L50
train
eonpatapon/contrail-api-cli
contrail_api_cli/main.py
get_subcommand_kwargs
def get_subcommand_kwargs(mgr, name, namespace): """Get subcommand options from global parsed arguments. """ subcmd = mgr.get(name) subcmd_kwargs = {} for opt in list(subcmd.args.values()) + list(subcmd.options.values()): if hasattr(namespace, opt.dest): subcmd_kwargs[opt.des...
python
def get_subcommand_kwargs(mgr, name, namespace): """Get subcommand options from global parsed arguments. """ subcmd = mgr.get(name) subcmd_kwargs = {} for opt in list(subcmd.args.values()) + list(subcmd.options.values()): if hasattr(namespace, opt.dest): subcmd_kwargs[opt.des...
[ "def", "get_subcommand_kwargs", "(", "mgr", ",", "name", ",", "namespace", ")", ":", "subcmd", "=", "mgr", ".", "get", "(", "name", ")", "subcmd_kwargs", "=", "{", "}", "for", "opt", "in", "list", "(", "subcmd", ".", "args", ".", "values", "(", ")", ...
Get subcommand options from global parsed arguments.
[ "Get", "subcommand", "options", "from", "global", "parsed", "arguments", "." ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/main.py#L23-L32
train
Phyks/libbmc
libbmc/citations/plaintext.py
get_plaintext_citations
def get_plaintext_citations(file): """ Parse a plaintext file to get a clean list of plaintext citations. The \ file should have one citation per line. :param file: Either the path to the plaintext file or the content of a \ plaintext file. :returns: A list of cleaned plaintext...
python
def get_plaintext_citations(file): """ Parse a plaintext file to get a clean list of plaintext citations. The \ file should have one citation per line. :param file: Either the path to the plaintext file or the content of a \ plaintext file. :returns: A list of cleaned plaintext...
[ "def", "get_plaintext_citations", "(", "file", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "file", ")", ":", "with", "open", "(", "file", ",", "'r'", ")", "as", "fh", ":", "content", "=", "fh", ".", "readlines", "(", ")", "else", ":", ...
Parse a plaintext file to get a clean list of plaintext citations. The \ file should have one citation per line. :param file: Either the path to the plaintext file or the content of a \ plaintext file. :returns: A list of cleaned plaintext citations.
[ "Parse", "a", "plaintext", "file", "to", "get", "a", "clean", "list", "of", "plaintext", "citations", ".", "The", "\\", "file", "should", "have", "one", "citation", "per", "line", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/plaintext.py#L20-L37
train
Phyks/libbmc
libbmc/citations/plaintext.py
get_cited_dois
def get_cited_dois(file): """ Get the DOIs of the papers cited in a plaintext file. The file should \ have one citation per line. .. note:: This function is also used as a backend tool by most of the others \ citations processors, to factorize the code. :param file: Either...
python
def get_cited_dois(file): """ Get the DOIs of the papers cited in a plaintext file. The file should \ have one citation per line. .. note:: This function is also used as a backend tool by most of the others \ citations processors, to factorize the code. :param file: Either...
[ "def", "get_cited_dois", "(", "file", ")", ":", "if", "not", "isinstance", "(", "file", ",", "list", ")", ":", "plaintext_citations", "=", "get_plaintext_citations", "(", "file", ")", "else", ":", "plaintext_citations", "=", "file", "dois", "=", "{", "}", ...
Get the DOIs of the papers cited in a plaintext file. The file should \ have one citation per line. .. note:: This function is also used as a backend tool by most of the others \ citations processors, to factorize the code. :param file: Either the path to the plaintext file or the...
[ "Get", "the", "DOIs", "of", "the", "papers", "cited", "in", "a", "plaintext", "file", ".", "The", "file", "should", "\\", "have", "one", "citation", "per", "line", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/citations/plaintext.py#L40-L103
train
Phyks/libbmc
libbmc/isbn.py
is_valid
def is_valid(isbn_id): """ Check that a given string is a valid ISBN. :param isbn_id: the isbn to be checked. :returns: boolean indicating whether the isbn is valid or not. >>> is_valid("978-3-16-148410-0") True >>> is_valid("9783161484100") True >>> is_valid("9783161484100aa") ...
python
def is_valid(isbn_id): """ Check that a given string is a valid ISBN. :param isbn_id: the isbn to be checked. :returns: boolean indicating whether the isbn is valid or not. >>> is_valid("978-3-16-148410-0") True >>> is_valid("9783161484100") True >>> is_valid("9783161484100aa") ...
[ "def", "is_valid", "(", "isbn_id", ")", ":", "return", "(", "(", "not", "isbnlib", ".", "notisbn", "(", "isbn_id", ")", ")", "and", "(", "isbnlib", ".", "get_canonical_isbn", "(", "isbn_id", ")", "==", "isbn_id", "or", "isbnlib", ".", "mask", "(", "isb...
Check that a given string is a valid ISBN. :param isbn_id: the isbn to be checked. :returns: boolean indicating whether the isbn is valid or not. >>> is_valid("978-3-16-148410-0") True >>> is_valid("9783161484100") True >>> is_valid("9783161484100aa") False >>> is_valid("abcd") ...
[ "Check", "that", "a", "given", "string", "is", "a", "valid", "ISBN", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/isbn.py#L14-L49
train
Phyks/libbmc
libbmc/isbn.py
extract_from_text
def extract_from_text(text): """ Extract ISBNs from a text. :param text: Some text. :returns: A list of canonical ISBNs found in the text. >>> extract_from_text("978-3-16-148410-0 9783161484100 9783161484100aa abcd 0136091814 0136091812 9780136091817 123456789X") ['9783161484100', '97831614841...
python
def extract_from_text(text): """ Extract ISBNs from a text. :param text: Some text. :returns: A list of canonical ISBNs found in the text. >>> extract_from_text("978-3-16-148410-0 9783161484100 9783161484100aa abcd 0136091814 0136091812 9780136091817 123456789X") ['9783161484100', '97831614841...
[ "def", "extract_from_text", "(", "text", ")", ":", "isbns", "=", "[", "isbnlib", ".", "get_canonical_isbn", "(", "isbn", ")", "for", "isbn", "in", "isbnlib", ".", "get_isbnlike", "(", "text", ")", "]", "return", "[", "i", "for", "i", "in", "isbns", "if...
Extract ISBNs from a text. :param text: Some text. :returns: A list of canonical ISBNs found in the text. >>> extract_from_text("978-3-16-148410-0 9783161484100 9783161484100aa abcd 0136091814 0136091812 9780136091817 123456789X") ['9783161484100', '9783161484100', '9783161484100', '0136091814', '1234...
[ "Extract", "ISBNs", "from", "a", "text", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/isbn.py#L52-L64
train
Phyks/libbmc
libbmc/isbn.py
get_bibtex
def get_bibtex(isbn_identifier): """ Get a BibTeX string for the given ISBN. :param isbn_identifier: ISBN to fetch BibTeX entry for. :returns: A BibTeX string or ``None`` if could not fetch it. >>> get_bibtex('9783161484100') '@book{9783161484100,\\n title = {Berkeley, Oakland: Albany, Eme...
python
def get_bibtex(isbn_identifier): """ Get a BibTeX string for the given ISBN. :param isbn_identifier: ISBN to fetch BibTeX entry for. :returns: A BibTeX string or ``None`` if could not fetch it. >>> get_bibtex('9783161484100') '@book{9783161484100,\\n title = {Berkeley, Oakland: Albany, Eme...
[ "def", "get_bibtex", "(", "isbn_identifier", ")", ":", "bibtex", "=", "doi", ".", "get_bibtex", "(", "to_doi", "(", "isbn_identifier", ")", ")", "if", "bibtex", "is", "None", ":", "bibtex", "=", "isbnlib", ".", "registry", ".", "bibformatters", "[", "'bibt...
Get a BibTeX string for the given ISBN. :param isbn_identifier: ISBN to fetch BibTeX entry for. :returns: A BibTeX string or ``None`` if could not fetch it. >>> get_bibtex('9783161484100') '@book{9783161484100,\\n title = {Berkeley, Oakland: Albany, Emeryville, Alameda, Kensington},\\n author =...
[ "Get", "a", "BibTeX", "string", "for", "the", "given", "ISBN", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/isbn.py#L67-L85
train
eonpatapon/contrail-api-cli
contrail_api_cli/parser.py
CommandParser.used_options
def used_options(self): """Return options already used in the command line rtype: command.Option generator """ for option_str in filter(lambda c: c.startswith('-'), self.words): for option in list(self.cmd.options.values()): if option_str in option.op...
python
def used_options(self): """Return options already used in the command line rtype: command.Option generator """ for option_str in filter(lambda c: c.startswith('-'), self.words): for option in list(self.cmd.options.values()): if option_str in option.op...
[ "def", "used_options", "(", "self", ")", ":", "for", "option_str", "in", "filter", "(", "lambda", "c", ":", "c", ".", "startswith", "(", "'-'", ")", ",", "self", ".", "words", ")", ":", "for", "option", "in", "list", "(", "self", ".", "cmd", ".", ...
Return options already used in the command line rtype: command.Option generator
[ "Return", "options", "already", "used", "in", "the", "command", "line" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/parser.py#L40-L49
train
eonpatapon/contrail-api-cli
contrail_api_cli/parser.py
CommandParser.available_options
def available_options(self): """Return options that can be used given the current cmd line rtype: command.Option generator """ for option in list(self.cmd.options.values()): if (option.is_multiple or option not in list(self.used_options)): ...
python
def available_options(self): """Return options that can be used given the current cmd line rtype: command.Option generator """ for option in list(self.cmd.options.values()): if (option.is_multiple or option not in list(self.used_options)): ...
[ "def", "available_options", "(", "self", ")", ":", "for", "option", "in", "list", "(", "self", ".", "cmd", ".", "options", ".", "values", "(", ")", ")", ":", "if", "(", "option", ".", "is_multiple", "or", "option", "not", "in", "list", "(", "self", ...
Return options that can be used given the current cmd line rtype: command.Option generator
[ "Return", "options", "that", "can", "be", "used", "given", "the", "current", "cmd", "line" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/parser.py#L52-L61
train
eonpatapon/contrail-api-cli
contrail_api_cli/parser.py
CommandParser.used_args
def used_args(self): """Return args already used in the command line rtype: command.Arg generator """ # get all arguments values from the command line values = [] for idx, c in enumerate(self.words[1:]): if c.startswith('-'): continue ...
python
def used_args(self): """Return args already used in the command line rtype: command.Arg generator """ # get all arguments values from the command line values = [] for idx, c in enumerate(self.words[1:]): if c.startswith('-'): continue ...
[ "def", "used_args", "(", "self", ")", ":", "values", "=", "[", "]", "for", "idx", ",", "c", "in", "enumerate", "(", "self", ".", "words", "[", "1", ":", "]", ")", ":", "if", "c", ".", "startswith", "(", "'-'", ")", ":", "continue", "option_str", ...
Return args already used in the command line rtype: command.Arg generator
[ "Return", "args", "already", "used", "in", "the", "command", "line" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/parser.py#L64-L94
train
eonpatapon/contrail-api-cli
contrail_api_cli/parser.py
CommandParser.available_args
def available_args(self): """Return args that can be used given the current cmd line rtype: command.Arg generator """ used = list(self.used_args) logger.debug('Found used args: %s' % used) for arg in list(self.cmd.args.values()): if (arg.is_multiple o...
python
def available_args(self): """Return args that can be used given the current cmd line rtype: command.Arg generator """ used = list(self.used_args) logger.debug('Found used args: %s' % used) for arg in list(self.cmd.args.values()): if (arg.is_multiple o...
[ "def", "available_args", "(", "self", ")", ":", "used", "=", "list", "(", "self", ".", "used_args", ")", "logger", ".", "debug", "(", "'Found used args: %s'", "%", "used", ")", "for", "arg", "in", "list", "(", "self", ".", "cmd", ".", "args", ".", "v...
Return args that can be used given the current cmd line rtype: command.Arg generator
[ "Return", "args", "that", "can", "be", "used", "given", "the", "current", "cmd", "line" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/parser.py#L97-L112
train
ph4r05/monero-serialize
monero_serialize/core/erefs.py
is_elem_ref
def is_elem_ref(elem_ref): """ Returns true if the elem_ref is an element reference :param elem_ref: :return: """ return ( elem_ref and isinstance(elem_ref, tuple) and len(elem_ref) == 3 and (elem_ref[0] == ElemRefObj or elem_ref[0] == ElemRefArr) )
python
def is_elem_ref(elem_ref): """ Returns true if the elem_ref is an element reference :param elem_ref: :return: """ return ( elem_ref and isinstance(elem_ref, tuple) and len(elem_ref) == 3 and (elem_ref[0] == ElemRefObj or elem_ref[0] == ElemRefArr) )
[ "def", "is_elem_ref", "(", "elem_ref", ")", ":", "return", "(", "elem_ref", "and", "isinstance", "(", "elem_ref", ",", "tuple", ")", "and", "len", "(", "elem_ref", ")", "==", "3", "and", "(", "elem_ref", "[", "0", "]", "==", "ElemRefObj", "or", "elem_r...
Returns true if the elem_ref is an element reference :param elem_ref: :return:
[ "Returns", "true", "if", "the", "elem_ref", "is", "an", "element", "reference" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/erefs.py#L11-L23
train
ph4r05/monero-serialize
monero_serialize/core/erefs.py
get_elem
def get_elem(elem_ref, default=None): """ Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference. :param elem_ref: :param default: :return: """ if not is_elem_ref(elem_ref): return elem_ref elif elem_ref[0] == ElemRefObj: return g...
python
def get_elem(elem_ref, default=None): """ Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference. :param elem_ref: :param default: :return: """ if not is_elem_ref(elem_ref): return elem_ref elif elem_ref[0] == ElemRefObj: return g...
[ "def", "get_elem", "(", "elem_ref", ",", "default", "=", "None", ")", ":", "if", "not", "is_elem_ref", "(", "elem_ref", ")", ":", "return", "elem_ref", "elif", "elem_ref", "[", "0", "]", "==", "ElemRefObj", ":", "return", "getattr", "(", "elem_ref", "[",...
Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference. :param elem_ref: :param default: :return:
[ "Gets", "the", "element", "referenced", "by", "elem_ref", "or", "returns", "the", "elem_ref", "directly", "if", "its", "not", "a", "reference", "." ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/erefs.py#L40-L53
train
ph4r05/monero-serialize
monero_serialize/core/erefs.py
set_elem
def set_elem(elem_ref, elem): """ Sets element referenced by the elem_ref. Returns the elem. :param elem_ref: :param elem: :return: """ if elem_ref is None or elem_ref == elem or not is_elem_ref(elem_ref): return elem elif elem_ref[0] == ElemRefObj: setattr(elem_ref[1],...
python
def set_elem(elem_ref, elem): """ Sets element referenced by the elem_ref. Returns the elem. :param elem_ref: :param elem: :return: """ if elem_ref is None or elem_ref == elem or not is_elem_ref(elem_ref): return elem elif elem_ref[0] == ElemRefObj: setattr(elem_ref[1],...
[ "def", "set_elem", "(", "elem_ref", ",", "elem", ")", ":", "if", "elem_ref", "is", "None", "or", "elem_ref", "==", "elem", "or", "not", "is_elem_ref", "(", "elem_ref", ")", ":", "return", "elem", "elif", "elem_ref", "[", "0", "]", "==", "ElemRefObj", "...
Sets element referenced by the elem_ref. Returns the elem. :param elem_ref: :param elem: :return:
[ "Sets", "element", "referenced", "by", "the", "elem_ref", ".", "Returns", "the", "elem", "." ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/erefs.py#L56-L73
train
crm416/semantic
semantic/solver.py
MathService._preprocess
def _preprocess(inp): """Revise wording to match canonical and expected forms.""" inp = re.sub(r'(\b)a(\b)', r'\g<1>one\g<2>', inp) inp = re.sub(r'to the (.*) power', r'to \g<1>', inp) inp = re.sub(r'to the (.*?)(\b)', r'to \g<1>\g<2>', inp) inp = re.sub(r'log of', r'log', inp) ...
python
def _preprocess(inp): """Revise wording to match canonical and expected forms.""" inp = re.sub(r'(\b)a(\b)', r'\g<1>one\g<2>', inp) inp = re.sub(r'to the (.*) power', r'to \g<1>', inp) inp = re.sub(r'to the (.*?)(\b)', r'to \g<1>\g<2>', inp) inp = re.sub(r'log of', r'log', inp) ...
[ "def", "_preprocess", "(", "inp", ")", ":", "inp", "=", "re", ".", "sub", "(", "r'(\\b)a(\\b)'", ",", "r'\\g<1>one\\g<2>'", ",", "inp", ")", "inp", "=", "re", ".", "sub", "(", "r'to the (.*) power'", ",", "r'to \\g<1>'", ",", "inp", ")", "inp", "=", "r...
Revise wording to match canonical and expected forms.
[ "Revise", "wording", "to", "match", "canonical", "and", "expected", "forms", "." ]
46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe
https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/solver.py#L66-L123
train
crm416/semantic
semantic/solver.py
MathService._calculate
def _calculate(numbers, symbols): """Calculates a final value given a set of numbers and symbols.""" if len(numbers) is 1: return numbers[0] precedence = [[pow], [mul, div], [add, sub]] # Find most important operation for op_group in precedence: for i, o...
python
def _calculate(numbers, symbols): """Calculates a final value given a set of numbers and symbols.""" if len(numbers) is 1: return numbers[0] precedence = [[pow], [mul, div], [add, sub]] # Find most important operation for op_group in precedence: for i, o...
[ "def", "_calculate", "(", "numbers", ",", "symbols", ")", ":", "if", "len", "(", "numbers", ")", "is", "1", ":", "return", "numbers", "[", "0", "]", "precedence", "=", "[", "[", "pow", "]", ",", "[", "mul", ",", "div", "]", ",", "[", "add", ","...
Calculates a final value given a set of numbers and symbols.
[ "Calculates", "a", "final", "value", "given", "a", "set", "of", "numbers", "and", "symbols", "." ]
46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe
https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/solver.py#L126-L144
train
crm416/semantic
semantic/solver.py
MathService.parseEquation
def parseEquation(self, inp): """Solves the equation specified by the input string. Args: inp (str): An equation, specified in words, containing some combination of numbers, binary, and unary operations. Returns: The floating-point result of carrying out...
python
def parseEquation(self, inp): """Solves the equation specified by the input string. Args: inp (str): An equation, specified in words, containing some combination of numbers, binary, and unary operations. Returns: The floating-point result of carrying out...
[ "def", "parseEquation", "(", "self", ",", "inp", ")", ":", "inp", "=", "MathService", ".", "_preprocess", "(", "inp", ")", "split", "=", "inp", ".", "split", "(", "' '", ")", "for", "i", ",", "w", "in", "enumerate", "(", "split", ")", ":", "if", ...
Solves the equation specified by the input string. Args: inp (str): An equation, specified in words, containing some combination of numbers, binary, and unary operations. Returns: The floating-point result of carrying out the computation.
[ "Solves", "the", "equation", "specified", "by", "the", "input", "string", "." ]
46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe
https://github.com/crm416/semantic/blob/46deb8fefb3ea58aad2fedc8d0d62f3ee254b8fe/semantic/solver.py#L146-L209
train
useblocks/groundwork
groundwork/patterns/gw_commands_pattern.py
CommandsListPlugin.register
def register(self, command, description, function, params=[]): """ Registers a new command for a plugin. :param command: Name of the command :param description: Description of the command. Is used as help message on cli :param function: function reference, which gets invoked if ...
python
def register(self, command, description, function, params=[]): """ Registers a new command for a plugin. :param command: Name of the command :param description: Description of the command. Is used as help message on cli :param function: function reference, which gets invoked if ...
[ "def", "register", "(", "self", ",", "command", ",", "description", ",", "function", ",", "params", "=", "[", "]", ")", ":", "return", "self", ".", "app", ".", "commands", ".", "register", "(", "command", ",", "description", ",", "function", ",", "para...
Registers a new command for a plugin. :param command: Name of the command :param description: Description of the command. Is used as help message on cli :param function: function reference, which gets invoked if command gets called. :param params: list of click options and arguments ...
[ "Registers", "a", "new", "command", "for", "a", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_commands_pattern.py#L80-L90
train
useblocks/groundwork
groundwork/patterns/gw_commands_pattern.py
CommandsListPlugin.get
def get(self, name=None): """ Returns commands, which can be filtered by name. :param name: name of the command :type name: str :return: None, single command or dict of commands """ return self.app.commands.get(name, self.plugin)
python
def get(self, name=None): """ Returns commands, which can be filtered by name. :param name: name of the command :type name: str :return: None, single command or dict of commands """ return self.app.commands.get(name, self.plugin)
[ "def", "get", "(", "self", ",", "name", "=", "None", ")", ":", "return", "self", ".", "app", ".", "commands", ".", "get", "(", "name", ",", "self", ".", "plugin", ")" ]
Returns commands, which can be filtered by name. :param name: name of the command :type name: str :return: None, single command or dict of commands
[ "Returns", "commands", "which", "can", "be", "filtered", "by", "name", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_commands_pattern.py#L101-L109
train
useblocks/groundwork
groundwork/patterns/gw_commands_pattern.py
CommandsListApplication.get
def get(self, name=None, plugin=None): """ Returns commands, which can be filtered by name or plugin. :param name: name of the command :type name: str :param plugin: plugin object, which registers the commands :type plugin: instance of GwBasePattern :return: None...
python
def get(self, name=None, plugin=None): """ Returns commands, which can be filtered by name or plugin. :param name: name of the command :type name: str :param plugin: plugin object, which registers the commands :type plugin: instance of GwBasePattern :return: None...
[ "def", "get", "(", "self", ",", "name", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "name", "is", "None", ":", "command_list", "=", "{", "}", "for", "key", "in", "self", ".", "_commands", "."...
Returns commands, which can be filtered by name or plugin. :param name: name of the command :type name: str :param plugin: plugin object, which registers the commands :type plugin: instance of GwBasePattern :return: None, single command or dict of commands
[ "Returns", "commands", "which", "can", "be", "filtered", "by", "name", "or", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_commands_pattern.py#L130-L162
train
useblocks/groundwork
groundwork/patterns/gw_commands_pattern.py
CommandsListApplication.unregister
def unregister(self, command): """ Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command """ if command not in self._comman...
python
def unregister(self, command): """ Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command """ if command not in self._comman...
[ "def", "unregister", "(", "self", ",", "command", ")", ":", "if", "command", "not", "in", "self", ".", "_commands", ".", "keys", "(", ")", ":", "self", ".", "log", ".", "warning", "(", "\"Can not unregister command %s\"", "%", "command", ")", "else", ":"...
Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command
[ "Unregisters", "an", "existing", "command", "so", "that", "this", "command", "is", "no", "longer", "available", "on", "the", "command", "line", "interface", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_commands_pattern.py#L185-L202
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_caveat.py
declared_caveat
def declared_caveat(key, value): '''Returns a "declared" caveat asserting that the given key is set to the given value. If a macaroon has exactly one first party caveat asserting the value of a particular key, then infer_declared will be able to infer the value, and then the check will allow the de...
python
def declared_caveat(key, value): '''Returns a "declared" caveat asserting that the given key is set to the given value. If a macaroon has exactly one first party caveat asserting the value of a particular key, then infer_declared will be able to infer the value, and then the check will allow the de...
[ "def", "declared_caveat", "(", "key", ",", "value", ")", ":", "if", "key", ".", "find", "(", "' '", ")", ">=", "0", "or", "key", "==", "''", ":", "return", "error_caveat", "(", "'invalid caveat \\'declared\\' key \"{}\"'", ".", "format", "(", "key", ")", ...
Returns a "declared" caveat asserting that the given key is set to the given value. If a macaroon has exactly one first party caveat asserting the value of a particular key, then infer_declared will be able to infer the value, and then the check will allow the declared value if it has the value spe...
[ "Returns", "a", "declared", "caveat", "asserting", "that", "the", "given", "key", "is", "set", "to", "the", "given", "value", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_caveat.py#L33-L46
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_caveat.py
_operation_caveat
def _operation_caveat(cond, ops): ''' Helper for allow_caveat and deny_caveat. It checks that all operation names are valid before creating the caveat. ''' for op in ops: if op.find(' ') != -1: return error_caveat('invalid operation name "{}"'.format(op)) return _first_party(con...
python
def _operation_caveat(cond, ops): ''' Helper for allow_caveat and deny_caveat. It checks that all operation names are valid before creating the caveat. ''' for op in ops: if op.find(' ') != -1: return error_caveat('invalid operation name "{}"'.format(op)) return _first_party(con...
[ "def", "_operation_caveat", "(", "cond", ",", "ops", ")", ":", "for", "op", "in", "ops", ":", "if", "op", ".", "find", "(", "' '", ")", "!=", "-", "1", ":", "return", "error_caveat", "(", "'invalid operation name \"{}\"'", ".", "format", "(", "op", ")"...
Helper for allow_caveat and deny_caveat. It checks that all operation names are valid before creating the caveat.
[ "Helper", "for", "allow_caveat", "and", "deny_caveat", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_caveat.py#L81-L89
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/_utils/__init__.py
to_bytes
def to_bytes(s): '''Return s as a bytes type, using utf-8 encoding if necessary. @param s string or bytes @return bytes ''' if isinstance(s, six.binary_type): return s if isinstance(s, six.string_types): return s.encode('utf-8') raise TypeError('want string or bytes, got {}',...
python
def to_bytes(s): '''Return s as a bytes type, using utf-8 encoding if necessary. @param s string or bytes @return bytes ''' if isinstance(s, six.binary_type): return s if isinstance(s, six.string_types): return s.encode('utf-8') raise TypeError('want string or bytes, got {}',...
[ "def", "to_bytes", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "binary_type", ")", ":", "return", "s", "if", "isinstance", "(", "s", ",", "six", ".", "string_types", ")", ":", "return", "s", ".", "encode", "(", "'utf-8'", ")"...
Return s as a bytes type, using utf-8 encoding if necessary. @param s string or bytes @return bytes
[ "Return", "s", "as", "a", "bytes", "type", "using", "utf", "-", "8", "encoding", "if", "necessary", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/_utils/__init__.py#L18-L27
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/_utils/__init__.py
b64decode
def b64decode(s): '''Base64 decodes a base64-encoded string in URL-safe or normal format, with or without padding. The argument may be string or bytes. @param s bytes decode @return bytes decoded @raises ValueError on failure ''' # add padding if necessary. s = to_bytes(s) if no...
python
def b64decode(s): '''Base64 decodes a base64-encoded string in URL-safe or normal format, with or without padding. The argument may be string or bytes. @param s bytes decode @return bytes decoded @raises ValueError on failure ''' # add padding if necessary. s = to_bytes(s) if no...
[ "def", "b64decode", "(", "s", ")", ":", "s", "=", "to_bytes", "(", "s", ")", "if", "not", "s", ".", "endswith", "(", "b'='", ")", ":", "s", "=", "s", "+", "b'='", "*", "(", "-", "len", "(", "s", ")", "%", "4", ")", "try", ":", "if", "'_'"...
Base64 decodes a base64-encoded string in URL-safe or normal format, with or without padding. The argument may be string or bytes. @param s bytes decode @return bytes decoded @raises ValueError on failure
[ "Base64", "decodes", "a", "base64", "-", "encoded", "string", "in", "URL", "-", "safe", "or", "normal", "format", "with", "or", "without", "padding", ".", "The", "argument", "may", "be", "string", "or", "bytes", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/_utils/__init__.py#L79-L98
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/_utils/__init__.py
raw_urlsafe_b64encode
def raw_urlsafe_b64encode(b): '''Base64 encode using URL-safe encoding with padding removed. @param b bytes to decode @return bytes decoded ''' b = to_bytes(b) b = base64.urlsafe_b64encode(b) b = b.rstrip(b'=') # strip padding return b
python
def raw_urlsafe_b64encode(b): '''Base64 encode using URL-safe encoding with padding removed. @param b bytes to decode @return bytes decoded ''' b = to_bytes(b) b = base64.urlsafe_b64encode(b) b = b.rstrip(b'=') # strip padding return b
[ "def", "raw_urlsafe_b64encode", "(", "b", ")", ":", "b", "=", "to_bytes", "(", "b", ")", "b", "=", "base64", ".", "urlsafe_b64encode", "(", "b", ")", "b", "=", "b", ".", "rstrip", "(", "b'='", ")", "return", "b" ]
Base64 encode using URL-safe encoding with padding removed. @param b bytes to decode @return bytes decoded
[ "Base64", "encode", "using", "URL", "-", "safe", "encoding", "with", "padding", "removed", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/_utils/__init__.py#L101-L110
train
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/_utils/__init__.py
cookie
def cookie( url, name, value, expires=None): '''Return a new Cookie using a slightly more friendly API than that provided by six.moves.http_cookiejar @param name The cookie name {str} @param value The cookie value {str} @param url The URL path of the cookie {str} ...
python
def cookie( url, name, value, expires=None): '''Return a new Cookie using a slightly more friendly API than that provided by six.moves.http_cookiejar @param name The cookie name {str} @param value The cookie value {str} @param url The URL path of the cookie {str} ...
[ "def", "cookie", "(", "url", ",", "name", ",", "value", ",", "expires", "=", "None", ")", ":", "u", "=", "urlparse", "(", "url", ")", "domain", "=", "u", ".", "hostname", "if", "'.'", "not", "in", "domain", "and", "not", "_is_ip_addr", "(", "domain...
Return a new Cookie using a slightly more friendly API than that provided by six.moves.http_cookiejar @param name The cookie name {str} @param value The cookie value {str} @param url The URL path of the cookie {str} @param expires The expiry time of the cookie {datetime}. If provided, it mu...
[ "Return", "a", "new", "Cookie", "using", "a", "slightly", "more", "friendly", "API", "than", "that", "provided", "by", "six", ".", "moves", ".", "http_cookiejar" ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/_utils/__init__.py#L123-L165
train
swevm/scaleio-py
scaleiopy/im.py
Im._login
def _login(self): """ LOGIN CAN ONLY BE DONE BY POSTING TO A HTTP FORM. A COOKIE IS THEN USED FOR INTERACTING WITH THE API """ self.logger.debug("Logging into " + "{}/{}".format(self._im_api_url, "j_spring_security_check")) self._im_session.headers.update({'Content-Type':...
python
def _login(self): """ LOGIN CAN ONLY BE DONE BY POSTING TO A HTTP FORM. A COOKIE IS THEN USED FOR INTERACTING WITH THE API """ self.logger.debug("Logging into " + "{}/{}".format(self._im_api_url, "j_spring_security_check")) self._im_session.headers.update({'Content-Type':...
[ "def", "_login", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Logging into \"", "+", "\"{}/{}\"", ".", "format", "(", "self", ".", "_im_api_url", ",", "\"j_spring_security_check\"", ")", ")", "self", ".", "_im_session", ".", "headers",...
LOGIN CAN ONLY BE DONE BY POSTING TO A HTTP FORM. A COOKIE IS THEN USED FOR INTERACTING WITH THE API
[ "LOGIN", "CAN", "ONLY", "BE", "DONE", "BY", "POSTING", "TO", "A", "HTTP", "FORM", ".", "A", "COOKIE", "IS", "THEN", "USED", "FOR", "INTERACTING", "WITH", "THE", "API" ]
d043a0137cb925987fd5c895a3210968ce1d9028
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/im.py#L107-L134
train
swevm/scaleio-py
scaleiopy/im.py
Im._do_get
def _do_get(self, uri, **kwargs): """ Convinient method for GET requests Returns http request status value from a POST request """ #TODO: # Add error handling. Check for HTTP status here would be much more conveinent than in each calling method scaleioapi_get_head...
python
def _do_get(self, uri, **kwargs): """ Convinient method for GET requests Returns http request status value from a POST request """ #TODO: # Add error handling. Check for HTTP status here would be much more conveinent than in each calling method scaleioapi_get_head...
[ "def", "_do_get", "(", "self", ",", "uri", ",", "**", "kwargs", ")", ":", "scaleioapi_get_headers", "=", "{", "'Content-type'", ":", "'application/json'", ",", "'Version'", ":", "'1.0'", "}", "self", ".", "logger", ".", "debug", "(", "\"_do_get() \"", "+", ...
Convinient method for GET requests Returns http request status value from a POST request
[ "Convinient", "method", "for", "GET", "requests", "Returns", "http", "request", "status", "value", "from", "a", "POST", "request" ]
d043a0137cb925987fd5c895a3210968ce1d9028
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/im.py#L144-L169
train
swevm/scaleio-py
scaleiopy/im.py
Im.uploadFileToIM
def uploadFileToIM (self, directory, filename, title): """ Parameters as they look in the form for uploading packages to IM """ self.logger.debug("uploadFileToIM(" + "{},{},{})".format(directory, filename, title)) parameters = {'data-filename-placement':'inside', ...
python
def uploadFileToIM (self, directory, filename, title): """ Parameters as they look in the form for uploading packages to IM """ self.logger.debug("uploadFileToIM(" + "{},{},{})".format(directory, filename, title)) parameters = {'data-filename-placement':'inside', ...
[ "def", "uploadFileToIM", "(", "self", ",", "directory", ",", "filename", ",", "title", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"uploadFileToIM(\"", "+", "\"{},{},{})\"", ".", "format", "(", "directory", ",", "filename", ",", "title", ")", ")"...
Parameters as they look in the form for uploading packages to IM
[ "Parameters", "as", "they", "look", "in", "the", "form", "for", "uploading", "packages", "to", "IM" ]
d043a0137cb925987fd5c895a3210968ce1d9028
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/im.py#L670-L702
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
dump_varint_t
async def dump_varint_t(writer, type_or, pv): """ Binary dump of the integer of given type :param writer: :param type_or: :param pv: :return: """ width = int_mark_to_size(type_or) n = (pv << 2) | type_or buffer = _UINT_BUFFER for _ in range(width): buffer[0] = n & 0...
python
async def dump_varint_t(writer, type_or, pv): """ Binary dump of the integer of given type :param writer: :param type_or: :param pv: :return: """ width = int_mark_to_size(type_or) n = (pv << 2) | type_or buffer = _UINT_BUFFER for _ in range(width): buffer[0] = n & 0...
[ "async", "def", "dump_varint_t", "(", "writer", ",", "type_or", ",", "pv", ")", ":", "width", "=", "int_mark_to_size", "(", "type_or", ")", "n", "=", "(", "pv", "<<", "2", ")", "|", "type_or", "buffer", "=", "_UINT_BUFFER", "for", "_", "in", "range", ...
Binary dump of the integer of given type :param writer: :param type_or: :param pv: :return:
[ "Binary", "dump", "of", "the", "integer", "of", "given", "type" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L210-L228
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
dump_varint
async def dump_varint(writer, val): """ Binary dump of the variable size integer :param writer: :param val: :return: """ if val <= 63: return await dump_varint_t(writer, PortableRawSizeMark.BYTE, val) elif val <= 16383: return await dump_varint_t(writer, PortableRawSizeM...
python
async def dump_varint(writer, val): """ Binary dump of the variable size integer :param writer: :param val: :return: """ if val <= 63: return await dump_varint_t(writer, PortableRawSizeMark.BYTE, val) elif val <= 16383: return await dump_varint_t(writer, PortableRawSizeM...
[ "async", "def", "dump_varint", "(", "writer", ",", "val", ")", ":", "if", "val", "<=", "63", ":", "return", "await", "dump_varint_t", "(", "writer", ",", "PortableRawSizeMark", ".", "BYTE", ",", "val", ")", "elif", "val", "<=", "16383", ":", "return", ...
Binary dump of the variable size integer :param writer: :param val: :return:
[ "Binary", "dump", "of", "the", "variable", "size", "integer" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L231-L248
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
load_varint
async def load_varint(reader): """ Binary load of variable size integer serialized by dump_varint :param reader: :return: """ buffer = _UINT_BUFFER await reader.areadinto(buffer) width = int_mark_to_size(buffer[0] & PortableRawSizeMark.MASK) result = buffer[0] shift = 8 fo...
python
async def load_varint(reader): """ Binary load of variable size integer serialized by dump_varint :param reader: :return: """ buffer = _UINT_BUFFER await reader.areadinto(buffer) width = int_mark_to_size(buffer[0] & PortableRawSizeMark.MASK) result = buffer[0] shift = 8 fo...
[ "async", "def", "load_varint", "(", "reader", ")", ":", "buffer", "=", "_UINT_BUFFER", "await", "reader", ".", "areadinto", "(", "buffer", ")", "width", "=", "int_mark_to_size", "(", "buffer", "[", "0", "]", "&", "PortableRawSizeMark", ".", "MASK", ")", "r...
Binary load of variable size integer serialized by dump_varint :param reader: :return:
[ "Binary", "load", "of", "variable", "size", "integer", "serialized", "by", "dump_varint" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L251-L269
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
dump_string
async def dump_string(writer, val): """ Binary string dump :param writer: :param val: :return: """ await dump_varint(writer, len(val)) await writer.awrite(val)
python
async def dump_string(writer, val): """ Binary string dump :param writer: :param val: :return: """ await dump_varint(writer, len(val)) await writer.awrite(val)
[ "async", "def", "dump_string", "(", "writer", ",", "val", ")", ":", "await", "dump_varint", "(", "writer", ",", "len", "(", "val", ")", ")", "await", "writer", ".", "awrite", "(", "val", ")" ]
Binary string dump :param writer: :param val: :return:
[ "Binary", "string", "dump" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L272-L281
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
load_string
async def load_string(reader): """ Loads string from binary stream :param reader: :return: """ ivalue = await load_varint(reader) fvalue = bytearray(ivalue) await reader.areadinto(fvalue) return bytes(fvalue)
python
async def load_string(reader): """ Loads string from binary stream :param reader: :return: """ ivalue = await load_varint(reader) fvalue = bytearray(ivalue) await reader.areadinto(fvalue) return bytes(fvalue)
[ "async", "def", "load_string", "(", "reader", ")", ":", "ivalue", "=", "await", "load_varint", "(", "reader", ")", "fvalue", "=", "bytearray", "(", "ivalue", ")", "await", "reader", ".", "areadinto", "(", "fvalue", ")", "return", "bytes", "(", "fvalue", ...
Loads string from binary stream :param reader: :return:
[ "Loads", "string", "from", "binary", "stream" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L284-L294
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
dump_blob
async def dump_blob(writer, elem, elem_type, params=None): """ Dumps blob to a binary stream :param writer: :param elem: :param elem_type: :param params: :return: """ elem_is_blob = isinstance(elem, x.BlobType) data = bytes(getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob els...
python
async def dump_blob(writer, elem, elem_type, params=None): """ Dumps blob to a binary stream :param writer: :param elem: :param elem_type: :param params: :return: """ elem_is_blob = isinstance(elem, x.BlobType) data = bytes(getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob els...
[ "async", "def", "dump_blob", "(", "writer", ",", "elem", ",", "elem_type", ",", "params", "=", "None", ")", ":", "elem_is_blob", "=", "isinstance", "(", "elem", ",", "x", ".", "BlobType", ")", "data", "=", "bytes", "(", "getattr", "(", "elem", ",", "...
Dumps blob to a binary stream :param writer: :param elem: :param elem_type: :param params: :return:
[ "Dumps", "blob", "to", "a", "binary", "stream" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L297-L310
train
ph4r05/monero-serialize
monero_serialize/xmrrpc.py
Blobber.container_load
async def container_load(self, container_type, params=None, container=None, obj=None): """ Loads container of elements from the reader. Supports the container ref. Returns loaded container. Blob array writer as in XMRRPC is serialized without size serialization. :param container...
python
async def container_load(self, container_type, params=None, container=None, obj=None): """ Loads container of elements from the reader. Supports the container ref. Returns loaded container. Blob array writer as in XMRRPC is serialized without size serialization. :param container...
[ "async", "def", "container_load", "(", "self", ",", "container_type", ",", "params", "=", "None", ",", "container", "=", "None", ",", "obj", "=", "None", ")", ":", "elem_type", "=", "x", ".", "container_elem_type", "(", "container_type", ",", "params", ")"...
Loads container of elements from the reader. Supports the container ref. Returns loaded container. Blob array writer as in XMRRPC is serialized without size serialization. :param container_type: :param params: :param container: :param obj: :return:
[ "Loads", "container", "of", "elements", "from", "the", "reader", ".", "Supports", "the", "container", "ref", ".", "Returns", "loaded", "container", ".", "Blob", "array", "writer", "as", "in", "XMRRPC", "is", "serialized", "without", "size", "serialization", "....
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrrpc.py#L682-L721
train
jenisys/parse_type
bin/make_localpi.py
make_index_for
def make_index_for(package, index_dir, verbose=True): """ Create an 'index.html' for one package. :param package: Package object to use. :param index_dir: Where 'index.html' should be created. """ index_template = """\ <html> <head><title>{title}</title></head> <body> <h1>{title}</h1> <ul> {p...
python
def make_index_for(package, index_dir, verbose=True): """ Create an 'index.html' for one package. :param package: Package object to use. :param index_dir: Where 'index.html' should be created. """ index_template = """\ <html> <head><title>{title}</title></head> <body> <h1>{title}</h1> <ul> {p...
[ "def", "make_index_for", "(", "package", ",", "index_dir", ",", "verbose", "=", "True", ")", ":", "index_template", "=", "item_template", "=", "'<li><a href=\"{1}\">{0}</a></li>'", "index_filename", "=", "os", ".", "path", ".", "join", "(", "index_dir", ",", "\"...
Create an 'index.html' for one package. :param package: Package object to use. :param index_dir: Where 'index.html' should be created.
[ "Create", "an", "index", ".", "html", "for", "one", "package", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/make_localpi.py#L118-L170
train
jenisys/parse_type
bin/make_localpi.py
make_package_index
def make_package_index(download_dir): """ Create a pypi server like file structure below download directory. :param download_dir: Download directory with packages. EXAMPLE BEFORE: +-- downloads/ +-- alice-1.0.zip +-- alice-1.0.tar.gz +-- bob-1.3.0.tar.gz ...
python
def make_package_index(download_dir): """ Create a pypi server like file structure below download directory. :param download_dir: Download directory with packages. EXAMPLE BEFORE: +-- downloads/ +-- alice-1.0.zip +-- alice-1.0.tar.gz +-- bob-1.3.0.tar.gz ...
[ "def", "make_package_index", "(", "download_dir", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "download_dir", ")", ":", "raise", "ValueError", "(", "\"No such directory: %r\"", "%", "download_dir", ")", "pkg_rootdir", "=", "os", ".", "path", ...
Create a pypi server like file structure below download directory. :param download_dir: Download directory with packages. EXAMPLE BEFORE: +-- downloads/ +-- alice-1.0.zip +-- alice-1.0.tar.gz +-- bob-1.3.0.tar.gz +-- bob-1.4.2.tar.gz +-- charly-1...
[ "Create", "a", "pypi", "server", "like", "file", "structure", "below", "download", "directory", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/bin/make_localpi.py#L173-L233
train
dbarsam/python-vsgen
vsgen/util/config.py
VSGConfigParser._convert_to_list
def _convert_to_list(self, value, delimiters): """ Return a list value translating from other types if necessary. :param str value: The value to convert. """ if not value: return [] if delimiters: return [l.strip() for l in value.split(delimiters...
python
def _convert_to_list(self, value, delimiters): """ Return a list value translating from other types if necessary. :param str value: The value to convert. """ if not value: return [] if delimiters: return [l.strip() for l in value.split(delimiters...
[ "def", "_convert_to_list", "(", "self", ",", "value", ",", "delimiters", ")", ":", "if", "not", "value", ":", "return", "[", "]", "if", "delimiters", ":", "return", "[", "l", ".", "strip", "(", ")", "for", "l", "in", "value", ".", "split", "(", "de...
Return a list value translating from other types if necessary. :param str value: The value to convert.
[ "Return", "a", "list", "value", "translating", "from", "other", "types", "if", "necessary", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L30-L40
train
dbarsam/python-vsgen
vsgen/util/config.py
VSGConfigParser.getlist
def getlist(self, section, option, raw=False, vars=None, fallback=[], delimiters=','): """ A convenience method which coerces the option in the specified section to a list of strings. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) return self._convert_to...
python
def getlist(self, section, option, raw=False, vars=None, fallback=[], delimiters=','): """ A convenience method which coerces the option in the specified section to a list of strings. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) return self._convert_to...
[ "def", "getlist", "(", "self", ",", "section", ",", "option", ",", "raw", "=", "False", ",", "vars", "=", "None", ",", "fallback", "=", "[", "]", ",", "delimiters", "=", "','", ")", ":", "v", "=", "self", ".", "get", "(", "section", ",", "option"...
A convenience method which coerces the option in the specified section to a list of strings.
[ "A", "convenience", "method", "which", "coerces", "the", "option", "in", "the", "specified", "section", "to", "a", "list", "of", "strings", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L50-L55
train
dbarsam/python-vsgen
vsgen/util/config.py
VSGConfigParser.getfile
def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False): """ A convenience method which coerces the option in the specified section to a file. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) v = self._convert_to_path(v) ...
python
def getfile(self, section, option, raw=False, vars=None, fallback="", validate=False): """ A convenience method which coerces the option in the specified section to a file. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) v = self._convert_to_path(v) ...
[ "def", "getfile", "(", "self", ",", "section", ",", "option", ",", "raw", "=", "False", ",", "vars", "=", "None", ",", "fallback", "=", "\"\"", ",", "validate", "=", "False", ")", ":", "v", "=", "self", ".", "get", "(", "section", ",", "option", ...
A convenience method which coerces the option in the specified section to a file.
[ "A", "convenience", "method", "which", "coerces", "the", "option", "in", "the", "specified", "section", "to", "a", "file", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L57-L63
train
dbarsam/python-vsgen
vsgen/util/config.py
VSGConfigParser.getdir
def getdir(self, section, option, raw=False, vars=None, fallback="", validate=False): """ A convenience method which coerces the option in the specified section to a directory. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) v = self._convert_to_path(v) ...
python
def getdir(self, section, option, raw=False, vars=None, fallback="", validate=False): """ A convenience method which coerces the option in the specified section to a directory. """ v = self.get(section, option, raw=raw, vars=vars, fallback=fallback) v = self._convert_to_path(v) ...
[ "def", "getdir", "(", "self", ",", "section", ",", "option", ",", "raw", "=", "False", ",", "vars", "=", "None", ",", "fallback", "=", "\"\"", ",", "validate", "=", "False", ")", ":", "v", "=", "self", ".", "get", "(", "section", ",", "option", "...
A convenience method which coerces the option in the specified section to a directory.
[ "A", "convenience", "method", "which", "coerces", "the", "option", "in", "the", "specified", "section", "to", "a", "directory", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L65-L71
train
dbarsam/python-vsgen
vsgen/util/config.py
VSGConfigParser.getdirs
def getdirs(self, section, option, raw=False, vars=None, fallback=[]): """ A convenience method which coerces the option in the specified section to a list of directories. """ globs = self.getlist(section, option, fallback=[]) return [f for g in globs for f in glob.glob(g) if os....
python
def getdirs(self, section, option, raw=False, vars=None, fallback=[]): """ A convenience method which coerces the option in the specified section to a list of directories. """ globs = self.getlist(section, option, fallback=[]) return [f for g in globs for f in glob.glob(g) if os....
[ "def", "getdirs", "(", "self", ",", "section", ",", "option", ",", "raw", "=", "False", ",", "vars", "=", "None", ",", "fallback", "=", "[", "]", ")", ":", "globs", "=", "self", ".", "getlist", "(", "section", ",", "option", ",", "fallback", "=", ...
A convenience method which coerces the option in the specified section to a list of directories.
[ "A", "convenience", "method", "which", "coerces", "the", "option", "in", "the", "specified", "section", "to", "a", "list", "of", "directories", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/config.py#L73-L78
train
useblocks/groundwork
groundwork/patterns/gw_documents_pattern.py
DocumentsListPlugin.register
def register(self, name, content, description=None): """ Register a new document. :param content: Content of this document. Jinja and rst are supported. :type content: str :param name: Unique name of the document for documentation purposes. :param description: Short desc...
python
def register(self, name, content, description=None): """ Register a new document. :param content: Content of this document. Jinja and rst are supported. :type content: str :param name: Unique name of the document for documentation purposes. :param description: Short desc...
[ "def", "register", "(", "self", ",", "name", ",", "content", ",", "description", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "documents", ".", "register", "(", "name", ",", "content", ",", "self", ".", "_plugin", ",", "description", ")"...
Register a new document. :param content: Content of this document. Jinja and rst are supported. :type content: str :param name: Unique name of the document for documentation purposes. :param description: Short description of this document
[ "Register", "a", "new", "document", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L66-L75
train
useblocks/groundwork
groundwork/patterns/gw_documents_pattern.py
DocumentsListApplication.unregister
def unregister(self, document): """ Unregisters an existing document, so that this document is no longer available. This function is mainly used during plugin deactivation. :param document: Name of the document """ if document not in self.documents.keys(): s...
python
def unregister(self, document): """ Unregisters an existing document, so that this document is no longer available. This function is mainly used during plugin deactivation. :param document: Name of the document """ if document not in self.documents.keys(): s...
[ "def", "unregister", "(", "self", ",", "document", ")", ":", "if", "document", "not", "in", "self", ".", "documents", ".", "keys", "(", ")", ":", "self", ".", "log", ".", "warning", "(", "\"Can not unregister document %s\"", "%", "document", ")", "else", ...
Unregisters an existing document, so that this document is no longer available. This function is mainly used during plugin deactivation. :param document: Name of the document
[ "Unregisters", "an", "existing", "document", "so", "that", "this", "document", "is", "no", "longer", "available", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L116-L128
train
useblocks/groundwork
groundwork/patterns/gw_documents_pattern.py
DocumentsListApplication.get
def get(self, document=None, plugin=None): """ Get one or more documents. :param document: Name of the document :type document: str :param plugin: Plugin object, under which the document was registered :type plugin: GwBasePattern """ if plugin is not None...
python
def get(self, document=None, plugin=None): """ Get one or more documents. :param document: Name of the document :type document: str :param plugin: Plugin object, under which the document was registered :type plugin: GwBasePattern """ if plugin is not None...
[ "def", "get", "(", "self", ",", "document", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "document", "is", "None", ":", "documents_list", "=", "{", "}", "for", "key", "in", "self", ".", "documen...
Get one or more documents. :param document: Name of the document :type document: str :param plugin: Plugin object, under which the document was registered :type plugin: GwBasePattern
[ "Get", "one", "or", "more", "documents", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_documents_pattern.py#L130-L161
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginManager.initialise_by_names
def initialise_by_names(self, plugins=None): """ Initialises given plugins, but does not activate them. This is needed to import and configure libraries, which are imported by used patterns, like GwFlask. After this action, all needed python modules are imported and configured. ...
python
def initialise_by_names(self, plugins=None): """ Initialises given plugins, but does not activate them. This is needed to import and configure libraries, which are imported by used patterns, like GwFlask. After this action, all needed python modules are imported and configured. ...
[ "def", "initialise_by_names", "(", "self", ",", "plugins", "=", "None", ")", ":", "if", "plugins", "is", "None", ":", "plugins", "=", "[", "]", "self", ".", "_log", ".", "debug", "(", "\"Plugins Initialisation started\"", ")", "if", "not", "isinstance", "(...
Initialises given plugins, but does not activate them. This is needed to import and configure libraries, which are imported by used patterns, like GwFlask. After this action, all needed python modules are imported and configured. Also the groundwork application object is ready and contains fun...
[ "Initialises", "given", "plugins", "but", "does", "not", "activate", "them", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L46-L79
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginManager.activate
def activate(self, plugins=[]): """ Activates given plugins. This calls mainly plugin.activate() and plugins register needed resources like commands, signals or documents. If given plugins have not been initialised, this is also done via :func:`_load`. :param plugins: ...
python
def activate(self, plugins=[]): """ Activates given plugins. This calls mainly plugin.activate() and plugins register needed resources like commands, signals or documents. If given plugins have not been initialised, this is also done via :func:`_load`. :param plugins: ...
[ "def", "activate", "(", "self", ",", "plugins", "=", "[", "]", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"Plugins Activation started\"", ")", "if", "not", "isinstance", "(", "plugins", ",", "list", ")", ":", "raise", "AttributeError", "(", "\"p...
Activates given plugins. This calls mainly plugin.activate() and plugins register needed resources like commands, signals or documents. If given plugins have not been initialised, this is also done via :func:`_load`. :param plugins: List of plugin names :type plugins: list of ...
[ "Activates", "given", "plugins", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L129-L183
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginManager.deactivate
def deactivate(self, plugins=[]): """ Deactivates given plugins. A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired, no deactivate functions are called.) A deactivated plugin is still loaded and initialised and can be react...
python
def deactivate(self, plugins=[]): """ Deactivates given plugins. A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired, no deactivate functions are called.) A deactivated plugin is still loaded and initialised and can be react...
[ "def", "deactivate", "(", "self", ",", "plugins", "=", "[", "]", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"Plugins Deactivation started\"", ")", "if", "not", "isinstance", "(", "plugins", ",", "list", ")", ":", "raise", "AttributeError", "(", ...
Deactivates given plugins. A given plugin must be activated, otherwise it is ignored and no action takes place (no signals are fired, no deactivate functions are called.) A deactivated plugin is still loaded and initialised and can be reactivated by calling :func:`activate` again. It i...
[ "Deactivates", "given", "plugins", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L185-L227
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginManager.get
def get(self, name=None): """ Returns the plugin object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins """ if name is None: ...
python
def get(self, name=None): """ Returns the plugin object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins """ if name is None: ...
[ "def", "get", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "return", "self", ".", "_plugins", "else", ":", "if", "name", "not", "in", "self", ".", "_plugins", ".", "keys", "(", ")", ":", "return", "None", "els...
Returns the plugin object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins
[ "Returns", "the", "plugin", "object", "with", "the", "given", "name", ".", "Or", "if", "a", "name", "is", "not", "given", "the", "complete", "plugin", "dictionary", "is", "returned", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L229-L243
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginManager.is_active
def is_active(self, name): """ Returns True if plugin exists and is active. If plugin does not exist, it returns None :param name: plugin name :return: boolean or None """ if name in self._plugins.keys(): return self._plugins["name"].active re...
python
def is_active(self, name): """ Returns True if plugin exists and is active. If plugin does not exist, it returns None :param name: plugin name :return: boolean or None """ if name in self._plugins.keys(): return self._plugins["name"].active re...
[ "def", "is_active", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_plugins", ".", "keys", "(", ")", ":", "return", "self", ".", "_plugins", "[", "\"name\"", "]", ".", "active", "return", "None" ]
Returns True if plugin exists and is active. If plugin does not exist, it returns None :param name: plugin name :return: boolean or None
[ "Returns", "True", "if", "plugin", "exists", "and", "is", "active", ".", "If", "plugin", "does", "not", "exist", "it", "returns", "None" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L255-L265
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginClassManager.register
def register(self, classes=[]): """ Registers new plugins. The registration only creates a new entry for a plugin inside the _classes dictionary. It does not activate or even initialise the plugin. A plugin must be a class, which inherits directly or indirectly from GwBasePatte...
python
def register(self, classes=[]): """ Registers new plugins. The registration only creates a new entry for a plugin inside the _classes dictionary. It does not activate or even initialise the plugin. A plugin must be a class, which inherits directly or indirectly from GwBasePatte...
[ "def", "register", "(", "self", ",", "classes", "=", "[", "]", ")", ":", "if", "not", "isinstance", "(", "classes", ",", "list", ")", ":", "raise", "AttributeError", "(", "\"plugins must be a list, not %s.\"", "%", "type", "(", "classes", ")", ")", "plugin...
Registers new plugins. The registration only creates a new entry for a plugin inside the _classes dictionary. It does not activate or even initialise the plugin. A plugin must be a class, which inherits directly or indirectly from GwBasePattern. :param classes: List of plugin classes ...
[ "Registers", "new", "plugins", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L331-L354
train
useblocks/groundwork
groundwork/pluginmanager.py
PluginClassManager.get
def get(self, name=None): """ Returns the plugin class object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins """ if name is None: ...
python
def get(self, name=None): """ Returns the plugin class object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins """ if name is None: ...
[ "def", "get", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "return", "self", ".", "_classes", "else", ":", "if", "name", "not", "in", "self", ".", "_classes", ".", "keys", "(", ")", ":", "return", "None", "els...
Returns the plugin class object with the given name. Or if a name is not given, the complete plugin dictionary is returned. :param name: Name of a plugin :return: None, single plugin or dictionary of plugins
[ "Returns", "the", "plugin", "class", "object", "with", "the", "given", "name", ".", "Or", "if", "a", "name", "is", "not", "given", "the", "complete", "plugin", "dictionary", "is", "returned", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/pluginmanager.py#L390-L404
train
dbarsam/python-vsgen
vsgen/solution.py
VSGSolution.write
def write(self): """ Writes the ``.sln`` file to disk. """ filters = { 'MSGUID': lambda x: ('{%s}' % x).upper(), 'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName)) } context = { 'sln': self } retu...
python
def write(self): """ Writes the ``.sln`` file to disk. """ filters = { 'MSGUID': lambda x: ('{%s}' % x).upper(), 'relslnfile': lambda x: os.path.relpath(x, os.path.dirname(self.FileName)) } context = { 'sln': self } retu...
[ "def", "write", "(", "self", ")", ":", "filters", "=", "{", "'MSGUID'", ":", "lambda", "x", ":", "(", "'{%s}'", "%", "x", ")", ".", "upper", "(", ")", ",", "'relslnfile'", ":", "lambda", "x", ":", "os", ".", "path", ".", "relpath", "(", "x", ",...
Writes the ``.sln`` file to disk.
[ "Writes", "the", ".", "sln", "file", "to", "disk", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/solution.py#L49-L60
train
atarashansky/self-assembling-manifold
SAM.py
SAM.load_annotations
def load_annotations(self, aname, sep=','): """Loads cell annotations. Loads the cell annoations specified by the 'aname' path. Parameters ---------- aname - string The path to the annotations file. First column should be cell IDs and second column shoul...
python
def load_annotations(self, aname, sep=','): """Loads cell annotations. Loads the cell annoations specified by the 'aname' path. Parameters ---------- aname - string The path to the annotations file. First column should be cell IDs and second column shoul...
[ "def", "load_annotations", "(", "self", ",", "aname", ",", "sep", "=", "','", ")", ":", "ann", "=", "pd", ".", "read_csv", "(", "aname", ")", "cell_names", "=", "np", ".", "array", "(", "list", "(", "self", ".", "adata", ".", "obs_names", ")", ")",...
Loads cell annotations. Loads the cell annoations specified by the 'aname' path. Parameters ---------- aname - string The path to the annotations file. First column should be cell IDs and second column should be the desired annotations.
[ "Loads", "cell", "annotations", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L460-L489
train
atarashansky/self-assembling-manifold
SAM.py
SAM.dispersion_ranking_NN
def dispersion_ranking_NN(self, nnm, num_norm_avg=50): """Computes the spatial dispersion factors for each gene. Parameters ---------- nnm - scipy.sparse, float Square cell-to-cell nearest-neighbor matrix. num_norm_avg - int, optional, default 50 The top...
python
def dispersion_ranking_NN(self, nnm, num_norm_avg=50): """Computes the spatial dispersion factors for each gene. Parameters ---------- nnm - scipy.sparse, float Square cell-to-cell nearest-neighbor matrix. num_norm_avg - int, optional, default 50 The top...
[ "def", "dispersion_ranking_NN", "(", "self", ",", "nnm", ",", "num_norm_avg", "=", "50", ")", ":", "self", ".", "knn_avg", "(", "nnm", ")", "D_avg", "=", "self", ".", "adata", ".", "layers", "[", "'X_knn_avg'", "]", "mu", ",", "var", "=", "sf", ".", ...
Computes the spatial dispersion factors for each gene. Parameters ---------- nnm - scipy.sparse, float Square cell-to-cell nearest-neighbor matrix. num_norm_avg - int, optional, default 50 The top 'num_norm_avg' dispersions are averaged to determine the ...
[ "Computes", "the", "spatial", "dispersion", "factors", "for", "each", "gene", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L491-L532
train
atarashansky/self-assembling-manifold
SAM.py
SAM.plot_correlated_groups
def plot_correlated_groups(self, group=None, n_genes=5, **kwargs): """Plots orthogonal expression patterns. In the default mode, plots orthogonal gene expression patterns. A specific correlated group of genes can be specified to plot gene expression patterns within that group. ...
python
def plot_correlated_groups(self, group=None, n_genes=5, **kwargs): """Plots orthogonal expression patterns. In the default mode, plots orthogonal gene expression patterns. A specific correlated group of genes can be specified to plot gene expression patterns within that group. ...
[ "def", "plot_correlated_groups", "(", "self", ",", "group", "=", "None", ",", "n_genes", "=", "5", ",", "**", "kwargs", ")", ":", "geneID_groups", "=", "self", ".", "adata", ".", "uns", "[", "'gene_groups'", "]", "if", "(", "group", "is", "None", ")", ...
Plots orthogonal expression patterns. In the default mode, plots orthogonal gene expression patterns. A specific correlated group of genes can be specified to plot gene expression patterns within that group. Parameters ---------- group - int, optional, default None ...
[ "Plots", "orthogonal", "expression", "patterns", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L857-L885
train
atarashansky/self-assembling-manifold
SAM.py
SAM.plot_correlated_genes
def plot_correlated_genes( self, name, n_genes=5, number_of_features=1000, **kwargs): """Plots gene expression patterns correlated with the input gene. Parameters ---------- name - string The name of the gene with r...
python
def plot_correlated_genes( self, name, n_genes=5, number_of_features=1000, **kwargs): """Plots gene expression patterns correlated with the input gene. Parameters ---------- name - string The name of the gene with r...
[ "def", "plot_correlated_genes", "(", "self", ",", "name", ",", "n_genes", "=", "5", ",", "number_of_features", "=", "1000", ",", "**", "kwargs", ")", ":", "all_gene_names", "=", "np", ".", "array", "(", "list", "(", "self", ".", "adata", ".", "var_names"...
Plots gene expression patterns correlated with the input gene. Parameters ---------- name - string The name of the gene with respect to which correlated gene expression patterns will be displayed. n_genes - int, optional, default 5 The number of top ...
[ "Plots", "gene", "expression", "patterns", "correlated", "with", "the", "input", "gene", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L887-L924
train
atarashansky/self-assembling-manifold
SAM.py
SAM.run_tsne
def run_tsne(self, X=None, metric='correlation', **kwargs): """Wrapper for sklearn's t-SNE implementation. See sklearn for the t-SNE documentation. All arguments are the same with the exception that 'metric' is set to 'precomputed' by default, implying that this function expects a dista...
python
def run_tsne(self, X=None, metric='correlation', **kwargs): """Wrapper for sklearn's t-SNE implementation. See sklearn for the t-SNE documentation. All arguments are the same with the exception that 'metric' is set to 'precomputed' by default, implying that this function expects a dista...
[ "def", "run_tsne", "(", "self", ",", "X", "=", "None", ",", "metric", "=", "'correlation'", ",", "**", "kwargs", ")", ":", "if", "(", "X", "is", "not", "None", ")", ":", "dt", "=", "man", ".", "TSNE", "(", "metric", "=", "metric", ",", "**", "k...
Wrapper for sklearn's t-SNE implementation. See sklearn for the t-SNE documentation. All arguments are the same with the exception that 'metric' is set to 'precomputed' by default, implying that this function expects a distance matrix by default.
[ "Wrapper", "for", "sklearn", "s", "t", "-", "SNE", "implementation", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1011-L1026
train
atarashansky/self-assembling-manifold
SAM.py
SAM.run_umap
def run_umap(self, X=None, metric=None, **kwargs): """Wrapper for umap-learn. See https://github.com/lmcinnes/umap sklearn for the documentation and source code. """ import umap as umap if metric is None: metric = self.distance if(X is not None): ...
python
def run_umap(self, X=None, metric=None, **kwargs): """Wrapper for umap-learn. See https://github.com/lmcinnes/umap sklearn for the documentation and source code. """ import umap as umap if metric is None: metric = self.distance if(X is not None): ...
[ "def", "run_umap", "(", "self", ",", "X", "=", "None", ",", "metric", "=", "None", ",", "**", "kwargs", ")", ":", "import", "umap", "as", "umap", "if", "metric", "is", "None", ":", "metric", "=", "self", ".", "distance", "if", "(", "X", "is", "no...
Wrapper for umap-learn. See https://github.com/lmcinnes/umap sklearn for the documentation and source code.
[ "Wrapper", "for", "umap", "-", "learn", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1028-L1048
train
atarashansky/self-assembling-manifold
SAM.py
SAM.scatter
def scatter(self, projection=None, c=None, cmap='rainbow', linewidth=0.0, edgecolor='k', axes=None, colorbar=True, s=10, **kwargs): """Display a scatter plot. Displays a scatter plot using the SAM projection or another input projection with or without annotations. Param...
python
def scatter(self, projection=None, c=None, cmap='rainbow', linewidth=0.0, edgecolor='k', axes=None, colorbar=True, s=10, **kwargs): """Display a scatter plot. Displays a scatter plot using the SAM projection or another input projection with or without annotations. Param...
[ "def", "scatter", "(", "self", ",", "projection", "=", "None", ",", "c", "=", "None", ",", "cmap", "=", "'rainbow'", ",", "linewidth", "=", "0.0", ",", "edgecolor", "=", "'k'", ",", "axes", "=", "None", ",", "colorbar", "=", "True", ",", "s", "=", ...
Display a scatter plot. Displays a scatter plot using the SAM projection or another input projection with or without annotations. Parameters ---------- projection - ndarray of floats, optional, default None An N x 2 matrix, where N is the number of data points. If ...
[ "Display", "a", "scatter", "plot", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1077-L1175
train
atarashansky/self-assembling-manifold
SAM.py
SAM.show_gene_expression
def show_gene_expression(self, gene, avg=True, axes=None, **kwargs): """Display a gene's expressions. Displays a scatter plot using the SAM projection or another input projection with a particular gene's expressions overlaid. Parameters ---------- gene - string ...
python
def show_gene_expression(self, gene, avg=True, axes=None, **kwargs): """Display a gene's expressions. Displays a scatter plot using the SAM projection or another input projection with a particular gene's expressions overlaid. Parameters ---------- gene - string ...
[ "def", "show_gene_expression", "(", "self", ",", "gene", ",", "avg", "=", "True", ",", "axes", "=", "None", ",", "**", "kwargs", ")", ":", "all_gene_names", "=", "np", ".", "array", "(", "list", "(", "self", ".", "adata", ".", "var_names", ")", ")", ...
Display a gene's expressions. Displays a scatter plot using the SAM projection or another input projection with a particular gene's expressions overlaid. Parameters ---------- gene - string a case-sensitive string indicating the gene expression pattern t...
[ "Display", "a", "gene", "s", "expressions", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1177-L1231
train
atarashansky/self-assembling-manifold
SAM.py
SAM.louvain_clustering
def louvain_clustering(self, X=None, res=1, method='modularity'): """Runs Louvain clustering using the vtraag implementation. Assumes that 'louvain' optional dependency is installed. Parameters ---------- res - float, optional, default 1 The resolution parameter whic...
python
def louvain_clustering(self, X=None, res=1, method='modularity'): """Runs Louvain clustering using the vtraag implementation. Assumes that 'louvain' optional dependency is installed. Parameters ---------- res - float, optional, default 1 The resolution parameter whic...
[ "def", "louvain_clustering", "(", "self", ",", "X", "=", "None", ",", "res", "=", "1", ",", "method", "=", "'modularity'", ")", ":", "if", "X", "is", "None", ":", "X", "=", "self", ".", "adata", ".", "uns", "[", "'neighbors'", "]", "[", "'connectiv...
Runs Louvain clustering using the vtraag implementation. Assumes that 'louvain' optional dependency is installed. Parameters ---------- res - float, optional, default 1 The resolution parameter which tunes the number of clusters Louvain finds. method - s...
[ "Runs", "Louvain", "clustering", "using", "the", "vtraag", "implementation", ".", "Assumes", "that", "louvain", "optional", "dependency", "is", "installed", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1265-L1316
train
atarashansky/self-assembling-manifold
SAM.py
SAM.kmeans_clustering
def kmeans_clustering(self, numc, X=None, npcs=15): """Performs k-means clustering. Parameters ---------- numc - int Number of clusters npcs - int, optional, default 15 Number of principal components to use as inpute for k-means clustering. ...
python
def kmeans_clustering(self, numc, X=None, npcs=15): """Performs k-means clustering. Parameters ---------- numc - int Number of clusters npcs - int, optional, default 15 Number of principal components to use as inpute for k-means clustering. ...
[ "def", "kmeans_clustering", "(", "self", ",", "numc", ",", "X", "=", "None", ",", "npcs", "=", "15", ")", ":", "from", "sklearn", ".", "cluster", "import", "KMeans", "if", "X", "is", "None", ":", "D_sub", "=", "self", ".", "adata", ".", "uns", "[",...
Performs k-means clustering. Parameters ---------- numc - int Number of clusters npcs - int, optional, default 15 Number of principal components to use as inpute for k-means clustering.
[ "Performs", "k", "-", "means", "clustering", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1318-L1350
train
atarashansky/self-assembling-manifold
SAM.py
SAM.identify_marker_genes_rf
def identify_marker_genes_rf(self, labels=None, clusters=None, n_genes=4000): """ Ranks marker genes for each cluster using a random forest classification approach. Parameters ---------- labels - numpy.array or str, optional, default Non...
python
def identify_marker_genes_rf(self, labels=None, clusters=None, n_genes=4000): """ Ranks marker genes for each cluster using a random forest classification approach. Parameters ---------- labels - numpy.array or str, optional, default Non...
[ "def", "identify_marker_genes_rf", "(", "self", ",", "labels", "=", "None", ",", "clusters", "=", "None", ",", "n_genes", "=", "4000", ")", ":", "if", "(", "labels", "is", "None", ")", ":", "try", ":", "keys", "=", "np", ".", "array", "(", "list", ...
Ranks marker genes for each cluster using a random forest classification approach. Parameters ---------- labels - numpy.array or str, optional, default None Cluster labels to use for marker gene identification. If None, assumes that one of SAM's clustering algor...
[ "Ranks", "marker", "genes", "for", "each", "cluster", "using", "a", "random", "forest", "classification", "approach", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1404-L1471
train
atarashansky/self-assembling-manifold
SAM.py
SAM.identify_marker_genes_corr
def identify_marker_genes_corr(self, labels=None, n_genes=4000): """ Ranking marker genes based on their respective magnitudes in the correlation dot products with cluster-specific reference expression profiles. Parameters ---------- labels - numpy.array or str...
python
def identify_marker_genes_corr(self, labels=None, n_genes=4000): """ Ranking marker genes based on their respective magnitudes in the correlation dot products with cluster-specific reference expression profiles. Parameters ---------- labels - numpy.array or str...
[ "def", "identify_marker_genes_corr", "(", "self", ",", "labels", "=", "None", ",", "n_genes", "=", "4000", ")", ":", "if", "(", "labels", "is", "None", ")", ":", "try", ":", "keys", "=", "np", ".", "array", "(", "list", "(", "self", ".", "adata", "...
Ranking marker genes based on their respective magnitudes in the correlation dot products with cluster-specific reference expression profiles. Parameters ---------- labels - numpy.array or str, optional, default None Cluster labels to use for marker gene identifica...
[ "Ranking", "marker", "genes", "based", "on", "their", "respective", "magnitudes", "in", "the", "correlation", "dot", "products", "with", "cluster", "-", "specific", "reference", "expression", "profiles", "." ]
4db4793f65af62047492327716932ba81a67f679
https://github.com/atarashansky/self-assembling-manifold/blob/4db4793f65af62047492327716932ba81a67f679/SAM.py#L1521-L1575
train
cocoakekeyu/cancan
cancan/ability.py
Ability.add
def add(self, action=None, subject=None, **conditions): """ Add ability are allowed using two arguments. The first one is the action you're setting the permission for, the second one is the class of object you're setting it on. the third one is the subject's conditions must be m...
python
def add(self, action=None, subject=None, **conditions): """ Add ability are allowed using two arguments. The first one is the action you're setting the permission for, the second one is the class of object you're setting it on. the third one is the subject's conditions must be m...
[ "def", "add", "(", "self", ",", "action", "=", "None", ",", "subject", "=", "None", ",", "**", "conditions", ")", ":", "self", ".", "add_rule", "(", "Rule", "(", "True", ",", "action", ",", "subject", ",", "**", "conditions", ")", ")" ]
Add ability are allowed using two arguments. The first one is the action you're setting the permission for, the second one is the class of object you're setting it on. the third one is the subject's conditions must be matches or a function to be test. self.add('update', Article...
[ "Add", "ability", "are", "allowed", "using", "two", "arguments", "." ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L21-L35
train
cocoakekeyu/cancan
cancan/ability.py
Ability.addnot
def addnot(self, action=None, subject=None, **conditions): """ Defines an ability which cannot be done. """ self.add_rule(Rule(False, action, subject, **conditions))
python
def addnot(self, action=None, subject=None, **conditions): """ Defines an ability which cannot be done. """ self.add_rule(Rule(False, action, subject, **conditions))
[ "def", "addnot", "(", "self", ",", "action", "=", "None", ",", "subject", "=", "None", ",", "**", "conditions", ")", ":", "self", ".", "add_rule", "(", "Rule", "(", "False", ",", "action", ",", "subject", ",", "**", "conditions", ")", ")" ]
Defines an ability which cannot be done.
[ "Defines", "an", "ability", "which", "cannot", "be", "done", "." ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L37-L41
train
cocoakekeyu/cancan
cancan/ability.py
Ability.can
def can(self, action, subject, **conditions): """ Check if the user has permission to perform a given action on an object """ for rule in self.relevant_rules_for_match(action, subject): if rule.matches_conditions(action, subject, **conditions): return rule.bas...
python
def can(self, action, subject, **conditions): """ Check if the user has permission to perform a given action on an object """ for rule in self.relevant_rules_for_match(action, subject): if rule.matches_conditions(action, subject, **conditions): return rule.bas...
[ "def", "can", "(", "self", ",", "action", ",", "subject", ",", "**", "conditions", ")", ":", "for", "rule", "in", "self", ".", "relevant_rules_for_match", "(", "action", ",", "subject", ")", ":", "if", "rule", ".", "matches_conditions", "(", "action", ",...
Check if the user has permission to perform a given action on an object
[ "Check", "if", "the", "user", "has", "permission", "to", "perform", "a", "given", "action", "on", "an", "object" ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L46-L53
train
cocoakekeyu/cancan
cancan/ability.py
Ability.relevant_rules_for_match
def relevant_rules_for_match(self, action, subject): """retrive match action and subject""" matches = [] for rule in self.rules: rule.expanded_actions = self.expand_actions(rule.actions) if rule.is_relevant(action, subject): matches.append(rule) r...
python
def relevant_rules_for_match(self, action, subject): """retrive match action and subject""" matches = [] for rule in self.rules: rule.expanded_actions = self.expand_actions(rule.actions) if rule.is_relevant(action, subject): matches.append(rule) r...
[ "def", "relevant_rules_for_match", "(", "self", ",", "action", ",", "subject", ")", ":", "matches", "=", "[", "]", "for", "rule", "in", "self", ".", "rules", ":", "rule", ".", "expanded_actions", "=", "self", ".", "expand_actions", "(", "rule", ".", "act...
retrive match action and subject
[ "retrive", "match", "action", "and", "subject" ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L62-L70
train
cocoakekeyu/cancan
cancan/ability.py
Ability.expand_actions
def expand_actions(self, actions): """ Accepts an array of actions and returns an array of actions which match """ r = [] for action in actions: r.append(action) if action in self.aliased_actions: r.extend(self.aliased_actions[action]) ...
python
def expand_actions(self, actions): """ Accepts an array of actions and returns an array of actions which match """ r = [] for action in actions: r.append(action) if action in self.aliased_actions: r.extend(self.aliased_actions[action]) ...
[ "def", "expand_actions", "(", "self", ",", "actions", ")", ":", "r", "=", "[", "]", "for", "action", "in", "actions", ":", "r", ".", "append", "(", "action", ")", "if", "action", "in", "self", ".", "aliased_actions", ":", "r", ".", "extend", "(", "...
Accepts an array of actions and returns an array of actions which match
[ "Accepts", "an", "array", "of", "actions", "and", "returns", "an", "array", "of", "actions", "which", "match" ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L81-L90
train
cocoakekeyu/cancan
cancan/ability.py
Ability.alias_action
def alias_action(self, *args, **kwargs): """ Alias one or more actions into another one. self.alias_action('create', 'read', 'update', 'delete', to='crud') """ to = kwargs.pop('to', None) if not to: return error_message = ("You can't specify target (...
python
def alias_action(self, *args, **kwargs): """ Alias one or more actions into another one. self.alias_action('create', 'read', 'update', 'delete', to='crud') """ to = kwargs.pop('to', None) if not to: return error_message = ("You can't specify target (...
[ "def", "alias_action", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "to", "=", "kwargs", ".", "pop", "(", "'to'", ",", "None", ")", "if", "not", "to", ":", "return", "error_message", "=", "(", "\"You can't specify target ({}) as alias \"",...
Alias one or more actions into another one. self.alias_action('create', 'read', 'update', 'delete', to='crud')
[ "Alias", "one", "or", "more", "actions", "into", "another", "one", "." ]
f198d560e6e008e6c5580ba55581a939a5d544ed
https://github.com/cocoakekeyu/cancan/blob/f198d560e6e008e6c5580ba55581a939a5d544ed/cancan/ability.py#L92-L108
train
suurjaak/InputScope
inputscope/db.py
fetch
def fetch(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT and fetch all.""" return select(table, cols, where, group, order, limit, **kwargs).fetchall()
python
def fetch(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT and fetch all.""" return select(table, cols, where, group, order, limit, **kwargs).fetchall()
[ "def", "fetch", "(", "table", ",", "cols", "=", "\"*\"", ",", "where", "=", "(", ")", ",", "group", "=", "\"\"", ",", "order", "=", "(", ")", ",", "limit", "=", "(", ")", ",", "**", "kwargs", ")", ":", "return", "select", "(", "table", ",", "...
Convenience wrapper for database SELECT and fetch all.
[ "Convenience", "wrapper", "for", "database", "SELECT", "and", "fetch", "all", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L24-L26
train
suurjaak/InputScope
inputscope/db.py
fetchone
def fetchone(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT and fetch one.""" return select(table, cols, where, group, order, limit, **kwargs).fetchone()
python
def fetchone(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT and fetch one.""" return select(table, cols, where, group, order, limit, **kwargs).fetchone()
[ "def", "fetchone", "(", "table", ",", "cols", "=", "\"*\"", ",", "where", "=", "(", ")", ",", "group", "=", "\"\"", ",", "order", "=", "(", ")", ",", "limit", "=", "(", ")", ",", "**", "kwargs", ")", ":", "return", "select", "(", "table", ",", ...
Convenience wrapper for database SELECT and fetch one.
[ "Convenience", "wrapper", "for", "database", "SELECT", "and", "fetch", "one", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L29-L31
train
suurjaak/InputScope
inputscope/db.py
insert
def insert(table, values=(), **kwargs): """Convenience wrapper for database INSERT.""" values = dict(values, **kwargs).items() sql, args = makeSQL("INSERT", table, values=values) return execute(sql, args).lastrowid
python
def insert(table, values=(), **kwargs): """Convenience wrapper for database INSERT.""" values = dict(values, **kwargs).items() sql, args = makeSQL("INSERT", table, values=values) return execute(sql, args).lastrowid
[ "def", "insert", "(", "table", ",", "values", "=", "(", ")", ",", "**", "kwargs", ")", ":", "values", "=", "dict", "(", "values", ",", "**", "kwargs", ")", ".", "items", "(", ")", "sql", ",", "args", "=", "makeSQL", "(", "\"INSERT\"", ",", "table...
Convenience wrapper for database INSERT.
[ "Convenience", "wrapper", "for", "database", "INSERT", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L34-L38
train
suurjaak/InputScope
inputscope/db.py
select
def select(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT.""" where = dict(where, **kwargs).items() sql, args = makeSQL("SELECT", table, cols, where, group, order, limit) return execute(sql, args)
python
def select(table, cols="*", where=(), group="", order=(), limit=(), **kwargs): """Convenience wrapper for database SELECT.""" where = dict(where, **kwargs).items() sql, args = makeSQL("SELECT", table, cols, where, group, order, limit) return execute(sql, args)
[ "def", "select", "(", "table", ",", "cols", "=", "\"*\"", ",", "where", "=", "(", ")", ",", "group", "=", "\"\"", ",", "order", "=", "(", ")", ",", "limit", "=", "(", ")", ",", "**", "kwargs", ")", ":", "where", "=", "dict", "(", "where", ","...
Convenience wrapper for database SELECT.
[ "Convenience", "wrapper", "for", "database", "SELECT", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L41-L45
train
suurjaak/InputScope
inputscope/db.py
update
def update(table, values, where=(), **kwargs): """Convenience wrapper for database UPDATE.""" where = dict(where, **kwargs).items() sql, args = makeSQL("UPDATE", table, values=values, where=where) return execute(sql, args).rowcount
python
def update(table, values, where=(), **kwargs): """Convenience wrapper for database UPDATE.""" where = dict(where, **kwargs).items() sql, args = makeSQL("UPDATE", table, values=values, where=where) return execute(sql, args).rowcount
[ "def", "update", "(", "table", ",", "values", ",", "where", "=", "(", ")", ",", "**", "kwargs", ")", ":", "where", "=", "dict", "(", "where", ",", "**", "kwargs", ")", ".", "items", "(", ")", "sql", ",", "args", "=", "makeSQL", "(", "\"UPDATE\"",...
Convenience wrapper for database UPDATE.
[ "Convenience", "wrapper", "for", "database", "UPDATE", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L48-L52
train
suurjaak/InputScope
inputscope/db.py
delete
def delete(table, where=(), **kwargs): """Convenience wrapper for database DELETE.""" where = dict(where, **kwargs).items() sql, args = makeSQL("DELETE", table, where=where) return execute(sql, args).rowcount
python
def delete(table, where=(), **kwargs): """Convenience wrapper for database DELETE.""" where = dict(where, **kwargs).items() sql, args = makeSQL("DELETE", table, where=where) return execute(sql, args).rowcount
[ "def", "delete", "(", "table", ",", "where", "=", "(", ")", ",", "**", "kwargs", ")", ":", "where", "=", "dict", "(", "where", ",", "**", "kwargs", ")", ".", "items", "(", ")", "sql", ",", "args", "=", "makeSQL", "(", "\"DELETE\"", ",", "table", ...
Convenience wrapper for database DELETE.
[ "Convenience", "wrapper", "for", "database", "DELETE", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L55-L59
train
suurjaak/InputScope
inputscope/db.py
make_cursor
def make_cursor(path, init_statements=(), _connectioncache={}): """Returns a cursor to the database, making new connection if not cached.""" connection = _connectioncache.get(path) if not connection: is_new = not os.path.exists(path) or not os.path.getsize(path) try: is_new and os.maked...
python
def make_cursor(path, init_statements=(), _connectioncache={}): """Returns a cursor to the database, making new connection if not cached.""" connection = _connectioncache.get(path) if not connection: is_new = not os.path.exists(path) or not os.path.getsize(path) try: is_new and os.maked...
[ "def", "make_cursor", "(", "path", ",", "init_statements", "=", "(", ")", ",", "_connectioncache", "=", "{", "}", ")", ":", "connection", "=", "_connectioncache", ".", "get", "(", "path", ")", "if", "not", "connection", ":", "is_new", "=", "not", "os", ...
Returns a cursor to the database, making new connection if not cached.
[ "Returns", "a", "cursor", "to", "the", "database", "making", "new", "connection", "if", "not", "cached", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/db.py#L73-L87
train