repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.get_note_names
def get_note_names(self): """Return a list with all the note names in the current container. Every name will only be mentioned once. """ res = [] for n in self.notes: if n.name not in res: res.append(n.name) return res
python
def get_note_names(self): """Return a list with all the note names in the current container. Every name will only be mentioned once. """ res = [] for n in self.notes: if n.name not in res: res.append(n.name) return res
[ "def", "get_note_names", "(", "self", ")", ":", "res", "=", "[", "]", "for", "n", "in", "self", ".", "notes", ":", "if", "n", ".", "name", "not", "in", "res", ":", "res", ".", "append", "(", "n", ".", "name", ")", "return", "res" ]
Return a list with all the note names in the current container. Every name will only be mentioned once.
[ "Return", "a", "list", "with", "all", "the", "note", "names", "in", "the", "current", "container", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L283-L292
bspaans/python-mingus
mingus/core/scales.py
determine
def determine(notes): """Determine the scales containing the notes. All major and minor scales are recognized. Example: >>> determine(['A', 'Bb', 'E', 'F#', 'G']) ['G melodic minor', 'G Bachian', 'D harmonic major'] """ notes = set(notes) res = [] for key in keys: for scal...
python
def determine(notes): """Determine the scales containing the notes. All major and minor scales are recognized. Example: >>> determine(['A', 'Bb', 'E', 'F#', 'G']) ['G melodic minor', 'G Bachian', 'D harmonic major'] """ notes = set(notes) res = [] for key in keys: for scal...
[ "def", "determine", "(", "notes", ")", ":", "notes", "=", "set", "(", "notes", ")", "res", "=", "[", "]", "for", "key", "in", "keys", ":", "for", "scale", "in", "_Scale", ".", "__subclasses__", "(", ")", ":", "if", "scale", ".", "type", "==", "'m...
Determine the scales containing the notes. All major and minor scales are recognized. Example: >>> determine(['A', 'Bb', 'E', 'F#', 'G']) ['G melodic minor', 'G Bachian', 'D harmonic major']
[ "Determine", "the", "scales", "containing", "the", "notes", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/scales.py#L60-L82
bspaans/python-mingus
mingus/core/scales.py
_Scale.degree
def degree(self, degree_number, direction='a'): """Return the asked scale degree. The direction of the scale is 'a' for ascending (default) and 'd' for descending. """ if degree_number < 1: raise RangeError("degree '%s' out of range" % degree_number) if direc...
python
def degree(self, degree_number, direction='a'): """Return the asked scale degree. The direction of the scale is 'a' for ascending (default) and 'd' for descending. """ if degree_number < 1: raise RangeError("degree '%s' out of range" % degree_number) if direc...
[ "def", "degree", "(", "self", ",", "degree_number", ",", "direction", "=", "'a'", ")", ":", "if", "degree_number", "<", "1", ":", "raise", "RangeError", "(", "\"degree '%s' out of range\"", "%", "degree_number", ")", "if", "direction", "==", "'a'", ":", "not...
Return the asked scale degree. The direction of the scale is 'a' for ascending (default) and 'd' for descending.
[ "Return", "the", "asked", "scale", "degree", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/scales.py#L126-L141
bspaans/python-mingus
mingus/extra/tablature.py
begin_track
def begin_track(tuning, padding=2): """Helper function that builds the first few characters of every bar.""" # find longest shorthand tuning base names = [x.to_shorthand() for x in tuning.tuning] basesize = len(max(names)) + 3 # Build result res = [] for x in names: r = ' %s' % x ...
python
def begin_track(tuning, padding=2): """Helper function that builds the first few characters of every bar.""" # find longest shorthand tuning base names = [x.to_shorthand() for x in tuning.tuning] basesize = len(max(names)) + 3 # Build result res = [] for x in names: r = ' %s' % x ...
[ "def", "begin_track", "(", "tuning", ",", "padding", "=", "2", ")", ":", "# find longest shorthand tuning base", "names", "=", "[", "x", ".", "to_shorthand", "(", ")", "for", "x", "in", "tuning", ".", "tuning", "]", "basesize", "=", "len", "(", "max", "(...
Helper function that builds the first few characters of every bar.
[ "Helper", "function", "that", "builds", "the", "first", "few", "characters", "of", "every", "bar", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L28-L41
bspaans/python-mingus
mingus/extra/tablature.py
add_headers
def add_headers(width=80, title='Untitled', subtitle='', author='', email='', description='', tunings=[]): """Create a nice header in the form of a list of strings using the information that has been filled in. All arguments except 'width' and 'tunings' should be strings. 'width' should be an i...
python
def add_headers(width=80, title='Untitled', subtitle='', author='', email='', description='', tunings=[]): """Create a nice header in the form of a list of strings using the information that has been filled in. All arguments except 'width' and 'tunings' should be strings. 'width' should be an i...
[ "def", "add_headers", "(", "width", "=", "80", ",", "title", "=", "'Untitled'", ",", "subtitle", "=", "''", ",", "author", "=", "''", ",", "email", "=", "''", ",", "description", "=", "''", ",", "tunings", "=", "[", "]", ")", ":", "result", "=", ...
Create a nice header in the form of a list of strings using the information that has been filled in. All arguments except 'width' and 'tunings' should be strings. 'width' should be an integer and 'tunings' a list of tunings representing the instruments.
[ "Create", "a", "nice", "header", "in", "the", "form", "of", "a", "list", "of", "strings", "using", "the", "information", "that", "has", "been", "filled", "in", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L44-L88
bspaans/python-mingus
mingus/extra/tablature.py
from_Note
def from_Note(note, width=80, tuning=None): """Return a string made out of ASCII tablature representing a Note object or note string. Throw a RangeError if a suitable fret can't be found. 'tuning' should be a StringTuning object or None for the default tuning. To force a certain fingering you can...
python
def from_Note(note, width=80, tuning=None): """Return a string made out of ASCII tablature representing a Note object or note string. Throw a RangeError if a suitable fret can't be found. 'tuning' should be a StringTuning object or None for the default tuning. To force a certain fingering you can...
[ "def", "from_Note", "(", "note", ",", "width", "=", "80", ",", "tuning", "=", "None", ")", ":", "if", "tuning", "is", "None", ":", "tuning", "=", "default_tuning", "result", "=", "begin_track", "(", "tuning", ")", "min", "=", "1000", "(", "s", ",", ...
Return a string made out of ASCII tablature representing a Note object or note string. Throw a RangeError if a suitable fret can't be found. 'tuning' should be a StringTuning object or None for the default tuning. To force a certain fingering you can use a 'string' and 'fret' attribute on the Not...
[ "Return", "a", "string", "made", "out", "of", "ASCII", "tablature", "representing", "a", "Note", "object", "or", "note", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L90-L140
bspaans/python-mingus
mingus/extra/tablature.py
from_NoteContainer
def from_NoteContainer(notes, width=80, tuning=None): """Return a string made out of ASCII tablature representing a NoteContainer object or list of note strings / Note objects. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default t...
python
def from_NoteContainer(notes, width=80, tuning=None): """Return a string made out of ASCII tablature representing a NoteContainer object or list of note strings / Note objects. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default t...
[ "def", "from_NoteContainer", "(", "notes", ",", "width", "=", "80", ",", "tuning", "=", "None", ")", ":", "if", "tuning", "is", "None", ":", "tuning", "=", "default_tuning", "result", "=", "begin_track", "(", "tuning", ")", "l", "=", "len", "(", "resul...
Return a string made out of ASCII tablature representing a NoteContainer object or list of note strings / Note objects. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default tuning. To force a certain fingering you can use a 'strin...
[ "Return", "a", "string", "made", "out", "of", "ASCII", "tablature", "representing", "a", "NoteContainer", "object", "or", "list", "of", "note", "strings", "/", "Note", "objects", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L142-L208
bspaans/python-mingus
mingus/extra/tablature.py
from_Bar
def from_Bar(bar, width=40, tuning=None, collapse=True): """Convert a mingus.containers.Bar object to ASCII tablature. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default tuning. If 'collapse' is False this will return a list of l...
python
def from_Bar(bar, width=40, tuning=None, collapse=True): """Convert a mingus.containers.Bar object to ASCII tablature. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default tuning. If 'collapse' is False this will return a list of l...
[ "def", "from_Bar", "(", "bar", ",", "width", "=", "40", ",", "tuning", "=", "None", ",", "collapse", "=", "True", ")", ":", "if", "tuning", "is", "None", ":", "tuning", "=", "default_tuning", "# Size of a quarter note", "qsize", "=", "_get_qsize", "(", "...
Convert a mingus.containers.Bar object to ASCII tablature. Throw a FingerError if no playable fingering can be found. 'tuning' should be a StringTuning object or None for the default tuning. If 'collapse' is False this will return a list of lines, if it's True all lines will be concatenated with a new...
[ "Convert", "a", "mingus", ".", "containers", ".", "Bar", "object", "to", "ASCII", "tablature", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L210-L300
bspaans/python-mingus
mingus/extra/tablature.py
from_Track
def from_Track(track, maxwidth=80, tuning=None): """Convert a mingus.containers.Track object to an ASCII tablature string. 'tuning' should be set to a StringTuning object or to None to use the Track's tuning (or alternatively the default if the Track hasn't got its own tuning). 'string' and 'fret'...
python
def from_Track(track, maxwidth=80, tuning=None): """Convert a mingus.containers.Track object to an ASCII tablature string. 'tuning' should be set to a StringTuning object or to None to use the Track's tuning (or alternatively the default if the Track hasn't got its own tuning). 'string' and 'fret'...
[ "def", "from_Track", "(", "track", ",", "maxwidth", "=", "80", ",", "tuning", "=", "None", ")", ":", "result", "=", "[", "]", "width", "=", "_get_width", "(", "maxwidth", ")", "if", "not", "tuning", ":", "tuning", "=", "track", ".", "get_tuning", "("...
Convert a mingus.containers.Track object to an ASCII tablature string. 'tuning' should be set to a StringTuning object or to None to use the Track's tuning (or alternatively the default if the Track hasn't got its own tuning). 'string' and 'fret' attributes on Notes are taken into account.
[ "Convert", "a", "mingus", ".", "containers", ".", "Track", "object", "to", "an", "ASCII", "tablature", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L302-L326
bspaans/python-mingus
mingus/extra/tablature.py
from_Composition
def from_Composition(composition, width=80): """Convert a mingus.containers.Composition to an ASCII tablature string. Automatically add an header based on the title, subtitle, author, e-mail and description attributes. An extra description of the piece can also be given. Tunings can be set by usin...
python
def from_Composition(composition, width=80): """Convert a mingus.containers.Composition to an ASCII tablature string. Automatically add an header based on the title, subtitle, author, e-mail and description attributes. An extra description of the piece can also be given. Tunings can be set by usin...
[ "def", "from_Composition", "(", "composition", ",", "width", "=", "80", ")", ":", "# Collect tunings", "instr_tunings", "=", "[", "]", "for", "track", "in", "composition", ":", "tun", "=", "track", ".", "get_tuning", "(", ")", "if", "tun", ":", "instr_tuni...
Convert a mingus.containers.Composition to an ASCII tablature string. Automatically add an header based on the title, subtitle, author, e-mail and description attributes. An extra description of the piece can also be given. Tunings can be set by using the Track.instrument.tuning or Track.tuning at...
[ "Convert", "a", "mingus", ".", "containers", ".", "Composition", "to", "an", "ASCII", "tablature", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L328-L397
bspaans/python-mingus
mingus/extra/tablature.py
from_Suite
def from_Suite(suite, maxwidth=80): """Convert a mingus.containers.Suite to an ASCII tablature string, complete with headers. This function makes use of the Suite's title, subtitle, author, email and description attributes. """ subtitle = str(len(suite.compositions)) + ' Compositions' if suite....
python
def from_Suite(suite, maxwidth=80): """Convert a mingus.containers.Suite to an ASCII tablature string, complete with headers. This function makes use of the Suite's title, subtitle, author, email and description attributes. """ subtitle = str(len(suite.compositions)) + ' Compositions' if suite....
[ "def", "from_Suite", "(", "suite", ",", "maxwidth", "=", "80", ")", ":", "subtitle", "=", "str", "(", "len", "(", "suite", ".", "compositions", ")", ")", "+", "' Compositions'", "if", "suite", ".", "subtitle", "==", "''", "else", "suite", ".", "subtitl...
Convert a mingus.containers.Suite to an ASCII tablature string, complete with headers. This function makes use of the Suite's title, subtitle, author, email and description attributes.
[ "Convert", "a", "mingus", ".", "containers", ".", "Suite", "to", "an", "ASCII", "tablature", "string", "complete", "with", "headers", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L399-L422
bspaans/python-mingus
mingus/extra/tablature.py
_get_qsize
def _get_qsize(tuning, width): """Return a reasonable quarter note size for 'tuning' and 'width'.""" names = [x.to_shorthand() for x in tuning.tuning] basesize = len(max(names)) + 3 barsize = ((width - basesize) - 2) - 1 # x * 4 + 0.5x - barsize = 0 4.5x = barsize x = barsize / 4.5 return max(0...
python
def _get_qsize(tuning, width): """Return a reasonable quarter note size for 'tuning' and 'width'.""" names = [x.to_shorthand() for x in tuning.tuning] basesize = len(max(names)) + 3 barsize = ((width - basesize) - 2) - 1 # x * 4 + 0.5x - barsize = 0 4.5x = barsize x = barsize / 4.5 return max(0...
[ "def", "_get_qsize", "(", "tuning", ",", "width", ")", ":", "names", "=", "[", "x", ".", "to_shorthand", "(", ")", "for", "x", "in", "tuning", ".", "tuning", "]", "basesize", "=", "len", "(", "max", "(", "names", ")", ")", "+", "3", "barsize", "=...
Return a reasonable quarter note size for 'tuning' and 'width'.
[ "Return", "a", "reasonable", "quarter", "note", "size", "for", "tuning", "and", "width", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L424-L431
bspaans/python-mingus
mingus/extra/tablature.py
_get_width
def _get_width(maxwidth): """Return the width of a single bar, when width of the page is given.""" width = maxwidth / 3 if maxwidth <= 60: width = maxwidth elif 60 < maxwidth <= 120: width = maxwidth / 2 return width
python
def _get_width(maxwidth): """Return the width of a single bar, when width of the page is given.""" width = maxwidth / 3 if maxwidth <= 60: width = maxwidth elif 60 < maxwidth <= 120: width = maxwidth / 2 return width
[ "def", "_get_width", "(", "maxwidth", ")", ":", "width", "=", "maxwidth", "/", "3", "if", "maxwidth", "<=", "60", ":", "width", "=", "maxwidth", "elif", "60", "<", "maxwidth", "<=", "120", ":", "width", "=", "maxwidth", "/", "2", "return", "width" ]
Return the width of a single bar, when width of the page is given.
[ "Return", "the", "width", "of", "a", "single", "bar", "when", "width", "of", "the", "page", "is", "given", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L433-L440
bspaans/python-mingus
mingus/core/chords.py
triad
def triad(note, key): """Return the triad on note in key as a list. Examples: >>> triad('E', 'C') ['E', 'G', 'B'] >>> triad('E', 'B') ['E', 'G#', 'B'] """ return [note, intervals.third(note, key), intervals.fifth(note, key)]
python
def triad(note, key): """Return the triad on note in key as a list. Examples: >>> triad('E', 'C') ['E', 'G', 'B'] >>> triad('E', 'B') ['E', 'G#', 'B'] """ return [note, intervals.third(note, key), intervals.fifth(note, key)]
[ "def", "triad", "(", "note", ",", "key", ")", ":", "return", "[", "note", ",", "intervals", ".", "third", "(", "note", ",", "key", ")", ",", "intervals", ".", "fifth", "(", "note", ",", "key", ")", "]" ]
Return the triad on note in key as a list. Examples: >>> triad('E', 'C') ['E', 'G', 'B'] >>> triad('E', 'B') ['E', 'G#', 'B']
[ "Return", "the", "triad", "on", "note", "in", "key", "as", "a", "list", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L165-L174
bspaans/python-mingus
mingus/core/chords.py
triads
def triads(key): """Return all the triads in key. Implemented using a cache. """ if _triads_cache.has_key(key): return _triads_cache[key] res = map(lambda x: triad(x, key), keys.get_notes(key)) _triads_cache[key] = res return res
python
def triads(key): """Return all the triads in key. Implemented using a cache. """ if _triads_cache.has_key(key): return _triads_cache[key] res = map(lambda x: triad(x, key), keys.get_notes(key)) _triads_cache[key] = res return res
[ "def", "triads", "(", "key", ")", ":", "if", "_triads_cache", ".", "has_key", "(", "key", ")", ":", "return", "_triads_cache", "[", "key", "]", "res", "=", "map", "(", "lambda", "x", ":", "triad", "(", "x", ",", "key", ")", ",", "keys", ".", "get...
Return all the triads in key. Implemented using a cache.
[ "Return", "all", "the", "triads", "in", "key", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L176-L185
bspaans/python-mingus
mingus/core/chords.py
augmented_triad
def augmented_triad(note): """Build an augmented triad on note. Example: >>> augmented_triad('C') ['C', 'E', 'G#'] """ return [note, intervals.major_third(note), notes.augment(intervals.major_fifth(note))]
python
def augmented_triad(note): """Build an augmented triad on note. Example: >>> augmented_triad('C') ['C', 'E', 'G#'] """ return [note, intervals.major_third(note), notes.augment(intervals.major_fifth(note))]
[ "def", "augmented_triad", "(", "note", ")", ":", "return", "[", "note", ",", "intervals", ".", "major_third", "(", "note", ")", ",", "notes", ".", "augment", "(", "intervals", ".", "major_fifth", "(", "note", ")", ")", "]" ]
Build an augmented triad on note. Example: >>> augmented_triad('C') ['C', 'E', 'G#']
[ "Build", "an", "augmented", "triad", "on", "note", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L214-L222
bspaans/python-mingus
mingus/core/chords.py
seventh
def seventh(note, key): """Return the seventh chord on note in key. Example: >>> seventh('C', 'C') ['C', 'E', 'G', 'B'] """ return triad(note, key) + [intervals.seventh(note, key)]
python
def seventh(note, key): """Return the seventh chord on note in key. Example: >>> seventh('C', 'C') ['C', 'E', 'G', 'B'] """ return triad(note, key) + [intervals.seventh(note, key)]
[ "def", "seventh", "(", "note", ",", "key", ")", ":", "return", "triad", "(", "note", ",", "key", ")", "+", "[", "intervals", ".", "seventh", "(", "note", ",", "key", ")", "]" ]
Return the seventh chord on note in key. Example: >>> seventh('C', 'C') ['C', 'E', 'G', 'B']
[ "Return", "the", "seventh", "chord", "on", "note", "in", "key", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L224-L231
bspaans/python-mingus
mingus/core/chords.py
sevenths
def sevenths(key): """Return all the sevenths chords in key in a list.""" if _sevenths_cache.has_key(key): return _sevenths_cache[key] res = map(lambda x: seventh(x, key), keys.get_notes(key)) _sevenths_cache[key] = res return res
python
def sevenths(key): """Return all the sevenths chords in key in a list.""" if _sevenths_cache.has_key(key): return _sevenths_cache[key] res = map(lambda x: seventh(x, key), keys.get_notes(key)) _sevenths_cache[key] = res return res
[ "def", "sevenths", "(", "key", ")", ":", "if", "_sevenths_cache", ".", "has_key", "(", "key", ")", ":", "return", "_sevenths_cache", "[", "key", "]", "res", "=", "map", "(", "lambda", "x", ":", "seventh", "(", "x", ",", "key", ")", ",", "keys", "."...
Return all the sevenths chords in key in a list.
[ "Return", "all", "the", "sevenths", "chords", "in", "key", "in", "a", "list", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L233-L239
bspaans/python-mingus
mingus/core/chords.py
dominant_flat_ninth
def dominant_flat_ninth(note): """Build a dominant flat ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'Db'] """ res = dominant_ninth(note) res[4] = intervals.minor_second(note) return res
python
def dominant_flat_ninth(note): """Build a dominant flat ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'Db'] """ res = dominant_ninth(note) res[4] = intervals.minor_second(note) return res
[ "def", "dominant_flat_ninth", "(", "note", ")", ":", "res", "=", "dominant_ninth", "(", "note", ")", "res", "[", "4", "]", "=", "intervals", ".", "minor_second", "(", "note", ")", "return", "res" ]
Build a dominant flat ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'Db']
[ "Build", "a", "dominant", "flat", "ninth", "chord", "on", "note", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L368-L377
bspaans/python-mingus
mingus/core/chords.py
dominant_sharp_ninth
def dominant_sharp_ninth(note): """Build a dominant sharp ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'D#'] """ res = dominant_ninth(note) res[4] = notes.augment(intervals.major_second(note)) return res
python
def dominant_sharp_ninth(note): """Build a dominant sharp ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'D#'] """ res = dominant_ninth(note) res[4] = notes.augment(intervals.major_second(note)) return res
[ "def", "dominant_sharp_ninth", "(", "note", ")", ":", "res", "=", "dominant_ninth", "(", "note", ")", "res", "[", "4", "]", "=", "notes", ".", "augment", "(", "intervals", ".", "major_second", "(", "note", ")", ")", "return", "res" ]
Build a dominant sharp ninth chord on note. Example: >>> dominant_ninth('C') ['C', 'E', 'G', 'Bb', 'D#']
[ "Build", "a", "dominant", "sharp", "ninth", "chord", "on", "note", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L379-L388
bspaans/python-mingus
mingus/core/chords.py
eleventh
def eleventh(note): """Build an eleventh chord on note. Example: >>> eleventh('C') ['C', 'G', 'Bb', 'F'] """ return [note, intervals.perfect_fifth(note), intervals.minor_seventh(note), intervals.perfect_fourth(note)]
python
def eleventh(note): """Build an eleventh chord on note. Example: >>> eleventh('C') ['C', 'G', 'Bb', 'F'] """ return [note, intervals.perfect_fifth(note), intervals.minor_seventh(note), intervals.perfect_fourth(note)]
[ "def", "eleventh", "(", "note", ")", ":", "return", "[", "note", ",", "intervals", ".", "perfect_fifth", "(", "note", ")", ",", "intervals", ".", "minor_seventh", "(", "note", ")", ",", "intervals", ".", "perfect_fourth", "(", "note", ")", "]" ]
Build an eleventh chord on note. Example: >>> eleventh('C') ['C', 'G', 'Bb', 'F']
[ "Build", "an", "eleventh", "chord", "on", "note", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L390-L398
bspaans/python-mingus
mingus/core/chords.py
dominant_flat_five
def dominant_flat_five(note): """Build a dominant flat five chord on note. Example: >>> dominant_flat_five('C') ['C', 'E', 'Gb', 'Bb'] """ res = dominant_seventh(note) res[2] = notes.diminish(res[2]) return res
python
def dominant_flat_five(note): """Build a dominant flat five chord on note. Example: >>> dominant_flat_five('C') ['C', 'E', 'Gb', 'Bb'] """ res = dominant_seventh(note) res[2] = notes.diminish(res[2]) return res
[ "def", "dominant_flat_five", "(", "note", ")", ":", "res", "=", "dominant_seventh", "(", "note", ")", "res", "[", "2", "]", "=", "notes", ".", "diminish", "(", "res", "[", "2", "]", ")", "return", "res" ]
Build a dominant flat five chord on note. Example: >>> dominant_flat_five('C') ['C', 'E', 'Gb', 'Bb']
[ "Build", "a", "dominant", "flat", "five", "chord", "on", "note", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L494-L503
bspaans/python-mingus
mingus/core/chords.py
from_shorthand
def from_shorthand(shorthand_string, slash=None): """Take a chord written in shorthand and return the notes in the chord. The function can recognize triads, sevenths, sixths, ninths, elevenths, thirteenths, slashed chords and a number of altered chords. The second argument should not be given and is o...
python
def from_shorthand(shorthand_string, slash=None): """Take a chord written in shorthand and return the notes in the chord. The function can recognize triads, sevenths, sixths, ninths, elevenths, thirteenths, slashed chords and a number of altered chords. The second argument should not be given and is o...
[ "def", "from_shorthand", "(", "shorthand_string", ",", "slash", "=", "None", ")", ":", "# warning reduce??", "if", "type", "(", "shorthand_string", ")", "==", "list", ":", "res", "=", "[", "]", "for", "x", "in", "shorthand_string", ":", "res", ".", "append...
Take a chord written in shorthand and return the notes in the chord. The function can recognize triads, sevenths, sixths, ninths, elevenths, thirteenths, slashed chords and a number of altered chords. The second argument should not be given and is only used for a recursive call when a slashed chord or...
[ "Take", "a", "chord", "written", "in", "shorthand", "and", "return", "the", "notes", "in", "the", "chord", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L699-L823
bspaans/python-mingus
mingus/core/chords.py
determine
def determine(chord, shorthand=False, no_inversions=False, no_polychords=False): """Name a chord. This function can determine almost every chord, from a simple triad to a fourteen note polychord.""" if chord == []: return [] elif len(chord) == 1: return chord elif len(chord) == ...
python
def determine(chord, shorthand=False, no_inversions=False, no_polychords=False): """Name a chord. This function can determine almost every chord, from a simple triad to a fourteen note polychord.""" if chord == []: return [] elif len(chord) == 1: return chord elif len(chord) == ...
[ "def", "determine", "(", "chord", ",", "shorthand", "=", "False", ",", "no_inversions", "=", "False", ",", "no_polychords", "=", "False", ")", ":", "if", "chord", "==", "[", "]", ":", "return", "[", "]", "elif", "len", "(", "chord", ")", "==", "1", ...
Name a chord. This function can determine almost every chord, from a simple triad to a fourteen note polychord.
[ "Name", "a", "chord", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L825-L850
bspaans/python-mingus
mingus/core/chords.py
determine_triad
def determine_triad(triad, shorthand=False, no_inversions=False, placeholder=None): """Name the triad; return answers in a list. The third argument should not be given. If shorthand is True the answers will be in abbreviated form. This function can determine major, minor, diminished and suspen...
python
def determine_triad(triad, shorthand=False, no_inversions=False, placeholder=None): """Name the triad; return answers in a list. The third argument should not be given. If shorthand is True the answers will be in abbreviated form. This function can determine major, minor, diminished and suspen...
[ "def", "determine_triad", "(", "triad", ",", "shorthand", "=", "False", ",", "no_inversions", "=", "False", ",", "placeholder", "=", "None", ")", ":", "if", "len", "(", "triad", ")", "!=", "3", ":", "# warning: raise exception: not a triad", "return", "False",...
Name the triad; return answers in a list. The third argument should not be given. If shorthand is True the answers will be in abbreviated form. This function can determine major, minor, diminished and suspended triads. Also knows about invertions. Examples: >>> determine_triad(['A', 'C', 'E']...
[ "Name", "the", "triad", ";", "return", "answers", "in", "a", "list", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L852-L925
bspaans/python-mingus
mingus/core/chords.py
determine_seventh
def determine_seventh(seventh, shorthand=False, no_inversion=False, no_polychords=False): """Determine the type of seventh chord; return the results in a list, ordered on inversions. This function expects seventh to be a list of 4 notes. If shorthand is set to True, results will be returned in...
python
def determine_seventh(seventh, shorthand=False, no_inversion=False, no_polychords=False): """Determine the type of seventh chord; return the results in a list, ordered on inversions. This function expects seventh to be a list of 4 notes. If shorthand is set to True, results will be returned in...
[ "def", "determine_seventh", "(", "seventh", ",", "shorthand", "=", "False", ",", "no_inversion", "=", "False", ",", "no_polychords", "=", "False", ")", ":", "if", "len", "(", "seventh", ")", "!=", "4", ":", "# warning raise exception: seventh chord is not a sevent...
Determine the type of seventh chord; return the results in a list, ordered on inversions. This function expects seventh to be a list of 4 notes. If shorthand is set to True, results will be returned in chord shorthand ('Cmin7', etc.); inversions will be dropped in that case. Example: >>> dete...
[ "Determine", "the", "type", "of", "seventh", "chord", ";", "return", "the", "results", "in", "a", "list", "ordered", "on", "inversions", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L927-L1019
bspaans/python-mingus
mingus/core/chords.py
determine_extended_chord5
def determine_extended_chord5(chord, shorthand=False, no_inversions=False, no_polychords=False): """Determine the names of an extended chord.""" if len(chord) != 5: # warning raise exeption: not an extended chord return False def inversion_exhauster(chord, shorthand, tries, result, ...
python
def determine_extended_chord5(chord, shorthand=False, no_inversions=False, no_polychords=False): """Determine the names of an extended chord.""" if len(chord) != 5: # warning raise exeption: not an extended chord return False def inversion_exhauster(chord, shorthand, tries, result, ...
[ "def", "determine_extended_chord5", "(", "chord", ",", "shorthand", "=", "False", ",", "no_inversions", "=", "False", ",", "no_polychords", "=", "False", ")", ":", "if", "len", "(", "chord", ")", "!=", "5", ":", "# warning raise exeption: not an extended chord", ...
Determine the names of an extended chord.
[ "Determine", "the", "names", "of", "an", "extended", "chord", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1021-L1082
bspaans/python-mingus
mingus/core/chords.py
determine_extended_chord6
def determine_extended_chord6(chord, shorthand=False, no_inversions=False, no_polychords=False): """Determine the names of an 6 note chord.""" if len(chord) != 6: # warning raise exeption: not an extended chord return False def inversion_exhauster( chord, shorthand, ...
python
def determine_extended_chord6(chord, shorthand=False, no_inversions=False, no_polychords=False): """Determine the names of an 6 note chord.""" if len(chord) != 6: # warning raise exeption: not an extended chord return False def inversion_exhauster( chord, shorthand, ...
[ "def", "determine_extended_chord6", "(", "chord", ",", "shorthand", "=", "False", ",", "no_inversions", "=", "False", ",", "no_polychords", "=", "False", ")", ":", "if", "len", "(", "chord", ")", "!=", "6", ":", "# warning raise exeption: not an extended chord", ...
Determine the names of an 6 note chord.
[ "Determine", "the", "names", "of", "an", "6", "note", "chord", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1084-L1140
bspaans/python-mingus
mingus/core/chords.py
determine_polychords
def determine_polychords(chord, shorthand=False): """Determine the polychords in chord. This function can handle anything from polychords based on two triads to 6 note extended chords. """ polychords = [] function_list = [determine_triad, determine_seventh, determine_ex...
python
def determine_polychords(chord, shorthand=False): """Determine the polychords in chord. This function can handle anything from polychords based on two triads to 6 note extended chords. """ polychords = [] function_list = [determine_triad, determine_seventh, determine_ex...
[ "def", "determine_polychords", "(", "chord", ",", "shorthand", "=", "False", ")", ":", "polychords", "=", "[", "]", "function_list", "=", "[", "determine_triad", ",", "determine_seventh", ",", "determine_extended_chord5", ",", "determine_extended_chord6", ",", "dete...
Determine the polychords in chord. This function can handle anything from polychords based on two triads to 6 note extended chords.
[ "Determine", "the", "polychords", "in", "chord", ".", "This", "function", "can", "handle", "anything", "from", "polychords", "based", "on", "two", "triads", "to", "6", "note", "extended", "chords", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1197-L1231
bspaans/python-mingus
mingus/extra/lilypond.py
from_Note
def from_Note(note, process_octaves=True, standalone=True): """Get a Note object and return the LilyPond equivalent in a string. If process_octaves is set to False, all data regarding octaves will be ignored. If standalone is True, the result can be used by functions like to_png and will produce a vali...
python
def from_Note(note, process_octaves=True, standalone=True): """Get a Note object and return the LilyPond equivalent in a string. If process_octaves is set to False, all data regarding octaves will be ignored. If standalone is True, the result can be used by functions like to_png and will produce a vali...
[ "def", "from_Note", "(", "note", ",", "process_octaves", "=", "True", ",", "standalone", "=", "True", ")", ":", "# Throw exception", "if", "not", "hasattr", "(", "note", ",", "'name'", ")", ":", "return", "False", "# Lower the case of the name", "result", "=",...
Get a Note object and return the LilyPond equivalent in a string. If process_octaves is set to False, all data regarding octaves will be ignored. If standalone is True, the result can be used by functions like to_png and will produce a valid output. The argument is mostly here to let from_NoteContainer...
[ "Get", "a", "Note", "object", "and", "return", "the", "LilyPond", "equivalent", "in", "a", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L34-L70
bspaans/python-mingus
mingus/extra/lilypond.py
from_NoteContainer
def from_NoteContainer(nc, duration=None, standalone=True): """Get a NoteContainer object and return the LilyPond equivalent in a string. The second argument determining the duration of the NoteContainer is optional. When the standalone argument is True the result of this function can be used direc...
python
def from_NoteContainer(nc, duration=None, standalone=True): """Get a NoteContainer object and return the LilyPond equivalent in a string. The second argument determining the duration of the NoteContainer is optional. When the standalone argument is True the result of this function can be used direc...
[ "def", "from_NoteContainer", "(", "nc", ",", "duration", "=", "None", ",", "standalone", "=", "True", ")", ":", "# Throw exception", "if", "nc", "is", "not", "None", "and", "not", "hasattr", "(", "nc", ",", "'notes'", ")", ":", "return", "False", "# Retu...
Get a NoteContainer object and return the LilyPond equivalent in a string. The second argument determining the duration of the NoteContainer is optional. When the standalone argument is True the result of this function can be used directly by functions like to_png. It is mostly here to be used by f...
[ "Get", "a", "NoteContainer", "object", "and", "return", "the", "LilyPond", "equivalent", "in", "a", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L72-L116
bspaans/python-mingus
mingus/extra/lilypond.py
from_Bar
def from_Bar(bar, showkey=True, showtime=True): """Get a Bar object and return the LilyPond equivalent in a string. The showkey and showtime parameters can be set to determine whether the key and the time should be shown. """ # Throw exception if not hasattr(bar, 'bar'): return False ...
python
def from_Bar(bar, showkey=True, showtime=True): """Get a Bar object and return the LilyPond equivalent in a string. The showkey and showtime parameters can be set to determine whether the key and the time should be shown. """ # Throw exception if not hasattr(bar, 'bar'): return False ...
[ "def", "from_Bar", "(", "bar", ",", "showkey", "=", "True", ",", "showtime", "=", "True", ")", ":", "# Throw exception", "if", "not", "hasattr", "(", "bar", ",", "'bar'", ")", ":", "return", "False", "# Process the key", "if", "showkey", ":", "key_note", ...
Get a Bar object and return the LilyPond equivalent in a string. The showkey and showtime parameters can be set to determine whether the key and the time should be shown.
[ "Get", "a", "Bar", "object", "and", "return", "the", "LilyPond", "equivalent", "in", "a", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L118-L160
bspaans/python-mingus
mingus/extra/lilypond.py
from_Track
def from_Track(track): """Process a Track object and return the LilyPond equivalent in a string.""" # Throw exception if not hasattr(track, 'bars'): return False lastkey = Key('C') lasttime = (4, 4) # Handle the Bars: result = '' for bar in track.bars: if lastkey != bar....
python
def from_Track(track): """Process a Track object and return the LilyPond equivalent in a string.""" # Throw exception if not hasattr(track, 'bars'): return False lastkey = Key('C') lasttime = (4, 4) # Handle the Bars: result = '' for bar in track.bars: if lastkey != bar....
[ "def", "from_Track", "(", "track", ")", ":", "# Throw exception", "if", "not", "hasattr", "(", "track", ",", "'bars'", ")", ":", "return", "False", "lastkey", "=", "Key", "(", "'C'", ")", "lasttime", "=", "(", "4", ",", "4", ")", "# Handle the Bars:", ...
Process a Track object and return the LilyPond equivalent in a string.
[ "Process", "a", "Track", "object", "and", "return", "the", "LilyPond", "equivalent", "in", "a", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L162-L184
bspaans/python-mingus
mingus/extra/lilypond.py
from_Composition
def from_Composition(composition): """Return the LilyPond equivalent of a Composition in a string.""" # warning Throw exception if not hasattr(composition, 'tracks'): return False result = '\\header { title = "%s" composer = "%s" opus = "%s" } '\ % (composition.title, composition.author...
python
def from_Composition(composition): """Return the LilyPond equivalent of a Composition in a string.""" # warning Throw exception if not hasattr(composition, 'tracks'): return False result = '\\header { title = "%s" composer = "%s" opus = "%s" } '\ % (composition.title, composition.author...
[ "def", "from_Composition", "(", "composition", ")", ":", "# warning Throw exception", "if", "not", "hasattr", "(", "composition", ",", "'tracks'", ")", ":", "return", "False", "result", "=", "'\\\\header { title = \"%s\" composer = \"%s\" opus = \"%s\" } '", "%", "(", "...
Return the LilyPond equivalent of a Composition in a string.
[ "Return", "the", "LilyPond", "equivalent", "of", "a", "Composition", "in", "a", "string", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L186-L195
bspaans/python-mingus
mingus/extra/lilypond.py
save_string_and_execute_LilyPond
def save_string_and_execute_LilyPond(ly_string, filename, command): """A helper function for to_png and to_pdf. Should not be used directly.""" ly_string = '\\version "2.10.33"\n' + ly_string if filename[-4:] in ['.pdf', '.png']: filename = filename[:-4] try: f = open(filename + '.ly', '...
python
def save_string_and_execute_LilyPond(ly_string, filename, command): """A helper function for to_png and to_pdf. Should not be used directly.""" ly_string = '\\version "2.10.33"\n' + ly_string if filename[-4:] in ['.pdf', '.png']: filename = filename[:-4] try: f = open(filename + '.ly', '...
[ "def", "save_string_and_execute_LilyPond", "(", "ly_string", ",", "filename", ",", "command", ")", ":", "ly_string", "=", "'\\\\version \"2.10.33\"\\n'", "+", "ly_string", "if", "filename", "[", "-", "4", ":", "]", "in", "[", "'.pdf'", ",", "'.png'", "]", ":",...
A helper function for to_png and to_pdf. Should not be used directly.
[ "A", "helper", "function", "for", "to_png", "and", "to_pdf", ".", "Should", "not", "be", "used", "directly", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L214-L229
bspaans/python-mingus
mingus/core/value.py
determine
def determine(value): """Analyse the value and return a tuple containing the parts it's made of. The tuple respectively consists of the base note value, the number of dots, and the ratio (see tuplet). Examples: >>> determine(8) (8, 0, 1, 1) >>> determine(12) (8, 0, 3, 2) >>> determ...
python
def determine(value): """Analyse the value and return a tuple containing the parts it's made of. The tuple respectively consists of the base note value, the number of dots, and the ratio (see tuplet). Examples: >>> determine(8) (8, 0, 1, 1) >>> determine(12) (8, 0, 3, 2) >>> determ...
[ "def", "determine", "(", "value", ")", ":", "i", "=", "-", "2", "for", "v", "in", "base_values", ":", "if", "value", "==", "v", ":", "return", "(", "value", ",", "0", ",", "1", ",", "1", ")", "if", "value", "<", "v", ":", "break", "i", "+=", ...
Analyse the value and return a tuple containing the parts it's made of. The tuple respectively consists of the base note value, the number of dots, and the ratio (see tuplet). Examples: >>> determine(8) (8, 0, 1, 1) >>> determine(12) (8, 0, 3, 2) >>> determine(14) (8, 0, 7, 4) ...
[ "Analyse", "the", "value", "and", "return", "a", "tuple", "containing", "the", "parts", "it", "s", "made", "of", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/value.py#L230-L274
bspaans/python-mingus
mingus/midi/fluidsynth.py
init
def init(sf2, driver=None, file=None): """Initialize the audio. Return True on success, False on failure. This function needs to be called before you can have any audio. The sf2 argument should be the location of a valid soundfont file. The optional driver argument can be any of 'alsa', 'oss', '...
python
def init(sf2, driver=None, file=None): """Initialize the audio. Return True on success, False on failure. This function needs to be called before you can have any audio. The sf2 argument should be the location of a valid soundfont file. The optional driver argument can be any of 'alsa', 'oss', '...
[ "def", "init", "(", "sf2", ",", "driver", "=", "None", ",", "file", "=", "None", ")", ":", "global", "midi", ",", "initialized", "if", "not", "initialized", ":", "if", "file", "is", "not", "None", ":", "midi", ".", "start_recording", "(", "file", ")"...
Initialize the audio. Return True on success, False on failure. This function needs to be called before you can have any audio. The sf2 argument should be the location of a valid soundfont file. The optional driver argument can be any of 'alsa', 'oss', 'jack', 'portaudio', 'sndmgr', 'coreaudio' ...
[ "Initialize", "the", "audio", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L105-L130
bspaans/python-mingus
mingus/midi/fluidsynth.py
FluidSynthSequencer.start_recording
def start_recording(self, file='mingus_dump.wav'): """Initialize a new wave file for recording.""" w = wave.open(file, 'wb') w.setnchannels(2) w.setsampwidth(2) w.setframerate(44100) self.wav = w
python
def start_recording(self, file='mingus_dump.wav'): """Initialize a new wave file for recording.""" w = wave.open(file, 'wb') w.setnchannels(2) w.setsampwidth(2) w.setframerate(44100) self.wav = w
[ "def", "start_recording", "(", "self", ",", "file", "=", "'mingus_dump.wav'", ")", ":", "w", "=", "wave", ".", "open", "(", "file", ",", "'wb'", ")", "w", ".", "setnchannels", "(", "2", ")", "w", ".", "setsampwidth", "(", "2", ")", "w", ".", "setfr...
Initialize a new wave file for recording.
[ "Initialize", "a", "new", "wave", "file", "for", "recording", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L61-L67
bspaans/python-mingus
mingus/midi/fluidsynth.py
FluidSynthSequencer.load_sound_font
def load_sound_font(self, sf2): """Load a sound font. Return True on success, False on failure. This function should be called before your audio can be played, since the instruments are kept in the sf2 file. """ self.sfid = self.fs.sfload(sf2) return not self.sf...
python
def load_sound_font(self, sf2): """Load a sound font. Return True on success, False on failure. This function should be called before your audio can be played, since the instruments are kept in the sf2 file. """ self.sfid = self.fs.sfload(sf2) return not self.sf...
[ "def", "load_sound_font", "(", "self", ",", "sf2", ")", ":", "self", ".", "sfid", "=", "self", ".", "fs", ".", "sfload", "(", "sf2", ")", "return", "not", "self", ".", "sfid", "==", "-", "1" ]
Load a sound font. Return True on success, False on failure. This function should be called before your audio can be played, since the instruments are kept in the sf2 file.
[ "Load", "a", "sound", "font", "." ]
train
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L69-L78
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.create
def create(self, group_type, config_file, group_name=None, region=None, profile_name=None): """ Create a Greengrass group in the given region. :param group_type: the type of group to create. Must match a `key` in the `group_types` dict :param config_file: conf...
python
def create(self, group_type, config_file, group_name=None, region=None, profile_name=None): """ Create a Greengrass group in the given region. :param group_type: the type of group to create. Must match a `key` in the `group_types` dict :param config_file: conf...
[ "def", "create", "(", "self", ",", "group_type", ",", "config_file", ",", "group_name", "=", "None", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "logging", ".", "info", "(", "\"[begin] create command using group_types:{0}\"", ".", "...
Create a Greengrass group in the given region. :param group_type: the type of group to create. Must match a `key` in the `group_types` dict :param config_file: config file of the group to create :param group_name: the name of the group. If no name is given, then group_ty...
[ "Create", "a", "Greengrass", "group", "in", "the", "given", "region", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L73-L180
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands._create_subscription_definition
def _create_subscription_definition(gg_client, group_type, config): """ Configure routing subscriptions for a Greengrass group. group_type: either default or an overridden group type config: GroupConfigFile object used for routing subscriptions """ logging.info('[begin] ...
python
def _create_subscription_definition(gg_client, group_type, config): """ Configure routing subscriptions for a Greengrass group. group_type: either default or an overridden group type config: GroupConfigFile object used for routing subscriptions """ logging.info('[begin] ...
[ "def", "_create_subscription_definition", "(", "gg_client", ",", "group_type", ",", "config", ")", ":", "logging", ".", "info", "(", "'[begin] Configuring routing subscriptions'", ")", "sub_info", "=", "gg_client", ".", "create_subscription_definition", "(", "Name", "="...
Configure routing subscriptions for a Greengrass group. group_type: either default or an overridden group type config: GroupConfigFile object used for routing subscriptions
[ "Configure", "routing", "subscriptions", "for", "a", "Greengrass", "group", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L321-L352
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.clean_core
def clean_core(self, config_file, region=None, profile_name=None): """ Clean all Core related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the core to clean :param region: the region in which the core s...
python
def clean_core(self, config_file, region=None, profile_name=None): """ Clean all Core related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the core to clean :param region: the region in which the core s...
[ "def", "clean_core", "(", "self", ",", "config_file", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "config", "=", "GroupConfigFile", "(", "config_file", "=", "config_file", ")", "if", "region", "is", "None", ":", "region", "=", ...
Clean all Core related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the core to clean :param region: the region in which the core should be cleaned. [default: us-west-2] :param profile_name: the nam...
[ "Clean", "all", "Core", "related", "provisioned", "artifacts", "from", "both", "the", "local", "file", "and", "the", "AWS", "Greengrass", "service", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L490-L518
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.clean_devices
def clean_devices(self, config_file, region=None, profile_name=None): """ Clean all device related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the devices to clean :param region: the region in which th...
python
def clean_devices(self, config_file, region=None, profile_name=None): """ Clean all device related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the devices to clean :param region: the region in which th...
[ "def", "clean_devices", "(", "self", ",", "config_file", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "config", "=", "GroupConfigFile", "(", "config_file", "=", "config_file", ")", "if", "region", "is", "None", ":", "region", "="...
Clean all device related provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the devices to clean :param region: the region in which the devices should be cleaned. [default: us-west-2] :param profile_name:...
[ "Clean", "all", "device", "related", "provisioned", "artifacts", "from", "both", "the", "local", "file", "and", "the", "AWS", "Greengrass", "service", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L520-L549
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.clean_file
def clean_file(config_file): """ Clean all provisioned artifacts from the local config file. :param config_file: config file of the group to clean """ logging.info('[begin] Cleaning config file') config = GroupConfigFile(config_file=config_file) if config.is_fre...
python
def clean_file(config_file): """ Clean all provisioned artifacts from the local config file. :param config_file: config file of the group to clean """ logging.info('[begin] Cleaning config file') config = GroupConfigFile(config_file=config_file) if config.is_fre...
[ "def", "clean_file", "(", "config_file", ")", ":", "logging", ".", "info", "(", "'[begin] Cleaning config file'", ")", "config", "=", "GroupConfigFile", "(", "config_file", "=", "config_file", ")", "if", "config", ".", "is_fresh", "(", ")", "is", "True", ":", ...
Clean all provisioned artifacts from the local config file. :param config_file: config file of the group to clean
[ "Clean", "all", "provisioned", "artifacts", "from", "the", "local", "config", "file", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L552-L564
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.clean_all
def clean_all(self, config_file, region=None, profile_name=None): """ Clean all provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the group to clean :param region: the region in which the group should be cle...
python
def clean_all(self, config_file, region=None, profile_name=None): """ Clean all provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the group to clean :param region: the region in which the group should be cle...
[ "def", "clean_all", "(", "self", ",", "config_file", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "logging", ".", "info", "(", "'[begin] Cleaning all provisioned artifacts'", ")", "config", "=", "GroupConfigFile", "(", "config_file", "...
Clean all provisioned artifacts from both the local file and the AWS Greengrass service. :param config_file: config file containing the group to clean :param region: the region in which the group should be cleaned. [default: us-west-2] :param profile_name: the name of the `a...
[ "Clean", "all", "provisioned", "artifacts", "from", "both", "the", "local", "file", "and", "the", "AWS", "Greengrass", "service", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L566-L591
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.deploy
def deploy(self, config_file, region=None, profile_name=None): """ Deploy the configuration and Lambda functions of a Greengrass group to the Greengrass core contained in the group. :param config_file: config file of the group to deploy :param region: the region from which to de...
python
def deploy(self, config_file, region=None, profile_name=None): """ Deploy the configuration and Lambda functions of a Greengrass group to the Greengrass core contained in the group. :param config_file: config file of the group to deploy :param region: the region from which to de...
[ "def", "deploy", "(", "self", ",", "config_file", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "config", "=", "GroupConfigFile", "(", "config_file", "=", "config_file", ")", "if", "config", ".", "is_fresh", "(", ")", ":", "rais...
Deploy the configuration and Lambda functions of a Greengrass group to the Greengrass core contained in the group. :param config_file: config file of the group to deploy :param region: the region from which to deploy the group. :param profile_name: the name of the `awscli` profile to us...
[ "Deploy", "the", "configuration", "and", "Lambda", "functions", "of", "a", "Greengrass", "group", "to", "the", "Greengrass", "core", "contained", "in", "the", "group", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L593-L619
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.create_core
def create_core(self, thing_name, config_file, region=None, cert_dir=None, account_id=None, policy_name='ggc-default-policy', profile_name=None): """ Using the `thing_name` value, creates a Thing in AWS IoT, attaches and downloads new keys & certs to the c...
python
def create_core(self, thing_name, config_file, region=None, cert_dir=None, account_id=None, policy_name='ggc-default-policy', profile_name=None): """ Using the `thing_name` value, creates a Thing in AWS IoT, attaches and downloads new keys & certs to the c...
[ "def", "create_core", "(", "self", ",", "thing_name", ",", "config_file", ",", "region", "=", "None", ",", "cert_dir", "=", "None", ",", "account_id", "=", "None", ",", "policy_name", "=", "'ggc-default-policy'", ",", "profile_name", "=", "None", ")", ":", ...
Using the `thing_name` value, creates a Thing in AWS IoT, attaches and downloads new keys & certs to the certificate directory, then records the created information in the local config file for inclusion in the Greengrass Group as a Greengrass Core. :param thing_name: the name of the th...
[ "Using", "the", "thing_name", "value", "creates", "a", "Thing", "in", "AWS", "IoT", "attaches", "and", "downloads", "new", "keys", "&", "certs", "to", "the", "certificate", "directory", "then", "records", "the", "created", "information", "in", "the", "local", ...
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L679-L733
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.create_devices
def create_devices(self, thing_names, config_file, region=None, cert_dir=None, append=False, account_id=None, policy_name='ggd-discovery-policy', profile_name=None): """ Using the `thing_names` values, creates Things in AWS IoT, attaches and download...
python
def create_devices(self, thing_names, config_file, region=None, cert_dir=None, append=False, account_id=None, policy_name='ggd-discovery-policy', profile_name=None): """ Using the `thing_names` values, creates Things in AWS IoT, attaches and download...
[ "def", "create_devices", "(", "self", ",", "thing_names", ",", "config_file", ",", "region", "=", "None", ",", "cert_dir", "=", "None", ",", "append", "=", "False", ",", "account_id", "=", "None", ",", "policy_name", "=", "'ggd-discovery-policy'", ",", "prof...
Using the `thing_names` values, creates Things in AWS IoT, attaches and downloads new keys & certs to the certificate directory, then records the created information in the local config file for inclusion in the Greengrass Group as Greengrass Devices. :param thing_names: the thing name ...
[ "Using", "the", "thing_names", "values", "creates", "Things", "in", "AWS", "IoT", "attaches", "and", "downloads", "new", "keys", "&", "certs", "to", "the", "certificate", "directory", "then", "records", "the", "created", "information", "in", "the", "local", "c...
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L773-L837
awslabs/aws-greengrass-group-setup
gg_group_setup/cmd.py
GroupCommands.associate_devices
def associate_devices(self, thing_names, config_file, region=None, profile_name=None): # TODO remove this function when Group discovery is enriched """ Using the `thing_names` values, associate existing Things in AWS IoT with the config of another Greengrass Gro...
python
def associate_devices(self, thing_names, config_file, region=None, profile_name=None): # TODO remove this function when Group discovery is enriched """ Using the `thing_names` values, associate existing Things in AWS IoT with the config of another Greengrass Gro...
[ "def", "associate_devices", "(", "self", ",", "thing_names", ",", "config_file", ",", "region", "=", "None", ",", "profile_name", "=", "None", ")", ":", "# TODO remove this function when Group discovery is enriched", "logging", ".", "info", "(", "\"associate_devices thi...
Using the `thing_names` values, associate existing Things in AWS IoT with the config of another Greengrass Group for use as Greengrass Devices. :param thing_names: the thing name or list of thing names to associate as Greengrass Devices :param config_file: config file used t...
[ "Using", "the", "thing_names", "values", "associate", "existing", "Things", "in", "AWS", "IoT", "with", "the", "config", "of", "another", "Greengrass", "Group", "for", "use", "as", "Greengrass", "Devices", "." ]
train
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L839-L878
yuanxu-li/html-table-extractor
html_table_extractor/extractor.py
Extractor._check_validity
def _check_validity(self, i, j, height, width): """ check if a rectangle (i, j, height, width) can be put into self.output """ return all(self._check_cell_validity(ii, jj) for ii in range(i, i+height) for jj in range(j, j+width))
python
def _check_validity(self, i, j, height, width): """ check if a rectangle (i, j, height, width) can be put into self.output """ return all(self._check_cell_validity(ii, jj) for ii in range(i, i+height) for jj in range(j, j+width))
[ "def", "_check_validity", "(", "self", ",", "i", ",", "j", ",", "height", ",", "width", ")", ":", "return", "all", "(", "self", ".", "_check_cell_validity", "(", "ii", ",", "jj", ")", "for", "ii", "in", "range", "(", "i", ",", "i", "+", "height", ...
check if a rectangle (i, j, height, width) can be put into self.output
[ "check", "if", "a", "rectangle", "(", "i", "j", "height", "width", ")", "can", "be", "put", "into", "self", ".", "output" ]
train
https://github.com/yuanxu-li/html-table-extractor/blob/e3e0f51121e112c304a5c251180d81906131b276/html_table_extractor/extractor.py#L84-L88
yuanxu-li/html-table-extractor
html_table_extractor/extractor.py
Extractor._check_cell_validity
def _check_cell_validity(self, i, j): """ check if a cell (i, j) can be put into self._output """ if i >= len(self._output): return True if j >= len(self._output[i]): return True if self._output[i][j] is None: return True return...
python
def _check_cell_validity(self, i, j): """ check if a cell (i, j) can be put into self._output """ if i >= len(self._output): return True if j >= len(self._output[i]): return True if self._output[i][j] is None: return True return...
[ "def", "_check_cell_validity", "(", "self", ",", "i", ",", "j", ")", ":", "if", "i", ">=", "len", "(", "self", ".", "_output", ")", ":", "return", "True", "if", "j", ">=", "len", "(", "self", ".", "_output", "[", "i", "]", ")", ":", "return", "...
check if a cell (i, j) can be put into self._output
[ "check", "if", "a", "cell", "(", "i", "j", ")", "can", "be", "put", "into", "self", ".", "_output" ]
train
https://github.com/yuanxu-li/html-table-extractor/blob/e3e0f51121e112c304a5c251180d81906131b276/html_table_extractor/extractor.py#L90-L100
coinkite/connectrum
connectrum/protocol.py
StratumProtocol.send_data
def send_data(self, message): ''' Given an object, encode as JSON and transmit to the server. ''' #logger.debug("TX:\n%s", json.dumps(message, indent=2)) data = json.dumps(message).encode('utf-8') + b'\n' self.transport.write(data)
python
def send_data(self, message): ''' Given an object, encode as JSON and transmit to the server. ''' #logger.debug("TX:\n%s", json.dumps(message, indent=2)) data = json.dumps(message).encode('utf-8') + b'\n' self.transport.write(data)
[ "def", "send_data", "(", "self", ",", "message", ")", ":", "#logger.debug(\"TX:\\n%s\", json.dumps(message, indent=2))", "data", "=", "json", ".", "dumps", "(", "message", ")", ".", "encode", "(", "'utf-8'", ")", "+", "b'\\n'", "self", ".", "transport", ".", "...
Given an object, encode as JSON and transmit to the server.
[ "Given", "an", "object", "encode", "as", "JSON", "and", "transmit", "to", "the", "server", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/protocol.py#L57-L63
coinkite/connectrum
connectrum/findall.py
IrcListener.got_who_reply
async def got_who_reply(self, nick=None, real_name=None, **kws): ''' Server replied to one of our WHO requests, with details. ''' #logger.debug('who reply: %r' % kws) nick = nick[2:] if nick[0:2] == 'E_' else nick host, ports = real_name.split(' ', 1) self.s...
python
async def got_who_reply(self, nick=None, real_name=None, **kws): ''' Server replied to one of our WHO requests, with details. ''' #logger.debug('who reply: %r' % kws) nick = nick[2:] if nick[0:2] == 'E_' else nick host, ports = real_name.split(' ', 1) self.s...
[ "async", "def", "got_who_reply", "(", "self", ",", "nick", "=", "None", ",", "real_name", "=", "None", ",", "*", "*", "kws", ")", ":", "#logger.debug('who reply: %r' % kws)", "nick", "=", "nick", "[", "2", ":", "]", "if", "nick", "[", "0", ":", "2", ...
Server replied to one of our WHO requests, with details.
[ "Server", "replied", "to", "one", "of", "our", "WHO", "requests", "with", "details", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/findall.py#L59-L74
coinkite/connectrum
connectrum/client.py
StratumClient.connect
async def connect(self, server_info, proto_code=None, *, use_tor=False, disable_cert_verify=False, proxy=None, short_term=False): ''' Start connection process. Destination must be specified in a ServerInfo() record (first arg). ...
python
async def connect(self, server_info, proto_code=None, *, use_tor=False, disable_cert_verify=False, proxy=None, short_term=False): ''' Start connection process. Destination must be specified in a ServerInfo() record (first arg). ...
[ "async", "def", "connect", "(", "self", ",", "server_info", ",", "proto_code", "=", "None", ",", "*", ",", "use_tor", "=", "False", ",", "disable_cert_verify", "=", "False", ",", "proxy", "=", "None", ",", "short_term", "=", "False", ")", ":", "self", ...
Start connection process. Destination must be specified in a ServerInfo() record (first arg).
[ "Start", "connection", "process", ".", "Destination", "must", "be", "specified", "in", "a", "ServerInfo", "()", "record", "(", "first", "arg", ")", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L68-L159
coinkite/connectrum
connectrum/client.py
StratumClient._keepalive
async def _keepalive(self): ''' Keep our connect to server alive forever, with some pointless traffic. ''' while self.protocol: vers = await self.RPC('server.version') logger.debug("Server version: " + repr(vers)) # Five minutes isn't...
python
async def _keepalive(self): ''' Keep our connect to server alive forever, with some pointless traffic. ''' while self.protocol: vers = await self.RPC('server.version') logger.debug("Server version: " + repr(vers)) # Five minutes isn't...
[ "async", "def", "_keepalive", "(", "self", ")", ":", "while", "self", ".", "protocol", ":", "vers", "=", "await", "self", ".", "RPC", "(", "'server.version'", ")", "logger", ".", "debug", "(", "\"Server version: \"", "+", "repr", "(", "vers", ")", ")", ...
Keep our connect to server alive forever, with some pointless traffic.
[ "Keep", "our", "connect", "to", "server", "alive", "forever", "with", "some", "pointless", "traffic", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L161-L173
coinkite/connectrum
connectrum/client.py
StratumClient._send_request
def _send_request(self, method, params=[], is_subscribe = False): ''' Send a new request to the server. Serialized the JSON and tracks id numbers and optional callbacks. ''' # pick a new ID self.next_id += 1 req_id = self.next_id # serialize as JS...
python
def _send_request(self, method, params=[], is_subscribe = False): ''' Send a new request to the server. Serialized the JSON and tracks id numbers and optional callbacks. ''' # pick a new ID self.next_id += 1 req_id = self.next_id # serialize as JS...
[ "def", "_send_request", "(", "self", ",", "method", ",", "params", "=", "[", "]", ",", "is_subscribe", "=", "False", ")", ":", "# pick a new ID", "self", ".", "next_id", "+=", "1", "req_id", "=", "self", ".", "next_id", "# serialize as JSON", "msg", "=", ...
Send a new request to the server. Serialized the JSON and tracks id numbers and optional callbacks.
[ "Send", "a", "new", "request", "to", "the", "server", ".", "Serialized", "the", "JSON", "and", "tracks", "id", "numbers", "and", "optional", "callbacks", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L176-L210
coinkite/connectrum
connectrum/client.py
StratumClient._got_response
def _got_response(self, msg): ''' Decode and dispatch responses from the server. Has already been unframed and deserialized into an object. ''' #logger.debug("MSG: %r" % msg) resp_id = msg.get('id', None) if resp_id is None: # subscription ...
python
def _got_response(self, msg): ''' Decode and dispatch responses from the server. Has already been unframed and deserialized into an object. ''' #logger.debug("MSG: %r" % msg) resp_id = msg.get('id', None) if resp_id is None: # subscription ...
[ "def", "_got_response", "(", "self", ",", "msg", ")", ":", "#logger.debug(\"MSG: %r\" % msg)", "resp_id", "=", "msg", ".", "get", "(", "'id'", ",", "None", ")", "if", "resp_id", "is", "None", ":", "# subscription traffic comes with method set, but no req id.", "meth...
Decode and dispatch responses from the server. Has already been unframed and deserialized into an object.
[ "Decode", "and", "dispatch", "responses", "from", "the", "server", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L212-L260
coinkite/connectrum
connectrum/client.py
StratumClient.subscribe
def subscribe(self, method, *params): ''' Perform a remote command which will stream events/data to us. Expects a method name, which look like: server.peers.subscribe .. and sometimes take arguments, all of which are positional. Returns a tup...
python
def subscribe(self, method, *params): ''' Perform a remote command which will stream events/data to us. Expects a method name, which look like: server.peers.subscribe .. and sometimes take arguments, all of which are positional. Returns a tup...
[ "def", "subscribe", "(", "self", ",", "method", ",", "*", "params", ")", ":", "assert", "'.'", "in", "method", "assert", "method", ".", "endswith", "(", "'subscribe'", ")", "return", "self", ".", "_send_request", "(", "method", ",", "params", ",", "is_su...
Perform a remote command which will stream events/data to us. Expects a method name, which look like: server.peers.subscribe .. and sometimes take arguments, all of which are positional. Returns a tuple: (Future, asyncio.Queue). The future will have ...
[ "Perform", "a", "remote", "command", "which", "will", "stream", "events", "/", "data", "to", "us", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L279-L294
coinkite/connectrum
connectrum/svr_info.py
ServerInfo.get_port
def get_port(self, for_protocol): ''' Return (hostname, port number, ssl) pair for the protocol. Assuming only one port per host. ''' assert len(for_protocol) == 1, "expect single letter code" use_ssl = for_protocol in ('s', 'g') if 'port' in self: retur...
python
def get_port(self, for_protocol): ''' Return (hostname, port number, ssl) pair for the protocol. Assuming only one port per host. ''' assert len(for_protocol) == 1, "expect single letter code" use_ssl = for_protocol in ('s', 'g') if 'port' in self: retur...
[ "def", "get_port", "(", "self", ",", "for_protocol", ")", ":", "assert", "len", "(", "for_protocol", ")", "==", "1", ",", "\"expect single letter code\"", "use_ssl", "=", "for_protocol", "in", "(", "'s'", ",", "'g'", ")", "if", "'port'", "in", "self", ":",...
Return (hostname, port number, ssl) pair for the protocol. Assuming only one port per host.
[ "Return", "(", "hostname", "port", "number", "ssl", ")", "pair", "for", "the", "protocol", ".", "Assuming", "only", "one", "port", "per", "host", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L115-L136
coinkite/connectrum
connectrum/svr_info.py
KnownServers.from_json
def from_json(self, fname): ''' Read contents of a CSV containing a list of servers. ''' with open(fname, 'rt') as fp: for row in json.load(fp): nn = ServerInfo.from_dict(row) self[str(nn)] = nn
python
def from_json(self, fname): ''' Read contents of a CSV containing a list of servers. ''' with open(fname, 'rt') as fp: for row in json.load(fp): nn = ServerInfo.from_dict(row) self[str(nn)] = nn
[ "def", "from_json", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "'rt'", ")", "as", "fp", ":", "for", "row", "in", "json", ".", "load", "(", "fp", ")", ":", "nn", "=", "ServerInfo", ".", "from_dict", "(", "row", ")", ...
Read contents of a CSV containing a list of servers.
[ "Read", "contents", "of", "a", "CSV", "containing", "a", "list", "of", "servers", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L171-L178
coinkite/connectrum
connectrum/svr_info.py
KnownServers.from_irc
def from_irc(self, irc_nickname=None, irc_password=None): ''' Connect to the IRC channel and find all servers presently connected. Slow; takes 30+ seconds but authoritative and current. OBSOLETE. ''' if have_bottom: from .findall import IrcListen...
python
def from_irc(self, irc_nickname=None, irc_password=None): ''' Connect to the IRC channel and find all servers presently connected. Slow; takes 30+ seconds but authoritative and current. OBSOLETE. ''' if have_bottom: from .findall import IrcListen...
[ "def", "from_irc", "(", "self", ",", "irc_nickname", "=", "None", ",", "irc_password", "=", "None", ")", ":", "if", "have_bottom", ":", "from", ".", "findall", "import", "IrcListener", "# connect and fetch current set of servers who are", "# on #electrum channel at free...
Connect to the IRC channel and find all servers presently connected. Slow; takes 30+ seconds but authoritative and current. OBSOLETE.
[ "Connect", "to", "the", "IRC", "channel", "and", "find", "all", "servers", "presently", "connected", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L180-L201
coinkite/connectrum
connectrum/svr_info.py
KnownServers.add_single
def add_single(self, hostname, ports, nickname=None, **kws): ''' Explicitly add a single entry. Hostname is a FQDN and ports is either a single int (assumed to be TCP port) or Electrum protocol/port number specification with spaces in between. ''' nickname = n...
python
def add_single(self, hostname, ports, nickname=None, **kws): ''' Explicitly add a single entry. Hostname is a FQDN and ports is either a single int (assumed to be TCP port) or Electrum protocol/port number specification with spaces in between. ''' nickname = n...
[ "def", "add_single", "(", "self", ",", "hostname", ",", "ports", ",", "nickname", "=", "None", ",", "*", "*", "kws", ")", ":", "nickname", "=", "nickname", "or", "hostname", "self", "[", "hostname", ".", "lower", "(", ")", "]", "=", "ServerInfo", "("...
Explicitly add a single entry. Hostname is a FQDN and ports is either a single int (assumed to be TCP port) or Electrum protocol/port number specification with spaces in between.
[ "Explicitly", "add", "a", "single", "entry", ".", "Hostname", "is", "a", "FQDN", "and", "ports", "is", "either", "a", "single", "int", "(", "assumed", "to", "be", "TCP", "port", ")", "or", "Electrum", "protocol", "/", "port", "number", "specification", "...
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L203-L211
coinkite/connectrum
connectrum/svr_info.py
KnownServers.save_json
def save_json(self, fname='servers.json'): ''' Write out to a CSV file. ''' rows = sorted(self.keys()) with open(fname, 'wt') as fp: json.dump([self[k] for k in rows], fp, indent=1)
python
def save_json(self, fname='servers.json'): ''' Write out to a CSV file. ''' rows = sorted(self.keys()) with open(fname, 'wt') as fp: json.dump([self[k] for k in rows], fp, indent=1)
[ "def", "save_json", "(", "self", ",", "fname", "=", "'servers.json'", ")", ":", "rows", "=", "sorted", "(", "self", ".", "keys", "(", ")", ")", "with", "open", "(", "fname", ",", "'wt'", ")", "as", "fp", ":", "json", ".", "dump", "(", "[", "self"...
Write out to a CSV file.
[ "Write", "out", "to", "a", "CSV", "file", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L238-L244
coinkite/connectrum
connectrum/svr_info.py
KnownServers.select
def select(self, **kws): ''' Find all servers with indicated protocol support. Shuffled. Filter by TOR support, and pruning level. ''' lst = [i for i in self.values() if i.select(**kws)] random.shuffle(lst) return lst
python
def select(self, **kws): ''' Find all servers with indicated protocol support. Shuffled. Filter by TOR support, and pruning level. ''' lst = [i for i in self.values() if i.select(**kws)] random.shuffle(lst) return lst
[ "def", "select", "(", "self", ",", "*", "*", "kws", ")", ":", "lst", "=", "[", "i", "for", "i", "in", "self", ".", "values", "(", ")", "if", "i", ".", "select", "(", "*", "*", "kws", ")", "]", "random", ".", "shuffle", "(", "lst", ")", "ret...
Find all servers with indicated protocol support. Shuffled. Filter by TOR support, and pruning level.
[ "Find", "all", "servers", "with", "indicated", "protocol", "support", ".", "Shuffled", "." ]
train
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L249-L259
mitodl/pylti
pylti/common.py
_post_patched_request
def _post_patched_request(consumers, lti_key, body, url, method, content_type): """ Authorization header needs to be capitalized for some LTI clients this function ensures that header is capitalized :param body: body of the call :param client: OAuth Client :param url: ...
python
def _post_patched_request(consumers, lti_key, body, url, method, content_type): """ Authorization header needs to be capitalized for some LTI clients this function ensures that header is capitalized :param body: body of the call :param client: OAuth Client :param url: ...
[ "def", "_post_patched_request", "(", "consumers", ",", "lti_key", ",", "body", ",", "url", ",", "method", ",", "content_type", ")", ":", "# pylint: disable=too-many-locals, too-many-arguments", "oauth_server", "=", "LTIOAuthServer", "(", "consumers", ")", "oauth_server"...
Authorization header needs to be capitalized for some LTI clients this function ensures that header is capitalized :param body: body of the call :param client: OAuth Client :param url: outcome url :return: response
[ "Authorization", "header", "needs", "to", "be", "capitalized", "for", "some", "LTI", "clients", "this", "function", "ensures", "that", "header", "is", "capitalized" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L145-L203
mitodl/pylti
pylti/common.py
post_message
def post_message(consumers, lti_key, url, body): """ Posts a signed message to LTI consumer :param consumers: consumers from config :param lti_key: key to find appropriate consumer :param url: post url :param body: xml body :return: success """ content_type = 'application/xml' ...
python
def post_message(consumers, lti_key, url, body): """ Posts a signed message to LTI consumer :param consumers: consumers from config :param lti_key: key to find appropriate consumer :param url: post url :param body: xml body :return: success """ content_type = 'application/xml' ...
[ "def", "post_message", "(", "consumers", ",", "lti_key", ",", "url", ",", "body", ")", ":", "content_type", "=", "'application/xml'", "method", "=", "'POST'", "(", "_", ",", "content", ")", "=", "_post_patched_request", "(", "consumers", ",", "lti_key", ",",...
Posts a signed message to LTI consumer :param consumers: consumers from config :param lti_key: key to find appropriate consumer :param url: post url :param body: xml body :return: success
[ "Posts", "a", "signed", "message", "to", "LTI", "consumer" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L206-L229
mitodl/pylti
pylti/common.py
post_message2
def post_message2(consumers, lti_key, url, body, method='POST', content_type='application/xml'): """ Posts a signed message to LTI consumer using LTI 2.0 format :param: consumers: consumers from config :param: lti_key: key to find appropriate consumer :param: url: post url ...
python
def post_message2(consumers, lti_key, url, body, method='POST', content_type='application/xml'): """ Posts a signed message to LTI consumer using LTI 2.0 format :param: consumers: consumers from config :param: lti_key: key to find appropriate consumer :param: url: post url ...
[ "def", "post_message2", "(", "consumers", ",", "lti_key", ",", "url", ",", "body", ",", "method", "=", "'POST'", ",", "content_type", "=", "'application/xml'", ")", ":", "# pylint: disable=too-many-arguments", "(", "response", ",", "_", ")", "=", "_post_patched_...
Posts a signed message to LTI consumer using LTI 2.0 format :param: consumers: consumers from config :param: lti_key: key to find appropriate consumer :param: url: post url :param: body: xml body :return: success
[ "Posts", "a", "signed", "message", "to", "LTI", "consumer", "using", "LTI", "2", ".", "0", "format" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L232-L256
mitodl/pylti
pylti/common.py
verify_request_common
def verify_request_common(consumers, url, method, headers, params): """ Verifies that request is valid :param consumers: consumers from config file :param url: request url :param method: request method :param headers: request headers :param params: request params :return: is request val...
python
def verify_request_common(consumers, url, method, headers, params): """ Verifies that request is valid :param consumers: consumers from config file :param url: request url :param method: request method :param headers: request headers :param params: request params :return: is request val...
[ "def", "verify_request_common", "(", "consumers", ",", "url", ",", "method", ",", "headers", ",", "params", ")", ":", "log", ".", "debug", "(", "\"consumers %s\"", ",", "consumers", ")", "log", ".", "debug", "(", "\"url %s\"", ",", "url", ")", "log", "."...
Verifies that request is valid :param consumers: consumers from config file :param url: request url :param method: request method :param headers: request headers :param params: request params :return: is request valid
[ "Verifies", "that", "request", "is", "valid" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L259-L308
mitodl/pylti
pylti/common.py
generate_request_xml
def generate_request_xml(message_identifier_id, operation, lis_result_sourcedid, score): # pylint: disable=too-many-locals """ Generates LTI 1.1 XML for posting result to LTI consumer. :param message_identifier_id: :param operation: :param lis_result_sourcedid: :par...
python
def generate_request_xml(message_identifier_id, operation, lis_result_sourcedid, score): # pylint: disable=too-many-locals """ Generates LTI 1.1 XML for posting result to LTI consumer. :param message_identifier_id: :param operation: :param lis_result_sourcedid: :par...
[ "def", "generate_request_xml", "(", "message_identifier_id", ",", "operation", ",", "lis_result_sourcedid", ",", "score", ")", ":", "# pylint: disable=too-many-locals", "root", "=", "etree", ".", "Element", "(", "u'imsx_POXEnvelopeRequest'", ",", "xmlns", "=", "u'http:/...
Generates LTI 1.1 XML for posting result to LTI consumer. :param message_identifier_id: :param operation: :param lis_result_sourcedid: :param score: :return: XML string
[ "Generates", "LTI", "1", ".", "1", "XML", "for", "posting", "result", "to", "LTI", "consumer", "." ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L311-L353
mitodl/pylti
pylti/common.py
LTIOAuthServer.lookup_consumer
def lookup_consumer(self, key): """ Search through keys """ if not self.consumers: log.critical(("No consumers defined in settings." "Have you created a configuration file?")) return None consumer = self.consumers.get(key) ...
python
def lookup_consumer(self, key): """ Search through keys """ if not self.consumers: log.critical(("No consumers defined in settings." "Have you created a configuration file?")) return None consumer = self.consumers.get(key) ...
[ "def", "lookup_consumer", "(", "self", ",", "key", ")", ":", "if", "not", "self", ".", "consumers", ":", "log", ".", "critical", "(", "(", "\"No consumers defined in settings.\"", "\"Have you created a configuration file?\"", ")", ")", "return", "None", "consumer", ...
Search through keys
[ "Search", "through", "keys" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L75-L94
mitodl/pylti
pylti/common.py
LTIOAuthServer.lookup_cert
def lookup_cert(self, key): """ Search through keys """ if not self.consumers: log.critical(("No consumers defined in settings." "Have you created a configuration file?")) return None consumer = self.consumers.get(key) if...
python
def lookup_cert(self, key): """ Search through keys """ if not self.consumers: log.critical(("No consumers defined in settings." "Have you created a configuration file?")) return None consumer = self.consumers.get(key) if...
[ "def", "lookup_cert", "(", "self", ",", "key", ")", ":", "if", "not", "self", ".", "consumers", ":", "log", ".", "critical", "(", "(", "\"No consumers defined in settings.\"", "\"Have you created a configuration file?\"", ")", ")", "return", "None", "consumer", "=...
Search through keys
[ "Search", "through", "keys" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L96-L110
mitodl/pylti
pylti/common.py
SignatureMethod_HMAC_SHA1_Unicode.check
def check(self, request, consumer, token, signature): """ Returns whether the given signature is the correct signature for the given consumer and token signing the given request. """ built = self.sign(request, consumer, token) if isinstance(signature, STRING_TYPES): ...
python
def check(self, request, consumer, token, signature): """ Returns whether the given signature is the correct signature for the given consumer and token signing the given request. """ built = self.sign(request, consumer, token) if isinstance(signature, STRING_TYPES): ...
[ "def", "check", "(", "self", ",", "request", ",", "consumer", ",", "token", ",", "signature", ")", ":", "built", "=", "self", ".", "sign", "(", "request", ",", "consumer", ",", "token", ")", "if", "isinstance", "(", "signature", ",", "STRING_TYPES", ")...
Returns whether the given signature is the correct signature for the given consumer and token signing the given request.
[ "Returns", "whether", "the", "given", "signature", "is", "the", "correct", "signature", "for", "the", "given", "consumer", "and", "token", "signing", "the", "given", "request", "." ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L364-L372
mitodl/pylti
pylti/common.py
LTIBase.name
def name(self): # pylint: disable=no-self-use """ Name returns user's name or user's email or user_id :return: best guess of name to use to greet user """ if 'lis_person_sourcedid' in self.session: return self.session['lis_person_sourcedid'] elif 'lis_person_...
python
def name(self): # pylint: disable=no-self-use """ Name returns user's name or user's email or user_id :return: best guess of name to use to greet user """ if 'lis_person_sourcedid' in self.session: return self.session['lis_person_sourcedid'] elif 'lis_person_...
[ "def", "name", "(", "self", ")", ":", "# pylint: disable=no-self-use", "if", "'lis_person_sourcedid'", "in", "self", ".", "session", ":", "return", "self", ".", "session", "[", "'lis_person_sourcedid'", "]", "elif", "'lis_person_contact_email_primary'", "in", "self", ...
Name returns user's name or user's email or user_id :return: best guess of name to use to greet user
[ "Name", "returns", "user", "s", "name", "or", "user", "s", "email", "or", "user_id", ":", "return", ":", "best", "guess", "of", "name", "to", "use", "to", "greet", "user" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L473-L485
mitodl/pylti
pylti/common.py
LTIBase.verify
def verify(self): """ Verify if LTI request is valid, validation depends on @lti wrapper arguments :raises: LTIException """ log.debug('verify request=%s', self.lti_kwargs.get('request')) if self.lti_kwargs.get('request') == 'session': self._verify_se...
python
def verify(self): """ Verify if LTI request is valid, validation depends on @lti wrapper arguments :raises: LTIException """ log.debug('verify request=%s', self.lti_kwargs.get('request')) if self.lti_kwargs.get('request') == 'session': self._verify_se...
[ "def", "verify", "(", "self", ")", ":", "log", ".", "debug", "(", "'verify request=%s'", ",", "self", ".", "lti_kwargs", ".", "get", "(", "'request'", ")", ")", "if", "self", ".", "lti_kwargs", ".", "get", "(", "'request'", ")", "==", "'session'", ":",...
Verify if LTI request is valid, validation depends on @lti wrapper arguments :raises: LTIException
[ "Verify", "if", "LTI", "request", "is", "valid", "validation", "depends", "on", "@lti", "wrapper", "arguments" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L487-L503
mitodl/pylti
pylti/common.py
LTIBase.is_role
def is_role(self, role): """ Verify if user is in role :param: role: role to verify against :return: if user is in role :exception: LTIException if role is unknown """ log.debug("is_role %s", role) roles = self.session['roles'].split(',') if role ...
python
def is_role(self, role): """ Verify if user is in role :param: role: role to verify against :return: if user is in role :exception: LTIException if role is unknown """ log.debug("is_role %s", role) roles = self.session['roles'].split(',') if role ...
[ "def", "is_role", "(", "self", ",", "role", ")", ":", "log", ".", "debug", "(", "\"is_role %s\"", ",", "role", ")", "roles", "=", "self", ".", "session", "[", "'roles'", "]", ".", "split", "(", "','", ")", "if", "role", "in", "LTI_ROLES", ":", "rol...
Verify if user is in role :param: role: role to verify against :return: if user is in role :exception: LTIException if role is unknown
[ "Verify", "if", "user", "is", "in", "role" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L550-L571
mitodl/pylti
pylti/common.py
LTIBase._check_role
def _check_role(self): """ Check that user is in role specified as wrapper attribute :exception: LTIRoleException if user is not in roles """ role = u'any' if 'role' in self.lti_kwargs: role = self.lti_kwargs['role'] log.debug( "check_role...
python
def _check_role(self): """ Check that user is in role specified as wrapper attribute :exception: LTIRoleException if user is not in roles """ role = u'any' if 'role' in self.lti_kwargs: role = self.lti_kwargs['role'] log.debug( "check_role...
[ "def", "_check_role", "(", "self", ")", ":", "role", "=", "u'any'", "if", "'role'", "in", "self", ".", "lti_kwargs", ":", "role", "=", "self", ".", "lti_kwargs", "[", "'role'", "]", "log", ".", "debug", "(", "\"check_role lti_role=%s decorator_role=%s\"", ",...
Check that user is in role specified as wrapper attribute :exception: LTIRoleException if user is not in roles
[ "Check", "that", "user", "is", "in", "role", "specified", "as", "wrapper", "attribute" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L573-L586
mitodl/pylti
pylti/common.py
LTIBase.post_grade
def post_grade(self, grade): """ Post grade to LTI consumer using XML :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exception: LTIPostMessageException if call failed """ message_identifier_id = self.message_identifier_id() ...
python
def post_grade(self, grade): """ Post grade to LTI consumer using XML :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exception: LTIPostMessageException if call failed """ message_identifier_id = self.message_identifier_id() ...
[ "def", "post_grade", "(", "self", ",", "grade", ")", ":", "message_identifier_id", "=", "self", ".", "message_identifier_id", "(", ")", "operation", "=", "'replaceResult'", "lis_result_sourcedid", "=", "self", ".", "lis_result_sourcedid", "# # edX devbox fix", "score"...
Post grade to LTI consumer using XML :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exception: LTIPostMessageException if call failed
[ "Post", "grade", "to", "LTI", "consumer", "using", "XML" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L588-L611
mitodl/pylti
pylti/common.py
LTIBase.post_grade2
def post_grade2(self, grade, user=None, comment=''): """ Post grade to LTI consumer using REST/JSON URL munging will is related to: https://openedx.atlassian.net/browse/PLAT-281 :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exce...
python
def post_grade2(self, grade, user=None, comment=''): """ Post grade to LTI consumer using REST/JSON URL munging will is related to: https://openedx.atlassian.net/browse/PLAT-281 :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exce...
[ "def", "post_grade2", "(", "self", ",", "grade", ",", "user", "=", "None", ",", "comment", "=", "''", ")", ":", "content_type", "=", "'application/vnd.ims.lis.v2.result+json'", "if", "user", "is", "None", ":", "user", "=", "self", ".", "user_id", "lti2_url",...
Post grade to LTI consumer using REST/JSON URL munging will is related to: https://openedx.atlassian.net/browse/PLAT-281 :param: grade: 0 <= grade <= 1 :return: True if post successful and grade valid :exception: LTIPostMessageException if call failed
[ "Post", "grade", "to", "LTI", "consumer", "using", "REST", "/", "JSON", "URL", "munging", "will", "is", "related", "to", ":", "https", ":", "//", "openedx", ".", "atlassian", ".", "net", "/", "browse", "/", "PLAT", "-", "281" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L613-L644
mitodl/pylti
pylti/flask.py
lti
def lti(app=None, request='any', error=default_error, role='any', *lti_args, **lti_kwargs): """ LTI decorator :param: app - Flask App object (optional). :py:attr:`flask.current_app` is used if no object is passed in. :param: error - Callback if LTI throws exception (optional). :...
python
def lti(app=None, request='any', error=default_error, role='any', *lti_args, **lti_kwargs): """ LTI decorator :param: app - Flask App object (optional). :py:attr:`flask.current_app` is used if no object is passed in. :param: error - Callback if LTI throws exception (optional). :...
[ "def", "lti", "(", "app", "=", "None", ",", "request", "=", "'any'", ",", "error", "=", "default_error", ",", "role", "=", "'any'", ",", "*", "lti_args", ",", "*", "*", "lti_kwargs", ")", ":", "def", "_lti", "(", "function", ")", ":", "\"\"\"\n ...
LTI decorator :param: app - Flask App object (optional). :py:attr:`flask.current_app` is used if no object is passed in. :param: error - Callback if LTI throws exception (optional). :py:attr:`pylti.flask.default_error` is the default. :param: request - Request type from :py:attr:`py...
[ "LTI", "decorator" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L159-L213
mitodl/pylti
pylti/flask.py
LTI._consumers
def _consumers(self): """ Gets consumer's map from app config :return: consumers map """ app_config = self.lti_kwargs['app'].config config = app_config.get('PYLTI_CONFIG', dict()) consumers = config.get('consumers', dict()) return consumers
python
def _consumers(self): """ Gets consumer's map from app config :return: consumers map """ app_config = self.lti_kwargs['app'].config config = app_config.get('PYLTI_CONFIG', dict()) consumers = config.get('consumers', dict()) return consumers
[ "def", "_consumers", "(", "self", ")", ":", "app_config", "=", "self", ".", "lti_kwargs", "[", "'app'", "]", ".", "config", "config", "=", "app_config", ".", "get", "(", "'PYLTI_CONFIG'", ",", "dict", "(", ")", ")", "consumers", "=", "config", ".", "ge...
Gets consumer's map from app config :return: consumers map
[ "Gets", "consumer", "s", "map", "from", "app", "config" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L42-L51
mitodl/pylti
pylti/flask.py
LTI.verify_request
def verify_request(self): """ Verify LTI request :raises: LTIException is request validation failed """ if flask_request.method == 'POST': params = flask_request.form.to_dict() else: params = flask_request.args.to_dict() log.debug(params) ...
python
def verify_request(self): """ Verify LTI request :raises: LTIException is request validation failed """ if flask_request.method == 'POST': params = flask_request.form.to_dict() else: params = flask_request.args.to_dict() log.debug(params) ...
[ "def", "verify_request", "(", "self", ")", ":", "if", "flask_request", ".", "method", "==", "'POST'", ":", "params", "=", "flask_request", ".", "form", ".", "to_dict", "(", ")", "else", ":", "params", "=", "flask_request", ".", "args", ".", "to_dict", "(...
Verify LTI request :raises: LTIException is request validation failed
[ "Verify", "LTI", "request", ":", "raises", ":", "LTIException", "is", "request", "validation", "failed" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L53-L87
mitodl/pylti
pylti/flask.py
LTI.response_url
def response_url(self): """ Returns remapped lis_outcome_service_url uses PYLTI_URL_FIX map to support edX dev-stack :return: remapped lis_outcome_service_url """ url = "" url = self.session['lis_outcome_service_url'] app_config = self.lti_kwargs['app'].c...
python
def response_url(self): """ Returns remapped lis_outcome_service_url uses PYLTI_URL_FIX map to support edX dev-stack :return: remapped lis_outcome_service_url """ url = "" url = self.session['lis_outcome_service_url'] app_config = self.lti_kwargs['app'].c...
[ "def", "response_url", "(", "self", ")", ":", "url", "=", "\"\"", "url", "=", "self", ".", "session", "[", "'lis_outcome_service_url'", "]", "app_config", "=", "self", ".", "lti_kwargs", "[", "'app'", "]", ".", "config", "urls", "=", "app_config", ".", "...
Returns remapped lis_outcome_service_url uses PYLTI_URL_FIX map to support edX dev-stack :return: remapped lis_outcome_service_url
[ "Returns", "remapped", "lis_outcome_service_url", "uses", "PYLTI_URL_FIX", "map", "to", "support", "edX", "dev", "-", "stack" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L90-L107
mitodl/pylti
pylti/flask.py
LTI._verify_any
def _verify_any(self): """ Verify that an initial request has been made, or failing that, that the request is in the session :raises: LTIException """ log.debug('verify_any enter') # Check to see if there is a new LTI launch request incoming newrequest = ...
python
def _verify_any(self): """ Verify that an initial request has been made, or failing that, that the request is in the session :raises: LTIException """ log.debug('verify_any enter') # Check to see if there is a new LTI launch request incoming newrequest = ...
[ "def", "_verify_any", "(", "self", ")", ":", "log", ".", "debug", "(", "'verify_any enter'", ")", "# Check to see if there is a new LTI launch request incoming", "newrequest", "=", "False", "if", "flask_request", ".", "method", "==", "'POST'", ":", "params", "=", "f...
Verify that an initial request has been made, or failing that, that the request is in the session :raises: LTIException
[ "Verify", "that", "an", "initial", "request", "has", "been", "made", "or", "failing", "that", "that", "the", "request", "is", "in", "the", "session", ":", "raises", ":", "LTIException" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L109-L135
mitodl/pylti
pylti/flask.py
LTI.close_session
def close_session(): """ Invalidates session """ for prop in LTI_PROPERTY_LIST: if session.get(prop, None): del session[prop] session[LTI_SESSION_KEY] = False
python
def close_session(): """ Invalidates session """ for prop in LTI_PROPERTY_LIST: if session.get(prop, None): del session[prop] session[LTI_SESSION_KEY] = False
[ "def", "close_session", "(", ")", ":", "for", "prop", "in", "LTI_PROPERTY_LIST", ":", "if", "session", ".", "get", "(", "prop", ",", "None", ")", ":", "del", "session", "[", "prop", "]", "session", "[", "LTI_SESSION_KEY", "]", "=", "False" ]
Invalidates session
[ "Invalidates", "session" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L149-L156
mitodl/pylti
pylti/chalice.py
LTI._consumers
def _consumers(self): """ Gets consumers from Lambda environment variables prefixed with CONSUMER_KEY_SECRET_. For example, given a consumer key of foo and a shared secret of bar, you should have an environment variable CONSUMER_KEY_SECRET_foo=bar. :return: consumers map...
python
def _consumers(self): """ Gets consumers from Lambda environment variables prefixed with CONSUMER_KEY_SECRET_. For example, given a consumer key of foo and a shared secret of bar, you should have an environment variable CONSUMER_KEY_SECRET_foo=bar. :return: consumers map...
[ "def", "_consumers", "(", "self", ")", ":", "consumers", "=", "{", "}", "for", "env", "in", "os", ".", "environ", ":", "if", "env", ".", "startswith", "(", "'CONSUMER_KEY_SECRET_'", ")", ":", "key", "=", "env", "[", "20", ":", "]", "# Strip off the CON...
Gets consumers from Lambda environment variables prefixed with CONSUMER_KEY_SECRET_. For example, given a consumer key of foo and a shared secret of bar, you should have an environment variable CONSUMER_KEY_SECRET_foo=bar. :return: consumers map :raises: LTIException if environm...
[ "Gets", "consumers", "from", "Lambda", "environment", "variables", "prefixed", "with", "CONSUMER_KEY_SECRET_", ".", "For", "example", "given", "a", "consumer", "key", "of", "foo", "and", "a", "shared", "secret", "of", "bar", "you", "should", "have", "an", "env...
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/chalice.py#L50-L71
mitodl/pylti
pylti/chalice.py
LTI.verify_request
def verify_request(self): """ Verify LTI request :raises: LTIException if request validation failed """ request = self.lti_kwargs['app'].current_request if request.method == 'POST': # Chalice expects JSON and does not nativly support forms data in ...
python
def verify_request(self): """ Verify LTI request :raises: LTIException if request validation failed """ request = self.lti_kwargs['app'].current_request if request.method == 'POST': # Chalice expects JSON and does not nativly support forms data in ...
[ "def", "verify_request", "(", "self", ")", ":", "request", "=", "self", ".", "lti_kwargs", "[", "'app'", "]", ".", "current_request", "if", "request", ".", "method", "==", "'POST'", ":", "# Chalice expects JSON and does not nativly support forms data in", "# a post bo...
Verify LTI request :raises: LTIException if request validation failed
[ "Verify", "LTI", "request" ]
train
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/chalice.py#L73-L119
django-danceschool/django-danceschool
danceschool/core/views.py
EventRegistrationSelectView.get_queryset
def get_queryset(self): ''' Recent events are listed in link form. ''' return Event.objects.filter( Q(startTime__gte=timezone.now() - timedelta(days=90)) & ( Q(series__isnull=False) | Q(publicevent__isnull=False) ) ).annotate(count=Count('eventregistratio...
python
def get_queryset(self): ''' Recent events are listed in link form. ''' return Event.objects.filter( Q(startTime__gte=timezone.now() - timedelta(days=90)) & ( Q(series__isnull=False) | Q(publicevent__isnull=False) ) ).annotate(count=Count('eventregistratio...
[ "def", "get_queryset", "(", "self", ")", ":", "return", "Event", ".", "objects", ".", "filter", "(", "Q", "(", "startTime__gte", "=", "timezone", ".", "now", "(", ")", "-", "timedelta", "(", "days", "=", "90", ")", ")", "&", "(", "Q", "(", "series_...
Recent events are listed in link form.
[ "Recent", "events", "are", "listed", "in", "link", "form", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L53-L64
django-danceschool/django-danceschool
danceschool/core/views.py
EventRegistrationSummaryView.get_context_data
def get_context_data(self, **kwargs): ''' Add the list of registrations for the given series ''' # Update the site session data so that registration processes know to send return links to # the view class registrations page. set_return_page() is in SiteHistoryMixin. self.set_return_pag...
python
def get_context_data(self, **kwargs): ''' Add the list of registrations for the given series ''' # Update the site session data so that registration processes know to send return links to # the view class registrations page. set_return_page() is in SiteHistoryMixin. self.set_return_pag...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Update the site session data so that registration processes know to send return links to", "# the view class registrations page. set_return_page() is in SiteHistoryMixin.", "self", ".", "set_return_page", "(...
Add the list of registrations for the given series
[ "Add", "the", "list", "of", "registrations", "for", "the", "given", "series" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L90-L105
django-danceschool/django-danceschool
danceschool/core/views.py
SubmissionRedirectView.get_context_data
def get_context_data(self, **kwargs): ''' The URL to redirect to can be explicitly specified, or it can come from the site session history, or it can be the default admin success page as specified in the site settings. ''' context = super(SubmissionRedirectView, self).ge...
python
def get_context_data(self, **kwargs): ''' The URL to redirect to can be explicitly specified, or it can come from the site session history, or it can be the default admin success page as specified in the site settings. ''' context = super(SubmissionRedirectView, self).ge...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "SubmissionRedirectView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "redirect_url", "=", "unquote", "(", "self", ".", ...
The URL to redirect to can be explicitly specified, or it can come from the site session history, or it can be the default admin success page as specified in the site settings.
[ "The", "URL", "to", "redirect", "to", "can", "be", "explicitly", "specified", "or", "it", "can", "come", "from", "the", "site", "session", "history", "or", "it", "can", "be", "the", "default", "admin", "success", "page", "as", "specified", "in", "the", "...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L115-L140
django-danceschool/django-danceschool
danceschool/core/views.py
ViewInvoiceView.get
def get(self, request, *args, **kwargs): ''' Invoices can be viewed only if the validation string is provided, unless the user is logged in and has view_all_invoice permissions ''' user_has_validation_string = self.get_object().validationString user_has_permissions = requ...
python
def get(self, request, *args, **kwargs): ''' Invoices can be viewed only if the validation string is provided, unless the user is logged in and has view_all_invoice permissions ''' user_has_validation_string = self.get_object().validationString user_has_permissions = requ...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "user_has_validation_string", "=", "self", ".", "get_object", "(", ")", ".", "validationString", "user_has_permissions", "=", "request", ".", "user", ".", "has_...
Invoices can be viewed only if the validation string is provided, unless the user is logged in and has view_all_invoice permissions
[ "Invoices", "can", "be", "viewed", "only", "if", "the", "validation", "string", "is", "provided", "unless", "the", "user", "is", "logged", "in", "and", "has", "view_all_invoice", "permissions" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L150-L159
django-danceschool/django-danceschool
danceschool/core/views.py
InvoiceNotificationView.dispatch
def dispatch(self, request, *args, **kwargs): ''' Get the set of invoices for which to permit notifications ''' if 'pk' in self.kwargs: try: self.invoices = Invoice.objects.filter(pk=self.kwargs.get('pk'))[:] except ValueError: raise Http404() ...
python
def dispatch(self, request, *args, **kwargs): ''' Get the set of invoices for which to permit notifications ''' if 'pk' in self.kwargs: try: self.invoices = Invoice.objects.filter(pk=self.kwargs.get('pk'))[:] except ValueError: raise Http404() ...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'pk'", "in", "self", ".", "kwargs", ":", "try", ":", "self", ".", "invoices", "=", "Invoice", ".", "objects", ".", "filter", "(", "pk", "=...
Get the set of invoices for which to permit notifications
[ "Get", "the", "set", "of", "invoices", "for", "which", "to", "permit", "notifications" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L199-L230
django-danceschool/django-danceschool
danceschool/core/views.py
InvoiceNotificationView.get_form_kwargs
def get_form_kwargs(self): ''' Pass the set of invoices to the form for creation ''' kwargs = super(InvoiceNotificationView, self).get_form_kwargs() kwargs['invoices'] = self.toNotify return kwargs
python
def get_form_kwargs(self): ''' Pass the set of invoices to the form for creation ''' kwargs = super(InvoiceNotificationView, self).get_form_kwargs() kwargs['invoices'] = self.toNotify return kwargs
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "InvoiceNotificationView", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", "[", "'invoices'", "]", "=", "self", ".", "toNotify", "return", "kwargs" ]
Pass the set of invoices to the form for creation
[ "Pass", "the", "set", "of", "invoices", "to", "the", "form", "for", "creation" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L232-L236
django-danceschool/django-danceschool
danceschool/core/views.py
SendEmailView.dispatch
def dispatch(self, request, *args, **kwargs): ''' If a list of customers or groups was passed, then parse it ''' ids = request.GET.get('customers') groups = request.GET.get('customergroup') self.customers = None if ids or groups: # Initial filter applies to no one bu...
python
def dispatch(self, request, *args, **kwargs): ''' If a list of customers or groups was passed, then parse it ''' ids = request.GET.get('customers') groups = request.GET.get('customergroup') self.customers = None if ids or groups: # Initial filter applies to no one bu...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ids", "=", "request", ".", "GET", ".", "get", "(", "'customers'", ")", "groups", "=", "request", ".", "GET", ".", "get", "(", "'customergroup'", "...
If a list of customers or groups was passed, then parse it
[ "If", "a", "list", "of", "customers", "or", "groups", "was", "passed", "then", "parse", "it" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L589-L609
django-danceschool/django-danceschool
danceschool/core/views.py
SendEmailView.get_form_kwargs
def get_form_kwargs(self, **kwargs): ''' Get the list of recent months and recent series to pass to the form ''' numMonths = 12 lastStart = ( Event.objects.annotate(Min('eventoccurrence__startTime')) .order_by('-eventoccurrence__startTime__min') ...
python
def get_form_kwargs(self, **kwargs): ''' Get the list of recent months and recent series to pass to the form ''' numMonths = 12 lastStart = ( Event.objects.annotate(Min('eventoccurrence__startTime')) .order_by('-eventoccurrence__startTime__min') ...
[ "def", "get_form_kwargs", "(", "self", ",", "*", "*", "kwargs", ")", ":", "numMonths", "=", "12", "lastStart", "=", "(", "Event", ".", "objects", ".", "annotate", "(", "Min", "(", "'eventoccurrence__startTime'", ")", ")", ".", "order_by", "(", "'-eventoccu...
Get the list of recent months and recent series to pass to the form
[ "Get", "the", "list", "of", "recent", "months", "and", "recent", "series", "to", "pass", "to", "the", "form" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L611-L652
django-danceschool/django-danceschool
danceschool/core/views.py
SendEmailView.get_initial
def get_initial(self): ''' If the user already submitted the form and decided to return from the confirmation page, then re-populate the form ''' initial = super(SendEmailView, self).get_initial() form_data = self.request.session.get(EMAIL_VALIDATION_STR, {}).get('form_d...
python
def get_initial(self): ''' If the user already submitted the form and decided to return from the confirmation page, then re-populate the form ''' initial = super(SendEmailView, self).get_initial() form_data = self.request.session.get(EMAIL_VALIDATION_STR, {}).get('form_d...
[ "def", "get_initial", "(", "self", ")", ":", "initial", "=", "super", "(", "SendEmailView", ",", "self", ")", ".", "get_initial", "(", ")", "form_data", "=", "self", ".", "request", ".", "session", ".", "get", "(", "EMAIL_VALIDATION_STR", ",", "{", "}", ...
If the user already submitted the form and decided to return from the confirmation page, then re-populate the form
[ "If", "the", "user", "already", "submitted", "the", "form", "and", "decided", "to", "return", "from", "the", "confirmation", "page", "then", "re", "-", "populate", "the", "form" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L654-L664
django-danceschool/django-danceschool
danceschool/core/views.py
SendEmailView.form_valid
def form_valid(self, form): ''' Pass form data to the confirmation view ''' form.cleaned_data.pop('template', None) self.request.session[EMAIL_VALIDATION_STR] = {'form_data': form.cleaned_data} return HttpResponseRedirect(reverse('emailConfirmation'))
python
def form_valid(self, form): ''' Pass form data to the confirmation view ''' form.cleaned_data.pop('template', None) self.request.session[EMAIL_VALIDATION_STR] = {'form_data': form.cleaned_data} return HttpResponseRedirect(reverse('emailConfirmation'))
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "form", ".", "cleaned_data", ".", "pop", "(", "'template'", ",", "None", ")", "self", ".", "request", ".", "session", "[", "EMAIL_VALIDATION_STR", "]", "=", "{", "'form_data'", ":", "form", ".", ...
Pass form data to the confirmation view
[ "Pass", "form", "data", "to", "the", "confirmation", "view" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L675-L679
django-danceschool/django-danceschool
danceschool/core/views.py
RepeatEventsView.form_valid
def form_valid(self, form): ''' For each object in the queryset, create the duplicated objects ''' startDate = form.cleaned_data.get('startDate') repeatEvery = form.cleaned_data.get('repeatEvery') periodicity = form.cleaned_data.get('periodicity') quantity = form.cleaned_data.ge...
python
def form_valid(self, form): ''' For each object in the queryset, create the duplicated objects ''' startDate = form.cleaned_data.get('startDate') repeatEvery = form.cleaned_data.get('repeatEvery') periodicity = form.cleaned_data.get('periodicity') quantity = form.cleaned_data.ge...
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "startDate", "=", "form", ".", "cleaned_data", ".", "get", "(", "'startDate'", ")", "repeatEvery", "=", "form", ".", "cleaned_data", ".", "get", "(", "'repeatEvery'", ")", "periodicity", "=", "form",...
For each object in the queryset, create the duplicated objects
[ "For", "each", "object", "in", "the", "queryset", "create", "the", "duplicated", "objects" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L934-L1013
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestList.recentEvents
def recentEvents(self): ''' Get the set of recent and upcoming events to which this list applies. ''' return Event.objects.filter( Q(pk__in=self.individualEvents.values_list('pk',flat=True)) | Q(session__in=self.eventSessions.all()) | Q(publicevent__ca...
python
def recentEvents(self): ''' Get the set of recent and upcoming events to which this list applies. ''' return Event.objects.filter( Q(pk__in=self.individualEvents.values_list('pk',flat=True)) | Q(session__in=self.eventSessions.all()) | Q(publicevent__ca...
[ "def", "recentEvents", "(", "self", ")", ":", "return", "Event", ".", "objects", ".", "filter", "(", "Q", "(", "pk__in", "=", "self", ".", "individualEvents", ".", "values_list", "(", "'pk'", ",", "flat", "=", "True", ")", ")", "|", "Q", "(", "sessio...
Get the set of recent and upcoming events to which this list applies.
[ "Get", "the", "set", "of", "recent", "and", "upcoming", "events", "to", "which", "this", "list", "applies", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L33-L45
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestList.currentEvent
def currentEvent(self): ''' Return the first event that hasn't ended yet, or if there are no future events, the last one to end. ''' currentEvent = self.recentEvents.filter(endTime__gte=timezone.now()).order_by('startTime').first() if not currentEvent: curren...
python
def currentEvent(self): ''' Return the first event that hasn't ended yet, or if there are no future events, the last one to end. ''' currentEvent = self.recentEvents.filter(endTime__gte=timezone.now()).order_by('startTime').first() if not currentEvent: curren...
[ "def", "currentEvent", "(", "self", ")", ":", "currentEvent", "=", "self", ".", "recentEvents", ".", "filter", "(", "endTime__gte", "=", "timezone", ".", "now", "(", ")", ")", ".", "order_by", "(", "'startTime'", ")", ".", "first", "(", ")", "if", "not...
Return the first event that hasn't ended yet, or if there are no future events, the last one to end.
[ "Return", "the", "first", "event", "that", "hasn", "t", "ended", "yet", "or", "if", "there", "are", "no", "future", "events", "the", "last", "one", "to", "end", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L48-L58
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestList.appliesToEvent
def appliesToEvent(self, event): ''' Check whether this guest list is applicable to an event. ''' return ( event in self.individualEvents.all() or event.session in self.eventSessions.all() or event.category in self.seriesCategories.all() or event.category ...
python
def appliesToEvent(self, event): ''' Check whether this guest list is applicable to an event. ''' return ( event in self.individualEvents.all() or event.session in self.eventSessions.all() or event.category in self.seriesCategories.all() or event.category ...
[ "def", "appliesToEvent", "(", "self", ",", "event", ")", ":", "return", "(", "event", "in", "self", ".", "individualEvents", ".", "all", "(", ")", "or", "event", ".", "session", "in", "self", ".", "eventSessions", ".", "all", "(", ")", "or", "event", ...
Check whether this guest list is applicable to an event.
[ "Check", "whether", "this", "guest", "list", "is", "applicable", "to", "an", "event", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L60-L67