partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | load_midi_file | Yield (pitch, start_beat, end_beat) for each note in midi file. | examples/import_midi.py | def load_midi_file(path):
"""Yield (pitch, start_beat, end_beat) for each note in midi file."""
midi_notes = []
def register_note(track, channel, pitch, velocity, start, end):
midi_notes.append((pitch, start, end))
midi.register_note = register_note
global m
m = midi.MidiFile()
m.o... | def load_midi_file(path):
"""Yield (pitch, start_beat, end_beat) for each note in midi file."""
midi_notes = []
def register_note(track, channel, pitch, velocity, start, end):
midi_notes.append((pitch, start, end))
midi.register_note = register_note
global m
m = midi.MidiFile()
m.o... | [
"Yield",
"(",
"pitch",
"start_beat",
"end_beat",
")",
"for",
"each",
"note",
"in",
"midi",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/examples/import_midi.py#L24-L41 | [
"def",
"load_midi_file",
"(",
"path",
")",
":",
"midi_notes",
"=",
"[",
"]",
"def",
"register_note",
"(",
"track",
",",
"channel",
",",
"pitch",
",",
"velocity",
",",
"start",
",",
"end",
")",
":",
"midi_notes",
".",
"append",
"(",
"(",
"pitch",
",",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Serializer.get_media | Return (images, sounds) | kurt/scratch14/__init__.py | def get_media(self, v14_scriptable):
"""Return (images, sounds)"""
images = []
sounds = []
for media in v14_scriptable.media:
if media.class_name == 'SoundMedia':
sounds.append(media)
elif media.class_name == 'ImageMedia':
images.ap... | def get_media(self, v14_scriptable):
"""Return (images, sounds)"""
images = []
sounds = []
for media in v14_scriptable.media:
if media.class_name == 'SoundMedia':
sounds.append(media)
elif media.class_name == 'ImageMedia':
images.ap... | [
"Return",
"(",
"images",
"sounds",
")"
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/__init__.py#L216-L225 | [
"def",
"get_media",
"(",
"self",
",",
"v14_scriptable",
")",
":",
"images",
"=",
"[",
"]",
"sounds",
"=",
"[",
"]",
"for",
"media",
"in",
"v14_scriptable",
".",
"media",
":",
"if",
"media",
".",
"class_name",
"==",
"'SoundMedia'",
":",
"sounds",
".",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Bitmap.from_byte_array | Decodes a run-length encoded ByteArray and returns a Bitmap.
The ByteArray decompresses to a sequence of 32-bit values, which are
stored as a byte string. (The specific encoding depends on Form.depth.) | kurt/scratch14/fixed_objects.py | def from_byte_array(cls, bytes_):
"""Decodes a run-length encoded ByteArray and returns a Bitmap.
The ByteArray decompresses to a sequence of 32-bit values, which are
stored as a byte string. (The specific encoding depends on Form.depth.)
"""
runs = cls._length_run_coding.parse(b... | def from_byte_array(cls, bytes_):
"""Decodes a run-length encoded ByteArray and returns a Bitmap.
The ByteArray decompresses to a sequence of 32-bit values, which are
stored as a byte string. (The specific encoding depends on Form.depth.)
"""
runs = cls._length_run_coding.parse(b... | [
"Decodes",
"a",
"run",
"-",
"length",
"encoded",
"ByteArray",
"and",
"returns",
"a",
"Bitmap",
".",
"The",
"ByteArray",
"decompresses",
"to",
"a",
"sequence",
"of",
"32",
"-",
"bit",
"values",
"which",
"are",
"stored",
"as",
"a",
"byte",
"string",
".",
"... | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/fixed_objects.py#L521-L529 | [
"def",
"from_byte_array",
"(",
"cls",
",",
"bytes_",
")",
":",
"runs",
"=",
"cls",
".",
"_length_run_coding",
".",
"parse",
"(",
"bytes_",
")",
"pixels",
"=",
"(",
"run",
".",
"pixels",
"for",
"run",
"in",
"runs",
".",
"data",
")",
"data",
"=",
"\"\"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Form.from_string | Returns a Form with 32-bit RGBA pixels
Accepts string containing raw RGBA color values | kurt/scratch14/fixed_objects.py | def from_string(cls, width, height, rgba_string):
"""Returns a Form with 32-bit RGBA pixels
Accepts string containing raw RGBA color values
"""
# Convert RGBA string to ARGB
raw = ""
for i in range(0, len(rgba_string), 4):
raw += rgba_string[i+3] # alpha
... | def from_string(cls, width, height, rgba_string):
"""Returns a Form with 32-bit RGBA pixels
Accepts string containing raw RGBA color values
"""
# Convert RGBA string to ARGB
raw = ""
for i in range(0, len(rgba_string), 4):
raw += rgba_string[i+3] # alpha
... | [
"Returns",
"a",
"Form",
"with",
"32",
"-",
"bit",
"RGBA",
"pixels",
"Accepts",
"string",
"containing",
"raw",
"RGBA",
"color",
"values"
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/fixed_objects.py#L642-L659 | [
"def",
"from_string",
"(",
"cls",
",",
"width",
",",
"height",
",",
"rgba_string",
")",
":",
"# Convert RGBA string to ARGB",
"raw",
"=",
"\"\"",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"rgba_string",
")",
",",
"4",
")",
":",
"raw",
"+=",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | open_file | Opens Explorer/Finder with given path, depending on platform | util/kurtgui.py | def open_file(path):
"""Opens Explorer/Finder with given path, depending on platform"""
if sys.platform=='win32':
os.startfile(path)
#subprocess.Popen(['start', path], shell= True)
elif sys.platform=='darwin':
subprocess.Popen(['open', path])
else:
try:
... | def open_file(path):
"""Opens Explorer/Finder with given path, depending on platform"""
if sys.platform=='win32':
os.startfile(path)
#subprocess.Popen(['start', path], shell= True)
elif sys.platform=='darwin':
subprocess.Popen(['open', path])
else:
try:
... | [
"Opens",
"Explorer",
"/",
"Finder",
"with",
"given",
"path",
"depending",
"on",
"platform"
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/util/kurtgui.py#L60-L73 | [
"def",
"open_file",
"(",
"path",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"'win32'",
":",
"os",
".",
"startfile",
"(",
"path",
")",
"#subprocess.Popen(['start', path], shell= True)",
"elif",
"sys",
".",
"platform",
"==",
"'darwin'",
":",
"subprocess",
"."... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | App.set_file_path | Update the file_path Entry widget | util/kurtgui.py | def set_file_path(self, path):
"""Update the file_path Entry widget"""
self.file_path.delete(0, END)
self.file_path.insert(0, path) | def set_file_path(self, path):
"""Update the file_path Entry widget"""
self.file_path.delete(0, END)
self.file_path.insert(0, path) | [
"Update",
"the",
"file_path",
"Entry",
"widget"
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/util/kurtgui.py#L175-L178 | [
"def",
"set_file_path",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"file_path",
".",
"delete",
"(",
"0",
",",
"END",
")",
"self",
".",
"file_path",
".",
"insert",
"(",
"0",
",",
"path",
")"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Project.load | Load project from file.
Use ``format`` to specify the file format to use.
Path can be a file-like object, in which case format is required.
Otherwise, can guess the appropriate format from the extension.
If you pass a file-like object, you're responsible for closing the
file.
... | kurt/__init__.py | def load(cls, path, format=None):
"""Load project from file.
Use ``format`` to specify the file format to use.
Path can be a file-like object, in which case format is required.
Otherwise, can guess the appropriate format from the extension.
If you pass a file-like object, you'... | def load(cls, path, format=None):
"""Load project from file.
Use ``format`` to specify the file format to use.
Path can be a file-like object, in which case format is required.
Otherwise, can guess the appropriate format from the extension.
If you pass a file-like object, you'... | [
"Load",
"project",
"from",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L232-L276 | [
"def",
"load",
"(",
"cls",
",",
"path",
",",
"format",
"=",
"None",
")",
":",
"path_was_string",
"=",
"isinstance",
"(",
"path",
",",
"basestring",
")",
"if",
"path_was_string",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Project.copy | Return a new Project instance, deep-copying all the attributes. | kurt/__init__.py | def copy(self):
"""Return a new Project instance, deep-copying all the attributes."""
p = Project()
p.name = self.name
p.path = self.path
p._plugin = self._plugin
p.stage = self.stage.copy()
p.stage.project = p
for sprite in self.sprites:
s = ... | def copy(self):
"""Return a new Project instance, deep-copying all the attributes."""
p = Project()
p.name = self.name
p.path = self.path
p._plugin = self._plugin
p.stage = self.stage.copy()
p.stage.project = p
for sprite in self.sprites:
s = ... | [
"Return",
"a",
"new",
"Project",
"instance",
"deep",
"-",
"copying",
"all",
"the",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L278-L312 | [
"def",
"copy",
"(",
"self",
")",
":",
"p",
"=",
"Project",
"(",
")",
"p",
".",
"name",
"=",
"self",
".",
"name",
"p",
".",
"path",
"=",
"self",
".",
"path",
"p",
".",
"_plugin",
"=",
"self",
".",
"_plugin",
"p",
".",
"stage",
"=",
"self",
"."... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Project.convert | Convert the project in-place to a different file format.
Returns a list of :class:`UnsupportedFeature` objects, which may give
warnings about the conversion.
:param format: :attr:`KurtFileFormat.name` eg. ``"scratch14"``.
:raises: :class:`ValueError` if the format doesn't exist. | kurt/__init__.py | def convert(self, format):
"""Convert the project in-place to a different file format.
Returns a list of :class:`UnsupportedFeature` objects, which may give
warnings about the conversion.
:param format: :attr:`KurtFileFormat.name` eg. ``"scratch14"``.
:raises: :class:`ValueErr... | def convert(self, format):
"""Convert the project in-place to a different file format.
Returns a list of :class:`UnsupportedFeature` objects, which may give
warnings about the conversion.
:param format: :attr:`KurtFileFormat.name` eg. ``"scratch14"``.
:raises: :class:`ValueErr... | [
"Convert",
"the",
"project",
"in",
"-",
"place",
"to",
"a",
"different",
"file",
"format",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L314-L326 | [
"def",
"convert",
"(",
"self",
",",
"format",
")",
":",
"self",
".",
"_plugin",
"=",
"kurt",
".",
"plugin",
".",
"Kurt",
".",
"get_plugin",
"(",
"format",
")",
"return",
"list",
"(",
"self",
".",
"_normalize",
"(",
")",
")"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Project.save | Save project to file.
:param path: Path or file pointer.
If you pass a file pointer, you're responsible for closing
it.
If path is not given, the :attr:`path` attribute is used,
usually the original path given to :attr:`load(... | kurt/__init__.py | def save(self, path=None, debug=False):
"""Save project to file.
:param path: Path or file pointer.
If you pass a file pointer, you're responsible for closing
it.
If path is not given, the :attr:`path` attribute is used,
... | def save(self, path=None, debug=False):
"""Save project to file.
:param path: Path or file pointer.
If you pass a file pointer, you're responsible for closing
it.
If path is not given, the :attr:`path` attribute is used,
... | [
"Save",
"project",
"to",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L328-L402 | [
"def",
"save",
"(",
"self",
",",
"path",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"p",
"=",
"self",
".",
"copy",
"(",
")",
"plugin",
"=",
"p",
".",
"_plugin",
"# require path",
"p",
".",
"path",
"=",
"path",
"or",
"self",
".",
"path",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Project._normalize | Convert the project to a standardised form for the current plugin.
Called after loading, before saving, and when converting to a new
format.
Yields UnsupportedFeature instances. | kurt/__init__.py | def _normalize(self):
"""Convert the project to a standardised form for the current plugin.
Called after loading, before saving, and when converting to a new
format.
Yields UnsupportedFeature instances.
"""
unique_sprite_names = set(sprite.name for sprite in self.spri... | def _normalize(self):
"""Convert the project to a standardised form for the current plugin.
Called after loading, before saving, and when converting to a new
format.
Yields UnsupportedFeature instances.
"""
unique_sprite_names = set(sprite.name for sprite in self.spri... | [
"Convert",
"the",
"project",
"to",
"a",
"standardised",
"form",
"for",
"the",
"current",
"plugin",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L407-L506 | [
"def",
"_normalize",
"(",
"self",
")",
":",
"unique_sprite_names",
"=",
"set",
"(",
"sprite",
".",
"name",
"for",
"sprite",
"in",
"self",
".",
"sprites",
")",
"if",
"len",
"(",
"unique_sprite_names",
")",
"<",
"len",
"(",
"self",
".",
"sprites",
")",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Scriptable.copy | Return a new instance, deep-copying all the attributes. | kurt/__init__.py | def copy(self, o=None):
"""Return a new instance, deep-copying all the attributes."""
if o is None: o = self.__class__(self.project)
o.scripts = [s.copy() for s in self.scripts]
o.variables = dict((n, v.copy()) for (n, v) in self.variables.items())
o.lists = dict((n, l.copy()) fo... | def copy(self, o=None):
"""Return a new instance, deep-copying all the attributes."""
if o is None: o = self.__class__(self.project)
o.scripts = [s.copy() for s in self.scripts]
o.variables = dict((n, v.copy()) for (n, v) in self.variables.items())
o.lists = dict((n, l.copy()) fo... | [
"Return",
"a",
"new",
"instance",
"deep",
"-",
"copying",
"all",
"the",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L675-L685 | [
"def",
"copy",
"(",
"self",
",",
"o",
"=",
"None",
")",
":",
"if",
"o",
"is",
"None",
":",
"o",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"project",
")",
"o",
".",
"scripts",
"=",
"[",
"s",
".",
"copy",
"(",
")",
"for",
"s",
"in",
"s... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Scriptable.parse | Parse the given code and add it to :attr:`scripts`.
The syntax matches :attr:`Script.stringify()`. See :mod:`kurt.text` for
reference. | kurt/__init__.py | def parse(self, text):
"""Parse the given code and add it to :attr:`scripts`.
The syntax matches :attr:`Script.stringify()`. See :mod:`kurt.text` for
reference.
"""
self.scripts.append(kurt.text.parse(text, self)) | def parse(self, text):
"""Parse the given code and add it to :attr:`scripts`.
The syntax matches :attr:`Script.stringify()`. See :mod:`kurt.text` for
reference.
"""
self.scripts.append(kurt.text.parse(text, self)) | [
"Parse",
"the",
"given",
"code",
"and",
"add",
"it",
"to",
":",
"attr",
":",
"scripts",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L704-L711 | [
"def",
"parse",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"scripts",
".",
"append",
"(",
"kurt",
".",
"text",
".",
"parse",
"(",
"text",
",",
"self",
")",
")"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Sprite.copy | Return a new instance, deep-copying all the attributes. | kurt/__init__.py | def copy(self):
"""Return a new instance, deep-copying all the attributes."""
o = self.__class__(self.project, self.name)
Scriptable.copy(self, o)
o.position = tuple(self.position)
o.direction = self.direction
o.rotation_style = self.rotation_style
o.size = self.s... | def copy(self):
"""Return a new instance, deep-copying all the attributes."""
o = self.__class__(self.project, self.name)
Scriptable.copy(self, o)
o.position = tuple(self.position)
o.direction = self.direction
o.rotation_style = self.rotation_style
o.size = self.s... | [
"Return",
"a",
"new",
"instance",
"deep",
"-",
"copying",
"all",
"the",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L825-L835 | [
"def",
"copy",
"(",
"self",
")",
":",
"o",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"project",
",",
"self",
".",
"name",
")",
"Scriptable",
".",
"copy",
"(",
"self",
",",
"o",
")",
"o",
".",
"position",
"=",
"tuple",
"(",
"self",
".",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Watcher.copy | Return a new instance with the same attributes. | kurt/__init__.py | def copy(self):
"""Return a new instance with the same attributes."""
o = self.__class__(self.target,
self.block.copy(),
self.style,
self.is_visible,
self.pos)
o.slider_min = self.slider_min
o.slider_max = self.slider_max
... | def copy(self):
"""Return a new instance with the same attributes."""
o = self.__class__(self.target,
self.block.copy(),
self.style,
self.is_visible,
self.pos)
o.slider_min = self.slider_min
o.slider_max = self.slider_max
... | [
"Return",
"a",
"new",
"instance",
"with",
"the",
"same",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L918-L927 | [
"def",
"copy",
"(",
"self",
")",
":",
"o",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"target",
",",
"self",
".",
"block",
".",
"copy",
"(",
")",
",",
"self",
".",
"style",
",",
"self",
".",
"is_visible",
",",
"self",
".",
"pos",
")",
"o"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Watcher.kind | The type of value to watch, based on :attr:`block`.
One of ``variable``, ``list``, or ``block``.
``block`` watchers watch the value of a reporter block. | kurt/__init__.py | def kind(self):
"""The type of value to watch, based on :attr:`block`.
One of ``variable``, ``list``, or ``block``.
``block`` watchers watch the value of a reporter block.
"""
if self.block.type.has_command('readVariable'):
return 'variable'
elif self.block... | def kind(self):
"""The type of value to watch, based on :attr:`block`.
One of ``variable``, ``list``, or ``block``.
``block`` watchers watch the value of a reporter block.
"""
if self.block.type.has_command('readVariable'):
return 'variable'
elif self.block... | [
"The",
"type",
"of",
"value",
"to",
"watch",
"based",
"on",
":",
"attr",
":",
"block",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L930-L943 | [
"def",
"kind",
"(",
"self",
")",
":",
"if",
"self",
".",
"block",
".",
"type",
".",
"has_command",
"(",
"'readVariable'",
")",
":",
"return",
"'variable'",
"elif",
"self",
".",
"block",
".",
"type",
".",
"has_command",
"(",
"'contentsOfList:'",
")",
":",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Watcher.value | Return the :class:`Variable` or :class:`List` to watch.
Returns ``None`` if it's a block watcher. | kurt/__init__.py | def value(self):
"""Return the :class:`Variable` or :class:`List` to watch.
Returns ``None`` if it's a block watcher.
"""
if self.kind == 'variable':
return self.target.variables[self.block.args[0]]
elif self.kind == 'list':
return self.target.lists[self... | def value(self):
"""Return the :class:`Variable` or :class:`List` to watch.
Returns ``None`` if it's a block watcher.
"""
if self.kind == 'variable':
return self.target.variables[self.block.args[0]]
elif self.kind == 'list':
return self.target.lists[self... | [
"Return",
"the",
":",
"class",
":",
"Variable",
"or",
":",
"class",
":",
"List",
"to",
"watch",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L946-L955 | [
"def",
"value",
"(",
"self",
")",
":",
"if",
"self",
".",
"kind",
"==",
"'variable'",
":",
"return",
"self",
".",
"target",
".",
"variables",
"[",
"self",
".",
"block",
".",
"args",
"[",
"0",
"]",
"]",
"elif",
"self",
".",
"kind",
"==",
"'list'",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Color.stringify | Returns the color value in hexcode format.
eg. ``'#ff1056'`` | kurt/__init__.py | def stringify(self):
"""Returns the color value in hexcode format.
eg. ``'#ff1056'``
"""
hexcode = "#"
for x in self.value:
part = hex(x)[2:]
if len(part) < 2: part = "0" + part
hexcode += part
return hexcode | def stringify(self):
"""Returns the color value in hexcode format.
eg. ``'#ff1056'``
"""
hexcode = "#"
for x in self.value:
part = hex(x)[2:]
if len(part) < 2: part = "0" + part
hexcode += part
return hexcode | [
"Returns",
"the",
"color",
"value",
"in",
"hexcode",
"format",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1123-L1134 | [
"def",
"stringify",
"(",
"self",
")",
":",
"hexcode",
"=",
"\"#\"",
"for",
"x",
"in",
"self",
".",
"value",
":",
"part",
"=",
"hex",
"(",
"x",
")",
"[",
"2",
":",
"]",
"if",
"len",
"(",
"part",
")",
"<",
"2",
":",
"part",
"=",
"\"0\"",
"+",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Insert.options | Return a list of valid options to a menu insert, given a
Scriptable for context.
Mostly complete, excepting 'attribute'. | kurt/__init__.py | def options(self, scriptable=None):
"""Return a list of valid options to a menu insert, given a
Scriptable for context.
Mostly complete, excepting 'attribute'.
"""
options = list(Insert.KIND_OPTIONS.get(self.kind, []))
if scriptable:
if self.kind == 'var':
... | def options(self, scriptable=None):
"""Return a list of valid options to a menu insert, given a
Scriptable for context.
Mostly complete, excepting 'attribute'.
"""
options = list(Insert.KIND_OPTIONS.get(self.kind, []))
if scriptable:
if self.kind == 'var':
... | [
"Return",
"a",
"list",
"of",
"valid",
"options",
"to",
"a",
"menu",
"insert",
"given",
"a",
"Scriptable",
"for",
"context",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1372-L1401 | [
"def",
"options",
"(",
"self",
",",
"scriptable",
"=",
"None",
")",
":",
"options",
"=",
"list",
"(",
"Insert",
".",
"KIND_OPTIONS",
".",
"get",
"(",
"self",
".",
"kind",
",",
"[",
"]",
")",
")",
"if",
"scriptable",
":",
"if",
"self",
".",
"kind",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BaseBlockType.text | The text displayed on the block.
String containing ``"%s"`` in place of inserts.
eg. ``'say %s for %s secs'`` | kurt/__init__.py | def text(self):
"""The text displayed on the block.
String containing ``"%s"`` in place of inserts.
eg. ``'say %s for %s secs'``
"""
parts = [("%s" if isinstance(p, Insert) else p) for p in self.parts]
parts = [("%%" if p == "%" else p) for p in parts] # escape percent... | def text(self):
"""The text displayed on the block.
String containing ``"%s"`` in place of inserts.
eg. ``'say %s for %s secs'``
"""
parts = [("%s" if isinstance(p, Insert) else p) for p in self.parts]
parts = [("%%" if p == "%" else p) for p in parts] # escape percent... | [
"The",
"text",
"displayed",
"on",
"the",
"block",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1455-L1465 | [
"def",
"text",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"(",
"\"%s\"",
"if",
"isinstance",
"(",
"p",
",",
"Insert",
")",
"else",
"p",
")",
"for",
"p",
"in",
"self",
".",
"parts",
"]",
"parts",
"=",
"[",
"(",
"\"%%\"",
"if",
"p",
"==",
"\"%\"",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BaseBlockType.stripped_text | The :attr:`text`, with spaces and inserts removed.
Used by :class:`BlockType.get` to look up blocks. | kurt/__init__.py | def stripped_text(self):
"""The :attr:`text`, with spaces and inserts removed.
Used by :class:`BlockType.get` to look up blocks.
"""
return BaseBlockType._strip_text(
self.text % tuple((i.default if i.shape == 'inline' else '%s')
for i ... | def stripped_text(self):
"""The :attr:`text`, with spaces and inserts removed.
Used by :class:`BlockType.get` to look up blocks.
"""
return BaseBlockType._strip_text(
self.text % tuple((i.default if i.shape == 'inline' else '%s')
for i ... | [
"The",
":",
"attr",
":",
"text",
"with",
"spaces",
"and",
"inserts",
"removed",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1482-L1490 | [
"def",
"stripped_text",
"(",
"self",
")",
":",
"return",
"BaseBlockType",
".",
"_strip_text",
"(",
"self",
".",
"text",
"%",
"tuple",
"(",
"(",
"i",
".",
"default",
"if",
"i",
".",
"shape",
"==",
"'inline'",
"else",
"'%s'",
")",
"for",
"i",
"in",
"se... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BaseBlockType._strip_text | Returns text with spaces and inserts removed. | kurt/__init__.py | def _strip_text(text):
"""Returns text with spaces and inserts removed."""
text = re.sub(r'[ ,?:]|%s', "", text.lower())
for chr in "-%":
new_text = text.replace(chr, "")
if new_text:
text = new_text
return text.lower() | def _strip_text(text):
"""Returns text with spaces and inserts removed."""
text = re.sub(r'[ ,?:]|%s', "", text.lower())
for chr in "-%":
new_text = text.replace(chr, "")
if new_text:
text = new_text
return text.lower() | [
"Returns",
"text",
"with",
"spaces",
"and",
"inserts",
"removed",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1493-L1500 | [
"def",
"_strip_text",
"(",
"text",
")",
":",
"text",
"=",
"re",
".",
"sub",
"(",
"r'[ ,?:]|%s'",
",",
"\"\"",
",",
"text",
".",
"lower",
"(",
")",
")",
"for",
"chr",
"in",
"\"-%\"",
":",
"new_text",
"=",
"text",
".",
"replace",
"(",
"chr",
",",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BaseBlockType.has_insert | Returns True if any of the inserts have the given shape. | kurt/__init__.py | def has_insert(self, shape):
"""Returns True if any of the inserts have the given shape."""
for insert in self.inserts:
if insert.shape == shape:
return True
return False | def has_insert(self, shape):
"""Returns True if any of the inserts have the given shape."""
for insert in self.inserts:
if insert.shape == shape:
return True
return False | [
"Returns",
"True",
"if",
"any",
"of",
"the",
"inserts",
"have",
"the",
"given",
"shape",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1526-L1531 | [
"def",
"has_insert",
"(",
"self",
",",
"shape",
")",
":",
"for",
"insert",
"in",
"self",
".",
"inserts",
":",
"if",
"insert",
".",
"shape",
"==",
"shape",
":",
"return",
"True",
"return",
"False"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BlockType._add_conversion | Add a new PluginBlockType conversion.
If the plugin already exists, do nothing. | kurt/__init__.py | def _add_conversion(self, plugin, pbt):
"""Add a new PluginBlockType conversion.
If the plugin already exists, do nothing.
"""
assert self.shape == pbt.shape
assert len(self.inserts) == len(pbt.inserts)
for (i, o) in zip(self.inserts, pbt.inserts):
assert i.... | def _add_conversion(self, plugin, pbt):
"""Add a new PluginBlockType conversion.
If the plugin already exists, do nothing.
"""
assert self.shape == pbt.shape
assert len(self.inserts) == len(pbt.inserts)
for (i, o) in zip(self.inserts, pbt.inserts):
assert i.... | [
"Add",
"a",
"new",
"PluginBlockType",
"conversion",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1558-L1571 | [
"def",
"_add_conversion",
"(",
"self",
",",
"plugin",
",",
"pbt",
")",
":",
"assert",
"self",
".",
"shape",
"==",
"pbt",
".",
"shape",
"assert",
"len",
"(",
"self",
".",
"inserts",
")",
"==",
"len",
"(",
"pbt",
".",
"inserts",
")",
"for",
"(",
"i",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BlockType.convert | Return a :class:`PluginBlockType` for the given plugin name.
If plugin is ``None``, return the first registered plugin. | kurt/__init__.py | def convert(self, plugin=None):
"""Return a :class:`PluginBlockType` for the given plugin name.
If plugin is ``None``, return the first registered plugin.
"""
if plugin:
plugin = kurt.plugin.Kurt.get_plugin(plugin)
if plugin.name in self._plugins:
... | def convert(self, plugin=None):
"""Return a :class:`PluginBlockType` for the given plugin name.
If plugin is ``None``, return the first registered plugin.
"""
if plugin:
plugin = kurt.plugin.Kurt.get_plugin(plugin)
if plugin.name in self._plugins:
... | [
"Return",
"a",
":",
"class",
":",
"PluginBlockType",
"for",
"the",
"given",
"plugin",
"name",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1573-L1589 | [
"def",
"convert",
"(",
"self",
",",
"plugin",
"=",
"None",
")",
":",
"if",
"plugin",
":",
"plugin",
"=",
"kurt",
".",
"plugin",
".",
"Kurt",
".",
"get_plugin",
"(",
"plugin",
")",
"if",
"plugin",
".",
"name",
"in",
"self",
".",
"_plugins",
":",
"re... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BlockType.has_conversion | Return True if the plugin supports this block. | kurt/__init__.py | def has_conversion(self, plugin):
"""Return True if the plugin supports this block."""
plugin = kurt.plugin.Kurt.get_plugin(plugin)
return plugin.name in self._plugins | def has_conversion(self, plugin):
"""Return True if the plugin supports this block."""
plugin = kurt.plugin.Kurt.get_plugin(plugin)
return plugin.name in self._plugins | [
"Return",
"True",
"if",
"the",
"plugin",
"supports",
"this",
"block",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1596-L1599 | [
"def",
"has_conversion",
"(",
"self",
",",
"plugin",
")",
":",
"plugin",
"=",
"kurt",
".",
"plugin",
".",
"Kurt",
".",
"get_plugin",
"(",
"plugin",
")",
"return",
"plugin",
".",
"name",
"in",
"self",
".",
"_plugins"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BlockType.has_command | Returns True if any of the plugins have the given command. | kurt/__init__.py | def has_command(self, command):
"""Returns True if any of the plugins have the given command."""
for pbt in self._plugins.values():
if pbt.command == command:
return True
return False | def has_command(self, command):
"""Returns True if any of the plugins have the given command."""
for pbt in self._plugins.values():
if pbt.command == command:
return True
return False | [
"Returns",
"True",
"if",
"any",
"of",
"the",
"plugins",
"have",
"the",
"given",
"command",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1601-L1606 | [
"def",
"has_command",
"(",
"self",
",",
"command",
")",
":",
"for",
"pbt",
"in",
"self",
".",
"_plugins",
".",
"values",
"(",
")",
":",
"if",
"pbt",
".",
"command",
"==",
"command",
":",
"return",
"True",
"return",
"False"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | BlockType.get | Return a :class:`BlockType` instance from the given parameter.
* If it's already a BlockType instance, return that.
* If it exactly matches the command on a :class:`PluginBlockType`,
return the corresponding BlockType.
* If it loosely matches the text on a PluginBlockType, return th... | kurt/__init__.py | def get(cls, block_type):
"""Return a :class:`BlockType` instance from the given parameter.
* If it's already a BlockType instance, return that.
* If it exactly matches the command on a :class:`PluginBlockType`,
return the corresponding BlockType.
* If it loosely matches the... | def get(cls, block_type):
"""Return a :class:`BlockType` instance from the given parameter.
* If it's already a BlockType instance, return that.
* If it exactly matches the command on a :class:`PluginBlockType`,
return the corresponding BlockType.
* If it loosely matches the... | [
"Return",
"a",
":",
"class",
":",
"BlockType",
"instance",
"from",
"the",
"given",
"parameter",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1617-L1653 | [
"def",
"get",
"(",
"cls",
",",
"block_type",
")",
":",
"if",
"isinstance",
"(",
"block_type",
",",
"(",
"BlockType",
",",
"CustomBlockType",
")",
")",
":",
"return",
"block_type",
"if",
"isinstance",
"(",
"block_type",
",",
"PluginBlockType",
")",
":",
"bl... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Block.copy | Return a new Block instance with the same attributes. | kurt/__init__.py | def copy(self):
"""Return a new Block instance with the same attributes."""
args = []
for arg in self.args:
if isinstance(arg, Block):
arg = arg.copy()
elif isinstance(arg, list):
arg = [b.copy() for b in arg]
args.append(arg)
... | def copy(self):
"""Return a new Block instance with the same attributes."""
args = []
for arg in self.args:
if isinstance(arg, Block):
arg = arg.copy()
elif isinstance(arg, list):
arg = [b.copy() for b in arg]
args.append(arg)
... | [
"Return",
"a",
"new",
"Block",
"instance",
"with",
"the",
"same",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1844-L1853 | [
"def",
"copy",
"(",
"self",
")",
":",
"args",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"args",
":",
"if",
"isinstance",
"(",
"arg",
",",
"Block",
")",
":",
"arg",
"=",
"arg",
".",
"copy",
"(",
")",
"elif",
"isinstance",
"(",
"arg",
",",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Script.copy | Return a new instance with the same attributes. | kurt/__init__.py | def copy(self):
"""Return a new instance with the same attributes."""
return self.__class__([b.copy() for b in self.blocks],
tuple(self.pos) if self.pos else None) | def copy(self):
"""Return a new instance with the same attributes."""
return self.__class__([b.copy() for b in self.blocks],
tuple(self.pos) if self.pos else None) | [
"Return",
"a",
"new",
"instance",
"with",
"the",
"same",
"attributes",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1929-L1932 | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"[",
"b",
".",
"copy",
"(",
")",
"for",
"b",
"in",
"self",
".",
"blocks",
"]",
",",
"tuple",
"(",
"self",
".",
"pos",
")",
"if",
"self",
".",
"pos",
"else",
"None",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Costume.load | Load costume from image file.
Uses :attr:`Image.load`, but will set the Costume's name based on the
image filename. | kurt/__init__.py | def load(self, path):
"""Load costume from image file.
Uses :attr:`Image.load`, but will set the Costume's name based on the
image filename.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
return Costume(name, Image.lo... | def load(self, path):
"""Load costume from image file.
Uses :attr:`Image.load`, but will set the Costume's name based on the
image filename.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
return Costume(name, Image.lo... | [
"Load",
"costume",
"from",
"image",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2043-L2052 | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"(",
"name",
",",
"extension",
")",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.pil_image | A :class:`PIL.Image.Image` instance containing the image data. | kurt/__init__.py | def pil_image(self):
"""A :class:`PIL.Image.Image` instance containing the image data."""
if not self._pil_image:
if self._format == "SVG":
raise VectorImageError("can't rasterise vector images")
self._pil_image = PIL.Image.open(StringIO(self.contents))
re... | def pil_image(self):
"""A :class:`PIL.Image.Image` instance containing the image data."""
if not self._pil_image:
if self._format == "SVG":
raise VectorImageError("can't rasterise vector images")
self._pil_image = PIL.Image.open(StringIO(self.contents))
re... | [
"A",
":",
"class",
":",
"PIL",
".",
"Image",
".",
"Image",
"instance",
"containing",
"the",
"image",
"data",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2145-L2151 | [
"def",
"pil_image",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_pil_image",
":",
"if",
"self",
".",
"_format",
"==",
"\"SVG\"",
":",
"raise",
"VectorImageError",
"(",
"\"can't rasterise vector images\"",
")",
"self",
".",
"_pil_image",
"=",
"PIL",
"."... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.contents | The raw file contents as a string. | kurt/__init__.py | def contents(self):
"""The raw file contents as a string."""
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
... | def contents(self):
"""The raw file contents as a string."""
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
... | [
"The",
"raw",
"file",
"contents",
"as",
"a",
"string",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2154-L2167 | [
"def",
"contents",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_contents",
":",
"if",
"self",
".",
"_path",
":",
"# Read file into memory so we don't run out of file descriptors",
"f",
"=",
"open",
"(",
"self",
".",
"_path",
",",
"\"rb\"",
")",
"self",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.format | The format of the image file.
An uppercase string corresponding to the
:attr:`PIL.ImageFile.ImageFile.format` attribute. Valid values include
``"JPEG"`` and ``"PNG"``. | kurt/__init__.py | def format(self):
"""The format of the image file.
An uppercase string corresponding to the
:attr:`PIL.ImageFile.ImageFile.format` attribute. Valid values include
``"JPEG"`` and ``"PNG"``.
"""
if self._format:
return self._format
elif self.pil_image... | def format(self):
"""The format of the image file.
An uppercase string corresponding to the
:attr:`PIL.ImageFile.ImageFile.format` attribute. Valid values include
``"JPEG"`` and ``"PNG"``.
"""
if self._format:
return self._format
elif self.pil_image... | [
"The",
"format",
"of",
"the",
"image",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2170-L2181 | [
"def",
"format",
"(",
"self",
")",
":",
"if",
"self",
".",
"_format",
":",
"return",
"self",
".",
"_format",
"elif",
"self",
".",
"pil_image",
":",
"return",
"self",
".",
"pil_image",
".",
"format"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.size | ``(width, height)`` in pixels. | kurt/__init__.py | def size(self):
"""``(width, height)`` in pixels."""
if self._size and not self._pil_image:
return self._size
else:
return self.pil_image.size | def size(self):
"""``(width, height)`` in pixels."""
if self._size and not self._pil_image:
return self._size
else:
return self.pil_image.size | [
"(",
"width",
"height",
")",
"in",
"pixels",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2193-L2198 | [
"def",
"size",
"(",
"self",
")",
":",
"if",
"self",
".",
"_size",
"and",
"not",
"self",
".",
"_pil_image",
":",
"return",
"self",
".",
"_size",
"else",
":",
"return",
"self",
".",
"pil_image",
".",
"size"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.load | Load image from file. | kurt/__init__.py | def load(cls, path):
"""Load image from file."""
assert os.path.exists(path), "No such file: %r" % path
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
image = Image(None)
image._path = path
image._format = Image.image_for... | def load(cls, path):
"""Load image from file."""
assert os.path.exists(path), "No such file: %r" % path
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
image = Image(None)
image._path = path
image._format = Image.image_for... | [
"Load",
"image",
"from",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2211-L2222 | [
"def",
"load",
"(",
"cls",
",",
"path",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
",",
"\"No such file: %r\"",
"%",
"path",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.convert | Return an Image instance with the first matching format.
For each format in ``*args``: If the image's :attr:`format` attribute
is the same as the format, return self, otherwise try the next format.
If none of the formats match, return a new Image instance with the
last format. | kurt/__init__.py | def convert(self, *formats):
"""Return an Image instance with the first matching format.
For each format in ``*args``: If the image's :attr:`format` attribute
is the same as the format, return self, otherwise try the next format.
If none of the formats match, return a new Image instanc... | def convert(self, *formats):
"""Return an Image instance with the first matching format.
For each format in ``*args``: If the image's :attr:`format` attribute
is the same as the format, return self, otherwise try the next format.
If none of the formats match, return a new Image instanc... | [
"Return",
"an",
"Image",
"instance",
"with",
"the",
"first",
"matching",
"format",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2224-L2239 | [
"def",
"convert",
"(",
"self",
",",
"*",
"formats",
")",
":",
"for",
"format",
"in",
"formats",
":",
"format",
"=",
"Image",
".",
"image_format",
"(",
"format",
")",
"if",
"self",
".",
"format",
"==",
"format",
":",
"return",
"self",
"else",
":",
"re... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image._convert | Return a new Image instance with the given format.
Returns self if the format is already the same. | kurt/__init__.py | def _convert(self, format):
"""Return a new Image instance with the given format.
Returns self if the format is already the same.
"""
if self.format == format:
return self
else:
image = Image(self.pil_image)
image._format = format
... | def _convert(self, format):
"""Return a new Image instance with the given format.
Returns self if the format is already the same.
"""
if self.format == format:
return self
else:
image = Image(self.pil_image)
image._format = format
... | [
"Return",
"a",
"new",
"Image",
"instance",
"with",
"the",
"given",
"format",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2241-L2252 | [
"def",
"_convert",
"(",
"self",
",",
"format",
")",
":",
"if",
"self",
".",
"format",
"==",
"format",
":",
"return",
"self",
"else",
":",
"image",
"=",
"Image",
"(",
"self",
".",
"pil_image",
")",
"image",
".",
"_format",
"=",
"format",
"return",
"im... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.save | Save image to file path.
The image format is guessed from the extension. If path has no
extension, the image's :attr:`format` is used.
:returns: Path to the saved file. | kurt/__init__.py | def save(self, path):
"""Save image to file path.
The image format is guessed from the extension. If path has no
extension, the image's :attr:`format` is used.
:returns: Path to the saved file.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os... | def save(self, path):
"""Save image to file path.
The image format is guessed from the extension. If path has no
extension, the image's :attr:`format` is used.
:returns: Path to the saved file.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os... | [
"Save",
"image",
"to",
"file",
"path",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2254-L2284 | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"(",
"name",
",",
"extension",
")",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.new | Return a new Image instance filled with a color. | kurt/__init__.py | def new(self, size, fill):
"""Return a new Image instance filled with a color."""
return Image(PIL.Image.new("RGB", size, fill)) | def new(self, size, fill):
"""Return a new Image instance filled with a color."""
return Image(PIL.Image.new("RGB", size, fill)) | [
"Return",
"a",
"new",
"Image",
"instance",
"filled",
"with",
"a",
"color",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2287-L2289 | [
"def",
"new",
"(",
"self",
",",
"size",
",",
"fill",
")",
":",
"return",
"Image",
"(",
"PIL",
".",
"Image",
".",
"new",
"(",
"\"RGB\"",
",",
"size",
",",
"fill",
")",
")"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.resize | Return a new Image instance with the given size. | kurt/__init__.py | def resize(self, size):
"""Return a new Image instance with the given size."""
return Image(self.pil_image.resize(size, PIL.Image.ANTIALIAS)) | def resize(self, size):
"""Return a new Image instance with the given size."""
return Image(self.pil_image.resize(size, PIL.Image.ANTIALIAS)) | [
"Return",
"a",
"new",
"Image",
"instance",
"with",
"the",
"given",
"size",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2291-L2293 | [
"def",
"resize",
"(",
"self",
",",
"size",
")",
":",
"return",
"Image",
"(",
"self",
".",
"pil_image",
".",
"resize",
"(",
"size",
",",
"PIL",
".",
"Image",
".",
"ANTIALIAS",
")",
")"
] | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Image.paste | Return a new Image with the given image pasted on top.
This image will show through transparent areas of the given image. | kurt/__init__.py | def paste(self, other):
"""Return a new Image with the given image pasted on top.
This image will show through transparent areas of the given image.
"""
r, g, b, alpha = other.pil_image.split()
pil_image = self.pil_image.copy()
pil_image.paste(other.pil_image, mask=alph... | def paste(self, other):
"""Return a new Image with the given image pasted on top.
This image will show through transparent areas of the given image.
"""
r, g, b, alpha = other.pil_image.split()
pil_image = self.pil_image.copy()
pil_image.paste(other.pil_image, mask=alph... | [
"Return",
"a",
"new",
"Image",
"with",
"the",
"given",
"image",
"pasted",
"on",
"top",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2295-L2304 | [
"def",
"paste",
"(",
"self",
",",
"other",
")",
":",
"r",
",",
"g",
",",
"b",
",",
"alpha",
"=",
"other",
".",
"pil_image",
".",
"split",
"(",
")",
"pil_image",
"=",
"self",
".",
"pil_image",
".",
"copy",
"(",
")",
"pil_image",
".",
"paste",
"(",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Sound.load | Load sound from wave file.
Uses :attr:`Waveform.load`, but will set the Waveform's name based on
the sound filename. | kurt/__init__.py | def load(self, path):
"""Load sound from wave file.
Uses :attr:`Waveform.load`, but will set the Waveform's name based on
the sound filename.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
return Sound(name, Waveform.... | def load(self, path):
"""Load sound from wave file.
Uses :attr:`Waveform.load`, but will set the Waveform's name based on
the sound filename.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
return Sound(name, Waveform.... | [
"Load",
"sound",
"from",
"wave",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2347-L2356 | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"(",
"name",
",",
"extension",
")",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Sound.save | Save the sound to a wave file at the given path.
Uses :attr:`Waveform.save`, but if the path ends in a folder instead of
a file, the filename is based on the project's :attr:`name`.
:returns: Path to the saved file. | kurt/__init__.py | def save(self, path):
"""Save the sound to a wave file at the given path.
Uses :attr:`Waveform.save`, but if the path ends in a folder instead of
a file, the filename is based on the project's :attr:`name`.
:returns: Path to the saved file.
"""
(folder, filename) = os.... | def save(self, path):
"""Save the sound to a wave file at the given path.
Uses :attr:`Waveform.save`, but if the path ends in a folder instead of
a file, the filename is based on the project's :attr:`name`.
:returns: Path to the saved file.
"""
(folder, filename) = os.... | [
"Save",
"the",
"sound",
"to",
"a",
"wave",
"file",
"at",
"the",
"given",
"path",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2358-L2371 | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"if",
"not",
"filename",
":",
"filename",
"=",
"_clean_filename",
"(",
"self",
".",
"name",
")",
"path",... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Waveform.contents | The raw file contents as a string. | kurt/__init__.py | def contents(self):
"""The raw file contents as a string."""
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
... | def contents(self):
"""The raw file contents as a string."""
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
... | [
"The",
"raw",
"file",
"contents",
"as",
"a",
"string",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2405-L2413 | [
"def",
"contents",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_contents",
":",
"if",
"self",
".",
"_path",
":",
"# Read file into memory so we don't run out of file descriptors",
"f",
"=",
"open",
"(",
"self",
".",
"_path",
",",
"\"rb\"",
")",
"self",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Waveform._wave | Return a wave.Wave_read instance from the ``wave`` module. | kurt/__init__.py | def _wave(self):
"""Return a wave.Wave_read instance from the ``wave`` module."""
try:
return wave.open(StringIO(self.contents))
except wave.Error, err:
err.message += "\nInvalid wave file: %s" % self
err.args = (err.message,)
raise | def _wave(self):
"""Return a wave.Wave_read instance from the ``wave`` module."""
try:
return wave.open(StringIO(self.contents))
except wave.Error, err:
err.message += "\nInvalid wave file: %s" % self
err.args = (err.message,)
raise | [
"Return",
"a",
"wave",
".",
"Wave_read",
"instance",
"from",
"the",
"wave",
"module",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2416-L2423 | [
"def",
"_wave",
"(",
"self",
")",
":",
"try",
":",
"return",
"wave",
".",
"open",
"(",
"StringIO",
"(",
"self",
".",
"contents",
")",
")",
"except",
"wave",
".",
"Error",
",",
"err",
":",
"err",
".",
"message",
"+=",
"\"\\nInvalid wave file: %s\"",
"%"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Waveform.load | Load Waveform from file. | kurt/__init__.py | def load(cls, path):
"""Load Waveform from file."""
assert os.path.exists(path), "No such file: %r" % path
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
wave = Waveform(None)
wave._path = path
return wave | def load(cls, path):
"""Load Waveform from file."""
assert os.path.exists(path), "No such file: %r" % path
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
wave = Waveform(None)
wave._path = path
return wave | [
"Load",
"Waveform",
"from",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2445-L2454 | [
"def",
"load",
"(",
"cls",
",",
"path",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
",",
"\"No such file: %r\"",
"%",
"path",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Waveform.save | Save waveform to file path as a WAV file.
:returns: Path to the saved file. | kurt/__init__.py | def save(self, path):
"""Save waveform to file path as a WAV file.
:returns: Path to the saved file.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
if not name:
raise ValueError, "name is required"
path ... | def save(self, path):
"""Save waveform to file path as a WAV file.
:returns: Path to the saved file.
"""
(folder, filename) = os.path.split(path)
(name, extension) = os.path.splitext(filename)
if not name:
raise ValueError, "name is required"
path ... | [
"Save",
"waveform",
"to",
"file",
"path",
"as",
"a",
"WAV",
"file",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L2456-L2473 | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"(",
"folder",
",",
"filename",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"(",
"name",
",",
"extension",
")",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | sort_nicely | Sort the given list in the way that humans expect. | examples/images.py | def sort_nicely(l):
"""Sort the given list in the way that humans expect."""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
l.sort(key=alphanum_key) | def sort_nicely(l):
"""Sort the given list in the way that humans expect."""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
l.sort(key=alphanum_key) | [
"Sort",
"the",
"given",
"list",
"in",
"the",
"way",
"that",
"humans",
"expect",
"."
] | tjvr/kurt | python | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/examples/images.py#L22-L26 | [
"def",
"sort_nicely",
"(",
"l",
")",
":",
"convert",
"=",
"lambda",
"text",
":",
"int",
"(",
"text",
")",
"if",
"text",
".",
"isdigit",
"(",
")",
"else",
"text",
"alphanum_key",
"=",
"lambda",
"key",
":",
"[",
"convert",
"(",
"c",
")",
"for",
"c",
... | fcccd80cae11dc233f6dd02b40ec9a388c62f259 |
train | Connection.open_channel | Open a new channel on this connection.
This method is a :ref:`coroutine <coroutine>`.
:return: The new :class:`Channel` object. | src/asynqp/connection.py | def open_channel(self):
"""
Open a new channel on this connection.
This method is a :ref:`coroutine <coroutine>`.
:return: The new :class:`Channel` object.
"""
if self._closing:
raise ConnectionClosed("Closed by application")
if self.closed.done():
... | def open_channel(self):
"""
Open a new channel on this connection.
This method is a :ref:`coroutine <coroutine>`.
:return: The new :class:`Channel` object.
"""
if self._closing:
raise ConnectionClosed("Closed by application")
if self.closed.done():
... | [
"Open",
"a",
"new",
"channel",
"on",
"this",
"connection",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/connection.py#L50-L64 | [
"def",
"open_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closing",
":",
"raise",
"ConnectionClosed",
"(",
"\"Closed by application\"",
")",
"if",
"self",
".",
"closed",
".",
"done",
"(",
")",
":",
"raise",
"self",
".",
"closed",
".",
"exception",... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Connection.close | Close the connection by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`. | src/asynqp/connection.py | def close(self):
"""
Close the connection by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`.
"""
if not self.is_closed():
self._closing = True
# Let the ConnectionActor do the actual close operations.
# It will do t... | def close(self):
"""
Close the connection by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`.
"""
if not self.is_closed():
self._closing = True
# Let the ConnectionActor do the actual close operations.
# It will do t... | [
"Close",
"the",
"connection",
"by",
"handshaking",
"with",
"the",
"server",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/connection.py#L71-L93 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_closed",
"(",
")",
":",
"self",
".",
"_closing",
"=",
"True",
"# Let the ConnectionActor do the actual close operations.",
"# It will do the work on CloseOK",
"self",
".",
"sender",
".",
"send_Clos... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | ConnectionActor.handle_PoisonPillFrame | Is sent in case protocol lost connection to server. | src/asynqp/connection.py | def handle_PoisonPillFrame(self, frame):
""" Is sent in case protocol lost connection to server."""
# Will be delivered after Close or CloseOK handlers. It's for channels,
# so ignore it.
if self.connection.closed.done():
return
# If connection was not closed already ... | def handle_PoisonPillFrame(self, frame):
""" Is sent in case protocol lost connection to server."""
# Will be delivered after Close or CloseOK handlers. It's for channels,
# so ignore it.
if self.connection.closed.done():
return
# If connection was not closed already ... | [
"Is",
"sent",
"in",
"case",
"protocol",
"lost",
"connection",
"to",
"server",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/connection.py#L174-L182 | [
"def",
"handle_PoisonPillFrame",
"(",
"self",
",",
"frame",
")",
":",
"# Will be delivered after Close or CloseOK handlers. It's for channels,",
"# so ignore it.",
"if",
"self",
".",
"connection",
".",
"closed",
".",
"done",
"(",
")",
":",
"return",
"# If connection was n... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | ConnectionActor.handle_ConnectionClose | AMQP server closed the channel with an error | src/asynqp/connection.py | def handle_ConnectionClose(self, frame):
""" AMQP server closed the channel with an error """
# Notify server we are OK to close.
self.sender.send_CloseOK()
exc = ConnectionClosed(frame.payload.reply_text,
frame.payload.reply_code)
self._close_all(... | def handle_ConnectionClose(self, frame):
""" AMQP server closed the channel with an error """
# Notify server we are OK to close.
self.sender.send_CloseOK()
exc = ConnectionClosed(frame.payload.reply_text,
frame.payload.reply_code)
self._close_all(... | [
"AMQP",
"server",
"closed",
"the",
"channel",
"with",
"an",
"error"
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/connection.py#L184-L194 | [
"def",
"handle_ConnectionClose",
"(",
"self",
",",
"frame",
")",
":",
"# Notify server we are OK to close.",
"self",
".",
"sender",
".",
"send_CloseOK",
"(",
")",
"exc",
"=",
"ConnectionClosed",
"(",
"frame",
".",
"payload",
".",
"reply_text",
",",
"frame",
".",... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Exchange.publish | Publish a message on the exchange, to be asynchronously delivered to queues.
:param asynqp.Message message: the message to send
:param str routing_key: the routing key with which to publish the message
:param bool mandatory: if True (the default) undeliverable messages result in an error (see a... | src/asynqp/exchange.py | def publish(self, message, routing_key, *, mandatory=True):
"""
Publish a message on the exchange, to be asynchronously delivered to queues.
:param asynqp.Message message: the message to send
:param str routing_key: the routing key with which to publish the message
:param bool m... | def publish(self, message, routing_key, *, mandatory=True):
"""
Publish a message on the exchange, to be asynchronously delivered to queues.
:param asynqp.Message message: the message to send
:param str routing_key: the routing key with which to publish the message
:param bool m... | [
"Publish",
"a",
"message",
"on",
"the",
"exchange",
"to",
"be",
"asynchronously",
"delivered",
"to",
"queues",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/exchange.py#L35-L43 | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"routing_key",
",",
"*",
",",
"mandatory",
"=",
"True",
")",
":",
"self",
".",
"sender",
".",
"send_BasicPublish",
"(",
"self",
".",
"name",
",",
"routing_key",
",",
"mandatory",
",",
"message",
")"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Exchange.delete | Delete the exchange.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the exchange will only be deleted if
it has no queues bound to it. | src/asynqp/exchange.py | def delete(self, *, if_unused=True):
"""
Delete the exchange.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the exchange will only be deleted if
it has no queues bound to it.
"""
self.sender.send_ExchangeDelete(self.name, i... | def delete(self, *, if_unused=True):
"""
Delete the exchange.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the exchange will only be deleted if
it has no queues bound to it.
"""
self.sender.send_ExchangeDelete(self.name, i... | [
"Delete",
"the",
"exchange",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/exchange.py#L46-L57 | [
"def",
"delete",
"(",
"self",
",",
"*",
",",
"if_unused",
"=",
"True",
")",
":",
"self",
".",
"sender",
".",
"send_ExchangeDelete",
"(",
"self",
".",
"name",
",",
"if_unused",
")",
"yield",
"from",
"self",
".",
"synchroniser",
".",
"wait",
"(",
"spec",... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | IncomingMessage.reject | Reject the message.
:keyword bool requeue: if true, the broker will attempt to requeue the
message and deliver it to an alternate consumer. | src/asynqp/message.py | def reject(self, *, requeue=True):
"""
Reject the message.
:keyword bool requeue: if true, the broker will attempt to requeue the
message and deliver it to an alternate consumer.
"""
self.sender.send_BasicReject(self.delivery_tag, requeue) | def reject(self, *, requeue=True):
"""
Reject the message.
:keyword bool requeue: if true, the broker will attempt to requeue the
message and deliver it to an alternate consumer.
"""
self.sender.send_BasicReject(self.delivery_tag, requeue) | [
"Reject",
"the",
"message",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/message.py#L144-L151 | [
"def",
"reject",
"(",
"self",
",",
"*",
",",
"requeue",
"=",
"True",
")",
":",
"self",
".",
"sender",
".",
"send_BasicReject",
"(",
"self",
".",
"delivery_tag",
",",
"requeue",
")"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Channel.declare_exchange | Declare an :class:`Exchange` on the broker. If the exchange does not exist, it will be created.
This method is a :ref:`coroutine <coroutine>`.
:param str name: the name of the exchange.
:param str type: the type of the exchange
(usually one of ``'fanout'``, ``'direct'``, ``'topic'`... | src/asynqp/channel.py | def declare_exchange(self, name, type, *, durable=True, auto_delete=False,
passive=False, internal=False, nowait=False,
arguments=None):
"""
Declare an :class:`Exchange` on the broker. If the exchange does not exist, it will be created.
This met... | def declare_exchange(self, name, type, *, durable=True, auto_delete=False,
passive=False, internal=False, nowait=False,
arguments=None):
"""
Declare an :class:`Exchange` on the broker. If the exchange does not exist, it will be created.
This met... | [
"Declare",
"an",
":",
"class",
":",
"Exchange",
"on",
"the",
"broker",
".",
"If",
"the",
"exchange",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L47-L93 | [
"def",
"declare_exchange",
"(",
"self",
",",
"name",
",",
"type",
",",
"*",
",",
"durable",
"=",
"True",
",",
"auto_delete",
"=",
"False",
",",
"passive",
"=",
"False",
",",
"internal",
"=",
"False",
",",
"nowait",
"=",
"False",
",",
"arguments",
"=",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Channel.declare_queue | Declare a queue on the broker. If the queue does not exist, it will be created.
This method is a :ref:`coroutine <coroutine>`.
:param str name: the name of the queue.
Supplying a name of '' will create a queue with a unique name of the server's choosing.
:keyword bool durable: If t... | src/asynqp/channel.py | def declare_queue(self, name='', *, durable=True, exclusive=False,
auto_delete=False, passive=False,
nowait=False, arguments=None):
"""
Declare a queue on the broker. If the queue does not exist, it will be created.
This method is a :ref:`coroutine <c... | def declare_queue(self, name='', *, durable=True, exclusive=False,
auto_delete=False, passive=False,
nowait=False, arguments=None):
"""
Declare a queue on the broker. If the queue does not exist, it will be created.
This method is a :ref:`coroutine <c... | [
"Declare",
"a",
"queue",
"on",
"the",
"broker",
".",
"If",
"the",
"queue",
"does",
"not",
"exist",
"it",
"will",
"be",
"created",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L96-L123 | [
"def",
"declare_queue",
"(",
"self",
",",
"name",
"=",
"''",
",",
"*",
",",
"durable",
"=",
"True",
",",
"exclusive",
"=",
"False",
",",
"auto_delete",
"=",
"False",
",",
"passive",
"=",
"False",
",",
"nowait",
"=",
"False",
",",
"arguments",
"=",
"N... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Channel.set_qos | Specify quality of service by requesting that messages be pre-fetched
from the server. Pre-fetching means that the server will deliver messages
to the client while the client is still processing unacknowledged messages.
This method is a :ref:`coroutine <coroutine>`.
:param int prefetch... | src/asynqp/channel.py | def set_qos(self, prefetch_size=0, prefetch_count=0, apply_globally=False):
"""
Specify quality of service by requesting that messages be pre-fetched
from the server. Pre-fetching means that the server will deliver messages
to the client while the client is still processing unacknowledge... | def set_qos(self, prefetch_size=0, prefetch_count=0, apply_globally=False):
"""
Specify quality of service by requesting that messages be pre-fetched
from the server. Pre-fetching means that the server will deliver messages
to the client while the client is still processing unacknowledge... | [
"Specify",
"quality",
"of",
"service",
"by",
"requesting",
"that",
"messages",
"be",
"pre",
"-",
"fetched",
"from",
"the",
"server",
".",
"Pre",
"-",
"fetching",
"means",
"that",
"the",
"server",
"will",
"deliver",
"messages",
"to",
"the",
"client",
"while",... | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L126-L153 | [
"def",
"set_qos",
"(",
"self",
",",
"prefetch_size",
"=",
"0",
",",
"prefetch_count",
"=",
"0",
",",
"apply_globally",
"=",
"False",
")",
":",
"self",
".",
"sender",
".",
"send_BasicQos",
"(",
"prefetch_size",
",",
"prefetch_count",
",",
"apply_globally",
")... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Channel.close | Close the channel by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`. | src/asynqp/channel.py | def close(self):
"""
Close the channel by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`.
"""
# If we aren't already closed ask for server to close
if not self.is_closed():
self._closing = True
# Let the ChannelActor do... | def close(self):
"""
Close the channel by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`.
"""
# If we aren't already closed ask for server to close
if not self.is_closed():
self._closing = True
# Let the ChannelActor do... | [
"Close",
"the",
"channel",
"by",
"handshaking",
"with",
"the",
"server",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L173-L194 | [
"def",
"close",
"(",
"self",
")",
":",
"# If we aren't already closed ask for server to close",
"if",
"not",
"self",
".",
"is_closed",
"(",
")",
":",
"self",
".",
"_closing",
"=",
"True",
"# Let the ChannelActor do the actual close operations.",
"# It will do the work on Cl... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | ChannelActor.handle_ChannelClose | AMQP server closed the channel with an error | src/asynqp/channel.py | def handle_ChannelClose(self, frame):
""" AMQP server closed the channel with an error """
# By docs:
# The response to receiving a Close after sending Close must be to
# send Close-Ok.
#
# No need for additional checks
self.sender.send_CloseOK()
exc = ex... | def handle_ChannelClose(self, frame):
""" AMQP server closed the channel with an error """
# By docs:
# The response to receiving a Close after sending Close must be to
# send Close-Ok.
#
# No need for additional checks
self.sender.send_CloseOK()
exc = ex... | [
"AMQP",
"server",
"closed",
"the",
"channel",
"with",
"an",
"error"
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L345-L355 | [
"def",
"handle_ChannelClose",
"(",
"self",
",",
"frame",
")",
":",
"# By docs:",
"# The response to receiving a Close after sending Close must be to",
"# send Close-Ok.",
"#",
"# No need for additional checks",
"self",
".",
"sender",
".",
"send_CloseOK",
"(",
")",
"exc",
"=... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | ChannelActor.handle_ChannelCloseOK | AMQP server closed channel as per our request | src/asynqp/channel.py | def handle_ChannelCloseOK(self, frame):
""" AMQP server closed channel as per our request """
assert self.channel._closing, "received a not expected CloseOk"
# Release the `close` method's future
self.synchroniser.notify(spec.ChannelCloseOK)
exc = ChannelClosed()
self._c... | def handle_ChannelCloseOK(self, frame):
""" AMQP server closed channel as per our request """
assert self.channel._closing, "received a not expected CloseOk"
# Release the `close` method's future
self.synchroniser.notify(spec.ChannelCloseOK)
exc = ChannelClosed()
self._c... | [
"AMQP",
"server",
"closed",
"channel",
"as",
"per",
"our",
"request"
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L357-L364 | [
"def",
"handle_ChannelCloseOK",
"(",
"self",
",",
"frame",
")",
":",
"assert",
"self",
".",
"channel",
".",
"_closing",
",",
"\"received a not expected CloseOk\"",
"# Release the `close` method's future",
"self",
".",
"synchroniser",
".",
"notify",
"(",
"spec",
".",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Queue.bind | Bind a queue to an exchange, with the supplied routing key.
This action 'subscribes' the queue to the routing key; the precise meaning of this
varies with the exchange type.
This method is a :ref:`coroutine <coroutine>`.
:param asynqp.Exchange exchange: the :class:`Exchange` to bind t... | src/asynqp/queue.py | def bind(self, exchange, routing_key, *, arguments=None):
"""
Bind a queue to an exchange, with the supplied routing key.
This action 'subscribes' the queue to the routing key; the precise meaning of this
varies with the exchange type.
This method is a :ref:`coroutine <coroutin... | def bind(self, exchange, routing_key, *, arguments=None):
"""
Bind a queue to an exchange, with the supplied routing key.
This action 'subscribes' the queue to the routing key; the precise meaning of this
varies with the exchange type.
This method is a :ref:`coroutine <coroutin... | [
"Bind",
"a",
"queue",
"to",
"an",
"exchange",
"with",
"the",
"supplied",
"routing",
"key",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L54-L78 | [
"def",
"bind",
"(",
"self",
",",
"exchange",
",",
"routing_key",
",",
"*",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Queue.consume | Start a consumer on the queue. Messages will be delivered asynchronously to the consumer.
The callback function will be called whenever a new message arrives on the queue.
Advanced usage: the callback object must be callable
(it must be a function or define a ``__call__`` method),
but m... | src/asynqp/queue.py | def consume(self, callback, *, no_local=False, no_ack=False, exclusive=False, arguments=None):
"""
Start a consumer on the queue. Messages will be delivered asynchronously to the consumer.
The callback function will be called whenever a new message arrives on the queue.
Advanced usage: ... | def consume(self, callback, *, no_local=False, no_ack=False, exclusive=False, arguments=None):
"""
Start a consumer on the queue. Messages will be delivered asynchronously to the consumer.
The callback function will be called whenever a new message arrives on the queue.
Advanced usage: ... | [
"Start",
"a",
"consumer",
"on",
"the",
"queue",
".",
"Messages",
"will",
"be",
"delivered",
"asynchronously",
"to",
"the",
"consumer",
".",
"The",
"callback",
"function",
"will",
"be",
"called",
"whenever",
"a",
"new",
"message",
"arrives",
"on",
"the",
"que... | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L81-L116 | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"*",
",",
"no_local",
"=",
"False",
",",
"no_ack",
"=",
"False",
",",
"exclusive",
"=",
"False",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Queue.get | Synchronously get a message from the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool no_ack: if true, the broker does not require acknowledgement of receipt of the message.
:return: an :class:`~asynqp.message.IncomingMessage`,
or ``None`` if there were no messa... | src/asynqp/queue.py | def get(self, *, no_ack=False):
"""
Synchronously get a message from the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool no_ack: if true, the broker does not require acknowledgement of receipt of the message.
:return: an :class:`~asynqp.message.IncomingMess... | def get(self, *, no_ack=False):
"""
Synchronously get a message from the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool no_ack: if true, the broker does not require acknowledgement of receipt of the message.
:return: an :class:`~asynqp.message.IncomingMess... | [
"Synchronously",
"get",
"a",
"message",
"from",
"the",
"queue",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L119-L142 | [
"def",
"get",
"(",
"self",
",",
"*",
",",
"no_ack",
"=",
"False",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"sender",
".",
"send_B... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Queue.purge | Purge all undelivered messages from the queue.
This method is a :ref:`coroutine <coroutine>`. | src/asynqp/queue.py | def purge(self):
"""
Purge all undelivered messages from the queue.
This method is a :ref:`coroutine <coroutine>`.
"""
self.sender.send_QueuePurge(self.name)
yield from self.synchroniser.wait(spec.QueuePurgeOK)
self.reader.ready() | def purge(self):
"""
Purge all undelivered messages from the queue.
This method is a :ref:`coroutine <coroutine>`.
"""
self.sender.send_QueuePurge(self.name)
yield from self.synchroniser.wait(spec.QueuePurgeOK)
self.reader.ready() | [
"Purge",
"all",
"undelivered",
"messages",
"from",
"the",
"queue",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L145-L153 | [
"def",
"purge",
"(",
"self",
")",
":",
"self",
".",
"sender",
".",
"send_QueuePurge",
"(",
"self",
".",
"name",
")",
"yield",
"from",
"self",
".",
"synchroniser",
".",
"wait",
"(",
"spec",
".",
"QueuePurgeOK",
")",
"self",
".",
"reader",
".",
"ready",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Queue.delete | Delete the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the queue will only be deleted
if it has no consumers.
:keyword bool if_empty: If true, the queue will only be deleted if
it has no unacknowledged messages. | src/asynqp/queue.py | def delete(self, *, if_unused=True, if_empty=True):
"""
Delete the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the queue will only be deleted
if it has no consumers.
:keyword bool if_empty: If true, the queue will only be ... | def delete(self, *, if_unused=True, if_empty=True):
"""
Delete the queue.
This method is a :ref:`coroutine <coroutine>`.
:keyword bool if_unused: If true, the queue will only be deleted
if it has no consumers.
:keyword bool if_empty: If true, the queue will only be ... | [
"Delete",
"the",
"queue",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L156-L173 | [
"def",
"delete",
"(",
"self",
",",
"*",
",",
"if_unused",
"=",
"True",
",",
"if_empty",
"=",
"True",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was already deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | QueueBinding.unbind | Unbind the queue from the exchange.
This method is a :ref:`coroutine <coroutine>`. | src/asynqp/queue.py | def unbind(self, arguments=None):
"""
Unbind the queue from the exchange.
This method is a :ref:`coroutine <coroutine>`.
"""
if self.deleted:
raise Deleted("Queue {} was already unbound from exchange {}".format(self.queue.name, self.exchange.name))
self.send... | def unbind(self, arguments=None):
"""
Unbind the queue from the exchange.
This method is a :ref:`coroutine <coroutine>`.
"""
if self.deleted:
raise Deleted("Queue {} was already unbound from exchange {}".format(self.queue.name, self.exchange.name))
self.send... | [
"Unbind",
"the",
"queue",
"from",
"the",
"exchange",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L209-L221 | [
"def",
"unbind",
"(",
"self",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was already unbound from exchange {}\"",
".",
"format",
"(",
"self",
".",
"queue",
".",
"name",
",",
"self",
".",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Consumer.cancel | Cancel the consumer and stop recieving messages.
This method is a :ref:`coroutine <coroutine>`. | src/asynqp/queue.py | def cancel(self):
"""
Cancel the consumer and stop recieving messages.
This method is a :ref:`coroutine <coroutine>`.
"""
self.sender.send_BasicCancel(self.tag)
try:
yield from self.synchroniser.wait(spec.BasicCancelOK)
except AMQPError:
p... | def cancel(self):
"""
Cancel the consumer and stop recieving messages.
This method is a :ref:`coroutine <coroutine>`.
"""
self.sender.send_BasicCancel(self.tag)
try:
yield from self.synchroniser.wait(spec.BasicCancelOK)
except AMQPError:
p... | [
"Cancel",
"the",
"consumer",
"and",
"stop",
"recieving",
"messages",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L255-L272 | [
"def",
"cancel",
"(",
"self",
")",
":",
"self",
".",
"sender",
".",
"send_BasicCancel",
"(",
"self",
".",
"tag",
")",
"try",
":",
"yield",
"from",
"self",
".",
"synchroniser",
".",
"wait",
"(",
"spec",
".",
"BasicCancelOK",
")",
"except",
"AMQPError",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | hello_world | Sends a 'hello world' message and then reads it from the queue. | doc/examples/helloworld.py | def hello_world():
"""
Sends a 'hello world' message and then reads it from the queue.
"""
# connect to the RabbitMQ broker
connection = yield from asynqp.connect('localhost', 5672, username='guest', password='guest')
# Open a communications channel
channel = yield from connection.open_chan... | def hello_world():
"""
Sends a 'hello world' message and then reads it from the queue.
"""
# connect to the RabbitMQ broker
connection = yield from asynqp.connect('localhost', 5672, username='guest', password='guest')
# Open a communications channel
channel = yield from connection.open_chan... | [
"Sends",
"a",
"hello",
"world",
"message",
"and",
"then",
"reads",
"it",
"from",
"the",
"queue",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/doc/examples/helloworld.py#L6-L35 | [
"def",
"hello_world",
"(",
")",
":",
"# connect to the RabbitMQ broker",
"connection",
"=",
"yield",
"from",
"asynqp",
".",
"connect",
"(",
"'localhost'",
",",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
")",
"# Open a communications ... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | Synchroniser.killall | Connection/Channel was closed. All subsequent and ongoing requests
should raise an error | src/asynqp/routing.py | def killall(self, exc):
""" Connection/Channel was closed. All subsequent and ongoing requests
should raise an error
"""
self.connection_exc = exc
# Set an exception for all others
for method, futs in self._futures.items():
for fut in futs:
... | def killall(self, exc):
""" Connection/Channel was closed. All subsequent and ongoing requests
should raise an error
"""
self.connection_exc = exc
# Set an exception for all others
for method, futs in self._futures.items():
for fut in futs:
... | [
"Connection",
"/",
"Channel",
"was",
"closed",
".",
"All",
"subsequent",
"and",
"ongoing",
"requests",
"should",
"raise",
"an",
"error"
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/routing.py#L85-L96 | [
"def",
"killall",
"(",
"self",
",",
"exc",
")",
":",
"self",
".",
"connection_exc",
"=",
"exc",
"# Set an exception for all others",
"for",
"method",
",",
"futs",
"in",
"self",
".",
"_futures",
".",
"items",
"(",
")",
":",
"for",
"fut",
"in",
"futs",
":"... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | connect | Connect to an AMQP server on the given host and port.
Log in to the given virtual host using the supplied credentials.
This function is a :ref:`coroutine <coroutine>`.
:param str host: the host server to connect to.
:param int port: the port which the AMQP server is listening on.
:param str userna... | src/asynqp/__init__.py | def connect(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, sock=None, **kwargs):
"""
Connect to an AMQP server on the given host and port.
Log in to the given virtual host... | def connect(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, sock=None, **kwargs):
"""
Connect to an AMQP server on the given host and port.
Log in to the given virtual host... | [
"Connect",
"to",
"an",
"AMQP",
"server",
"on",
"the",
"given",
"host",
"and",
"port",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/__init__.py#L22-L86 | [
"def",
"connect",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
",",
"virtual_host",
"=",
"'/'",
",",
"on_connection_close",
"=",
"None",
",",
"*",
",",
"loop",
"=",
"None",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | connect_and_open_channel | Connect to an AMQP server and open a channel on the connection.
This function is a :ref:`coroutine <coroutine>`.
Parameters of this function are the same as :func:`connect`.
:return: a tuple of ``(connection, channel)``.
Equivalent to::
connection = yield from connect(host, port, username, p... | src/asynqp/__init__.py | def connect_and_open_channel(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, **kwargs):
"""
... | def connect_and_open_channel(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, **kwargs):
"""
... | [
"Connect",
"to",
"an",
"AMQP",
"server",
"and",
"open",
"a",
"channel",
"on",
"the",
"connection",
".",
"This",
"function",
"is",
"a",
":",
"ref",
":",
"coroutine",
"<coroutine",
">",
"."
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/__init__.py#L90-L112 | [
"def",
"connect_and_open_channel",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
",",
"virtual_host",
"=",
"'/'",
",",
"on_connection_close",
"=",
"None",
",",
"*",
",",
"loop",
... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | AMQP.heartbeat_timeout | Called by heartbeat_monitor on timeout | src/asynqp/protocol.py | def heartbeat_timeout(self):
""" Called by heartbeat_monitor on timeout """
assert not self._closed, "Did we not stop heartbeat_monitor on close?"
log.error("Heartbeat time out")
poison_exc = ConnectionLostError('Heartbeat timed out')
poison_frame = frames.PoisonPillFrame(poison_... | def heartbeat_timeout(self):
""" Called by heartbeat_monitor on timeout """
assert not self._closed, "Did we not stop heartbeat_monitor on close?"
log.error("Heartbeat time out")
poison_exc = ConnectionLostError('Heartbeat timed out')
poison_frame = frames.PoisonPillFrame(poison_... | [
"Called",
"by",
"heartbeat_monitor",
"on",
"timeout"
] | benjamin-hodgson/asynqp | python | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/protocol.py#L66-L74 | [
"def",
"heartbeat_timeout",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"_closed",
",",
"\"Did we not stop heartbeat_monitor on close?\"",
"log",
".",
"error",
"(",
"\"Heartbeat time out\"",
")",
"poison_exc",
"=",
"ConnectionLostError",
"(",
"'Heartbeat timed ... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 |
train | convert_general | Take a python object and convert it to the format Imgur expects. | pyimgur/request.py | def convert_general(value):
"""Take a python object and convert it to the format Imgur expects."""
if isinstance(value, bool):
return "true" if value else "false"
elif isinstance(value, list):
value = [convert_general(item) for item in value]
value = convert_to_imgur_list(value)
... | def convert_general(value):
"""Take a python object and convert it to the format Imgur expects."""
if isinstance(value, bool):
return "true" if value else "false"
elif isinstance(value, list):
value = [convert_general(item) for item in value]
value = convert_to_imgur_list(value)
... | [
"Take",
"a",
"python",
"object",
"and",
"convert",
"it",
"to",
"the",
"format",
"Imgur",
"expects",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/request.py#L32-L43 | [
"def",
"convert_general",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"\"true\"",
"if",
"value",
"else",
"\"false\"",
"elif",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"[",
"convert_ge... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | to_imgur_format | Convert the parameters to the format Imgur expects. | pyimgur/request.py | def to_imgur_format(params):
"""Convert the parameters to the format Imgur expects."""
if params is None:
return None
return dict((k, convert_general(val)) for (k, val) in params.items()) | def to_imgur_format(params):
"""Convert the parameters to the format Imgur expects."""
if params is None:
return None
return dict((k, convert_general(val)) for (k, val) in params.items()) | [
"Convert",
"the",
"parameters",
"to",
"the",
"format",
"Imgur",
"expects",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/request.py#L53-L57 | [
"def",
"to_imgur_format",
"(",
"params",
")",
":",
"if",
"params",
"is",
"None",
":",
"return",
"None",
"return",
"dict",
"(",
"(",
"k",
",",
"convert_general",
"(",
"val",
")",
")",
"for",
"(",
"k",
",",
"val",
")",
"in",
"params",
".",
"items",
"... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | StateSelect.render | Handle a few expected values for rendering the current choice.
Extracts the state name from StateWrapper and State object. | django_xworkflows/models.py | def render(self, name, value, attrs=None, *args, **kwargs):
"""Handle a few expected values for rendering the current choice.
Extracts the state name from StateWrapper and State object.
"""
if isinstance(value, base.StateWrapper):
state_name = value.state.name
elif i... | def render(self, name, value, attrs=None, *args, **kwargs):
"""Handle a few expected values for rendering the current choice.
Extracts the state name from StateWrapper and State object.
"""
if isinstance(value, base.StateWrapper):
state_name = value.state.name
elif i... | [
"Handle",
"a",
"few",
"expected",
"values",
"for",
"rendering",
"the",
"current",
"choice",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L38-L49 | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"state_name",
"=",
"value",
".",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.contribute_to_class | Contribute the state to a Model.
Attaches a StateFieldProperty to wrap the attribute. | django_xworkflows/models.py | def contribute_to_class(self, cls, name):
"""Contribute the state to a Model.
Attaches a StateFieldProperty to wrap the attribute.
"""
super(StateField, self).contribute_to_class(cls, name)
parent_property = getattr(cls, self.name, None)
setattr(cls, self.name, StateFie... | def contribute_to_class(self, cls, name):
"""Contribute the state to a Model.
Attaches a StateFieldProperty to wrap the attribute.
"""
super(StateField, self).contribute_to_class(cls, name)
parent_property = getattr(cls, self.name, None)
setattr(cls, self.name, StateFie... | [
"Contribute",
"the",
"state",
"to",
"a",
"Model",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L115-L123 | [
"def",
"contribute_to_class",
"(",
"self",
",",
"cls",
",",
"name",
")",
":",
"super",
"(",
"StateField",
",",
"self",
")",
".",
"contribute_to_class",
"(",
"cls",
",",
"name",
")",
"parent_property",
"=",
"getattr",
"(",
"cls",
",",
"self",
".",
"name",... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.to_python | Converts the DB-stored value into a Python value. | django_xworkflows/models.py | def to_python(self, value):
"""Converts the DB-stored value into a Python value."""
if isinstance(value, base.StateWrapper):
res = value
else:
if isinstance(value, base.State):
state = value
elif value is None:
state = self.work... | def to_python(self, value):
"""Converts the DB-stored value into a Python value."""
if isinstance(value, base.StateWrapper):
res = value
else:
if isinstance(value, base.State):
state = value
elif value is None:
state = self.work... | [
"Converts",
"the",
"DB",
"-",
"stored",
"value",
"into",
"a",
"Python",
"value",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L125-L144 | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"res",
"=",
"value",
"else",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"State",
")",
":",
"state",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.get_db_prep_value | Convert a value to DB storage.
Returns the state name. | django_xworkflows/models.py | def get_db_prep_value(self, value, connection, prepared=False):
"""Convert a value to DB storage.
Returns the state name.
"""
if not prepared:
value = self.get_prep_value(value)
return value.state.name | def get_db_prep_value(self, value, connection, prepared=False):
"""Convert a value to DB storage.
Returns the state name.
"""
if not prepared:
value = self.get_prep_value(value)
return value.state.name | [
"Convert",
"a",
"value",
"to",
"DB",
"storage",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L153-L160 | [
"def",
"get_db_prep_value",
"(",
"self",
",",
"value",
",",
"connection",
",",
"prepared",
"=",
"False",
")",
":",
"if",
"not",
"prepared",
":",
"value",
"=",
"self",
".",
"get_prep_value",
"(",
"value",
")",
"return",
"value",
".",
"state",
".",
"name"
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.value_to_string | Convert a field value to a string.
Returns the state name. | django_xworkflows/models.py | def value_to_string(self, obj):
"""Convert a field value to a string.
Returns the state name.
"""
statefield = self.to_python(self.value_from_object(obj))
return statefield.state.name | def value_to_string(self, obj):
"""Convert a field value to a string.
Returns the state name.
"""
statefield = self.to_python(self.value_from_object(obj))
return statefield.state.name | [
"Convert",
"a",
"field",
"value",
"to",
"a",
"string",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L162-L168 | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"statefield",
"=",
"self",
".",
"to_python",
"(",
"self",
".",
"value_from_object",
"(",
"obj",
")",
")",
"return",
"statefield",
".",
"state",
".",
"name"
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.validate | Validate that a given value is a valid option for a given model instance.
Args:
value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python.
model_instance: A WorkflowEnabled instance | django_xworkflows/models.py | def validate(self, value, model_instance):
"""Validate that a given value is a valid option for a given model instance.
Args:
value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python.
model_instance: A WorkflowEnabled instance
"""
if not ... | def validate(self, value, model_instance):
"""Validate that a given value is a valid option for a given model instance.
Args:
value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python.
model_instance: A WorkflowEnabled instance
"""
if not ... | [
"Validate",
"that",
"a",
"given",
"value",
"is",
"a",
"valid",
"option",
"for",
"a",
"given",
"model",
"instance",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L170-L182 | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"model_instance",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"raise",
"exceptions",
".",
"ValidationError",
"(",
"self",
".",
"error_messages",
"[",
"'wr... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | StateField.deconstruct | Deconstruction for migrations.
Return a simpler object (_SerializedWorkflow), since our Workflows
are rather hard to serialize: Django doesn't like deconstructing
metaclass-built classes. | django_xworkflows/models.py | def deconstruct(self):
"""Deconstruction for migrations.
Return a simpler object (_SerializedWorkflow), since our Workflows
are rather hard to serialize: Django doesn't like deconstructing
metaclass-built classes.
"""
name, path, args, kwargs = super(StateField, self).de... | def deconstruct(self):
"""Deconstruction for migrations.
Return a simpler object (_SerializedWorkflow), since our Workflows
are rather hard to serialize: Django doesn't like deconstructing
metaclass-built classes.
"""
name, path, args, kwargs = super(StateField, self).de... | [
"Deconstruction",
"for",
"migrations",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L187-L210 | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"StateField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"# We want to display the proper class name, which isn't available",
"# at the same point f... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | WorkflowEnabledMeta._find_workflows | Find workflow definition(s) in a WorkflowEnabled definition.
This method overrides the default behavior from xworkflows in order to
use our custom StateField objects. | django_xworkflows/models.py | def _find_workflows(mcs, attrs):
"""Find workflow definition(s) in a WorkflowEnabled definition.
This method overrides the default behavior from xworkflows in order to
use our custom StateField objects.
"""
workflows = {}
for k, v in attrs.items():
if isinsta... | def _find_workflows(mcs, attrs):
"""Find workflow definition(s) in a WorkflowEnabled definition.
This method overrides the default behavior from xworkflows in order to
use our custom StateField objects.
"""
workflows = {}
for k, v in attrs.items():
if isinsta... | [
"Find",
"workflow",
"definition",
"(",
"s",
")",
"in",
"a",
"WorkflowEnabled",
"definition",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L217-L227 | [
"def",
"_find_workflows",
"(",
"mcs",
",",
"attrs",
")",
":",
"workflows",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"StateField",
")",
":",
"workflows",
"[",
"k",
"]",
"="... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | Workflow._get_log_model_class | Cache for fetching the actual log model object once django is loaded.
Otherwise, import conflict occur: WorkflowEnabled imports <log_model>
which tries to import all models to retrieve the proper model class. | django_xworkflows/models.py | def _get_log_model_class(self):
"""Cache for fetching the actual log model object once django is loaded.
Otherwise, import conflict occur: WorkflowEnabled imports <log_model>
which tries to import all models to retrieve the proper model class.
"""
if self.log_model_class is not ... | def _get_log_model_class(self):
"""Cache for fetching the actual log model object once django is loaded.
Otherwise, import conflict occur: WorkflowEnabled imports <log_model>
which tries to import all models to retrieve the proper model class.
"""
if self.log_model_class is not ... | [
"Cache",
"for",
"fetching",
"the",
"actual",
"log",
"model",
"object",
"once",
"django",
"is",
"loaded",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L385-L396 | [
"def",
"_get_log_model_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"log_model_class",
"is",
"not",
"None",
":",
"return",
"self",
".",
"log_model_class",
"app_label",
",",
"model_label",
"=",
"self",
".",
"log_model",
".",
"rsplit",
"(",
"'.'",
",",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | Workflow.db_log | Logs the transition into the database. | django_xworkflows/models.py | def db_log(self, transition, from_state, instance, *args, **kwargs):
"""Logs the transition into the database."""
if self.log_model:
model_class = self._get_log_model_class()
extras = {}
for db_field, transition_arg, default in model_class.EXTRA_LOG_ATTRIBUTES:
... | def db_log(self, transition, from_state, instance, *args, **kwargs):
"""Logs the transition into the database."""
if self.log_model:
model_class = self._get_log_model_class()
extras = {}
for db_field, transition_arg, default in model_class.EXTRA_LOG_ATTRIBUTES:
... | [
"Logs",
"the",
"transition",
"into",
"the",
"database",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L398-L412 | [
"def",
"db_log",
"(",
"self",
",",
"transition",
",",
"from_state",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"log_model",
":",
"model_class",
"=",
"self",
".",
"_get_log_model_class",
"(",
")",
"extras",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | Workflow.log_transition | Generic transition logging. | django_xworkflows/models.py | def log_transition(self, transition, from_state, instance, *args, **kwargs):
"""Generic transition logging."""
save = kwargs.pop('save', True)
log = kwargs.pop('log', True)
super(Workflow, self).log_transition(
transition, from_state, instance, *args, **kwargs)
if sav... | def log_transition(self, transition, from_state, instance, *args, **kwargs):
"""Generic transition logging."""
save = kwargs.pop('save', True)
log = kwargs.pop('log', True)
super(Workflow, self).log_transition(
transition, from_state, instance, *args, **kwargs)
if sav... | [
"Generic",
"transition",
"logging",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L414-L423 | [
"def",
"log_transition",
"(",
"self",
",",
"transition",
",",
"from_state",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"save",
"=",
"kwargs",
".",
"pop",
"(",
"'save'",
",",
"True",
")",
"log",
"=",
"kwargs",
".",
"pop",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | clean_readme | Cleanup README.rst for proper PyPI formatting. | setup.py | def clean_readme(fname):
"""Cleanup README.rst for proper PyPI formatting."""
with codecs.open(fname, 'r', 'utf-8') as f:
return ''.join(
re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
for line in f
if not (line.startswith('.. currentmodule') or line.startswi... | def clean_readme(fname):
"""Cleanup README.rst for proper PyPI formatting."""
with codecs.open(fname, 'r', 'utf-8') as f:
return ''.join(
re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
for line in f
if not (line.startswith('.. currentmodule') or line.startswi... | [
"Cleanup",
"README",
".",
"rst",
"for",
"proper",
"PyPI",
"formatting",
"."
] | rbarrois/django_xworkflows | python | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/setup.py#L31-L38 | [
"def",
"clean_readme",
"(",
"fname",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fname",
",",
"'r'",
",",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"''",
".",
"join",
"(",
"re",
".",
"sub",
"(",
"r':\\w+:`([^`]+?)( <[^<>]+>)?`'",
",",
"r'``\\1``'",
... | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 |
train | _get_album_or_image | Return a gallery image/album depending on what the json represent. | pyimgur/__init__.py | def _get_album_or_image(json, imgur):
"""Return a gallery image/album depending on what the json represent."""
if json['is_album']:
return Gallery_album(json, imgur, has_fetched=False)
return Gallery_image(json, imgur) | def _get_album_or_image(json, imgur):
"""Return a gallery image/album depending on what the json represent."""
if json['is_album']:
return Gallery_album(json, imgur, has_fetched=False)
return Gallery_image(json, imgur) | [
"Return",
"a",
"gallery",
"image",
"/",
"album",
"depending",
"on",
"what",
"the",
"json",
"represent",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L66-L70 | [
"def",
"_get_album_or_image",
"(",
"json",
",",
"imgur",
")",
":",
"if",
"json",
"[",
"'is_album'",
"]",
":",
"return",
"Gallery_album",
"(",
"json",
",",
"imgur",
",",
"has_fetched",
"=",
"False",
")",
"return",
"Gallery_image",
"(",
"json",
",",
"imgur",... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Basic_object.refresh | Refresh this objects attributes to the newest values.
Attributes that weren't added to the object before, due to lazy
loading, will be added by calling refresh. | pyimgur/__init__.py | def refresh(self):
"""
Refresh this objects attributes to the newest values.
Attributes that weren't added to the object before, due to lazy
loading, will be added by calling refresh.
"""
resp = self._imgur._send_request(self._INFO_URL)
self._populate(resp)
... | def refresh(self):
"""
Refresh this objects attributes to the newest values.
Attributes that weren't added to the object before, due to lazy
loading, will be added by calling refresh.
"""
resp = self._imgur._send_request(self._INFO_URL)
self._populate(resp)
... | [
"Refresh",
"this",
"objects",
"attributes",
"to",
"the",
"newest",
"values",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L220-L229 | [
"def",
"refresh",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"self",
".",
"_INFO_URL",
")",
"self",
".",
"_populate",
"(",
"resp",
")",
"self",
".",
"_has_fetched",
"=",
"True"
] | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Album.add_images | Add images to the album.
:param images: A list of the images we want to add to the album. Can be
Image objects, ids or a combination of the two. Images that you
cannot add (non-existing or not owned by you) will not cause
exceptions, but fail silently. | pyimgur/__init__.py | def add_images(self, images):
"""
Add images to the album.
:param images: A list of the images we want to add to the album. Can be
Image objects, ids or a combination of the two. Images that you
cannot add (non-existing or not owned by you) will not cause
ex... | def add_images(self, images):
"""
Add images to the album.
:param images: A list of the images we want to add to the album. Can be
Image objects, ids or a combination of the two. Images that you
cannot add (non-existing or not owned by you) will not cause
ex... | [
"Add",
"images",
"to",
"the",
"album",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L265-L277 | [
"def",
"add_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/{0}/add\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"params",
"=",
"{",
"'ids'",
":",
"images",
"}",
"return",
"self",
... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Album.remove_images | Remove images from the album.
:param images: A list of the images we want to remove from the album.
Can be Image objects, ids or a combination of the two. Images that
you cannot remove (non-existing, not owned by you or not part of
album) will not cause exceptions, but fail ... | pyimgur/__init__.py | def remove_images(self, images):
"""
Remove images from the album.
:param images: A list of the images we want to remove from the album.
Can be Image objects, ids or a combination of the two. Images that
you cannot remove (non-existing, not owned by you or not part of
... | def remove_images(self, images):
"""
Remove images from the album.
:param images: A list of the images we want to remove from the album.
Can be Image objects, ids or a combination of the two. Images that
you cannot remove (non-existing, not owned by you or not part of
... | [
"Remove",
"images",
"from",
"the",
"album",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L294-L308 | [
"def",
"remove_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/{0}/\"",
"\"remove_images\"",
".",
"format",
"(",
"self",
".",
"_delete_or_id_hash",
")",
")",
"# NOTE: Returns True and ever... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Album.set_images | Set the images in this album.
:param images: A list of the images we want the album to contain.
Can be Image objects, ids or a combination of the two. Images that
images that you cannot set (non-existing or not owned by you) will
not cause exceptions, but fail silently. | pyimgur/__init__.py | def set_images(self, images):
"""
Set the images in this album.
:param images: A list of the images we want the album to contain.
Can be Image objects, ids or a combination of the two. Images that
images that you cannot set (non-existing or not owned by you) will
... | def set_images(self, images):
"""
Set the images in this album.
:param images: A list of the images we want the album to contain.
Can be Image objects, ids or a combination of the two. Images that
images that you cannot set (non-existing or not owned by you) will
... | [
"Set",
"the",
"images",
"in",
"this",
"album",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L310-L323 | [
"def",
"set_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/\"",
"\"{0}/\"",
".",
"format",
"(",
"self",
".",
"_delete_or_id_hash",
")",
")",
"params",
"=",
"{",
"'ids'",
":",
"i... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Album.submit_to_gallery | Add this to the gallery.
Require that the authenticated user has accepted gallery terms and
verified their email.
:param title: The title of the new gallery item.
:param bypass_terms: If the user has not accepted Imgur's terms yet,
this method will return an error. Set this... | pyimgur/__init__.py | def submit_to_gallery(self, title, bypass_terms=False):
"""
Add this to the gallery.
Require that the authenticated user has accepted gallery terms and
verified their email.
:param title: The title of the new gallery item.
:param bypass_terms: If the user has not accept... | def submit_to_gallery(self, title, bypass_terms=False):
"""
Add this to the gallery.
Require that the authenticated user has accepted gallery terms and
verified their email.
:param title: The title of the new gallery item.
:param bypass_terms: If the user has not accept... | [
"Add",
"this",
"to",
"the",
"gallery",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L325-L343 | [
"def",
"submit_to_gallery",
"(",
"self",
",",
"title",
",",
"bypass_terms",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"payload",
"=",
"{",
"'title'"... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Album.update | Update the album's information.
Arguments with the value None will retain their old values.
:param title: The title of the album.
:param description: A description of the album.
:param images: A list of the images we want the album to contain.
Can be Image objects, ids or a... | pyimgur/__init__.py | def update(self, title=None, description=None, images=None, cover=None,
layout=None, privacy=None):
"""
Update the album's information.
Arguments with the value None will retain their old values.
:param title: The title of the album.
:param description: A descrip... | def update(self, title=None, description=None, images=None, cover=None,
layout=None, privacy=None):
"""
Update the album's information.
Arguments with the value None will retain their old values.
:param title: The title of the album.
:param description: A descrip... | [
"Update",
"the",
"album",
"s",
"information",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L345-L381 | [
"def",
"update",
"(",
"self",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"images",
"=",
"None",
",",
"cover",
"=",
"None",
",",
"layout",
"=",
"None",
",",
"privacy",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_im... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Comment.get_replies | Get the replies to this comment. | pyimgur/__init__.py | def get_replies(self):
"""Get the replies to this comment."""
url = self._imgur._base_url + "/3/comment/{0}/replies".format(self.id)
json = self._imgur._send_request(url)
child_comments = json['children']
return [Comment(com, self._imgur) for com in child_comments] | def get_replies(self):
"""Get the replies to this comment."""
url = self._imgur._base_url + "/3/comment/{0}/replies".format(self.id)
json = self._imgur._send_request(url)
child_comments = json['children']
return [Comment(com, self._imgur) for com in child_comments] | [
"Get",
"the",
"replies",
"to",
"this",
"comment",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L432-L437 | [
"def",
"get_replies",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/comment/{0}/replies\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"json",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
")",
... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Gallery_item.comment | Make a top-level comment to this.
:param text: The comment text. | pyimgur/__init__.py | def comment(self, text):
"""
Make a top-level comment to this.
:param text: The comment text.
"""
url = self._imgur._base_url + "/3/comment"
payload = {'image_id': self.id, 'comment': text}
resp = self._imgur._send_request(url, params=payload, needs_auth=True,
... | def comment(self, text):
"""
Make a top-level comment to this.
:param text: The comment text.
"""
url = self._imgur._base_url + "/3/comment"
payload = {'image_id': self.id, 'comment': text}
resp = self._imgur._send_request(url, params=payload, needs_auth=True,
... | [
"Make",
"a",
"top",
"-",
"level",
"comment",
"to",
"this",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L464-L474 | [
"def",
"comment",
"(",
"self",
",",
"text",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/comment\"",
"payload",
"=",
"{",
"'image_id'",
":",
"self",
".",
"id",
",",
"'comment'",
":",
"text",
"}",
"resp",
"=",
"self",
".",... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Gallery_item.downvote | Dislike this.
A downvote will replace a neutral vote or an upvote. Downvoting
something the authenticated user has already downvoted will set the
vote to neutral. | pyimgur/__init__.py | def downvote(self):
"""
Dislike this.
A downvote will replace a neutral vote or an upvote. Downvoting
something the authenticated user has already downvoted will set the
vote to neutral.
"""
url = self._imgur._base_url + "/3/gallery/{0}/vote/down".format(self.id)... | def downvote(self):
"""
Dislike this.
A downvote will replace a neutral vote or an upvote. Downvoting
something the authenticated user has already downvoted will set the
vote to neutral.
"""
url = self._imgur._base_url + "/3/gallery/{0}/vote/down".format(self.id)... | [
"Dislike",
"this",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L476-L485 | [
"def",
"downvote",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}/vote/down\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
",",
"needs... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Gallery_item.get_comments | Get a list of the top-level comments. | pyimgur/__init__.py | def get_comments(self):
"""Get a list of the top-level comments."""
url = self._imgur._base_url + "/3/gallery/{0}/comments".format(self.id)
resp = self._imgur._send_request(url)
return [Comment(com, self._imgur) for com in resp] | def get_comments(self):
"""Get a list of the top-level comments."""
url = self._imgur._base_url + "/3/gallery/{0}/comments".format(self.id)
resp = self._imgur._send_request(url)
return [Comment(com, self._imgur) for com in resp] | [
"Get",
"a",
"list",
"of",
"the",
"top",
"-",
"level",
"comments",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L487-L491 | [
"def",
"get_comments",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}/comments\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
")",
... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
train | Gallery_item.remove_from_gallery | Remove this image from the gallery. | pyimgur/__init__.py | def remove_from_gallery(self):
"""Remove this image from the gallery."""
url = self._imgur._base_url + "/3/gallery/{0}".format(self.id)
self._imgur._send_request(url, needs_auth=True, method='DELETE')
if isinstance(self, Image):
item = self._imgur.get_image(self.id)
e... | def remove_from_gallery(self):
"""Remove this image from the gallery."""
url = self._imgur._base_url + "/3/gallery/{0}".format(self.id)
self._imgur._send_request(url, needs_auth=True, method='DELETE')
if isinstance(self, Image):
item = self._imgur.get_image(self.id)
e... | [
"Remove",
"this",
"image",
"from",
"the",
"gallery",
"."
] | Damgaard/PyImgur | python | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L493-L502 | [
"def",
"remove_from_gallery",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
",",
"needs_auth",
"... | 606f17078d24158632f807430f8d0b9b3cd8b312 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.