partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Color.nearest_hue
Returns the name of the nearest named hue. For example, if you supply an indigo color (a color between blue and violet), the return value is "violet". If primary is set to True, the return value is "purple". Primary colors leave out the fuzzy lime, teal, cyan, azure an...
lib/colors/__init__.py
def nearest_hue(self, primary=False): """ Returns the name of the nearest named hue. For example, if you supply an indigo color (a color between blue and violet), the return value is "violet". If primary is set to True, the return value is "purple". Primary colors lea...
def nearest_hue(self, primary=False): """ Returns the name of the nearest named hue. For example, if you supply an indigo color (a color between blue and violet), the return value is "violet". If primary is set to True, the return value is "purple". Primary colors lea...
[ "Returns", "the", "name", "of", "the", "nearest", "named", "hue", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L774-L803
[ "def", "nearest_hue", "(", "self", ",", "primary", "=", "False", ")", ":", "if", "self", ".", "is_black", ":", "return", "\"black\"", "elif", "self", ".", "is_white", ":", "return", "\"white\"", "elif", "self", ".", "is_grey", ":", "return", "\"grey\"", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Color.blend
Returns a mix of two colors.
lib/colors/__init__.py
def blend(self, clr, factor=0.5): """ Returns a mix of two colors. """ r = self.r * (1 - factor) + clr.r * factor g = self.g * (1 - factor) + clr.g * factor b = self.b * (1 - factor) + clr.b * factor a = self.a * (1 - factor) + clr.a * factor return Color(...
def blend(self, clr, factor=0.5): """ Returns a mix of two colors. """ r = self.r * (1 - factor) + clr.r * factor g = self.g * (1 - factor) + clr.g * factor b = self.b * (1 - factor) + clr.b * factor a = self.a * (1 - factor) + clr.a * factor return Color(...
[ "Returns", "a", "mix", "of", "two", "colors", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L805-L813
[ "def", "blend", "(", "self", ",", "clr", ",", "factor", "=", "0.5", ")", ":", "r", "=", "self", ".", "r", "*", "(", "1", "-", "factor", ")", "+", "clr", ".", "r", "*", "factor", "g", "=", "self", ".", "g", "*", "(", "1", "-", "factor", ")...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Color.distance
Returns the Euclidean distance between two colors (0.0-1.0). Consider colors arranged on the color wheel: - hue is the angle of a color along the center - saturation is the distance of a color from the center - brightness is the elevation of a color from the center (i.e. we're...
lib/colors/__init__.py
def distance(self, clr): """ Returns the Euclidean distance between two colors (0.0-1.0). Consider colors arranged on the color wheel: - hue is the angle of a color along the center - saturation is the distance of a color from the center - brightness is the elevation of ...
def distance(self, clr): """ Returns the Euclidean distance between two colors (0.0-1.0). Consider colors arranged on the color wheel: - hue is the angle of a color along the center - saturation is the distance of a color from the center - brightness is the elevation of ...
[ "Returns", "the", "Euclidean", "distance", "between", "two", "colors", "(", "0", ".", "0", "-", "1", ".", "0", ")", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L815-L832
[ "def", "distance", "(", "self", ",", "clr", ")", ":", "coord", "=", "lambda", "a", ",", "d", ":", "(", "cos", "(", "radians", "(", "a", ")", ")", "*", "d", ",", "sin", "(", "radians", "(", "a", ")", ")", "*", "d", ")", "x0", ",", "y0", "=...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Color.swatch
Rectangle swatch for this color.
lib/colors/__init__.py
def swatch(self, x, y, w=35, h=35, roundness=0): """ Rectangle swatch for this color. """ _ctx.fill(self) _ctx.rect(x, y, w, h, roundness)
def swatch(self, x, y, w=35, h=35, roundness=0): """ Rectangle swatch for this color. """ _ctx.fill(self) _ctx.rect(x, y, w, h, roundness)
[ "Rectangle", "swatch", "for", "this", "color", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L834-L839
[ "def", "swatch", "(", "self", ",", "x", ",", "y", ",", "w", "=", "35", ",", "h", "=", "35", ",", "roundness", "=", "0", ")", ":", "_ctx", ".", "fill", "(", "self", ")", "_ctx", ".", "rect", "(", "x", ",", "y", ",", "w", ",", "h", ",", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.image_to_rgb
Returns a list of colors based on pixel values in the image. The Core Image library must be present to determine pixel colors. F. Albers: http://nodebox.net/code/index.php/shared_2007-06-11-11-37-05
lib/colors/__init__.py
def image_to_rgb(self, path, n=10): """ Returns a list of colors based on pixel values in the image. The Core Image library must be present to determine pixel colors. F. Albers: http://nodebox.net/code/index.php/shared_2007-06-11-11-37-05 """ from PIL import Image ...
def image_to_rgb(self, path, n=10): """ Returns a list of colors based on pixel values in the image. The Core Image library must be present to determine pixel colors. F. Albers: http://nodebox.net/code/index.php/shared_2007-06-11-11-37-05 """ from PIL import Image ...
[ "Returns", "a", "list", "of", "colors", "based", "on", "pixel", "values", "in", "the", "image", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L974-L994
[ "def", "image_to_rgb", "(", "self", ",", "path", ",", "n", "=", "10", ")", ":", "from", "PIL", "import", "Image", "img", "=", "Image", ".", "open", "(", "path", ")", "p", "=", "img", ".", "getdata", "(", ")", "f", "=", "lambda", "p", ":", "choi...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.context_to_rgb
Returns the colors that have the given word in their context. For example, the word "anger" appears in black, orange and red contexts, so the list will contain those three colors.
lib/colors/__init__.py
def context_to_rgb(self, str): """ Returns the colors that have the given word in their context. For example, the word "anger" appears in black, orange and red contexts, so the list will contain those three colors. """ matches = [] for clr in context: ...
def context_to_rgb(self, str): """ Returns the colors that have the given word in their context. For example, the word "anger" appears in black, orange and red contexts, so the list will contain those three colors. """ matches = [] for clr in context: ...
[ "Returns", "the", "colors", "that", "have", "the", "given", "word", "in", "their", "context", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L996-L1014
[ "def", "context_to_rgb", "(", "self", ",", "str", ")", ":", "matches", "=", "[", "]", "for", "clr", "in", "context", ":", "tags", "=", "context", "[", "clr", "]", "for", "tag", "in", "tags", ":", "if", "tag", ".", "startswith", "(", "str", ")", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList._context
Returns the intersection of each color's context. Get the nearest named hue of each color, and finds overlapping tags in each hue's colors. For example, a list containing yellow, deeppink and olive yields: femininity, friendship, happiness, joy.
lib/colors/__init__.py
def _context(self): """ Returns the intersection of each color's context. Get the nearest named hue of each color, and finds overlapping tags in each hue's colors. For example, a list containing yellow, deeppink and olive yields: femininity, friendship, happiness, joy. ...
def _context(self): """ Returns the intersection of each color's context. Get the nearest named hue of each color, and finds overlapping tags in each hue's colors. For example, a list containing yellow, deeppink and olive yields: femininity, friendship, happiness, joy. ...
[ "Returns", "the", "intersection", "of", "each", "color", "s", "context", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1016-L1050
[ "def", "_context", "(", "self", ")", ":", "tags1", "=", "None", "for", "clr", "in", "self", ":", "overlap", "=", "[", "]", "if", "clr", ".", "is_black", ":", "name", "=", "\"black\"", "elif", "clr", ".", "is_white", ":", "name", "=", "\"white\"", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.copy
Returns a deep copy of the list.
lib/colors/__init__.py
def copy(self): """ Returns a deep copy of the list. """ return ColorList( [color(clr.r, clr.g, clr.b, clr.a, mode="rgb") for clr in self], name=self.name, tags=self.tags )
def copy(self): """ Returns a deep copy of the list. """ return ColorList( [color(clr.r, clr.g, clr.b, clr.a, mode="rgb") for clr in self], name=self.name, tags=self.tags )
[ "Returns", "a", "deep", "copy", "of", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1054-L1063
[ "def", "copy", "(", "self", ")", ":", "return", "ColorList", "(", "[", "color", "(", "clr", ".", "r", ",", "clr", ".", "g", ",", "clr", ".", "b", ",", "clr", ".", "a", ",", "mode", "=", "\"rgb\"", ")", "for", "clr", "in", "self", "]", ",", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList._darkest
Returns the darkest color from the list. Knowing the contrast between a light and a dark swatch can help us decide how to display readable typography.
lib/colors/__init__.py
def _darkest(self): """ Returns the darkest color from the list. Knowing the contrast between a light and a dark swatch can help us decide how to display readable typography. """ min, n = (1.0, 1.0, 1.0), 3.0 for clr in self: if clr.r + clr.g + clr.b...
def _darkest(self): """ Returns the darkest color from the list. Knowing the contrast between a light and a dark swatch can help us decide how to display readable typography. """ min, n = (1.0, 1.0, 1.0), 3.0 for clr in self: if clr.r + clr.g + clr.b...
[ "Returns", "the", "darkest", "color", "from", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1065-L1078
[ "def", "_darkest", "(", "self", ")", ":", "min", ",", "n", "=", "(", "1.0", ",", "1.0", ",", "1.0", ")", ",", "3.0", "for", "clr", "in", "self", ":", "if", "clr", ".", "r", "+", "clr", ".", "g", "+", "clr", ".", "b", "<", "n", ":", "min",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList._average
Returns one average color for the colors in the list.
lib/colors/__init__.py
def _average(self): """ Returns one average color for the colors in the list. """ r, g, b, a = 0, 0, 0, 0 for clr in self: r += clr.r g += clr.g b += clr.b a += clr.alpha r /= len(self) g /= len(self) b /= l...
def _average(self): """ Returns one average color for the colors in the list. """ r, g, b, a = 0, 0, 0, 0 for clr in self: r += clr.r g += clr.g b += clr.b a += clr.alpha r /= len(self) g /= len(self) b /= l...
[ "Returns", "one", "average", "color", "for", "the", "colors", "in", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1095-L1111
[ "def", "_average", "(", "self", ")", ":", "r", ",", "g", ",", "b", ",", "a", "=", "0", ",", "0", ",", "0", ",", "0", "for", "clr", "in", "self", ":", "r", "+=", "clr", ".", "r", "g", "+=", "clr", ".", "g", "b", "+=", "clr", ".", "b", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.sort_by_distance
Returns a list with the smallest distance between two neighboring colors. The algorithm has a factorial complexity so it may run slow.
lib/colors/__init__.py
def sort_by_distance(self, reversed=False): """ Returns a list with the smallest distance between two neighboring colors. The algorithm has a factorial complexity so it may run slow. """ if len(self) == 0: return ColorList() # Find the darkest color in the list. ...
def sort_by_distance(self, reversed=False): """ Returns a list with the smallest distance between two neighboring colors. The algorithm has a factorial complexity so it may run slow. """ if len(self) == 0: return ColorList() # Find the darkest color in the list. ...
[ "Returns", "a", "list", "with", "the", "smallest", "distance", "between", "two", "neighboring", "colors", ".", "The", "algorithm", "has", "a", "factorial", "complexity", "so", "it", "may", "run", "slow", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1127-L1160
[ "def", "sort_by_distance", "(", "self", ",", "reversed", "=", "False", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "ColorList", "(", ")", "# Find the darkest color in the list.", "root", "=", "self", "[", "0", "]", "for", "clr", "i...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList._sorted_copy
Returns a sorted copy with the colors arranged according to the given comparison.
lib/colors/__init__.py
def _sorted_copy(self, comparison, reversed=False): """ Returns a sorted copy with the colors arranged according to the given comparison. """ sorted = self.copy() _list.sort(sorted, comparison) if reversed: _list.reverse(sorted) return sorted
def _sorted_copy(self, comparison, reversed=False): """ Returns a sorted copy with the colors arranged according to the given comparison. """ sorted = self.copy() _list.sort(sorted, comparison) if reversed: _list.reverse(sorted) return sorted
[ "Returns", "a", "sorted", "copy", "with", "the", "colors", "arranged", "according", "to", "the", "given", "comparison", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1162-L1170
[ "def", "_sorted_copy", "(", "self", ",", "comparison", ",", "reversed", "=", "False", ")", ":", "sorted", "=", "self", ".", "copy", "(", ")", "_list", ".", "sort", "(", "sorted", ",", "comparison", ")", "if", "reversed", ":", "_list", ".", "reverse", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.cluster_sort
Sorts the list by cmp1, then cuts it into n pieces which are sorted by cmp2. If you want to cluster by hue, use n=12 (since there are 12 primary/secondary hues). The resulting list will not contain n even slices: n is used rather to slice up the cmp1 property of the colors, e.g. cmp1=br...
lib/colors/__init__.py
def cluster_sort(self, cmp1="hue", cmp2="brightness", reversed=False, n=12): """ Sorts the list by cmp1, then cuts it into n pieces which are sorted by cmp2. If you want to cluster by hue, use n=12 (since there are 12 primary/secondary hues). The resulting list will not contain n even s...
def cluster_sort(self, cmp1="hue", cmp2="brightness", reversed=False, n=12): """ Sorts the list by cmp1, then cuts it into n pieces which are sorted by cmp2. If you want to cluster by hue, use n=12 (since there are 12 primary/secondary hues). The resulting list will not contain n even s...
[ "Sorts", "the", "list", "by", "cmp1", "then", "cuts", "it", "into", "n", "pieces", "which", "are", "sorted", "by", "cmp2", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1216-L1237
[ "def", "cluster_sort", "(", "self", ",", "cmp1", "=", "\"hue\"", ",", "cmp2", "=", "\"brightness\"", ",", "reversed", "=", "False", ",", "n", "=", "12", ")", ":", "sorted", "=", "self", ".", "sort", "(", "cmp1", ")", "clusters", "=", "ColorList", "("...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.reverse
Returns a reversed copy of the list.
lib/colors/__init__.py
def reverse(self): """ Returns a reversed copy of the list. """ colors = ColorList.copy(self) _list.reverse(colors) return colors
def reverse(self): """ Returns a reversed copy of the list. """ colors = ColorList.copy(self) _list.reverse(colors) return colors
[ "Returns", "a", "reversed", "copy", "of", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1241-L1247
[ "def", "reverse", "(", "self", ")", ":", "colors", "=", "ColorList", ".", "copy", "(", "self", ")", "_list", ".", "reverse", "(", "colors", ")", "return", "colors" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.repeat
Returns a list that is a repetition of the given list. When oscillate is True, moves from the end back to the beginning, and then from the beginning to the end, and so on.
lib/colors/__init__.py
def repeat(self, n=2, oscillate=False, callback=None): """ Returns a list that is a repetition of the given list. When oscillate is True, moves from the end back to the beginning, and then from the beginning to the end, and so on. """ colorlist = ColorList() ...
def repeat(self, n=2, oscillate=False, callback=None): """ Returns a list that is a repetition of the given list. When oscillate is True, moves from the end back to the beginning, and then from the beginning to the end, and so on. """ colorlist = ColorList() ...
[ "Returns", "a", "list", "that", "is", "a", "repetition", "of", "the", "given", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1249-L1264
[ "def", "repeat", "(", "self", ",", "n", "=", "2", ",", "oscillate", "=", "False", ",", "callback", "=", "None", ")", ":", "colorlist", "=", "ColorList", "(", ")", "colors", "=", "ColorList", ".", "copy", "(", "self", ")", "for", "i", "in", "_range"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.swatch
Rectangle swatches for all the colors in the list.
lib/colors/__init__.py
def swatch(self, x, y, w=35, h=35, padding=0, roundness=0): """ Rectangle swatches for all the colors in the list. """ for clr in self: clr.swatch(x, y, w, h, roundness) y += h + padding
def swatch(self, x, y, w=35, h=35, padding=0, roundness=0): """ Rectangle swatches for all the colors in the list. """ for clr in self: clr.swatch(x, y, w, h, roundness) y += h + padding
[ "Rectangle", "swatches", "for", "all", "the", "colors", "in", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1315-L1321
[ "def", "swatch", "(", "self", ",", "x", ",", "y", ",", "w", "=", "35", ",", "h", "=", "35", ",", "padding", "=", "0", ",", "roundness", "=", "0", ")", ":", "for", "clr", "in", "self", ":", "clr", ".", "swatch", "(", "x", ",", "y", ",", "w...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorList.swarm
Fancy random ovals for all the colors in the list.
lib/colors/__init__.py
def swarm(self, x, y, r=100): """ Fancy random ovals for all the colors in the list. """ sc = _ctx.stroke(0, 0, 0, 0) sw = _ctx.strokewidth(0) _ctx.push() _ctx.transform(_ctx.CORNER) _ctx.translate(x, y) for i in _range(r * 3): clr = ...
def swarm(self, x, y, r=100): """ Fancy random ovals for all the colors in the list. """ sc = _ctx.stroke(0, 0, 0, 0) sw = _ctx.strokewidth(0) _ctx.push() _ctx.transform(_ctx.CORNER) _ctx.translate(x, y) for i in _range(r * 3): clr = ...
[ "Fancy", "random", "ovals", "for", "all", "the", "colors", "in", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1325-L1354
[ "def", "swarm", "(", "self", ",", "x", ",", "y", ",", "r", "=", "100", ")", ":", "sc", "=", "_ctx", ".", "stroke", "(", "0", ",", "0", ",", "0", ",", "0", ")", "sw", "=", "_ctx", ".", "strokewidth", "(", "0", ")", "_ctx", ".", "push", "("...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Gradient._interpolate
Returns intermediary colors for given list of colors.
lib/colors/__init__.py
def _interpolate(self, colors, n=100): """ Returns intermediary colors for given list of colors. """ gradient = [] for i in _range(n): l = len(colors) - 1 x = int(1.0 * i / n * l) x = min(x + 0, l) y = min(x + 1, l) base = 1....
def _interpolate(self, colors, n=100): """ Returns intermediary colors for given list of colors. """ gradient = [] for i in _range(n): l = len(colors) - 1 x = int(1.0 * i / n * l) x = min(x + 0, l) y = min(x + 1, l) base = 1....
[ "Returns", "intermediary", "colors", "for", "given", "list", "of", "colors", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1781-L1803
[ "def", "_interpolate", "(", "self", ",", "colors", ",", "n", "=", "100", ")", ":", "gradient", "=", "[", "]", "for", "i", "in", "_range", "(", "n", ")", ":", "l", "=", "len", "(", "colors", ")", "-", "1", "x", "=", "int", "(", "1.0", "*", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Gradient._cache
Populates the list with a number of gradient colors. The list has Gradient.steps colors that interpolate between the fixed base Gradient.colors. The spread parameter controls the midpoint of the gradient, you can shift it right and left. A separate gradient is calculated for ea...
lib/colors/__init__.py
def _cache(self): """ Populates the list with a number of gradient colors. The list has Gradient.steps colors that interpolate between the fixed base Gradient.colors. The spread parameter controls the midpoint of the gradient, you can shift it right and left. A separate...
def _cache(self): """ Populates the list with a number of gradient colors. The list has Gradient.steps colors that interpolate between the fixed base Gradient.colors. The spread parameter controls the midpoint of the gradient, you can shift it right and left. A separate...
[ "Populates", "the", "list", "with", "a", "number", "of", "gradient", "colors", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1805-L1841
[ "def", "_cache", "(", "self", ")", ":", "n", "=", "self", ".", "steps", "# Only one color in base list.", "if", "len", "(", "self", ".", "_colors", ")", "==", "1", ":", "ColorList", ".", "__init__", "(", "self", ",", "[", "self", ".", "_colors", "[", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorRange.copy
Returns a copy of the range. Optionally, supply a color to get a range copy limited to the hue of that color.
lib/colors/__init__.py
def copy(self, clr=None, d=0.0): """ Returns a copy of the range. Optionally, supply a color to get a range copy limited to the hue of that color. """ cr = ColorRange() cr.name = self.name cr.h = deepcopy(self.h) cr.s = deepcopy(self.s) c...
def copy(self, clr=None, d=0.0): """ Returns a copy of the range. Optionally, supply a color to get a range copy limited to the hue of that color. """ cr = ColorRange() cr.name = self.name cr.h = deepcopy(self.h) cr.s = deepcopy(self.s) c...
[ "Returns", "a", "copy", "of", "the", "range", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2015-L2038
[ "def", "copy", "(", "self", ",", "clr", "=", "None", ",", "d", "=", "0.0", ")", ":", "cr", "=", "ColorRange", "(", ")", "cr", ".", "name", "=", "self", ".", "name", "cr", ".", "h", "=", "deepcopy", "(", "self", ".", "h", ")", "cr", ".", "s"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorRange.color
Returns a color with random values in the defined h, s b, a ranges. If a color is given, use that color's hue and alpha, and generate its saturation and brightness from the shade. The hue is varied with the given d. In this way you could have a "warm" color range that returns a...
lib/colors/__init__.py
def color(self, clr=None, d=0.035): """ Returns a color with random values in the defined h, s b, a ranges. If a color is given, use that color's hue and alpha, and generate its saturation and brightness from the shade. The hue is varied with the given d. In this way yo...
def color(self, clr=None, d=0.035): """ Returns a color with random values in the defined h, s b, a ranges. If a color is given, use that color's hue and alpha, and generate its saturation and brightness from the shade. The hue is varied with the given d. In this way yo...
[ "Returns", "a", "color", "with", "random", "values", "in", "the", "defined", "h", "s", "b", "a", "ranges", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2040-L2078
[ "def", "color", "(", "self", ",", "clr", "=", "None", ",", "d", "=", "0.035", ")", ":", "# Revert to grayscale for black, white and grey hues.", "if", "clr", "!=", "None", "and", "not", "isinstance", "(", "clr", ",", "Color", ")", ":", "clr", "=", "color",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorRange.contains
Returns True if the given color is part of this color range. Check whether each h, s, b, a component of the color falls within the defined range for that component. If the given color is grayscale, checks against the definitions for black and white.
lib/colors/__init__.py
def contains(self, clr): """ Returns True if the given color is part of this color range. Check whether each h, s, b, a component of the color falls within the defined range for that component. If the given color is grayscale, checks against the definitions for black an...
def contains(self, clr): """ Returns True if the given color is part of this color range. Check whether each h, s, b, a component of the color falls within the defined range for that component. If the given color is grayscale, checks against the definitions for black an...
[ "Returns", "True", "if", "the", "given", "color", "is", "part", "of", "this", "color", "range", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2086-L2119
[ "def", "contains", "(", "self", ",", "clr", ")", ":", "if", "not", "isinstance", "(", "clr", ",", "Color", ")", ":", "return", "False", "if", "not", "isinstance", "(", "clr", ",", "_list", ")", ":", "clr", "=", "[", "clr", "]", "for", "clr", "in"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme._weight_by_hue
Returns a list of (hue, ranges, total weight, normalized total weight)-tuples. ColorTheme is made up out of (color, range, weight) tuples. For consistency with XML-output in the old Prism format (i.e. <color>s made up of <shade>s) we need a group weight per different hue. The s...
lib/colors/__init__.py
def _weight_by_hue(self): """ Returns a list of (hue, ranges, total weight, normalized total weight)-tuples. ColorTheme is made up out of (color, range, weight) tuples. For consistency with XML-output in the old Prism format (i.e. <color>s made up of <shade>s) we need a group ...
def _weight_by_hue(self): """ Returns a list of (hue, ranges, total weight, normalized total weight)-tuples. ColorTheme is made up out of (color, range, weight) tuples. For consistency with XML-output in the old Prism format (i.e. <color>s made up of <shade>s) we need a group ...
[ "Returns", "a", "list", "of", "(", "hue", "ranges", "total", "weight", "normalized", "total", "weight", ")", "-", "tuples", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2603-L2635
[ "def", "_weight_by_hue", "(", "self", ")", ":", "grouped", "=", "{", "}", "weights", "=", "[", "]", "for", "clr", ",", "rng", ",", "weight", "in", "self", ".", "ranges", ":", "h", "=", "clr", ".", "nearest_hue", "(", "primary", "=", "False", ")", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme._xml
Returns the color information as XML. The XML has the following structure: <colors query=""> <color name="" weight="" /> <rgb r="" g="" b="" /> <shade name="" weight="" /> </color> </colors> Notice that ranges are stored by name a...
lib/colors/__init__.py
def _xml(self): """ Returns the color information as XML. The XML has the following structure: <colors query=""> <color name="" weight="" /> <rgb r="" g="" b="" /> <shade name="" weight="" /> </color> </colors> Not...
def _xml(self): """ Returns the color information as XML. The XML has the following structure: <colors query=""> <color name="" weight="" /> <rgb r="" g="" b="" /> <shade name="" weight="" /> </color> </colors> Not...
[ "Returns", "the", "color", "information", "as", "XML", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2637-L2669
[ "def", "_xml", "(", "self", ")", ":", "grouped", "=", "self", ".", "_weight_by_hue", "(", ")", "xml", "=", "\"<colors query=\\\"\"", "+", "self", ".", "name", "+", "\"\\\" tags=\\\"\"", "+", "\", \"", ".", "join", "(", "self", ".", "tags", ")", "+", "\...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme._save
Saves the color information in the cache as XML.
lib/colors/__init__.py
def _save(self): """ Saves the color information in the cache as XML. """ if not os.path.exists(self.cache): os.makedirs(self.cache) path = os.path.join(self.cache, self.name + ".xml") f = open(path, "w") f.write(self.xml) f.close()
def _save(self): """ Saves the color information in the cache as XML. """ if not os.path.exists(self.cache): os.makedirs(self.cache) path = os.path.join(self.cache, self.name + ".xml") f = open(path, "w") f.write(self.xml) f.close()
[ "Saves", "the", "color", "information", "in", "the", "cache", "as", "XML", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2673-L2683
[ "def", "_save", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "cache", ")", ":", "os", ".", "makedirs", "(", "self", ".", "cache", ")", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme._load
Loads a theme from aggregated web data. The data must be old-style Prism XML: <color>s consisting of <shade>s. Colors named "blue" will be overridden with the blue parameter. archive can be a file like object (e.g. a ZipFile) and will be used along with 'member' if specified.
lib/colors/__init__.py
def _load(self, top=5, blue="blue", archive=None, member=None): """ Loads a theme from aggregated web data. The data must be old-style Prism XML: <color>s consisting of <shade>s. Colors named "blue" will be overridden with the blue parameter. archive can be a file like object (...
def _load(self, top=5, blue="blue", archive=None, member=None): """ Loads a theme from aggregated web data. The data must be old-style Prism XML: <color>s consisting of <shade>s. Colors named "blue" will be overridden with the blue parameter. archive can be a file like object (...
[ "Loads", "a", "theme", "from", "aggregated", "web", "data", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2685-L2731
[ "def", "_load", "(", "self", ",", "top", "=", "5", ",", "blue", "=", "\"blue\"", ",", "archive", "=", "None", ",", "member", "=", "None", ")", ":", "if", "archive", "is", "None", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", "....
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme.color
Returns a random color within the theme. Fetches a random range (the weight is taken into account, so ranges with a bigger weight have a higher chance of propagating) and hues it with the associated color.
lib/colors/__init__.py
def color(self, d=0.035): """ Returns a random color within the theme. Fetches a random range (the weight is taken into account, so ranges with a bigger weight have a higher chance of propagating) and hues it with the associated color. """ s = sum([w for clr, rng...
def color(self, d=0.035): """ Returns a random color within the theme. Fetches a random range (the weight is taken into account, so ranges with a bigger weight have a higher chance of propagating) and hues it with the associated color. """ s = sum([w for clr, rng...
[ "Returns", "a", "random", "color", "within", "the", "theme", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2733-L2747
[ "def", "color", "(", "self", ",", "d", "=", "0.035", ")", ":", "s", "=", "sum", "(", "[", "w", "for", "clr", ",", "rng", ",", "w", "in", "self", ".", "ranges", "]", ")", "r", "=", "random", "(", ")", "for", "clr", ",", "rng", ",", "weight",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme.colors
Returns a number of random colors from the theme.
lib/colors/__init__.py
def colors(self, n=10, d=0.035): """ Returns a number of random colors from the theme. """ s = sum([w for clr, rng, w in self.ranges]) colors = colorlist() for i in _range(n): r = random() for clr, rng, weight in self.ranges: if wei...
def colors(self, n=10, d=0.035): """ Returns a number of random colors from the theme. """ s = sum([w for clr, rng, w in self.ranges]) colors = colorlist() for i in _range(n): r = random() for clr, rng, weight in self.ranges: if wei...
[ "Returns", "a", "number", "of", "random", "colors", "from", "the", "theme", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2749-L2762
[ "def", "colors", "(", "self", ",", "n", "=", "10", ",", "d", "=", "0.035", ")", ":", "s", "=", "sum", "(", "[", "w", "for", "clr", ",", "rng", ",", "w", "in", "self", ".", "ranges", "]", ")", "colors", "=", "colorlist", "(", ")", "for", "i"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme.recombine
Genetic recombination of two themes using cut and splice technique.
lib/colors/__init__.py
def recombine(self, other, d=0.7): """ Genetic recombination of two themes using cut and splice technique. """ a, b = self, other d1 = max(0, min(d, 1)) d2 = d1 c = ColorTheme( name=a.name[:int(len(a.name) * d1)] + b.name[int(len(b.na...
def recombine(self, other, d=0.7): """ Genetic recombination of two themes using cut and splice technique. """ a, b = self, other d1 = max(0, min(d, 1)) d2 = d1 c = ColorTheme( name=a.name[:int(len(a.name) * d1)] + b.name[int(len(b.na...
[ "Genetic", "recombination", "of", "two", "themes", "using", "cut", "and", "splice", "technique", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2820-L2840
[ "def", "recombine", "(", "self", ",", "other", ",", "d", "=", "0.7", ")", ":", "a", ",", "b", "=", "self", ",", "other", "d1", "=", "max", "(", "0", ",", "min", "(", "d", ",", "1", ")", ")", "d2", "=", "d1", "c", "=", "ColorTheme", "(", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ColorTheme.swatch
Draws a weighted swatch with approximately n columns and rows. When the grouped parameter is True, colors are grouped in blocks of the same hue (also see the _weight_by_hue() method).
lib/colors/__init__.py
def swatch(self, x, y, w=35, h=35, padding=4, roundness=0, n=12, d=0.035, grouped=None): """ Draws a weighted swatch with approximately n columns and rows. When the grouped parameter is True, colors are grouped in blocks of the same hue (also see the _weight_by_hue() method). ""...
def swatch(self, x, y, w=35, h=35, padding=4, roundness=0, n=12, d=0.035, grouped=None): """ Draws a weighted swatch with approximately n columns and rows. When the grouped parameter is True, colors are grouped in blocks of the same hue (also see the _weight_by_hue() method). ""...
[ "Draws", "a", "weighted", "swatch", "with", "approximately", "n", "columns", "and", "rows", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2842-L2889
[ "def", "swatch", "(", "self", ",", "x", ",", "y", ",", "w", "=", "35", ",", "h", "=", "35", ",", "padding", "=", "4", ",", "roundness", "=", "0", ",", "n", "=", "12", ",", "d", "=", "0.035", ",", "grouped", "=", "None", ")", ":", "if", "g...
d554c1765c1899fa25727c9fc6805d221585562b
valid
TuioProfile.fseq
fseq messages associate a unique frame id with a set of set and alive messages
lib/tuio/profiles.py
def fseq(self, client, message): """ fseq messages associate a unique frame id with a set of set and alive messages """ client.last_frame = client.current_frame client.current_frame = message[3]
def fseq(self, client, message): """ fseq messages associate a unique frame id with a set of set and alive messages """ client.last_frame = client.current_frame client.current_frame = message[3]
[ "fseq", "messages", "associate", "a", "unique", "frame", "id", "with", "a", "set", "of", "set", "and", "alive", "messages" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/profiles.py#L30-L36
[ "def", "fseq", "(", "self", ",", "client", ",", "message", ")", ":", "client", ".", "last_frame", "=", "client", ".", "current_frame", "client", ".", "current_frame", "=", "message", "[", "3", "]" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
TuioProfile.objs
Returns a generator list of tracked objects which are recognized with this profile and are in the current session.
lib/tuio/profiles.py
def objs(self): """ Returns a generator list of tracked objects which are recognized with this profile and are in the current session. """ for obj in self.objects.itervalues(): if obj.sessionid in self.sessions: yield obj
def objs(self): """ Returns a generator list of tracked objects which are recognized with this profile and are in the current session. """ for obj in self.objects.itervalues(): if obj.sessionid in self.sessions: yield obj
[ "Returns", "a", "generator", "list", "of", "tracked", "objects", "which", "are", "recognized", "with", "this", "profile", "and", "are", "in", "the", "current", "session", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/profiles.py#L38-L45
[ "def", "objs", "(", "self", ")", ":", "for", "obj", "in", "self", ".", "objects", ".", "itervalues", "(", ")", ":", "if", "obj", ".", "sessionid", "in", "self", ".", "sessions", ":", "yield", "obj" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._append_element
Append a render function and the parameters to pass an equivilent PathElement, or the PathElement itself.
shoebot/data/bezier.py
def _append_element(self, render_func, pe): ''' Append a render function and the parameters to pass an equivilent PathElement, or the PathElement itself. ''' self._render_funcs.append(render_func) self._elements.append(pe)
def _append_element(self, render_func, pe): ''' Append a render function and the parameters to pass an equivilent PathElement, or the PathElement itself. ''' self._render_funcs.append(render_func) self._elements.append(pe)
[ "Append", "a", "render", "function", "and", "the", "parameters", "to", "pass", "an", "equivilent", "PathElement", "or", "the", "PathElement", "itself", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L92-L98
[ "def", "_append_element", "(", "self", ",", "render_func", ",", "pe", ")", ":", "self", ".", "_render_funcs", ".", "append", "(", "render_func", ")", "self", ".", "_elements", ".", "append", "(", "pe", ")" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._get_bounds
Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.
shoebot/data/bezier.py
def _get_bounds(self): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._bounds: return self._bounds record_surface = cairo.RecordingSurface(cairo.CONTE...
def _get_bounds(self): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._bounds: return self._bounds record_surface = cairo.RecordingSurface(cairo.CONTE...
[ "Return", "cached", "bounds", "of", "this", "Grob", ".", "If", "bounds", "are", "not", "cached", "render", "to", "a", "meta", "surface", "and", "keep", "the", "meta", "surface", "and", "bounds", "cached", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L189-L203
[ "def", "_get_bounds", "(", "self", ")", ":", "if", "self", ".", "_bounds", ":", "return", "self", ".", "_bounds", "record_surface", "=", "cairo", ".", "RecordingSurface", "(", "cairo", ".", "CONTENT_COLOR_ALPHA", ",", "(", "-", "1", ",", "-", "1", ",", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath.contains
Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.
shoebot/data/bezier.py
def contains(self, x, y): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._bounds: return self._bounds record_surface = cairo.RecordingSurface(cairo.CO...
def contains(self, x, y): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._bounds: return self._bounds record_surface = cairo.RecordingSurface(cairo.CO...
[ "Return", "cached", "bounds", "of", "this", "Grob", ".", "If", "bounds", "are", "not", "cached", "render", "to", "a", "meta", "surface", "and", "keep", "the", "meta", "surface", "and", "bounds", "cached", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L209-L223
[ "def", "contains", "(", "self", ",", "x", ",", "y", ")", ":", "if", "self", ".", "_bounds", ":", "return", "self", ".", "_bounds", "record_surface", "=", "cairo", ".", "RecordingSurface", "(", "cairo", ".", "CONTENT_COLOR_ALPHA", ",", "(", "-", "1", ",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._get_center
Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached.
shoebot/data/bezier.py
def _get_center(self): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._center: return self._center # get the center point (x1, y1, x2, y2) = s...
def _get_center(self): ''' Return cached bounds of this Grob. If bounds are not cached, render to a meta surface, and keep the meta surface and bounds cached. ''' if self._center: return self._center # get the center point (x1, y1, x2, y2) = s...
[ "Return", "cached", "bounds", "of", "this", "Grob", ".", "If", "bounds", "are", "not", "cached", "render", "to", "a", "meta", "surface", "and", "keep", "the", "meta", "surface", "and", "bounds", "cached", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L225-L243
[ "def", "_get_center", "(", "self", ")", ":", "if", "self", ".", "_center", ":", "return", "self", ".", "_center", "# get the center point", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", "=", "self", ".", "_get_bounds", "(", ")", "x", "=", "(", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._render_closure
Use a closure so that draw attributes can be saved
shoebot/data/bezier.py
def _render_closure(self): '''Use a closure so that draw attributes can be saved''' fillcolor = self.fill strokecolor = self.stroke strokewidth = self.strokewidth def _render(cairo_ctx): ''' At the moment this is based on cairo. TODO: Need to...
def _render_closure(self): '''Use a closure so that draw attributes can be saved''' fillcolor = self.fill strokecolor = self.stroke strokewidth = self.strokewidth def _render(cairo_ctx): ''' At the moment this is based on cairo. TODO: Need to...
[ "Use", "a", "closure", "so", "that", "draw", "attributes", "can", "be", "saved" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L247-L306
[ "def", "_render_closure", "(", "self", ")", ":", "fillcolor", "=", "self", ".", "fill", "strokecolor", "=", "self", ".", "stroke", "strokewidth", "=", "self", ".", "strokewidth", "def", "_render", "(", "cairo_ctx", ")", ":", "'''\n At the moment this ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._get_contours
Returns a list of contours in the path, as BezierPath objects. A contour is a sequence of lines and curves separated from the next contour by a MOVETO. For example, the glyph "o" has two contours: the inner circle and the outer circle.
shoebot/data/bezier.py
def _get_contours(self): """ Returns a list of contours in the path, as BezierPath objects. A contour is a sequence of lines and curves separated from the next contour by a MOVETO. For example, the glyph "o" has two contours: the inner circle and the outer circle. """ # O...
def _get_contours(self): """ Returns a list of contours in the path, as BezierPath objects. A contour is a sequence of lines and curves separated from the next contour by a MOVETO. For example, the glyph "o" has two contours: the inner circle and the outer circle. """ # O...
[ "Returns", "a", "list", "of", "contours", "in", "the", "path", "as", "BezierPath", "objects", ".", "A", "contour", "is", "a", "sequence", "of", "lines", "and", "curves", "separated", "from", "the", "next", "contour", "by", "a", "MOVETO", ".", "For", "exa...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L311-L338
[ "def", "_get_contours", "(", "self", ")", ":", "# Originally from nodebox-gl", "contours", "=", "[", "]", "current_contour", "=", "None", "empty", "=", "True", "for", "i", ",", "el", "in", "enumerate", "(", "self", ".", "_get_elements", "(", ")", ")", ":",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._locate
Locates t on a specific segment in the path. Returns (index, t, PathElement) A path is a combination of lines and curves (segments). The returned index indicates the start of the segment that contains point t. The returned t is the absolute time on that segment, ...
shoebot/data/bezier.py
def _locate(self, t, segments=None): """ Locates t on a specific segment in the path. Returns (index, t, PathElement) A path is a combination of lines and curves (segments). The returned index indicates the start of the segment that contains point t. The returned ...
def _locate(self, t, segments=None): """ Locates t on a specific segment in the path. Returns (index, t, PathElement) A path is a combination of lines and curves (segments). The returned index indicates the start of the segment that contains point t. The returned ...
[ "Locates", "t", "on", "a", "specific", "segment", "in", "the", "path", ".", "Returns", "(", "index", "t", "PathElement", ")", "A", "path", "is", "a", "combination", "of", "lines", "and", "curves", "(", "segments", ")", ".", "The", "returned", "index", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L340-L370
[ "def", "_locate", "(", "self", ",", "t", ",", "segments", "=", "None", ")", ":", "# Originally from nodebox-gl", "if", "segments", "is", "None", ":", "segments", "=", "self", ".", "_segment_lengths", "(", "relative", "=", "True", ")", "if", "len", "(", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath.point
Returns the PathElement at time t (0.0-1.0) on the path. Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls. Gets the point on that segment. When you supp...
shoebot/data/bezier.py
def point(self, t, segments=None): """ Returns the PathElement at time t (0.0-1.0) on the path. Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls...
def point(self, t, segments=None): """ Returns the PathElement at time t (0.0-1.0) on the path. Returns coordinates for point at t on the path. Gets the length of the path, based on the length of each curve and line in the path. Determines in what segment t falls...
[ "Returns", "the", "PathElement", "at", "time", "t", "(", "0", ".", "0", "-", "1", ".", "0", ")", "on", "the", "path", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L372-L408
[ "def", "point", "(", "self", ",", "t", ",", "segments", "=", "None", ")", ":", "# Originally from nodebox-gl", "if", "len", "(", "self", ".", "_elements", ")", "==", "0", ":", "raise", "PathError", "(", "\"The given path is empty\"", ")", "if", "self", "."...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath.points
Returns an iterator with a list of calculated points for the path. To omit the last point on closed paths: end=1-1.0/amount
shoebot/data/bezier.py
def points(self, amount=100, start=0.0, end=1.0, segments=None): """ Returns an iterator with a list of calculated points for the path. To omit the last point on closed paths: end=1-1.0/amount """ # Originally from nodebox-gl if len(self._elements) == 0: raise Pat...
def points(self, amount=100, start=0.0, end=1.0, segments=None): """ Returns an iterator with a list of calculated points for the path. To omit the last point on closed paths: end=1-1.0/amount """ # Originally from nodebox-gl if len(self._elements) == 0: raise Pat...
[ "Returns", "an", "iterator", "with", "a", "list", "of", "calculated", "points", "for", "the", "path", ".", "To", "omit", "the", "last", "point", "on", "closed", "paths", ":", "end", "=", "1", "-", "1", ".", "0", "/", "amount" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L410-L426
[ "def", "points", "(", "self", ",", "amount", "=", "100", ",", "start", "=", "0.0", ",", "end", "=", "1.0", ",", "segments", "=", "None", ")", ":", "# Originally from nodebox-gl", "if", "len", "(", "self", ".", "_elements", ")", "==", "0", ":", "raise...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._linepoint
Returns coordinates for point at t on the line. Calculates the coordinates of x and y for a point at t on a straight line. The t parameter is a number between 0.0 and 1.0, x0 and y0 define the starting point of the line, x1 and y1 the ending point of the line.
shoebot/data/bezier.py
def _linepoint(self, t, x0, y0, x1, y1): """ Returns coordinates for point at t on the line. Calculates the coordinates of x and y for a point at t on a straight line. The t parameter is a number between 0.0 and 1.0, x0 and y0 define the starting point of the line, ...
def _linepoint(self, t, x0, y0, x1, y1): """ Returns coordinates for point at t on the line. Calculates the coordinates of x and y for a point at t on a straight line. The t parameter is a number between 0.0 and 1.0, x0 and y0 define the starting point of the line, ...
[ "Returns", "coordinates", "for", "point", "at", "t", "on", "the", "line", ".", "Calculates", "the", "coordinates", "of", "x", "and", "y", "for", "a", "point", "at", "t", "on", "a", "straight", "line", ".", "The", "t", "parameter", "is", "a", "number", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L428-L438
[ "def", "_linepoint", "(", "self", ",", "t", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "# Originally from nodebox-gl", "out_x", "=", "x0", "+", "t", "*", "(", "x1", "-", "x0", ")", "out_y", "=", "y0", "+", "t", "*", "(", "y1", "-", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._linelength
Returns the length of the line.
shoebot/data/bezier.py
def _linelength(self, x0, y0, x1, y1): """ Returns the length of the line. """ # Originally from nodebox-gl a = pow(abs(x0 - x1), 2) b = pow(abs(y0 - y1), 2) return sqrt(a + b)
def _linelength(self, x0, y0, x1, y1): """ Returns the length of the line. """ # Originally from nodebox-gl a = pow(abs(x0 - x1), 2) b = pow(abs(y0 - y1), 2) return sqrt(a + b)
[ "Returns", "the", "length", "of", "the", "line", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L440-L446
[ "def", "_linelength", "(", "self", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ":", "# Originally from nodebox-gl", "a", "=", "pow", "(", "abs", "(", "x0", "-", "x1", ")", ",", "2", ")", "b", "=", "pow", "(", "abs", "(", "y0", "-", "y1", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._curvepoint
Returns coordinates for point at t on the spline. Calculates the coordinates of x and y for a point at t on the cubic bezier spline, and its control points, based on the de Casteljau interpolation algorithm. The t parameter is a number between 0.0 and 1.0, x0 and y0 defin...
shoebot/data/bezier.py
def _curvepoint(self, t, x0, y0, x1, y1, x2, y2, x3, y3, handles=False): """ Returns coordinates for point at t on the spline. Calculates the coordinates of x and y for a point at t on the cubic bezier spline, and its control points, based on the de Casteljau interpolation algorithm. ...
def _curvepoint(self, t, x0, y0, x1, y1, x2, y2, x3, y3, handles=False): """ Returns coordinates for point at t on the spline. Calculates the coordinates of x and y for a point at t on the cubic bezier spline, and its control points, based on the de Casteljau interpolation algorithm. ...
[ "Returns", "coordinates", "for", "point", "at", "t", "on", "the", "spline", ".", "Calculates", "the", "coordinates", "of", "x", "and", "y", "for", "a", "point", "at", "t", "on", "the", "cubic", "bezier", "spline", "and", "its", "control", "points", "base...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L448-L477
[ "def", "_curvepoint", "(", "self", ",", "t", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ",", "handles", "=", "False", ")", ":", "# Originally from nodebox-gl", "mint", "=", "1", "-", "t", "x01", "=", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._curvelength
Returns the length of the spline. Integrates the estimated length of the cubic bezier spline defined by x0, y0, ... x3, y3, by adding the lengths of lineair lines between points at t. The number of points is defined by n (n=10 would add the lengths of lines between 0.0 an...
shoebot/data/bezier.py
def _curvelength(self, x0, y0, x1, y1, x2, y2, x3, y3, n=20): """ Returns the length of the spline. Integrates the estimated length of the cubic bezier spline defined by x0, y0, ... x3, y3, by adding the lengths of lineair lines between points at t. The number of points is de...
def _curvelength(self, x0, y0, x1, y1, x2, y2, x3, y3, n=20): """ Returns the length of the spline. Integrates the estimated length of the cubic bezier spline defined by x0, y0, ... x3, y3, by adding the lengths of lineair lines between points at t. The number of points is de...
[ "Returns", "the", "length", "of", "the", "spline", ".", "Integrates", "the", "estimated", "length", "of", "the", "cubic", "bezier", "spline", "defined", "by", "x0", "y0", "...", "x3", "y3", "by", "adding", "the", "lengths", "of", "lineair", "lines", "betwe...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L479-L499
[ "def", "_curvelength", "(", "self", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ",", "n", "=", "20", ")", ":", "# Originally from nodebox-gl", "length", "=", "0", "xi", "=", "x0", "yi", "=", "y0", "fo...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._segment_lengths
Returns a list with the lengths of each segment in the path.
shoebot/data/bezier.py
def _segment_lengths(self, relative=False, n=20): """ Returns a list with the lengths of each segment in the path. """ # From nodebox_gl lengths = [] first = True for el in self._get_elements(): if first is True: close_x, close_y = el.x, el.y ...
def _segment_lengths(self, relative=False, n=20): """ Returns a list with the lengths of each segment in the path. """ # From nodebox_gl lengths = [] first = True for el in self._get_elements(): if first is True: close_x, close_y = el.x, el.y ...
[ "Returns", "a", "list", "with", "the", "lengths", "of", "each", "segment", "in", "the", "path", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L501-L534
[ "def", "_segment_lengths", "(", "self", ",", "relative", "=", "False", ",", "n", "=", "20", ")", ":", "# From nodebox_gl", "lengths", "=", "[", "]", "first", "=", "True", "for", "el", "in", "self", ".", "_get_elements", "(", ")", ":", "if", "first", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._get_length
Returns the length of the path. Calculates the length of each spline in the path, using n as a number of points to measure. When segmented is True, returns a list containing the individual length of each spline as values between 0.0 and 1.0, defining the relative length of each splin...
shoebot/data/bezier.py
def _get_length(self, segmented=False, precision=10): """ Returns the length of the path. Calculates the length of each spline in the path, using n as a number of points to measure. When segmented is True, returns a list containing the individual length of each spline as valu...
def _get_length(self, segmented=False, precision=10): """ Returns the length of the path. Calculates the length of each spline in the path, using n as a number of points to measure. When segmented is True, returns a list containing the individual length of each spline as valu...
[ "Returns", "the", "length", "of", "the", "path", ".", "Calculates", "the", "length", "of", "each", "spline", "in", "the", "path", "using", "n", "as", "a", "number", "of", "points", "to", "measure", ".", "When", "segmented", "is", "True", "returns", "a", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L536-L547
[ "def", "_get_length", "(", "self", ",", "segmented", "=", "False", ",", "precision", "=", "10", ")", ":", "# Originally from nodebox-gl", "if", "not", "segmented", ":", "return", "sum", "(", "self", ".", "_segment_lengths", "(", "n", "=", "precision", ")", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BezierPath._get_elements
Yields all elements as PathElements
shoebot/data/bezier.py
def _get_elements(self): ''' Yields all elements as PathElements ''' for index, el in enumerate(self._elements): if isinstance(el, tuple): el = PathElement(*el) self._elements[index] = el yield el
def _get_elements(self): ''' Yields all elements as PathElements ''' for index, el in enumerate(self._elements): if isinstance(el, tuple): el = PathElement(*el) self._elements[index] = el yield el
[ "Yields", "all", "elements", "as", "PathElements" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/bezier.py#L549-L557
[ "def", "_get_elements", "(", "self", ")", ":", "for", "index", ",", "el", "in", "enumerate", "(", "self", ".", "_elements", ")", ":", "if", "isinstance", "(", "el", ",", "tuple", ")", ":", "el", "=", "PathElement", "(", "*", "el", ")", "self", ".",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
depth_first_search
Simple, multi-purpose depth-first search. Visits all the nodes connected to the root, depth-first. The visit function is called on each node. Recursion will stop if it returns True, and ubsequently dfs() will return True. The traversable function takes the current node and edge, and returns Tru...
lib/graph/proximity.py
def depth_first_search(root, visit=lambda node: False, traversable=lambda node, edge: True): """ Simple, multi-purpose depth-first search. Visits all the nodes connected to the root, depth-first. The visit function is called on each node. Recursion will stop if it returns True, and ubsequently dfs...
def depth_first_search(root, visit=lambda node: False, traversable=lambda node, edge: True): """ Simple, multi-purpose depth-first search. Visits all the nodes connected to the root, depth-first. The visit function is called on each node. Recursion will stop if it returns True, and ubsequently dfs...
[ "Simple", "multi", "-", "purpose", "depth", "-", "first", "search", ".", "Visits", "all", "the", "nodes", "connected", "to", "the", "root", "depth", "-", "first", ".", "The", "visit", "function", "is", "called", "on", "each", "node", ".", "Recursion", "w...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/proximity.py#L23-L46
[ "def", "depth_first_search", "(", "root", ",", "visit", "=", "lambda", "node", ":", "False", ",", "traversable", "=", "lambda", "node", ",", "edge", ":", "True", ")", ":", "stop", "=", "visit", "(", "root", ")", "root", ".", "_visited", "=", "True", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
adjacency
An edge weight map indexed by node id's. A dictionary indexed by node id1's in which each value is a dictionary of connected node id2's linking to the edge weight. If directed, edges go from id1 to id2, but not the other way. If stochastic, all the weights for the neighbors of a given node sum to 1...
lib/graph/proximity.py
def adjacency(graph, directed=False, reversed=False, stochastic=False, heuristic=None): """ An edge weight map indexed by node id's. A dictionary indexed by node id1's in which each value is a dictionary of connected node id2's linking to the edge weight. If directed, edges go from id1 to id2,...
def adjacency(graph, directed=False, reversed=False, stochastic=False, heuristic=None): """ An edge weight map indexed by node id's. A dictionary indexed by node id1's in which each value is a dictionary of connected node id2's linking to the edge weight. If directed, edges go from id1 to id2,...
[ "An", "edge", "weight", "map", "indexed", "by", "node", "id", "s", ".", "A", "dictionary", "indexed", "by", "node", "id1", "s", "in", "which", "each", "value", "is", "a", "dictionary", "of", "connected", "node", "id2", "s", "linking", "to", "the", "edg...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/proximity.py#L50-L90
[ "def", "adjacency", "(", "graph", ",", "directed", "=", "False", ",", "reversed", "=", "False", ",", "stochastic", "=", "False", ",", "heuristic", "=", "None", ")", ":", "v", "=", "{", "}", "for", "n", "in", "graph", ".", "nodes", ":", "v", "[", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
brandes_betweenness_centrality
Betweenness centrality for nodes in the graph. Betweenness centrality is a measure of the number of shortests paths that pass through a node. Nodes in high-density areas will get a good score. The algorithm is Brandes' betweenness centrality, from NetworkX 0.35.1: Aric Hagberg, Dan Schult and ...
lib/graph/proximity.py
def brandes_betweenness_centrality(graph, normalized=True): """ Betweenness centrality for nodes in the graph. Betweenness centrality is a measure of the number of shortests paths that pass through a node. Nodes in high-density areas will get a good score. The algorithm is Brandes' betweennes...
def brandes_betweenness_centrality(graph, normalized=True): """ Betweenness centrality for nodes in the graph. Betweenness centrality is a measure of the number of shortests paths that pass through a node. Nodes in high-density areas will get a good score. The algorithm is Brandes' betweennes...
[ "Betweenness", "centrality", "for", "nodes", "in", "the", "graph", ".", "Betweenness", "centrality", "is", "a", "measure", "of", "the", "number", "of", "shortests", "paths", "that", "pass", "through", "a", "node", ".", "Nodes", "in", "high", "-", "density", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/proximity.py#L128-L192
[ "def", "brandes_betweenness_centrality", "(", "graph", ",", "normalized", "=", "True", ")", ":", "G", "=", "graph", ".", "keys", "(", ")", "W", "=", "adjacency", "(", "graph", ")", "betweenness", "=", "dict", ".", "fromkeys", "(", "G", ",", "0.0", ")",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
eigenvector_centrality
Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a directed network. It rewards nodes with a high potential of (indirectly) connecting to high-scoring nodes. Nodes with no incoming connections have a score of zer...
lib/graph/proximity.py
def eigenvector_centrality(graph, normalized=True, reversed=True, rating={}, start=None, iterations=100, tolerance=0.0001): """ Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a directed n...
def eigenvector_centrality(graph, normalized=True, reversed=True, rating={}, start=None, iterations=100, tolerance=0.0001): """ Eigenvector centrality for nodes in the graph (like Google's PageRank). Eigenvector centrality is a measure of the importance of a node in a directed n...
[ "Eigenvector", "centrality", "for", "nodes", "in", "the", "graph", "(", "like", "Google", "s", "PageRank", ")", ".", "Eigenvector", "centrality", "is", "a", "measure", "of", "the", "importance", "of", "a", "node", "in", "a", "directed", "network", ".", "It...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/proximity.py#L198-L255
[ "def", "eigenvector_centrality", "(", "graph", ",", "normalized", "=", "True", ",", "reversed", "=", "True", ",", "rating", "=", "{", "}", ",", "start", "=", "None", ",", "iterations", "=", "100", ",", "tolerance", "=", "0.0001", ")", ":", "G", "=", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
examples_menu
:return: xml for menu, [(bot_action, label), ...], [(menu_action, label), ...]
extensions/lib/shoebotit/gtk3_utils.py
def examples_menu(root_dir=None, depth=0): """ :return: xml for menu, [(bot_action, label), ...], [(menu_action, label), ...] """ # pre 3.12 menus examples_dir = ide_utils.get_example_dir() if not examples_dir: return "", [], [] root_dir = root_dir or examples_dir file_tmpl = '...
def examples_menu(root_dir=None, depth=0): """ :return: xml for menu, [(bot_action, label), ...], [(menu_action, label), ...] """ # pre 3.12 menus examples_dir = ide_utils.get_example_dir() if not examples_dir: return "", [], [] root_dir = root_dir or examples_dir file_tmpl = '...
[ ":", "return", ":", "xml", "for", "menu", "[", "(", "bot_action", "label", ")", "...", "]", "[", "(", "menu_action", "label", ")", "...", "]" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L35-L74
[ "def", "examples_menu", "(", "root_dir", "=", "None", ",", "depth", "=", "0", ")", ":", "# pre 3.12 menus", "examples_dir", "=", "ide_utils", ".", "get_example_dir", "(", ")", "if", "not", "examples_dir", ":", "return", "\"\"", ",", "[", "]", ",", "[", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
mk_examples_menu
:return: base_item, rel_paths
extensions/lib/shoebotit/gtk3_utils.py
def mk_examples_menu(text, root_dir=None, depth=0): """ :return: base_item, rel_paths """ # 3.12+ menus examples_dir = ide_utils.get_example_dir() if not examples_dir: return None, [] root_dir = root_dir or examples_dir file_actions = [] menu = Gio.Menu.new() b...
def mk_examples_menu(text, root_dir=None, depth=0): """ :return: base_item, rel_paths """ # 3.12+ menus examples_dir = ide_utils.get_example_dir() if not examples_dir: return None, [] root_dir = root_dir or examples_dir file_actions = [] menu = Gio.Menu.new() b...
[ ":", "return", ":", "base_item", "rel_paths" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L82-L117
[ "def", "mk_examples_menu", "(", "text", ",", "root_dir", "=", "None", ",", "depth", "=", "0", ")", ":", "# 3.12+ menus", "examples_dir", "=", "ide_utils", ".", "get_example_dir", "(", ")", "if", "not", "examples_dir", ":", "return", "None", ",", "[", "]", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
get_child_by_name
Iterate through a gtk container, `parent`, and return the widget with the name `name`.
extensions/lib/shoebotit/gtk3_utils.py
def get_child_by_name(parent, name): """ Iterate through a gtk container, `parent`, and return the widget with the name `name`. """ # http://stackoverflow.com/questions/2072976/access-to-widget-in-gtk def iterate_children(widget, name): if widget.get_name() == name: return wi...
def get_child_by_name(parent, name): """ Iterate through a gtk container, `parent`, and return the widget with the name `name`. """ # http://stackoverflow.com/questions/2072976/access-to-widget-in-gtk def iterate_children(widget, name): if widget.get_name() == name: return wi...
[ "Iterate", "through", "a", "gtk", "container", "parent", "and", "return", "the", "widget", "with", "the", "name", "name", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L129-L147
[ "def", "get_child_by_name", "(", "parent", ",", "name", ")", ":", "# http://stackoverflow.com/questions/2072976/access-to-widget-in-gtk", "def", "iterate_children", "(", "widget", ",", "name", ")", ":", "if", "widget", ".", "get_name", "(", ")", "==", "name", ":", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
venv_has_script
:param script: script to look for in bin folder
extensions/lib/shoebotit/gtk3_utils.py
def venv_has_script(script): """ :param script: script to look for in bin folder """ def f(venv): path=os.path.join(venv, 'bin', script) if os.path.isfile(path): return True return f
def venv_has_script(script): """ :param script: script to look for in bin folder """ def f(venv): path=os.path.join(venv, 'bin', script) if os.path.isfile(path): return True return f
[ ":", "param", "script", ":", "script", "to", "look", "for", "in", "bin", "folder" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L151-L159
[ "def", "venv_has_script", "(", "script", ")", ":", "def", "f", "(", "venv", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "venv", ",", "'bin'", ",", "script", ")", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "re...
d554c1765c1899fa25727c9fc6805d221585562b
valid
is_venv
:param directory: base directory of python environment
extensions/lib/shoebotit/gtk3_utils.py
def is_venv(directory, executable='python'): """ :param directory: base directory of python environment """ path=os.path.join(directory, 'bin', executable) return os.path.isfile(path)
def is_venv(directory, executable='python'): """ :param directory: base directory of python environment """ path=os.path.join(directory, 'bin', executable) return os.path.isfile(path)
[ ":", "param", "directory", ":", "base", "directory", "of", "python", "environment" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L162-L167
[ "def", "is_venv", "(", "directory", ",", "executable", "=", "'python'", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'bin'", ",", "executable", ")", "return", "os", ".", "path", ".", "isfile", "(", "path", ")" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
vw_envs
:return: python environments in ~/.virtualenvs :param filter: if this returns False the venv will be ignored >>> vw_envs(filter=venv_has_script('pip'))
extensions/lib/shoebotit/gtk3_utils.py
def vw_envs(filter=None): """ :return: python environments in ~/.virtualenvs :param filter: if this returns False the venv will be ignored >>> vw_envs(filter=venv_has_script('pip')) """ vw_root=os.path.abspath(os.path.expanduser(os.path.expandvars('~/.virtualenvs'))) venvs=[] for direc...
def vw_envs(filter=None): """ :return: python environments in ~/.virtualenvs :param filter: if this returns False the venv will be ignored >>> vw_envs(filter=venv_has_script('pip')) """ vw_root=os.path.abspath(os.path.expanduser(os.path.expandvars('~/.virtualenvs'))) venvs=[] for direc...
[ ":", "return", ":", "python", "environments", "in", "~", "/", ".", "virtualenvs" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L170-L186
[ "def", "vw_envs", "(", "filter", "=", "None", ")", ":", "vw_root", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "os", ".", "path", ".", "expandvars", "(", "'~/.virtualenvs'", ")", ")", ")", "venvs", "=", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
sbot_executable
Find shoebot executable
extensions/lib/shoebotit/gtk3_utils.py
def sbot_executable(): """ Find shoebot executable """ gsettings=load_gsettings() venv = gsettings.get_string('current-virtualenv') if venv == 'Default': sbot = which('sbot') elif venv == 'System': # find system python env_venv = os.environ.get('VIRTUAL_ENV') ...
def sbot_executable(): """ Find shoebot executable """ gsettings=load_gsettings() venv = gsettings.get_string('current-virtualenv') if venv == 'Default': sbot = which('sbot') elif venv == 'System': # find system python env_venv = os.environ.get('VIRTUAL_ENV') ...
[ "Find", "shoebot", "executable" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/gtk3_utils.py#L206-L230
[ "def", "sbot_executable", "(", ")", ":", "gsettings", "=", "load_gsettings", "(", ")", "venv", "=", "gsettings", ".", "get_string", "(", "'current-virtualenv'", ")", "if", "venv", "==", "'Default'", ":", "sbot", "=", "which", "(", "'sbot'", ")", "elif", "v...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Page._description
Returns the meta description in the page.
lib/web/page.py
def _description(self): """ Returns the meta description in the page. """ meta = self.find("meta", {"name":"description"}) if isinstance(meta, dict) and \ meta.has_key("content"): return meta["content"] else: return u""
def _description(self): """ Returns the meta description in the page. """ meta = self.find("meta", {"name":"description"}) if isinstance(meta, dict) and \ meta.has_key("content"): return meta["content"] else: return u""
[ "Returns", "the", "meta", "description", "in", "the", "page", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/page.py#L82-L92
[ "def", "_description", "(", "self", ")", ":", "meta", "=", "self", ".", "find", "(", "\"meta\"", ",", "{", "\"name\"", ":", "\"description\"", "}", ")", "if", "isinstance", "(", "meta", ",", "dict", ")", "and", "meta", ".", "has_key", "(", "\"content\"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Page._keywords
Returns the meta keywords in the page.
lib/web/page.py
def _keywords(self): """ Returns the meta keywords in the page. """ meta = self.find("meta", {"name":"keywords"}) if isinstance(meta, dict) and \ meta.has_key("content"): keywords = [k.strip() for k in meta["content"].split(",")] else: ...
def _keywords(self): """ Returns the meta keywords in the page. """ meta = self.find("meta", {"name":"keywords"}) if isinstance(meta, dict) and \ meta.has_key("content"): keywords = [k.strip() for k in meta["content"].split(",")] else: ...
[ "Returns", "the", "meta", "keywords", "in", "the", "page", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/page.py#L96-L108
[ "def", "_keywords", "(", "self", ")", ":", "meta", "=", "self", ".", "find", "(", "\"meta\"", ",", "{", "\"name\"", ":", "\"keywords\"", "}", ")", "if", "isinstance", "(", "meta", ",", "dict", ")", "and", "meta", ".", "has_key", "(", "\"content\"", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Page.links
Retrieves links in the page. Returns a list of URL's. By default, only external URL's are returned. External URL's starts with http:// and point to another domain than the domain the page is on.
lib/web/page.py
def links(self, external=True): """ Retrieves links in the page. Returns a list of URL's. By default, only external URL's are returned. External URL's starts with http:// and point to another domain than the domain the page is on. """ ...
def links(self, external=True): """ Retrieves links in the page. Returns a list of URL's. By default, only external URL's are returned. External URL's starts with http:// and point to another domain than the domain the page is on. """ ...
[ "Retrieves", "links", "in", "the", "page", ".", "Returns", "a", "list", "of", "URL", "s", ".", "By", "default", "only", "external", "URL", "s", "are", "returned", ".", "External", "URL", "s", "starts", "with", "http", ":", "//", "and", "point", "to", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/page.py#L112-L133
[ "def", "links", "(", "self", ",", "external", "=", "True", ")", ":", "domain", "=", "URLParser", "(", "self", ".", "url", ")", ".", "domain", "links", "=", "[", "]", "for", "a", "in", "self", "(", "\"a\"", ")", ":", "for", "attribute", ",", "valu...
d554c1765c1899fa25727c9fc6805d221585562b
valid
sorted
Returns a sorted copy of the list.
lib/graph/cluster.py
def sorted(list, cmp=None, reversed=False): """ Returns a sorted copy of the list. """ list = [x for x in list] list.sort(cmp) if reversed: list.reverse() return list
def sorted(list, cmp=None, reversed=False): """ Returns a sorted copy of the list. """ list = [x for x in list] list.sort(cmp) if reversed: list.reverse() return list
[ "Returns", "a", "sorted", "copy", "of", "the", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L8-L14
[ "def", "sorted", "(", "list", ",", "cmp", "=", "None", ",", "reversed", "=", "False", ")", ":", "list", "=", "[", "x", "for", "x", "in", "list", "]", "list", ".", "sort", "(", "cmp", ")", "if", "reversed", ":", "list", ".", "reverse", "(", ")",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
unique
Returns a copy of the list without duplicates.
lib/graph/cluster.py
def unique(list): """ Returns a copy of the list without duplicates. """ unique = []; [unique.append(x) for x in list if x not in unique] return unique
def unique(list): """ Returns a copy of the list without duplicates. """ unique = []; [unique.append(x) for x in list if x not in unique] return unique
[ "Returns", "a", "copy", "of", "the", "list", "without", "duplicates", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L16-L20
[ "def", "unique", "(", "list", ")", ":", "unique", "=", "[", "]", "[", "unique", ".", "append", "(", "x", ")", "for", "x", "in", "list", "if", "x", "not", "in", "unique", "]", "return", "unique" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
flatten
Recursively lists the node and its links. Distance of 0 will return the given [node]. Distance of 1 will return a list of the node and all its links. Distance of 2 will also include the linked nodes' links, etc.
lib/graph/cluster.py
def flatten(node, distance=1): """ Recursively lists the node and its links. Distance of 0 will return the given [node]. Distance of 1 will return a list of the node and all its links. Distance of 2 will also include the linked nodes' links, etc. """ # When you pass a graph i...
def flatten(node, distance=1): """ Recursively lists the node and its links. Distance of 0 will return the given [node]. Distance of 1 will return a list of the node and all its links. Distance of 2 will also include the linked nodes' links, etc. """ # When you pass a graph i...
[ "Recursively", "lists", "the", "node", "and", "its", "links", ".", "Distance", "of", "0", "will", "return", "the", "given", "[", "node", "]", ".", "Distance", "of", "1", "will", "return", "a", "list", "of", "the", "node", "and", "all", "its", "links", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L24-L43
[ "def", "flatten", "(", "node", ",", "distance", "=", "1", ")", ":", "# When you pass a graph it returns all the node id's in it.", "if", "hasattr", "(", "node", ",", "\"nodes\"", ")", "and", "hasattr", "(", "node", ",", "\"edges\"", ")", ":", "return", "[", "n...
d554c1765c1899fa25727c9fc6805d221585562b
valid
subgraph
Creates the subgraph of the flattened node with given id (or list of id's). Finds all the edges between the nodes that make up the subgraph.
lib/graph/cluster.py
def subgraph(graph, id, distance=1): """ Creates the subgraph of the flattened node with given id (or list of id's). Finds all the edges between the nodes that make up the subgraph. """ g = graph.copy(empty=True) if isinstance(id, (FunctionType, LambdaType)): # id can also be ...
def subgraph(graph, id, distance=1): """ Creates the subgraph of the flattened node with given id (or list of id's). Finds all the edges between the nodes that make up the subgraph. """ g = graph.copy(empty=True) if isinstance(id, (FunctionType, LambdaType)): # id can also be ...
[ "Creates", "the", "subgraph", "of", "the", "flattened", "node", "with", "given", "id", "(", "or", "list", "of", "id", "s", ")", ".", "Finds", "all", "the", "edges", "between", "the", "nodes", "that", "make", "up", "the", "subgraph", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L66-L91
[ "def", "subgraph", "(", "graph", ",", "id", ",", "distance", "=", "1", ")", ":", "g", "=", "graph", ".", "copy", "(", "empty", "=", "True", ")", "if", "isinstance", "(", "id", ",", "(", "FunctionType", ",", "LambdaType", ")", ")", ":", "# id can al...
d554c1765c1899fa25727c9fc6805d221585562b
valid
clique
Returns the largest possible clique for the node with given id.
lib/graph/cluster.py
def clique(graph, id): """ Returns the largest possible clique for the node with given id. """ clique = [id] for n in graph.nodes: friend = True for id in clique: if n.id == id or graph.edge(n.id, id) == None: friend = False break ...
def clique(graph, id): """ Returns the largest possible clique for the node with given id. """ clique = [id] for n in graph.nodes: friend = True for id in clique: if n.id == id or graph.edge(n.id, id) == None: friend = False break ...
[ "Returns", "the", "largest", "possible", "clique", "for", "the", "node", "with", "given", "id", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L110-L125
[ "def", "clique", "(", "graph", ",", "id", ")", ":", "clique", "=", "[", "id", "]", "for", "n", "in", "graph", ".", "nodes", ":", "friend", "=", "True", "for", "id", "in", "clique", ":", "if", "n", ".", "id", "==", "id", "or", "graph", ".", "e...
d554c1765c1899fa25727c9fc6805d221585562b
valid
cliques
Returns all the cliques in the graph of at least the given size.
lib/graph/cluster.py
def cliques(graph, threshold=3): """ Returns all the cliques in the graph of at least the given size. """ cliques = [] for n in graph.nodes: c = clique(graph, n.id) if len(c) >= threshold: c.sort() if c not in cliques: cliques.append(c) ...
def cliques(graph, threshold=3): """ Returns all the cliques in the graph of at least the given size. """ cliques = [] for n in graph.nodes: c = clique(graph, n.id) if len(c) >= threshold: c.sort() if c not in cliques: cliques.append(c) ...
[ "Returns", "all", "the", "cliques", "in", "the", "graph", "of", "at", "least", "the", "given", "size", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L127-L140
[ "def", "cliques", "(", "graph", ",", "threshold", "=", "3", ")", ":", "cliques", "=", "[", "]", "for", "n", "in", "graph", ".", "nodes", ":", "c", "=", "clique", "(", "graph", ",", "n", ".", "id", ")", "if", "len", "(", "c", ")", ">=", "thres...
d554c1765c1899fa25727c9fc6805d221585562b
valid
partition
Splits unconnected subgraphs. For each node in the graph, make a list of its id and all directly connected id's. If one of the nodes in this list intersects with a subgraph, they are all part of that subgraph. Otherwise, this list is part of a new subgraph. Return a list of subgraphs sorted by ...
lib/graph/cluster.py
def partition(graph): """ Splits unconnected subgraphs. For each node in the graph, make a list of its id and all directly connected id's. If one of the nodes in this list intersects with a subgraph, they are all part of that subgraph. Otherwise, this list is part of a new subgraph. Re...
def partition(graph): """ Splits unconnected subgraphs. For each node in the graph, make a list of its id and all directly connected id's. If one of the nodes in this list intersects with a subgraph, they are all part of that subgraph. Otherwise, this list is part of a new subgraph. Re...
[ "Splits", "unconnected", "subgraphs", ".", "For", "each", "node", "in", "the", "graph", "make", "a", "list", "of", "its", "id", "and", "all", "directly", "connected", "id", "s", ".", "If", "one", "of", "the", "nodes", "in", "this", "list", "intersects", ...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/cluster.py#L144-L186
[ "def", "partition", "(", "graph", ")", ":", "g", "=", "[", "]", "for", "n", "in", "graph", ".", "nodes", ":", "c", "=", "[", "n", ".", "id", "for", "n", "in", "flatten", "(", "n", ")", "]", "f", "=", "False", "for", "i", "in", "range", "(",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
DrawQueueSink.render
Calls implmentation to get a render context, passes it to the drawqueues render function then calls self.rendering_finished
shoebot/core/drawqueue_sink.py
def render(self, size, frame, drawqueue): ''' Calls implmentation to get a render context, passes it to the drawqueues render function then calls self.rendering_finished ''' r_context = self.create_rcontext(size, frame) drawqueue.render(r_context) self.ren...
def render(self, size, frame, drawqueue): ''' Calls implmentation to get a render context, passes it to the drawqueues render function then calls self.rendering_finished ''' r_context = self.create_rcontext(size, frame) drawqueue.render(r_context) self.ren...
[ "Calls", "implmentation", "to", "get", "a", "render", "context", "passes", "it", "to", "the", "drawqueues", "render", "function", "then", "calls", "self", ".", "rendering_finished" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/drawqueue_sink.py#L14-L23
[ "def", "render", "(", "self", ",", "size", ",", "frame", ",", "drawqueue", ")", ":", "r_context", "=", "self", ".", "create_rcontext", "(", "size", ",", "frame", ")", "drawqueue", ".", "render", "(", "r_context", ")", "self", ".", "rendering_finished", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
VarListener.batch
Context manager to only update listeners at the end, in the meantime it doesn't matter what intermediate state the vars are in (they can be added and removed) >>> with VarListener.batch() ... pass
shoebot/core/var_listener.py
def batch(vars, oldvars, ns): """ Context manager to only update listeners at the end, in the meantime it doesn't matter what intermediate state the vars are in (they can be added and removed) >>> with VarListener.batch() ... pass """ snapshot...
def batch(vars, oldvars, ns): """ Context manager to only update listeners at the end, in the meantime it doesn't matter what intermediate state the vars are in (they can be added and removed) >>> with VarListener.batch() ... pass """ snapshot...
[ "Context", "manager", "to", "only", "update", "listeners", "at", "the", "end", "in", "the", "meantime", "it", "doesn", "t", "matter", "what", "intermediate", "state", "the", "vars", "are", "in", "(", "they", "can", "be", "added", "and", "removed", ")" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/var_listener.py#L60-L93
[ "def", "batch", "(", "vars", ",", "oldvars", ",", "ns", ")", ":", "snapshot_vars", "=", "dict", "(", "vars", ")", "with", "VarListener", ".", "disabled", "(", ")", ":", "yield", "added_vars", "=", "set", "(", "oldvars", ".", "keys", "(", ")", ")", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
hexDump
Useful utility; prints the string in hexadecimal
lib/tuio/OSC.py
def hexDump(bytes): """Useful utility; prints the string in hexadecimal""" for i in range(len(bytes)): sys.stdout.write("%2x " % (ord(bytes[i]))) if (i+1) % 8 == 0: print repr(bytes[i-7:i+1]) if(len(bytes) % 8 != 0): print string.rjust("", 11), repr(bytes[i-len(bytes)%8:...
def hexDump(bytes): """Useful utility; prints the string in hexadecimal""" for i in range(len(bytes)): sys.stdout.write("%2x " % (ord(bytes[i]))) if (i+1) % 8 == 0: print repr(bytes[i-7:i+1]) if(len(bytes) % 8 != 0): print string.rjust("", 11), repr(bytes[i-len(bytes)%8:...
[ "Useful", "utility", ";", "prints", "the", "string", "in", "hexadecimal" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L38-L46
[ "def", "hexDump", "(", "bytes", ")", ":", "for", "i", "in", "range", "(", "len", "(", "bytes", ")", ")", ":", "sys", ".", "stdout", ".", "write", "(", "\"%2x \"", "%", "(", "ord", "(", "bytes", "[", "i", "]", ")", ")", ")", "if", "(", "i", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
readLong
Tries to interpret the next 8 bytes of the data as a 64-bit signed integer.
lib/tuio/OSC.py
def readLong(data): """Tries to interpret the next 8 bytes of the data as a 64-bit signed integer.""" high, low = struct.unpack(">ll", data[0:8]) big = (long(high) << 32) + low rest = data[8:] return (big, rest)
def readLong(data): """Tries to interpret the next 8 bytes of the data as a 64-bit signed integer.""" high, low = struct.unpack(">ll", data[0:8]) big = (long(high) << 32) + low rest = data[8:] return (big, rest)
[ "Tries", "to", "interpret", "the", "next", "8", "bytes", "of", "the", "data", "as", "a", "64", "-", "bit", "signed", "integer", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L126-L132
[ "def", "readLong", "(", "data", ")", ":", "high", ",", "low", "=", "struct", ".", "unpack", "(", "\">ll\"", ",", "data", "[", "0", ":", "8", "]", ")", "big", "=", "(", "long", "(", "high", ")", "<<", "32", ")", "+", "low", "rest", "=", "data"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
OSCBlob
Convert a string into an OSC Blob, returning a (typetag, data) tuple.
lib/tuio/OSC.py
def OSCBlob(next): """Convert a string into an OSC Blob, returning a (typetag, data) tuple.""" if type(next) == type(""): length = len(next) padded = math.ceil((len(next)) / 4.0) * 4 binary = struct.pack(">i%ds" % (padded), length, next) tag = 'b' else: tag ...
def OSCBlob(next): """Convert a string into an OSC Blob, returning a (typetag, data) tuple.""" if type(next) == type(""): length = len(next) padded = math.ceil((len(next)) / 4.0) * 4 binary = struct.pack(">i%ds" % (padded), length, next) tag = 'b' else: tag ...
[ "Convert", "a", "string", "into", "an", "OSC", "Blob", "returning", "a", "(", "typetag", "data", ")", "tuple", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L148-L161
[ "def", "OSCBlob", "(", "next", ")", ":", "if", "type", "(", "next", ")", "==", "type", "(", "\"\"", ")", ":", "length", "=", "len", "(", "next", ")", "padded", "=", "math", ".", "ceil", "(", "(", "len", "(", "next", ")", ")", "/", "4.0", ")",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
OSCArgument
Convert some Python types to their OSC binary representations, returning a (typetag, data) tuple.
lib/tuio/OSC.py
def OSCArgument(next): """Convert some Python types to their OSC binary representations, returning a (typetag, data) tuple.""" if type(next) == type(""): OSCstringLength = math.ceil((len(next)+1) / 4.0) * 4 binary = struct.pack(">%ds" % (OSCstringLength), next) tag = "s" el...
def OSCArgument(next): """Convert some Python types to their OSC binary representations, returning a (typetag, data) tuple.""" if type(next) == type(""): OSCstringLength = math.ceil((len(next)+1) / 4.0) * 4 binary = struct.pack(">%ds" % (OSCstringLength), next) tag = "s" el...
[ "Convert", "some", "Python", "types", "to", "their", "OSC", "binary", "representations", "returning", "a", "(", "typetag", "data", ")", "tuple", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L164-L183
[ "def", "OSCArgument", "(", "next", ")", ":", "if", "type", "(", "next", ")", "==", "type", "(", "\"\"", ")", ":", "OSCstringLength", "=", "math", ".", "ceil", "(", "(", "len", "(", "next", ")", "+", "1", ")", "/", "4.0", ")", "*", "4", "binary"...
d554c1765c1899fa25727c9fc6805d221585562b
valid
parseArgs
Given a list of strings, produces a list where those strings have been parsed (where possible) as floats or integers.
lib/tuio/OSC.py
def parseArgs(args): """Given a list of strings, produces a list where those strings have been parsed (where possible) as floats or integers.""" parsed = [] for arg in args: print arg arg = arg.strip() interpretation = None try: interpretation = float(arg)...
def parseArgs(args): """Given a list of strings, produces a list where those strings have been parsed (where possible) as floats or integers.""" parsed = [] for arg in args: print arg arg = arg.strip() interpretation = None try: interpretation = float(arg)...
[ "Given", "a", "list", "of", "strings", "produces", "a", "list", "where", "those", "strings", "have", "been", "parsed", "(", "where", "possible", ")", "as", "floats", "or", "integers", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L186-L204
[ "def", "parseArgs", "(", "args", ")", ":", "parsed", "=", "[", "]", "for", "arg", "in", "args", ":", "print", "arg", "arg", "=", "arg", ".", "strip", "(", ")", "interpretation", "=", "None", "try", ":", "interpretation", "=", "float", "(", "arg", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
decodeOSC
Converts a typetagged OSC message to a Python list.
lib/tuio/OSC.py
def decodeOSC(data): """Converts a typetagged OSC message to a Python list.""" table = {"i":readInt, "f":readFloat, "s":readString, "b":readBlob} decoded = [] address, rest = readString(data) typetags = "" if address == "#bundle": time, rest = readLong(rest) # decoded.append(addr...
def decodeOSC(data): """Converts a typetagged OSC message to a Python list.""" table = {"i":readInt, "f":readFloat, "s":readString, "b":readBlob} decoded = [] address, rest = readString(data) typetags = "" if address == "#bundle": time, rest = readLong(rest) # decoded.append(addr...
[ "Converts", "a", "typetagged", "OSC", "message", "to", "a", "Python", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L208-L235
[ "def", "decodeOSC", "(", "data", ")", ":", "table", "=", "{", "\"i\"", ":", "readInt", ",", "\"f\"", ":", "readFloat", ",", "\"s\"", ":", "readString", ",", "\"b\"", ":", "readBlob", "}", "decoded", "=", "[", "]", "address", ",", "rest", "=", "readSt...
d554c1765c1899fa25727c9fc6805d221585562b
valid
OSCMessage.append
Appends data to the message, updating the typetags based on the argument's type. If the argument is a blob (counted string) pass in 'b' as typehint.
lib/tuio/OSC.py
def append(self, argument, typehint = None): """Appends data to the message, updating the typetags based on the argument's type. If the argument is a blob (counted string) pass in 'b' as typehint.""" if typehint == 'b': binary = OSCBlob(argument) else...
def append(self, argument, typehint = None): """Appends data to the message, updating the typetags based on the argument's type. If the argument is a blob (counted string) pass in 'b' as typehint.""" if typehint == 'b': binary = OSCBlob(argument) else...
[ "Appends", "data", "to", "the", "message", "updating", "the", "typetags", "based", "on", "the", "argument", "s", "type", ".", "If", "the", "argument", "is", "a", "blob", "(", "counted", "string", ")", "pass", "in", "b", "as", "typehint", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L73-L86
[ "def", "append", "(", "self", ",", "argument", ",", "typehint", "=", "None", ")", ":", "if", "typehint", "==", "'b'", ":", "binary", "=", "OSCBlob", "(", "argument", ")", "else", ":", "binary", "=", "OSCArgument", "(", "argument", ")", "self", ".", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
OSCMessage.getBinary
Returns the binary message (so far) with typetags.
lib/tuio/OSC.py
def getBinary(self): """Returns the binary message (so far) with typetags.""" address = OSCArgument(self.address)[1] typetags = OSCArgument(self.typetags)[1] return address + typetags + self.message
def getBinary(self): """Returns the binary message (so far) with typetags.""" address = OSCArgument(self.address)[1] typetags = OSCArgument(self.typetags)[1] return address + typetags + self.message
[ "Returns", "the", "binary", "message", "(", "so", "far", ")", "with", "typetags", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L92-L96
[ "def", "getBinary", "(", "self", ")", ":", "address", "=", "OSCArgument", "(", "self", ".", "address", ")", "[", "1", "]", "typetags", "=", "OSCArgument", "(", "self", ".", "typetags", ")", "[", "1", "]", "return", "address", "+", "typetags", "+", "s...
d554c1765c1899fa25727c9fc6805d221585562b
valid
CallbackManager.handle
Given OSC data, tries to call the callback with the right address.
lib/tuio/OSC.py
def handle(self, data, source = None): """Given OSC data, tries to call the callback with the right address.""" decoded = decodeOSC(data) self.dispatch(decoded, source)
def handle(self, data, source = None): """Given OSC data, tries to call the callback with the right address.""" decoded = decodeOSC(data) self.dispatch(decoded, source)
[ "Given", "OSC", "data", "tries", "to", "call", "the", "callback", "with", "the", "right", "address", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L249-L253
[ "def", "handle", "(", "self", ",", "data", ",", "source", "=", "None", ")", ":", "decoded", "=", "decodeOSC", "(", "data", ")", "self", ".", "dispatch", "(", "decoded", ",", "source", ")" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
CallbackManager.dispatch
Sends decoded OSC data to an appropriate calback
lib/tuio/OSC.py
def dispatch(self, message, source = None): """Sends decoded OSC data to an appropriate calback""" msgtype = "" try: if type(message[0]) == str: # got a single message address = message[0] self.callbacks[address](message) el...
def dispatch(self, message, source = None): """Sends decoded OSC data to an appropriate calback""" msgtype = "" try: if type(message[0]) == str: # got a single message address = message[0] self.callbacks[address](message) el...
[ "Sends", "decoded", "OSC", "data", "to", "an", "appropriate", "calback" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L255-L275
[ "def", "dispatch", "(", "self", ",", "message", ",", "source", "=", "None", ")", ":", "msgtype", "=", "\"\"", "try", ":", "if", "type", "(", "message", "[", "0", "]", ")", "==", "str", ":", "# got a single message", "address", "=", "message", "[", "0...
d554c1765c1899fa25727c9fc6805d221585562b
valid
CallbackManager.add
Adds a callback to our set of callbacks, or removes the callback with name if callback is None.
lib/tuio/OSC.py
def add(self, callback, name): """Adds a callback to our set of callbacks, or removes the callback with name if callback is None.""" if callback == None: del self.callbacks[name] else: self.callbacks[name] = callback
def add(self, callback, name): """Adds a callback to our set of callbacks, or removes the callback with name if callback is None.""" if callback == None: del self.callbacks[name] else: self.callbacks[name] = callback
[ "Adds", "a", "callback", "to", "our", "set", "of", "callbacks", "or", "removes", "the", "callback", "with", "name", "if", "callback", "is", "None", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/OSC.py#L277-L284
[ "def", "add", "(", "self", ",", "callback", ",", "name", ")", ":", "if", "callback", "==", "None", ":", "del", "self", ".", "callbacks", "[", "name", "]", "else", ":", "self", ".", "callbacks", "[", "name", "]", "=", "callback" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
find_example_dir
Find examples dir .. a little bit ugly..
extensions/lib/shoebotit/ide_utils.py
def find_example_dir(): """ Find examples dir .. a little bit ugly.. """ # Replace %s with directory to check for shoebot menus. code_stub = textwrap.dedent(""" from pkg_resources import resource_filename, Requirement, DistributionNotFound try: print(resource_filename(Requirement.par...
def find_example_dir(): """ Find examples dir .. a little bit ugly.. """ # Replace %s with directory to check for shoebot menus. code_stub = textwrap.dedent(""" from pkg_resources import resource_filename, Requirement, DistributionNotFound try: print(resource_filename(Requirement.par...
[ "Find", "examples", "dir", "..", "a", "little", "bit", "ugly", ".." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L271-L313
[ "def", "find_example_dir", "(", ")", ":", "# Replace %s with directory to check for shoebot menus.", "code_stub", "=", "textwrap", ".", "dedent", "(", "\"\"\"\n from pkg_resources import resource_filename, Requirement, DistributionNotFound\n try:\n print(resource_filename(Requir...
d554c1765c1899fa25727c9fc6805d221585562b
valid
AsynchronousFileReader.run
The body of the tread: read lines and put them on the queue.
extensions/lib/shoebotit/ide_utils.py
def run(self): """ The body of the tread: read lines and put them on the queue. """ try: for line in iter(self._fd.readline, False): if line is not None: if self._althandler: if self._althandler(line): ...
def run(self): """ The body of the tread: read lines and put them on the queue. """ try: for line in iter(self._fd.readline, False): if line is not None: if self._althandler: if self._althandler(line): ...
[ "The", "body", "of", "the", "tread", ":", "read", "lines", "and", "put", "them", "on", "the", "queue", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L49-L66
[ "def", "run", "(", "self", ")", ":", "try", ":", "for", "line", "in", "iter", "(", "self", ".", "_fd", ".", "readline", ",", "False", ")", ":", "if", "line", "is", "not", "None", ":", "if", "self", ".", "_althandler", ":", "if", "self", ".", "_...
d554c1765c1899fa25727c9fc6805d221585562b
valid
AsynchronousFileReader.eof
Check whether there is no more content to expect.
extensions/lib/shoebotit/ide_utils.py
def eof(self): """ Check whether there is no more content to expect. """ return (not self.is_alive()) and self._queue.empty() or self._fd.closed
def eof(self): """ Check whether there is no more content to expect. """ return (not self.is_alive()) and self._queue.empty() or self._fd.closed
[ "Check", "whether", "there", "is", "no", "more", "content", "to", "expect", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L68-L72
[ "def", "eof", "(", "self", ")", ":", "return", "(", "not", "self", ".", "is_alive", "(", ")", ")", "and", "self", ".", "_queue", ".", "empty", "(", ")", "or", "self", ".", "_fd", ".", "closed" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
ShoebotProcess.live_source_load
Send new source code to the bot :param source: :param good_cb: callback called if code was good :param bad_cb: callback called if code was bad (will get contents of exception) :return:
extensions/lib/shoebotit/ide_utils.py
def live_source_load(self, source): """ Send new source code to the bot :param source: :param good_cb: callback called if code was good :param bad_cb: callback called if code was bad (will get contents of exception) :return: """ source = source.rstrip('\n...
def live_source_load(self, source): """ Send new source code to the bot :param source: :param good_cb: callback called if code was good :param bad_cb: callback called if code was bad (will get contents of exception) :return: """ source = source.rstrip('\n...
[ "Send", "new", "source", "code", "to", "the", "bot" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L180-L193
[ "def", "live_source_load", "(", "self", ",", "source", ")", ":", "source", "=", "source", ".", "rstrip", "(", "'\\n'", ")", "if", "source", "!=", "self", ".", "source", ":", "self", ".", "source", "=", "source", "b64_source", "=", "base64", ".", "b64en...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ShoebotProcess.send_command
:param cmd: :param args: :return:
extensions/lib/shoebotit/ide_utils.py
def send_command(self, cmd, *args): """ :param cmd: :param args: :return: """ # Test in python 2 and 3 before modifying (gedit2 + 3) if True: # Create a CommandResponse using a cookie as a unique id cookie = str(uuid.uuid4()) re...
def send_command(self, cmd, *args): """ :param cmd: :param args: :return: """ # Test in python 2 and 3 before modifying (gedit2 + 3) if True: # Create a CommandResponse using a cookie as a unique id cookie = str(uuid.uuid4()) re...
[ ":", "param", "cmd", ":", ":", "param", "args", ":", ":", "return", ":" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L198-L223
[ "def", "send_command", "(", "self", ",", "cmd", ",", "*", "args", ")", ":", "# Test in python 2 and 3 before modifying (gedit2 + 3)", "if", "True", ":", "# Create a CommandResponse using a cookie as a unique id", "cookie", "=", "str", "(", "uuid", ".", "uuid4", "(", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ShoebotProcess.close
Close outputs of process.
extensions/lib/shoebotit/ide_utils.py
def close(self): """ Close outputs of process. """ self.process.stdout.close() self.process.stderr.close() self.running = False
def close(self): """ Close outputs of process. """ self.process.stdout.close() self.process.stderr.close() self.running = False
[ "Close", "outputs", "of", "process", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L225-L231
[ "def", "close", "(", "self", ")", ":", "self", ".", "process", ".", "stdout", ".", "close", "(", ")", "self", ".", "process", ".", "stderr", ".", "close", "(", ")", "self", ".", "running", "=", "False" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
ShoebotProcess.get_output
:yield: stdout_line, stderr_line, running Generator that outputs lines captured from stdout and stderr These can be consumed to output on a widget in an IDE
extensions/lib/shoebotit/ide_utils.py
def get_output(self): """ :yield: stdout_line, stderr_line, running Generator that outputs lines captured from stdout and stderr These can be consumed to output on a widget in an IDE """ if self.process.poll() is not None: self.close() yield Non...
def get_output(self): """ :yield: stdout_line, stderr_line, running Generator that outputs lines captured from stdout and stderr These can be consumed to output on a widget in an IDE """ if self.process.poll() is not None: self.close() yield Non...
[ ":", "yield", ":", "stdout_line", "stderr_line", "running" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L233-L253
[ "def", "get_output", "(", "self", ")", ":", "if", "self", ".", "process", ".", "poll", "(", ")", "is", "not", "None", ":", "self", ".", "close", "(", ")", "yield", "None", ",", "None", "while", "not", "(", "self", ".", "stdout_queue", ".", "empty",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
ShoebotProcess.get_command_responses
Get responses to commands sent
extensions/lib/shoebotit/ide_utils.py
def get_command_responses(self): """ Get responses to commands sent """ if not self.response_queue.empty(): yield None while not self.response_queue.empty(): line = self.response_queue.get() if line is not None: yield line
def get_command_responses(self): """ Get responses to commands sent """ if not self.response_queue.empty(): yield None while not self.response_queue.empty(): line = self.response_queue.get() if line is not None: yield line
[ "Get", "responses", "to", "commands", "sent" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/lib/shoebotit/ide_utils.py#L255-L264
[ "def", "get_command_responses", "(", "self", ")", ":", "if", "not", "self", ".", "response_queue", ".", "empty", "(", ")", ":", "yield", "None", "while", "not", "self", ".", "response_queue", ".", "empty", "(", ")", ":", "line", "=", "self", ".", "resp...
d554c1765c1899fa25727c9fc6805d221585562b
valid
sort_by_preference
:param options: List of options :param prefer: Prefered options :return: Pass in a list of options, return options in 'prefer' first >>> sort_by_preference(["cairo", "cairocffi"], ["cairocffi"]) ["cairocffi", "cairo"]
shoebot/core/backend.py
def sort_by_preference(options, prefer): """ :param options: List of options :param prefer: Prefered options :return: Pass in a list of options, return options in 'prefer' first >>> sort_by_preference(["cairo", "cairocffi"], ["cairocffi"]) ["cairocffi", "cairo"] """ if not prefer: ...
def sort_by_preference(options, prefer): """ :param options: List of options :param prefer: Prefered options :return: Pass in a list of options, return options in 'prefer' first >>> sort_by_preference(["cairo", "cairocffi"], ["cairocffi"]) ["cairocffi", "cairo"] """ if not prefer: ...
[ ":", "param", "options", ":", "List", "of", "options", ":", "param", "prefer", ":", "Prefered", "options", ":", "return", ":" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/backend.py#L69-L82
[ "def", "sort_by_preference", "(", "options", ",", "prefer", ")", ":", "if", "not", "prefer", ":", "return", "options", "return", "sorted", "(", "options", ",", "key", "=", "lambda", "x", ":", "(", "prefer", "+", "options", ")", ".", "index", "(", "x", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
get_driver_options
Interpret env var as key=value :return:
shoebot/core/backend.py
def get_driver_options(): """ Interpret env var as key=value :return: """ options = os.environ.get("SHOEBOT_GRAPHICS") if not options: return {} try: return dict([kv.split('=') for kv in options.split()]) except ValueError: sys.stderr.write("Bad option format.\n"...
def get_driver_options(): """ Interpret env var as key=value :return: """ options = os.environ.get("SHOEBOT_GRAPHICS") if not options: return {} try: return dict([kv.split('=') for kv in options.split()]) except ValueError: sys.stderr.write("Bad option format.\n"...
[ "Interpret", "env", "var", "as", "key", "=", "value", ":", "return", ":" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/backend.py#L124-L139
[ "def", "get_driver_options", "(", ")", ":", "options", "=", "os", ".", "environ", ".", "get", "(", "\"SHOEBOT_GRAPHICS\"", ")", "if", "not", "options", ":", "return", "{", "}", "try", ":", "return", "dict", "(", "[", "kv", ".", "split", "(", "'='", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
BackendMixin.import_libs
Loop through module_names, add has_.... booleans to class set ..._impl to first successful import :param module_names: list of module names to try importing :param impl_name: used in error output if no modules succeed :return: name, module from first successful implementation
shoebot/core/backend.py
def import_libs(self, module_names, impl_name): """ Loop through module_names, add has_.... booleans to class set ..._impl to first successful import :param module_names: list of module names to try importing :param impl_name: used in error output if no modules succeed...
def import_libs(self, module_names, impl_name): """ Loop through module_names, add has_.... booleans to class set ..._impl to first successful import :param module_names: list of module names to try importing :param impl_name: used in error output if no modules succeed...
[ "Loop", "through", "module_names", "add", "has_", "....", "booleans", "to", "class", "set", "...", "_impl", "to", "first", "successful", "import" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/backend.py#L38-L63
[ "def", "import_libs", "(", "self", ",", "module_names", ",", "impl_name", ")", ":", "for", "name", "in", "module_names", ":", "try", ":", "module", "=", "__import__", "(", "name", ")", "has_module", "=", "True", "except", "ImportError", ":", "module", "=",...
d554c1765c1899fa25727c9fc6805d221585562b
valid
CairoGIBackend.ensure_pycairo_context
If ctx is a cairocffi Context convert it to a PyCairo Context otherwise return the original context :param ctx: :return:
shoebot/core/backend.py
def ensure_pycairo_context(self, ctx): """ If ctx is a cairocffi Context convert it to a PyCairo Context otherwise return the original context :param ctx: :return: """ if self.cairocffi and isinstance(ctx, self.cairocffi.Context): from shoebot.util.ca...
def ensure_pycairo_context(self, ctx): """ If ctx is a cairocffi Context convert it to a PyCairo Context otherwise return the original context :param ctx: :return: """ if self.cairocffi and isinstance(ctx, self.cairocffi.Context): from shoebot.util.ca...
[ "If", "ctx", "is", "a", "cairocffi", "Context", "convert", "it", "to", "a", "PyCairo", "Context", "otherwise", "return", "the", "original", "context" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/backend.py#L109-L121
[ "def", "ensure_pycairo_context", "(", "self", ",", "ctx", ")", ":", "if", "self", ".", "cairocffi", "and", "isinstance", "(", "ctx", ",", "self", ".", "cairocffi", ".", "Context", ")", ":", "from", "shoebot", ".", "util", ".", "cairocffi", ".", "cairocff...
d554c1765c1899fa25727c9fc6805d221585562b
valid
pangocairo_create_context
If python-gi-cairo is not installed, using PangoCairo.create_context dies with an unhelpful KeyError, check for that and output somethig useful.
shoebot/data/typography.py
def pangocairo_create_context(cr): """ If python-gi-cairo is not installed, using PangoCairo.create_context dies with an unhelpful KeyError, check for that and output somethig useful. """ # TODO move this to core.backend try: return PangoCairo.create_context(cr) except KeyError a...
def pangocairo_create_context(cr): """ If python-gi-cairo is not installed, using PangoCairo.create_context dies with an unhelpful KeyError, check for that and output somethig useful. """ # TODO move this to core.backend try: return PangoCairo.create_context(cr) except KeyError a...
[ "If", "python", "-", "gi", "-", "cairo", "is", "not", "installed", "using", "PangoCairo", ".", "create_context", "dies", "with", "an", "unhelpful", "KeyError", "check", "for", "that", "and", "output", "somethig", "useful", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/typography.py#L55-L68
[ "def", "pangocairo_create_context", "(", "cr", ")", ":", "# TODO move this to core.backend", "try", ":", "return", "PangoCairo", ".", "create_context", "(", "cr", ")", "except", "KeyError", "as", "e", ":", "if", "e", ".", "args", "==", "(", "'could not find fore...
d554c1765c1899fa25727c9fc6805d221585562b
valid
Text._get_center
Returns the center point of the path, disregarding transforms.
shoebot/data/typography.py
def _get_center(self): '''Returns the center point of the path, disregarding transforms. ''' w, h = self.layout.get_pixel_size() x = (self.x + w / 2) y = (self.y + h / 2) return x, y
def _get_center(self): '''Returns the center point of the path, disregarding transforms. ''' w, h = self.layout.get_pixel_size() x = (self.x + w / 2) y = (self.y + h / 2) return x, y
[ "Returns", "the", "center", "point", "of", "the", "path", "disregarding", "transforms", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/typography.py#L247-L253
[ "def", "_get_center", "(", "self", ")", ":", "w", ",", "h", "=", "self", ".", "layout", ".", "get_pixel_size", "(", ")", "x", "=", "(", "self", ".", "x", "+", "w", "/", "2", ")", "y", "=", "(", "self", ".", "y", "+", "h", "/", "2", ")", "...
d554c1765c1899fa25727c9fc6805d221585562b
valid
is_list
Determines if an item in a paragraph is a list. If all of the lines in the markup start with a "*" or "1." this indicates a list as parsed by parse_paragraphs(). It can be drawn with draw_list().
lib/web/wikipedia.py
def is_list(str): """ Determines if an item in a paragraph is a list. If all of the lines in the markup start with a "*" or "1." this indicates a list as parsed by parse_paragraphs(). It can be drawn with draw_list(). """ for chunk in str.split("\n"): chunk = chunk.replace...
def is_list(str): """ Determines if an item in a paragraph is a list. If all of the lines in the markup start with a "*" or "1." this indicates a list as parsed by parse_paragraphs(). It can be drawn with draw_list(). """ for chunk in str.split("\n"): chunk = chunk.replace...
[ "Determines", "if", "an", "item", "in", "a", "paragraph", "is", "a", "list", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1350-L1366
[ "def", "is_list", "(", "str", ")", ":", "for", "chunk", "in", "str", ".", "split", "(", "\"\\n\"", ")", ":", "chunk", "=", "chunk", ".", "replace", "(", "\"\\t\"", ",", "\"\"", ")", "if", "not", "chunk", ".", "lstrip", "(", ")", ".", "startswith", ...
d554c1765c1899fa25727c9fc6805d221585562b
valid
is_math
Determines if an item in a paragraph is a LaTeX math equation. Math equations are wrapped in <math></math> tags. They can be drawn as an image using draw_math().
lib/web/wikipedia.py
def is_math(str): """ Determines if an item in a paragraph is a LaTeX math equation. Math equations are wrapped in <math></math> tags. They can be drawn as an image using draw_math(). """ str = str.strip() if str.startswith("<math>") and str.endswith("</math>"): retur...
def is_math(str): """ Determines if an item in a paragraph is a LaTeX math equation. Math equations are wrapped in <math></math> tags. They can be drawn as an image using draw_math(). """ str = str.strip() if str.startswith("<math>") and str.endswith("</math>"): retur...
[ "Determines", "if", "an", "item", "in", "a", "paragraph", "is", "a", "LaTeX", "math", "equation", ".", "Math", "equations", "are", "wrapped", "in", "<math", ">", "<", "/", "math", ">", "tags", ".", "They", "can", "be", "drawn", "as", "an", "image", "...
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1368-L1381
[ "def", "is_math", "(", "str", ")", ":", "str", "=", "str", ".", "strip", "(", ")", "if", "str", ".", "startswith", "(", "\"<math>\"", ")", "and", "str", ".", "endswith", "(", "\"</math>\"", ")", ":", "return", "True", "else", ":", "return", "False" ]
d554c1765c1899fa25727c9fc6805d221585562b
valid
draw_math
Uses mimetex to generate a GIF-image from the LaTeX equation.
lib/web/wikipedia.py
def draw_math(str, x, y, alpha=1.0): """ Uses mimetex to generate a GIF-image from the LaTeX equation. """ try: from web import _ctx except: pass str = re.sub("</{0,1}math>", "", str.strip()) img = mimetex.gif(str) w, h = _ctx.imagesize(img) _ctx.image(img, x, y, alpha=alp...
def draw_math(str, x, y, alpha=1.0): """ Uses mimetex to generate a GIF-image from the LaTeX equation. """ try: from web import _ctx except: pass str = re.sub("</{0,1}math>", "", str.strip()) img = mimetex.gif(str) w, h = _ctx.imagesize(img) _ctx.image(img, x, y, alpha=alp...
[ "Uses", "mimetex", "to", "generate", "a", "GIF", "-", "image", "from", "the", "LaTeX", "equation", "." ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1383-L1395
[ "def", "draw_math", "(", "str", ",", "x", ",", "y", ",", "alpha", "=", "1.0", ")", ":", "try", ":", "from", "web", "import", "_ctx", "except", ":", "pass", "str", "=", "re", ".", "sub", "(", "\"</{0,1}math>\"", ",", "\"\"", ",", "str", ".", "stri...
d554c1765c1899fa25727c9fc6805d221585562b
valid
textwidth
textwidth() reports incorrectly when lineheight() is smaller than 1.0
lib/web/wikipedia.py
def textwidth(str): """textwidth() reports incorrectly when lineheight() is smaller than 1.0 """ try: from web import _ctx except: pass l = _ctx.lineheight() _ctx.lineheight(1) w = _ctx.textwidth(str) _ctx.lineheight(l) return w
def textwidth(str): """textwidth() reports incorrectly when lineheight() is smaller than 1.0 """ try: from web import _ctx except: pass l = _ctx.lineheight() _ctx.lineheight(1) w = _ctx.textwidth(str) _ctx.lineheight(l) return w
[ "textwidth", "()", "reports", "incorrectly", "when", "lineheight", "()", "is", "smaller", "than", "1", ".", "0" ]
shoebot/shoebot
python
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1397-L1410
[ "def", "textwidth", "(", "str", ")", ":", "try", ":", "from", "web", "import", "_ctx", "except", ":", "pass", "l", "=", "_ctx", ".", "lineheight", "(", ")", "_ctx", ".", "lineheight", "(", "1", ")", "w", "=", "_ctx", ".", "textwidth", "(", "str", ...
d554c1765c1899fa25727c9fc6805d221585562b