repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
bspaans/python-mingus
mingus/core/progressions.py
substitute_minor_for_major
def substitute_minor_for_major(progression, substitute_index, ignore_suffix=False): """Substitute minor chords for its major equivalent. 'm' and 'm7' suffixes recognized, and ['II', 'III', 'VI'] if there is no suffix. Examples: >>> substitute_minor_for_major(['VI'], 0) ['I'] >>> su...
python
def substitute_minor_for_major(progression, substitute_index, ignore_suffix=False): """Substitute minor chords for its major equivalent. 'm' and 'm7' suffixes recognized, and ['II', 'III', 'VI'] if there is no suffix. Examples: >>> substitute_minor_for_major(['VI'], 0) ['I'] >>> su...
[ "def", "substitute_minor_for_major", "(", "progression", ",", "substitute_index", ",", "ignore_suffix", "=", "False", ")", ":", "(", "roman", ",", "acc", ",", "suff", ")", "=", "parse_string", "(", "progression", "[", "substitute_index", "]", ")", "res", "=", ...
Substitute minor chords for its major equivalent. 'm' and 'm7' suffixes recognized, and ['II', 'III', 'VI'] if there is no suffix. Examples: >>> substitute_minor_for_major(['VI'], 0) ['I'] >>> substitute_minor_for_major(['Vm'], 0) ['bVIIM'] >>> substitute_minor_for_major(['VIm7'], 0) ...
[ "Substitute", "minor", "chords", "for", "its", "major", "equivalent", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/progressions.py#L278-L307
train
bspaans/python-mingus
mingus/core/progressions.py
substitute_diminished_for_diminished
def substitute_diminished_for_diminished(progression, substitute_index, ignore_suffix=False): """Substitute a diminished chord for another diminished chord. 'dim' and 'dim7' suffixes recognized, and 'VI' if there is no suffix. Example: >>> substitute_diminished_for_diminished(['VII'], 0) [...
python
def substitute_diminished_for_diminished(progression, substitute_index, ignore_suffix=False): """Substitute a diminished chord for another diminished chord. 'dim' and 'dim7' suffixes recognized, and 'VI' if there is no suffix. Example: >>> substitute_diminished_for_diminished(['VII'], 0) [...
[ "def", "substitute_diminished_for_diminished", "(", "progression", ",", "substitute_index", ",", "ignore_suffix", "=", "False", ")", ":", "(", "roman", ",", "acc", ",", "suff", ")", "=", "parse_string", "(", "progression", "[", "substitute_index", "]", ")", "res...
Substitute a diminished chord for another diminished chord. 'dim' and 'dim7' suffixes recognized, and 'VI' if there is no suffix. Example: >>> substitute_diminished_for_diminished(['VII'], 0) ['IIdim', 'bIVdim', 'bbVIdim']
[ "Substitute", "a", "diminished", "chord", "for", "another", "diminished", "chord", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/progressions.py#L338-L364
train
bspaans/python-mingus
mingus/core/progressions.py
interval_diff
def interval_diff(progression1, progression2, interval): """Return the number of half steps progression2 needs to be diminished or augmented until the interval between progression1 and progression2 is interval.""" i = numeral_intervals[numerals.index(progression1)] j = numeral_intervals[numerals.ind...
python
def interval_diff(progression1, progression2, interval): """Return the number of half steps progression2 needs to be diminished or augmented until the interval between progression1 and progression2 is interval.""" i = numeral_intervals[numerals.index(progression1)] j = numeral_intervals[numerals.ind...
[ "def", "interval_diff", "(", "progression1", ",", "progression2", ",", "interval", ")", ":", "i", "=", "numeral_intervals", "[", "numerals", ".", "index", "(", "progression1", ")", "]", "j", "=", "numeral_intervals", "[", "numerals", ".", "index", "(", "prog...
Return the number of half steps progression2 needs to be diminished or augmented until the interval between progression1 and progression2 is interval.
[ "Return", "the", "number", "of", "half", "steps", "progression2", "needs", "to", "be", "diminished", "or", "augmented", "until", "the", "interval", "between", "progression1", "and", "progression2", "is", "interval", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/progressions.py#L468-L483
train
bspaans/python-mingus
mingus/core/progressions.py
skip
def skip(roman_numeral, skip=1): """Skip the given places to the next roman numeral. Examples: >>> skip('I') 'II' >>> skip('VII') 'I' >>> skip('I', 2) 'III' """ i = numerals.index(roman_numeral) + skip return numerals[i % 7]
python
def skip(roman_numeral, skip=1): """Skip the given places to the next roman numeral. Examples: >>> skip('I') 'II' >>> skip('VII') 'I' >>> skip('I', 2) 'III' """ i = numerals.index(roman_numeral) + skip return numerals[i % 7]
[ "def", "skip", "(", "roman_numeral", ",", "skip", "=", "1", ")", ":", "i", "=", "numerals", ".", "index", "(", "roman_numeral", ")", "+", "skip", "return", "numerals", "[", "i", "%", "7", "]" ]
Skip the given places to the next roman numeral. Examples: >>> skip('I') 'II' >>> skip('VII') 'I' >>> skip('I', 2) 'III'
[ "Skip", "the", "given", "places", "to", "the", "next", "roman", "numeral", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/progressions.py#L485-L497
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.add_note
def add_note(self, note, octave=None, dynamics={}): """Add a note to the container and sorts the notes from low to high. The note can either be a string, in which case you could also use the octave and dynamics arguments, or a Note object. """ if type(note) == str: i...
python
def add_note(self, note, octave=None, dynamics={}): """Add a note to the container and sorts the notes from low to high. The note can either be a string, in which case you could also use the octave and dynamics arguments, or a Note object. """ if type(note) == str: i...
[ "def", "add_note", "(", "self", ",", "note", ",", "octave", "=", "None", ",", "dynamics", "=", "{", "}", ")", ":", "if", "type", "(", "note", ")", "==", "str", ":", "if", "octave", "is", "not", "None", ":", "note", "=", "Note", "(", "note", ","...
Add a note to the container and sorts the notes from low to high. The note can either be a string, in which case you could also use the octave and dynamics arguments, or a Note object.
[ "Add", "a", "note", "to", "the", "container", "and", "sorts", "the", "notes", "from", "low", "to", "high", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L45-L67
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.add_notes
def add_notes(self, notes): """Feed notes to self.add_note. The notes can either be an other NoteContainer, a list of Note objects or strings or a list of lists formatted like this: >>> notes = [['C', 5], ['E', 5], ['G', 6]] or even: >>> notes = [['C', 5, {'volume': 20}...
python
def add_notes(self, notes): """Feed notes to self.add_note. The notes can either be an other NoteContainer, a list of Note objects or strings or a list of lists formatted like this: >>> notes = [['C', 5], ['E', 5], ['G', 6]] or even: >>> notes = [['C', 5, {'volume': 20}...
[ "def", "add_notes", "(", "self", ",", "notes", ")", ":", "if", "hasattr", "(", "notes", ",", "'notes'", ")", ":", "for", "x", "in", "notes", ".", "notes", ":", "self", ".", "add_note", "(", "x", ")", "return", "self", ".", "notes", "elif", "hasattr...
Feed notes to self.add_note. The notes can either be an other NoteContainer, a list of Note objects or strings or a list of lists formatted like this: >>> notes = [['C', 5], ['E', 5], ['G', 6]] or even: >>> notes = [['C', 5, {'volume': 20}], ['E', 6, {'volume': 20}]]
[ "Feed", "notes", "to", "self", ".", "add_note", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L69-L97
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.from_chord_shorthand
def from_chord_shorthand(self, shorthand): """Empty the container and add the notes in the shorthand. See mingus.core.chords.from_shorthand for an up to date list of recognized format. Example: >>> NoteContainer().from_chord_shorthand('Am') ['A-4', 'C-5', 'E-5'] ...
python
def from_chord_shorthand(self, shorthand): """Empty the container and add the notes in the shorthand. See mingus.core.chords.from_shorthand for an up to date list of recognized format. Example: >>> NoteContainer().from_chord_shorthand('Am') ['A-4', 'C-5', 'E-5'] ...
[ "def", "from_chord_shorthand", "(", "self", ",", "shorthand", ")", ":", "self", ".", "empty", "(", ")", "self", ".", "add_notes", "(", "chords", ".", "from_shorthand", "(", "shorthand", ")", ")", "return", "self" ]
Empty the container and add the notes in the shorthand. See mingus.core.chords.from_shorthand for an up to date list of recognized format. Example: >>> NoteContainer().from_chord_shorthand('Am') ['A-4', 'C-5', 'E-5']
[ "Empty", "the", "container", "and", "add", "the", "notes", "in", "the", "shorthand", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L103-L115
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.from_interval
def from_interval(self, startnote, shorthand, up=True): """Shortcut to from_interval_shorthand.""" return self.from_interval_shorthand(startnote, shorthand, up)
python
def from_interval(self, startnote, shorthand, up=True): """Shortcut to from_interval_shorthand.""" return self.from_interval_shorthand(startnote, shorthand, up)
[ "def", "from_interval", "(", "self", ",", "startnote", ",", "shorthand", ",", "up", "=", "True", ")", ":", "return", "self", ".", "from_interval_shorthand", "(", "startnote", ",", "shorthand", ",", "up", ")" ]
Shortcut to from_interval_shorthand.
[ "Shortcut", "to", "from_interval_shorthand", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L117-L119
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.from_interval_shorthand
def from_interval_shorthand(self, startnote, shorthand, up=True): """Empty the container and add the note described in the startnote and shorthand. See core.intervals for the recognized format. Examples: >>> nc = NoteContainer() >>> nc.from_interval_shorthand('C', '5') ...
python
def from_interval_shorthand(self, startnote, shorthand, up=True): """Empty the container and add the note described in the startnote and shorthand. See core.intervals for the recognized format. Examples: >>> nc = NoteContainer() >>> nc.from_interval_shorthand('C', '5') ...
[ "def", "from_interval_shorthand", "(", "self", ",", "startnote", ",", "shorthand", ",", "up", "=", "True", ")", ":", "self", ".", "empty", "(", ")", "if", "type", "(", "startnote", ")", "==", "str", ":", "startnote", "=", "Note", "(", "startnote", ")",...
Empty the container and add the note described in the startnote and shorthand. See core.intervals for the recognized format. Examples: >>> nc = NoteContainer() >>> nc.from_interval_shorthand('C', '5') ['C-4', 'G-4'] >>> nc.from_interval_shorthand('C', '5', False...
[ "Empty", "the", "container", "and", "add", "the", "note", "described", "in", "the", "startnote", "and", "shorthand", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L121-L140
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.remove_note
def remove_note(self, note, octave=-1): """Remove note from container. The note can either be a Note object or a string representing the note's name. If no specific octave is given, the note gets removed in every octave. """ res = [] for x in self.notes: ...
python
def remove_note(self, note, octave=-1): """Remove note from container. The note can either be a Note object or a string representing the note's name. If no specific octave is given, the note gets removed in every octave. """ res = [] for x in self.notes: ...
[ "def", "remove_note", "(", "self", ",", "note", ",", "octave", "=", "-", "1", ")", ":", "res", "=", "[", "]", "for", "x", "in", "self", ".", "notes", ":", "if", "type", "(", "note", ")", "==", "str", ":", "if", "x", ".", "name", "!=", "note",...
Remove note from container. The note can either be a Note object or a string representing the note's name. If no specific octave is given, the note gets removed in every octave.
[ "Remove", "note", "from", "container", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L213-L232
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.remove_notes
def remove_notes(self, notes): """Remove notes from the containers. This function accepts a list of Note objects or notes as strings and also single strings or Note objects. """ if type(notes) == str: return self.remove_note(notes) elif hasattr(notes, 'name')...
python
def remove_notes(self, notes): """Remove notes from the containers. This function accepts a list of Note objects or notes as strings and also single strings or Note objects. """ if type(notes) == str: return self.remove_note(notes) elif hasattr(notes, 'name')...
[ "def", "remove_notes", "(", "self", ",", "notes", ")", ":", "if", "type", "(", "notes", ")", "==", "str", ":", "return", "self", ".", "remove_note", "(", "notes", ")", "elif", "hasattr", "(", "notes", ",", "'name'", ")", ":", "return", "self", ".", ...
Remove notes from the containers. This function accepts a list of Note objects or notes as strings and also single strings or Note objects.
[ "Remove", "notes", "from", "the", "containers", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L234-L246
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.remove_duplicate_notes
def remove_duplicate_notes(self): """Remove duplicate and enharmonic notes from the container.""" res = [] for x in self.notes: if x not in res: res.append(x) self.notes = res return res
python
def remove_duplicate_notes(self): """Remove duplicate and enharmonic notes from the container.""" res = [] for x in self.notes: if x not in res: res.append(x) self.notes = res return res
[ "def", "remove_duplicate_notes", "(", "self", ")", ":", "res", "=", "[", "]", "for", "x", "in", "self", ".", "notes", ":", "if", "x", "not", "in", "res", ":", "res", ".", "append", "(", "x", ")", "self", ".", "notes", "=", "res", "return", "res" ...
Remove duplicate and enharmonic notes from the container.
[ "Remove", "duplicate", "and", "enharmonic", "notes", "from", "the", "container", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L248-L255
train
bspaans/python-mingus
mingus/containers/note_container.py
NoteContainer.transpose
def transpose(self, interval, up=True): """Transpose all the notes in the container up or down the given interval.""" for n in self.notes: n.transpose(interval, up) return self
python
def transpose(self, interval, up=True): """Transpose all the notes in the container up or down the given interval.""" for n in self.notes: n.transpose(interval, up) return self
[ "def", "transpose", "(", "self", ",", "interval", ",", "up", "=", "True", ")", ":", "for", "n", "in", "self", ".", "notes", ":", "n", ".", "transpose", "(", "interval", ",", "up", ")", "return", "self" ]
Transpose all the notes in the container up or down the given interval.
[ "Transpose", "all", "the", "notes", "in", "the", "container", "up", "or", "down", "the", "given", "interval", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L276-L281
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/containers/note_container.py#L283-L292
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/scales.py#L60-L82
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/scales.py#L126-L141
train
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", ")", ":", "names", "=", "[", "x", ".", "to_shorthand", "(", ")", "for", "x", "in", "tuning", ".", "tuning", "]", "basesize", "=", "len", "(", "max", "(", "names", ")", ")", "+", "3", ...
Helper function that builds the first few characters of every bar.
[ "Helper", "function", "that", "builds", "the", "first", "few", "characters", "of", "every", "bar", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L28-L41
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L44-L88
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L90-L140
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L302-L326
train
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", ")", ":", "instr_tunings", "=", "[", "]", "for", "track", "in", "composition", ":", "tun", "=", "track", ".", "get_tuning", "(", ")", "if", "tun", ":", "instr_tunings", ".", "append"...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L328-L397
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L399-L422
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L424-L431
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/tablature.py#L433-L440
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L165-L174
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L176-L185
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L214-L222
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L224-L231
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L233-L239
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L368-L377
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L379-L388
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L390-L398
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L494-L503
train
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", ")", ":", "if", "type", "(", "shorthand_string", ")", "==", "list", ":", "res", "=", "[", "]", "for", "x", "in", "shorthand_string", ":", "res", ".", "append", "(", "from_shorth...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L699-L823
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L825-L850
train
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", ":", "return", "False", "def", "inversion_exhauster", "(", "...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L852-L925
train
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", ":", "return", "False", "def", "inversion_exhauster", ...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L927-L1019
train
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", ":", "return", "False", "def", "inversion_exhauster...
Determine the names of an extended chord.
[ "Determine", "the", "names", "of", "an", "extended", "chord", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1021-L1082
train
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", ":", "return", "False", "def", "inversion_exhauster...
Determine the names of an 6 note chord.
[ "Determine", "the", "names", "of", "an", "6", "note", "chord", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1084-L1140
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/chords.py#L1197-L1231
train
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", ")", ":", "if", "not", "hasattr", "(", "note", ",", "'name'", ")", ":", "return", "False", "result", "=", "note", ".", "name", "[", "0", "]", ".", ...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L34-L70
train
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", ")", ":", "if", "nc", "is", "not", "None", "and", "not", "hasattr", "(", "nc", ",", "'notes'", ")", ":", "return", "False", "if", "nc", "is", "None"...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L72-L116
train
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", ")", ":", "if", "not", "hasattr", "(", "bar", ",", "'bar'", ")", ":", "return", "False", "if", "showkey", ":", "key_note", "=", "Note", "(", "bar", ".", "key"...
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L118-L160
train
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", ")", ":", "if", "not", "hasattr", "(", "track", ",", "'bars'", ")", ":", "return", "False", "lastkey", "=", "Key", "(", "'C'", ")", "lasttime", "=", "(", "4", ",", "4", ")", "result", "=", "''", "for", "bar", "i...
Process a Track object and return the LilyPond equivalent in a string.
[ "Process", "a", "Track", "object", "and", "return", "the", "LilyPond", "equivalent", "in", "a", "string", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L162-L184
train
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", ")", ":", "if", "not", "hasattr", "(", "composition", ",", "'tracks'", ")", ":", "return", "False", "result", "=", "'\\\\header { title = \"%s\" composer = \"%s\" opus = \"%s\" } '", "%", "(", "composition", ".", "title",...
Return the LilyPond equivalent of a Composition in a string.
[ "Return", "the", "LilyPond", "equivalent", "of", "a", "Composition", "in", "a", "string", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L186-L195
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/extra/lilypond.py#L214-L229
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/core/value.py#L230-L274
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L105-L130
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L61-L67
train
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", "." ]
aa5a5d992d45ada61be0f9f86261380731bd7749
https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/fluidsynth.py#L69-L78
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L73-L180
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L321-L352
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L490-L518
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L520-L549
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L552-L564
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L566-L591
train
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L593-L619
train
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", ...
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L679-L733
train
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...
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L773-L837
train
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", ")", ":", "logging", ".", "info", "(", "\"associate_devices thing_names:{0}\"", ".", "format", "(", "thing_names", ")",...
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", "." ]
06189ceccb794fedf80e0e7649938c18792e16c9
https://github.com/awslabs/aws-greengrass-group-setup/blob/06189ceccb794fedf80e0e7649938c18792e16c9/gg_group_setup/cmd.py#L839-L878
train
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", ")", ":", "data", "=", "json", ".", "dumps", "(", "message", ")", ".", "encode", "(", "'utf-8'", ")", "+", "b'\\n'", "self", ".", "transport", ".", "write", "(", "data", ")" ]
Given an object, encode as JSON and transmit to the server.
[ "Given", "an", "object", "encode", "as", "JSON", "and", "transmit", "to", "the", "server", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/protocol.py#L57-L63
train
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", ")", ":", "nick", "=", "nick", "[", "2", ":", "]", "if", "nick", "[", "0", ":", "2", "]", "==", "'E_'", "else", "nick", "ho...
Server replied to one of our WHO requests, with details.
[ "Server", "replied", "to", "one", "of", "our", "WHO", "requests", "with", "details", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/findall.py#L59-L74
train
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", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L161-L173
train
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", ")", ":", "self", ".", "next_id", "+=", "1", "req_id", "=", "self", ".", "next_id", "msg", "=", "{", "'id'", ":", "req_id", ",", "'...
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", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L176-L210
train
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", ")", ":", "resp_id", "=", "msg", ".", "get", "(", "'id'", ",", "None", ")", "if", "resp_id", "is", "None", ":", "method", "=", "msg", ".", "get", "(", "'method'", ",", "None", ")", "if", "not", "me...
Decode and dispatch responses from the server. Has already been unframed and deserialized into an object.
[ "Decode", "and", "dispatch", "responses", "from", "the", "server", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/client.py#L212-L260
train
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", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L171-L178
train
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", "bot", "=", "IrcListener", "(", "irc_nickname", "=", "irc_nickname", ",",...
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", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L180-L201
train
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", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L238-L244
train
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", ")", "return", "lst...
Find all servers with indicated protocol support. Shuffled. Filter by TOR support, and pruning level.
[ "Find", "all", "servers", "with", "indicated", "protocol", "support", ".", "Shuffled", "." ]
99948f92cc5c3ecb1a8a70146294014e608e50fc
https://github.com/coinkite/connectrum/blob/99948f92cc5c3ecb1a8a70146294014e608e50fc/connectrum/svr_info.py#L249-L259
train
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", ")", ":", "oauth_server", "=", "LTIOAuthServer", "(", "consumers", ")", "oauth_server", ".", "add_signature_method", "(", "SignatureMetho...
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L145-L203
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L206-L229
train
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'", ")", ":", "(", "response", ",", "_", ")", "=", "_post_patched_request", "(", "consumers", ",", "...
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L232-L256
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L259-L308
train
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", ")", ":", "root", "=", "etree", ".", "Element", "(", "u'imsx_POXEnvelopeRequest'", ",", "xmlns", "=", "u'http://www.imsglobal.org/services/'", "u'lt...
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", "." ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L311-L353
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L550-L571
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L573-L586
train
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", "score", "=", "float", "(...
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/common.py#L588-L611
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L42-L51
train
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" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/flask.py#L90-L107
train
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", ":", "]", "consumers", "[", ...
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...
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/chalice.py#L50-L71
train
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'", ":", "parsed_url", "=", "request", ".", "raw_body", ".", "decode", "(", ...
Verify LTI request :raises: LTIException if request validation failed
[ "Verify", "LTI", "request" ]
18a608282e0d5bc941beb2eaaeea3b7ad484b399
https://github.com/mitodl/pylti/blob/18a608282e0d5bc941beb2eaaeea3b7ad484b399/pylti/chalice.py#L73-L119
train
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", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L53-L64
train
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", ")", ":", "self", ".", "set_return_page", "(", "'viewregistrations'", ",", "_", "(", "'View Registrations'", ")", ",", "event_id", "=", "self", ".", "object", ".", "id", ")", "context", "=", "{",...
Add the list of registrations for the given series
[ "Add", "the", "list", "of", "registrations", "for", "the", "given", "series" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L90-L105
train
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", ".", "request", ...
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", "...
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L115-L140
train
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_perm",...
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L150-L159
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L199-L230
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L232-L236
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L589-L609
train
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", "(", "'-eventoccurrence...
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L611-L652
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L654-L664
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L675-L679
train
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" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/views.py#L934-L1013
train
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", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L33-L45
train
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", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L48-L58
train
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", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L60-L67
train
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestList.getDayStart
def getDayStart(self, dateTime): ''' Ensure local time and get the beginning of the day ''' return ensure_localtime(dateTime).replace(hour=0,minute=0,second=0,microsecond=0)
python
def getDayStart(self, dateTime): ''' Ensure local time and get the beginning of the day ''' return ensure_localtime(dateTime).replace(hour=0,minute=0,second=0,microsecond=0)
[ "def", "getDayStart", "(", "self", ",", "dateTime", ")", ":", "return", "ensure_localtime", "(", "dateTime", ")", ".", "replace", "(", "hour", "=", "0", ",", "minute", "=", "0", ",", "second", "=", "0", ",", "microsecond", "=", "0", ")" ]
Ensure local time and get the beginning of the day
[ "Ensure", "local", "time", "and", "get", "the", "beginning", "of", "the", "day" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L69-L71
train
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestList.getListForEvent
def getListForEvent(self, event=None): ''' Get the list of names associated with a particular event. ''' names = list(self.guestlistname_set.annotate( guestType=Case( When(notes__isnull=False, then=F('notes')), default=Value(ugettext('Manually Added')), ...
python
def getListForEvent(self, event=None): ''' Get the list of names associated with a particular event. ''' names = list(self.guestlistname_set.annotate( guestType=Case( When(notes__isnull=False, then=F('notes')), default=Value(ugettext('Manually Added')), ...
[ "def", "getListForEvent", "(", "self", ",", "event", "=", "None", ")", ":", "names", "=", "list", "(", "self", ".", "guestlistname_set", ".", "annotate", "(", "guestType", "=", "Case", "(", "When", "(", "notes__isnull", "=", "False", ",", "then", "=", ...
Get the list of names associated with a particular event.
[ "Get", "the", "list", "of", "names", "associated", "with", "a", "particular", "event", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L152-L191
train
django-danceschool/django-danceschool
danceschool/guestlist/models.py
GuestListComponent.clean
def clean(self): ''' Either staffCategory or staffMember must be filled in, but not both. ''' if not self.staffCategory and not self.staffMember: raise ValidationError(_('Either staff category or staff member must be specified.')) if self.staffCategory and self.staffMember: ...
python
def clean(self): ''' Either staffCategory or staffMember must be filled in, but not both. ''' if not self.staffCategory and not self.staffMember: raise ValidationError(_('Either staff category or staff member must be specified.')) if self.staffCategory and self.staffMember: ...
[ "def", "clean", "(", "self", ")", ":", "if", "not", "self", ".", "staffCategory", "and", "not", "self", ".", "staffMember", ":", "raise", "ValidationError", "(", "_", "(", "'Either staff category or staff member must be specified.'", ")", ")", "if", "self", ".",...
Either staffCategory or staffMember must be filled in, but not both.
[ "Either", "staffCategory", "or", "staffMember", "must", "be", "filled", "in", "but", "not", "both", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L237-L242
train
django-danceschool/django-danceschool
danceschool/core/ajax.py
updateSeriesAttributes
def updateSeriesAttributes(request): ''' This function handles the filtering of available series classes and seriesteachers when a series is chosen on the Substitute Teacher reporting form. ''' if request.method == 'POST' and request.POST.get('event'): series_option = request.POST.get(...
python
def updateSeriesAttributes(request): ''' This function handles the filtering of available series classes and seriesteachers when a series is chosen on the Substitute Teacher reporting form. ''' if request.method == 'POST' and request.POST.get('event'): series_option = request.POST.get(...
[ "def", "updateSeriesAttributes", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", "and", "request", ".", "POST", ".", "get", "(", "'event'", ")", ":", "series_option", "=", "request", ".", "POST", ".", "get", "(", "'event'", ")",...
This function handles the filtering of available series classes and seriesteachers when a series is chosen on the Substitute Teacher reporting form.
[ "This", "function", "handles", "the", "filtering", "of", "available", "series", "classes", "and", "seriesteachers", "when", "a", "series", "is", "chosen", "on", "the", "Substitute", "Teacher", "reporting", "form", "." ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/ajax.py#L54-L78
train
django-danceschool/django-danceschool
danceschool/core/ajax.py
processCheckIn
def processCheckIn(request): ''' This function handles the Ajax call made when a user is marked as checked in ''' if request.method == 'POST': event_id = request.POST.get('event_id') reg_ids = request.POST.getlist('reg_id') if not event_id: return HttpResp...
python
def processCheckIn(request): ''' This function handles the Ajax call made when a user is marked as checked in ''' if request.method == 'POST': event_id = request.POST.get('event_id') reg_ids = request.POST.getlist('reg_id') if not event_id: return HttpResp...
[ "def", "processCheckIn", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'POST'", ":", "event_id", "=", "request", ".", "POST", ".", "get", "(", "'event_id'", ")", "reg_ids", "=", "request", ".", "POST", ".", "getlist", "(", "'reg_id'", ...
This function handles the Ajax call made when a user is marked as checked in
[ "This", "function", "handles", "the", "Ajax", "call", "made", "when", "a", "user", "is", "marked", "as", "checked", "in" ]
bb08cbf39017a812a5a94bdb4ea34170bf1a30ba
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/ajax.py#L81-L103
train