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 |
|---|---|---|---|---|---|---|---|---|---|---|
MediaFire/mediafire-python-open-sdk | examples/mediafire-cli.py | do_folder_update_metadata | def do_folder_update_metadata(client, args):
"""Update file metadata"""
client.update_folder_metadata(args.uri, foldername=args.foldername,
description=args.description,
mtime=args.mtime, privacy=args.privacy,
... | python | def do_folder_update_metadata(client, args):
"""Update file metadata"""
client.update_folder_metadata(args.uri, foldername=args.foldername,
description=args.description,
mtime=args.mtime, privacy=args.privacy,
... | [
"def",
"do_folder_update_metadata",
"(",
"client",
",",
"args",
")",
":",
"client",
".",
"update_folder_metadata",
"(",
"args",
".",
"uri",
",",
"foldername",
"=",
"args",
".",
"foldername",
",",
"description",
"=",
"args",
".",
"description",
",",
"mtime",
... | Update file metadata | [
"Update",
"file",
"metadata"
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L129-L135 |
MediaFire/mediafire-python-open-sdk | examples/mediafire-cli.py | main | def main(): # pylint: disable=too-many-statements
"""Main entry point"""
parser = argparse.ArgumentParser(prog='mediafire-cli',
description=__doc__)
parser.add_argument('--debug', dest='debug', action='store_true',
default=False, help='Enable de... | python | def main(): # pylint: disable=too-many-statements
"""Main entry point"""
parser = argparse.ArgumentParser(prog='mediafire-cli',
description=__doc__)
parser.add_argument('--debug', dest='debug', action='store_true',
default=False, help='Enable de... | [
"def",
"main",
"(",
")",
":",
"# pylint: disable=too-many-statements",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"'mediafire-cli'",
",",
"description",
"=",
"__doc__",
")",
"parser",
".",
"add_argument",
"(",
"'--debug'",
",",
"dest",
"... | Main entry point | [
"Main",
"entry",
"point"
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L145-L273 |
dlecocq/nsq-py | nsq/http/nsqd.py | Client.pub | def pub(self, topic, message):
'''Publish a message to a topic'''
return self.post('pub', params={'topic': topic}, data=message) | python | def pub(self, topic, message):
'''Publish a message to a topic'''
return self.post('pub', params={'topic': topic}, data=message) | [
"def",
"pub",
"(",
"self",
",",
"topic",
",",
"message",
")",
":",
"return",
"self",
".",
"post",
"(",
"'pub'",
",",
"params",
"=",
"{",
"'topic'",
":",
"topic",
"}",
",",
"data",
"=",
"message",
")"
] | Publish a message to a topic | [
"Publish",
"a",
"message",
"to",
"a",
"topic"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L19-L21 |
dlecocq/nsq-py | nsq/http/nsqd.py | Client.mpub | def mpub(self, topic, messages, binary=True):
'''Send multiple messages to a topic. Optionally pack the messages'''
if binary:
# Pack and ship the data
return self.post('mpub', data=pack(messages)[4:],
params={'topic': topic, 'binary': True})
elif any('\n'... | python | def mpub(self, topic, messages, binary=True):
'''Send multiple messages to a topic. Optionally pack the messages'''
if binary:
# Pack and ship the data
return self.post('mpub', data=pack(messages)[4:],
params={'topic': topic, 'binary': True})
elif any('\n'... | [
"def",
"mpub",
"(",
"self",
",",
"topic",
",",
"messages",
",",
"binary",
"=",
"True",
")",
":",
"if",
"binary",
":",
"# Pack and ship the data",
"return",
"self",
".",
"post",
"(",
"'mpub'",
",",
"data",
"=",
"pack",
"(",
"messages",
")",
"[",
"4",
... | Send multiple messages to a topic. Optionally pack the messages | [
"Send",
"multiple",
"messages",
"to",
"a",
"topic",
".",
"Optionally",
"pack",
"the",
"messages"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L24-L37 |
dlecocq/nsq-py | nsq/http/nsqd.py | Client.clean_stats | def clean_stats(self):
'''Stats with topics and channels keyed on topic and channel names'''
stats = self.stats()
if 'topics' in stats: # pragma: no branch
topics = stats['topics']
topics = dict((t.pop('topic_name'), t) for t in topics)
for topic, data in top... | python | def clean_stats(self):
'''Stats with topics and channels keyed on topic and channel names'''
stats = self.stats()
if 'topics' in stats: # pragma: no branch
topics = stats['topics']
topics = dict((t.pop('topic_name'), t) for t in topics)
for topic, data in top... | [
"def",
"clean_stats",
"(",
"self",
")",
":",
"stats",
"=",
"self",
".",
"stats",
"(",
")",
"if",
"'topics'",
"in",
"stats",
":",
"# pragma: no branch",
"topics",
"=",
"stats",
"[",
"'topics'",
"]",
"topics",
"=",
"dict",
"(",
"(",
"t",
".",
"pop",
"(... | Stats with topics and channels keyed on topic and channel names | [
"Stats",
"with",
"topics",
"and",
"channels",
"keyed",
"on",
"topic",
"and",
"channel",
"names"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L99-L112 |
Nukesor/pueue | pueue/client/manipulation.py | execute_add | def execute_add(args, root_dir=None):
"""Add a new command to the daemon queue.
Args:
args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al']
root_dir (string): The path to the root directory the daemon is running in.
"""
# We accept a list of s... | python | def execute_add(args, root_dir=None):
"""Add a new command to the daemon queue.
Args:
args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al']
root_dir (string): The path to the root directory the daemon is running in.
"""
# We accept a list of s... | [
"def",
"execute_add",
"(",
"args",
",",
"root_dir",
"=",
"None",
")",
":",
"# We accept a list of strings.",
"# This is done to create a better commandline experience with argparse.",
"command",
"=",
"' '",
".",
"join",
"(",
"args",
"[",
"'command'",
"]",
")",
"# Send n... | Add a new command to the daemon queue.
Args:
args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al']
root_dir (string): The path to the root directory the daemon is running in. | [
"Add",
"a",
"new",
"command",
"to",
"the",
"daemon",
"queue",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L9-L26 |
Nukesor/pueue | pueue/client/manipulation.py | execute_edit | def execute_edit(args, root_dir=None):
"""Edit a existing queue command in the daemon.
Args:
args['key'] int: The key of the queue entry to be edited
root_dir (string): The path to the root directory the daemon is running in.
"""
# Get editor
EDITOR = os.environ.get('EDITOR', 'vim')... | python | def execute_edit(args, root_dir=None):
"""Edit a existing queue command in the daemon.
Args:
args['key'] int: The key of the queue entry to be edited
root_dir (string): The path to the root directory the daemon is running in.
"""
# Get editor
EDITOR = os.environ.get('EDITOR', 'vim')... | [
"def",
"execute_edit",
"(",
"args",
",",
"root_dir",
"=",
"None",
")",
":",
"# Get editor",
"EDITOR",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'EDITOR'",
",",
"'vim'",
")",
"# Get command from server",
"key",
"=",
"args",
"[",
"'key'",
"]",
"status",
... | Edit a existing queue command in the daemon.
Args:
args['key'] int: The key of the queue entry to be edited
root_dir (string): The path to the root directory the daemon is running in. | [
"Edit",
"a",
"existing",
"queue",
"command",
"in",
"the",
"daemon",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L29-L66 |
Nukesor/pueue | pueue/client/factories.py | command_factory | def command_factory(command):
"""A factory which returns functions for direct daemon communication.
This factory will create a function which sends a payload to the daemon
and returns the unpickled object which is returned by the daemon.
Args:
command (string): The type of payload this should ... | python | def command_factory(command):
"""A factory which returns functions for direct daemon communication.
This factory will create a function which sends a payload to the daemon
and returns the unpickled object which is returned by the daemon.
Args:
command (string): The type of payload this should ... | [
"def",
"command_factory",
"(",
"command",
")",
":",
"def",
"communicate",
"(",
"body",
"=",
"{",
"}",
",",
"root_dir",
"=",
"None",
")",
":",
"\"\"\"Communicate with the daemon.\n\n This function sends a payload to the daemon and returns the unpickled\n object sen... | A factory which returns functions for direct daemon communication.
This factory will create a function which sends a payload to the daemon
and returns the unpickled object which is returned by the daemon.
Args:
command (string): The type of payload this should be. This determines
as wh... | [
"A",
"factory",
"which",
"returns",
"functions",
"for",
"direct",
"daemon",
"communication",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/factories.py#L6-L44 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.get_descriptor | def get_descriptor(self, number):
"""Create file descriptors for process output."""
# Create stdout file and get file descriptor
stdout_path = os.path.join(self.config_dir,
'pueue_process_{}.stdout'.format(number))
if os.path.exists(stdout_path):
... | python | def get_descriptor(self, number):
"""Create file descriptors for process output."""
# Create stdout file and get file descriptor
stdout_path = os.path.join(self.config_dir,
'pueue_process_{}.stdout'.format(number))
if os.path.exists(stdout_path):
... | [
"def",
"get_descriptor",
"(",
"self",
",",
"number",
")",
":",
"# Create stdout file and get file descriptor",
"stdout_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'pueue_process_{}.stdout'",
".",
"format",
"(",
"number",
")",
... | Create file descriptors for process output. | [
"Create",
"file",
"descriptors",
"for",
"process",
"output",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L58-L79 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.clean_descriptor | def clean_descriptor(self, number):
"""Close file descriptor and remove underlying files."""
self.descriptors[number]['stdout'].close()
self.descriptors[number]['stderr'].close()
if os.path.exists(self.descriptors[number]['stdout_path']):
os.remove(self.descriptors[number]['... | python | def clean_descriptor(self, number):
"""Close file descriptor and remove underlying files."""
self.descriptors[number]['stdout'].close()
self.descriptors[number]['stderr'].close()
if os.path.exists(self.descriptors[number]['stdout_path']):
os.remove(self.descriptors[number]['... | [
"def",
"clean_descriptor",
"(",
"self",
",",
"number",
")",
":",
"self",
".",
"descriptors",
"[",
"number",
"]",
"[",
"'stdout'",
"]",
".",
"close",
"(",
")",
"self",
".",
"descriptors",
"[",
"number",
"]",
"[",
"'stderr'",
"]",
".",
"close",
"(",
")... | Close file descriptor and remove underlying files. | [
"Close",
"file",
"descriptor",
"and",
"remove",
"underlying",
"files",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L81-L90 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.check_finished | def check_finished(self):
"""Poll all processes and handle any finished processes."""
changed = False
for key in list(self.processes.keys()):
# Poll process and check if it finshed
process = self.processes[key]
process.poll()
if process.returncode ... | python | def check_finished(self):
"""Poll all processes and handle any finished processes."""
changed = False
for key in list(self.processes.keys()):
# Poll process and check if it finshed
process = self.processes[key]
process.poll()
if process.returncode ... | [
"def",
"check_finished",
"(",
"self",
")",
":",
"changed",
"=",
"False",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"processes",
".",
"keys",
"(",
")",
")",
":",
"# Poll process and check if it finshed",
"process",
"=",
"self",
".",
"processes",
"[",
"k... | Poll all processes and handle any finished processes. | [
"Poll",
"all",
"processes",
"and",
"handle",
"any",
"finished",
"processes",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L92-L146 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.check_for_new | def check_for_new(self):
"""Check if we can start a new process."""
free_slots = self.max_processes - len(self.processes)
for item in range(free_slots):
key = self.queue.next()
if key is not None:
self.spawn_new(key) | python | def check_for_new(self):
"""Check if we can start a new process."""
free_slots = self.max_processes - len(self.processes)
for item in range(free_slots):
key = self.queue.next()
if key is not None:
self.spawn_new(key) | [
"def",
"check_for_new",
"(",
"self",
")",
":",
"free_slots",
"=",
"self",
".",
"max_processes",
"-",
"len",
"(",
"self",
".",
"processes",
")",
"for",
"item",
"in",
"range",
"(",
"free_slots",
")",
":",
"key",
"=",
"self",
".",
"queue",
".",
"next",
... | Check if we can start a new process. | [
"Check",
"if",
"we",
"can",
"start",
"a",
"new",
"process",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L148-L154 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.spawn_new | def spawn_new(self, key):
"""Spawn a new task and save it to the queue."""
# Check if path exists
if not os.path.exists(self.queue[key]['path']):
self.queue[key]['status'] = 'failed'
error_msg = "The directory for this command doesn't exist anymore: {}".format(self.queue[... | python | def spawn_new(self, key):
"""Spawn a new task and save it to the queue."""
# Check if path exists
if not os.path.exists(self.queue[key]['path']):
self.queue[key]['status'] = 'failed'
error_msg = "The directory for this command doesn't exist anymore: {}".format(self.queue[... | [
"def",
"spawn_new",
"(",
"self",
",",
"key",
")",
":",
"# Check if path exists",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'path'",
"]",
")",
":",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
... | Spawn a new task and save it to the queue. | [
"Spawn",
"a",
"new",
"task",
"and",
"save",
"it",
"to",
"the",
"queue",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L156-L201 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.kill_all | def kill_all(self, kill_signal, kill_shell=False):
"""Kill all running processes."""
for key in self.processes.keys():
self.kill_process(key, kill_signal, kill_shell) | python | def kill_all(self, kill_signal, kill_shell=False):
"""Kill all running processes."""
for key in self.processes.keys():
self.kill_process(key, kill_signal, kill_shell) | [
"def",
"kill_all",
"(",
"self",
",",
"kill_signal",
",",
"kill_shell",
"=",
"False",
")",
":",
"for",
"key",
"in",
"self",
".",
"processes",
".",
"keys",
"(",
")",
":",
"self",
".",
"kill_process",
"(",
"key",
",",
"kill_signal",
",",
"kill_shell",
")"... | Kill all running processes. | [
"Kill",
"all",
"running",
"processes",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L221-L224 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.start_process | def start_process(self, key):
"""Start a specific processes."""
if key in self.processes and key in self.paused:
os.killpg(os.getpgid(self.processes[key].pid), signal.SIGCONT)
self.queue[key]['status'] = 'running'
self.paused.remove(key)
return True
... | python | def start_process(self, key):
"""Start a specific processes."""
if key in self.processes and key in self.paused:
os.killpg(os.getpgid(self.processes[key].pid), signal.SIGCONT)
self.queue[key]['status'] = 'running'
self.paused.remove(key)
return True
... | [
"def",
"start_process",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"processes",
"and",
"key",
"in",
"self",
".",
"paused",
":",
"os",
".",
"killpg",
"(",
"os",
".",
"getpgid",
"(",
"self",
".",
"processes",
"[",
"key",
"]",
... | Start a specific processes. | [
"Start",
"a",
"specific",
"processes",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L226-L238 |
Nukesor/pueue | pueue/daemon/process_handler.py | ProcessHandler.pause_process | def pause_process(self, key):
"""Pause a specific processes."""
if key in self.processes and key not in self.paused:
os.killpg(os.getpgid(self.processes[key].pid), signal.SIGSTOP)
self.queue[key]['status'] = 'paused'
self.paused.append(key)
return True
... | python | def pause_process(self, key):
"""Pause a specific processes."""
if key in self.processes and key not in self.paused:
os.killpg(os.getpgid(self.processes[key].pid), signal.SIGSTOP)
self.queue[key]['status'] = 'paused'
self.paused.append(key)
return True
... | [
"def",
"pause_process",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"processes",
"and",
"key",
"not",
"in",
"self",
".",
"paused",
":",
"os",
".",
"killpg",
"(",
"os",
".",
"getpgid",
"(",
"self",
".",
"processes",
"[",
"key"... | Pause a specific processes. | [
"Pause",
"a",
"specific",
"processes",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L240-L247 |
Nukesor/pueue | pueue/__init__.py | daemon_factory | def daemon_factory(path):
"""Create a closure which creates a running daemon.
We need to create a closure that contains the correct path the daemon should
be started with. This is needed as the `Daemonize` library
requires a callable function for daemonization and doesn't accept any arguments.
This... | python | def daemon_factory(path):
"""Create a closure which creates a running daemon.
We need to create a closure that contains the correct path the daemon should
be started with. This is needed as the `Daemonize` library
requires a callable function for daemonization and doesn't accept any arguments.
This... | [
"def",
"daemon_factory",
"(",
"path",
")",
":",
"def",
"start_daemon",
"(",
")",
":",
"root_dir",
"=",
"path",
"config_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_dir",
",",
"'.config/pueue'",
")",
"try",
":",
"daemon",
"=",
"Daemon",
"(",
"r... | Create a closure which creates a running daemon.
We need to create a closure that contains the correct path the daemon should
be started with. This is needed as the `Daemonize` library
requires a callable function for daemonization and doesn't accept any arguments.
This function cleans up sockets and o... | [
"Create",
"a",
"closure",
"which",
"creates",
"a",
"running",
"daemon",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L13-L37 |
Nukesor/pueue | pueue/__init__.py | main | def main():
"""Execute entry function."""
args = parser.parse_args()
args_dict = vars(args)
root_dir = args_dict['root'] if 'root' in args else None
# If a root directory is specified, get the absolute path and
# check if it exists. Abort if it doesn't exist!
if root_dir:
root_dir =... | python | def main():
"""Execute entry function."""
args = parser.parse_args()
args_dict = vars(args)
root_dir = args_dict['root'] if 'root' in args else None
# If a root directory is specified, get the absolute path and
# check if it exists. Abort if it doesn't exist!
if root_dir:
root_dir =... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"args_dict",
"=",
"vars",
"(",
"args",
")",
"root_dir",
"=",
"args_dict",
"[",
"'root'",
"]",
"if",
"'root'",
"in",
"args",
"else",
"None",
"# If a root directory is specifie... | Execute entry function. | [
"Execute",
"entry",
"function",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L40-L73 |
corpusops/pdbclone | lib/pdb_clone/pdbhandler.py | register | def register(host=DFLT_ADDRESS[0], port=DFLT_ADDRESS[1],
signum=signal.SIGUSR1):
"""Register a pdb handler for signal 'signum'.
The handler sets pdb to listen on the ('host', 'port') internet address
and to start a remote debugging session on accepting a socket connection.
"""
_pdbhand... | python | def register(host=DFLT_ADDRESS[0], port=DFLT_ADDRESS[1],
signum=signal.SIGUSR1):
"""Register a pdb handler for signal 'signum'.
The handler sets pdb to listen on the ('host', 'port') internet address
and to start a remote debugging session on accepting a socket connection.
"""
_pdbhand... | [
"def",
"register",
"(",
"host",
"=",
"DFLT_ADDRESS",
"[",
"0",
"]",
",",
"port",
"=",
"DFLT_ADDRESS",
"[",
"1",
"]",
",",
"signum",
"=",
"signal",
".",
"SIGUSR1",
")",
":",
"_pdbhandler",
".",
"_register",
"(",
"host",
",",
"port",
",",
"signum",
")"... | Register a pdb handler for signal 'signum'.
The handler sets pdb to listen on the ('host', 'port') internet address
and to start a remote debugging session on accepting a socket connection. | [
"Register",
"a",
"pdb",
"handler",
"for",
"signal",
"signum",
"."
] | train | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L19-L26 |
corpusops/pdbclone | lib/pdb_clone/pdbhandler.py | get_handler | def get_handler():
"""Return the handler as a named tuple.
The named tuple attributes are 'host', 'port', 'signum'.
Return None when no handler has been registered.
"""
host, port, signum = _pdbhandler._registered()
if signum:
return Handler(host if host else DFLT_ADDRESS[0].encode(),
... | python | def get_handler():
"""Return the handler as a named tuple.
The named tuple attributes are 'host', 'port', 'signum'.
Return None when no handler has been registered.
"""
host, port, signum = _pdbhandler._registered()
if signum:
return Handler(host if host else DFLT_ADDRESS[0].encode(),
... | [
"def",
"get_handler",
"(",
")",
":",
"host",
",",
"port",
",",
"signum",
"=",
"_pdbhandler",
".",
"_registered",
"(",
")",
"if",
"signum",
":",
"return",
"Handler",
"(",
"host",
"if",
"host",
"else",
"DFLT_ADDRESS",
"[",
"0",
"]",
".",
"encode",
"(",
... | Return the handler as a named tuple.
The named tuple attributes are 'host', 'port', 'signum'.
Return None when no handler has been registered. | [
"Return",
"the",
"handler",
"as",
"a",
"named",
"tuple",
"."
] | train | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L35-L44 |
dlecocq/nsq-py | nsq/checker.py | StoppableThread.wait | def wait(self, timeout):
'''Wait for the provided time to elapse'''
logger.debug('Waiting for %fs', timeout)
return self._event.wait(timeout) | python | def wait(self, timeout):
'''Wait for the provided time to elapse'''
logger.debug('Waiting for %fs', timeout)
return self._event.wait(timeout) | [
"def",
"wait",
"(",
"self",
",",
"timeout",
")",
":",
"logger",
".",
"debug",
"(",
"'Waiting for %fs'",
",",
"timeout",
")",
"return",
"self",
".",
"_event",
".",
"wait",
"(",
"timeout",
")"
] | Wait for the provided time to elapse | [
"Wait",
"for",
"the",
"provided",
"time",
"to",
"elapse"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L14-L17 |
dlecocq/nsq-py | nsq/checker.py | PeriodicThread.delay | def delay(self):
'''How long to wait before the next check'''
if self._last_checked:
return self._interval - (time.time() - self._last_checked)
return self._interval | python | def delay(self):
'''How long to wait before the next check'''
if self._last_checked:
return self._interval - (time.time() - self._last_checked)
return self._interval | [
"def",
"delay",
"(",
"self",
")",
":",
"if",
"self",
".",
"_last_checked",
":",
"return",
"self",
".",
"_interval",
"-",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_last_checked",
")",
"return",
"self",
".",
"_interval"
] | How long to wait before the next check | [
"How",
"long",
"to",
"wait",
"before",
"the",
"next",
"check"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L34-L38 |
dlecocq/nsq-py | nsq/checker.py | PeriodicThread.callback | def callback(self):
'''Run the callback'''
self._callback(*self._args, **self._kwargs)
self._last_checked = time.time() | python | def callback(self):
'''Run the callback'''
self._callback(*self._args, **self._kwargs)
self._last_checked = time.time() | [
"def",
"callback",
"(",
"self",
")",
":",
"self",
".",
"_callback",
"(",
"*",
"self",
".",
"_args",
",",
"*",
"*",
"self",
".",
"_kwargs",
")",
"self",
".",
"_last_checked",
"=",
"time",
".",
"time",
"(",
")"
] | Run the callback | [
"Run",
"the",
"callback"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L40-L43 |
dlecocq/nsq-py | nsq/checker.py | PeriodicThread.run | def run(self):
'''Run the callback periodically'''
while not self.wait(self.delay()):
try:
logger.info('Invoking callback %s', self.callback)
self.callback()
except StandardError:
logger.exception('Callback failed') | python | def run(self):
'''Run the callback periodically'''
while not self.wait(self.delay()):
try:
logger.info('Invoking callback %s', self.callback)
self.callback()
except StandardError:
logger.exception('Callback failed') | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"wait",
"(",
"self",
".",
"delay",
"(",
")",
")",
":",
"try",
":",
"logger",
".",
"info",
"(",
"'Invoking callback %s'",
",",
"self",
".",
"callback",
")",
"self",
".",
"callback",
"... | Run the callback periodically | [
"Run",
"the",
"callback",
"periodically"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L45-L52 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.login | def login(self, email=None, password=None, app_id=None, api_key=None):
"""Login to MediaFire account.
Keyword arguments:
email -- account email
password -- account password
app_id -- application ID
api_key -- API Key (optional)
"""
session_token = self.ap... | python | def login(self, email=None, password=None, app_id=None, api_key=None):
"""Login to MediaFire account.
Keyword arguments:
email -- account email
password -- account password
app_id -- application ID
api_key -- API Key (optional)
"""
session_token = self.ap... | [
"def",
"login",
"(",
"self",
",",
"email",
"=",
"None",
",",
"password",
"=",
"None",
",",
"app_id",
"=",
"None",
",",
"api_key",
"=",
"None",
")",
":",
"session_token",
"=",
"self",
".",
"api",
".",
"user_get_session_token",
"(",
"app_id",
"=",
"app_i... | Login to MediaFire account.
Keyword arguments:
email -- account email
password -- account password
app_id -- application ID
api_key -- API Key (optional) | [
"Login",
"to",
"MediaFire",
"account",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L80-L93 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.get_resource_by_uri | def get_resource_by_uri(self, uri):
"""Return resource described by MediaFire URI.
uri -- MediaFire URI
Examples:
Folder (using folderkey):
mf:r5g3p2z0sqs3j
mf:r5g3p2z0sqs3j/folder/file.ext
File (using quickkey):
mf:xkr43dadqa3o2p2
... | python | def get_resource_by_uri(self, uri):
"""Return resource described by MediaFire URI.
uri -- MediaFire URI
Examples:
Folder (using folderkey):
mf:r5g3p2z0sqs3j
mf:r5g3p2z0sqs3j/folder/file.ext
File (using quickkey):
mf:xkr43dadqa3o2p2
... | [
"def",
"get_resource_by_uri",
"(",
"self",
",",
"uri",
")",
":",
"location",
"=",
"self",
".",
"_parse_uri",
"(",
"uri",
")",
"if",
"location",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"# Use path lookup only, root=myfiles",
"result",
"=",
"self",
".",
"ge... | Return resource described by MediaFire URI.
uri -- MediaFire URI
Examples:
Folder (using folderkey):
mf:r5g3p2z0sqs3j
mf:r5g3p2z0sqs3j/folder/file.ext
File (using quickkey):
mf:xkr43dadqa3o2p2
Path:
mf:///Documents/f... | [
"Return",
"resource",
"described",
"by",
"MediaFire",
"URI",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L95-L130 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.get_resource_by_key | def get_resource_by_key(self, resource_key):
"""Return resource by quick_key/folder_key.
key -- quick_key or folder_key
"""
# search for quick_key by default
lookup_order = ["quick_key", "folder_key"]
if len(resource_key) == FOLDER_KEY_LENGTH:
lookup_order ... | python | def get_resource_by_key(self, resource_key):
"""Return resource by quick_key/folder_key.
key -- quick_key or folder_key
"""
# search for quick_key by default
lookup_order = ["quick_key", "folder_key"]
if len(resource_key) == FOLDER_KEY_LENGTH:
lookup_order ... | [
"def",
"get_resource_by_key",
"(",
"self",
",",
"resource_key",
")",
":",
"# search for quick_key by default",
"lookup_order",
"=",
"[",
"\"quick_key\"",
",",
"\"folder_key\"",
"]",
"if",
"len",
"(",
"resource_key",
")",
"==",
"FOLDER_KEY_LENGTH",
":",
"lookup_order",... | Return resource by quick_key/folder_key.
key -- quick_key or folder_key | [
"Return",
"resource",
"by",
"quick_key",
"/",
"folder_key",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L132-L164 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.get_resource_by_path | def get_resource_by_path(self, path, folder_key=None):
"""Return resource by remote path.
path -- remote path
Keyword arguments:
folder_key -- what to use as the root folder (None for root)
"""
logger.debug("resolving %s", path)
# remove empty path components
... | python | def get_resource_by_path(self, path, folder_key=None):
"""Return resource by remote path.
path -- remote path
Keyword arguments:
folder_key -- what to use as the root folder (None for root)
"""
logger.debug("resolving %s", path)
# remove empty path components
... | [
"def",
"get_resource_by_path",
"(",
"self",
",",
"path",
",",
"folder_key",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"resolving %s\"",
",",
"path",
")",
"# remove empty path components",
"path",
"=",
"posixpath",
".",
"normpath",
"(",
"path",
")",... | Return resource by remote path.
path -- remote path
Keyword arguments:
folder_key -- what to use as the root folder (None for root) | [
"Return",
"resource",
"by",
"remote",
"path",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L166-L225 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient._folder_get_content_iter | def _folder_get_content_iter(self, folder_key=None):
"""Iterator for api.folder_get_content"""
lookup_params = [
{'content_type': 'folders', 'node': 'folders'},
{'content_type': 'files', 'node': 'files'}
]
for param in lookup_params:
more_chunks = Tr... | python | def _folder_get_content_iter(self, folder_key=None):
"""Iterator for api.folder_get_content"""
lookup_params = [
{'content_type': 'folders', 'node': 'folders'},
{'content_type': 'files', 'node': 'files'}
]
for param in lookup_params:
more_chunks = Tr... | [
"def",
"_folder_get_content_iter",
"(",
"self",
",",
"folder_key",
"=",
"None",
")",
":",
"lookup_params",
"=",
"[",
"{",
"'content_type'",
":",
"'folders'",
",",
"'node'",
":",
"'folders'",
"}",
",",
"{",
"'content_type'",
":",
"'files'",
",",
"'node'",
":"... | Iterator for api.folder_get_content | [
"Iterator",
"for",
"api",
".",
"folder_get_content"
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L227-L253 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.get_folder_contents_iter | def get_folder_contents_iter(self, uri):
"""Return iterator for directory contents.
uri -- mediafire URI
Example:
for item in get_folder_contents_iter('mf:///Documents'):
print(item)
"""
resource = self.get_resource_by_uri(uri)
if not isins... | python | def get_folder_contents_iter(self, uri):
"""Return iterator for directory contents.
uri -- mediafire URI
Example:
for item in get_folder_contents_iter('mf:///Documents'):
print(item)
"""
resource = self.get_resource_by_uri(uri)
if not isins... | [
"def",
"get_folder_contents_iter",
"(",
"self",
",",
"uri",
")",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"Folder",
")",
":",
"raise",
"NotAFolderError",
"(",
"uri",
")",
"f... | Return iterator for directory contents.
uri -- mediafire URI
Example:
for item in get_folder_contents_iter('mf:///Documents'):
print(item) | [
"Return",
"iterator",
"for",
"directory",
"contents",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L255-L280 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.create_folder | def create_folder(self, uri, recursive=False):
"""Create folder.
uri -- MediaFire URI
Keyword arguments:
recursive -- set to True to create intermediate folders.
"""
logger.info("Creating %s", uri)
# check that folder exists already
try:
res... | python | def create_folder(self, uri, recursive=False):
"""Create folder.
uri -- MediaFire URI
Keyword arguments:
recursive -- set to True to create intermediate folders.
"""
logger.info("Creating %s", uri)
# check that folder exists already
try:
res... | [
"def",
"create_folder",
"(",
"self",
",",
"uri",
",",
"recursive",
"=",
"False",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating %s\"",
",",
"uri",
")",
"# check that folder exists already",
"try",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(... | Create folder.
uri -- MediaFire URI
Keyword arguments:
recursive -- set to True to create intermediate folders. | [
"Create",
"folder",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L282-L327 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.delete_folder | def delete_folder(self, uri, purge=False):
"""Delete folder.
uri -- MediaFire folder URI
Keyword arguments:
purge -- delete the folder without sending it to Trash
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
... | python | def delete_folder(self, uri, purge=False):
"""Delete folder.
uri -- MediaFire folder URI
Keyword arguments:
purge -- delete the folder without sending it to Trash
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
... | [
"def",
"delete_folder",
"(",
"self",
",",
"uri",
",",
"purge",
"=",
"False",
")",
":",
"try",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",
"except",
"ResourceNotFoundError",
":",
"# Nothing to remove",
"return",
"None",
"if",
"n... | Delete folder.
uri -- MediaFire folder URI
Keyword arguments:
purge -- delete the folder without sending it to Trash | [
"Delete",
"folder",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L329-L364 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.delete_file | def delete_file(self, uri, purge=False):
"""Delete file.
uri -- MediaFire file URI
Keyword arguments:
purge -- delete the file without sending it to Trash.
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
# ... | python | def delete_file(self, uri, purge=False):
"""Delete file.
uri -- MediaFire file URI
Keyword arguments:
purge -- delete the file without sending it to Trash.
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
# ... | [
"def",
"delete_file",
"(",
"self",
",",
"uri",
",",
"purge",
"=",
"False",
")",
":",
"try",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",
"except",
"ResourceNotFoundError",
":",
"# Nothing to remove",
"return",
"None",
"if",
"not... | Delete file.
uri -- MediaFire file URI
Keyword arguments:
purge -- delete the file without sending it to Trash. | [
"Delete",
"file",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L366-L388 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.delete_resource | def delete_resource(self, uri, purge=False):
"""Delete file or folder
uri -- mediafire URI
Keyword arguments:
purge -- delete the resource without sending it to Trash.
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
... | python | def delete_resource(self, uri, purge=False):
"""Delete file or folder
uri -- mediafire URI
Keyword arguments:
purge -- delete the resource without sending it to Trash.
"""
try:
resource = self.get_resource_by_uri(uri)
except ResourceNotFoundError:
... | [
"def",
"delete_resource",
"(",
"self",
",",
"uri",
",",
"purge",
"=",
"False",
")",
":",
"try",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",
"except",
"ResourceNotFoundError",
":",
"# Nothing to remove",
"return",
"None",
"if",
... | Delete file or folder
uri -- mediafire URI
Keyword arguments:
purge -- delete the resource without sending it to Trash. | [
"Delete",
"file",
"or",
"folder"
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L390-L411 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient._prepare_upload_info | def _prepare_upload_info(self, source, dest_uri):
"""Prepare Upload object, resolve paths"""
try:
dest_resource = self.get_resource_by_uri(dest_uri)
except ResourceNotFoundError:
dest_resource = None
is_fh = hasattr(source, 'read')
folder_key = None
... | python | def _prepare_upload_info(self, source, dest_uri):
"""Prepare Upload object, resolve paths"""
try:
dest_resource = self.get_resource_by_uri(dest_uri)
except ResourceNotFoundError:
dest_resource = None
is_fh = hasattr(source, 'read')
folder_key = None
... | [
"def",
"_prepare_upload_info",
"(",
"self",
",",
"source",
",",
"dest_uri",
")",
":",
"try",
":",
"dest_resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"dest_uri",
")",
"except",
"ResourceNotFoundError",
":",
"dest_resource",
"=",
"None",
"is_fh",
"=",
... | Prepare Upload object, resolve paths | [
"Prepare",
"Upload",
"object",
"resolve",
"paths"
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L428-L472 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.upload_file | def upload_file(self, source, dest_uri):
"""Upload file to MediaFire.
source -- path to the file or a file-like object (e.g. io.BytesIO)
dest_uri -- MediaFire Resource URI
"""
folder_key, name = self._prepare_upload_info(source, dest_uri)
is_fh = hasattr(source, 'read'... | python | def upload_file(self, source, dest_uri):
"""Upload file to MediaFire.
source -- path to the file or a file-like object (e.g. io.BytesIO)
dest_uri -- MediaFire Resource URI
"""
folder_key, name = self._prepare_upload_info(source, dest_uri)
is_fh = hasattr(source, 'read'... | [
"def",
"upload_file",
"(",
"self",
",",
"source",
",",
"dest_uri",
")",
":",
"folder_key",
",",
"name",
"=",
"self",
".",
"_prepare_upload_info",
"(",
"source",
",",
"dest_uri",
")",
"is_fh",
"=",
"hasattr",
"(",
"source",
",",
"'read'",
")",
"fd",
"=",
... | Upload file to MediaFire.
source -- path to the file or a file-like object (e.g. io.BytesIO)
dest_uri -- MediaFire Resource URI | [
"Upload",
"file",
"to",
"MediaFire",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L474-L500 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.download_file | def download_file(self, src_uri, target):
"""Download file from MediaFire.
src_uri -- MediaFire file URI to download
target -- download path or file-like object in write mode
"""
resource = self.get_resource_by_uri(src_uri)
if not isinstance(resource, File):
... | python | def download_file(self, src_uri, target):
"""Download file from MediaFire.
src_uri -- MediaFire file URI to download
target -- download path or file-like object in write mode
"""
resource = self.get_resource_by_uri(src_uri)
if not isinstance(resource, File):
... | [
"def",
"download_file",
"(",
"self",
",",
"src_uri",
",",
"target",
")",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"src_uri",
")",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"File",
")",
":",
"raise",
"MediaFireError",
"(",
"\"On... | Download file from MediaFire.
src_uri -- MediaFire file URI to download
target -- download path or file-like object in write mode | [
"Download",
"file",
"from",
"MediaFire",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L502-L555 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.update_file_metadata | def update_file_metadata(self, uri, filename=None, description=None,
mtime=None, privacy=None):
"""Update file metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change the
metadata on the server side:
filename -- r... | python | def update_file_metadata(self, uri, filename=None, description=None,
mtime=None, privacy=None):
"""Update file metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change the
metadata on the server side:
filename -- r... | [
"def",
"update_file_metadata",
"(",
"self",
",",
"uri",
",",
"filename",
"=",
"None",
",",
"description",
"=",
"None",
",",
"mtime",
"=",
"None",
",",
"privacy",
"=",
"None",
")",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",... | Update file metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change the
metadata on the server side:
filename -- rename file
description -- set file description string
mtime -- set file modification time
privacy -- set file pr... | [
"Update",
"file",
"metadata",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L558-L582 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient.update_folder_metadata | def update_folder_metadata(self, uri, foldername=None, description=None,
mtime=None, privacy=None,
privacy_recursive=None):
"""Update folder metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change ... | python | def update_folder_metadata(self, uri, foldername=None, description=None,
mtime=None, privacy=None,
privacy_recursive=None):
"""Update folder metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change ... | [
"def",
"update_folder_metadata",
"(",
"self",
",",
"uri",
",",
"foldername",
"=",
"None",
",",
"description",
"=",
"None",
",",
"mtime",
"=",
"None",
",",
"privacy",
"=",
"None",
",",
"privacy_recursive",
"=",
"None",
")",
":",
"resource",
"=",
"self",
"... | Update folder metadata.
uri -- MediaFire file URI
Supplying the following keyword arguments would change the
metadata on the server side:
filename -- rename file
description -- set file description string
mtime -- set file modification time
privacy -- set file ... | [
"Update",
"folder",
"metadata",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L586-L615 |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | MediaFireClient._parse_uri | def _parse_uri(uri):
"""Parse and validate MediaFire URI."""
tokens = urlparse(uri)
if tokens.netloc != '':
logger.error("Invalid URI: %s", uri)
raise ValueError("MediaFire URI format error: "
"host should be empty - mf:///path")
if... | python | def _parse_uri(uri):
"""Parse and validate MediaFire URI."""
tokens = urlparse(uri)
if tokens.netloc != '':
logger.error("Invalid URI: %s", uri)
raise ValueError("MediaFire URI format error: "
"host should be empty - mf:///path")
if... | [
"def",
"_parse_uri",
"(",
"uri",
")",
":",
"tokens",
"=",
"urlparse",
"(",
"uri",
")",
"if",
"tokens",
".",
"netloc",
"!=",
"''",
":",
"logger",
".",
"error",
"(",
"\"Invalid URI: %s\"",
",",
"uri",
")",
"raise",
"ValueError",
"(",
"\"MediaFire URI format ... | Parse and validate MediaFire URI. | [
"Parse",
"and",
"validate",
"MediaFire",
"URI",
"."
] | train | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L619-L633 |
dlecocq/nsq-py | nsq/stats.py | Nsqlookupd.merged | def merged(self):
'''The clean stats from all the hosts reporting to this host.'''
stats = {}
for topic in self.client.topics()['topics']:
for producer in self.client.lookup(topic)['producers']:
hostname = producer['broadcast_address']
port = producer[... | python | def merged(self):
'''The clean stats from all the hosts reporting to this host.'''
stats = {}
for topic in self.client.topics()['topics']:
for producer in self.client.lookup(topic)['producers']:
hostname = producer['broadcast_address']
port = producer[... | [
"def",
"merged",
"(",
"self",
")",
":",
"stats",
"=",
"{",
"}",
"for",
"topic",
"in",
"self",
".",
"client",
".",
"topics",
"(",
")",
"[",
"'topics'",
"]",
":",
"for",
"producer",
"in",
"self",
".",
"client",
".",
"lookup",
"(",
"topic",
")",
"["... | The clean stats from all the hosts reporting to this host. | [
"The",
"clean",
"stats",
"from",
"all",
"the",
"hosts",
"reporting",
"to",
"this",
"host",
"."
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L11-L21 |
dlecocq/nsq-py | nsq/stats.py | Nsqlookupd.raw | def raw(self):
'''All the raw, unaggregated stats (with duplicates).'''
topic_keys = (
'message_count',
'depth',
'backend_depth',
'paused'
)
channel_keys = (
'in_flight_count',
'timeout_count',
'paused',... | python | def raw(self):
'''All the raw, unaggregated stats (with duplicates).'''
topic_keys = (
'message_count',
'depth',
'backend_depth',
'paused'
)
channel_keys = (
'in_flight_count',
'timeout_count',
'paused',... | [
"def",
"raw",
"(",
"self",
")",
":",
"topic_keys",
"=",
"(",
"'message_count'",
",",
"'depth'",
",",
"'backend_depth'",
",",
"'paused'",
")",
"channel_keys",
"=",
"(",
"'in_flight_count'",
",",
"'timeout_count'",
",",
"'paused'",
",",
"'deferred_count'",
",",
... | All the raw, unaggregated stats (with duplicates). | [
"All",
"the",
"raw",
"unaggregated",
"stats",
"(",
"with",
"duplicates",
")",
"."
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L24-L91 |
dlecocq/nsq-py | nsq/stats.py | Nsqlookupd.stats | def stats(self):
'''Stats that have been aggregated appropriately.'''
data = Counter()
for name, value, aggregated in self.raw:
if aggregated:
data['%s.max' % name] = max(data['%s.max' % name], value)
data['%s.total' % name] += value
else:
... | python | def stats(self):
'''Stats that have been aggregated appropriately.'''
data = Counter()
for name, value, aggregated in self.raw:
if aggregated:
data['%s.max' % name] = max(data['%s.max' % name], value)
data['%s.total' % name] += value
else:
... | [
"def",
"stats",
"(",
"self",
")",
":",
"data",
"=",
"Counter",
"(",
")",
"for",
"name",
",",
"value",
",",
"aggregated",
"in",
"self",
".",
"raw",
":",
"if",
"aggregated",
":",
"data",
"[",
"'%s.max'",
"%",
"name",
"]",
"=",
"max",
"(",
"data",
"... | Stats that have been aggregated appropriately. | [
"Stats",
"that",
"have",
"been",
"aggregated",
"appropriately",
"."
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L94-L104 |
corpusops/pdbclone | lib/pdb_clone/bootstrappdb_gdb.py | get_curline | def get_curline():
"""Return the current python source line."""
if Frame:
frame = Frame.get_selected_python_frame()
if frame:
line = ''
f = frame.get_pyop()
if f and not f.is_optimized_out():
cwd = os.path.join(os.getcwd(), '')
... | python | def get_curline():
"""Return the current python source line."""
if Frame:
frame = Frame.get_selected_python_frame()
if frame:
line = ''
f = frame.get_pyop()
if f and not f.is_optimized_out():
cwd = os.path.join(os.getcwd(), '')
... | [
"def",
"get_curline",
"(",
")",
":",
"if",
"Frame",
":",
"frame",
"=",
"Frame",
".",
"get_selected_python_frame",
"(",
")",
"if",
"frame",
":",
"line",
"=",
"''",
"f",
"=",
"frame",
".",
"get_pyop",
"(",
")",
"if",
"f",
"and",
"not",
"f",
".",
"is_... | Return the current python source line. | [
"Return",
"the",
"current",
"python",
"source",
"line",
"."
] | train | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bootstrappdb_gdb.py#L80-L103 |
dlecocq/nsq-py | nsq/reader.py | Reader.reconnected | def reconnected(self, conn):
'''Subscribe connection and manipulate its RDY state'''
conn.sub(self._topic, self._channel)
conn.rdy(1) | python | def reconnected(self, conn):
'''Subscribe connection and manipulate its RDY state'''
conn.sub(self._topic, self._channel)
conn.rdy(1) | [
"def",
"reconnected",
"(",
"self",
",",
"conn",
")",
":",
"conn",
".",
"sub",
"(",
"self",
".",
"_topic",
",",
"self",
".",
"_channel",
")",
"conn",
".",
"rdy",
"(",
"1",
")"
] | Subscribe connection and manipulate its RDY state | [
"Subscribe",
"connection",
"and",
"manipulate",
"its",
"RDY",
"state"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L16-L19 |
dlecocq/nsq-py | nsq/reader.py | Reader.distribute_ready | def distribute_ready(self):
'''Distribute the ready state across all of the connections'''
connections = [c for c in self.connections() if c.alive()]
if len(connections) > self._max_in_flight:
raise NotImplementedError(
'Max in flight must be greater than number of co... | python | def distribute_ready(self):
'''Distribute the ready state across all of the connections'''
connections = [c for c in self.connections() if c.alive()]
if len(connections) > self._max_in_flight:
raise NotImplementedError(
'Max in flight must be greater than number of co... | [
"def",
"distribute_ready",
"(",
"self",
")",
":",
"connections",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"connections",
"(",
")",
"if",
"c",
".",
"alive",
"(",
")",
"]",
"if",
"len",
"(",
"connections",
")",
">",
"self",
".",
"_max_in_flight",
... | Distribute the ready state across all of the connections | [
"Distribute",
"the",
"ready",
"state",
"across",
"all",
"of",
"the",
"connections"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L26-L42 |
dlecocq/nsq-py | nsq/reader.py | Reader.needs_distribute_ready | def needs_distribute_ready(self):
'''Determine whether or not we need to redistribute the ready state'''
# Try to pre-empty starvation by comparing current RDY against
# the last value sent.
alive = [c for c in self.connections() if c.alive()]
if any(c.ready <= (c.last_ready_sent... | python | def needs_distribute_ready(self):
'''Determine whether or not we need to redistribute the ready state'''
# Try to pre-empty starvation by comparing current RDY against
# the last value sent.
alive = [c for c in self.connections() if c.alive()]
if any(c.ready <= (c.last_ready_sent... | [
"def",
"needs_distribute_ready",
"(",
"self",
")",
":",
"# Try to pre-empty starvation by comparing current RDY against",
"# the last value sent.",
"alive",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"connections",
"(",
")",
"if",
"c",
".",
"alive",
"(",
")",
"... | Determine whether or not we need to redistribute the ready state | [
"Determine",
"whether",
"or",
"not",
"we",
"need",
"to",
"redistribute",
"the",
"ready",
"state"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L44-L50 |
dlecocq/nsq-py | nsq/reader.py | Reader.read | def read(self):
'''Read some number of messages'''
found = Client.read(self)
# Redistribute our ready state if necessary
if self.needs_distribute_ready():
self.distribute_ready()
# Finally, return all the results we've read
return found | python | def read(self):
'''Read some number of messages'''
found = Client.read(self)
# Redistribute our ready state if necessary
if self.needs_distribute_ready():
self.distribute_ready()
# Finally, return all the results we've read
return found | [
"def",
"read",
"(",
"self",
")",
":",
"found",
"=",
"Client",
".",
"read",
"(",
"self",
")",
"# Redistribute our ready state if necessary",
"if",
"self",
".",
"needs_distribute_ready",
"(",
")",
":",
"self",
".",
"distribute_ready",
"(",
")",
"# Finally, return ... | Read some number of messages | [
"Read",
"some",
"number",
"of",
"messages"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L57-L66 |
dlecocq/nsq-py | shovel/profile.py | profiler | def profiler():
'''Profile the block'''
import cProfile
import pstats
pr = cProfile.Profile()
pr.enable()
yield
pr.disable()
ps = pstats.Stats(pr).sort_stats('tottime')
ps.print_stats() | python | def profiler():
'''Profile the block'''
import cProfile
import pstats
pr = cProfile.Profile()
pr.enable()
yield
pr.disable()
ps = pstats.Stats(pr).sort_stats('tottime')
ps.print_stats() | [
"def",
"profiler",
"(",
")",
":",
"import",
"cProfile",
"import",
"pstats",
"pr",
"=",
"cProfile",
".",
"Profile",
"(",
")",
"pr",
".",
"enable",
"(",
")",
"yield",
"pr",
".",
"disable",
"(",
")",
"ps",
"=",
"pstats",
".",
"Stats",
"(",
"pr",
")",
... | Profile the block | [
"Profile",
"the",
"block"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/shovel/profile.py#L9-L18 |
dlecocq/nsq-py | shovel/profile.py | messages | def messages(count, size):
'''Generator for count messages of the provided size'''
import string
# Make sure we have at least 'size' letters
letters = islice(cycle(chain(string.lowercase, string.uppercase)), size)
return islice(cycle(''.join(l) for l in permutations(letters, size)), count) | python | def messages(count, size):
'''Generator for count messages of the provided size'''
import string
# Make sure we have at least 'size' letters
letters = islice(cycle(chain(string.lowercase, string.uppercase)), size)
return islice(cycle(''.join(l) for l in permutations(letters, size)), count) | [
"def",
"messages",
"(",
"count",
",",
"size",
")",
":",
"import",
"string",
"# Make sure we have at least 'size' letters",
"letters",
"=",
"islice",
"(",
"cycle",
"(",
"chain",
"(",
"string",
".",
"lowercase",
",",
"string",
".",
"uppercase",
")",
")",
",",
... | Generator for count messages of the provided size | [
"Generator",
"for",
"count",
"messages",
"of",
"the",
"provided",
"size"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/shovel/profile.py#L21-L26 |
dlecocq/nsq-py | shovel/profile.py | grouper | def grouper(iterable, n):
'''Collect data into fixed-length chunks or blocks'''
args = [iter(iterable)] * n
for group in izip_longest(fillvalue=None, *args):
group = [g for g in group if g != None]
yield group | python | def grouper(iterable, n):
'''Collect data into fixed-length chunks or blocks'''
args = [iter(iterable)] * n
for group in izip_longest(fillvalue=None, *args):
group = [g for g in group if g != None]
yield group | [
"def",
"grouper",
"(",
"iterable",
",",
"n",
")",
":",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"n",
"for",
"group",
"in",
"izip_longest",
"(",
"fillvalue",
"=",
"None",
",",
"*",
"args",
")",
":",
"group",
"=",
"[",
"g",
"for",
... | Collect data into fixed-length chunks or blocks | [
"Collect",
"data",
"into",
"fixed",
"-",
"length",
"chunks",
"or",
"blocks"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/shovel/profile.py#L29-L34 |
dlecocq/nsq-py | shovel/profile.py | basic | def basic(topic='topic', channel='channel', count=1e6, size=10, gevent=False,
max_in_flight=2500, profile=False):
'''Basic benchmark'''
if gevent:
from gevent import monkey
monkey.patch_all()
# Check the types of the arguments
count = int(count)
size = int(size)
max_in_fligh... | python | def basic(topic='topic', channel='channel', count=1e6, size=10, gevent=False,
max_in_flight=2500, profile=False):
'''Basic benchmark'''
if gevent:
from gevent import monkey
monkey.patch_all()
# Check the types of the arguments
count = int(count)
size = int(size)
max_in_fligh... | [
"def",
"basic",
"(",
"topic",
"=",
"'topic'",
",",
"channel",
"=",
"'channel'",
",",
"count",
"=",
"1e6",
",",
"size",
"=",
"10",
",",
"gevent",
"=",
"False",
",",
"max_in_flight",
"=",
"2500",
",",
"profile",
"=",
"False",
")",
":",
"if",
"gevent",
... | Basic benchmark | [
"Basic",
"benchmark"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/shovel/profile.py#L38-L71 |
dlecocq/nsq-py | shovel/profile.py | stats | def stats():
'''Read a stream of floats and give summary statistics'''
import re
import sys
import math
values = []
for line in sys.stdin:
values.extend(map(float, re.findall(r'\d+\.?\d+', line)))
mean = sum(values) / len(values)
variance = sum((val - mean) ** 2 for val in value... | python | def stats():
'''Read a stream of floats and give summary statistics'''
import re
import sys
import math
values = []
for line in sys.stdin:
values.extend(map(float, re.findall(r'\d+\.?\d+', line)))
mean = sum(values) / len(values)
variance = sum((val - mean) ** 2 for val in value... | [
"def",
"stats",
"(",
")",
":",
"import",
"re",
"import",
"sys",
"import",
"math",
"values",
"=",
"[",
"]",
"for",
"line",
"in",
"sys",
".",
"stdin",
":",
"values",
".",
"extend",
"(",
"map",
"(",
"float",
",",
"re",
".",
"findall",
"(",
"r'\\d+\\.?... | Read a stream of floats and give summary statistics | [
"Read",
"a",
"stream",
"of",
"floats",
"and",
"give",
"summary",
"statistics"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/shovel/profile.py#L75-L87 |
dlecocq/nsq-py | nsq/backoff.py | AttemptCounter.ready | def ready(self):
'''Whether or not enough time has passed since the last failure'''
if self._last_failed:
delta = time.time() - self._last_failed
return delta >= self.backoff()
return True | python | def ready(self):
'''Whether or not enough time has passed since the last failure'''
if self._last_failed:
delta = time.time() - self._last_failed
return delta >= self.backoff()
return True | [
"def",
"ready",
"(",
"self",
")",
":",
"if",
"self",
".",
"_last_failed",
":",
"delta",
"=",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_last_failed",
"return",
"delta",
">=",
"self",
".",
"backoff",
"(",
")",
"return",
"True"
] | Whether or not enough time has passed since the last failure | [
"Whether",
"or",
"not",
"enough",
"time",
"has",
"passed",
"since",
"the",
"last",
"failure"
] | train | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/backoff.py#L83-L88 |
Nukesor/pueue | pueue/client/displaying.py | execute_status | def execute_status(args, root_dir=None):
"""Print the status of the daemon.
This function displays the current status of the daemon as well
as the whole queue and all available information about every entry
in the queue.
`terminaltables` is used to format and display the queue contents.
`colorc... | python | def execute_status(args, root_dir=None):
"""Print the status of the daemon.
This function displays the current status of the daemon as well
as the whole queue and all available information about every entry
in the queue.
`terminaltables` is used to format and display the queue contents.
`colorc... | [
"def",
"execute_status",
"(",
"args",
",",
"root_dir",
"=",
"None",
")",
":",
"status",
"=",
"command_factory",
"(",
"'status'",
")",
"(",
"{",
"}",
",",
"root_dir",
"=",
"root_dir",
")",
"# First rows, showing daemon status",
"if",
"status",
"[",
"'status'",
... | Print the status of the daemon.
This function displays the current status of the daemon as well
as the whole queue and all available information about every entry
in the queue.
`terminaltables` is used to format and display the queue contents.
`colorclass` is used to color format the various items ... | [
"Print",
"the",
"status",
"of",
"the",
"daemon",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/displaying.py#L19-L105 |
Nukesor/pueue | pueue/client/displaying.py | execute_log | def execute_log(args, root_dir):
"""Print the current log file.
Args:
args['keys'] (int): If given, we only look at the specified processes.
root_dir (string): The path to the root directory the daemon is running in.
"""
# Print the logs of all specified processes
if args.get('keys... | python | def execute_log(args, root_dir):
"""Print the current log file.
Args:
args['keys'] (int): If given, we only look at the specified processes.
root_dir (string): The path to the root directory the daemon is running in.
"""
# Print the logs of all specified processes
if args.get('keys... | [
"def",
"execute_log",
"(",
"args",
",",
"root_dir",
")",
":",
"# Print the logs of all specified processes",
"if",
"args",
".",
"get",
"(",
"'keys'",
")",
":",
"config_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_dir",
",",
"'.config/pueue'",
")",
"... | Print the current log file.
Args:
args['keys'] (int): If given, we only look at the specified processes.
root_dir (string): The path to the root directory the daemon is running in. | [
"Print",
"the",
"current",
"log",
"file",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/displaying.py#L108-L156 |
Nukesor/pueue | pueue/client/displaying.py | execute_show | def execute_show(args, root_dir):
"""Print stderr and stdout of the current running process.
Args:
args['watch'] (bool): If True, we open a curses session and tail
the output live in the console.
root_dir (string): The path to the root directory the daemon is runni... | python | def execute_show(args, root_dir):
"""Print stderr and stdout of the current running process.
Args:
args['watch'] (bool): If True, we open a curses session and tail
the output live in the console.
root_dir (string): The path to the root directory the daemon is runni... | [
"def",
"execute_show",
"(",
"args",
",",
"root_dir",
")",
":",
"key",
"=",
"None",
"if",
"args",
".",
"get",
"(",
"'key'",
")",
":",
"key",
"=",
"args",
"[",
"'key'",
"]",
"status",
"=",
"command_factory",
"(",
"'status'",
")",
"(",
"{",
"}",
",",
... | Print stderr and stdout of the current running process.
Args:
args['watch'] (bool): If True, we open a curses session and tail
the output live in the console.
root_dir (string): The path to the root directory the daemon is running in. | [
"Print",
"stderr",
"and",
"stdout",
"of",
"the",
"current",
"running",
"process",
"."
] | train | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/displaying.py#L159-L228 |
KKBOX/OpenAPI-Python | kkbox_developer_sdk/track_fetcher.py | KKBOXTrackFetcher.fetch_track | def fetch_track(self, track_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches a song track by given ID.
:param track_id: the track ID.
:type track_id: str
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.1/reference#tracks-track_id`.
''... | python | def fetch_track(self, track_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches a song track by given ID.
:param track_id: the track ID.
:type track_id: str
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.1/reference#tracks-track_id`.
''... | [
"def",
"fetch_track",
"(",
"self",
",",
"track_id",
",",
"terr",
"=",
"KKBOXTerritory",
".",
"TAIWAN",
")",
":",
"url",
"=",
"'https://api.kkbox.com/v1.1/tracks/%s'",
"%",
"track_id",
"url",
"+=",
"'?'",
"+",
"url_parse",
".",
"urlencode",
"(",
"{",
"'territor... | Fetches a song track by given ID.
:param track_id: the track ID.
:type track_id: str
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.1/reference#tracks-track_id`. | [
"Fetches",
"a",
"song",
"track",
"by",
"given",
"ID",
"."
] | train | https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/track_fetcher.py#L13-L26 |
csirtgadgets/csirtgsdk-py | csirtgsdk/indicator.py | Indicator.show | def show(self, user, feed, id):
"""
Show a specific indicator by id
:param user: feed username
:param feed: feed name
:param id: indicator endpoint id [INT]
:return: dict
Example:
ret = Indicator.show('csirtgadgets','port-scanners', '1234')
"... | python | def show(self, user, feed, id):
"""
Show a specific indicator by id
:param user: feed username
:param feed: feed name
:param id: indicator endpoint id [INT]
:return: dict
Example:
ret = Indicator.show('csirtgadgets','port-scanners', '1234')
"... | [
"def",
"show",
"(",
"self",
",",
"user",
",",
"feed",
",",
"id",
")",
":",
"uri",
"=",
"'/users/{}/feeds/{}/indicators/{}'",
".",
"format",
"(",
"user",
",",
"feed",
",",
"id",
")",
"return",
"self",
".",
"client",
".",
"get",
"(",
"uri",
")"
] | Show a specific indicator by id
:param user: feed username
:param feed: feed name
:param id: indicator endpoint id [INT]
:return: dict
Example:
ret = Indicator.show('csirtgadgets','port-scanners', '1234') | [
"Show",
"a",
"specific",
"indicator",
"by",
"id"
] | train | https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/indicator.py#L50-L63 |
csirtgadgets/csirtgsdk-py | csirtgsdk/indicator.py | Indicator.create | def create(self):
"""
Submit action on the Indicator object
:return: Indicator Object
"""
uri = '/users/{0}/feeds/{1}/indicators'\
.format(self.user, self.feed)
data = {
"indicator": json.loads(str(self.indicator)),
"comment": self.co... | python | def create(self):
"""
Submit action on the Indicator object
:return: Indicator Object
"""
uri = '/users/{0}/feeds/{1}/indicators'\
.format(self.user, self.feed)
data = {
"indicator": json.loads(str(self.indicator)),
"comment": self.co... | [
"def",
"create",
"(",
"self",
")",
":",
"uri",
"=",
"'/users/{0}/feeds/{1}/indicators'",
".",
"format",
"(",
"self",
".",
"user",
",",
"self",
".",
"feed",
")",
"data",
"=",
"{",
"\"indicator\"",
":",
"json",
".",
"loads",
"(",
"str",
"(",
"self",
".",... | Submit action on the Indicator object
:return: Indicator Object | [
"Submit",
"action",
"on",
"the",
"Indicator",
"object"
] | train | https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/indicator.py#L116-L146 |
csirtgadgets/csirtgsdk-py | csirtgsdk/indicator.py | Indicator.create_bulk | def create_bulk(self, indicators, user, feed):
from .constants import API_VERSION
if API_VERSION == '1':
print("create_bulk currently un-avail with APIv1")
raise SystemExit
"""
Submit action against the IndicatorBulk endpoint
:param indicators: list of I... | python | def create_bulk(self, indicators, user, feed):
from .constants import API_VERSION
if API_VERSION == '1':
print("create_bulk currently un-avail with APIv1")
raise SystemExit
"""
Submit action against the IndicatorBulk endpoint
:param indicators: list of I... | [
"def",
"create_bulk",
"(",
"self",
",",
"indicators",
",",
"user",
",",
"feed",
")",
":",
"from",
".",
"constants",
"import",
"API_VERSION",
"if",
"API_VERSION",
"==",
"'1'",
":",
"print",
"(",
"\"create_bulk currently un-avail with APIv1\"",
")",
"raise",
"Syst... | Submit action against the IndicatorBulk endpoint
:param indicators: list of Indicator Objects
:param user: feed username
:param feed: feed name
:return: list of Indicator Objects submitted
from csirtgsdk.client import Client
from csirtgsdk.indicator import Indicator
... | [
"Submit",
"action",
"against",
"the",
"IndicatorBulk",
"endpoint"
] | train | https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/indicator.py#L148-L212 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | bind_global_key | def bind_global_key(conn, event_type, key_string, cb):
"""
An alias for ``bind_key(event_type, ROOT_WINDOW, key_string, cb)``.
:param event_type: Either 'KeyPress' or 'KeyRelease'.
:type event_type: str
:param key_string: A string of the form 'Mod1-Control-a'.
Namely, a list o... | python | def bind_global_key(conn, event_type, key_string, cb):
"""
An alias for ``bind_key(event_type, ROOT_WINDOW, key_string, cb)``.
:param event_type: Either 'KeyPress' or 'KeyRelease'.
:type event_type: str
:param key_string: A string of the form 'Mod1-Control-a'.
Namely, a list o... | [
"def",
"bind_global_key",
"(",
"conn",
",",
"event_type",
",",
"key_string",
",",
"cb",
")",
":",
"root",
"=",
"conn",
".",
"get_setup",
"(",
")",
".",
"roots",
"[",
"0",
"]",
".",
"root",
"return",
"bind_key",
"(",
"conn",
",",
"event_type",
",",
"r... | An alias for ``bind_key(event_type, ROOT_WINDOW, key_string, cb)``.
:param event_type: Either 'KeyPress' or 'KeyRelease'.
:type event_type: str
:param key_string: A string of the form 'Mod1-Control-a'.
Namely, a list of zero or more modifiers separated by
'-', f... | [
"An",
"alias",
"for",
"bind_key",
"(",
"event_type",
"ROOT_WINDOW",
"key_string",
"cb",
")",
".",
":",
"param",
"event_type",
":",
"Either",
"KeyPress",
"or",
"KeyRelease",
".",
":",
"type",
"event_type",
":",
"str",
":",
"param",
"key_string",
":",
"A",
"... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L27-L42 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | bind_key | def bind_key(conn, event_type, wid, key_string, cb):
"""
Binds a function ``cb`` to a particular key press ``key_string`` on a
window ``wid``. Whether it's a key release or key press binding is
determined by ``event_type``.
``bind_key`` will automatically hook into the ``event`` module's dispatcher,... | python | def bind_key(conn, event_type, wid, key_string, cb):
"""
Binds a function ``cb`` to a particular key press ``key_string`` on a
window ``wid``. Whether it's a key release or key press binding is
determined by ``event_type``.
``bind_key`` will automatically hook into the ``event`` module's dispatcher,... | [
"def",
"bind_key",
"(",
"conn",
",",
"event_type",
",",
"wid",
",",
"key_string",
",",
"cb",
")",
":",
"assert",
"event_type",
"in",
"(",
"'KeyPress'",
",",
"'KeyRelease'",
")",
"mods",
",",
"kc",
"=",
"parse_keystring",
"(",
"conn",
",",
"key_string",
"... | Binds a function ``cb`` to a particular key press ``key_string`` on a
window ``wid``. Whether it's a key release or key press binding is
determined by ``event_type``.
``bind_key`` will automatically hook into the ``event`` module's dispatcher,
so that if you're using ``event.main()`` for your main loop,... | [
"Binds",
"a",
"function",
"cb",
"to",
"a",
"particular",
"key",
"press",
"key_string",
"on",
"a",
"window",
"wid",
".",
"Whether",
"it",
"s",
"a",
"key",
"release",
"or",
"key",
"press",
"binding",
"is",
"determined",
"by",
"event_type",
".",
"bind_key",
... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L44-L80 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | parse_keystring | def parse_keystring(conn, key_string):
"""
A utility function to turn strings like 'Mod1+Mod4+a' into a pair
corresponding to its modifiers and keycode.
:param key_string: String starting with zero or more modifiers followed
by exactly one key press.
Avail... | python | def parse_keystring(conn, key_string):
"""
A utility function to turn strings like 'Mod1+Mod4+a' into a pair
corresponding to its modifiers and keycode.
:param key_string: String starting with zero or more modifiers followed
by exactly one key press.
Avail... | [
"def",
"parse_keystring",
"(",
"conn",
",",
"key_string",
")",
":",
"# FIXME this code is temporary hack, requires better abstraction",
"from",
"PyQt5",
".",
"QtGui",
"import",
"QKeySequence",
"from",
"PyQt5",
".",
"QtCore",
"import",
"Qt",
"from",
".",
"qt_keycodes",
... | A utility function to turn strings like 'Mod1+Mod4+a' into a pair
corresponding to its modifiers and keycode.
:param key_string: String starting with zero or more modifiers followed
by exactly one key press.
Available modifiers: Control, Mod1, Mod2, Mod3, Mod4,
... | [
"A",
"utility",
"function",
"to",
"turn",
"strings",
"like",
"Mod1",
"+",
"Mod4",
"+",
"a",
"into",
"a",
"pair",
"corresponding",
"to",
"its",
"modifiers",
"and",
"keycode",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L82-L140 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | lookup_string | def lookup_string(conn, kstr):
"""
Finds the keycode associated with a string representation of a keysym.
:param kstr: English representation of a keysym.
:return: Keycode, if one exists.
:rtype: int
"""
if kstr in keysyms:
return get_keycode(conn, keysyms[kstr])
elif len(kstr) ... | python | def lookup_string(conn, kstr):
"""
Finds the keycode associated with a string representation of a keysym.
:param kstr: English representation of a keysym.
:return: Keycode, if one exists.
:rtype: int
"""
if kstr in keysyms:
return get_keycode(conn, keysyms[kstr])
elif len(kstr) ... | [
"def",
"lookup_string",
"(",
"conn",
",",
"kstr",
")",
":",
"if",
"kstr",
"in",
"keysyms",
":",
"return",
"get_keycode",
"(",
"conn",
",",
"keysyms",
"[",
"kstr",
"]",
")",
"elif",
"len",
"(",
"kstr",
")",
">",
"1",
"and",
"kstr",
".",
"capitalize",
... | Finds the keycode associated with a string representation of a keysym.
:param kstr: English representation of a keysym.
:return: Keycode, if one exists.
:rtype: int | [
"Finds",
"the",
"keycode",
"associated",
"with",
"a",
"string",
"representation",
"of",
"a",
"keysym",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L142-L155 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_keyboard_mapping | def get_keyboard_mapping(conn):
"""
Return a keyboard mapping cookie that can be used to fetch the table of
keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie
"""
mn, mx = get_min_max_keycode(conn)
return conn.core.GetKeyboardMapping(mn, mx - mn + 1) | python | def get_keyboard_mapping(conn):
"""
Return a keyboard mapping cookie that can be used to fetch the table of
keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie
"""
mn, mx = get_min_max_keycode(conn)
return conn.core.GetKeyboardMapping(mn, mx - mn + 1) | [
"def",
"get_keyboard_mapping",
"(",
"conn",
")",
":",
"mn",
",",
"mx",
"=",
"get_min_max_keycode",
"(",
"conn",
")",
"return",
"conn",
".",
"core",
".",
"GetKeyboardMapping",
"(",
"mn",
",",
"mx",
"-",
"mn",
"+",
"1",
")"
] | Return a keyboard mapping cookie that can be used to fetch the table of
keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie | [
"Return",
"a",
"keyboard",
"mapping",
"cookie",
"that",
"can",
"be",
"used",
"to",
"fetch",
"the",
"table",
"of",
"keysyms",
"in",
"the",
"current",
"X",
"environment",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L166-L175 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_keyboard_mapping_unchecked | def get_keyboard_mapping_unchecked(conn):
"""
Return an unchecked keyboard mapping cookie that can be used to fetch the
table of keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie
"""
mn, mx = get_min_max_keycode()
return conn.core.GetKeyboardMappingUnchecked... | python | def get_keyboard_mapping_unchecked(conn):
"""
Return an unchecked keyboard mapping cookie that can be used to fetch the
table of keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie
"""
mn, mx = get_min_max_keycode()
return conn.core.GetKeyboardMappingUnchecked... | [
"def",
"get_keyboard_mapping_unchecked",
"(",
"conn",
")",
":",
"mn",
",",
"mx",
"=",
"get_min_max_keycode",
"(",
")",
"return",
"conn",
".",
"core",
".",
"GetKeyboardMappingUnchecked",
"(",
"mn",
",",
"mx",
"-",
"mn",
"+",
"1",
")"
] | Return an unchecked keyboard mapping cookie that can be used to fetch the
table of keysyms in the current X environment.
:rtype: xcb.xproto.GetKeyboardMappingCookie | [
"Return",
"an",
"unchecked",
"keyboard",
"mapping",
"cookie",
"that",
"can",
"be",
"used",
"to",
"fetch",
"the",
"table",
"of",
"keysyms",
"in",
"the",
"current",
"X",
"environment",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L177-L186 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_keysym | def get_keysym(conn, keycode, col=0, kbmap=None):
"""
Get the keysym associated with a particular keycode in the current X
environment. Although we get a list of keysyms from X in
'get_keyboard_mapping', this list is really a table with
'keysys_per_keycode' columns and ``mx - mn`` rows (where ``mx``... | python | def get_keysym(conn, keycode, col=0, kbmap=None):
"""
Get the keysym associated with a particular keycode in the current X
environment. Although we get a list of keysyms from X in
'get_keyboard_mapping', this list is really a table with
'keysys_per_keycode' columns and ``mx - mn`` rows (where ``mx``... | [
"def",
"get_keysym",
"(",
"conn",
",",
"keycode",
",",
"col",
"=",
"0",
",",
"kbmap",
"=",
"None",
")",
":",
"if",
"kbmap",
"is",
"None",
":",
"kbmap",
"=",
"__kbmap",
"mn",
",",
"mx",
"=",
"get_min_max_keycode",
"(",
"conn",
")",
"per",
"=",
"kbma... | Get the keysym associated with a particular keycode in the current X
environment. Although we get a list of keysyms from X in
'get_keyboard_mapping', this list is really a table with
'keysys_per_keycode' columns and ``mx - mn`` rows (where ``mx`` is the
maximum keycode and ``mn`` is the minimum keycode)... | [
"Get",
"the",
"keysym",
"associated",
"with",
"a",
"particular",
"keycode",
"in",
"the",
"current",
"X",
"environment",
".",
"Although",
"we",
"get",
"a",
"list",
"of",
"keysyms",
"from",
"X",
"in",
"get_keyboard_mapping",
"this",
"list",
"is",
"really",
"a"... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L188-L223 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_keycode | def get_keycode(conn, keysym):
"""
Given a keysym, find the keycode mapped to it in the current X environment.
It is necessary to search the keysym table in order to do this, including
all columns.
:param keysym: An X keysym.
:return: A keycode or None if one could not be found.
:rtype: int... | python | def get_keycode(conn, keysym):
"""
Given a keysym, find the keycode mapped to it in the current X environment.
It is necessary to search the keysym table in order to do this, including
all columns.
:param keysym: An X keysym.
:return: A keycode or None if one could not be found.
:rtype: int... | [
"def",
"get_keycode",
"(",
"conn",
",",
"keysym",
")",
":",
"mn",
",",
"mx",
"=",
"get_min_max_keycode",
"(",
"conn",
")",
"cols",
"=",
"__kbmap",
".",
"keysyms_per_keycode",
"for",
"i",
"in",
"range",
"(",
"mn",
",",
"mx",
"+",
"1",
")",
":",
"for",... | Given a keysym, find the keycode mapped to it in the current X environment.
It is necessary to search the keysym table in order to do this, including
all columns.
:param keysym: An X keysym.
:return: A keycode or None if one could not be found.
:rtype: int | [
"Given",
"a",
"keysym",
"find",
"the",
"keycode",
"mapped",
"to",
"it",
"in",
"the",
"current",
"X",
"environment",
".",
"It",
"is",
"necessary",
"to",
"search",
"the",
"keysym",
"table",
"in",
"order",
"to",
"do",
"this",
"including",
"all",
"columns",
... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L235-L253 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_keys_to_mods | def get_keys_to_mods(conn):
"""
Fetches and creates the keycode -> modifier mask mapping. Typically, you
shouldn't have to use this---xpybutil will keep this up to date if it
changes.
This function may be useful in that it should closely replicate the output
of the ``xmodmap`` command. For exam... | python | def get_keys_to_mods(conn):
"""
Fetches and creates the keycode -> modifier mask mapping. Typically, you
shouldn't have to use this---xpybutil will keep this up to date if it
changes.
This function may be useful in that it should closely replicate the output
of the ``xmodmap`` command. For exam... | [
"def",
"get_keys_to_mods",
"(",
"conn",
")",
":",
"mm",
"=",
"xproto",
".",
"ModMask",
"modmasks",
"=",
"[",
"mm",
".",
"Shift",
",",
"mm",
".",
"Lock",
",",
"mm",
".",
"Control",
",",
"mm",
".",
"_1",
",",
"mm",
".",
"_2",
",",
"mm",
".",
"_3"... | Fetches and creates the keycode -> modifier mask mapping. Typically, you
shouldn't have to use this---xpybutil will keep this up to date if it
changes.
This function may be useful in that it should closely replicate the output
of the ``xmodmap`` command. For example:
::
keymods = get_key... | [
"Fetches",
"and",
"creates",
"the",
"keycode",
"-",
">",
"modifier",
"mask",
"mapping",
".",
"Typically",
"you",
"shouldn",
"t",
"have",
"to",
"use",
"this",
"---",
"xpybutil",
"will",
"keep",
"this",
"up",
"to",
"date",
"if",
"it",
"changes",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L255-L291 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | get_modifiers | def get_modifiers(state):
"""
Takes a ``state`` (typically found in key press or button press events)
and returns a string list representation of the modifiers that were pressed
when generating the event.
:param state: Typically from ``some_event.state``.
:return: List of modifier string repres... | python | def get_modifiers(state):
"""
Takes a ``state`` (typically found in key press or button press events)
and returns a string list representation of the modifiers that were pressed
when generating the event.
:param state: Typically from ``some_event.state``.
:return: List of modifier string repres... | [
"def",
"get_modifiers",
"(",
"state",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"state",
"&",
"xproto",
".",
"ModMask",
".",
"Shift",
":",
"ret",
".",
"append",
"(",
"'Shift'",
")",
"if",
"state",
"&",
"xproto",
".",
"ModMask",
".",
"Lock",
":",
"ret",... | Takes a ``state`` (typically found in key press or button press events)
and returns a string list representation of the modifiers that were pressed
when generating the event.
:param state: Typically from ``some_event.state``.
:return: List of modifier string representations.
:rtype: [str] | [
"Takes",
"a",
"state",
"(",
"typically",
"found",
"in",
"key",
"press",
"or",
"button",
"press",
"events",
")",
"and",
"returns",
"a",
"string",
"list",
"representation",
"of",
"the",
"modifiers",
"that",
"were",
"pressed",
"when",
"generating",
"the",
"even... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L293-L332 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | grab_key | def grab_key(conn, wid, modifiers, key):
"""
Grabs a key for a particular window and a modifiers/key value.
If the grab was successful, return True. Otherwise, return False.
If your client is grabbing keys, it is useful to notify the user if a
key wasn't grabbed. Keyboard shortcuts not responding is... | python | def grab_key(conn, wid, modifiers, key):
"""
Grabs a key for a particular window and a modifiers/key value.
If the grab was successful, return True. Otherwise, return False.
If your client is grabbing keys, it is useful to notify the user if a
key wasn't grabbed. Keyboard shortcuts not responding is... | [
"def",
"grab_key",
"(",
"conn",
",",
"wid",
",",
"modifiers",
",",
"key",
")",
":",
"try",
":",
"for",
"mod",
"in",
"TRIVIAL_MODS",
":",
"conn",
".",
"core",
".",
"GrabKeyChecked",
"(",
"True",
",",
"wid",
",",
"modifiers",
"|",
"mod",
",",
"key",
... | Grabs a key for a particular window and a modifiers/key value.
If the grab was successful, return True. Otherwise, return False.
If your client is grabbing keys, it is useful to notify the user if a
key wasn't grabbed. Keyboard shortcuts not responding is disorienting!
Also, this function will grab sev... | [
"Grabs",
"a",
"key",
"for",
"a",
"particular",
"window",
"and",
"a",
"modifiers",
"/",
"key",
"value",
".",
"If",
"the",
"grab",
"was",
"successful",
"return",
"True",
".",
"Otherwise",
"return",
"False",
".",
"If",
"your",
"client",
"is",
"grabbing",
"k... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L334-L363 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | ungrab_key | def ungrab_key(conn, wid, modifiers, key):
"""
Ungrabs a key that was grabbed by ``grab_key``. Similarly, it will return
True on success and False on failure.
When ungrabbing a key, the parameters to this function should be
*precisely* the same as the parameters to ``grab_key``.
:param wid: A ... | python | def ungrab_key(conn, wid, modifiers, key):
"""
Ungrabs a key that was grabbed by ``grab_key``. Similarly, it will return
True on success and False on failure.
When ungrabbing a key, the parameters to this function should be
*precisely* the same as the parameters to ``grab_key``.
:param wid: A ... | [
"def",
"ungrab_key",
"(",
"conn",
",",
"wid",
",",
"modifiers",
",",
"key",
")",
":",
"try",
":",
"for",
"mod",
"in",
"TRIVIAL_MODS",
":",
"conn",
".",
"core",
".",
"UngrabKeyChecked",
"(",
"key",
",",
"wid",
",",
"modifiers",
"|",
"mod",
")",
".",
... | Ungrabs a key that was grabbed by ``grab_key``. Similarly, it will return
True on success and False on failure.
When ungrabbing a key, the parameters to this function should be
*precisely* the same as the parameters to ``grab_key``.
:param wid: A window identifier.
:type wid: int
:param modifi... | [
"Ungrabs",
"a",
"key",
"that",
"was",
"grabbed",
"by",
"grab_key",
".",
"Similarly",
"it",
"will",
"return",
"True",
"on",
"success",
"and",
"False",
"on",
"failure",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L365-L387 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | update_keyboard_mapping | def update_keyboard_mapping(conn, e):
"""
Whenever the keyboard mapping is changed, this function needs to be called
to update xpybutil's internal representing of the current keysym table.
Indeed, xpybutil will do this for you automatically.
Moreover, if something is changed that affects the curren... | python | def update_keyboard_mapping(conn, e):
"""
Whenever the keyboard mapping is changed, this function needs to be called
to update xpybutil's internal representing of the current keysym table.
Indeed, xpybutil will do this for you automatically.
Moreover, if something is changed that affects the curren... | [
"def",
"update_keyboard_mapping",
"(",
"conn",
",",
"e",
")",
":",
"global",
"__kbmap",
",",
"__keysmods",
"newmap",
"=",
"get_keyboard_mapping",
"(",
"conn",
")",
".",
"reply",
"(",
")",
"if",
"e",
"is",
"None",
":",
"__kbmap",
"=",
"newmap",
"__keysmods"... | Whenever the keyboard mapping is changed, this function needs to be called
to update xpybutil's internal representing of the current keysym table.
Indeed, xpybutil will do this for you automatically.
Moreover, if something is changed that affects the current keygrabs,
xpybutil will initiate a regrab wi... | [
"Whenever",
"the",
"keyboard",
"mapping",
"is",
"changed",
"this",
"function",
"needs",
"to",
"be",
"called",
"to",
"update",
"xpybutil",
"s",
"internal",
"representing",
"of",
"the",
"current",
"keysym",
"table",
".",
"Indeed",
"xpybutil",
"will",
"do",
"this... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L389-L422 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | run_keybind_callbacks | def run_keybind_callbacks(e):
"""
A function that intercepts all key press/release events, and runs
their corresponding callback functions. Nothing much to see here, except
that we must mask out the trivial modifiers from the state in order to
find the right callback.
Callbacks are called in the... | python | def run_keybind_callbacks(e):
"""
A function that intercepts all key press/release events, and runs
their corresponding callback functions. Nothing much to see here, except
that we must mask out the trivial modifiers from the state in order to
find the right callback.
Callbacks are called in the... | [
"def",
"run_keybind_callbacks",
"(",
"e",
")",
":",
"kc",
",",
"mods",
"=",
"e",
".",
"detail",
",",
"e",
".",
"state",
"for",
"mod",
"in",
"TRIVIAL_MODS",
":",
"mods",
"&=",
"~",
"mod",
"key",
"=",
"(",
"e",
".",
"event",
",",
"mods",
",",
"kc",... | A function that intercepts all key press/release events, and runs
their corresponding callback functions. Nothing much to see here, except
that we must mask out the trivial modifiers from the state in order to
find the right callback.
Callbacks are called in the order that they have been added. (FIFO.)
... | [
"A",
"function",
"that",
"intercepts",
"all",
"key",
"press",
"/",
"release",
"events",
"and",
"runs",
"their",
"corresponding",
"callback",
"functions",
".",
"Nothing",
"much",
"to",
"see",
"here",
"except",
"that",
"we",
"must",
"mask",
"out",
"the",
"triv... | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L424-L447 |
codito/pyqtkeybind | pyqtkeybind/x11/keybindutil.py | __regrab | def __regrab(changes):
"""
Takes a dictionary of changes (mapping old keycode to new keycode) and
regrabs any keys that have been changed with the updated keycode.
:param changes: Mapping of changes from old keycode to new keycode.
:type changes: dict
:rtype: void
"""
for wid, mods, kc ... | python | def __regrab(changes):
"""
Takes a dictionary of changes (mapping old keycode to new keycode) and
regrabs any keys that have been changed with the updated keycode.
:param changes: Mapping of changes from old keycode to new keycode.
:type changes: dict
:rtype: void
"""
for wid, mods, kc ... | [
"def",
"__regrab",
"(",
"changes",
")",
":",
"for",
"wid",
",",
"mods",
",",
"kc",
"in",
"__keybinds",
".",
"keys",
"(",
")",
":",
"if",
"kc",
"in",
"changes",
":",
"ungrab_key",
"(",
"wid",
",",
"mods",
",",
"kc",
")",
"grab_key",
"(",
"wid",
",... | Takes a dictionary of changes (mapping old keycode to new keycode) and
regrabs any keys that have been changed with the updated keycode.
:param changes: Mapping of changes from old keycode to new keycode.
:type changes: dict
:rtype: void | [
"Takes",
"a",
"dictionary",
"of",
"changes",
"(",
"mapping",
"old",
"keycode",
"to",
"new",
"keycode",
")",
"and",
"regrabs",
"any",
"keys",
"that",
"have",
"been",
"changed",
"with",
"the",
"updated",
"keycode",
"."
] | train | https://github.com/codito/pyqtkeybind/blob/fbfedc654c4f77778d565b52ac76470631036255/pyqtkeybind/x11/keybindutil.py#L449-L466 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.get_storages | def get_storages(self, storage_type='normal'):
"""
Return a list of Storage objects from the API.
Storage types: public, private, normal, backup, cdrom, template, favorite
"""
res = self.get_request('/storage/' + storage_type)
return Storage._create_storage_objs(res['sto... | python | def get_storages(self, storage_type='normal'):
"""
Return a list of Storage objects from the API.
Storage types: public, private, normal, backup, cdrom, template, favorite
"""
res = self.get_request('/storage/' + storage_type)
return Storage._create_storage_objs(res['sto... | [
"def",
"get_storages",
"(",
"self",
",",
"storage_type",
"=",
"'normal'",
")",
":",
"res",
"=",
"self",
".",
"get_request",
"(",
"'/storage/'",
"+",
"storage_type",
")",
"return",
"Storage",
".",
"_create_storage_objs",
"(",
"res",
"[",
"'storages'",
"]",
",... | Return a list of Storage objects from the API.
Storage types: public, private, normal, backup, cdrom, template, favorite | [
"Return",
"a",
"list",
"of",
"Storage",
"objects",
"from",
"the",
"API",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L14-L21 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.get_storage | def get_storage(self, storage):
"""
Return a Storage object from the API.
"""
res = self.get_request('/storage/' + str(storage))
return Storage(cloud_manager=self, **res['storage']) | python | def get_storage(self, storage):
"""
Return a Storage object from the API.
"""
res = self.get_request('/storage/' + str(storage))
return Storage(cloud_manager=self, **res['storage']) | [
"def",
"get_storage",
"(",
"self",
",",
"storage",
")",
":",
"res",
"=",
"self",
".",
"get_request",
"(",
"'/storage/'",
"+",
"str",
"(",
"storage",
")",
")",
"return",
"Storage",
"(",
"cloud_manager",
"=",
"self",
",",
"*",
"*",
"res",
"[",
"'storage'... | Return a Storage object from the API. | [
"Return",
"a",
"Storage",
"object",
"from",
"the",
"API",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L23-L28 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.create_storage | def create_storage(self, size=10, tier='maxiops', title='Storage disk', zone='fi-hel1', backup_rule={}):
"""
Create a Storage object. Returns an object based on the API's response.
"""
body = {
'storage': {
'size': size,
'tier': tier,
... | python | def create_storage(self, size=10, tier='maxiops', title='Storage disk', zone='fi-hel1', backup_rule={}):
"""
Create a Storage object. Returns an object based on the API's response.
"""
body = {
'storage': {
'size': size,
'tier': tier,
... | [
"def",
"create_storage",
"(",
"self",
",",
"size",
"=",
"10",
",",
"tier",
"=",
"'maxiops'",
",",
"title",
"=",
"'Storage disk'",
",",
"zone",
"=",
"'fi-hel1'",
",",
"backup_rule",
"=",
"{",
"}",
")",
":",
"body",
"=",
"{",
"'storage'",
":",
"{",
"'s... | Create a Storage object. Returns an object based on the API's response. | [
"Create",
"a",
"Storage",
"object",
".",
"Returns",
"an",
"object",
"based",
"on",
"the",
"API",
"s",
"response",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L30-L44 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.modify_storage | def modify_storage(self, storage, size, title, backup_rule={}):
"""
Modify a Storage object. Returns an object based on the API's response.
"""
res = self._modify_storage(str(storage), size, title, backup_rule)
return Storage(cloud_manager=self, **res['storage']) | python | def modify_storage(self, storage, size, title, backup_rule={}):
"""
Modify a Storage object. Returns an object based on the API's response.
"""
res = self._modify_storage(str(storage), size, title, backup_rule)
return Storage(cloud_manager=self, **res['storage']) | [
"def",
"modify_storage",
"(",
"self",
",",
"storage",
",",
"size",
",",
"title",
",",
"backup_rule",
"=",
"{",
"}",
")",
":",
"res",
"=",
"self",
".",
"_modify_storage",
"(",
"str",
"(",
"storage",
")",
",",
"size",
",",
"title",
",",
"backup_rule",
... | Modify a Storage object. Returns an object based on the API's response. | [
"Modify",
"a",
"Storage",
"object",
".",
"Returns",
"an",
"object",
"based",
"on",
"the",
"API",
"s",
"response",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L56-L61 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.attach_storage | def attach_storage(self, server, storage, storage_type, address):
"""
Attach a Storage object to a Server. Return a list of the server's storages.
"""
body = {'storage_device': {}}
if storage:
body['storage_device']['storage'] = str(storage)
if storage_type:
... | python | def attach_storage(self, server, storage, storage_type, address):
"""
Attach a Storage object to a Server. Return a list of the server's storages.
"""
body = {'storage_device': {}}
if storage:
body['storage_device']['storage'] = str(storage)
if storage_type:
... | [
"def",
"attach_storage",
"(",
"self",
",",
"server",
",",
"storage",
",",
"storage_type",
",",
"address",
")",
":",
"body",
"=",
"{",
"'storage_device'",
":",
"{",
"}",
"}",
"if",
"storage",
":",
"body",
"[",
"'storage_device'",
"]",
"[",
"'storage'",
"]... | Attach a Storage object to a Server. Return a list of the server's storages. | [
"Attach",
"a",
"Storage",
"object",
"to",
"a",
"Server",
".",
"Return",
"a",
"list",
"of",
"the",
"server",
"s",
"storages",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L69-L85 |
UpCloudLtd/upcloud-python-api | upcloud_api/cloud_manager/storage_mixin.py | StorageManager.detach_storage | def detach_storage(self, server, address):
"""
Detach a Storage object to a Server. Return a list of the server's storages.
"""
body = {'storage_device': {'address': address}}
url = '/server/{0}/storage/detach'.format(server)
res = self.post_request(url, body)
ret... | python | def detach_storage(self, server, address):
"""
Detach a Storage object to a Server. Return a list of the server's storages.
"""
body = {'storage_device': {'address': address}}
url = '/server/{0}/storage/detach'.format(server)
res = self.post_request(url, body)
ret... | [
"def",
"detach_storage",
"(",
"self",
",",
"server",
",",
"address",
")",
":",
"body",
"=",
"{",
"'storage_device'",
":",
"{",
"'address'",
":",
"address",
"}",
"}",
"url",
"=",
"'/server/{0}/storage/detach'",
".",
"format",
"(",
"server",
")",
"res",
"=",... | Detach a Storage object to a Server. Return a list of the server's storages. | [
"Detach",
"a",
"Storage",
"object",
"to",
"a",
"Server",
".",
"Return",
"a",
"list",
"of",
"the",
"server",
"s",
"storages",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/cloud_manager/storage_mixin.py#L87-L94 |
UpCloudLtd/upcloud-python-api | upcloud_api/storage.py | Storage._reset | def _reset(self, **kwargs):
"""
Reset after repopulating from API.
"""
# there are some inconsistenciens in the API regarding these
# note: this could be written in fancier ways, but this way is simpler
if 'uuid' in kwargs:
self.uuid = kwargs['uuid']
... | python | def _reset(self, **kwargs):
"""
Reset after repopulating from API.
"""
# there are some inconsistenciens in the API regarding these
# note: this could be written in fancier ways, but this way is simpler
if 'uuid' in kwargs:
self.uuid = kwargs['uuid']
... | [
"def",
"_reset",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# there are some inconsistenciens in the API regarding these",
"# note: this could be written in fancier ways, but this way is simpler",
"if",
"'uuid'",
"in",
"kwargs",
":",
"self",
".",
"uuid",
"=",
"kwargs"... | Reset after repopulating from API. | [
"Reset",
"after",
"repopulating",
"from",
"API",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/storage.py#L29-L59 |
UpCloudLtd/upcloud-python-api | upcloud_api/storage.py | Storage.save | def save(self):
"""
Save (modify) the storage to the API.
Note: only size and title are updateable fields.
"""
res = self.cloud_manager._modify_storage(self, self.size, self.title)
self._reset(**res['storage']) | python | def save(self):
"""
Save (modify) the storage to the API.
Note: only size and title are updateable fields.
"""
res = self.cloud_manager._modify_storage(self, self.size, self.title)
self._reset(**res['storage']) | [
"def",
"save",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"cloud_manager",
".",
"_modify_storage",
"(",
"self",
",",
"self",
".",
"size",
",",
"self",
".",
"title",
")",
"self",
".",
"_reset",
"(",
"*",
"*",
"res",
"[",
"'storage'",
"]",
")"
] | Save (modify) the storage to the API.
Note: only size and title are updateable fields. | [
"Save",
"(",
"modify",
")",
"the",
"storage",
"to",
"the",
"API",
".",
"Note",
":",
"only",
"size",
"and",
"title",
"are",
"updateable",
"fields",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/storage.py#L67-L73 |
UpCloudLtd/upcloud-python-api | upcloud_api/storage.py | Storage.to_dict | def to_dict(self):
"""
Return a dict that can be serialised to JSON and sent to UpCloud's API.
Uses the convenience attribute `os` for determining `action` and `storage`
fields.
"""
body = {
'tier': self.tier,
'title': self.title,
'siz... | python | def to_dict(self):
"""
Return a dict that can be serialised to JSON and sent to UpCloud's API.
Uses the convenience attribute `os` for determining `action` and `storage`
fields.
"""
body = {
'tier': self.tier,
'title': self.title,
'siz... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"body",
"=",
"{",
"'tier'",
":",
"self",
".",
"tier",
",",
"'title'",
":",
"self",
".",
"title",
",",
"'size'",
":",
"self",
".",
"size",
",",
"}",
"# optionals",
"if",
"hasattr",
"(",
"self",
",",
"'address... | Return a dict that can be serialised to JSON and sent to UpCloud's API.
Uses the convenience attribute `os` for determining `action` and `storage`
fields. | [
"Return",
"a",
"dict",
"that",
"can",
"be",
"serialised",
"to",
"JSON",
"and",
"sent",
"to",
"UpCloud",
"s",
"API",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/storage.py#L82-L103 |
KKBOX/OpenAPI-Python | kkbox_developer_sdk/album_fetcher.py | KKBOXAlbumFetcher.fetch_album | def fetch_album(self, album_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches an album by given ID.
:param album_id: the album ID.
:type album_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.... | python | def fetch_album(self, album_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches an album by given ID.
:param album_id: the album ID.
:type album_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.... | [
"def",
"fetch_album",
"(",
"self",
",",
"album_id",
",",
"terr",
"=",
"KKBOXTerritory",
".",
"TAIWAN",
")",
":",
"url",
"=",
"'https://api.kkbox.com/v1.1/albums/%s'",
"%",
"album_id",
"url",
"+=",
"'?'",
"+",
"url_parse",
".",
"urlencode",
"(",
"{",
"'territor... | Fetches an album by given ID.
:param album_id: the album ID.
:type album_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
See `https://docs-en.kkbox.codes/v1.1/reference#albums-album_id`. | [
"Fetches",
"an",
"album",
"by",
"given",
"ID",
"."
] | train | https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/album_fetcher.py#L13-L27 |
fm4d/KickassAPI | KickassAPI.py | Torrent.lookup | def lookup(self):
"""
Prints name, author, size and age
"""
print "%s by %s, size: %s, uploaded %s ago" % (self.name, self.author,
self.size, self.age) | python | def lookup(self):
"""
Prints name, author, size and age
"""
print "%s by %s, size: %s, uploaded %s ago" % (self.name, self.author,
self.size, self.age) | [
"def",
"lookup",
"(",
"self",
")",
":",
"print",
"\"%s by %s, size: %s, uploaded %s ago\"",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"author",
",",
"self",
".",
"size",
",",
"self",
".",
"age",
")"
] | Prints name, author, size and age | [
"Prints",
"name",
"author",
"size",
"and",
"age"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L60-L65 |
fm4d/KickassAPI | KickassAPI.py | Url._get_max_page | def _get_max_page(self, url):
"""
Open url and return amount of pages
"""
html = requests.get(url).text
pq = PyQuery(html)
try:
tds = int(pq("h2").text().split()[-1])
if tds % 25:
return tds / 25 + 1
return tds / 25
... | python | def _get_max_page(self, url):
"""
Open url and return amount of pages
"""
html = requests.get(url).text
pq = PyQuery(html)
try:
tds = int(pq("h2").text().split()[-1])
if tds % 25:
return tds / 25 + 1
return tds / 25
... | [
"def",
"_get_max_page",
"(",
"self",
",",
"url",
")",
":",
"html",
"=",
"requests",
".",
"get",
"(",
"url",
")",
".",
"text",
"pq",
"=",
"PyQuery",
"(",
"html",
")",
"try",
":",
"tds",
"=",
"int",
"(",
"pq",
"(",
"\"h2\"",
")",
".",
"text",
"("... | Open url and return amount of pages | [
"Open",
"url",
"and",
"return",
"amount",
"of",
"pages"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L88-L100 |
fm4d/KickassAPI | KickassAPI.py | SearchUrl.build | def build(self, update=True):
"""
Build and return url. Also update max_page.
"""
ret = self.base + self.query
page = "".join(("/", str(self.page), "/"))
if self.category:
category = " category:" + self.category
else:
category = ""
... | python | def build(self, update=True):
"""
Build and return url. Also update max_page.
"""
ret = self.base + self.query
page = "".join(("/", str(self.page), "/"))
if self.category:
category = " category:" + self.category
else:
category = ""
... | [
"def",
"build",
"(",
"self",
",",
"update",
"=",
"True",
")",
":",
"ret",
"=",
"self",
".",
"base",
"+",
"self",
".",
"query",
"page",
"=",
"\"\"",
".",
"join",
"(",
"(",
"\"/\"",
",",
"str",
"(",
"self",
".",
"page",
")",
",",
"\"/\"",
")",
... | Build and return url. Also update max_page. | [
"Build",
"and",
"return",
"url",
".",
"Also",
"update",
"max_page",
"."
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L143-L164 |
fm4d/KickassAPI | KickassAPI.py | UserUrl.build | def build(self, update=True):
"""
Build and return url. Also update max_page.
URL structure for user torrent lists differs from other result lists
as the page number is part of the query string and not the URL path
"""
query_str = "?page={}".format(self.page)
if s... | python | def build(self, update=True):
"""
Build and return url. Also update max_page.
URL structure for user torrent lists differs from other result lists
as the page number is part of the query string and not the URL path
"""
query_str = "?page={}".format(self.page)
if s... | [
"def",
"build",
"(",
"self",
",",
"update",
"=",
"True",
")",
":",
"query_str",
"=",
"\"?page={}\"",
".",
"format",
"(",
"self",
".",
"page",
")",
"if",
"self",
".",
"order",
":",
"query_str",
"+=",
"\"\"",
".",
"join",
"(",
"(",
"\"&field=\"",
",",
... | Build and return url. Also update max_page.
URL structure for user torrent lists differs from other result lists
as the page number is part of the query string and not the URL path | [
"Build",
"and",
"return",
"url",
".",
"Also",
"update",
"max_page",
".",
"URL",
"structure",
"for",
"user",
"torrent",
"lists",
"differs",
"from",
"other",
"result",
"lists",
"as",
"the",
"page",
"number",
"is",
"part",
"of",
"the",
"query",
"string",
"and... | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L177-L191 |
fm4d/KickassAPI | KickassAPI.py | Results._items | def _items(self):
"""
Parse url and yield namedtuple Torrent for every torrent on page
"""
torrents = map(self._get_torrent, self._get_rows())
for t in torrents:
yield t | python | def _items(self):
"""
Parse url and yield namedtuple Torrent for every torrent on page
"""
torrents = map(self._get_torrent, self._get_rows())
for t in torrents:
yield t | [
"def",
"_items",
"(",
"self",
")",
":",
"torrents",
"=",
"map",
"(",
"self",
".",
"_get_torrent",
",",
"self",
".",
"_get_rows",
"(",
")",
")",
"for",
"t",
"in",
"torrents",
":",
"yield",
"t"
] | Parse url and yield namedtuple Torrent for every torrent on page | [
"Parse",
"url",
"and",
"yield",
"namedtuple",
"Torrent",
"for",
"every",
"torrent",
"on",
"page"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L205-L212 |
fm4d/KickassAPI | KickassAPI.py | Results._get_torrent | def _get_torrent(self, row):
"""
Parse row into namedtuple
"""
td = row("td")
name = td("a.cellMainLink").text()
name = name.replace(" . ", ".").replace(" .", ".")
author = td("a.plain").text()
verified_author = True if td(".lightgrey>.ka-verify") else Fal... | python | def _get_torrent(self, row):
"""
Parse row into namedtuple
"""
td = row("td")
name = td("a.cellMainLink").text()
name = name.replace(" . ", ".").replace(" .", ".")
author = td("a.plain").text()
verified_author = True if td(".lightgrey>.ka-verify") else Fal... | [
"def",
"_get_torrent",
"(",
"self",
",",
"row",
")",
":",
"td",
"=",
"row",
"(",
"\"td\"",
")",
"name",
"=",
"td",
"(",
"\"a.cellMainLink\"",
")",
".",
"text",
"(",
")",
"name",
"=",
"name",
".",
"replace",
"(",
"\" . \"",
",",
"\".\"",
")",
".",
... | Parse row into namedtuple | [
"Parse",
"row",
"into",
"namedtuple"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L222-L249 |
fm4d/KickassAPI | KickassAPI.py | Results._get_rows | def _get_rows(self):
"""
Return all rows on page
"""
html = requests.get(self.url.build()).text
if re.search('did not match any documents', html):
return []
pq = PyQuery(html)
rows = pq("table.data").find("tr")
return map(rows.eq, range(rows.si... | python | def _get_rows(self):
"""
Return all rows on page
"""
html = requests.get(self.url.build()).text
if re.search('did not match any documents', html):
return []
pq = PyQuery(html)
rows = pq("table.data").find("tr")
return map(rows.eq, range(rows.si... | [
"def",
"_get_rows",
"(",
"self",
")",
":",
"html",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
".",
"build",
"(",
")",
")",
".",
"text",
"if",
"re",
".",
"search",
"(",
"'did not match any documents'",
",",
"html",
")",
":",
"return",
"[",
... | Return all rows on page | [
"Return",
"all",
"rows",
"on",
"page"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L251-L260 |
fm4d/KickassAPI | KickassAPI.py | Results.pages | def pages(self, page_from, page_to):
"""
Yield torrents in range from page_from to page_to
"""
if not all([page_from < self.url.max_page, page_from > 0,
page_to <= self.url.max_page, page_to > page_from]):
raise IndexError("Invalid page numbers")
... | python | def pages(self, page_from, page_to):
"""
Yield torrents in range from page_from to page_to
"""
if not all([page_from < self.url.max_page, page_from > 0,
page_to <= self.url.max_page, page_to > page_from]):
raise IndexError("Invalid page numbers")
... | [
"def",
"pages",
"(",
"self",
",",
"page_from",
",",
"page_to",
")",
":",
"if",
"not",
"all",
"(",
"[",
"page_from",
"<",
"self",
".",
"url",
".",
"max_page",
",",
"page_from",
">",
"0",
",",
"page_to",
"<=",
"self",
".",
"url",
".",
"max_page",
","... | Yield torrents in range from page_from to page_to | [
"Yield",
"torrents",
"in",
"range",
"from",
"page_from",
"to",
"page_to"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L283-L320 |
fm4d/KickassAPI | KickassAPI.py | Results.all | def all(self):
"""
Yield torrents in range from current page to last page
"""
return self.pages(self.url.page, self.url.max_page) | python | def all(self):
"""
Yield torrents in range from current page to last page
"""
return self.pages(self.url.page, self.url.max_page) | [
"def",
"all",
"(",
"self",
")",
":",
"return",
"self",
".",
"pages",
"(",
"self",
".",
"url",
".",
"page",
",",
"self",
".",
"url",
".",
"max_page",
")"
] | Yield torrents in range from current page to last page | [
"Yield",
"torrents",
"in",
"range",
"from",
"current",
"page",
"to",
"last",
"page"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L322-L326 |
fm4d/KickassAPI | KickassAPI.py | Results.order | def order(self, field, order=None):
"""
Set field and order set by arguments
"""
if not order:
order = ORDER.DESC
self.url.order = (field, order)
self.url.set_page(1)
return self | python | def order(self, field, order=None):
"""
Set field and order set by arguments
"""
if not order:
order = ORDER.DESC
self.url.order = (field, order)
self.url.set_page(1)
return self | [
"def",
"order",
"(",
"self",
",",
"field",
",",
"order",
"=",
"None",
")",
":",
"if",
"not",
"order",
":",
"order",
"=",
"ORDER",
".",
"DESC",
"self",
".",
"url",
".",
"order",
"=",
"(",
"field",
",",
"order",
")",
"self",
".",
"url",
".",
"set... | Set field and order set by arguments | [
"Set",
"field",
"and",
"order",
"set",
"by",
"arguments"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L328-L336 |
fm4d/KickassAPI | KickassAPI.py | Search.category | def category(self, category):
"""
Change category of current search and return self
"""
self.url.category = category
self.url.set_page(1)
return self | python | def category(self, category):
"""
Change category of current search and return self
"""
self.url.category = category
self.url.set_page(1)
return self | [
"def",
"category",
"(",
"self",
",",
"category",
")",
":",
"self",
".",
"url",
".",
"category",
"=",
"category",
"self",
".",
"url",
".",
"set_page",
"(",
"1",
")",
"return",
"self"
] | Change category of current search and return self | [
"Change",
"category",
"of",
"current",
"search",
"and",
"return",
"self"
] | train | https://github.com/fm4d/KickassAPI/blob/6ecc6846dcec0d6f6e493bf776031aa92d55604f/KickassAPI.py#L362-L368 |
UpCloudLtd/upcloud-python-api | upcloud_api/firewall.py | FirewallRule.destroy | def destroy(self):
"""
Remove this FirewallRule from the API.
This instance must be associated with a server for this method to work,
which is done by instantiating via server.get_firewall_rules().
"""
if not hasattr(self, 'server') or not self.server:
raise ... | python | def destroy(self):
"""
Remove this FirewallRule from the API.
This instance must be associated with a server for this method to work,
which is done by instantiating via server.get_firewall_rules().
"""
if not hasattr(self, 'server') or not self.server:
raise ... | [
"def",
"destroy",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'server'",
")",
"or",
"not",
"self",
".",
"server",
":",
"raise",
"Exception",
"(",
"\"\"\"FirewallRule not associated with server;\n please use or server.get_firewall_rul... | Remove this FirewallRule from the API.
This instance must be associated with a server for this method to work,
which is done by instantiating via server.get_firewall_rules(). | [
"Remove",
"this",
"FirewallRule",
"from",
"the",
"API",
"."
] | train | https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/firewall.py#L27-L43 |
KKBOX/OpenAPI-Python | kkbox_developer_sdk/new_release_category_fetcher.py | KKBOXNewReleaseCategoryFetcher.fetch_new_release_category | def fetch_new_release_category(self, category_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches new release categories by given ID.
:param category_id: the station ID.
:type category_id: str
:param terr: the current territory.
:return: API response.
:rtype: list
... | python | def fetch_new_release_category(self, category_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetches new release categories by given ID.
:param category_id: the station ID.
:type category_id: str
:param terr: the current territory.
:return: API response.
:rtype: list
... | [
"def",
"fetch_new_release_category",
"(",
"self",
",",
"category_id",
",",
"terr",
"=",
"KKBOXTerritory",
".",
"TAIWAN",
")",
":",
"url",
"=",
"'https://api.kkbox.com/v1.1/new-release-categories/%s'",
"%",
"category_id",
"url",
"+=",
"'?'",
"+",
"url_parse",
".",
"u... | Fetches new release categories by given ID.
:param category_id: the station ID.
:type category_id: str
:param terr: the current territory.
:return: API response.
:rtype: list
See `https://docs-en.kkbox.codes/v1.1/reference#newreleasecategories-category_id` | [
"Fetches",
"new",
"release",
"categories",
"by",
"given",
"ID",
"."
] | train | https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/new_release_category_fetcher.py#L28-L42 |
KKBOX/OpenAPI-Python | kkbox_developer_sdk/artist_fetcher.py | KKBOXArtistFetcher.fetch_top_tracks_of_artist | def fetch_top_tracks_of_artist(self, artist_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetcher top tracks belong to an artist by given ID.
:param artist_id: the artist ID.
:type artist_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
... | python | def fetch_top_tracks_of_artist(self, artist_id, terr=KKBOXTerritory.TAIWAN):
'''
Fetcher top tracks belong to an artist by given ID.
:param artist_id: the artist ID.
:type artist_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
... | [
"def",
"fetch_top_tracks_of_artist",
"(",
"self",
",",
"artist_id",
",",
"terr",
"=",
"KKBOXTerritory",
".",
"TAIWAN",
")",
":",
"url",
"=",
"'https://api.kkbox.com/v1.1/artists/%s/top-tracks'",
"%",
"artist_id",
"url",
"+=",
"'?'",
"+",
"url_parse",
".",
"urlencode... | Fetcher top tracks belong to an artist by given ID.
:param artist_id: the artist ID.
:type artist_id: str
:param terr: the current territory.
:return: API response.
:rtype: dict
See 'https://docs-en.kkbox.codes/v1.1/reference#artists-artist_id-toptracks' | [
"Fetcher",
"top",
"tracks",
"belong",
"to",
"an",
"artist",
"by",
"given",
"ID",
"."
] | train | https://github.com/KKBOX/OpenAPI-Python/blob/77aa22fd300ed987d5507a5b66b149edcd28047d/kkbox_developer_sdk/artist_fetcher.py#L47-L61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.