repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Requester.on_stop
def on_stop(self): """ stop requester """ LOGGER.debug("rabbitmq.Requester.on_stop") try: self.channel.close() except Exception as e: LOGGER.warn("rabbitmq.Requester.on_stop - Exception raised while closing channel") try: self.c...
python
def on_stop(self): """ stop requester """ LOGGER.debug("rabbitmq.Requester.on_stop") try: self.channel.close() except Exception as e: LOGGER.warn("rabbitmq.Requester.on_stop - Exception raised while closing channel") try: self.c...
[ "def", "on_stop", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Requester.on_stop\"", ")", "try", ":", "self", ".", "channel", ".", "close", "(", ")", "except", "Exception", "as", "e", ":", "LOGGER", ".", "warn", "(", "\"rabbitmq.Requeste...
stop requester
[ "stop", "requester" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L106-L118
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Requester.on_response
def on_response(self, ch, method_frame, props, body): """ setup response is correlation id is the good one """ LOGGER.debug("rabbitmq.Requester.on_response") if self.corr_id == props.correlation_id: self.response = {'props': props, 'body': body} else: ...
python
def on_response(self, ch, method_frame, props, body): """ setup response is correlation id is the good one """ LOGGER.debug("rabbitmq.Requester.on_response") if self.corr_id == props.correlation_id: self.response = {'props': props, 'body': body} else: ...
[ "def", "on_response", "(", "self", ",", "ch", ",", "method_frame", ",", "props", ",", "body", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Requester.on_response\"", ")", "if", "self", ".", "corr_id", "==", "props", ".", "correlation_id", ":", "self", ...
setup response is correlation id is the good one
[ "setup", "response", "is", "correlation", "id", "is", "the", "good", "one" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L132-L145
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Requester.call
def call(self, my_args=None): """ setup the request and call the remote service. Wait the answer (blocking call) :param my_args: dict like {properties, body} :return response """ LOGGER.debug("rabbitmq.Requester.call") if my_args is None: raise excepti...
python
def call(self, my_args=None): """ setup the request and call the remote service. Wait the answer (blocking call) :param my_args: dict like {properties, body} :return response """ LOGGER.debug("rabbitmq.Requester.call") if my_args is None: raise excepti...
[ "def", "call", "(", "self", ",", "my_args", "=", "None", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Requester.call\"", ")", "if", "my_args", "is", "None", ":", "raise", "exceptions", ".", "ArianeConfError", "(", "\"requestor call arguments\"", ")", "if...
setup the request and call the remote service. Wait the answer (blocking call) :param my_args: dict like {properties, body} :return response
[ "setup", "the", "request", "and", "call", "the", "remote", "service", ".", "Wait", "the", "answer", "(", "blocking", "call", ")", ":", "param", "my_args", ":", "dict", "like", "{", "properties", "body", "}", ":", "return", "response" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L147-L273
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Service.run
def run(self): """ consume message from channel on the consuming thread. """ LOGGER.debug("rabbitmq.Service.run") try: self.channel.start_consuming() except Exception as e: LOGGER.warn("rabbitmq.Service.run - Exception raised while consuming")
python
def run(self): """ consume message from channel on the consuming thread. """ LOGGER.debug("rabbitmq.Service.run") try: self.channel.start_consuming() except Exception as e: LOGGER.warn("rabbitmq.Service.run - Exception raised while consuming")
[ "def", "run", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Service.run\"", ")", "try", ":", "self", ".", "channel", ".", "start_consuming", "(", ")", "except", "Exception", "as", "e", ":", "LOGGER", ".", "warn", "(", "\"rabbitmq.Service....
consume message from channel on the consuming thread.
[ "consume", "message", "from", "channel", "on", "the", "consuming", "thread", "." ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L321-L329
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Service.on_request
def on_request(self, ch, method_frame, props, body): """ message consumed treatment through provided callback and basic ack """ LOGGER.debug("rabbitmq.Service.on_request - request " + str(props) + " received") try: properties = props.headers.copy() propert...
python
def on_request(self, ch, method_frame, props, body): """ message consumed treatment through provided callback and basic ack """ LOGGER.debug("rabbitmq.Service.on_request - request " + str(props) + " received") try: properties = props.headers.copy() propert...
[ "def", "on_request", "(", "self", ",", "ch", ",", "method_frame", ",", "props", ",", "body", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Service.on_request - request \"", "+", "str", "(", "props", ")", "+", "\" received\"", ")", "try", ":", "propertie...
message consumed treatment through provided callback and basic ack
[ "message", "consumed", "treatment", "through", "provided", "callback", "and", "basic", "ack" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L331-L357
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Service.on_start
def on_start(self): """ start the service """ LOGGER.debug("rabbitmq.Service.on_start") self.connection = pika.BlockingConnection(self.parameters) self.channel = self.connection.channel() self.channel.queue_declare(queue=self.serviceQ, auto_delete=True) se...
python
def on_start(self): """ start the service """ LOGGER.debug("rabbitmq.Service.on_start") self.connection = pika.BlockingConnection(self.parameters) self.channel = self.connection.channel() self.channel.queue_declare(queue=self.serviceQ, auto_delete=True) se...
[ "def", "on_start", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Service.on_start\"", ")", "self", ".", "connection", "=", "pika", ".", "BlockingConnection", "(", "self", ".", "parameters", ")", "self", ".", "channel", "=", "self", ".", "...
start the service
[ "start", "the", "service" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L359-L370
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Service.on_stop
def on_stop(self): """ stop the service """ LOGGER.debug("rabbitmq.Service.on_stop") self.is_started = False try: self.channel.stop_consuming() except Exception as e: LOGGER.warn("rabbitmq.Service.on_stop - Exception raised while stoping co...
python
def on_stop(self): """ stop the service """ LOGGER.debug("rabbitmq.Service.on_stop") self.is_started = False try: self.channel.stop_consuming() except Exception as e: LOGGER.warn("rabbitmq.Service.on_stop - Exception raised while stoping co...
[ "def", "on_stop", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Service.on_stop\"", ")", "self", ".", "is_started", "=", "False", "try", ":", "self", ".", "channel", ".", "stop_consuming", "(", ")", "except", "Exception", "as", "e", ":", ...
stop the service
[ "stop", "the", "service" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L372-L391
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/rabbitmq/driver.py
Driver.stop
def stop(self): """ Stop services and requestors and then connection. :return: self """ LOGGER.debug("rabbitmq.Driver.stop") for requester in self.requester_registry: requester.stop() self.requester_registry.clear() for service in self.service...
python
def stop(self): """ Stop services and requestors and then connection. :return: self """ LOGGER.debug("rabbitmq.Driver.stop") for requester in self.requester_registry: requester.stop() self.requester_registry.clear() for service in self.service...
[ "def", "stop", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"rabbitmq.Driver.stop\"", ")", "for", "requester", "in", "self", ".", "requester_registry", ":", "requester", ".", "stop", "(", ")", "self", ".", "requester_registry", ".", "clear", "(", ...
Stop services and requestors and then connection. :return: self
[ "Stop", "services", "and", "requestors", "and", "then", "connection", ".", ":", "return", ":", "self" ]
train
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/rabbitmq/driver.py#L482-L499
chrlie/howabout
features/steps/levenshtein_steps.py
step_impl2
def step_impl2(context, first, second, prefix): """ :type context behave.runner.Context :type first str :type second str :type prefix str """ context.first = first context.second = second
python
def step_impl2(context, first, second, prefix): """ :type context behave.runner.Context :type first str :type second str :type prefix str """ context.first = first context.second = second
[ "def", "step_impl2", "(", "context", ",", "first", ",", "second", ",", "prefix", ")", ":", "context", ".", "first", "=", "first", "context", ".", "second", "=", "second" ]
:type context behave.runner.Context :type first str :type second str :type prefix str
[ ":", "type", "context", "behave", ".", "runner", ".", "Context", ":", "type", "first", "str", ":", "type", "second", "str", ":", "type", "prefix", "str" ]
train
https://github.com/chrlie/howabout/blob/780cacbdd9156106cc77f643c75191a824b034bb/features/steps/levenshtein_steps.py#L53-L61
artisanofcode/python-broadway
scripts/release.py
error
def error(message, *args, **kwargs): """ print an error message """ print('[!] ' + message.format(*args, **kwargs)) sys.exit(1)
python
def error(message, *args, **kwargs): """ print an error message """ print('[!] ' + message.format(*args, **kwargs)) sys.exit(1)
[ "def", "error", "(", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "print", "(", "'[!] '", "+", "message", ".", "format", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "sys", ".", "exit", "(", "1", ")" ]
print an error message
[ "print", "an", "error", "message" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L25-L29
artisanofcode/python-broadway
scripts/release.py
parse_changes
def parse_changes(): """ grab version from CHANGES and validate entry """ with open('CHANGES') as changes: for match in re.finditer(RE_CHANGES, changes.read(1024), re.M): if len(match.group(1)) != len(match.group(3)): error('incorrect underline in CHANGES') date...
python
def parse_changes(): """ grab version from CHANGES and validate entry """ with open('CHANGES') as changes: for match in re.finditer(RE_CHANGES, changes.read(1024), re.M): if len(match.group(1)) != len(match.group(3)): error('incorrect underline in CHANGES') date...
[ "def", "parse_changes", "(", ")", ":", "with", "open", "(", "'CHANGES'", ")", "as", "changes", ":", "for", "match", "in", "re", ".", "finditer", "(", "RE_CHANGES", ",", "changes", ".", "read", "(", "1024", ")", ",", "re", ".", "M", ")", ":", "if", ...
grab version from CHANGES and validate entry
[ "grab", "version", "from", "CHANGES", "and", "validate", "entry" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L38-L54
artisanofcode/python-broadway
scripts/release.py
increment_version
def increment_version(version): """ get the next version """ parts = [int(v) for v in version.split('.')] parts[-1] += 1 parts.append('dev0') return '.'.join(map(str, parts))
python
def increment_version(version): """ get the next version """ parts = [int(v) for v in version.split('.')] parts[-1] += 1 parts.append('dev0') return '.'.join(map(str, parts))
[ "def", "increment_version", "(", "version", ")", ":", "parts", "=", "[", "int", "(", "v", ")", "for", "v", "in", "version", ".", "split", "(", "'.'", ")", "]", "parts", "[", "-", "1", "]", "+=", "1", "parts", ".", "append", "(", "'dev0'", ")", ...
get the next version
[ "get", "the", "next", "version" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L57-L64
artisanofcode/python-broadway
scripts/release.py
set_version
def set_version(version): """ set the version in the projects root module """ with open(FILENAME) as pythonfile: content = pythonfile.read() output = re.sub(RE_VERSION, r"\1'{}'".format(version), content) if content == output: error('failed updating {}'.format(FILENAME)) with ope...
python
def set_version(version): """ set the version in the projects root module """ with open(FILENAME) as pythonfile: content = pythonfile.read() output = re.sub(RE_VERSION, r"\1'{}'".format(version), content) if content == output: error('failed updating {}'.format(FILENAME)) with ope...
[ "def", "set_version", "(", "version", ")", ":", "with", "open", "(", "FILENAME", ")", "as", "pythonfile", ":", "content", "=", "pythonfile", ".", "read", "(", ")", "output", "=", "re", ".", "sub", "(", "RE_VERSION", ",", "r\"\\1'{}'\"", ".", "format", ...
set the version in the projects root module
[ "set", "the", "version", "in", "the", "projects", "root", "module" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L67-L79
artisanofcode/python-broadway
scripts/release.py
upload
def upload(): """ build the files and upload to pypi """ def twine(*args): """ run a twine command """ process = run(sys.executable, '-m', 'twine', *args) return process.wait() != 0 if run(sys.executable, 'setup.py', 'sdist', 'bdist_wheel').wait() != 0: error('failed build...
python
def upload(): """ build the files and upload to pypi """ def twine(*args): """ run a twine command """ process = run(sys.executable, '-m', 'twine', *args) return process.wait() != 0 if run(sys.executable, 'setup.py', 'sdist', 'bdist_wheel').wait() != 0: error('failed build...
[ "def", "upload", "(", ")", ":", "def", "twine", "(", "*", "args", ")", ":", "\"\"\" run a twine command \"\"\"", "process", "=", "run", "(", "sys", ".", "executable", ",", "'-m'", ",", "'twine'", ",", "*", "args", ")", "return", "process", ".", "wait", ...
build the files and upload to pypi
[ "build", "the", "files", "and", "upload", "to", "pypi" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L82-L98
artisanofcode/python-broadway
scripts/release.py
check_tag
def check_tag(version): """ check theres not already a tag for this version """ output = run('git', 'tag', stdout=subprocess.PIPE).communicate()[0] tags = set(output.decode('utf-8').splitlines()) if 'v{}'.format(version) in tags: error('version already exists')
python
def check_tag(version): """ check theres not already a tag for this version """ output = run('git', 'tag', stdout=subprocess.PIPE).communicate()[0] tags = set(output.decode('utf-8').splitlines()) if 'v{}'.format(version) in tags: error('version already exists')
[ "def", "check_tag", "(", "version", ")", ":", "output", "=", "run", "(", "'git'", ",", "'tag'", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", ".", "communicate", "(", ")", "[", "0", "]", "tags", "=", "set", "(", "output", ".", "decode", "(", ...
check theres not already a tag for this version
[ "check", "theres", "not", "already", "a", "tag", "for", "this", "version" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L101-L108
artisanofcode/python-broadway
scripts/release.py
main
def main(): """ entry point """ os.chdir(os.path.join(os.path.dirname(__file__), '..')) version = parse_changes() print('[i] releasing {}'.format(version)) check_clean() check_tag(version) set_version(version) clean() upload() clean() commit(version) tag(version) ...
python
def main(): """ entry point """ os.chdir(os.path.join(os.path.dirname(__file__), '..')) version = parse_changes() print('[i] releasing {}'.format(version)) check_clean() check_tag(version) set_version(version) clean() upload() clean() commit(version) tag(version) ...
[ "def", "main", "(", ")", ":", "os", ".", "chdir", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'..'", ")", ")", "version", "=", "parse_changes", "(", ")", "print", "(", "'[i] releasing {}'...
entry point
[ "entry", "point" ]
train
https://github.com/artisanofcode/python-broadway/blob/a051ca5a922ecb38a541df59e8740e2a047d9a4a/scripts/release.py#L139-L156
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.get_motd
def get_motd(self, server=None): """ Gets the server's MOTD. Optional arguments: * server=None - Server to get the MOTD of. """ with self.lock: if not server: self.send('MOTD') else: self.send('MOTD %s' % server) ...
python
def get_motd(self, server=None): """ Gets the server's MOTD. Optional arguments: * server=None - Server to get the MOTD of. """ with self.lock: if not server: self.send('MOTD') else: self.send('MOTD %s' % server) ...
[ "def", "get_motd", "(", "self", ",", "server", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "server", ":", "self", ".", "send", "(", "'MOTD'", ")", "else", ":", "self", ".", "send", "(", "'MOTD %s'", "%", "server", ")", "...
Gets the server's MOTD. Optional arguments: * server=None - Server to get the MOTD of.
[ "Gets", "the", "server", "s", "MOTD", ".", "Optional", "arguments", ":", "*", "server", "=", "None", "-", "Server", "to", "get", "the", "MOTD", "of", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L24-L48
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.get_lusers
def get_lusers(self, mask=None, target=None): """ Get the LUSERS information. Optional arguments: * mask=None - Mask to get LUSERS information of. * target=None - Forward the query. """ with self.lock: if not mask: self.send('LUSERS') ...
python
def get_lusers(self, mask=None, target=None): """ Get the LUSERS information. Optional arguments: * mask=None - Mask to get LUSERS information of. * target=None - Forward the query. """ with self.lock: if not mask: self.send('LUSERS') ...
[ "def", "get_lusers", "(", "self", ",", "mask", "=", "None", ",", "target", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "mask", ":", "self", ".", "send", "(", "'LUSERS'", ")", "elif", "not", "target", "and", "mask", ":", ...
Get the LUSERS information. Optional arguments: * mask=None - Mask to get LUSERS information of. * target=None - Forward the query.
[ "Get", "the", "LUSERS", "information", ".", "Optional", "arguments", ":", "*", "mask", "=", "None", "-", "Mask", "to", "get", "LUSERS", "information", "of", ".", "*", "target", "=", "None", "-", "Forward", "the", "query", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L50-L94
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.get_version
def get_version(self, target=None): """ Get the servers VERSION information. Optional arguments: * target=None - Server to get the VERSION information of. """ with self.lock: if not target: self.send('VERSION') else: ...
python
def get_version(self, target=None): """ Get the servers VERSION information. Optional arguments: * target=None - Server to get the VERSION information of. """ with self.lock: if not target: self.send('VERSION') else: ...
[ "def", "get_version", "(", "self", ",", "target", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "target", ":", "self", ".", "send", "(", "'VERSION'", ")", "else", ":", "self", ".", "send", "(", "'VERSION %s'", "%", "target", ...
Get the servers VERSION information. Optional arguments: * target=None - Server to get the VERSION information of.
[ "Get", "the", "servers", "VERSION", "information", ".", "Optional", "arguments", ":", "*", "target", "=", "None", "-", "Server", "to", "get", "the", "VERSION", "information", "of", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L96-L124
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.stats
def stats(self, query=None, target=None): """ Get the server's STATS information. Optional arguments: * query=None - STATS Query. * target=None - Target server. """ with self.lock: if not query: self.send('STATS') elif not t...
python
def stats(self, query=None, target=None): """ Get the server's STATS information. Optional arguments: * query=None - STATS Query. * target=None - Target server. """ with self.lock: if not query: self.send('STATS') elif not t...
[ "def", "stats", "(", "self", ",", "query", "=", "None", ",", "target", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "query", ":", "self", ".", "send", "(", "'STATS'", ")", "elif", "not", "target", "and", "query", ":", "se...
Get the server's STATS information. Optional arguments: * query=None - STATS Query. * target=None - Target server.
[ "Get", "the", "server", "s", "STATS", "information", ".", "Optional", "arguments", ":", "*", "query", "=", "None", "-", "STATS", "Query", ".", "*", "target", "=", "None", "-", "Target", "server", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L126-L147
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.links
def links(self, r_server=None, mask=None): """ Get LINKS information. Optional arguments: * r_server=None - Forward the query to this server. * mask=None - Match mask servers. """ with self.lock: if not r_server: self.send('LINKS') ...
python
def links(self, r_server=None, mask=None): """ Get LINKS information. Optional arguments: * r_server=None - Forward the query to this server. * mask=None - Match mask servers. """ with self.lock: if not r_server: self.send('LINKS') ...
[ "def", "links", "(", "self", ",", "r_server", "=", "None", ",", "mask", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "r_server", ":", "self", ".", "send", "(", "'LINKS'", ")", "elif", "not", "mask", "and", "r_server", ":", ...
Get LINKS information. Optional arguments: * r_server=None - Forward the query to this server. * mask=None - Match mask servers.
[ "Get", "LINKS", "information", ".", "Optional", "arguments", ":", "*", "r_server", "=", "None", "-", "Forward", "the", "query", "to", "this", "server", ".", "*", "mask", "=", "None", "-", "Match", "mask", "servers", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L149-L173
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.time
def time(self, target=None): """ Get server time. Optional arguments: * target=None - Target server. """ with self.lock: if target: self.send('TIME %s' % target) else: self.send('TIME') time = '' ...
python
def time(self, target=None): """ Get server time. Optional arguments: * target=None - Target server. """ with self.lock: if target: self.send('TIME %s' % target) else: self.send('TIME') time = '' ...
[ "def", "time", "(", "self", ",", "target", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "target", ":", "self", ".", "send", "(", "'TIME %s'", "%", "target", ")", "else", ":", "self", ".", "send", "(", "'TIME'", ")", "time", "=",...
Get server time. Optional arguments: * target=None - Target server.
[ "Get", "server", "time", ".", "Optional", "arguments", ":", "*", "target", "=", "None", "-", "Target", "server", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L175-L190
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.s_connect
def s_connect(self, server, port, r_server=None): """ Link a server. Required arguments: * server - Server to link with. * port - Port to use. Optional arguments: * r_server=None - Link r_server with server. """ with self.lock: if not r...
python
def s_connect(self, server, port, r_server=None): """ Link a server. Required arguments: * server - Server to link with. * port - Port to use. Optional arguments: * r_server=None - Link r_server with server. """ with self.lock: if not r...
[ "def", "s_connect", "(", "self", ",", "server", ",", "port", ",", "r_server", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "r_server", ":", "self", ".", "send", "(", "'CONNECT %s %s'", "%", "(", "server", ",", "port", ")", ...
Link a server. Required arguments: * server - Server to link with. * port - Port to use. Optional arguments: * r_server=None - Link r_server with server.
[ "Link", "a", "server", ".", "Required", "arguments", ":", "*", "server", "-", "Server", "to", "link", "with", ".", "*", "port", "-", "Port", "to", "use", ".", "Optional", "arguments", ":", "*", "r_server", "=", "None", "-", "Link", "r_server", "with", ...
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L192-L206
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.admin
def admin(self, server=None): """ Get the admin information. Optional arguments: * server=None - Get admin information for - server instead of the current server. """ with self.lock: if not server: self.send('ADMIN') els...
python
def admin(self, server=None): """ Get the admin information. Optional arguments: * server=None - Get admin information for - server instead of the current server. """ with self.lock: if not server: self.send('ADMIN') els...
[ "def", "admin", "(", "self", ",", "server", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "server", ":", "self", ".", "send", "(", "'ADMIN'", ")", "else", ":", "self", ".", "send", "(", "'ADMIN %s'", "%", "server", ")", "r...
Get the admin information. Optional arguments: * server=None - Get admin information for - server instead of the current server.
[ "Get", "the", "admin", "information", ".", "Optional", "arguments", ":", "*", "server", "=", "None", "-", "Get", "admin", "information", "for", "-", "server", "instead", "of", "the", "current", "server", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L212-L233
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.s_info
def s_info(self, server=None): """ Runs the INFO command on a server. Optional arguments: * server=None - Get INFO for server instead of the current server. """ with self.lock: if not server: self.send('INFO') else: ...
python
def s_info(self, server=None): """ Runs the INFO command on a server. Optional arguments: * server=None - Get INFO for server instead of the current server. """ with self.lock: if not server: self.send('INFO') else: ...
[ "def", "s_info", "(", "self", ",", "server", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "server", ":", "self", ".", "send", "(", "'INFO'", ")", "else", ":", "self", ".", "send", "(", "'INFO %s'", "%", "server", ")", "si...
Runs the INFO command on a server. Optional arguments: * server=None - Get INFO for server instead of the current server.
[ "Runs", "the", "INFO", "command", "on", "a", "server", ".", "Optional", "arguments", ":", "*", "server", "=", "None", "-", "Get", "INFO", "for", "server", "instead", "of", "the", "current", "server", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L235-L254
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.squery
def squery(self, sname, msg): """ Send a SQUERY. Required arguments: * sname - Service name. * msg - Message to send. """ with self.lock: self.send('SQUERY %s :%s' % (sname, msg), error_check=True)
python
def squery(self, sname, msg): """ Send a SQUERY. Required arguments: * sname - Service name. * msg - Message to send. """ with self.lock: self.send('SQUERY %s :%s' % (sname, msg), error_check=True)
[ "def", "squery", "(", "self", ",", "sname", ",", "msg", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "send", "(", "'SQUERY %s :%s'", "%", "(", "sname", ",", "msg", ")", ",", "error_check", "=", "True", ")" ]
Send a SQUERY. Required arguments: * sname - Service name. * msg - Message to send.
[ "Send", "a", "SQUERY", ".", "Required", "arguments", ":", "*", "sname", "-", "Service", "name", ".", "*", "msg", "-", "Message", "to", "send", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L260-L268
jamieleshaw/lurklib
lurklib/squeries.py
_ServerQueries.kill
def kill(self, nick, reason=''): """ Kill someone Required arguments: * nick - Nick to kill. Optional arguments: * reason='' - Reason for killing them. """ with self.lock: self.send('KILL ' + nick + ' :' + reason, error_check=True)
python
def kill(self, nick, reason=''): """ Kill someone Required arguments: * nick - Nick to kill. Optional arguments: * reason='' - Reason for killing them. """ with self.lock: self.send('KILL ' + nick + ' :' + reason, error_check=True)
[ "def", "kill", "(", "self", ",", "nick", ",", "reason", "=", "''", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "send", "(", "'KILL '", "+", "nick", "+", "' :'", "+", "reason", ",", "error_check", "=", "True", ")" ]
Kill someone Required arguments: * nick - Nick to kill. Optional arguments: * reason='' - Reason for killing them.
[ "Kill", "someone", "Required", "arguments", ":", "*", "nick", "-", "Nick", "to", "kill", ".", "Optional", "arguments", ":", "*", "reason", "=", "-", "Reason", "for", "killing", "them", "." ]
train
https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/squeries.py#L270-L279
dossier/dossier.web
dossier/web/interface.py
as_multi_dict
def as_multi_dict(d): 'Coerce a dictionary to a bottle.MultiDict' if isinstance(d, bottle.MultiDict): return d md = bottle.MultiDict() for k, v in d.iteritems(): if isinstance(v, list): for x in v: md[k] = x else: md[k] = v return md
python
def as_multi_dict(d): 'Coerce a dictionary to a bottle.MultiDict' if isinstance(d, bottle.MultiDict): return d md = bottle.MultiDict() for k, v in d.iteritems(): if isinstance(v, list): for x in v: md[k] = x else: md[k] = v return md
[ "def", "as_multi_dict", "(", "d", ")", ":", "if", "isinstance", "(", "d", ",", "bottle", ".", "MultiDict", ")", ":", "return", "d", "md", "=", "bottle", ".", "MultiDict", "(", ")", "for", "k", ",", "v", "in", "d", ".", "iteritems", "(", ")", ":",...
Coerce a dictionary to a bottle.MultiDict
[ "Coerce", "a", "dictionary", "to", "a", "bottle", ".", "MultiDict" ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L376-L387
dossier/dossier.web
dossier/web/interface.py
Queryable.set_query_params
def set_query_params(self, query_params): '''Set the query parameters. The query parameters should be a dictionary mapping keys to strings or lists of strings. :param query_params: query parameters :type query_params: ``name |--> (str | [str])`` :rtype: :class:`Queryabl...
python
def set_query_params(self, query_params): '''Set the query parameters. The query parameters should be a dictionary mapping keys to strings or lists of strings. :param query_params: query parameters :type query_params: ``name |--> (str | [str])`` :rtype: :class:`Queryabl...
[ "def", "set_query_params", "(", "self", ",", "query_params", ")", ":", "self", ".", "query_params", "=", "as_multi_dict", "(", "query_params", ")", "self", ".", "apply_param_schema", "(", ")", "return", "self" ]
Set the query parameters. The query parameters should be a dictionary mapping keys to strings or lists of strings. :param query_params: query parameters :type query_params: ``name |--> (str | [str])`` :rtype: :class:`Queryable`
[ "Set", "the", "query", "parameters", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L129-L141
dossier/dossier.web
dossier/web/interface.py
Queryable.add_query_params
def add_query_params(self, query_params): '''Overwrite the given query parameters. This is the same as :meth:`Queryable.set_query_params`, except it overwrites existing parameters individually whereas ``set_query_params`` deletes all existing key in ``query_params``. '''...
python
def add_query_params(self, query_params): '''Overwrite the given query parameters. This is the same as :meth:`Queryable.set_query_params`, except it overwrites existing parameters individually whereas ``set_query_params`` deletes all existing key in ``query_params``. '''...
[ "def", "add_query_params", "(", "self", ",", "query_params", ")", ":", "query_params", "=", "as_multi_dict", "(", "query_params", ")", "for", "k", "in", "query_params", ":", "self", ".", "query_params", ".", "pop", "(", "k", ",", "None", ")", "for", "v", ...
Overwrite the given query parameters. This is the same as :meth:`Queryable.set_query_params`, except it overwrites existing parameters individually whereas ``set_query_params`` deletes all existing key in ``query_params``.
[ "Overwrite", "the", "given", "query", "parameters", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L143-L157
dossier/dossier.web
dossier/web/interface.py
Queryable.apply_param_schema
def apply_param_schema(self): '''Applies the schema defined to the given parameters. This combines the values in ``config_params`` and ``query_params``, and converts them to typed Python values per ``param_schema``. This is called automatically whenever the query parameters are...
python
def apply_param_schema(self): '''Applies the schema defined to the given parameters. This combines the values in ``config_params`` and ``query_params``, and converts them to typed Python values per ``param_schema``. This is called automatically whenever the query parameters are...
[ "def", "apply_param_schema", "(", "self", ")", ":", "def", "param_str", "(", "name", ",", "cons", ",", "default", ")", ":", "try", ":", "v", "=", "self", ".", "query_params", ".", "get", "(", "name", ",", "default", ")", "if", "v", "is", "None", ":...
Applies the schema defined to the given parameters. This combines the values in ``config_params`` and ``query_params``, and converts them to typed Python values per ``param_schema``. This is called automatically whenever the query parameters are updated.
[ "Applies", "the", "schema", "defined", "to", "the", "given", "parameters", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L159-L207
dossier/dossier.web
dossier/web/interface.py
SearchEngine.create_filter_predicate
def create_filter_predicate(self): '''Creates a filter predicate. The list of available filters is given by calls to ``add_filter``, and the list of filters to use is given by parameters in ``params``. In this default implementation, multiple filters can be specified wi...
python
def create_filter_predicate(self): '''Creates a filter predicate. The list of available filters is given by calls to ``add_filter``, and the list of filters to use is given by parameters in ``params``. In this default implementation, multiple filters can be specified wi...
[ "def", "create_filter_predicate", "(", "self", ")", ":", "assert", "self", ".", "query_content_id", "is", "not", "None", ",", "'must call SearchEngine.set_query_id first'", "filter_names", "=", "self", ".", "query_params", ".", "getlist", "(", "'filter'", ")", "if",...
Creates a filter predicate. The list of available filters is given by calls to ``add_filter``, and the list of filters to use is given by parameters in ``params``. In this default implementation, multiple filters can be specified with the ``filter`` parameter. Each filter is ...
[ "Creates", "a", "filter", "predicate", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L268-L297
dossier/dossier.web
dossier/web/interface.py
SearchEngine.results
def results(self): '''Returns results as a JSON encodable Python value. This calls :meth:`SearchEngine.recommendations` and converts the results returned into JSON encodable values. Namely, feature collections are slimmed down to only features that are useful to an end-user. ...
python
def results(self): '''Returns results as a JSON encodable Python value. This calls :meth:`SearchEngine.recommendations` and converts the results returned into JSON encodable values. Namely, feature collections are slimmed down to only features that are useful to an end-user. ...
[ "def", "results", "(", "self", ")", ":", "results", "=", "self", ".", "recommendations", "(", ")", "transformed", "=", "[", "]", "for", "t", "in", "results", "[", "'results'", "]", ":", "if", "len", "(", "t", ")", "==", "2", ":", "cid", ",", "fc"...
Returns results as a JSON encodable Python value. This calls :meth:`SearchEngine.recommendations` and converts the results returned into JSON encodable values. Namely, feature collections are slimmed down to only features that are useful to an end-user.
[ "Returns", "results", "as", "a", "JSON", "encodable", "Python", "value", "." ]
train
https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/interface.py#L310-L334
sternoru/goscalecms
goscale/plugins/pictures/models.py
Picasa._get_entry_link
def _get_entry_link(self, entry): """ Returns a unique link for an entry """ entry_link = None for link in entry.link: if '/data/' not in link.href and '/lh/' not in link.href: entry_link = link.href break return entry_link or entry.lin...
python
def _get_entry_link(self, entry): """ Returns a unique link for an entry """ entry_link = None for link in entry.link: if '/data/' not in link.href and '/lh/' not in link.href: entry_link = link.href break return entry_link or entry.lin...
[ "def", "_get_entry_link", "(", "self", ",", "entry", ")", ":", "entry_link", "=", "None", "for", "link", "in", "entry", ".", "link", ":", "if", "'/data/'", "not", "in", "link", ".", "href", "and", "'/lh/'", "not", "in", "link", ".", "href", ":", "ent...
Returns a unique link for an entry
[ "Returns", "a", "unique", "link", "for", "an", "entry" ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/plugins/pictures/models.py#L75-L83
sternoru/goscalecms
goscale/plugins/pictures/models.py
Picasa._store_post
def _store_post(self, stored_entry, entry=None): """ This method formats entry returned by _get_data() and puts to DB create textDesc, title, and MIME """ stored_entry.content_type = self.type if 1==1 or self.type == 'photos': # ignore type for now # is photo widt...
python
def _store_post(self, stored_entry, entry=None): """ This method formats entry returned by _get_data() and puts to DB create textDesc, title, and MIME """ stored_entry.content_type = self.type if 1==1 or self.type == 'photos': # ignore type for now # is photo widt...
[ "def", "_store_post", "(", "self", ",", "stored_entry", ",", "entry", "=", "None", ")", ":", "stored_entry", ".", "content_type", "=", "self", ".", "type", "if", "1", "==", "1", "or", "self", ".", "type", "==", "'photos'", ":", "# ignore type for now", "...
This method formats entry returned by _get_data() and puts to DB create textDesc, title, and MIME
[ "This", "method", "formats", "entry", "returned", "by", "_get_data", "()", "and", "puts", "to", "DB", "create", "textDesc", "title", "and", "MIME" ]
train
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/plugins/pictures/models.py#L106-L169
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
find
def find(value): """ returns a dictionary of rdfclasses based on the a lowercase search args: value: the value to search by """ value = str(value).lower() rtn_dict = RegistryDictionary() for attr in dir(MODULE.rdfclass): if value in attr.l...
python
def find(value): """ returns a dictionary of rdfclasses based on the a lowercase search args: value: the value to search by """ value = str(value).lower() rtn_dict = RegistryDictionary() for attr in dir(MODULE.rdfclass): if value in attr.l...
[ "def", "find", "(", "value", ")", ":", "value", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "rtn_dict", "=", "RegistryDictionary", "(", ")", "for", "attr", "in", "dir", "(", "MODULE", ".", "rdfclass", ")", ":", "if", "value", "in", "attr...
returns a dictionary of rdfclasses based on the a lowercase search args: value: the value to search by
[ "returns", "a", "dictionary", "of", "rdfclasses", "based", "on", "the", "a", "lowercase", "search" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L32-L49
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
list_base_properties
def list_base_properties(bases): """ returns a dictionary of properties assigned to the class""" rtn_dict = {} for base in bases: if hasattr(base, 'properties'): rtn_dict.update(base.properties) return rtn_dict
python
def list_base_properties(bases): """ returns a dictionary of properties assigned to the class""" rtn_dict = {} for base in bases: if hasattr(base, 'properties'): rtn_dict.update(base.properties) return rtn_dict
[ "def", "list_base_properties", "(", "bases", ")", ":", "rtn_dict", "=", "{", "}", "for", "base", "in", "bases", ":", "if", "hasattr", "(", "base", ",", "'properties'", ")", ":", "rtn_dict", ".", "update", "(", "base", ".", "properties", ")", "return", ...
returns a dictionary of properties assigned to the class
[ "returns", "a", "dictionary", "of", "properties", "assigned", "to", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L80-L86
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
list_hierarchy
def list_hierarchy(class_name, bases): """ Creates a list of the class hierarchy Args: ----- class_name: name of the current class bases: list/tuple of bases for the current class """ class_list = [Uri(class_name)] for base in bases: if base.__name__ not in IGNORE_C...
python
def list_hierarchy(class_name, bases): """ Creates a list of the class hierarchy Args: ----- class_name: name of the current class bases: list/tuple of bases for the current class """ class_list = [Uri(class_name)] for base in bases: if base.__name__ not in IGNORE_C...
[ "def", "list_hierarchy", "(", "class_name", ",", "bases", ")", ":", "class_list", "=", "[", "Uri", "(", "class_name", ")", "]", "for", "base", "in", "bases", ":", "if", "base", ".", "__name__", "not", "in", "IGNORE_CLASSES", ":", "class_list", ".", "appe...
Creates a list of the class hierarchy Args: ----- class_name: name of the current class bases: list/tuple of bases for the current class
[ "Creates", "a", "list", "of", "the", "class", "hierarchy" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L705-L719
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
es_get_class_defs
def es_get_class_defs(cls_def, cls_name): """ Reads through the class defs and gets the related es class defintions Args: ----- class_defs: RdfDataset of class definitions """ rtn_dict = {key: value for key, value in cls_def.items() \ if key.startswith("kds_es")} ...
python
def es_get_class_defs(cls_def, cls_name): """ Reads through the class defs and gets the related es class defintions Args: ----- class_defs: RdfDataset of class definitions """ rtn_dict = {key: value for key, value in cls_def.items() \ if key.startswith("kds_es")} ...
[ "def", "es_get_class_defs", "(", "cls_def", ",", "cls_name", ")", ":", "rtn_dict", "=", "{", "key", ":", "value", "for", "key", ",", "value", "in", "cls_def", ".", "items", "(", ")", "if", "key", ".", "startswith", "(", "\"kds_es\"", ")", "}", "for", ...
Reads through the class defs and gets the related es class defintions Args: ----- class_defs: RdfDataset of class definitions
[ "Reads", "through", "the", "class", "defs", "and", "gets", "the", "related", "es", "class", "defintions" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L721-L734
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
get_rml_processors
def get_rml_processors(es_defs): """ Returns the es_defs with the instaniated rml_processor Args: ----- es_defs: the rdf_class elacticsearch defnitions cls_name: the name of the tied class """ proc_defs = es_defs.get("kds_esRmlProcessor", []) if proc_defs: new_defs =...
python
def get_rml_processors(es_defs): """ Returns the es_defs with the instaniated rml_processor Args: ----- es_defs: the rdf_class elacticsearch defnitions cls_name: the name of the tied class """ proc_defs = es_defs.get("kds_esRmlProcessor", []) if proc_defs: new_defs =...
[ "def", "get_rml_processors", "(", "es_defs", ")", ":", "proc_defs", "=", "es_defs", ".", "get", "(", "\"kds_esRmlProcessor\"", ",", "[", "]", ")", "if", "proc_defs", ":", "new_defs", "=", "[", "]", "for", "proc", "in", "proc_defs", ":", "params", "=", "p...
Returns the es_defs with the instaniated rml_processor Args: ----- es_defs: the rdf_class elacticsearch defnitions cls_name: the name of the tied class
[ "Returns", "the", "es_defs", "with", "the", "instaniated", "rml_processor" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L736-L763
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
list_properties
def list_properties(cls): """ returns a dictionary of properties assigned to the class""" rtn_dict = {} for attr in dir(cls): if attr not in ["properties", "__doc__", "doc"]: attr_val = getattr(cls, attr) if isinstance(attr_val, MODULE.rdfclass.RdfPropertyMeta): ...
python
def list_properties(cls): """ returns a dictionary of properties assigned to the class""" rtn_dict = {} for attr in dir(cls): if attr not in ["properties", "__doc__", "doc"]: attr_val = getattr(cls, attr) if isinstance(attr_val, MODULE.rdfclass.RdfPropertyMeta): ...
[ "def", "list_properties", "(", "cls", ")", ":", "rtn_dict", "=", "{", "}", "for", "attr", "in", "dir", "(", "cls", ")", ":", "if", "attr", "not", "in", "[", "\"properties\"", ",", "\"__doc__\"", ",", "\"doc\"", "]", ":", "attr_val", "=", "getattr", "...
returns a dictionary of properties assigned to the class
[ "returns", "a", "dictionary", "of", "properties", "assigned", "to", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L765-L774
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
remove_parents
def remove_parents(bases): """ removes the parent classes if one base is subclass of another""" if len(bases) < 2: return bases remove_i = [] bases = list(bases) for i, base in enumerate(bases): for j, other in enumerate(bases): # print(i, j, base, other, remove_i...
python
def remove_parents(bases): """ removes the parent classes if one base is subclass of another""" if len(bases) < 2: return bases remove_i = [] bases = list(bases) for i, base in enumerate(bases): for j, other in enumerate(bases): # print(i, j, base, other, remove_i...
[ "def", "remove_parents", "(", "bases", ")", ":", "if", "len", "(", "bases", ")", "<", "2", ":", "return", "bases", "remove_i", "=", "[", "]", "bases", "=", "list", "(", "bases", ")", "for", "i", ",", "base", "in", "enumerate", "(", "bases", ")", ...
removes the parent classes if one base is subclass of another
[ "removes", "the", "parent", "classes", "if", "one", "base", "is", "subclass", "of", "another" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L789-L809
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
get_query_kwargs
def get_query_kwargs(es_defs): """ Reads the es_defs and returns a dict of special kwargs to use when query for data of an instance of a class reference: rdfframework.sparl.queries.sparqlAllItemDataTemplate.rq """ rtn_dict = {} if es_defs: if es_defs.get("kds_esSpecialUnion"): ...
python
def get_query_kwargs(es_defs): """ Reads the es_defs and returns a dict of special kwargs to use when query for data of an instance of a class reference: rdfframework.sparl.queries.sparqlAllItemDataTemplate.rq """ rtn_dict = {} if es_defs: if es_defs.get("kds_esSpecialUnion"): ...
[ "def", "get_query_kwargs", "(", "es_defs", ")", ":", "rtn_dict", "=", "{", "}", "if", "es_defs", ":", "if", "es_defs", ".", "get", "(", "\"kds_esSpecialUnion\"", ")", ":", "rtn_dict", "[", "'special_union'", "]", "=", "es_defs", "[", "\"kds_esSpecialUnion\"", ...
Reads the es_defs and returns a dict of special kwargs to use when query for data of an instance of a class reference: rdfframework.sparl.queries.sparqlAllItemDataTemplate.rq
[ "Reads", "the", "es_defs", "and", "returns", "a", "dict", "of", "special", "kwargs", "to", "use", "when", "query", "for", "data", "of", "an", "instance", "of", "a", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L811-L826
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.add_property
def add_property(self, pred, obj): """ adds a property and its value to the class instance args: pred: the predicate/property to add obj: the value/object to add obj_method: *** No longer used. """ pred = Uri(pred) try: self[pred]....
python
def add_property(self, pred, obj): """ adds a property and its value to the class instance args: pred: the predicate/property to add obj: the value/object to add obj_method: *** No longer used. """ pred = Uri(pred) try: self[pred]....
[ "def", "add_property", "(", "self", ",", "pred", ",", "obj", ")", ":", "pred", "=", "Uri", "(", "pred", ")", "try", ":", "self", "[", "pred", "]", ".", "append", "(", "obj", ")", "# except AttributeError:", "# new_list = [self[pred]]", "# new_list.ap...
adds a property and its value to the class instance args: pred: the predicate/property to add obj: the value/object to add obj_method: *** No longer used.
[ "adds", "a", "property", "and", "its", "value", "to", "the", "class", "instance" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L194-L233
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.conv_json
def conv_json(self, uri_format="sparql_uri", add_ids=False): """ converts the class to a json compatable python dictionary Args: uri_format('sparql_uri','pyuri'): The format that uri values will be returned Returns: dict: a json compatabile python di...
python
def conv_json(self, uri_format="sparql_uri", add_ids=False): """ converts the class to a json compatable python dictionary Args: uri_format('sparql_uri','pyuri'): The format that uri values will be returned Returns: dict: a json compatabile python di...
[ "def", "conv_json", "(", "self", ",", "uri_format", "=", "\"sparql_uri\"", ",", "add_ids", "=", "False", ")", ":", "def", "convert_item", "(", "ivalue", ")", ":", "\"\"\" converts an idividual value to a json value\n\n Args:\n ivalue: value of the it...
converts the class to a json compatable python dictionary Args: uri_format('sparql_uri','pyuri'): The format that uri values will be returned Returns: dict: a json compatabile python dictionary
[ "converts", "the", "class", "to", "a", "json", "compatable", "python", "dictionary" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L245-L293
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.es_mapping
def es_mapping(cls, base_class=None, role='rdf_class', **kwargs): """ Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a s...
python
def es_mapping(cls, base_class=None, role='rdf_class', **kwargs): """ Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a s...
[ "def", "es_mapping", "(", "cls", ",", "base_class", "=", "None", ",", "role", "=", "'rdf_class'", ",", "*", "*", "kwargs", ")", ":", "def", "_prop_filter", "(", "prop", ",", "value", ",", "*", "*", "kwargs", ")", ":", "\"\"\" filters out props that should ...
Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a subject of an object. options are es_Nested or rdf_class
[ "Returns", "the", "es", "mapping", "for", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L296-L394
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.es_indexers
def es_indexers(cls, base_class=None, role='rdf_class', **kwargs): """ Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a ...
python
def es_indexers(cls, base_class=None, role='rdf_class', **kwargs): """ Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a ...
[ "def", "es_indexers", "(", "cls", ",", "base_class", "=", "None", ",", "role", "=", "'rdf_class'", ",", "*", "*", "kwargs", ")", ":", "def", "_prop_filter", "(", "prop", ",", "value", ",", "*", "*", "kwargs", ")", ":", "\"\"\" filters out props that should...
Returns the es mapping for the class args: ----- base_class: The root class being indexed role: the role states how the class should be mapped depending upon whether it is used as a subject of an object. options are es_Nested or rdf_class
[ "Returns", "the", "es", "mapping", "for", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L397-L464
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.bnode_id
def bnode_id(self): """ calculates the bnode id for the class """ if self.subject.type != 'bnode': return self.subject rtn_list = [] for prop in sorted(self): for value in sorted(self[prop]): rtn_list.append("%s%s" % (prop, value)) ...
python
def bnode_id(self): """ calculates the bnode id for the class """ if self.subject.type != 'bnode': return self.subject rtn_list = [] for prop in sorted(self): for value in sorted(self[prop]): rtn_list.append("%s%s" % (prop, value)) ...
[ "def", "bnode_id", "(", "self", ")", ":", "if", "self", ".", "subject", ".", "type", "!=", "'bnode'", ":", "return", "self", ".", "subject", "rtn_list", "=", "[", "]", "for", "prop", "in", "sorted", "(", "self", ")", ":", "for", "value", "in", "sor...
calculates the bnode id for the class
[ "calculates", "the", "bnode", "id", "for", "the", "class" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L466-L476
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.es_json
def es_json(self, role='rdf_class', remove_empty=True, **kwargs): """ Returns a JSON object of the class for insertion into es args: role: the role states how the class data should be returned depending upon whether it is used as a subject of an object. o...
python
def es_json(self, role='rdf_class', remove_empty=True, **kwargs): """ Returns a JSON object of the class for insertion into es args: role: the role states how the class data should be returned depending upon whether it is used as a subject of an object. o...
[ "def", "es_json", "(", "self", ",", "role", "=", "'rdf_class'", ",", "remove_empty", "=", "True", ",", "*", "*", "kwargs", ")", ":", "def", "test_idx_status", "(", "cls_inst", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Return True if the class has...
Returns a JSON object of the class for insertion into es args: role: the role states how the class data should be returned depending upon whether it is used as a subject of an object. options are kds_esNested or rdf_class remove_empty: True removes em...
[ "Returns", "a", "JSON", "object", "of", "the", "class", "for", "insertion", "into", "es" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L479-L588
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.get_rml
def get_rml(self, rml_def, **kwargs): """ returns the rml mapping output for specified mapping Args: ----- rml_def: The name of the mapping or a dictionary definition """ if isinstance(rml_def, str): rml_procs = self.es_defs.get("kds_esRmlProcesso...
python
def get_rml(self, rml_def, **kwargs): """ returns the rml mapping output for specified mapping Args: ----- rml_def: The name of the mapping or a dictionary definition """ if isinstance(rml_def, str): rml_procs = self.es_defs.get("kds_esRmlProcesso...
[ "def", "get_rml", "(", "self", ",", "rml_def", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "rml_def", ",", "str", ")", ":", "rml_procs", "=", "self", ".", "es_defs", ".", "get", "(", "\"kds_esRmlProcessor\"", ",", "[", "]", ")", "for"...
returns the rml mapping output for specified mapping Args: ----- rml_def: The name of the mapping or a dictionary definition
[ "returns", "the", "rml", "mapping", "output", "for", "specified", "mapping" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L590-L607
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase.get_all_rml
def get_all_rml(self, **kwargs): """ Returns a dictionary with the output of all the rml procceor results """ rml_procs = self.es_defs.get("kds_esRmlProcessor", []) role = kwargs.get('role') if role: rml_procs = [proc for proc in rml_procs ...
python
def get_all_rml(self, **kwargs): """ Returns a dictionary with the output of all the rml procceor results """ rml_procs = self.es_defs.get("kds_esRmlProcessor", []) role = kwargs.get('role') if role: rml_procs = [proc for proc in rml_procs ...
[ "def", "get_all_rml", "(", "self", ",", "*", "*", "kwargs", ")", ":", "rml_procs", "=", "self", ".", "es_defs", ".", "get", "(", "\"kds_esRmlProcessor\"", ",", "[", "]", ")", "role", "=", "kwargs", ".", "get", "(", "'role'", ")", "if", "role", ":", ...
Returns a dictionary with the output of all the rml procceor results
[ "Returns", "a", "dictionary", "with", "the", "output", "of", "all", "the", "rml", "procceor", "results" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L609-L622
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase._set_subject
def _set_subject(self, subject): """ sets the subject value for the class instance Args: subject(dict, Uri, str): the subject for the class instance """ # if not subject: # self.subject = def test_uri(value): """ test to see if the value is a ...
python
def _set_subject(self, subject): """ sets the subject value for the class instance Args: subject(dict, Uri, str): the subject for the class instance """ # if not subject: # self.subject = def test_uri(value): """ test to see if the value is a ...
[ "def", "_set_subject", "(", "self", ",", "subject", ")", ":", "# if not subject:", "# self.subject =", "def", "test_uri", "(", "value", ")", ":", "\"\"\" test to see if the value is a uri or bnode\n\n Returns: Uri or Bnode \"\"\"", "# .__wrapped__", "if", "not", ...
sets the subject value for the class instance Args: subject(dict, Uri, str): the subject for the class instance
[ "sets", "the", "subject", "value", "for", "the", "class", "instance" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L624-L658
KnowledgeLinks/rdfframework
rdfframework/rdfclass/rdfclass.py
RdfClassBase._initilize_props
def _initilize_props(self): """ Adds an intialized property to the class dictionary """ # if self.subject == "pyuri_aHR0cDovL3R1dHQuZWR1Lw==_": # pdb.set_trace() try: # pdb.set_trace() for prop in self.es_props: self[prop] = self.properties[pro...
python
def _initilize_props(self): """ Adds an intialized property to the class dictionary """ # if self.subject == "pyuri_aHR0cDovL3R1dHQuZWR1Lw==_": # pdb.set_trace() try: # pdb.set_trace() for prop in self.es_props: self[prop] = self.properties[pro...
[ "def", "_initilize_props", "(", "self", ")", ":", "# if self.subject == \"pyuri_aHR0cDovL3R1dHQuZWR1Lw==_\":", "# pdb.set_trace()", "try", ":", "# pdb.set_trace()", "for", "prop", "in", "self", ".", "es_props", ":", "self", "[", "prop", "]", "=", "self", ".", "p...
Adds an intialized property to the class dictionary
[ "Adds", "an", "intialized", "property", "to", "the", "class", "dictionary" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/rdfclass/rdfclass.py#L660-L689
jnmclarty/rrsm
rrsm/core.py
StateMachine.switch_to
def switch_to(self, newstate): """Switch to a new state newstate : int or string Can be either the value of the state, or the label of the state""" if type(newstate) is int: if newstate in self._states: self._curcode = newstate ...
python
def switch_to(self, newstate): """Switch to a new state newstate : int or string Can be either the value of the state, or the label of the state""" if type(newstate) is int: if newstate in self._states: self._curcode = newstate ...
[ "def", "switch_to", "(", "self", ",", "newstate", ")", ":", "if", "type", "(", "newstate", ")", "is", "int", ":", "if", "newstate", "in", "self", ".", "_states", ":", "self", ".", "_curcode", "=", "newstate", "else", ":", "raise", "Exception", "(", "...
Switch to a new state newstate : int or string Can be either the value of the state, or the label of the state
[ "Switch", "to", "a", "new", "state", "newstate", ":", "int", "or", "string", "Can", "be", "either", "the", "value", "of", "the", "state", "or", "the", "label", "of", "the", "state" ]
train
https://github.com/jnmclarty/rrsm/blob/d1c65792adbccaf9fb2b9fd252ea844053f9f59b/rrsm/core.py#L96-L110
devricks/soft_drf
soft_drf/api/viewsets/__init__.py
GenericViewSet.get_serializer_class
def get_serializer_class(self, action=None): """ Return the serializer class depending on request method. Attribute of proper serializer should be defined. """ if action is not None: return getattr(self, '%s_serializer_class' % action) else: return...
python
def get_serializer_class(self, action=None): """ Return the serializer class depending on request method. Attribute of proper serializer should be defined. """ if action is not None: return getattr(self, '%s_serializer_class' % action) else: return...
[ "def", "get_serializer_class", "(", "self", ",", "action", "=", "None", ")", ":", "if", "action", "is", "not", "None", ":", "return", "getattr", "(", "self", ",", "'%s_serializer_class'", "%", "action", ")", "else", ":", "return", "super", "(", "GenericVie...
Return the serializer class depending on request method. Attribute of proper serializer should be defined.
[ "Return", "the", "serializer", "class", "depending", "on", "request", "method", ".", "Attribute", "of", "proper", "serializer", "should", "be", "defined", "." ]
train
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/viewsets/__init__.py#L11-L19
devricks/soft_drf
soft_drf/api/viewsets/__init__.py
GenericViewSet.get_serializer
def get_serializer(self, *args, **kwargs): """ Returns the serializer instance that should be used to the given action. If any action was given, returns the serializer_class """ action = kwargs.pop('action', None) serializer_class = self.get_serializer_class(acti...
python
def get_serializer(self, *args, **kwargs): """ Returns the serializer instance that should be used to the given action. If any action was given, returns the serializer_class """ action = kwargs.pop('action', None) serializer_class = self.get_serializer_class(acti...
[ "def", "get_serializer", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "action", "=", "kwargs", ".", "pop", "(", "'action'", ",", "None", ")", "serializer_class", "=", "self", ".", "get_serializer_class", "(", "action", ")", "kwargs",...
Returns the serializer instance that should be used to the given action. If any action was given, returns the serializer_class
[ "Returns", "the", "serializer", "instance", "that", "should", "be", "used", "to", "the", "given", "action", ".", "If", "any", "action", "was", "given", "returns", "the", "serializer_class" ]
train
https://github.com/devricks/soft_drf/blob/1869b13f9341bfcebd931059e93de2bc38570da3/soft_drf/api/viewsets/__init__.py#L21-L32
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.open
def open(self, autocommit=False): """Call-through to data_access.open.""" self.data_access.open(autocommit=autocommit) return self
python
def open(self, autocommit=False): """Call-through to data_access.open.""" self.data_access.open(autocommit=autocommit) return self
[ "def", "open", "(", "self", ",", "autocommit", "=", "False", ")", ":", "self", ".", "data_access", ".", "open", "(", "autocommit", "=", "autocommit", ")", "return", "self" ]
Call-through to data_access.open.
[ "Call", "-", "through", "to", "data_access", ".", "open", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L34-L37
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.close
def close(self, commit=True): """Call-through to data_access.close.""" self.data_access.close(commit=commit) return self
python
def close(self, commit=True): """Call-through to data_access.close.""" self.data_access.close(commit=commit) return self
[ "def", "close", "(", "self", ",", "commit", "=", "True", ")", ":", "self", ".", "data_access", ".", "close", "(", "commit", "=", "commit", ")", "return", "self" ]
Call-through to data_access.close.
[ "Call", "-", "through", "to", "data_access", ".", "close", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L39-L42
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.setup
def setup(self): """Creates the default relations and transfers tables. The SQL used may not work on all databases. (It was written for SQLite3) """ cmds = [ """ create table if not exists relations ( id integer not null primary key, name text not null unique, ...
python
def setup(self): """Creates the default relations and transfers tables. The SQL used may not work on all databases. (It was written for SQLite3) """ cmds = [ """ create table if not exists relations ( id integer not null primary key, name text not null unique, ...
[ "def", "setup", "(", "self", ")", ":", "cmds", "=", "[", "\"\"\"\n create table if not exists relations (\n id integer not null primary key,\n name text not null unique,\n completed_at datetime\n );\n \"\"\"", ",", "\"\"\"\n create table if ...
Creates the default relations and transfers tables. The SQL used may not work on all databases. (It was written for SQLite3)
[ "Creates", "the", "default", "relations", "and", "transfers", "tables", ".", "The", "SQL", "used", "may", "not", "work", "on", "all", "databases", ".", "(", "It", "was", "written", "for", "SQLite3", ")" ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L54-L82
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.reset
def reset(self, relation_name=None): """Reset the transfer info for a particular relation, or if none is given, for all relations. """ if relation_name is not None: self.data_access.delete("relations", dict(name=relation_name)) else: self.data_access.delete("relations", "1=1") return sel...
python
def reset(self, relation_name=None): """Reset the transfer info for a particular relation, or if none is given, for all relations. """ if relation_name is not None: self.data_access.delete("relations", dict(name=relation_name)) else: self.data_access.delete("relations", "1=1") return sel...
[ "def", "reset", "(", "self", ",", "relation_name", "=", "None", ")", ":", "if", "relation_name", "is", "not", "None", ":", "self", ".", "data_access", ".", "delete", "(", "\"relations\"", ",", "dict", "(", "name", "=", "relation_name", ")", ")", "else", ...
Reset the transfer info for a particular relation, or if none is given, for all relations.
[ "Reset", "the", "transfer", "info", "for", "a", "particular", "relation", "or", "if", "none", "is", "given", "for", "all", "relations", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L89-L96
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.start_transfer
def start_transfer(self, relation_name): """Write records to the data source indicating that a transfer has been started for a particular relation. """ self.reset(relation_name) relation = Relation(name=relation_name) self.data_access.insert_model(relation) return relation
python
def start_transfer(self, relation_name): """Write records to the data source indicating that a transfer has been started for a particular relation. """ self.reset(relation_name) relation = Relation(name=relation_name) self.data_access.insert_model(relation) return relation
[ "def", "start_transfer", "(", "self", ",", "relation_name", ")", ":", "self", ".", "reset", "(", "relation_name", ")", "relation", "=", "Relation", "(", "name", "=", "relation_name", ")", "self", ".", "data_access", ".", "insert_model", "(", "relation", ")",...
Write records to the data source indicating that a transfer has been started for a particular relation.
[ "Write", "records", "to", "the", "data", "source", "indicating", "that", "a", "transfer", "has", "been", "started", "for", "a", "particular", "relation", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L98-L105
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.register_transfer
def register_transfer(self, relation, old_id, new_id): """Register the old and new ids for a particular record in a relation.""" transfer = Transfer(relation_id=relation.id, old_id=old_id, new_id=new_id) self.data_access.insert_model(transfer) return transfer
python
def register_transfer(self, relation, old_id, new_id): """Register the old and new ids for a particular record in a relation.""" transfer = Transfer(relation_id=relation.id, old_id=old_id, new_id=new_id) self.data_access.insert_model(transfer) return transfer
[ "def", "register_transfer", "(", "self", ",", "relation", ",", "old_id", ",", "new_id", ")", ":", "transfer", "=", "Transfer", "(", "relation_id", "=", "relation", ".", "id", ",", "old_id", "=", "old_id", ",", "new_id", "=", "new_id", ")", "self", ".", ...
Register the old and new ids for a particular record in a relation.
[ "Register", "the", "old", "and", "new", "ids", "for", "a", "particular", "record", "in", "a", "relation", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L107-L111
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.complete_transfer
def complete_transfer(self, relation, cleanup=True): """Write records to the data source indicating that a transfer has been completed for a particular relation. """ relation.completed_at = utc_now().isoformat() self.data_access.update_model(relation) if cleanup: self.cleanup() return ...
python
def complete_transfer(self, relation, cleanup=True): """Write records to the data source indicating that a transfer has been completed for a particular relation. """ relation.completed_at = utc_now().isoformat() self.data_access.update_model(relation) if cleanup: self.cleanup() return ...
[ "def", "complete_transfer", "(", "self", ",", "relation", ",", "cleanup", "=", "True", ")", ":", "relation", ".", "completed_at", "=", "utc_now", "(", ")", ".", "isoformat", "(", ")", "self", ".", "data_access", ".", "update_model", "(", "relation", ")", ...
Write records to the data source indicating that a transfer has been completed for a particular relation.
[ "Write", "records", "to", "the", "data", "source", "indicating", "that", "a", "transfer", "has", "been", "completed", "for", "a", "particular", "relation", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L113-L121
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.is_transfer_complete
def is_transfer_complete(self, relation_name): """Checks to see if a tansfer has been completed.""" phold = self.data_access.sql_writer.to_placeholder() return self.data_access.find_model( Relation, ("name = {0} and completed_at is not null".format(phold), [relation_name])) is not None
python
def is_transfer_complete(self, relation_name): """Checks to see if a tansfer has been completed.""" phold = self.data_access.sql_writer.to_placeholder() return self.data_access.find_model( Relation, ("name = {0} and completed_at is not null".format(phold), [relation_name])) is not None
[ "def", "is_transfer_complete", "(", "self", ",", "relation_name", ")", ":", "phold", "=", "self", ".", "data_access", ".", "sql_writer", ".", "to_placeholder", "(", ")", "return", "self", ".", "data_access", ".", "find_model", "(", "Relation", ",", "(", "\"n...
Checks to see if a tansfer has been completed.
[ "Checks", "to", "see", "if", "a", "tansfer", "has", "been", "completed", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L123-L128
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.get_new_id
def get_new_id(self, relation_name, old_id, strict=False): """Given a relation name and its old ID, get the new ID for a relation. If strict is true, an error is thrown if no record is found for the relation and old ID. """ record = self.data_access.find( "relations as r inner join transfers as t ...
python
def get_new_id(self, relation_name, old_id, strict=False): """Given a relation name and its old ID, get the new ID for a relation. If strict is true, an error is thrown if no record is found for the relation and old ID. """ record = self.data_access.find( "relations as r inner join transfers as t ...
[ "def", "get_new_id", "(", "self", ",", "relation_name", ",", "old_id", ",", "strict", "=", "False", ")", ":", "record", "=", "self", ".", "data_access", ".", "find", "(", "\"relations as r inner join transfers as t on r.id = t.relation_id\"", ",", "(", "(", "\"r.n...
Given a relation name and its old ID, get the new ID for a relation. If strict is true, an error is thrown if no record is found for the relation and old ID.
[ "Given", "a", "relation", "name", "and", "its", "old", "ID", "get", "the", "new", "ID", "for", "a", "relation", ".", "If", "strict", "is", "true", "an", "error", "is", "thrown", "if", "no", "record", "is", "found", "for", "the", "relation", "and", "o...
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L130-L142
treycucco/bidon
bidon/experimental/transfer_tracker.py
TransferTracker.id_getter
def id_getter(self, relation_name, strict=False): """Returns a function that accepts an old_id and returns the new ID for the enclosed relation name.""" def get_id(old_id): """Get the new ID for the enclosed relation, given an old ID.""" return self.get_new_id(relation_name, old_id, strict) ...
python
def id_getter(self, relation_name, strict=False): """Returns a function that accepts an old_id and returns the new ID for the enclosed relation name.""" def get_id(old_id): """Get the new ID for the enclosed relation, given an old ID.""" return self.get_new_id(relation_name, old_id, strict) ...
[ "def", "id_getter", "(", "self", ",", "relation_name", ",", "strict", "=", "False", ")", ":", "def", "get_id", "(", "old_id", ")", ":", "\"\"\"Get the new ID for the enclosed relation, given an old ID.\"\"\"", "return", "self", ".", "get_new_id", "(", "relation_name",...
Returns a function that accepts an old_id and returns the new ID for the enclosed relation name.
[ "Returns", "a", "function", "that", "accepts", "an", "old_id", "and", "returns", "the", "new", "ID", "for", "the", "enclosed", "relation", "name", "." ]
train
https://github.com/treycucco/bidon/blob/d9f24596841d0e69e8ac70a1d1a1deecea95e340/bidon/experimental/transfer_tracker.py#L144-L150
henrysher/kotocore
kotocore/collections.py
CollectionDetails.requires_loaded
def requires_loaded(func): """ A decorator to ensure the resource data is loaded. """ def _wrapper(self, *args, **kwargs): # If we don't have data, go load it. if self._loaded_data is None: self._loaded_data = self.loader.load(self.service_name) ...
python
def requires_loaded(func): """ A decorator to ensure the resource data is loaded. """ def _wrapper(self, *args, **kwargs): # If we don't have data, go load it. if self._loaded_data is None: self._loaded_data = self.loader.load(self.service_name) ...
[ "def", "requires_loaded", "(", "func", ")", ":", "def", "_wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# If we don't have data, go load it.", "if", "self", ".", "_loaded_data", "is", "None", ":", "self", ".", "_loaded_data", ...
A decorator to ensure the resource data is loaded.
[ "A", "decorator", "to", "ensure", "the", "resource", "data", "is", "loaded", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L56-L67
henrysher/kotocore
kotocore/collections.py
CollectionDetails.result_key_for
def result_key_for(self, op_name): """ Checks for the presence of a ``result_key``, which defines what data should make up an instance. Returns ``None`` if there is no ``result_key``. :param op_name: The operation name to look for the ``result_key`` in. :type op_name: s...
python
def result_key_for(self, op_name): """ Checks for the presence of a ``result_key``, which defines what data should make up an instance. Returns ``None`` if there is no ``result_key``. :param op_name: The operation name to look for the ``result_key`` in. :type op_name: s...
[ "def", "result_key_for", "(", "self", ",", "op_name", ")", ":", "ops", "=", "self", ".", "collection_data", ".", "get", "(", "'operations'", ",", "{", "}", ")", "op", "=", "ops", ".", "get", "(", "op_name", ",", "{", "}", ")", "key", "=", "op", "...
Checks for the presence of a ``result_key``, which defines what data should make up an instance. Returns ``None`` if there is no ``result_key``. :param op_name: The operation name to look for the ``result_key`` in. :type op_name: string :returns: The expected key to look for d...
[ "Checks", "for", "the", "presence", "of", "a", "result_key", "which", "defines", "what", "data", "should", "make", "up", "an", "instance", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L147-L163
henrysher/kotocore
kotocore/collections.py
Collection.full_update_params
def full_update_params(self, conn_method_name, params): """ When a API method on the collection is called, this goes through the params & run a series of hooks to allow for updating those parameters. Typically, this method is **NOT** call by the user. However, the user may wish ...
python
def full_update_params(self, conn_method_name, params): """ When a API method on the collection is called, this goes through the params & run a series of hooks to allow for updating those parameters. Typically, this method is **NOT** call by the user. However, the user may wish ...
[ "def", "full_update_params", "(", "self", ",", "conn_method_name", ",", "params", ")", ":", "# We'll check for custom methods to do addition, specific work.", "custom_method_name", "=", "'update_params_{0}'", ".", "format", "(", "conn_method_name", ")", "custom_method", "=", ...
When a API method on the collection is called, this goes through the params & run a series of hooks to allow for updating those parameters. Typically, this method is **NOT** call by the user. However, the user may wish to define other methods (i.e. ``update_params`` to work with multipl...
[ "When", "a", "API", "method", "on", "the", "collection", "is", "called", "this", "goes", "through", "the", "params", "&", "run", "a", "series", "of", "hooks", "to", "allow", "for", "updating", "those", "parameters", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L312-L344
henrysher/kotocore
kotocore/collections.py
Collection.full_post_process
def full_post_process(self, conn_method_name, result): """ When a response from an API method call is received, this goes through the returned data & run a series of hooks to allow for handling that data. Typically, this method is **NOT** call by the user. However, the user ...
python
def full_post_process(self, conn_method_name, result): """ When a response from an API method call is received, this goes through the returned data & run a series of hooks to allow for handling that data. Typically, this method is **NOT** call by the user. However, the user ...
[ "def", "full_post_process", "(", "self", ",", "conn_method_name", ",", "result", ")", ":", "result", "=", "self", ".", "post_process", "(", "conn_method_name", ",", "result", ")", "# We'll check for custom methods to do addition, specific work.", "custom_method_name", "="...
When a response from an API method call is received, this goes through the returned data & run a series of hooks to allow for handling that data. Typically, this method is **NOT** call by the user. However, the user may wish to define other methods (i.e. ``post_process`` to work with ...
[ "When", "a", "response", "from", "an", "API", "method", "call", "is", "received", "this", "goes", "through", "the", "returned", "data", "&", "run", "a", "series", "of", "hooks", "to", "allow", "for", "handling", "that", "data", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L371-L403
henrysher/kotocore
kotocore/collections.py
Collection.post_process_create
def post_process_create(self, result): """ An example of the ``post_process`` extensions, this returns an instance of the ``Resource`` created (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :returns: A ``Resou...
python
def post_process_create(self, result): """ An example of the ``post_process`` extensions, this returns an instance of the ``Resource`` created (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :returns: A ``Resou...
[ "def", "post_process_create", "(", "self", ",", "result", ")", ":", "# We need to possibly drill into the response & get out the data here.", "# Check for a result key.", "result_key", "=", "self", ".", "_details", ".", "result_key_for", "(", "'create'", ")", "if", "not", ...
An example of the ``post_process`` extensions, this returns an instance of the ``Resource`` created (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :returns: A ``Resource`` subclass
[ "An", "example", "of", "the", "post_process", "extensions", "this", "returns", "an", "instance", "of", "the", "Resource", "created", "(", "rather", "than", "just", "a", "bag", "of", "data", ")", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L427-L444
henrysher/kotocore
kotocore/collections.py
Collection.post_process_each
def post_process_each(self, result): """ An example of the ``post_process`` extensions, this returns a set of instances of the ``Resource`` fetched (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :retur...
python
def post_process_each(self, result): """ An example of the ``post_process`` extensions, this returns a set of instances of the ``Resource`` fetched (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :retur...
[ "def", "post_process_each", "(", "self", ",", "result", ")", ":", "# We need to possibly drill into the response & get out the data here.", "# Check for a result key.", "result_key", "=", "self", ".", "_details", ".", "result_key_for", "(", "'each'", ")", "if", "not", "re...
An example of the ``post_process`` extensions, this returns a set of instances of the ``Resource`` fetched (rather than just a bag of data). :param result: The full data handed back from the API. :type result: dict :returns: A list of ``Resource`` subclass
[ "An", "example", "of", "the", "post_process", "extensions", "this", "returns", "a", "set", "of", "instances", "of", "the", "Resource", "fetched", "(", "rather", "than", "just", "a", "bag", "of", "data", ")", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L446-L464
henrysher/kotocore
kotocore/collections.py
Collection.build_resource
def build_resource(self, data): """ Given some data, builds the correct/matching ``Resource`` subclass for the ``Collection``. Useful in things like ``create`` & ``each``. :param result: The data for an instance handed back from the API. :type result: dict :returns: A `...
python
def build_resource(self, data): """ Given some data, builds the correct/matching ``Resource`` subclass for the ``Collection``. Useful in things like ``create`` & ``each``. :param result: The data for an instance handed back from the API. :type result: dict :returns: A `...
[ "def", "build_resource", "(", "self", ",", "data", ")", ":", "if", "self", ".", "_res_class", "is", "None", ":", "self", ".", "_res_class", "=", "self", ".", "_details", ".", "session", ".", "get_resource", "(", "self", ".", "_details", ".", "service_nam...
Given some data, builds the correct/matching ``Resource`` subclass for the ``Collection``. Useful in things like ``create`` & ``each``. :param result: The data for an instance handed back from the API. :type result: dict :returns: A ``Resource`` subclass
[ "Given", "some", "data", "builds", "the", "correct", "/", "matching", "Resource", "subclass", "for", "the", "Collection", ".", "Useful", "in", "things", "like", "create", "&", "each", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L466-L488
henrysher/kotocore
kotocore/collections.py
CollectionFactory.construct_for
def construct_for(self, service_name, collection_name, base_class=None): """ Builds a new, specialized ``Collection`` subclass as part of a given service. This will load the ``ResourceJSON``, determine the correct mappings/methods & constructs a brand new class with those method...
python
def construct_for(self, service_name, collection_name, base_class=None): """ Builds a new, specialized ``Collection`` subclass as part of a given service. This will load the ``ResourceJSON``, determine the correct mappings/methods & constructs a brand new class with those method...
[ "def", "construct_for", "(", "self", ",", "service_name", ",", "collection_name", ",", "base_class", "=", "None", ")", ":", "details", "=", "self", ".", "details_class", "(", "self", ".", "session", ",", "service_name", ",", "collection_name", ",", "loader", ...
Builds a new, specialized ``Collection`` subclass as part of a given service. This will load the ``ResourceJSON``, determine the correct mappings/methods & constructs a brand new class with those methods on it. :param service_name: The name of the service to construct a resourc...
[ "Builds", "a", "new", "specialized", "Collection", "subclass", "as", "part", "of", "a", "given", "service", "." ]
train
https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/collections.py#L549-L594
svasilev94/GraphLibrary
graphlibrary/first_search.py
BFS
def BFS(G, start): """ Algorithm for breadth-first searching the vertices of a graph. """ if start not in G.vertices: raise GraphInsertError("Vertex %s doesn't exist." % (start,)) color = {} pred = {} dist = {} queue = Queue() queue.put(start) for vertex in G.v...
python
def BFS(G, start): """ Algorithm for breadth-first searching the vertices of a graph. """ if start not in G.vertices: raise GraphInsertError("Vertex %s doesn't exist." % (start,)) color = {} pred = {} dist = {} queue = Queue() queue.put(start) for vertex in G.v...
[ "def", "BFS", "(", "G", ",", "start", ")", ":", "if", "start", "not", "in", "G", ".", "vertices", ":", "raise", "GraphInsertError", "(", "\"Vertex %s doesn't exist.\"", "%", "(", "start", ",", ")", ")", "color", "=", "{", "}", "pred", "=", "{", "}", ...
Algorithm for breadth-first searching the vertices of a graph.
[ "Algorithm", "for", "breadth", "-", "first", "searching", "the", "vertices", "of", "a", "graph", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/first_search.py#L8-L32
svasilev94/GraphLibrary
graphlibrary/first_search.py
BFS_Tree
def BFS_Tree(G, start): """ Return an oriented tree constructed from bfs starting at 'start'. """ if start not in G.vertices: raise GraphInsertError("Vertex %s doesn't exist." % (start,)) pred = BFS(G, start) T = digraph.DiGraph() queue = Queue() queue.put(start) wh...
python
def BFS_Tree(G, start): """ Return an oriented tree constructed from bfs starting at 'start'. """ if start not in G.vertices: raise GraphInsertError("Vertex %s doesn't exist." % (start,)) pred = BFS(G, start) T = digraph.DiGraph() queue = Queue() queue.put(start) wh...
[ "def", "BFS_Tree", "(", "G", ",", "start", ")", ":", "if", "start", "not", "in", "G", ".", "vertices", ":", "raise", "GraphInsertError", "(", "\"Vertex %s doesn't exist.\"", "%", "(", "start", ",", ")", ")", "pred", "=", "BFS", "(", "G", ",", "start", ...
Return an oriented tree constructed from bfs starting at 'start'.
[ "Return", "an", "oriented", "tree", "constructed", "from", "bfs", "starting", "at", "start", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/first_search.py#L35-L51
svasilev94/GraphLibrary
graphlibrary/first_search.py
DFS
def DFS(G): """ Algorithm for depth-first searching the vertices of a graph. """ if not G.vertices: raise GraphInsertError("This graph have no vertices.") color = {} pred = {} reach = {} finish = {} def DFSvisit(G, current, time): color[current] = 'grey' ...
python
def DFS(G): """ Algorithm for depth-first searching the vertices of a graph. """ if not G.vertices: raise GraphInsertError("This graph have no vertices.") color = {} pred = {} reach = {} finish = {} def DFSvisit(G, current, time): color[current] = 'grey' ...
[ "def", "DFS", "(", "G", ")", ":", "if", "not", "G", ".", "vertices", ":", "raise", "GraphInsertError", "(", "\"This graph have no vertices.\"", ")", "color", "=", "{", "}", "pred", "=", "{", "}", "reach", "=", "{", "}", "finish", "=", "{", "}", "def"...
Algorithm for depth-first searching the vertices of a graph.
[ "Algorithm", "for", "depth", "-", "first", "searching", "the", "vertices", "of", "a", "graph", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/first_search.py#L54-L92
svasilev94/GraphLibrary
graphlibrary/first_search.py
DFS_Tree
def DFS_Tree(G): """ Return an oriented tree constructed from dfs. """ if not G.vertices: raise GraphInsertError("This graph have no vertices.") pred = {} T = digraph.DiGraph() vertex_data = DFS(G) for vertex in vertex_data: pred[vertex] = vertex_data[vertex][0]...
python
def DFS_Tree(G): """ Return an oriented tree constructed from dfs. """ if not G.vertices: raise GraphInsertError("This graph have no vertices.") pred = {} T = digraph.DiGraph() vertex_data = DFS(G) for vertex in vertex_data: pred[vertex] = vertex_data[vertex][0]...
[ "def", "DFS_Tree", "(", "G", ")", ":", "if", "not", "G", ".", "vertices", ":", "raise", "GraphInsertError", "(", "\"This graph have no vertices.\"", ")", "pred", "=", "{", "}", "T", "=", "digraph", ".", "DiGraph", "(", ")", "vertex_data", "=", "DFS", "("...
Return an oriented tree constructed from dfs.
[ "Return", "an", "oriented", "tree", "constructed", "from", "dfs", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/first_search.py#L95-L116
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
exception_handler_v20
def exception_handler_v20(status_code, error_content): """Exception handler for API v2.0 client. This routine generates the appropriate Neutron exception according to the contents of the response body. :param status_code: HTTP error status code :param error_content: deserialized body of error resp...
python
def exception_handler_v20(status_code, error_content): """Exception handler for API v2.0 client. This routine generates the appropriate Neutron exception according to the contents of the response body. :param status_code: HTTP error status code :param error_content: deserialized body of error resp...
[ "def", "exception_handler_v20", "(", "status_code", ",", "error_content", ")", ":", "error_dict", "=", "None", "request_ids", "=", "error_content", ".", "request_ids", "if", "isinstance", "(", "error_content", ",", "dict", ")", ":", "error_dict", "=", "error_conte...
Exception handler for API v2.0 client. This routine generates the appropriate Neutron exception according to the contents of the response body. :param status_code: HTTP error status code :param error_content: deserialized body of error response
[ "Exception", "handler", "for", "API", "v2", ".", "0", "client", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L39-L85
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
_RequestIdMixin._append_request_ids
def _append_request_ids(self, resp): """Add request_ids as an attribute to the object :param resp: Response object or list of Response objects """ if isinstance(resp, list): # Add list of request_ids if response is of type list. for resp_obj in resp: ...
python
def _append_request_ids(self, resp): """Add request_ids as an attribute to the object :param resp: Response object or list of Response objects """ if isinstance(resp, list): # Add list of request_ids if response is of type list. for resp_obj in resp: ...
[ "def", "_append_request_ids", "(", "self", ",", "resp", ")", ":", "if", "isinstance", "(", "resp", ",", "list", ")", ":", "# Add list of request_ids if response is of type list.", "for", "resp_obj", "in", "resp", ":", "self", ".", "_append_request_id", "(", "resp_...
Add request_ids as an attribute to the object :param resp: Response object or list of Response objects
[ "Add", "request_ids", "as", "an", "attribute", "to", "the", "object" ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L97-L108
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
ClientBase.serialize
def serialize(self, data): """Serializes a dictionary into JSON. A dictionary with a single key can be passed and it can contain any structure. """ if data is None: return None elif isinstance(data, dict): return serializer.Serializer().serialize(...
python
def serialize(self, data): """Serializes a dictionary into JSON. A dictionary with a single key can be passed and it can contain any structure. """ if data is None: return None elif isinstance(data, dict): return serializer.Serializer().serialize(...
[ "def", "serialize", "(", "self", ",", "data", ")", ":", "if", "data", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "data", ",", "dict", ")", ":", "return", "serializer", ".", "Serializer", "(", ")", ".", "serialize", "(", "data", "...
Serializes a dictionary into JSON. A dictionary with a single key can be passed and it can contain any structure.
[ "Serializes", "a", "dictionary", "into", "JSON", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L292-L304
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
ClientBase.deserialize
def deserialize(self, data, status_code): """Deserializes a JSON string into a dictionary.""" if status_code == 204: return data return serializer.Serializer().deserialize( data)['body']
python
def deserialize(self, data, status_code): """Deserializes a JSON string into a dictionary.""" if status_code == 204: return data return serializer.Serializer().deserialize( data)['body']
[ "def", "deserialize", "(", "self", ",", "data", ",", "status_code", ")", ":", "if", "status_code", "==", "204", ":", "return", "data", "return", "serializer", ".", "Serializer", "(", ")", ".", "deserialize", "(", "data", ")", "[", "'body'", "]" ]
Deserializes a JSON string into a dictionary.
[ "Deserializes", "a", "JSON", "string", "into", "a", "dictionary", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L306-L311
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
ClientBase.retry_request
def retry_request(self, method, action, body=None, headers=None, params=None): """Call do_request with the default retry configuration. Only idempotent requests should retry failed connection attempts. :raises: ConnectionFailed if the maximum # of retries is exceeded ...
python
def retry_request(self, method, action, body=None, headers=None, params=None): """Call do_request with the default retry configuration. Only idempotent requests should retry failed connection attempts. :raises: ConnectionFailed if the maximum # of retries is exceeded ...
[ "def", "retry_request", "(", "self", ",", "method", ",", "action", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "params", "=", "None", ")", ":", "max_attempts", "=", "self", ".", "retries", "+", "1", "for", "i", "in", "range", "(", "...
Call do_request with the default retry configuration. Only idempotent requests should retry failed connection attempts. :raises: ConnectionFailed if the maximum # of retries is exceeded
[ "Call", "do_request", "with", "the", "default", "retry", "configuration", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L313-L339
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.list_ext
def list_ext(self, collection, path, retrieve_all, **_params): """Client extension hook for list.""" return self.list(collection, path, retrieve_all, **_params)
python
def list_ext(self, collection, path, retrieve_all, **_params): """Client extension hook for list.""" return self.list(collection, path, retrieve_all, **_params)
[ "def", "list_ext", "(", "self", ",", "collection", ",", "path", ",", "retrieve_all", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "collection", ",", "path", ",", "retrieve_all", ",", "*", "*", "_params", ")" ]
Client extension hook for list.
[ "Client", "extension", "hook", "for", "list", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L571-L573
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_ext
def show_ext(self, path, id, **_params): """Client extension hook for show.""" return self.get(path % id, params=_params)
python
def show_ext(self, path, id, **_params): """Client extension hook for show.""" return self.get(path % id, params=_params)
[ "def", "show_ext", "(", "self", ",", "path", ",", "id", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "path", "%", "id", ",", "params", "=", "_params", ")" ]
Client extension hook for show.
[ "Client", "extension", "hook", "for", "show", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L575-L577
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.update_ext
def update_ext(self, path, id, body=None): """Client extension hook for update.""" return self.put(path % id, body=body)
python
def update_ext(self, path, id, body=None): """Client extension hook for update.""" return self.put(path % id, body=body)
[ "def", "update_ext", "(", "self", ",", "path", ",", "id", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "path", "%", "id", ",", "body", "=", "body", ")" ]
Client extension hook for update.
[ "Client", "extension", "hook", "for", "update", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L583-L585
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_quota
def show_quota(self, project_id, **_params): """Fetch information of a certain project's quotas.""" return self.get(self.quota_path % (project_id), params=_params)
python
def show_quota(self, project_id, **_params): """Fetch information of a certain project's quotas.""" return self.get(self.quota_path % (project_id), params=_params)
[ "def", "show_quota", "(", "self", ",", "project_id", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "quota_path", "%", "(", "project_id", ")", ",", "params", "=", "_params", ")" ]
Fetch information of a certain project's quotas.
[ "Fetch", "information", "of", "a", "certain", "project", "s", "quotas", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L601-L603
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.update_quota
def update_quota(self, project_id, body=None): """Update a project's quotas.""" return self.put(self.quota_path % (project_id), body=body)
python
def update_quota(self, project_id, body=None): """Update a project's quotas.""" return self.put(self.quota_path % (project_id), body=body)
[ "def", "update_quota", "(", "self", ",", "project_id", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "quota_path", "%", "(", "project_id", ")", ",", "body", "=", "body", ")" ]
Update a project's quotas.
[ "Update", "a", "project", "s", "quotas", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L607-L609
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_extension
def show_extension(self, ext_alias, **_params): """Fetches information of a certain extension.""" return self.get(self.extension_path % ext_alias, params=_params)
python
def show_extension(self, ext_alias, **_params): """Fetches information of a certain extension.""" return self.get(self.extension_path % ext_alias, params=_params)
[ "def", "show_extension", "(", "self", ",", "ext_alias", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "extension_path", "%", "ext_alias", ",", "params", "=", "_params", ")" ]
Fetches information of a certain extension.
[ "Fetches", "information", "of", "a", "certain", "extension", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L621-L623
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.list_ports
def list_ports(self, retrieve_all=True, **_params): """Fetches a list of all ports for a project.""" # Pass filters in "params" argument to do_request return self.list('ports', self.ports_path, retrieve_all, **_params)
python
def list_ports(self, retrieve_all=True, **_params): """Fetches a list of all ports for a project.""" # Pass filters in "params" argument to do_request return self.list('ports', self.ports_path, retrieve_all, **_params)
[ "def", "list_ports", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "# Pass filters in \"params\" argument to do_request", "return", "self", ".", "list", "(", "'ports'", ",", "self", ".", "ports_path", ",", "retrieve_all", ","...
Fetches a list of all ports for a project.
[ "Fetches", "a", "list", "of", "all", "ports", "for", "a", "project", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L625-L629
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_port
def show_port(self, port, **_params): """Fetches information of a certain port.""" return self.get(self.port_path % (port), params=_params)
python
def show_port(self, port, **_params): """Fetches information of a certain port.""" return self.get(self.port_path % (port), params=_params)
[ "def", "show_port", "(", "self", ",", "port", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "port_path", "%", "(", "port", ")", ",", "params", "=", "_params", ")" ]
Fetches information of a certain port.
[ "Fetches", "information", "of", "a", "certain", "port", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L631-L633
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.update_port
def update_port(self, port, body=None): """Updates a port.""" return self.put(self.port_path % (port), body=body)
python
def update_port(self, port, body=None): """Updates a port.""" return self.put(self.port_path % (port), body=body)
[ "def", "update_port", "(", "self", ",", "port", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "port_path", "%", "(", "port", ")", ",", "body", "=", "body", ")" ]
Updates a port.
[ "Updates", "a", "port", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L639-L641
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.list_networks
def list_networks(self, retrieve_all=True, **_params): """Fetches a list of all networks for a project.""" # Pass filters in "params" argument to do_request return self.list('networks', self.networks_path, retrieve_all, **_params)
python
def list_networks(self, retrieve_all=True, **_params): """Fetches a list of all networks for a project.""" # Pass filters in "params" argument to do_request return self.list('networks', self.networks_path, retrieve_all, **_params)
[ "def", "list_networks", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "# Pass filters in \"params\" argument to do_request", "return", "self", ".", "list", "(", "'networks'", ",", "self", ".", "networks_path", ",", "retrieve_al...
Fetches a list of all networks for a project.
[ "Fetches", "a", "list", "of", "all", "networks", "for", "a", "project", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L647-L651
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_network
def show_network(self, network, **_params): """Fetches information of a certain network.""" return self.get(self.network_path % (network), params=_params)
python
def show_network(self, network, **_params): """Fetches information of a certain network.""" return self.get(self.network_path % (network), params=_params)
[ "def", "show_network", "(", "self", ",", "network", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "network_path", "%", "(", "network", ")", ",", "params", "=", "_params", ")" ]
Fetches information of a certain network.
[ "Fetches", "information", "of", "a", "certain", "network", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L653-L655
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.update_network
def update_network(self, network, body=None): """Updates a network.""" return self.put(self.network_path % (network), body=body)
python
def update_network(self, network, body=None): """Updates a network.""" return self.put(self.network_path % (network), body=body)
[ "def", "update_network", "(", "self", ",", "network", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "network_path", "%", "(", "network", ")", ",", "body", "=", "body", ")" ]
Updates a network.
[ "Updates", "a", "network", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L661-L663
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.list_subnets
def list_subnets(self, retrieve_all=True, **_params): """Fetches a list of all subnets for a project.""" return self.list('subnets', self.subnets_path, retrieve_all, **_params)
python
def list_subnets(self, retrieve_all=True, **_params): """Fetches a list of all subnets for a project.""" return self.list('subnets', self.subnets_path, retrieve_all, **_params)
[ "def", "list_subnets", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "'subnets'", ",", "self", ".", "subnets_path", ",", "retrieve_all", ",", "*", "*", "_params", ")" ]
Fetches a list of all subnets for a project.
[ "Fetches", "a", "list", "of", "all", "subnets", "for", "a", "project", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L669-L672
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_subnet
def show_subnet(self, subnet, **_params): """Fetches information of a certain subnet.""" return self.get(self.subnet_path % (subnet), params=_params)
python
def show_subnet(self, subnet, **_params): """Fetches information of a certain subnet.""" return self.get(self.subnet_path % (subnet), params=_params)
[ "def", "show_subnet", "(", "self", ",", "subnet", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "subnet_path", "%", "(", "subnet", ")", ",", "params", "=", "_params", ")" ]
Fetches information of a certain subnet.
[ "Fetches", "information", "of", "a", "certain", "subnet", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L674-L676
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.update_subnet
def update_subnet(self, subnet, body=None): """Updates a subnet.""" return self.put(self.subnet_path % (subnet), body=body)
python
def update_subnet(self, subnet, body=None): """Updates a subnet.""" return self.put(self.subnet_path % (subnet), body=body)
[ "def", "update_subnet", "(", "self", ",", "subnet", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "subnet_path", "%", "(", "subnet", ")", ",", "body", "=", "body", ")" ]
Updates a subnet.
[ "Updates", "a", "subnet", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L682-L684
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.list_subnetpools
def list_subnetpools(self, retrieve_all=True, **_params): """Fetches a list of all subnetpools for a project.""" return self.list('subnetpools', self.subnetpools_path, retrieve_all, **_params)
python
def list_subnetpools(self, retrieve_all=True, **_params): """Fetches a list of all subnetpools for a project.""" return self.list('subnetpools', self.subnetpools_path, retrieve_all, **_params)
[ "def", "list_subnetpools", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "'subnetpools'", ",", "self", ".", "subnetpools_path", ",", "retrieve_all", ",", "*", "*", "_params", ")" ]
Fetches a list of all subnetpools for a project.
[ "Fetches", "a", "list", "of", "all", "subnetpools", "for", "a", "project", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L690-L693
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
Client.show_subnetpool
def show_subnetpool(self, subnetpool, **_params): """Fetches information of a certain subnetpool.""" return self.get(self.subnetpool_path % (subnetpool), params=_params)
python
def show_subnetpool(self, subnetpool, **_params): """Fetches information of a certain subnetpool.""" return self.get(self.subnetpool_path % (subnetpool), params=_params)
[ "def", "show_subnetpool", "(", "self", ",", "subnetpool", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "get", "(", "self", ".", "subnetpool_path", "%", "(", "subnetpool", ")", ",", "params", "=", "_params", ")" ]
Fetches information of a certain subnetpool.
[ "Fetches", "information", "of", "a", "certain", "subnetpool", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L695-L697