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 | LiveExecution.call_good_cb | If good_cb returns True then keep it
:return: | shoebot/grammar/livecode.py | def call_good_cb(self):
"""
If good_cb returns True then keep it
:return:
"""
with LiveExecution.lock:
if self.good_cb and not self.good_cb():
self.good_cb = None | def call_good_cb(self):
"""
If good_cb returns True then keep it
:return:
"""
with LiveExecution.lock:
if self.good_cb and not self.good_cb():
self.good_cb = None | [
"If",
"good_cb",
"returns",
"True",
"then",
"keep",
"it",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/livecode.py#L135-L142 | [
"def",
"call_good_cb",
"(",
"self",
")",
":",
"with",
"LiveExecution",
".",
"lock",
":",
"if",
"self",
".",
"good_cb",
"and",
"not",
"self",
".",
"good_cb",
"(",
")",
":",
"self",
".",
"good_cb",
"=",
"None"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | LiveExecution.run_context | Context in which the user can run the source in a custom manner.
If no exceptions occur then the source will move from 'tenuous'
to 'known good'.
>>> with run_context() as (known_good, source, ns):
>>> ... exec source in ns
>>> ... ns['draw']() | shoebot/grammar/livecode.py | def run_context(self):
"""
Context in which the user can run the source in a custom manner.
If no exceptions occur then the source will move from 'tenuous'
to 'known good'.
>>> with run_context() as (known_good, source, ns):
>>> ... exec source in ns
>>> ... n... | def run_context(self):
"""
Context in which the user can run the source in a custom manner.
If no exceptions occur then the source will move from 'tenuous'
to 'known good'.
>>> with run_context() as (known_good, source, ns):
>>> ... exec source in ns
>>> ... n... | [
"Context",
"in",
"which",
"the",
"user",
"can",
"run",
"the",
"source",
"in",
"a",
"custom",
"manner",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/livecode.py#L145-L174 | [
"def",
"run_context",
"(",
"self",
")",
":",
"with",
"LiveExecution",
".",
"lock",
":",
"if",
"self",
".",
"edited_source",
"is",
"None",
":",
"yield",
"True",
",",
"self",
".",
"known_good",
",",
"self",
".",
"ns",
"return",
"ns_snapshot",
"=",
"copy",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid.cohesion | Boids move towards the flock's centre of mass.
The centre of mass is the average position of all boids,
not including itself (the "perceived centre"). | lib/boids/__init__.py | def cohesion(self, d=100):
""" Boids move towards the flock's centre of mass.
The centre of mass is the average position of all boids,
not including itself (the "perceived centre").
"""
vx = vy = vz = 0
for b in self.boids:
... | def cohesion(self, d=100):
""" Boids move towards the flock's centre of mass.
The centre of mass is the average position of all boids,
not including itself (the "perceived centre").
"""
vx = vy = vz = 0
for b in self.boids:
... | [
"Boids",
"move",
"towards",
"the",
"flock",
"s",
"centre",
"of",
"mass",
".",
"The",
"centre",
"of",
"mass",
"is",
"the",
"average",
"position",
"of",
"all",
"boids",
"not",
"including",
"itself",
"(",
"the",
"perceived",
"centre",
")",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L41-L58 | [
"def",
"cohesion",
"(",
"self",
",",
"d",
"=",
"100",
")",
":",
"vx",
"=",
"vy",
"=",
"vz",
"=",
"0",
"for",
"b",
"in",
"self",
".",
"boids",
":",
"if",
"b",
"!=",
"self",
":",
"vx",
",",
"vy",
",",
"vz",
"=",
"vx",
"+",
"b",
".",
"x",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid.separation | Boids keep a small distance from other boids.
Ensures that boids don't collide into each other,
in a smoothly accelerated motion. | lib/boids/__init__.py | def separation(self, r=10):
""" Boids keep a small distance from other boids.
Ensures that boids don't collide into each other,
in a smoothly accelerated motion.
"""
vx = vy = vz = 0
for b in self.boids:
if b != self:
... | def separation(self, r=10):
""" Boids keep a small distance from other boids.
Ensures that boids don't collide into each other,
in a smoothly accelerated motion.
"""
vx = vy = vz = 0
for b in self.boids:
if b != self:
... | [
"Boids",
"keep",
"a",
"small",
"distance",
"from",
"other",
"boids",
".",
"Ensures",
"that",
"boids",
"don",
"t",
"collide",
"into",
"each",
"other",
"in",
"a",
"smoothly",
"accelerated",
"motion",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L60-L76 | [
"def",
"separation",
"(",
"self",
",",
"r",
"=",
"10",
")",
":",
"vx",
"=",
"vy",
"=",
"vz",
"=",
"0",
"for",
"b",
"in",
"self",
".",
"boids",
":",
"if",
"b",
"!=",
"self",
":",
"if",
"abs",
"(",
"self",
".",
"x",
"-",
"b",
".",
"x",
")",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid.alignment | Boids match velocity with other boids. | lib/boids/__init__.py | def alignment(self, d=5):
""" Boids match velocity with other boids.
"""
vx = vy = vz = 0
for b in self.boids:
if b != self:
vx, vy, vz = vx+b.vx, vy+b.vy, vz+b.vz
n = len(self.boids)-1
vx, vy, vz = vx/n, vy/n, vz/n
... | def alignment(self, d=5):
""" Boids match velocity with other boids.
"""
vx = vy = vz = 0
for b in self.boids:
if b != self:
vx, vy, vz = vx+b.vx, vy+b.vy, vz+b.vz
n = len(self.boids)-1
vx, vy, vz = vx/n, vy/n, vz/n
... | [
"Boids",
"match",
"velocity",
"with",
"other",
"boids",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L78-L91 | [
"def",
"alignment",
"(",
"self",
",",
"d",
"=",
"5",
")",
":",
"vx",
"=",
"vy",
"=",
"vz",
"=",
"0",
"for",
"b",
"in",
"self",
".",
"boids",
":",
"if",
"b",
"!=",
"self",
":",
"vx",
",",
"vy",
",",
"vz",
"=",
"vx",
"+",
"b",
".",
"vx",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid.limit | The speed limit for a boid.
Boids can momentarily go very fast,
something that is impossible for real animals. | lib/boids/__init__.py | def limit(self, max=30):
""" The speed limit for a boid.
Boids can momentarily go very fast,
something that is impossible for real animals.
"""
if abs(self.vx) > max:
self.vx = self.vx/abs(self.vx)*max
if abs(self.vy) > max... | def limit(self, max=30):
""" The speed limit for a boid.
Boids can momentarily go very fast,
something that is impossible for real animals.
"""
if abs(self.vx) > max:
self.vx = self.vx/abs(self.vx)*max
if abs(self.vy) > max... | [
"The",
"speed",
"limit",
"for",
"a",
"boid",
".",
"Boids",
"can",
"momentarily",
"go",
"very",
"fast",
"something",
"that",
"is",
"impossible",
"for",
"real",
"animals",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L93-L107 | [
"def",
"limit",
"(",
"self",
",",
"max",
"=",
"30",
")",
":",
"if",
"abs",
"(",
"self",
".",
"vx",
")",
">",
"max",
":",
"self",
".",
"vx",
"=",
"self",
".",
"vx",
"/",
"abs",
"(",
"self",
".",
"vx",
")",
"*",
"max",
"if",
"abs",
"(",
"se... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid._angle | Returns the angle towards which the boid is steering. | lib/boids/__init__.py | def _angle(self):
""" Returns the angle towards which the boid is steering.
"""
from math import atan, pi, degrees
a = degrees(atan(self.vy/self.vx)) + 360
if self.vx < 0: a += 180
return a | def _angle(self):
""" Returns the angle towards which the boid is steering.
"""
from math import atan, pi, degrees
a = degrees(atan(self.vy/self.vx)) + 360
if self.vx < 0: a += 180
return a | [
"Returns",
"the",
"angle",
"towards",
"which",
"the",
"boid",
"is",
"steering",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L109-L118 | [
"def",
"_angle",
"(",
"self",
")",
":",
"from",
"math",
"import",
"atan",
",",
"pi",
",",
"degrees",
"a",
"=",
"degrees",
"(",
"atan",
"(",
"self",
".",
"vy",
"/",
"self",
".",
"vx",
")",
")",
"+",
"360",
"if",
"self",
".",
"vx",
"<",
"0",
":... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boid.goal | Tendency towards a particular place. | lib/boids/__init__.py | def goal(self, x, y, z, d=50.0):
""" Tendency towards a particular place.
"""
return (x-self.x)/d, (y-self.y)/d, (z-self.z)/d | def goal(self, x, y, z, d=50.0):
""" Tendency towards a particular place.
"""
return (x-self.x)/d, (y-self.y)/d, (z-self.z)/d | [
"Tendency",
"towards",
"a",
"particular",
"place",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L122-L127 | [
"def",
"goal",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
",",
"d",
"=",
"50.0",
")",
":",
"return",
"(",
"x",
"-",
"self",
".",
"x",
")",
"/",
"d",
",",
"(",
"y",
"-",
"self",
".",
"y",
")",
"/",
"d",
",",
"(",
"z",
"-",
"self",
".",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boids.constrain | Cages the flock inside the x, y, w, h area.
The actual cage is a bit larger,
so boids don't seem to bounce of invisible walls
(they are rather "encouraged" to stay in the area).
If a boid touches the ground level,
it may decide to perch there for a while. | lib/boids/__init__.py | def constrain(self):
""" Cages the flock inside the x, y, w, h area.
The actual cage is a bit larger,
so boids don't seem to bounce of invisible walls
(they are rather "encouraged" to stay in the area).
If a boid touches the ground level,
it may... | def constrain(self):
""" Cages the flock inside the x, y, w, h area.
The actual cage is a bit larger,
so boids don't seem to bounce of invisible walls
(they are rather "encouraged" to stay in the area).
If a boid touches the ground level,
it may... | [
"Cages",
"the",
"flock",
"inside",
"the",
"x",
"y",
"w",
"h",
"area",
".",
"The",
"actual",
"cage",
"is",
"a",
"bit",
"larger",
"so",
"boids",
"don",
"t",
"seem",
"to",
"bounce",
"of",
"invisible",
"walls",
"(",
"they",
"are",
"rather",
"encouraged",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L219-L251 | [
"def",
"constrain",
"(",
"self",
")",
":",
"dx",
"=",
"self",
".",
"w",
"*",
"0.1",
"dy",
"=",
"self",
".",
"h",
"*",
"0.1",
"for",
"b",
"in",
"self",
":",
"if",
"b",
".",
"x",
"<",
"self",
".",
"x",
"-",
"dx",
":",
"b",
".",
"vx",
"+=",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Boids.update | Calculates the next motion frame for the flock. | lib/boids/__init__.py | def update(self,
shuffled=True,
cohesion=100,
separation=10,
alignment=5,
goal=20,
limit=30):
""" Calculates the next motion frame for the flock.
"""
# Shuffling the list of boids ens... | def update(self,
shuffled=True,
cohesion=100,
separation=10,
alignment=5,
goal=20,
limit=30):
""" Calculates the next motion frame for the flock.
"""
# Shuffling the list of boids ens... | [
"Calculates",
"the",
"next",
"motion",
"frame",
"for",
"the",
"flock",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/boids/__init__.py#L253-L323 | [
"def",
"update",
"(",
"self",
",",
"shuffled",
"=",
"True",
",",
"cohesion",
"=",
"100",
",",
"separation",
"=",
"10",
",",
"alignment",
"=",
"5",
",",
"goal",
"=",
"20",
",",
"limit",
"=",
"30",
")",
":",
"# Shuffling the list of boids ensures fluid movem... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Scanner.iterscan | Yield match, end_idx for each match | lib/web/simplejson/scanner.py | def iterscan(self, string, idx=0, context=None):
"""
Yield match, end_idx for each match
"""
match = self.scanner.scanner(string, idx).match
actions = self.actions
lastend = idx
end = len(string)
while True:
m = match()
if m is None... | def iterscan(self, string, idx=0, context=None):
"""
Yield match, end_idx for each match
"""
match = self.scanner.scanner(string, idx).match
actions = self.actions
lastend = idx
end = len(string)
while True:
m = match()
if m is None... | [
"Yield",
"match",
"end_idx",
"for",
"each",
"match"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/simplejson/scanner.py#L36-L59 | [
"def",
"iterscan",
"(",
"self",
",",
"string",
",",
"idx",
"=",
"0",
",",
"context",
"=",
"None",
")",
":",
"match",
"=",
"self",
".",
"scanner",
".",
"scanner",
"(",
"string",
",",
"idx",
")",
".",
"match",
"actions",
"=",
"self",
".",
"actions",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | layout.copy | Returns a copy of the layout for the given graph. | lib/graph/layout.py | def copy(self, graph):
""" Returns a copy of the layout for the given graph.
"""
l = self.__class__(graph, self.n)
l.i = 0
return l | def copy(self, graph):
""" Returns a copy of the layout for the given graph.
"""
l = self.__class__(graph, self.n)
l.i = 0
return l | [
"Returns",
"a",
"copy",
"of",
"the",
"layout",
"for",
"the",
"given",
"graph",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/layout.py#L26-L33 | [
"def",
"copy",
"(",
"self",
",",
"graph",
")",
":",
"l",
"=",
"self",
".",
"__class__",
"(",
"graph",
",",
"self",
".",
"n",
")",
"l",
".",
"i",
"=",
"0",
"return",
"l"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | create | Returns a new graph with predefined styling. | lib/graph/__init__.py | def create(iterations=1000, distance=1.0, layout=LAYOUT_SPRING, depth=True):
""" Returns a new graph with predefined styling.
"""
#global _ctx
_ctx.colormode(_ctx.RGB)
g = graph(iterations, distance, layout)
# Styles for different types of nodes.
s = style.style
... | def create(iterations=1000, distance=1.0, layout=LAYOUT_SPRING, depth=True):
""" Returns a new graph with predefined styling.
"""
#global _ctx
_ctx.colormode(_ctx.RGB)
g = graph(iterations, distance, layout)
# Styles for different types of nodes.
s = style.style
... | [
"Returns",
"a",
"new",
"graph",
"with",
"predefined",
"styling",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L725-L797 | [
"def",
"create",
"(",
"iterations",
"=",
"1000",
",",
"distance",
"=",
"1.0",
",",
"layout",
"=",
"LAYOUT_SPRING",
",",
"depth",
"=",
"True",
")",
":",
"#global _ctx",
"_ctx",
".",
"colormode",
"(",
"_ctx",
".",
"RGB",
")",
"g",
"=",
"graph",
"(",
"i... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | node.can_reach | Returns True if given node can be reached over traversable edges.
To enforce edge direction, use a node==edge.node1 traversable. | lib/graph/__init__.py | def can_reach(self, node, traversable=lambda node, edge: True):
""" Returns True if given node can be reached over traversable edges.
To enforce edge direction, use a node==edge.node1 traversable.
"""
if isinstance(node, str):
node = self.graph[node]
... | def can_reach(self, node, traversable=lambda node, edge: True):
""" Returns True if given node can be reached over traversable edges.
To enforce edge direction, use a node==edge.node1 traversable.
"""
if isinstance(node, str):
node = self.graph[node]
... | [
"Returns",
"True",
"if",
"given",
"node",
"can",
"be",
"reached",
"over",
"traversable",
"edges",
".",
"To",
"enforce",
"edge",
"direction",
"use",
"a",
"node",
"==",
"edge",
".",
"node1",
"traversable",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L69-L82 | [
"def",
"can_reach",
"(",
"self",
",",
"node",
",",
"traversable",
"=",
"lambda",
"node",
",",
"edge",
":",
"True",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"str",
")",
":",
"node",
"=",
"self",
".",
"graph",
"[",
"node",
"]",
"for",
"n",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.copy | Create a copy of the graph (by default with nodes and edges). | lib/graph/__init__.py | def copy(self, empty=False):
""" Create a copy of the graph (by default with nodes and edges).
"""
g = graph(self.layout.n, self.distance, self.layout.type)
g.layout = self.layout.copy(g)
g.styles = self.styles.copy(g)
g.events = self.events.copy(g)
... | def copy(self, empty=False):
""" Create a copy of the graph (by default with nodes and edges).
"""
g = graph(self.layout.n, self.distance, self.layout.type)
g.layout = self.layout.copy(g)
g.styles = self.styles.copy(g)
g.events = self.events.copy(g)
... | [
"Create",
"a",
"copy",
"of",
"the",
"graph",
"(",
"by",
"default",
"with",
"nodes",
"and",
"edges",
")",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L241-L257 | [
"def",
"copy",
"(",
"self",
",",
"empty",
"=",
"False",
")",
":",
"g",
"=",
"graph",
"(",
"self",
".",
"layout",
".",
"n",
",",
"self",
".",
"distance",
",",
"self",
".",
"layout",
".",
"type",
")",
"g",
".",
"layout",
"=",
"self",
".",
"layout... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.clear | Remove nodes and edges and reset the layout. | lib/graph/__init__.py | def clear(self):
""" Remove nodes and edges and reset the layout.
"""
dict.clear(self)
self.nodes = []
self.edges = []
self.root = None
self.layout.i = 0
self.alpha = 0 | def clear(self):
""" Remove nodes and edges and reset the layout.
"""
dict.clear(self)
self.nodes = []
self.edges = []
self.root = None
self.layout.i = 0
self.alpha = 0 | [
"Remove",
"nodes",
"and",
"edges",
"and",
"reset",
"the",
"layout",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L259-L270 | [
"def",
"clear",
"(",
"self",
")",
":",
"dict",
".",
"clear",
"(",
"self",
")",
"self",
".",
"nodes",
"=",
"[",
"]",
"self",
".",
"edges",
"=",
"[",
"]",
"self",
".",
"root",
"=",
"None",
"self",
".",
"layout",
".",
"i",
"=",
"0",
"self",
".",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.add_node | Add node from id and return the node object. | lib/graph/__init__.py | def add_node(self, id, radius=8, style=style.DEFAULT, category="", label=None, root=False,
properties={}):
""" Add node from id and return the node object.
"""
if self.has_key(id):
return self[id]
if not isinstance(style, str) ... | def add_node(self, id, radius=8, style=style.DEFAULT, category="", label=None, root=False,
properties={}):
""" Add node from id and return the node object.
"""
if self.has_key(id):
return self[id]
if not isinstance(style, str) ... | [
"Add",
"node",
"from",
"id",
"and",
"return",
"the",
"node",
"object",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L272-L289 | [
"def",
"add_node",
"(",
"self",
",",
"id",
",",
"radius",
"=",
"8",
",",
"style",
"=",
"style",
".",
"DEFAULT",
",",
"category",
"=",
"\"\"",
",",
"label",
"=",
"None",
",",
"root",
"=",
"False",
",",
"properties",
"=",
"{",
"}",
")",
":",
"if",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.add_edge | Add weighted (0.0-1.0) edge between nodes, creating them if necessary.
The weight represents the importance of the connection (not the cost). | lib/graph/__init__.py | def add_edge(self, id1, id2, weight=0.0, length=1.0, label="", properties={}):
""" Add weighted (0.0-1.0) edge between nodes, creating them if necessary.
The weight represents the importance of the connection (not the cost).
"""
if id1 == id2: return None
... | def add_edge(self, id1, id2, weight=0.0, length=1.0, label="", properties={}):
""" Add weighted (0.0-1.0) edge between nodes, creating them if necessary.
The weight represents the importance of the connection (not the cost).
"""
if id1 == id2: return None
... | [
"Add",
"weighted",
"(",
"0",
".",
"0",
"-",
"1",
".",
"0",
")",
"edge",
"between",
"nodes",
"creating",
"them",
"if",
"necessary",
".",
"The",
"weight",
"represents",
"the",
"importance",
"of",
"the",
"connection",
"(",
"not",
"the",
"cost",
")",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L298-L324 | [
"def",
"add_edge",
"(",
"self",
",",
"id1",
",",
"id2",
",",
"weight",
"=",
"0.0",
",",
"length",
"=",
"1.0",
",",
"label",
"=",
"\"\"",
",",
"properties",
"=",
"{",
"}",
")",
":",
"if",
"id1",
"==",
"id2",
":",
"return",
"None",
"if",
"not",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.remove_node | Remove node with given id. | lib/graph/__init__.py | def remove_node(self, id):
""" Remove node with given id.
"""
if self.has_key(id):
n = self[id]
self.nodes.remove(n)
del self[id]
# Remove all edges involving id and all links to it.
for e in list(self.edges):
... | def remove_node(self, id):
""" Remove node with given id.
"""
if self.has_key(id):
n = self[id]
self.nodes.remove(n)
del self[id]
# Remove all edges involving id and all links to it.
for e in list(self.edges):
... | [
"Remove",
"node",
"with",
"given",
"id",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L326-L343 | [
"def",
"remove_node",
"(",
"self",
",",
"id",
")",
":",
"if",
"self",
".",
"has_key",
"(",
"id",
")",
":",
"n",
"=",
"self",
"[",
"id",
"]",
"self",
".",
"nodes",
".",
"remove",
"(",
"n",
")",
"del",
"self",
"[",
"id",
"]",
"# Remove all edges in... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.remove_edge | Remove edges between nodes with given id's. | lib/graph/__init__.py | def remove_edge(self, id1, id2):
""" Remove edges between nodes with given id's.
"""
for e in list(self.edges):
if id1 in (e.node1.id, e.node2.id) and \
id2 in (e.node1.id, e.node2.id):
e.node1.links.remove(e.node2)
e.n... | def remove_edge(self, id1, id2):
""" Remove edges between nodes with given id's.
"""
for e in list(self.edges):
if id1 in (e.node1.id, e.node2.id) and \
id2 in (e.node1.id, e.node2.id):
e.node1.links.remove(e.node2)
e.n... | [
"Remove",
"edges",
"between",
"nodes",
"with",
"given",
"id",
"s",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L345-L355 | [
"def",
"remove_edge",
"(",
"self",
",",
"id1",
",",
"id2",
")",
":",
"for",
"e",
"in",
"list",
"(",
"self",
".",
"edges",
")",
":",
"if",
"id1",
"in",
"(",
"e",
".",
"node1",
".",
"id",
",",
"e",
".",
"node2",
".",
"id",
")",
"and",
"id2",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.edge | Returns the edge between the nodes with given id1 and id2. | lib/graph/__init__.py | def edge(self, id1, id2):
""" Returns the edge between the nodes with given id1 and id2.
"""
if id1 in self and \
id2 in self and \
self[id2] in self[id1].links:
return self[id1].links.edge(id2)
return None | def edge(self, id1, id2):
""" Returns the edge between the nodes with given id1 and id2.
"""
if id1 in self and \
id2 in self and \
self[id2] in self[id1].links:
return self[id1].links.edge(id2)
return None | [
"Returns",
"the",
"edge",
"between",
"the",
"nodes",
"with",
"given",
"id1",
"and",
"id2",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L364-L371 | [
"def",
"edge",
"(",
"self",
",",
"id1",
",",
"id2",
")",
":",
"if",
"id1",
"in",
"self",
"and",
"id2",
"in",
"self",
"and",
"self",
"[",
"id2",
"]",
"in",
"self",
"[",
"id1",
"]",
".",
"links",
":",
"return",
"self",
"[",
"id1",
"]",
".",
"li... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.update | Iterates the graph layout and updates node positions. | lib/graph/__init__.py | def update(self, iterations=10):
""" Iterates the graph layout and updates node positions.
"""
# The graph fades in when initially constructed.
self.alpha += 0.05
self.alpha = min(self.alpha, 1.0)
# Iterates over the graph's layout.
# Each s... | def update(self, iterations=10):
""" Iterates the graph layout and updates node positions.
"""
# The graph fades in when initially constructed.
self.alpha += 0.05
self.alpha = min(self.alpha, 1.0)
# Iterates over the graph's layout.
# Each s... | [
"Iterates",
"the",
"graph",
"layout",
"and",
"updates",
"node",
"positions",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L381-L411 | [
"def",
"update",
"(",
"self",
",",
"iterations",
"=",
"10",
")",
":",
"# The graph fades in when initially constructed.",
"self",
".",
"alpha",
"+=",
"0.05",
"self",
".",
"alpha",
"=",
"min",
"(",
"self",
".",
"alpha",
",",
"1.0",
")",
"# Iterates over the gra... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.offset | Returns the distance from the center to the given node. | lib/graph/__init__.py | def offset(self, node):
""" Returns the distance from the center to the given node.
"""
x = self.x + node.x - _ctx.WIDTH/2
y = self.y + node.y - _ctx.HEIGHT/2
return x, y | def offset(self, node):
""" Returns the distance from the center to the given node.
"""
x = self.x + node.x - _ctx.WIDTH/2
y = self.y + node.y - _ctx.HEIGHT/2
return x, y | [
"Returns",
"the",
"distance",
"from",
"the",
"center",
"to",
"the",
"given",
"node",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L424-L429 | [
"def",
"offset",
"(",
"self",
",",
"node",
")",
":",
"x",
"=",
"self",
".",
"x",
"+",
"node",
".",
"x",
"-",
"_ctx",
".",
"WIDTH",
"/",
"2",
"y",
"=",
"self",
".",
"y",
"+",
"node",
".",
"y",
"-",
"_ctx",
".",
"HEIGHT",
"/",
"2",
"return",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.draw | Layout the graph incrementally.
The graph is drawn at the center of the canvas.
The weighted and directed parameters visualize edge weight and direction.
The highlight specifies list of connected nodes.
The path will be colored according to the "highlight" style.
Clicki... | lib/graph/__init__.py | def draw(self, dx=0, dy=0, weighted=False, directed=False, highlight=[], traffic=None):
""" Layout the graph incrementally.
The graph is drawn at the center of the canvas.
The weighted and directed parameters visualize edge weight and direction.
The highlight specifies ... | def draw(self, dx=0, dy=0, weighted=False, directed=False, highlight=[], traffic=None):
""" Layout the graph incrementally.
The graph is drawn at the center of the canvas.
The weighted and directed parameters visualize edge weight and direction.
The highlight specifies ... | [
"Layout",
"the",
"graph",
"incrementally",
".",
"The",
"graph",
"is",
"drawn",
"at",
"the",
"center",
"of",
"the",
"canvas",
".",
"The",
"weighted",
"and",
"directed",
"parameters",
"visualize",
"edge",
"weight",
"and",
"direction",
".",
"The",
"highlight",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L431-L494 | [
"def",
"draw",
"(",
"self",
",",
"dx",
"=",
"0",
",",
"dy",
"=",
"0",
",",
"weighted",
"=",
"False",
",",
"directed",
"=",
"False",
",",
"highlight",
"=",
"[",
"]",
",",
"traffic",
"=",
"None",
")",
":",
"self",
".",
"update",
"(",
")",
"# Draw... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.prune | Removes all nodes with less or equal links than depth. | lib/graph/__init__.py | def prune(self, depth=0):
""" Removes all nodes with less or equal links than depth.
"""
for n in list(self.nodes):
if len(n.links) <= depth:
self.remove_node(n.id) | def prune(self, depth=0):
""" Removes all nodes with less or equal links than depth.
"""
for n in list(self.nodes):
if len(n.links) <= depth:
self.remove_node(n.id) | [
"Removes",
"all",
"nodes",
"with",
"less",
"or",
"equal",
"links",
"than",
"depth",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L496-L501 | [
"def",
"prune",
"(",
"self",
",",
"depth",
"=",
"0",
")",
":",
"for",
"n",
"in",
"list",
"(",
"self",
".",
"nodes",
")",
":",
"if",
"len",
"(",
"n",
".",
"links",
")",
"<=",
"depth",
":",
"self",
".",
"remove_node",
"(",
"n",
".",
"id",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.betweenness_centrality | Calculates betweenness centrality and returns an node id -> weight dictionary.
Node betweenness weights are updated in the process. | lib/graph/__init__.py | def betweenness_centrality(self, normalized=True):
""" Calculates betweenness centrality and returns an node id -> weight dictionary.
Node betweenness weights are updated in the process.
"""
bc = proximity.brandes_betweenness_centrality(self, normalized)
for id, w in bc.iteritems... | def betweenness_centrality(self, normalized=True):
""" Calculates betweenness centrality and returns an node id -> weight dictionary.
Node betweenness weights are updated in the process.
"""
bc = proximity.brandes_betweenness_centrality(self, normalized)
for id, w in bc.iteritems... | [
"Calculates",
"betweenness",
"centrality",
"and",
"returns",
"an",
"node",
"id",
"-",
">",
"weight",
"dictionary",
".",
"Node",
"betweenness",
"weights",
"are",
"updated",
"in",
"the",
"process",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L512-L518 | [
"def",
"betweenness_centrality",
"(",
"self",
",",
"normalized",
"=",
"True",
")",
":",
"bc",
"=",
"proximity",
".",
"brandes_betweenness_centrality",
"(",
"self",
",",
"normalized",
")",
"for",
"id",
",",
"w",
"in",
"bc",
".",
"iteritems",
"(",
")",
":",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.eigenvector_centrality | Calculates eigenvector centrality and returns an node id -> weight dictionary.
Node eigenvalue weights are updated in the process. | lib/graph/__init__.py | def eigenvector_centrality(self, normalized=True, reversed=True, rating={},
start=None, iterations=100, tolerance=0.0001):
""" Calculates eigenvector centrality and returns an node id -> weight dictionary.
Node eigenvalue weights are updated in the process.
"""
... | def eigenvector_centrality(self, normalized=True, reversed=True, rating={},
start=None, iterations=100, tolerance=0.0001):
""" Calculates eigenvector centrality and returns an node id -> weight dictionary.
Node eigenvalue weights are updated in the process.
"""
... | [
"Calculates",
"eigenvector",
"centrality",
"and",
"returns",
"an",
"node",
"id",
"-",
">",
"weight",
"dictionary",
".",
"Node",
"eigenvalue",
"weights",
"are",
"updated",
"in",
"the",
"process",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L520-L529 | [
"def",
"eigenvector_centrality",
"(",
"self",
",",
"normalized",
"=",
"True",
",",
"reversed",
"=",
"True",
",",
"rating",
"=",
"{",
"}",
",",
"start",
"=",
"None",
",",
"iterations",
"=",
"100",
",",
"tolerance",
"=",
"0.0001",
")",
":",
"ec",
"=",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.nodes_by_betweenness | Returns nodes sorted by betweenness centrality.
Nodes with a lot of passing traffic will be at the front of the list. | lib/graph/__init__.py | def nodes_by_betweenness(self, treshold=0.0):
""" Returns nodes sorted by betweenness centrality.
Nodes with a lot of passing traffic will be at the front of the list.
"""
nodes = [(n.betweenness, n) for n in self.nodes if n.betweenness > treshold]
nodes.sort(); nodes.reverse()
... | def nodes_by_betweenness(self, treshold=0.0):
""" Returns nodes sorted by betweenness centrality.
Nodes with a lot of passing traffic will be at the front of the list.
"""
nodes = [(n.betweenness, n) for n in self.nodes if n.betweenness > treshold]
nodes.sort(); nodes.reverse()
... | [
"Returns",
"nodes",
"sorted",
"by",
"betweenness",
"centrality",
".",
"Nodes",
"with",
"a",
"lot",
"of",
"passing",
"traffic",
"will",
"be",
"at",
"the",
"front",
"of",
"the",
"list",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L531-L537 | [
"def",
"nodes_by_betweenness",
"(",
"self",
",",
"treshold",
"=",
"0.0",
")",
":",
"nodes",
"=",
"[",
"(",
"n",
".",
"betweenness",
",",
"n",
")",
"for",
"n",
"in",
"self",
".",
"nodes",
"if",
"n",
".",
"betweenness",
">",
"treshold",
"]",
"nodes",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.nodes_by_eigenvalue | Returns nodes sorted by eigenvector centrality.
Nodes with a lot of incoming traffic will be at the front of the list | lib/graph/__init__.py | def nodes_by_eigenvalue(self, treshold=0.0):
""" Returns nodes sorted by eigenvector centrality.
Nodes with a lot of incoming traffic will be at the front of the list
"""
nodes = [(n.eigenvalue, n) for n in self.nodes if n.eigenvalue > treshold]
nodes.sort(); nodes.reverse()
... | def nodes_by_eigenvalue(self, treshold=0.0):
""" Returns nodes sorted by eigenvector centrality.
Nodes with a lot of incoming traffic will be at the front of the list
"""
nodes = [(n.eigenvalue, n) for n in self.nodes if n.eigenvalue > treshold]
nodes.sort(); nodes.reverse()
... | [
"Returns",
"nodes",
"sorted",
"by",
"eigenvector",
"centrality",
".",
"Nodes",
"with",
"a",
"lot",
"of",
"incoming",
"traffic",
"will",
"be",
"at",
"the",
"front",
"of",
"the",
"list"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L541-L547 | [
"def",
"nodes_by_eigenvalue",
"(",
"self",
",",
"treshold",
"=",
"0.0",
")",
":",
"nodes",
"=",
"[",
"(",
"n",
".",
"eigenvalue",
",",
"n",
")",
"for",
"n",
"in",
"self",
".",
"nodes",
"if",
"n",
".",
"eigenvalue",
">",
"treshold",
"]",
"nodes",
".... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.nodes_by_category | Returns nodes with the given category attribute. | lib/graph/__init__.py | def nodes_by_category(self, category):
""" Returns nodes with the given category attribute.
"""
return [n for n in self.nodes if n.category == category] | def nodes_by_category(self, category):
""" Returns nodes with the given category attribute.
"""
return [n for n in self.nodes if n.category == category] | [
"Returns",
"nodes",
"with",
"the",
"given",
"category",
"attribute",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L551-L554 | [
"def",
"nodes_by_category",
"(",
"self",
",",
"category",
")",
":",
"return",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"nodes",
"if",
"n",
".",
"category",
"==",
"category",
"]"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph.crown | Returns a list of leaves, nodes connected to leaves, etc. | lib/graph/__init__.py | def crown(self, depth=2):
""" Returns a list of leaves, nodes connected to leaves, etc.
"""
nodes = []
for node in self.leaves: nodes += node.flatten(depth-1)
return cluster.unique(nodes) | def crown(self, depth=2):
""" Returns a list of leaves, nodes connected to leaves, etc.
"""
nodes = []
for node in self.leaves: nodes += node.flatten(depth-1)
return cluster.unique(nodes) | [
"Returns",
"a",
"list",
"of",
"leaves",
"nodes",
"connected",
"to",
"leaves",
"etc",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L563-L568 | [
"def",
"crown",
"(",
"self",
",",
"depth",
"=",
"2",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
".",
"leaves",
":",
"nodes",
"+=",
"node",
".",
"flatten",
"(",
"depth",
"-",
"1",
")",
"return",
"cluster",
".",
"unique",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph._density | The number of edges in relation to the total number of possible edges. | lib/graph/__init__.py | def _density(self):
""" The number of edges in relation to the total number of possible edges.
"""
return 2.0*len(self.edges) / (len(self.nodes) * (len(self.nodes)-1)) | def _density(self):
""" The number of edges in relation to the total number of possible edges.
"""
return 2.0*len(self.edges) / (len(self.nodes) * (len(self.nodes)-1)) | [
"The",
"number",
"of",
"edges",
"in",
"relation",
"to",
"the",
"total",
"number",
"of",
"possible",
"edges",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L572-L575 | [
"def",
"_density",
"(",
"self",
")",
":",
"return",
"2.0",
"*",
"len",
"(",
"self",
".",
"edges",
")",
"/",
"(",
"len",
"(",
"self",
".",
"nodes",
")",
"*",
"(",
"len",
"(",
"self",
".",
"nodes",
")",
"-",
"1",
")",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | xgraph.load | Rebuilds the graph around the given node id. | lib/graph/__init__.py | def load(self, id):
""" Rebuilds the graph around the given node id.
"""
self.clear()
# Root node.
self.add_node(id, root=True)
# Directly connected nodes have priority.
for w, id2 in self.get_links(id):
self.add_edge(id, id... | def load(self, id):
""" Rebuilds the graph around the given node id.
"""
self.clear()
# Root node.
self.add_node(id, root=True)
# Directly connected nodes have priority.
for w, id2 in self.get_links(id):
self.add_edge(id, id... | [
"Rebuilds",
"the",
"graph",
"around",
"the",
"given",
"node",
"id",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L672-L700 | [
"def",
"load",
"(",
"self",
",",
"id",
")",
":",
"self",
".",
"clear",
"(",
")",
"# Root node.",
"self",
".",
"add_node",
"(",
"id",
",",
"root",
"=",
"True",
")",
"# Directly connected nodes have priority.",
"for",
"w",
",",
"id2",
"in",
"self",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | xgraph.click | Callback from graph.events when a node is clicked. | lib/graph/__init__.py | def click(self, node):
""" Callback from graph.events when a node is clicked.
"""
if not self.has_node(node.id): return
if node == self.root: return
self._dx, self._dy = self.offset(node)
self.previous = self.root.id
self.load(node.id) | def click(self, node):
""" Callback from graph.events when a node is clicked.
"""
if not self.has_node(node.id): return
if node == self.root: return
self._dx, self._dy = self.offset(node)
self.previous = self.root.id
self.load(node.id) | [
"Callback",
"from",
"graph",
".",
"events",
"when",
"a",
"node",
"is",
"clicked",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/__init__.py#L702-L712 | [
"def",
"click",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"has_node",
"(",
"node",
".",
"id",
")",
":",
"return",
"if",
"node",
"==",
"self",
".",
"root",
":",
"return",
"self",
".",
"_dx",
",",
"self",
".",
"_dy",
"=",
"sel... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | bezier_arc | Compute a cubic Bezier approximation of an elliptical arc.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle.
The coordinate system has coordinates that increase to the right and down.
Angles, measured in degress, start with 0 to the right (the positive X axis)
and increase counter-cloc... | lib/svg/arc.py | def bezier_arc(x1, y1, x2, y2, start_angle=0, extent=90):
""" Compute a cubic Bezier approximation of an elliptical arc.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle.
The coordinate system has coordinates that increase to the right and down.
Angles, measured in degress, start w... | def bezier_arc(x1, y1, x2, y2, start_angle=0, extent=90):
""" Compute a cubic Bezier approximation of an elliptical arc.
(x1, y1) and (x2, y2) are the corners of the enclosing rectangle.
The coordinate system has coordinates that increase to the right and down.
Angles, measured in degress, start w... | [
"Compute",
"a",
"cubic",
"Bezier",
"approximation",
"of",
"an",
"elliptical",
"arc",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/arc.py#L29-L91 | [
"def",
"bezier_arc",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"start_angle",
"=",
"0",
",",
"extent",
"=",
"90",
")",
":",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
"=",
"min",
"(",
"x1",
",",
"x2",
")",
",",
"max",
"(",
"y1",
",",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | angle | The angle in degrees between two vectors. | lib/svg/arc.py | def angle(x1, y1, x2, y2):
""" The angle in degrees between two vectors.
"""
sign = 1.0
usign = (x1*y2 - y1*x2)
if usign < 0:
sign = -1.0
num = x1*x2 + y1*y2
den = hypot(x1,y1) * hypot(x2,y2)
ratio = min(max(num/den, -1.0), 1.0)
return sign * degrees(acos(ratio)) | def angle(x1, y1, x2, y2):
""" The angle in degrees between two vectors.
"""
sign = 1.0
usign = (x1*y2 - y1*x2)
if usign < 0:
sign = -1.0
num = x1*x2 + y1*y2
den = hypot(x1,y1) * hypot(x2,y2)
ratio = min(max(num/den, -1.0), 1.0)
return sign * degrees(acos(ratio)) | [
"The",
"angle",
"in",
"degrees",
"between",
"two",
"vectors",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/arc.py#L93-L103 | [
"def",
"angle",
"(",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
")",
":",
"sign",
"=",
"1.0",
"usign",
"=",
"(",
"x1",
"*",
"y2",
"-",
"y1",
"*",
"x2",
")",
"if",
"usign",
"<",
"0",
":",
"sign",
"=",
"-",
"1.0",
"num",
"=",
"x1",
"*",
"x2",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | transform_from_local | Transform from the local frame to absolute space. | lib/svg/arc.py | def transform_from_local(xp, yp, cphi, sphi, mx, my):
""" Transform from the local frame to absolute space.
"""
x = xp * cphi - yp * sphi + mx
y = xp * sphi + yp * cphi + my
return (x,y) | def transform_from_local(xp, yp, cphi, sphi, mx, my):
""" Transform from the local frame to absolute space.
"""
x = xp * cphi - yp * sphi + mx
y = xp * sphi + yp * cphi + my
return (x,y) | [
"Transform",
"from",
"the",
"local",
"frame",
"to",
"absolute",
"space",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/arc.py#L105-L110 | [
"def",
"transform_from_local",
"(",
"xp",
",",
"yp",
",",
"cphi",
",",
"sphi",
",",
"mx",
",",
"my",
")",
":",
"x",
"=",
"xp",
"*",
"cphi",
"-",
"yp",
"*",
"sphi",
"+",
"mx",
"y",
"=",
"xp",
"*",
"sphi",
"+",
"yp",
"*",
"cphi",
"+",
"my",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | elliptical_arc_to | An elliptical arc approximated with Bezier curves or a line segment.
Algorithm taken from the SVG 1.1 Implementation Notes:
http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes | lib/svg/arc.py | def elliptical_arc_to(x1, y1, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2):
""" An elliptical arc approximated with Bezier curves or a line segment.
Algorithm taken from the SVG 1.1 Implementation Notes:
http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
"""
# Basic normalizati... | def elliptical_arc_to(x1, y1, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2):
""" An elliptical arc approximated with Bezier curves or a line segment.
Algorithm taken from the SVG 1.1 Implementation Notes:
http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
"""
# Basic normalizati... | [
"An",
"elliptical",
"arc",
"approximated",
"with",
"Bezier",
"curves",
"or",
"a",
"line",
"segment",
".",
"Algorithm",
"taken",
"from",
"the",
"SVG",
"1",
".",
"1",
"Implementation",
"Notes",
":",
"http",
":",
"//",
"www",
".",
"w3",
".",
"org",
"/",
"... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/arc.py#L112-L186 | [
"def",
"elliptical_arc_to",
"(",
"x1",
",",
"y1",
",",
"rx",
",",
"ry",
",",
"phi",
",",
"large_arc_flag",
",",
"sweep_flag",
",",
"x2",
",",
"y2",
")",
":",
"# Basic normalization.",
"rx",
"=",
"abs",
"(",
"rx",
")",
"ry",
"=",
"abs",
"(",
"ry",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotPlugin._create_view | Create the gtk.TextView used for shell output | extensions/gedit/gedit3-plugin/shoebotit/__init__.py | def _create_view(self, name="shoebot-output"):
""" Create the gtk.TextView used for shell output """
view = Gtk.TextView()
view.set_editable(False)
fontdesc = Pango.FontDescription("Monospace")
view.modify_font(fontdesc)
view.set_name(name)
buff = view.get_buffe... | def _create_view(self, name="shoebot-output"):
""" Create the gtk.TextView used for shell output """
view = Gtk.TextView()
view.set_editable(False)
fontdesc = Pango.FontDescription("Monospace")
view.modify_font(fontdesc)
view.set_name(name)
buff = view.get_buffe... | [
"Create",
"the",
"gtk",
".",
"TextView",
"used",
"for",
"shell",
"output"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/gedit/gedit3-plugin/shoebotit/__init__.py#L262-L273 | [
"def",
"_create_view",
"(",
"self",
",",
"name",
"=",
"\"shoebot-output\"",
")",
":",
"view",
"=",
"Gtk",
".",
"TextView",
"(",
")",
"view",
".",
"set_editable",
"(",
"False",
")",
"fontdesc",
"=",
"Pango",
".",
"FontDescription",
"(",
"\"Monospace\"",
")"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.set_bot | Bot must be set before running | shoebot/core/canvas.py | def set_bot(self, bot):
''' Bot must be set before running '''
self.bot = bot
self.sink.set_bot(bot) | def set_bot(self, bot):
''' Bot must be set before running '''
self.bot = bot
self.sink.set_bot(bot) | [
"Bot",
"must",
"be",
"set",
"before",
"running"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L72-L75 | [
"def",
"set_bot",
"(",
"self",
",",
"bot",
")",
":",
"self",
".",
"bot",
"=",
"bot",
"self",
".",
"sink",
".",
"set_bot",
"(",
"bot",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.settings | Pass a load of settings into the canvas | shoebot/core/canvas.py | def settings(self, **kwargs):
'''
Pass a load of settings into the canvas
'''
for k, v in kwargs.items():
setattr(self, k, v) | def settings(self, **kwargs):
'''
Pass a load of settings into the canvas
'''
for k, v in kwargs.items():
setattr(self, k, v) | [
"Pass",
"a",
"load",
"of",
"settings",
"into",
"the",
"canvas"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L106-L111 | [
"def",
"settings",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"k",
",",
"v",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.size_or_default | If size is not set, otherwise set size to DEFAULT_SIZE
and return it.
This means, only the first call to size() is valid. | shoebot/core/canvas.py | def size_or_default(self):
'''
If size is not set, otherwise set size to DEFAULT_SIZE
and return it.
This means, only the first call to size() is valid.
'''
if not self.size:
self.size = self.DEFAULT_SIZE
return self.size | def size_or_default(self):
'''
If size is not set, otherwise set size to DEFAULT_SIZE
and return it.
This means, only the first call to size() is valid.
'''
if not self.size:
self.size = self.DEFAULT_SIZE
return self.size | [
"If",
"size",
"is",
"not",
"set",
"otherwise",
"set",
"size",
"to",
"DEFAULT_SIZE",
"and",
"return",
"it",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L113-L122 | [
"def",
"size_or_default",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"size",
":",
"self",
".",
"size",
"=",
"self",
".",
"DEFAULT_SIZE",
"return",
"self",
".",
"size"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.set_size | Size is only set the first time it is called
Size that is set is returned | shoebot/core/canvas.py | def set_size(self, size):
'''
Size is only set the first time it is called
Size that is set is returned
'''
if self.size is None:
self.size = size
return size
else:
return self.size | def set_size(self, size):
'''
Size is only set the first time it is called
Size that is set is returned
'''
if self.size is None:
self.size = size
return size
else:
return self.size | [
"Size",
"is",
"only",
"set",
"the",
"first",
"time",
"it",
"is",
"called"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L124-L134 | [
"def",
"set_size",
"(",
"self",
",",
"size",
")",
":",
"if",
"self",
".",
"size",
"is",
"None",
":",
"self",
".",
"size",
"=",
"size",
"return",
"size",
"else",
":",
"return",
"self",
".",
"size"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.snapshot | Ask the drawqueue to output to target.
target can be anything supported by the combination
of canvas implementation and drawqueue implmentation.
If target is not supported then an exception is thrown. | shoebot/core/canvas.py | def snapshot(self, target, defer=True, file_number=None):
'''
Ask the drawqueue to output to target.
target can be anything supported by the combination
of canvas implementation and drawqueue implmentation.
If target is not supported then an exception is thrown.
'''
... | def snapshot(self, target, defer=True, file_number=None):
'''
Ask the drawqueue to output to target.
target can be anything supported by the combination
of canvas implementation and drawqueue implmentation.
If target is not supported then an exception is thrown.
'''
... | [
"Ask",
"the",
"drawqueue",
"to",
"output",
"to",
"target",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L148-L161 | [
"def",
"snapshot",
"(",
"self",
",",
"target",
",",
"defer",
"=",
"True",
",",
"file_number",
"=",
"None",
")",
":",
"output_func",
"=",
"self",
".",
"output_closure",
"(",
"target",
",",
"file_number",
")",
"if",
"defer",
":",
"self",
".",
"_drawqueue",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Canvas.flush | Passes the drawqueue to the sink for rendering | shoebot/core/canvas.py | def flush(self, frame):
'''
Passes the drawqueue to the sink for rendering
'''
self.sink.render(self.size_or_default(), frame, self._drawqueue)
self.reset_drawqueue() | def flush(self, frame):
'''
Passes the drawqueue to the sink for rendering
'''
self.sink.render(self.size_or_default(), frame, self._drawqueue)
self.reset_drawqueue() | [
"Passes",
"the",
"drawqueue",
"to",
"the",
"sink",
"for",
"rendering"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/canvas.py#L163-L168 | [
"def",
"flush",
"(",
"self",
",",
"frame",
")",
":",
"self",
".",
"sink",
".",
"render",
"(",
"self",
".",
"size_or_default",
"(",
")",
",",
"frame",
",",
"self",
".",
"_drawqueue",
")",
"self",
".",
"reset_drawqueue",
"(",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.overlap | Returns True when point 1 and point 2 overlap.
There is an r treshold in which point 1 and point 2
are considered to overlap. | lib/beziereditor/__init__.py | def overlap(self, x1, y1, x2, y2, r=5):
""" Returns True when point 1 and point 2 overlap.
There is an r treshold in which point 1 and point 2
are considered to overlap.
"""
if abs(x2-x1) < r and abs(y2-y1) < r:
return True
... | def overlap(self, x1, y1, x2, y2, r=5):
""" Returns True when point 1 and point 2 overlap.
There is an r treshold in which point 1 and point 2
are considered to overlap.
"""
if abs(x2-x1) < r and abs(y2-y1) < r:
return True
... | [
"Returns",
"True",
"when",
"point",
"1",
"and",
"point",
"2",
"overlap",
".",
"There",
"is",
"an",
"r",
"treshold",
"in",
"which",
"point",
"1",
"and",
"point",
"2",
"are",
"considered",
"to",
"overlap",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L174-L186 | [
"def",
"overlap",
"(",
"self",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"r",
"=",
"5",
")",
":",
"if",
"abs",
"(",
"x2",
"-",
"x1",
")",
"<",
"r",
"and",
"abs",
"(",
"y2",
"-",
"y1",
")",
"<",
"r",
":",
"return",
"True",
"else",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.reflect | Reflects the point x, y through origin x0, y0. | lib/beziereditor/__init__.py | def reflect(self, x0, y0, x, y):
""" Reflects the point x, y through origin x0, y0.
"""
rx = x0 - (x-x0)
ry = y0 - (y-y0)
return rx, ry | def reflect(self, x0, y0, x, y):
""" Reflects the point x, y through origin x0, y0.
"""
rx = x0 - (x-x0)
ry = y0 - (y-y0)
return rx, ry | [
"Reflects",
"the",
"point",
"x",
"y",
"through",
"origin",
"x0",
"y0",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L188-L195 | [
"def",
"reflect",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x",
",",
"y",
")",
":",
"rx",
"=",
"x0",
"-",
"(",
"x",
"-",
"x0",
")",
"ry",
"=",
"y0",
"-",
"(",
"y",
"-",
"y0",
")",
"return",
"rx",
",",
"ry"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.angle | Calculates the angle between two points. | lib/beziereditor/__init__.py | def angle(self, x0, y0, x1, y1):
""" Calculates the angle between two points.
"""
a = degrees( atan((y1-y0) / (x1-x0+0.00001)) ) + 360
if x1-x0 < 0: a += 180
return a | def angle(self, x0, y0, x1, y1):
""" Calculates the angle between two points.
"""
a = degrees( atan((y1-y0) / (x1-x0+0.00001)) ) + 360
if x1-x0 < 0: a += 180
return a | [
"Calculates",
"the",
"angle",
"between",
"two",
"points",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L197-L204 | [
"def",
"angle",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
")",
":",
"a",
"=",
"degrees",
"(",
"atan",
"(",
"(",
"y1",
"-",
"y0",
")",
"/",
"(",
"x1",
"-",
"x0",
"+",
"0.00001",
")",
")",
")",
"+",
"360",
"if",
"x1",
"-",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.coordinates | Calculates the coordinates of a point from the origin. | lib/beziereditor/__init__.py | def coordinates(self, x0, y0, distance, angle):
""" Calculates the coordinates of a point from the origin.
"""
x = x0 + cos(radians(angle)) * distance
y = y0 + sin(radians(angle)) * distance
return Point(x, y) | def coordinates(self, x0, y0, distance, angle):
""" Calculates the coordinates of a point from the origin.
"""
x = x0 + cos(radians(angle)) * distance
y = y0 + sin(radians(angle)) * distance
return Point(x, y) | [
"Calculates",
"the",
"coordinates",
"of",
"a",
"point",
"from",
"the",
"origin",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L213-L220 | [
"def",
"coordinates",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"distance",
",",
"angle",
")",
":",
"x",
"=",
"x0",
"+",
"cos",
"(",
"radians",
"(",
"angle",
")",
")",
"*",
"distance",
"y",
"=",
"y0",
"+",
"sin",
"(",
"radians",
"(",
"angle",
")"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.contains_point | Returns true when x, y is on the path stroke outline. | lib/beziereditor/__init__.py | def contains_point(self, x, y, d=2):
""" Returns true when x, y is on the path stroke outline.
"""
if self.path != None and len(self.path) > 1 \
and self.path.contains(x, y):
# If all points around the mouse are also part of the path,
# this mean... | def contains_point(self, x, y, d=2):
""" Returns true when x, y is on the path stroke outline.
"""
if self.path != None and len(self.path) > 1 \
and self.path.contains(x, y):
# If all points around the mouse are also part of the path,
# this mean... | [
"Returns",
"true",
"when",
"x",
"y",
"is",
"on",
"the",
"path",
"stroke",
"outline",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L222-L243 | [
"def",
"contains_point",
"(",
"self",
",",
"x",
",",
"y",
",",
"d",
"=",
"2",
")",
":",
"if",
"self",
".",
"path",
"!=",
"None",
"and",
"len",
"(",
"self",
".",
"path",
")",
">",
"1",
"and",
"self",
".",
"path",
".",
"contains",
"(",
"x",
","... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.insert_point | Inserts a point on the path at the mouse location.
We first need to check if the mouse location is on the path.
Inserting point is time intensive and experimental. | lib/beziereditor/__init__.py | def insert_point(self, x, y):
""" Inserts a point on the path at the mouse location.
We first need to check if the mouse location is on the path.
Inserting point is time intensive and experimental.
"""
try:
bezier = _ctx.ximport("b... | def insert_point(self, x, y):
""" Inserts a point on the path at the mouse location.
We first need to check if the mouse location is on the path.
Inserting point is time intensive and experimental.
"""
try:
bezier = _ctx.ximport("b... | [
"Inserts",
"a",
"point",
"on",
"the",
"path",
"at",
"the",
"mouse",
"location",
".",
"We",
"first",
"need",
"to",
"check",
"if",
"the",
"mouse",
"location",
"is",
"on",
"the",
"path",
".",
"Inserting",
"point",
"is",
"time",
"intensive",
"and",
"experime... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L245-L316 | [
"def",
"insert_point",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"try",
":",
"bezier",
"=",
"_ctx",
".",
"ximport",
"(",
"\"bezier\"",
")",
"except",
":",
"from",
"nodebox",
".",
"graphics",
"import",
"bezier",
"# Do a number of checks distributed along the p... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.update | Update runs each frame to check for mouse interaction.
Alters the path by allowing the user to add new points,
drag point handles and move their location.
Updates are automatically stored as SVG
in the given filename. | lib/beziereditor/__init__.py | def update(self):
""" Update runs each frame to check for mouse interaction.
Alters the path by allowing the user to add new points,
drag point handles and move their location.
Updates are automatically stored as SVG
in the given filename.
"""
... | def update(self):
""" Update runs each frame to check for mouse interaction.
Alters the path by allowing the user to add new points,
drag point handles and move their location.
Updates are automatically stored as SVG
in the given filename.
"""
... | [
"Update",
"runs",
"each",
"frame",
"to",
"check",
"for",
"mouse",
"interaction",
".",
"Alters",
"the",
"path",
"by",
"allowing",
"the",
"user",
"to",
"add",
"new",
"points",
"drag",
"point",
"handles",
"and",
"move",
"their",
"location",
".",
"Updates",
"a... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L318-L635 | [
"def",
"update",
"(",
"self",
")",
":",
"x",
",",
"y",
"=",
"mouse",
"(",
")",
"if",
"self",
".",
"show_grid",
":",
"x",
",",
"y",
"=",
"self",
".",
"grid",
".",
"snap",
"(",
"x",
",",
"y",
")",
"if",
"_ctx",
".",
"_ns",
"[",
"\"mousedown\"",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.draw | Draws the editable path and interface elements. | lib/beziereditor/__init__.py | def draw(self):
""" Draws the editable path and interface elements.
"""
# Enable interaction.
self.update()
x, y = mouse()
# Snap to grid when enabled.
# The grid is enabled with the TAB key.
if self.show_grid:
... | def draw(self):
""" Draws the editable path and interface elements.
"""
# Enable interaction.
self.update()
x, y = mouse()
# Snap to grid when enabled.
# The grid is enabled with the TAB key.
if self.show_grid:
... | [
"Draws",
"the",
"editable",
"path",
"and",
"interface",
"elements",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L637-L842 | [
"def",
"draw",
"(",
"self",
")",
":",
"# Enable interaction.",
"self",
".",
"update",
"(",
")",
"x",
",",
"y",
"=",
"mouse",
"(",
")",
"# Snap to grid when enabled.",
"# The grid is enabled with the TAB key.",
"if",
"self",
".",
"show_grid",
":",
"self",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.draw_freehand | Freehand sketching. | lib/beziereditor/__init__.py | def draw_freehand(self):
""" Freehand sketching.
"""
if _ctx._ns["mousedown"]:
x, y = mouse()
if self.show_grid:
x, y = self.grid.snap(x, y)
if self.freehand_move == True:
cmd = MOVETO... | def draw_freehand(self):
""" Freehand sketching.
"""
if _ctx._ns["mousedown"]:
x, y = mouse()
if self.show_grid:
x, y = self.grid.snap(x, y)
if self.freehand_move == True:
cmd = MOVETO... | [
"Freehand",
"sketching",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L844-L895 | [
"def",
"draw_freehand",
"(",
"self",
")",
":",
"if",
"_ctx",
".",
"_ns",
"[",
"\"mousedown\"",
"]",
":",
"x",
",",
"y",
"=",
"mouse",
"(",
")",
"if",
"self",
".",
"show_grid",
":",
"x",
",",
"y",
"=",
"self",
".",
"grid",
".",
"snap",
"(",
"x",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BezierPathEditor.export_svg | Exports the path as SVG.
Uses the filename given when creating this object.
The file is automatically updated to reflect
changes to the path. | lib/beziereditor/__init__.py | def export_svg(self):
""" Exports the path as SVG.
Uses the filename given when creating this object.
The file is automatically updated to reflect
changes to the path.
"""
d = ""
if len(self._points) > 0:
d += "M "+s... | def export_svg(self):
""" Exports the path as SVG.
Uses the filename given when creating this object.
The file is automatically updated to reflect
changes to the path.
"""
d = ""
if len(self._points) > 0:
d += "M "+s... | [
"Exports",
"the",
"path",
"as",
"SVG",
".",
"Uses",
"the",
"filename",
"given",
"when",
"creating",
"this",
"object",
".",
"The",
"file",
"is",
"automatically",
"updated",
"to",
"reflect",
"changes",
"to",
"the",
"path",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/beziereditor/__init__.py#L897-L935 | [
"def",
"export_svg",
"(",
"self",
")",
":",
"d",
"=",
"\"\"",
"if",
"len",
"(",
"self",
".",
"_points",
")",
">",
"0",
":",
"d",
"+=",
"\"M \"",
"+",
"str",
"(",
"self",
".",
"_points",
"[",
"0",
"]",
".",
"x",
")",
"+",
"\" \"",
"+",
"str",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | FlickrImage.download | Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator
that will fetch the image's URL from Flickr.
A second process then downloads the file at the retrieved URL.
Once it is done downloading, this image will have its pat... | lib/web/flickr.py | def download(self, size=SIZE_XLARGE, thumbnail=False, wait=60, asynchronous=False):
""" Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator
that will fetch the image's URL from Flickr.
A second process then downloads ... | def download(self, size=SIZE_XLARGE, thumbnail=False, wait=60, asynchronous=False):
""" Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator
that will fetch the image's URL from Flickr.
A second process then downloads ... | [
"Downloads",
"this",
"image",
"to",
"cache",
".",
"Calling",
"the",
"download",
"()",
"method",
"instantiates",
"an",
"asynchronous",
"URLAccumulator",
"that",
"will",
"fetch",
"the",
"image",
"s",
"URL",
"from",
"Flickr",
".",
"A",
"second",
"process",
"then"... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/flickr.py#L62-L86 | [
"def",
"download",
"(",
"self",
",",
"size",
"=",
"SIZE_XLARGE",
",",
"thumbnail",
"=",
"False",
",",
"wait",
"=",
"60",
",",
"asynchronous",
"=",
"False",
")",
":",
"if",
"thumbnail",
"==",
"True",
":",
"size",
"=",
"SIZE_THUMBNAIL",
"# backwards compatib... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.gtk_mouse_button_down | Handle right mouse button clicks | shoebot/gui/gtk_window.py | def gtk_mouse_button_down(self, widget, event):
''' Handle right mouse button clicks '''
if self.menu_enabled and event.button == 3:
menu = self.uimanager.get_widget('/Save as')
menu.popup(None, None, None, None, event.button, event.time)
else:
super(ShoebotWi... | def gtk_mouse_button_down(self, widget, event):
''' Handle right mouse button clicks '''
if self.menu_enabled and event.button == 3:
menu = self.uimanager.get_widget('/Save as')
menu.popup(None, None, None, None, event.button, event.time)
else:
super(ShoebotWi... | [
"Handle",
"right",
"mouse",
"button",
"clicks"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L116-L122 | [
"def",
"gtk_mouse_button_down",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"if",
"self",
".",
"menu_enabled",
"and",
"event",
".",
"button",
"==",
"3",
":",
"menu",
"=",
"self",
".",
"uimanager",
".",
"get_widget",
"(",
"'/Save as'",
")",
"menu"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.show_variables_window | Show the variables window. | shoebot/gui/gtk_window.py | def show_variables_window(self):
"""
Show the variables window.
"""
if self.var_window is None and self.bot._vars:
self.var_window = VarWindow(self, self.bot, '%s variables' % (self.title or 'Shoebot'))
self.var_window.window.connect("destroy", self.var_window_clo... | def show_variables_window(self):
"""
Show the variables window.
"""
if self.var_window is None and self.bot._vars:
self.var_window = VarWindow(self, self.bot, '%s variables' % (self.title or 'Shoebot'))
self.var_window.window.connect("destroy", self.var_window_clo... | [
"Show",
"the",
"variables",
"window",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L135-L141 | [
"def",
"show_variables_window",
"(",
"self",
")",
":",
"if",
"self",
".",
"var_window",
"is",
"None",
"and",
"self",
".",
"bot",
".",
"_vars",
":",
"self",
".",
"var_window",
"=",
"VarWindow",
"(",
"self",
",",
"self",
".",
"bot",
",",
"'%s variables'",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.hide_variables_window | Hide the variables window | shoebot/gui/gtk_window.py | def hide_variables_window(self):
"""
Hide the variables window
"""
if self.var_window is not None:
self.var_window.window.destroy()
self.var_window = None | def hide_variables_window(self):
"""
Hide the variables window
"""
if self.var_window is not None:
self.var_window.window.destroy()
self.var_window = None | [
"Hide",
"the",
"variables",
"window"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L143-L149 | [
"def",
"hide_variables_window",
"(",
"self",
")",
":",
"if",
"self",
".",
"var_window",
"is",
"not",
"None",
":",
"self",
".",
"var_window",
".",
"window",
".",
"destroy",
"(",
")",
"self",
".",
"var_window",
"=",
"None"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.var_window_closed | Called if user clicked close button on var window
:param widget:
:return: | shoebot/gui/gtk_window.py | def var_window_closed(self, widget):
"""
Called if user clicked close button on var window
:param widget:
:return:
"""
# TODO - Clean up the menu handling stuff its a bit spagetti right now
self.action_group.get_action('vars').set_active(False)
self.show_v... | def var_window_closed(self, widget):
"""
Called if user clicked close button on var window
:param widget:
:return:
"""
# TODO - Clean up the menu handling stuff its a bit spagetti right now
self.action_group.get_action('vars').set_active(False)
self.show_v... | [
"Called",
"if",
"user",
"clicked",
"close",
"button",
"on",
"var",
"window",
":",
"param",
"widget",
":",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L151-L160 | [
"def",
"var_window_closed",
"(",
"self",
",",
"widget",
")",
":",
"# TODO - Clean up the menu handling stuff its a bit spagetti right now",
"self",
".",
"action_group",
".",
"get_action",
"(",
"'vars'",
")",
".",
"set_active",
"(",
"False",
")",
"self",
".",
"show_var... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.schedule_snapshot | Tell the canvas to perform a snapshot when it's finished rendering
:param format:
:return: | shoebot/gui/gtk_window.py | def schedule_snapshot(self, format):
"""
Tell the canvas to perform a snapshot when it's finished rendering
:param format:
:return:
"""
bot = self.bot
canvas = self.bot.canvas
script = bot._namespace['__file__']
if script:
filename = os... | def schedule_snapshot(self, format):
"""
Tell the canvas to perform a snapshot when it's finished rendering
:param format:
:return:
"""
bot = self.bot
canvas = self.bot.canvas
script = bot._namespace['__file__']
if script:
filename = os... | [
"Tell",
"the",
"canvas",
"to",
"perform",
"a",
"snapshot",
"when",
"it",
"s",
"finished",
"rendering",
":",
"param",
"format",
":",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L171-L186 | [
"def",
"schedule_snapshot",
"(",
"self",
",",
"format",
")",
":",
"bot",
"=",
"self",
".",
"bot",
"canvas",
"=",
"self",
".",
"bot",
".",
"canvas",
"script",
"=",
"bot",
".",
"_namespace",
"[",
"'__file__'",
"]",
"if",
"script",
":",
"filename",
"=",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.trigger_fullscreen_action | Toggle fullscreen from outside the GUI,
causes the GUI to updated and run all its actions. | shoebot/gui/gtk_window.py | def trigger_fullscreen_action(self, fullscreen):
"""
Toggle fullscreen from outside the GUI,
causes the GUI to updated and run all its actions.
"""
action = self.action_group.get_action('fullscreen')
action.set_active(fullscreen) | def trigger_fullscreen_action(self, fullscreen):
"""
Toggle fullscreen from outside the GUI,
causes the GUI to updated and run all its actions.
"""
action = self.action_group.get_action('fullscreen')
action.set_active(fullscreen) | [
"Toggle",
"fullscreen",
"from",
"outside",
"the",
"GUI",
"causes",
"the",
"GUI",
"to",
"updated",
"and",
"run",
"all",
"its",
"actions",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L212-L218 | [
"def",
"trigger_fullscreen_action",
"(",
"self",
",",
"fullscreen",
")",
":",
"action",
"=",
"self",
".",
"action_group",
".",
"get_action",
"(",
"'fullscreen'",
")",
"action",
".",
"set_active",
"(",
"fullscreen",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_fullscreen | Widget Action to Make the window fullscreen and update the bot. | shoebot/gui/gtk_window.py | def do_fullscreen(self, widget):
"""
Widget Action to Make the window fullscreen and update the bot.
"""
self.fullscreen()
self.is_fullscreen = True
# next lines seem to be needed for window switching really to
# fullscreen mode before reading it's size values
... | def do_fullscreen(self, widget):
"""
Widget Action to Make the window fullscreen and update the bot.
"""
self.fullscreen()
self.is_fullscreen = True
# next lines seem to be needed for window switching really to
# fullscreen mode before reading it's size values
... | [
"Widget",
"Action",
"to",
"Make",
"the",
"window",
"fullscreen",
"and",
"update",
"the",
"bot",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L220-L233 | [
"def",
"do_fullscreen",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"fullscreen",
"(",
")",
"self",
".",
"is_fullscreen",
"=",
"True",
"# next lines seem to be needed for window switching really to",
"# fullscreen mode before reading it's size values",
"while",
"Gtk"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_unfullscreen | Widget Action to set Windowed Mode. | shoebot/gui/gtk_window.py | def do_unfullscreen(self, widget):
"""
Widget Action to set Windowed Mode.
"""
self.unfullscreen()
self.is_fullscreen = False
self.bot._screen_ratio = None | def do_unfullscreen(self, widget):
"""
Widget Action to set Windowed Mode.
"""
self.unfullscreen()
self.is_fullscreen = False
self.bot._screen_ratio = None | [
"Widget",
"Action",
"to",
"set",
"Windowed",
"Mode",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L235-L241 | [
"def",
"do_unfullscreen",
"(",
"self",
",",
"widget",
")",
":",
"self",
".",
"unfullscreen",
"(",
")",
"self",
".",
"is_fullscreen",
"=",
"False",
"self",
".",
"bot",
".",
"_screen_ratio",
"=",
"None"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_window_close | Widget Action to Close the window, triggering the quit event. | shoebot/gui/gtk_window.py | def do_window_close(self, widget, data=None):
"""
Widget Action to Close the window, triggering the quit event.
"""
publish_event(QUIT_EVENT)
if self.has_server:
self.sock.close()
self.hide_variables_window()
self.destroy()
self.window_open ... | def do_window_close(self, widget, data=None):
"""
Widget Action to Close the window, triggering the quit event.
"""
publish_event(QUIT_EVENT)
if self.has_server:
self.sock.close()
self.hide_variables_window()
self.destroy()
self.window_open ... | [
"Widget",
"Action",
"to",
"Close",
"the",
"window",
"triggering",
"the",
"quit",
"event",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L243-L255 | [
"def",
"do_window_close",
"(",
"self",
",",
"widget",
",",
"data",
"=",
"None",
")",
":",
"publish_event",
"(",
"QUIT_EVENT",
")",
"if",
"self",
".",
"has_server",
":",
"self",
".",
"sock",
".",
"close",
"(",
")",
"self",
".",
"hide_variables_window",
"(... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_toggle_fullscreen | Widget Action to Toggle fullscreen from the GUI | shoebot/gui/gtk_window.py | def do_toggle_fullscreen(self, action):
"""
Widget Action to Toggle fullscreen from the GUI
"""
is_fullscreen = action.get_active()
if is_fullscreen:
self.fullscreen()
else:
self.unfullscreen() | def do_toggle_fullscreen(self, action):
"""
Widget Action to Toggle fullscreen from the GUI
"""
is_fullscreen = action.get_active()
if is_fullscreen:
self.fullscreen()
else:
self.unfullscreen() | [
"Widget",
"Action",
"to",
"Toggle",
"fullscreen",
"from",
"the",
"GUI"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L257-L265 | [
"def",
"do_toggle_fullscreen",
"(",
"self",
",",
"action",
")",
":",
"is_fullscreen",
"=",
"action",
".",
"get_active",
"(",
")",
"if",
"is_fullscreen",
":",
"self",
".",
"fullscreen",
"(",
")",
"else",
":",
"self",
".",
"unfullscreen",
"(",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_toggle_play | Widget Action to toggle play / pause. | shoebot/gui/gtk_window.py | def do_toggle_play(self, action):
"""
Widget Action to toggle play / pause.
"""
# TODO - move this into bot controller
# along with stuff in socketserver and shell
if self.pause_speed is None and not action.get_active():
self.pause_speed = self.bot._speed
... | def do_toggle_play(self, action):
"""
Widget Action to toggle play / pause.
"""
# TODO - move this into bot controller
# along with stuff in socketserver and shell
if self.pause_speed is None and not action.get_active():
self.pause_speed = self.bot._speed
... | [
"Widget",
"Action",
"to",
"toggle",
"play",
"/",
"pause",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L267-L278 | [
"def",
"do_toggle_play",
"(",
"self",
",",
"action",
")",
":",
"# TODO - move this into bot controller",
"# along with stuff in socketserver and shell",
"if",
"self",
".",
"pause_speed",
"is",
"None",
"and",
"not",
"action",
".",
"get_active",
"(",
")",
":",
"self",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.do_toggle_variables | Widget Action to toggle showing the variables window. | shoebot/gui/gtk_window.py | def do_toggle_variables(self, action):
"""
Widget Action to toggle showing the variables window.
"""
self.show_vars = action.get_active()
if self.show_vars:
self.show_variables_window()
else:
self.hide_variables_window() | def do_toggle_variables(self, action):
"""
Widget Action to toggle showing the variables window.
"""
self.show_vars = action.get_active()
if self.show_vars:
self.show_variables_window()
else:
self.hide_variables_window() | [
"Widget",
"Action",
"to",
"toggle",
"showing",
"the",
"variables",
"window",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L280-L288 | [
"def",
"do_toggle_variables",
"(",
"self",
",",
"action",
")",
":",
"self",
".",
"show_vars",
"=",
"action",
".",
"get_active",
"(",
")",
"if",
"self",
".",
"show_vars",
":",
"self",
".",
"show_variables_window",
"(",
")",
"else",
":",
"self",
".",
"hide... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindow.main_iteration | Called from main loop, if your sink needs to handle GUI events
do it here.
Check any GUI flags then call Gtk.main_iteration to update things. | shoebot/gui/gtk_window.py | def main_iteration(self):
"""
Called from main loop, if your sink needs to handle GUI events
do it here.
Check any GUI flags then call Gtk.main_iteration to update things.
"""
if self.show_vars:
self.show_variables_window()
else:
self.hide... | def main_iteration(self):
"""
Called from main loop, if your sink needs to handle GUI events
do it here.
Check any GUI flags then call Gtk.main_iteration to update things.
"""
if self.show_vars:
self.show_variables_window()
else:
self.hide... | [
"Called",
"from",
"main",
"loop",
"if",
"your",
"sink",
"needs",
"to",
"handle",
"GUI",
"events",
"do",
"it",
"here",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_window.py#L290-L309 | [
"def",
"main_iteration",
"(",
"self",
")",
":",
"if",
"self",
".",
"show_vars",
":",
"self",
".",
"show_variables_window",
"(",
")",
"else",
":",
"self",
".",
"hide_variables_window",
"(",
")",
"for",
"snapshot_f",
"in",
"self",
".",
"scheduled_snapshots",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot._set_initial_defaults | Set the default values. Called at __init__ and at the end of run(),
do that new draw loop iterations don't take up values left over by the
previous one. | shoebot/grammar/bot.py | def _set_initial_defaults(self):
'''Set the default values. Called at __init__ and at the end of run(),
do that new draw loop iterations don't take up values left over by the
previous one.'''
DEFAULT_WIDTH, DEFAULT_HEIGHT = self._canvas.DEFAULT_SIZE
self.WIDTH = self._namespace.g... | def _set_initial_defaults(self):
'''Set the default values. Called at __init__ and at the end of run(),
do that new draw loop iterations don't take up values left over by the
previous one.'''
DEFAULT_WIDTH, DEFAULT_HEIGHT = self._canvas.DEFAULT_SIZE
self.WIDTH = self._namespace.g... | [
"Set",
"the",
"default",
"values",
".",
"Called",
"at",
"__init__",
"and",
"at",
"the",
"end",
"of",
"run",
"()",
"do",
"that",
"new",
"draw",
"loop",
"iterations",
"don",
"t",
"take",
"up",
"values",
"left",
"over",
"by",
"the",
"previous",
"one",
"."... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L137-L157 | [
"def",
"_set_initial_defaults",
"(",
"self",
")",
":",
"DEFAULT_WIDTH",
",",
"DEFAULT_HEIGHT",
"=",
"self",
".",
"_canvas",
".",
"DEFAULT_SIZE",
"self",
".",
"WIDTH",
"=",
"self",
".",
"_namespace",
".",
"get",
"(",
"'WIDTH'",
",",
"DEFAULT_WIDTH",
")",
"sel... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot._mouse_pointer_moved | GUI callback for mouse moved | shoebot/grammar/bot.py | def _mouse_pointer_moved(self, x, y):
'''GUI callback for mouse moved'''
self._namespace['MOUSEX'] = x
self._namespace['MOUSEY'] = y | def _mouse_pointer_moved(self, x, y):
'''GUI callback for mouse moved'''
self._namespace['MOUSEX'] = x
self._namespace['MOUSEY'] = y | [
"GUI",
"callback",
"for",
"mouse",
"moved"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L172-L175 | [
"def",
"_mouse_pointer_moved",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"self",
".",
"_namespace",
"[",
"'MOUSEX'",
"]",
"=",
"x",
"self",
".",
"_namespace",
"[",
"'MOUSEY'",
"]",
"=",
"y"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot._key_pressed | GUI callback for key pressed | shoebot/grammar/bot.py | def _key_pressed(self, key, keycode):
'''GUI callback for key pressed'''
self._namespace['key'] = key
self._namespace['keycode'] = keycode
self._namespace['keydown'] = True | def _key_pressed(self, key, keycode):
'''GUI callback for key pressed'''
self._namespace['key'] = key
self._namespace['keycode'] = keycode
self._namespace['keydown'] = True | [
"GUI",
"callback",
"for",
"key",
"pressed"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L177-L181 | [
"def",
"_key_pressed",
"(",
"self",
",",
"key",
",",
"keycode",
")",
":",
"self",
".",
"_namespace",
"[",
"'key'",
"]",
"=",
"key",
"self",
".",
"_namespace",
"[",
"'keycode'",
"]",
"=",
"keycode",
"self",
".",
"_namespace",
"[",
"'keydown'",
"]",
"=",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot._makeInstance | Creates an instance of a class defined in this document.
This method sets the context of the object to the current context. | shoebot/grammar/bot.py | def _makeInstance(self, clazz, args, kwargs):
'''Creates an instance of a class defined in this document.
This method sets the context of the object to the current context.'''
inst = clazz(self, *args, **kwargs)
return inst | def _makeInstance(self, clazz, args, kwargs):
'''Creates an instance of a class defined in this document.
This method sets the context of the object to the current context.'''
inst = clazz(self, *args, **kwargs)
return inst | [
"Creates",
"an",
"instance",
"of",
"a",
"class",
"defined",
"in",
"this",
"document",
".",
"This",
"method",
"sets",
"the",
"context",
"of",
"the",
"object",
"to",
"the",
"current",
"context",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L199-L203 | [
"def",
"_makeInstance",
"(",
"self",
",",
"clazz",
",",
"args",
",",
"kwargs",
")",
":",
"inst",
"=",
"clazz",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"inst"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot._makeColorableInstance | Create an object, if fill, stroke or strokewidth
is not specified, get them from the _canvas
:param clazz:
:param args:
:param kwargs:
:return: | shoebot/grammar/bot.py | def _makeColorableInstance(self, clazz, args, kwargs):
"""
Create an object, if fill, stroke or strokewidth
is not specified, get them from the _canvas
:param clazz:
:param args:
:param kwargs:
:return:
"""
kwargs = dict(kwargs)
fill = kw... | def _makeColorableInstance(self, clazz, args, kwargs):
"""
Create an object, if fill, stroke or strokewidth
is not specified, get them from the _canvas
:param clazz:
:param args:
:param kwargs:
:return:
"""
kwargs = dict(kwargs)
fill = kw... | [
"Create",
"an",
"object",
"if",
"fill",
"stroke",
"or",
"strokewidth",
"is",
"not",
"specified",
"get",
"them",
"from",
"the",
"_canvas"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L205-L229 | [
"def",
"_makeColorableInstance",
"(",
"self",
",",
"clazz",
",",
"args",
",",
"kwargs",
")",
":",
"kwargs",
"=",
"dict",
"(",
"kwargs",
")",
"fill",
"=",
"kwargs",
".",
"get",
"(",
"'fill'",
",",
"self",
".",
"_canvas",
".",
"fillcolor",
")",
"if",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.color | :param args: color in a supported format.
:return: Color object containing the color. | shoebot/grammar/bot.py | def color(self, *args):
'''
:param args: color in a supported format.
:return: Color object containing the color.
'''
return self.Color(mode=self.color_mode, color_range=self.color_range, *args) | def color(self, *args):
'''
:param args: color in a supported format.
:return: Color object containing the color.
'''
return self.Color(mode=self.color_mode, color_range=self.color_range, *args) | [
":",
"param",
"args",
":",
"color",
"in",
"a",
"supported",
"format",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L266-L272 | [
"def",
"color",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"Color",
"(",
"mode",
"=",
"self",
".",
"color_mode",
",",
"color_range",
"=",
"self",
".",
"color_range",
",",
"*",
"args",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.grid | Returns an iterator that contains coordinate tuples.
The grid can be used to quickly create grid-like structures.
A common way to use them is:
for x, y in grid(10,10,12,12):
rect(x,y, 10,10) | shoebot/grammar/bot.py | def grid(self, cols, rows, colSize=1, rowSize=1, shuffled=False):
"""Returns an iterator that contains coordinate tuples.
The grid can be used to quickly create grid-like structures.
A common way to use them is:
for x, y in grid(10,10,12,12):
rect(x,y, 10,10)
... | def grid(self, cols, rows, colSize=1, rowSize=1, shuffled=False):
"""Returns an iterator that contains coordinate tuples.
The grid can be used to quickly create grid-like structures.
A common way to use them is:
for x, y in grid(10,10,12,12):
rect(x,y, 10,10)
... | [
"Returns",
"an",
"iterator",
"that",
"contains",
"coordinate",
"tuples",
".",
"The",
"grid",
"can",
"be",
"used",
"to",
"quickly",
"create",
"grid",
"-",
"like",
"structures",
".",
"A",
"common",
"way",
"to",
"use",
"them",
"is",
":",
"for",
"x",
"y",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L296-L312 | [
"def",
"grid",
"(",
"self",
",",
"cols",
",",
"rows",
",",
"colSize",
"=",
"1",
",",
"rowSize",
"=",
"1",
",",
"shuffled",
"=",
"False",
")",
":",
"# Taken ipsis verbis from Nodebox",
"from",
"random",
"import",
"shuffle",
"rowRange",
"=",
"range",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.snapshot | Save the contents of current surface into a file or cairo surface/context
:param filename: Can be a filename or a Cairo surface.
:param defer: If true, buffering/threading may be employed however output will not be immediate.
:param autonumber: If true then a number will be appended to the file... | shoebot/grammar/bot.py | def snapshot(self, target=None, defer=None, autonumber=False):
'''Save the contents of current surface into a file or cairo surface/context
:param filename: Can be a filename or a Cairo surface.
:param defer: If true, buffering/threading may be employed however output will not be immediate.
... | def snapshot(self, target=None, defer=None, autonumber=False):
'''Save the contents of current surface into a file or cairo surface/context
:param filename: Can be a filename or a Cairo surface.
:param defer: If true, buffering/threading may be employed however output will not be immediate.
... | [
"Save",
"the",
"contents",
"of",
"current",
"surface",
"into",
"a",
"file",
"or",
"cairo",
"surface",
"/",
"context"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L324-L360 | [
"def",
"snapshot",
"(",
"self",
",",
"target",
"=",
"None",
",",
"defer",
"=",
"None",
",",
"autonumber",
"=",
"False",
")",
":",
"if",
"autonumber",
":",
"file_number",
"=",
"self",
".",
"_frame",
"else",
":",
"file_number",
"=",
"None",
"if",
"isinst... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.show | Returns an Image object of the current surface. Used for displaying
output in Jupyter notebooks. Adapted from the cairo-jupyter project. | shoebot/grammar/bot.py | def show(self, format='png', as_data=False):
'''Returns an Image object of the current surface. Used for displaying
output in Jupyter notebooks. Adapted from the cairo-jupyter project.'''
from io import BytesIO
b = BytesIO()
if format == 'png':
from IPython.display... | def show(self, format='png', as_data=False):
'''Returns an Image object of the current surface. Used for displaying
output in Jupyter notebooks. Adapted from the cairo-jupyter project.'''
from io import BytesIO
b = BytesIO()
if format == 'png':
from IPython.display... | [
"Returns",
"an",
"Image",
"object",
"of",
"the",
"current",
"surface",
".",
"Used",
"for",
"displaying",
"output",
"in",
"Jupyter",
"notebooks",
".",
"Adapted",
"from",
"the",
"cairo",
"-",
"jupyter",
"project",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L362-L390 | [
"def",
"show",
"(",
"self",
",",
"format",
"=",
"'png'",
",",
"as_data",
"=",
"False",
")",
":",
"from",
"io",
"import",
"BytesIO",
"b",
"=",
"BytesIO",
"(",
")",
"if",
"format",
"==",
"'png'",
":",
"from",
"IPython",
".",
"display",
"import",
"Image... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.ximport | Import Nodebox libraries.
The libraries get _ctx, which provides
them with the nodebox API.
:param libName: Library name to import | shoebot/grammar/bot.py | def ximport(self, libName):
'''
Import Nodebox libraries.
The libraries get _ctx, which provides
them with the nodebox API.
:param libName: Library name to import
'''
# from Nodebox
lib = __import__(libName)
self._namespace[libName] = lib
... | def ximport(self, libName):
'''
Import Nodebox libraries.
The libraries get _ctx, which provides
them with the nodebox API.
:param libName: Library name to import
'''
# from Nodebox
lib = __import__(libName)
self._namespace[libName] = lib
... | [
"Import",
"Nodebox",
"libraries",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L392-L405 | [
"def",
"ximport",
"(",
"self",
",",
"libName",
")",
":",
"# from Nodebox",
"lib",
"=",
"__import__",
"(",
"libName",
")",
"self",
".",
"_namespace",
"[",
"libName",
"]",
"=",
"lib",
"lib",
".",
"_ctx",
"=",
"self",
"return",
"lib"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.size | Set the canvas size
Only the first call will actually be effective.
:param w: Width
:param h: height | shoebot/grammar/bot.py | def size(self, w=None, h=None):
'''Set the canvas size
Only the first call will actually be effective.
:param w: Width
:param h: height
'''
if not w:
w = self._canvas.width
if not h:
h = self._canvas.height
if not w and not h:
... | def size(self, w=None, h=None):
'''Set the canvas size
Only the first call will actually be effective.
:param w: Width
:param h: height
'''
if not w:
w = self._canvas.width
if not h:
h = self._canvas.height
if not w and not h:
... | [
"Set",
"the",
"canvas",
"size"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L409-L430 | [
"def",
"size",
"(",
"self",
",",
"w",
"=",
"None",
",",
"h",
"=",
"None",
")",
":",
"if",
"not",
"w",
":",
"w",
"=",
"self",
".",
"_canvas",
".",
"width",
"if",
"not",
"h",
":",
"h",
"=",
"self",
".",
"_canvas",
".",
"height",
"if",
"not",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Bot.speed | Set animation framerate.
:param framerate: Frames per second to run bot.
:return: Current framerate of animation. | shoebot/grammar/bot.py | def speed(self, framerate=None):
'''Set animation framerate.
:param framerate: Frames per second to run bot.
:return: Current framerate of animation.
'''
if framerate is not None:
self._speed = framerate
self._dynamic = True
else:
retu... | def speed(self, framerate=None):
'''Set animation framerate.
:param framerate: Frames per second to run bot.
:return: Current framerate of animation.
'''
if framerate is not None:
self._speed = framerate
self._dynamic = True
else:
retu... | [
"Set",
"animation",
"framerate",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/bot.py#L432-L442 | [
"def",
"speed",
"(",
"self",
",",
"framerate",
"=",
"None",
")",
":",
"if",
"framerate",
"is",
"not",
"None",
":",
"self",
".",
"_speed",
"=",
"framerate",
"self",
".",
"_dynamic",
"=",
"True",
"else",
":",
"return",
"self",
".",
"_speed"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | InputDeviceMixin.set_callbacks | Set callbacks for input events | shoebot/core/input_device.py | def set_callbacks(self, **kwargs):
''' Set callbacks for input events '''
for name in self.SUPPORTED_CALLBACKS:
func = kwargs.get(name, getattr(self, name))
setattr(self, name, func) | def set_callbacks(self, **kwargs):
''' Set callbacks for input events '''
for name in self.SUPPORTED_CALLBACKS:
func = kwargs.get(name, getattr(self, name))
setattr(self, name, func) | [
"Set",
"callbacks",
"for",
"input",
"events"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/input_device.py#L17-L21 | [
"def",
"set_callbacks",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"name",
"in",
"self",
".",
"SUPPORTED_CALLBACKS",
":",
"func",
"=",
"kwargs",
".",
"get",
"(",
"name",
",",
"getattr",
"(",
"self",
",",
"name",
")",
")",
"setattr",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | complement | Returns the color and its complement in a list. | lib/colors/__init__.py | def complement(clr):
"""
Returns the color and its complement in a list.
"""
clr = color(clr)
colors = colorlist(clr)
colors.append(clr.complement)
return colors | def complement(clr):
"""
Returns the color and its complement in a list.
"""
clr = color(clr)
colors = colorlist(clr)
colors.append(clr.complement)
return colors | [
"Returns",
"the",
"color",
"and",
"its",
"complement",
"in",
"a",
"list",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1413-L1421 | [
"def",
"complement",
"(",
"clr",
")",
":",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist",
"(",
"clr",
")",
"colors",
".",
"append",
"(",
"clr",
".",
"complement",
")",
"return",
"colors"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | complementary | Returns a list of complementary colors.
The complement is the color 180 degrees across
the artistic RYB color wheel.
The list contains darker and softer contrasting
and complementing colors. | lib/colors/__init__.py | def complementary(clr):
"""
Returns a list of complementary colors.
The complement is the color 180 degrees across
the artistic RYB color wheel.
The list contains darker and softer contrasting
and complementing colors.
"""
clr = color(clr)
colors = colorlist(clr)
# A contrastin... | def complementary(clr):
"""
Returns a list of complementary colors.
The complement is the color 180 degrees across
the artistic RYB color wheel.
The list contains darker and softer contrasting
and complementing colors.
"""
clr = color(clr)
colors = colorlist(clr)
# A contrastin... | [
"Returns",
"a",
"list",
"of",
"complementary",
"colors",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1424-L1467 | [
"def",
"complementary",
"(",
"clr",
")",
":",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist",
"(",
"clr",
")",
"# A contrasting color: much darker or lighter than the original.",
"c",
"=",
"clr",
".",
"copy",
"(",
")",
"if",
"clr",
".",
"br... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | split_complementary | Returns a list with the split complement of the color.
The split complement are the two colors to the left and right
of the color's complement. | lib/colors/__init__.py | def split_complementary(clr):
"""
Returns a list with the split complement of the color.
The split complement are the two colors to the left and right
of the color's complement.
"""
clr = color(clr)
colors = colorlist(clr)
clr = clr.complement
colors.append(clr.rotate_ryb(-30).light... | def split_complementary(clr):
"""
Returns a list with the split complement of the color.
The split complement are the two colors to the left and right
of the color's complement.
"""
clr = color(clr)
colors = colorlist(clr)
clr = clr.complement
colors.append(clr.rotate_ryb(-30).light... | [
"Returns",
"a",
"list",
"with",
"the",
"split",
"complement",
"of",
"the",
"color",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1470-L1483 | [
"def",
"split_complementary",
"(",
"clr",
")",
":",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist",
"(",
"clr",
")",
"clr",
"=",
"clr",
".",
"complement",
"colors",
".",
"append",
"(",
"clr",
".",
"rotate_ryb",
"(",
"-",
"30",
")",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | left_complement | Returns the left half of the split complement.
A list is returned with the same darker and softer colors
as in the complementary list, but using the hue of the
left split complement instead of the complement itself. | lib/colors/__init__.py | def left_complement(clr):
"""
Returns the left half of the split complement.
A list is returned with the same darker and softer colors
as in the complementary list, but using the hue of the
left split complement instead of the complement itself.
"""
left = split_complementary(clr)[1]
co... | def left_complement(clr):
"""
Returns the left half of the split complement.
A list is returned with the same darker and softer colors
as in the complementary list, but using the hue of the
left split complement instead of the complement itself.
"""
left = split_complementary(clr)[1]
co... | [
"Returns",
"the",
"left",
"half",
"of",
"the",
"split",
"complement",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1486-L1504 | [
"def",
"left_complement",
"(",
"clr",
")",
":",
"left",
"=",
"split_complementary",
"(",
"clr",
")",
"[",
"1",
"]",
"colors",
"=",
"complementary",
"(",
"clr",
")",
"colors",
"[",
"3",
"]",
".",
"h",
"=",
"left",
".",
"h",
"colors",
"[",
"4",
"]",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | right_complement | Returns the right half of the split complement. | lib/colors/__init__.py | def right_complement(clr):
"""
Returns the right half of the split complement.
"""
right = split_complementary(clr)[2]
colors = complementary(clr)
colors[3].h = right.h
colors[4].h = right.h
colors[5].h = right.h
colors = colorlist(
colors[0], colors[2], colors[1], colors[5]... | def right_complement(clr):
"""
Returns the right half of the split complement.
"""
right = split_complementary(clr)[2]
colors = complementary(clr)
colors[3].h = right.h
colors[4].h = right.h
colors[5].h = right.h
colors = colorlist(
colors[0], colors[2], colors[1], colors[5]... | [
"Returns",
"the",
"right",
"half",
"of",
"the",
"split",
"complement",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1507-L1521 | [
"def",
"right_complement",
"(",
"clr",
")",
":",
"right",
"=",
"split_complementary",
"(",
"clr",
")",
"[",
"2",
"]",
"colors",
"=",
"complementary",
"(",
"clr",
")",
"colors",
"[",
"3",
"]",
".",
"h",
"=",
"right",
".",
"h",
"colors",
"[",
"4",
"]... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | analogous | Returns colors that are next to each other on the wheel.
These yield natural color schemes (like shades of water or sky).
The angle determines how far the colors are apart,
making it bigger will introduce more variation.
The contrast determines the darkness/lightness of
the analogue colors in respe... | lib/colors/__init__.py | def analogous(clr, angle=10, contrast=0.25):
"""
Returns colors that are next to each other on the wheel.
These yield natural color schemes (like shades of water or sky).
The angle determines how far the colors are apart,
making it bigger will introduce more variation.
The contrast determines t... | def analogous(clr, angle=10, contrast=0.25):
"""
Returns colors that are next to each other on the wheel.
These yield natural color schemes (like shades of water or sky).
The angle determines how far the colors are apart,
making it bigger will introduce more variation.
The contrast determines t... | [
"Returns",
"colors",
"that",
"are",
"next",
"to",
"each",
"other",
"on",
"the",
"wheel",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1524-L1549 | [
"def",
"analogous",
"(",
"clr",
",",
"angle",
"=",
"10",
",",
"contrast",
"=",
"0.25",
")",
":",
"contrast",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"contrast",
",",
"1.0",
")",
")",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | monochrome | Returns colors in the same hue with varying brightness/saturation. | lib/colors/__init__.py | def monochrome(clr):
"""
Returns colors in the same hue with varying brightness/saturation.
"""
def _wrap(x, min, threshold, plus):
if x - min < threshold:
return x + plus
else:
return x - min
colors = colorlist(clr)
c = clr.copy()
c.brightness = _wr... | def monochrome(clr):
"""
Returns colors in the same hue with varying brightness/saturation.
"""
def _wrap(x, min, threshold, plus):
if x - min < threshold:
return x + plus
else:
return x - min
colors = colorlist(clr)
c = clr.copy()
c.brightness = _wr... | [
"Returns",
"colors",
"in",
"the",
"same",
"hue",
"with",
"varying",
"brightness",
"/",
"saturation",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1552-L1582 | [
"def",
"monochrome",
"(",
"clr",
")",
":",
"def",
"_wrap",
"(",
"x",
",",
"min",
",",
"threshold",
",",
"plus",
")",
":",
"if",
"x",
"-",
"min",
"<",
"threshold",
":",
"return",
"x",
"+",
"plus",
"else",
":",
"return",
"x",
"-",
"min",
"colors",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | triad | Returns a triad of colors.
The triad is made up of this color and two other colors
that together make up an equilateral triangle on
the artistic color wheel. | lib/colors/__init__.py | def triad(clr, angle=120):
"""
Returns a triad of colors.
The triad is made up of this color and two other colors
that together make up an equilateral triangle on
the artistic color wheel.
"""
clr = color(clr)
colors = colorlist(clr)
colors.append(clr.rotate_ryb(angle).lighten(0.1))... | def triad(clr, angle=120):
"""
Returns a triad of colors.
The triad is made up of this color and two other colors
that together make up an equilateral triangle on
the artistic color wheel.
"""
clr = color(clr)
colors = colorlist(clr)
colors.append(clr.rotate_ryb(angle).lighten(0.1))... | [
"Returns",
"a",
"triad",
"of",
"colors",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1585-L1598 | [
"def",
"triad",
"(",
"clr",
",",
"angle",
"=",
"120",
")",
":",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist",
"(",
"clr",
")",
"colors",
".",
"append",
"(",
"clr",
".",
"rotate_ryb",
"(",
"angle",
")",
".",
"lighten",
"(",
"0.... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | tetrad | Returns a tetrad of colors.
The tetrad is made up of this color and three other colors
that together make up a cross on the artistic color wheel. | lib/colors/__init__.py | def tetrad(clr, angle=90):
"""
Returns a tetrad of colors.
The tetrad is made up of this color and three other colors
that together make up a cross on the artistic color wheel.
"""
clr = color(clr)
colors = colorlist(clr)
c = clr.rotate_ryb(angle)
if clr.brightness < 0.5:
c... | def tetrad(clr, angle=90):
"""
Returns a tetrad of colors.
The tetrad is made up of this color and three other colors
that together make up a cross on the artistic color wheel.
"""
clr = color(clr)
colors = colorlist(clr)
c = clr.rotate_ryb(angle)
if clr.brightness < 0.5:
c... | [
"Returns",
"a",
"tetrad",
"of",
"colors",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1601-L1627 | [
"def",
"tetrad",
"(",
"clr",
",",
"angle",
"=",
"90",
")",
":",
"clr",
"=",
"color",
"(",
"clr",
")",
"colors",
"=",
"colorlist",
"(",
"clr",
")",
"c",
"=",
"clr",
".",
"rotate_ryb",
"(",
"angle",
")",
"if",
"clr",
".",
"brightness",
"<",
"0.5",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | compound | Roughly the complement and some far analogs. | lib/colors/__init__.py | def compound(clr, flip=False):
"""
Roughly the complement and some far analogs.
"""
def _wrap(x, min, threshold, plus):
if x - min < threshold:
return x + plus
else:
return x - min
d = 1
if flip: d = -1
clr = color(clr)
colors = colorlist(clr)
... | def compound(clr, flip=False):
"""
Roughly the complement and some far analogs.
"""
def _wrap(x, min, threshold, plus):
if x - min < threshold:
return x + plus
else:
return x - min
d = 1
if flip: d = -1
clr = color(clr)
colors = colorlist(clr)
... | [
"Roughly",
"the",
"complement",
"and",
"some",
"far",
"analogs",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1630-L1670 | [
"def",
"compound",
"(",
"clr",
",",
"flip",
"=",
"False",
")",
":",
"def",
"_wrap",
"(",
"x",
",",
"min",
",",
"threshold",
",",
"plus",
")",
":",
"if",
"x",
"-",
"min",
"<",
"threshold",
":",
"return",
"x",
"+",
"plus",
"else",
":",
"return",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | outline | Outlines each contour in a path with the colors in the list.
Each contour starts with the first color in the list,
and ends with the last color in the list.
Because each line segment is drawn separately,
works only with corner-mode transforms. | lib/colors/__init__.py | def outline(path, colors, precision=0.4, continuous=True):
"""
Outlines each contour in a path with the colors in the list.
Each contour starts with the first color in the list,
and ends with the last color in the list.
Because each line segment is drawn separately,
works only with corner-mode... | def outline(path, colors, precision=0.4, continuous=True):
"""
Outlines each contour in a path with the colors in the list.
Each contour starts with the first color in the list,
and ends with the last color in the list.
Because each line segment is drawn separately,
works only with corner-mode... | [
"Outlines",
"each",
"contour",
"in",
"a",
"path",
"with",
"the",
"colors",
"in",
"the",
"list",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L1854-L1908 | [
"def",
"outline",
"(",
"path",
",",
"colors",
",",
"precision",
"=",
"0.4",
",",
"continuous",
"=",
"True",
")",
":",
"# The count of points in a given path/contour.",
"def",
"_point_count",
"(",
"path",
",",
"precision",
")",
":",
"return",
"max",
"(",
"int",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | guess_name | Guesses the shade and hue name of a color.
If the given color is named in the named_colors list, return that name.
Otherwise guess its nearest hue and shade range. | lib/colors/__init__.py | def guess_name(clr):
"""
Guesses the shade and hue name of a color.
If the given color is named in the named_colors list, return that name.
Otherwise guess its nearest hue and shade range.
"""
clr = Color(clr)
if clr.is_transparent: return "transparent"
if clr.is_black: return "black"
... | def guess_name(clr):
"""
Guesses the shade and hue name of a color.
If the given color is named in the named_colors list, return that name.
Otherwise guess its nearest hue and shade range.
"""
clr = Color(clr)
if clr.is_transparent: return "transparent"
if clr.is_black: return "black"
... | [
"Guesses",
"the",
"shade",
"and",
"hue",
"name",
"of",
"a",
"color",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2347-L2374 | [
"def",
"guess_name",
"(",
"clr",
")",
":",
"clr",
"=",
"Color",
"(",
"clr",
")",
"if",
"clr",
".",
"is_transparent",
":",
"return",
"\"transparent\"",
"if",
"clr",
".",
"is_black",
":",
"return",
"\"black\"",
"if",
"clr",
".",
"is_white",
":",
"return",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | shader | Returns a 0.0 - 1.0 brightness adjusted to a light source.
The light source is positioned at dx, dy.
The returned float is calculated for x, y position
(e.g. an oval at x, y should have this brightness).
The radius influences the strength of the light,
angle and spread control the direction of the... | lib/colors/__init__.py | def shader(x, y, dx, dy, radius=300, angle=0, spread=90):
"""
Returns a 0.0 - 1.0 brightness adjusted to a light source.
The light source is positioned at dx, dy.
The returned float is calculated for x, y position
(e.g. an oval at x, y should have this brightness).
The radius influences the st... | def shader(x, y, dx, dy, radius=300, angle=0, spread=90):
"""
Returns a 0.0 - 1.0 brightness adjusted to a light source.
The light source is positioned at dx, dy.
The returned float is calculated for x, y position
(e.g. an oval at x, y should have this brightness).
The radius influences the st... | [
"Returns",
"a",
"0",
".",
"0",
"-",
"1",
".",
"0",
"brightness",
"adjusted",
"to",
"a",
"light",
"source",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2381-L2439 | [
"def",
"shader",
"(",
"x",
",",
"y",
",",
"dx",
",",
"dy",
",",
"radius",
"=",
"300",
",",
"angle",
"=",
"0",
",",
"spread",
"=",
"90",
")",
":",
"if",
"angle",
"!=",
"None",
":",
"radius",
"*=",
"2",
"# Get the distance and angle between point and lig... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | aggregated | A dictionary of all aggregated words.
They keys in the dictionary correspond to subfolders in the aggregated cache.
Each key has a list of words. Each of these words is the name of an XML-file
in the subfolder. The XML-file contains color information harvested from the web
(or handmade). | lib/colors/__init__.py | def aggregated(cache=DEFAULT_CACHE):
"""
A dictionary of all aggregated words.
They keys in the dictionary correspond to subfolders in the aggregated cache.
Each key has a list of words. Each of these words is the name of an XML-file
in the subfolder. The XML-file contains color information harvest... | def aggregated(cache=DEFAULT_CACHE):
"""
A dictionary of all aggregated words.
They keys in the dictionary correspond to subfolders in the aggregated cache.
Each key has a list of words. Each of these words is the name of an XML-file
in the subfolder. The XML-file contains color information harvest... | [
"A",
"dictionary",
"of",
"all",
"aggregated",
"words",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2463-L2482 | [
"def",
"aggregated",
"(",
"cache",
"=",
"DEFAULT_CACHE",
")",
":",
"global",
"_aggregated_name",
",",
"_aggregated_dict",
"if",
"_aggregated_name",
"!=",
"cache",
":",
"_aggregated_name",
"=",
"cache",
"_aggregated_dict",
"=",
"{",
"}",
"for",
"path",
"in",
"glo... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | search_engine | Return a color aggregate from colors and ranges parsed from the web.
T. De Smedt, http://nodebox.net/code/index.php/Prism | lib/colors/__init__.py | def search_engine(query, top=5, service="google", license=None,
cache=os.path.join(DEFAULT_CACHE, "google")):
"""
Return a color aggregate from colors and ranges parsed from the web.
T. De Smedt, http://nodebox.net/code/index.php/Prism
"""
# Check if we have cached information firs... | def search_engine(query, top=5, service="google", license=None,
cache=os.path.join(DEFAULT_CACHE, "google")):
"""
Return a color aggregate from colors and ranges parsed from the web.
T. De Smedt, http://nodebox.net/code/index.php/Prism
"""
# Check if we have cached information firs... | [
"Return",
"a",
"color",
"aggregate",
"from",
"colors",
"and",
"ranges",
"parsed",
"from",
"the",
"web",
".",
"T",
".",
"De",
"Smedt",
"http",
":",
"//",
"nodebox",
".",
"net",
"/",
"code",
"/",
"index",
".",
"php",
"/",
"Prism"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L2926-L2978 | [
"def",
"search_engine",
"(",
"query",
",",
"top",
"=",
"5",
",",
"service",
"=",
"\"google\"",
",",
"license",
"=",
"None",
",",
"cache",
"=",
"os",
".",
"path",
".",
"join",
"(",
"DEFAULT_CACHE",
",",
"\"google\"",
")",
")",
":",
"# Check if we have cac... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | morguefile | Returns a list of colors drawn from a morgueFile image.
With the Web library installed,
downloads a thumbnail from morgueFile and retrieves pixel colors. | lib/colors/__init__.py | def morguefile(query, n=10, top=10):
"""
Returns a list of colors drawn from a morgueFile image.
With the Web library installed,
downloads a thumbnail from morgueFile and retrieves pixel colors.
"""
from web import morguefile
images = morguefile.search(query)[:top]
path = choice(images... | def morguefile(query, n=10, top=10):
"""
Returns a list of colors drawn from a morgueFile image.
With the Web library installed,
downloads a thumbnail from morgueFile and retrieves pixel colors.
"""
from web import morguefile
images = morguefile.search(query)[:top]
path = choice(images... | [
"Returns",
"a",
"list",
"of",
"colors",
"drawn",
"from",
"a",
"morgueFile",
"image",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L3009-L3021 | [
"def",
"morguefile",
"(",
"query",
",",
"n",
"=",
"10",
",",
"top",
"=",
"10",
")",
":",
"from",
"web",
"import",
"morguefile",
"images",
"=",
"morguefile",
".",
"search",
"(",
"query",
")",
"[",
":",
"top",
"]",
"path",
"=",
"choice",
"(",
"images... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Color.str_to_rgb | Returns RGB values based on a descriptive string.
If the given str is a named color, return its RGB values.
Otherwise, return a random named color that has str
in its name, or a random named color which name appears in str.
Specific suffixes (-ish, -ed, -y and -like) are recognised
... | lib/colors/__init__.py | def str_to_rgb(self, str):
""" Returns RGB values based on a descriptive string.
If the given str is a named color, return its RGB values.
Otherwise, return a random named color that has str
in its name, or a random named color which name appears in str.
Specific suffixes (-is... | def str_to_rgb(self, str):
""" Returns RGB values based on a descriptive string.
If the given str is a named color, return its RGB values.
Otherwise, return a random named color that has str
in its name, or a random named color which name appears in str.
Specific suffixes (-is... | [
"Returns",
"RGB",
"values",
"based",
"on",
"a",
"descriptive",
"string",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L582-L618 | [
"def",
"str_to_rgb",
"(",
"self",
",",
"str",
")",
":",
"str",
"=",
"str",
".",
"lower",
"(",
")",
"for",
"ch",
"in",
"\"_- \"",
":",
"str",
"=",
"str",
".",
"replace",
"(",
"ch",
",",
"\"\"",
")",
"# if named_hues.has_key(str):",
"# clr = color(named... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Color.rotate_ryb | Returns a color rotated on the artistic RYB color wheel.
An artistic color wheel has slightly different opposites
(e.g. purple-yellow instead of purple-lime).
It is mathematically incorrect but generally assumed
to provide better complementary colors.
http://en.wikipedia.org/wi... | lib/colors/__init__.py | def rotate_ryb(self, angle=180):
""" Returns a color rotated on the artistic RYB color wheel.
An artistic color wheel has slightly different opposites
(e.g. purple-yellow instead of purple-lime).
It is mathematically incorrect but generally assumed
to provide better complementa... | def rotate_ryb(self, angle=180):
""" Returns a color rotated on the artistic RYB color wheel.
An artistic color wheel has slightly different opposites
(e.g. purple-yellow instead of purple-lime).
It is mathematically incorrect but generally assumed
to provide better complementa... | [
"Returns",
"a",
"color",
"rotated",
"on",
"the",
"artistic",
"RYB",
"color",
"wheel",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/colors/__init__.py#L696-L758 | [
"def",
"rotate_ryb",
"(",
"self",
",",
"angle",
"=",
"180",
")",
":",
"h",
"=",
"self",
".",
"h",
"*",
"360",
"angle",
"=",
"angle",
"%",
"360",
"# Approximation of Itten's RYB color wheel.",
"# In HSB, colors hues range from 0-360.",
"# However, on the artistic color... | d554c1765c1899fa25727c9fc6805d221585562b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.