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 | Parser.parse_definitions | Parse multiple definitions and yield them. | flake8_rst_docstrings.py | def parse_definitions(self, class_, all=False):
"""Parse multiple definitions and yield them."""
while self.current is not None:
self.log.debug(
"parsing definition list, current token is %r (%s)",
self.current.kind,
self.current.value,
... | def parse_definitions(self, class_, all=False):
"""Parse multiple definitions and yield them."""
while self.current is not None:
self.log.debug(
"parsing definition list, current token is %r (%s)",
self.current.kind,
self.current.value,
... | [
"Parse",
"multiple",
"definitions",
"and",
"yield",
"them",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L695-L725 | [
"def",
"parse_definitions",
"(",
"self",
",",
"class_",
",",
"all",
"=",
"False",
")",
":",
"while",
"self",
".",
"current",
"is",
"not",
"None",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"parsing definition list, current token is %r (%s)\"",
",",
"self",
... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | Parser.parse_all | Parse the __all__ definition in a module. | flake8_rst_docstrings.py | def parse_all(self):
"""Parse the __all__ definition in a module."""
assert self.current.value == "__all__"
self.consume(tk.NAME)
if self.current.value != "=":
raise AllError("Could not evaluate contents of __all__. ")
self.consume(tk.OP)
if self.current.value... | def parse_all(self):
"""Parse the __all__ definition in a module."""
assert self.current.value == "__all__"
self.consume(tk.NAME)
if self.current.value != "=":
raise AllError("Could not evaluate contents of __all__. ")
self.consume(tk.OP)
if self.current.value... | [
"Parse",
"the",
"__all__",
"definition",
"in",
"a",
"module",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L727-L760 | [
"def",
"parse_all",
"(",
"self",
")",
":",
"assert",
"self",
".",
"current",
".",
"value",
"==",
"\"__all__\"",
"self",
".",
"consume",
"(",
"tk",
".",
"NAME",
")",
"if",
"self",
".",
"current",
".",
"value",
"!=",
"\"=\"",
":",
"raise",
"AllError",
... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | Parser.parse_module | Parse a module (and its children) and return a Module object. | flake8_rst_docstrings.py | def parse_module(self):
"""Parse a module (and its children) and return a Module object."""
self.log.debug("parsing module.")
start = self.line
docstring = self.parse_docstring()
children = list(self.parse_definitions(Module, all=True))
assert self.current is None, self.c... | def parse_module(self):
"""Parse a module (and its children) and return a Module object."""
self.log.debug("parsing module.")
start = self.line
docstring = self.parse_docstring()
children = list(self.parse_definitions(Module, all=True))
assert self.current is None, self.c... | [
"Parse",
"a",
"module",
"(",
"and",
"its",
"children",
")",
"and",
"return",
"a",
"Module",
"object",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L762-L790 | [
"def",
"parse_module",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"parsing module.\"",
")",
"start",
"=",
"self",
".",
"line",
"docstring",
"=",
"self",
".",
"parse_docstring",
"(",
")",
"children",
"=",
"list",
"(",
"self",
".",
"... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | Parser.check_current | Verify the current token is of type `kind` and equals `value`. | flake8_rst_docstrings.py | def check_current(self, kind=None, value=None):
"""Verify the current token is of type `kind` and equals `value`."""
msg = textwrap.dedent(
"""
Unexpected token at line {self.line}:
In file: {self.filename}
Got kind {self.current.kind!r}
Got value {self.curren... | def check_current(self, kind=None, value=None):
"""Verify the current token is of type `kind` and equals `value`."""
msg = textwrap.dedent(
"""
Unexpected token at line {self.line}:
In file: {self.filename}
Got kind {self.current.kind!r}
Got value {self.curren... | [
"Verify",
"the",
"current",
"token",
"is",
"of",
"type",
"kind",
"and",
"equals",
"value",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L865-L879 | [
"def",
"check_current",
"(",
"self",
",",
"kind",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"msg",
"=",
"textwrap",
".",
"dedent",
"(",
"\"\"\"\n Unexpected token at line {self.line}:\n In file: {self.filename}\n Got kind {self.current.kind!r}\n ... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | Parser.parse_from_import_statement | Parse a 'from x import y' statement.
The purpose is to find __future__ statements. | flake8_rst_docstrings.py | def parse_from_import_statement(self):
"""Parse a 'from x import y' statement.
The purpose is to find __future__ statements.
"""
self.log.debug("parsing from/import statement.")
is_future_import = self._parse_from_import_source()
self._parse_from_import_names(is_future_i... | def parse_from_import_statement(self):
"""Parse a 'from x import y' statement.
The purpose is to find __future__ statements.
"""
self.log.debug("parsing from/import statement.")
is_future_import = self._parse_from_import_source()
self._parse_from_import_names(is_future_i... | [
"Parse",
"a",
"from",
"x",
"import",
"y",
"statement",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L881-L888 | [
"def",
"parse_from_import_statement",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"parsing from/import statement.\"",
")",
"is_future_import",
"=",
"self",
".",
"_parse_from_import_source",
"(",
")",
"self",
".",
"_parse_from_import_names",
"(",
... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | Parser._parse_from_import_names | Parse the 'y' part in a 'from x import y' statement. | flake8_rst_docstrings.py | def _parse_from_import_names(self, is_future_import):
"""Parse the 'y' part in a 'from x import y' statement."""
if self.current.value == "(":
self.consume(tk.OP)
expected_end_kinds = (tk.OP,)
else:
expected_end_kinds = (tk.NEWLINE, tk.ENDMARKER)
while... | def _parse_from_import_names(self, is_future_import):
"""Parse the 'y' part in a 'from x import y' statement."""
if self.current.value == "(":
self.consume(tk.OP)
expected_end_kinds = (tk.OP,)
else:
expected_end_kinds = (tk.NEWLINE, tk.ENDMARKER)
while... | [
"Parse",
"the",
"y",
"part",
"in",
"a",
"from",
"x",
"import",
"y",
"statement",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L912-L949 | [
"def",
"_parse_from_import_names",
"(",
"self",
",",
"is_future_import",
")",
":",
"if",
"self",
".",
"current",
".",
"value",
"==",
"\"(\"",
":",
"self",
".",
"consume",
"(",
"tk",
".",
"OP",
")",
"expected_end_kinds",
"=",
"(",
"tk",
".",
"OP",
",",
... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | reStructuredTextChecker.run | Use docutils to check docstrings are valid RST. | flake8_rst_docstrings.py | def run(self):
"""Use docutils to check docstrings are valid RST."""
# Is there any reason not to call load_source here?
if self.err is not None:
assert self.source is None
msg = "%s%03i %s" % (
rst_prefix,
rst_fail_load,
"F... | def run(self):
"""Use docutils to check docstrings are valid RST."""
# Is there any reason not to call load_source here?
if self.err is not None:
assert self.source is None
msg = "%s%03i %s" % (
rst_prefix,
rst_fail_load,
"F... | [
"Use",
"docutils",
"to",
"check",
"docstrings",
"are",
"valid",
"RST",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L979-L1054 | [
"def",
"run",
"(",
"self",
")",
":",
"# Is there any reason not to call load_source here?",
"if",
"self",
".",
"err",
"is",
"not",
"None",
":",
"assert",
"self",
".",
"source",
"is",
"None",
"msg",
"=",
"\"%s%03i %s\"",
"%",
"(",
"rst_prefix",
",",
"rst_fail_l... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | reStructuredTextChecker.load_source | Load the source for the specified file. | flake8_rst_docstrings.py | def load_source(self):
"""Load the source for the specified file."""
if self.filename in self.STDIN_NAMES:
self.filename = "stdin"
if sys.version_info[0] < 3:
self.source = sys.stdin.read()
else:
self.source = TextIOWrapper(sys.stdin.bu... | def load_source(self):
"""Load the source for the specified file."""
if self.filename in self.STDIN_NAMES:
self.filename = "stdin"
if sys.version_info[0] < 3:
self.source = sys.stdin.read()
else:
self.source = TextIOWrapper(sys.stdin.bu... | [
"Load",
"the",
"source",
"for",
"the",
"specified",
"file",
"."
] | peterjc/flake8-rst-docstrings | python | https://github.com/peterjc/flake8-rst-docstrings/blob/b8b17d0317fc6728d5586553ab29a7d97e6417fd/flake8_rst_docstrings.py#L1056-L1070 | [
"def",
"load_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"in",
"self",
".",
"STDIN_NAMES",
":",
"self",
".",
"filename",
"=",
"\"stdin\"",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"<",
"3",
":",
"self",
".",
"source",
"=",
... | b8b17d0317fc6728d5586553ab29a7d97e6417fd |
valid | lab_to_rgb | Converts CIE Lab to RGB components.
First we have to convert to XYZ color space.
Conversion involves using a white point,
in this case D65 which represents daylight illumination.
Algorithms adopted from:
http://www.easyrgb.com/math.php | lib/web/kuler.py | def lab_to_rgb(l, a, b):
""" Converts CIE Lab to RGB components.
First we have to convert to XYZ color space.
Conversion involves using a white point,
in this case D65 which represents daylight illumination.
Algorithms adopted from:
http://www.easyrgb.com/math.php
"""
... | def lab_to_rgb(l, a, b):
""" Converts CIE Lab to RGB components.
First we have to convert to XYZ color space.
Conversion involves using a white point,
in this case D65 which represents daylight illumination.
Algorithms adopted from:
http://www.easyrgb.com/math.php
"""
... | [
"Converts",
"CIE",
"Lab",
"to",
"RGB",
"components",
".",
"First",
"we",
"have",
"to",
"convert",
"to",
"XYZ",
"color",
"space",
".",
"Conversion",
"involves",
"using",
"a",
"white",
"point",
"in",
"this",
"case",
"D65",
"which",
"represents",
"daylight",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/kuler.py#L31-L71 | [
"def",
"lab_to_rgb",
"(",
"l",
",",
"a",
",",
"b",
")",
":",
"y",
"=",
"(",
"l",
"+",
"16",
")",
"/",
"116.0",
"x",
"=",
"a",
"/",
"500.0",
"+",
"y",
"z",
"=",
"y",
"-",
"b",
"/",
"200.0",
"v",
"=",
"[",
"x",
",",
"y",
",",
"z",
"]",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KulerTheme._darkest | Returns the darkest swatch.
Knowing the contract between a light and a dark swatch
can help us decide how to display readable typography. | lib/web/kuler.py | def _darkest(self):
""" Returns the darkest swatch.
Knowing the contract between a light and a dark swatch
can help us decide how to display readable typography.
"""
rgb, n = (1.0, 1.0, 1.0), 3.0
for r,g,b in self:
if r+g+b ... | def _darkest(self):
""" Returns the darkest swatch.
Knowing the contract between a light and a dark swatch
can help us decide how to display readable typography.
"""
rgb, n = (1.0, 1.0, 1.0), 3.0
for r,g,b in self:
if r+g+b ... | [
"Returns",
"the",
"darkest",
"swatch",
".",
"Knowing",
"the",
"contract",
"between",
"a",
"light",
"and",
"a",
"dark",
"swatch",
"can",
"help",
"us",
"decide",
"how",
"to",
"display",
"readable",
"typography",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/kuler.py#L84-L98 | [
"def",
"_darkest",
"(",
"self",
")",
":",
"rgb",
",",
"n",
"=",
"(",
"1.0",
",",
"1.0",
",",
"1.0",
")",
",",
"3.0",
"for",
"r",
",",
"g",
",",
"b",
"in",
"self",
":",
"if",
"r",
"+",
"g",
"+",
"b",
"<",
"n",
":",
"rgb",
",",
"n",
"=",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Kuler.parse_theme | Parses a theme from XML returned by Kuler.
Gets the theme's id, label and swatches.
All of the swatches are converted to RGB.
If we have a full description for a theme id in cache,
parse that to get tags associated with the theme. | lib/web/kuler.py | def parse_theme(self, xml):
""" Parses a theme from XML returned by Kuler.
Gets the theme's id, label and swatches.
All of the swatches are converted to RGB.
If we have a full description for a theme id in cache,
parse that to get tags associated with the theme.... | def parse_theme(self, xml):
""" Parses a theme from XML returned by Kuler.
Gets the theme's id, label and swatches.
All of the swatches are converted to RGB.
If we have a full description for a theme id in cache,
parse that to get tags associated with the theme.... | [
"Parses",
"a",
"theme",
"from",
"XML",
"returned",
"by",
"Kuler",
".",
"Gets",
"the",
"theme",
"s",
"id",
"label",
"and",
"swatches",
".",
"All",
"of",
"the",
"swatches",
"are",
"converted",
"to",
"RGB",
".",
"If",
"we",
"have",
"a",
"full",
"descripti... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/kuler.py#L181-L227 | [
"def",
"parse_theme",
"(",
"self",
",",
"xml",
")",
":",
"kt",
"=",
"KulerTheme",
"(",
")",
"kt",
".",
"author",
"=",
"xml",
".",
"getElementsByTagName",
"(",
"\"author\"",
")",
"[",
"0",
"]",
"kt",
".",
"author",
"=",
"kt",
".",
"author",
".",
"ch... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | create_listening_socket | Create socket and set listening options
:param host:
:param port:
:param handler:
:return: | shoebot/sbio/socket_server.py | def create_listening_socket(host, port, handler):
"""
Create socket and set listening options
:param host:
:param port:
:param handler:
:return:
"""
sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((host, port))
sock.listen(1)
... | def create_listening_socket(host, port, handler):
"""
Create socket and set listening options
:param host:
:param port:
:param handler:
:return:
"""
sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((host, port))
sock.listen(1)
... | [
"Create",
"socket",
"and",
"set",
"listening",
"options",
":",
"param",
"host",
":",
":",
"param",
"port",
":",
":",
"param",
"handler",
":",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/socket_server.py#L56-L71 | [
"def",
"create_listening_socket",
"(",
"host",
",",
"port",
",",
"handler",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
")",
"sock",
".",
"setsockopt",
"(",
"socket",
".",
"SOL_SOCKET",
",",
"socket",
".",
"SO_REUSEADDR",
",",
"1",
")",
"sock",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | SocketServer.listener | Asynchronous connection listener. Starts a handler for each connection. | shoebot/sbio/socket_server.py | def listener(self, sock, *args):
'''Asynchronous connection listener. Starts a handler for each connection.'''
conn, addr = sock.accept()
f = conn.makefile(conn)
self.shell = ShoebotCmd(self.bot, stdin=f, stdout=f, intro=INTRO)
print(_("Connected"))
GObject.io_add_watch(... | def listener(self, sock, *args):
'''Asynchronous connection listener. Starts a handler for each connection.'''
conn, addr = sock.accept()
f = conn.makefile(conn)
self.shell = ShoebotCmd(self.bot, stdin=f, stdout=f, intro=INTRO)
print(_("Connected"))
GObject.io_add_watch(... | [
"Asynchronous",
"connection",
"listener",
".",
"Starts",
"a",
"handler",
"for",
"each",
"connection",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/socket_server.py#L80-L91 | [
"def",
"listener",
"(",
"self",
",",
"sock",
",",
"*",
"args",
")",
":",
"conn",
",",
"addr",
"=",
"sock",
".",
"accept",
"(",
")",
"f",
"=",
"conn",
".",
"makefile",
"(",
"conn",
")",
"self",
".",
"shell",
"=",
"ShoebotCmd",
"(",
"self",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | SocketServer.handler | Asynchronous connection handler. Processes each line from the socket. | shoebot/sbio/socket_server.py | def handler(self, conn, *args):
'''
Asynchronous connection handler. Processes each line from the socket.
'''
# lines from cmd.Cmd
self.shell.stdout.write(self.shell.prompt)
line = self.shell.stdin.readline()
if not len(line):
line = 'EOF'
... | def handler(self, conn, *args):
'''
Asynchronous connection handler. Processes each line from the socket.
'''
# lines from cmd.Cmd
self.shell.stdout.write(self.shell.prompt)
line = self.shell.stdin.readline()
if not len(line):
line = 'EOF'
... | [
"Asynchronous",
"connection",
"handler",
".",
"Processes",
"each",
"line",
"from",
"the",
"socket",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/socket_server.py#L93-L114 | [
"def",
"handler",
"(",
"self",
",",
"conn",
",",
"*",
"args",
")",
":",
"# lines from cmd.Cmd",
"self",
".",
"shell",
".",
"stdout",
".",
"write",
"(",
"self",
".",
"shell",
".",
"prompt",
")",
"line",
"=",
"self",
".",
"shell",
".",
"stdin",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | trusted_cmd | Trusted commands cannot be run remotely
:param f:
:return: | shoebot/sbio/shell.py | def trusted_cmd(f):
"""
Trusted commands cannot be run remotely
:param f:
:return:
"""
def run_cmd(self, line):
if self.trusted:
f(self, line)
else:
print("Sorry cannot do %s here." % f.__name__[3:])
global trusted_cmds
trusted_cmds.add(f.__name_... | def trusted_cmd(f):
"""
Trusted commands cannot be run remotely
:param f:
:return:
"""
def run_cmd(self, line):
if self.trusted:
f(self, line)
else:
print("Sorry cannot do %s here." % f.__name__[3:])
global trusted_cmds
trusted_cmds.add(f.__name_... | [
"Trusted",
"commands",
"cannot",
"be",
"run",
"remotely"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L51-L67 | [
"def",
"trusted_cmd",
"(",
"f",
")",
":",
"def",
"run_cmd",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"trusted",
":",
"f",
"(",
"self",
",",
"line",
")",
"else",
":",
"print",
"(",
"\"Sorry cannot do %s here.\"",
"%",
"f",
".",
"__name__... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.print_response | print response, if cookie is set then print that each line
:param args:
:param keep: if True more output is to come
:param cookie: set a custom cookie,
if set to 'None' then self.cookie will be used.
if set to 'False' disables cookie output entirely
... | shoebot/sbio/shell.py | def print_response(self, input='', keep=False, *args, **kwargs):
"""
print response, if cookie is set then print that each line
:param args:
:param keep: if True more output is to come
:param cookie: set a custom cookie,
if set to 'None' then self.cookie wi... | def print_response(self, input='', keep=False, *args, **kwargs):
"""
print response, if cookie is set then print that each line
:param args:
:param keep: if True more output is to come
:param cookie: set a custom cookie,
if set to 'None' then self.cookie wi... | [
"print",
"response",
"if",
"cookie",
"is",
"set",
"then",
"print",
"that",
"each",
"line",
":",
"param",
"args",
":",
":",
"param",
"keep",
":",
"if",
"True",
"more",
"output",
"is",
"to",
"come",
":",
"param",
"cookie",
":",
"set",
"a",
"custom",
"c... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L108-L142 | [
"def",
"print_response",
"(",
"self",
",",
"input",
"=",
"''",
",",
"keep",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cookie",
"=",
"kwargs",
".",
"get",
"(",
"'cookie'",
")",
"if",
"cookie",
"is",
"None",
":",
"cookie",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_escape_nl | Escape newlines in any responses | shoebot/sbio/shell.py | def do_escape_nl(self, arg):
"""
Escape newlines in any responses
"""
if arg.lower() == 'off':
self.escape_nl = False
else:
self.escape_nl = True | def do_escape_nl(self, arg):
"""
Escape newlines in any responses
"""
if arg.lower() == 'off':
self.escape_nl = False
else:
self.escape_nl = True | [
"Escape",
"newlines",
"in",
"any",
"responses"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L152-L159 | [
"def",
"do_escape_nl",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
".",
"lower",
"(",
")",
"==",
"'off'",
":",
"self",
".",
"escape_nl",
"=",
"False",
"else",
":",
"self",
".",
"escape_nl",
"=",
"True"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_prompt | Enable or disable prompt
:param arg: on|off
:return: | shoebot/sbio/shell.py | def do_prompt(self, arg):
"""
Enable or disable prompt
:param arg: on|off
:return:
"""
if arg.lower() == 'off':
self.response_prompt = ''
self.prompt = ''
return
elif arg.lower() == 'on':
self.prompt = PROMPT
... | def do_prompt(self, arg):
"""
Enable or disable prompt
:param arg: on|off
:return:
"""
if arg.lower() == 'off':
self.response_prompt = ''
self.prompt = ''
return
elif arg.lower() == 'on':
self.prompt = PROMPT
... | [
"Enable",
"or",
"disable",
"prompt",
":",
"param",
"arg",
":",
"on|off",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L161-L174 | [
"def",
"do_prompt",
"(",
"self",
",",
"arg",
")",
":",
"if",
"arg",
".",
"lower",
"(",
")",
"==",
"'off'",
":",
"self",
".",
"response_prompt",
"=",
"''",
"self",
".",
"prompt",
"=",
"''",
"return",
"elif",
"arg",
".",
"lower",
"(",
")",
"==",
"'... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_speed | rewind | shoebot/sbio/shell.py | def do_speed(self, speed):
"""
rewind
"""
if speed:
try:
self.bot._speed = float(speed)
except Exception as e:
self.print_response('%s is not a valid framerate' % speed)
return
self.print_response('Speed: %s ... | def do_speed(self, speed):
"""
rewind
"""
if speed:
try:
self.bot._speed = float(speed)
except Exception as e:
self.print_response('%s is not a valid framerate' % speed)
return
self.print_response('Speed: %s ... | [
"rewind"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L182-L192 | [
"def",
"do_speed",
"(",
"self",
",",
"speed",
")",
":",
"if",
"speed",
":",
"try",
":",
"self",
".",
"bot",
".",
"_speed",
"=",
"float",
"(",
"speed",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
".",
"print_response",
"(",
"'%s is not a valid f... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_restart | Attempt to restart the bot. | shoebot/sbio/shell.py | def do_restart(self, line):
"""
Attempt to restart the bot.
"""
self.bot._frame = 0
self.bot._namespace.clear()
self.bot._namespace.update(self.bot._initial_namespace) | def do_restart(self, line):
"""
Attempt to restart the bot.
"""
self.bot._frame = 0
self.bot._namespace.clear()
self.bot._namespace.update(self.bot._initial_namespace) | [
"Attempt",
"to",
"restart",
"the",
"bot",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L194-L200 | [
"def",
"do_restart",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"bot",
".",
"_frame",
"=",
"0",
"self",
".",
"bot",
".",
"_namespace",
".",
"clear",
"(",
")",
"self",
".",
"bot",
".",
"_namespace",
".",
"update",
"(",
"self",
".",
"bot",
".... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_pause | Toggle pause | shoebot/sbio/shell.py | def do_pause(self, line):
"""
Toggle pause
"""
# along with stuff in socketserver and shell
if self.pause_speed is None:
self.pause_speed = self.bot._speed
self.bot._speed = 0
self.print_response('Paused')
else:
self.bot._sp... | def do_pause(self, line):
"""
Toggle pause
"""
# along with stuff in socketserver and shell
if self.pause_speed is None:
self.pause_speed = self.bot._speed
self.bot._speed = 0
self.print_response('Paused')
else:
self.bot._sp... | [
"Toggle",
"pause"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L202-L214 | [
"def",
"do_pause",
"(",
"self",
",",
"line",
")",
":",
"# along with stuff in socketserver and shell",
"if",
"self",
".",
"pause_speed",
"is",
"None",
":",
"self",
".",
"pause_speed",
"=",
"self",
".",
"bot",
".",
"_speed",
"self",
".",
"bot",
".",
"_speed",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_play | Resume playback if bot is paused | shoebot/sbio/shell.py | def do_play(self, line):
"""
Resume playback if bot is paused
"""
if self.pause_speed is None:
self.bot._speed = self.pause_speed
self.pause_speed = None
self.print_response("Play") | def do_play(self, line):
"""
Resume playback if bot is paused
"""
if self.pause_speed is None:
self.bot._speed = self.pause_speed
self.pause_speed = None
self.print_response("Play") | [
"Resume",
"playback",
"if",
"bot",
"is",
"paused"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L216-L223 | [
"def",
"do_play",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"pause_speed",
"is",
"None",
":",
"self",
".",
"bot",
".",
"_speed",
"=",
"self",
".",
"pause_speed",
"self",
".",
"pause_speed",
"=",
"None",
"self",
".",
"print_response",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_goto | Go to specific frame
:param line:
:return: | shoebot/sbio/shell.py | def do_goto(self, line):
"""
Go to specific frame
:param line:
:return:
"""
self.print_response("Go to frame %s" % line)
self.bot._frame = int(line) | def do_goto(self, line):
"""
Go to specific frame
:param line:
:return:
"""
self.print_response("Go to frame %s" % line)
self.bot._frame = int(line) | [
"Go",
"to",
"specific",
"frame",
":",
"param",
"line",
":",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L225-L232 | [
"def",
"do_goto",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"print_response",
"(",
"\"Go to frame %s\"",
"%",
"line",
")",
"self",
".",
"bot",
".",
"_frame",
"=",
"int",
"(",
"line",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_rewind | rewind | shoebot/sbio/shell.py | def do_rewind(self, line):
"""
rewind
"""
self.print_response("Rewinding from frame %s to 0" % self.bot._frame)
self.bot._frame = 0 | def do_rewind(self, line):
"""
rewind
"""
self.print_response("Rewinding from frame %s to 0" % self.bot._frame)
self.bot._frame = 0 | [
"rewind"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L234-L239 | [
"def",
"do_rewind",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"print_response",
"(",
"\"Rewinding from frame %s to 0\"",
"%",
"self",
".",
"bot",
".",
"_frame",
")",
"self",
".",
"bot",
".",
"_frame",
"=",
"0"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_vars | List bot variables and values | shoebot/sbio/shell.py | def do_vars(self, line):
"""
List bot variables and values
"""
if self.bot._vars:
max_name_len = max([len(name) for name in self.bot._vars])
for i, (name, v) in enumerate(self.bot._vars.items()):
keep = i < len(self.bot._vars) - 1
s... | def do_vars(self, line):
"""
List bot variables and values
"""
if self.bot._vars:
max_name_len = max([len(name) for name in self.bot._vars])
for i, (name, v) in enumerate(self.bot._vars.items()):
keep = i < len(self.bot._vars) - 1
s... | [
"List",
"bot",
"variables",
"and",
"values"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L241-L251 | [
"def",
"do_vars",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"bot",
".",
"_vars",
":",
"max_name_len",
"=",
"max",
"(",
"[",
"len",
"(",
"name",
")",
"for",
"name",
"in",
"self",
".",
"bot",
".",
"_vars",
"]",
")",
"for",
"i",
",",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_load_base64 | load filename=(file)
load base64=(base64 encoded)
Send new code to shoebot.
If it does not run successfully shoebot will attempt to role back.
Editors can enable livecoding by sending new code as it is edited. | shoebot/sbio/shell.py | def do_load_base64(self, line):
"""
load filename=(file)
load base64=(base64 encoded)
Send new code to shoebot.
If it does not run successfully shoebot will attempt to role back.
Editors can enable livecoding by sending new code as it is edited.
"""
coo... | def do_load_base64(self, line):
"""
load filename=(file)
load base64=(base64 encoded)
Send new code to shoebot.
If it does not run successfully shoebot will attempt to role back.
Editors can enable livecoding by sending new code as it is edited.
"""
coo... | [
"load",
"filename",
"=",
"(",
"file",
")",
"load",
"base64",
"=",
"(",
"base64",
"encoded",
")"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L254-L284 | [
"def",
"do_load_base64",
"(",
"self",
",",
"line",
")",
":",
"cookie",
"=",
"self",
".",
"cookie",
"executor",
"=",
"self",
".",
"bot",
".",
"_executor",
"def",
"source_good",
"(",
")",
":",
"self",
".",
"print_response",
"(",
"status",
"=",
"RESPONSE_CO... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_exit | Exit shell and shoebot | shoebot/sbio/shell.py | def do_exit(self, line):
"""
Exit shell and shoebot
"""
if self.trusted:
publish_event(QUIT_EVENT)
self.print_response('Bye.\n')
return True | def do_exit(self, line):
"""
Exit shell and shoebot
"""
if self.trusted:
publish_event(QUIT_EVENT)
self.print_response('Bye.\n')
return True | [
"Exit",
"shell",
"and",
"shoebot"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L294-L301 | [
"def",
"do_exit",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"trusted",
":",
"publish_event",
"(",
"QUIT_EVENT",
")",
"self",
".",
"print_response",
"(",
"'Bye.\\n'",
")",
"return",
"True"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_fullscreen | Make the current window fullscreen | shoebot/sbio/shell.py | def do_fullscreen(self, line):
"""
Make the current window fullscreen
"""
self.bot.canvas.sink.trigger_fullscreen_action(True)
print(self.response_prompt, file=self.stdout) | def do_fullscreen(self, line):
"""
Make the current window fullscreen
"""
self.bot.canvas.sink.trigger_fullscreen_action(True)
print(self.response_prompt, file=self.stdout) | [
"Make",
"the",
"current",
"window",
"fullscreen"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L311-L316 | [
"def",
"do_fullscreen",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"bot",
".",
"canvas",
".",
"sink",
".",
"trigger_fullscreen_action",
"(",
"True",
")",
"print",
"(",
"self",
".",
"response_prompt",
",",
"file",
"=",
"self",
".",
"stdout",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_windowed | Un-fullscreen the current window | shoebot/sbio/shell.py | def do_windowed(self, line):
"""
Un-fullscreen the current window
"""
self.bot.canvas.sink.trigger_fullscreen_action(False)
print(self.response_prompt, file=self.stdout) | def do_windowed(self, line):
"""
Un-fullscreen the current window
"""
self.bot.canvas.sink.trigger_fullscreen_action(False)
print(self.response_prompt, file=self.stdout) | [
"Un",
"-",
"fullscreen",
"the",
"current",
"window"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L318-L323 | [
"def",
"do_windowed",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"bot",
".",
"canvas",
".",
"sink",
".",
"trigger_fullscreen_action",
"(",
"False",
")",
"print",
"(",
"self",
".",
"response_prompt",
",",
"file",
"=",
"self",
".",
"stdout",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_EOF | Exit shell and shoebot
Alias for exit. | shoebot/sbio/shell.py | def do_EOF(self, line):
"""
Exit shell and shoebot
Alias for exit.
"""
print(self.response_prompt, file=self.stdout)
return self.do_exit(line) | def do_EOF(self, line):
"""
Exit shell and shoebot
Alias for exit.
"""
print(self.response_prompt, file=self.stdout)
return self.do_exit(line) | [
"Exit",
"shell",
"and",
"shoebot"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L325-L332 | [
"def",
"do_EOF",
"(",
"self",
",",
"line",
")",
":",
"print",
"(",
"self",
".",
"response_prompt",
",",
"file",
"=",
"self",
".",
"stdout",
")",
"return",
"self",
".",
"do_exit",
"(",
"line",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_help | Show help on all commands. | shoebot/sbio/shell.py | def do_help(self, arg):
"""
Show help on all commands.
"""
print(self.response_prompt, file=self.stdout)
return cmd.Cmd.do_help(self, arg) | def do_help(self, arg):
"""
Show help on all commands.
"""
print(self.response_prompt, file=self.stdout)
return cmd.Cmd.do_help(self, arg) | [
"Show",
"help",
"on",
"all",
"commands",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L334-L339 | [
"def",
"do_help",
"(",
"self",
",",
"arg",
")",
":",
"print",
"(",
"self",
".",
"response_prompt",
",",
"file",
"=",
"self",
".",
"stdout",
")",
"return",
"cmd",
".",
"Cmd",
".",
"do_help",
"(",
"self",
",",
"arg",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.do_set | Set a variable. | shoebot/sbio/shell.py | def do_set(self, line):
"""
Set a variable.
"""
try:
name, value = [part.strip() for part in line.split('=')]
if name not in self.bot._vars:
self.print_response('No such variable %s enter vars to see available vars' % name)
return
... | def do_set(self, line):
"""
Set a variable.
"""
try:
name, value = [part.strip() for part in line.split('=')]
if name not in self.bot._vars:
self.print_response('No such variable %s enter vars to see available vars' % name)
return
... | [
"Set",
"a",
"variable",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L341-L360 | [
"def",
"do_set",
"(",
"self",
",",
"line",
")",
":",
"try",
":",
"name",
",",
"value",
"=",
"[",
"part",
".",
"strip",
"(",
")",
"for",
"part",
"in",
"line",
".",
"split",
"(",
"'='",
")",
"]",
"if",
"name",
"not",
"in",
"self",
".",
"bot",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotCmd.precmd | Allow commands to have a last parameter of 'cookie=somevalue'
TODO somevalue will be prepended onto any output lines so
that editors can distinguish output from certain kinds
of events they have sent.
:param line:
:return: | shoebot/sbio/shell.py | def precmd(self, line):
"""
Allow commands to have a last parameter of 'cookie=somevalue'
TODO somevalue will be prepended onto any output lines so
that editors can distinguish output from certain kinds
of events they have sent.
:param line:
:return:
"""... | def precmd(self, line):
"""
Allow commands to have a last parameter of 'cookie=somevalue'
TODO somevalue will be prepended onto any output lines so
that editors can distinguish output from certain kinds
of events they have sent.
:param line:
:return:
"""... | [
"Allow",
"commands",
"to",
"have",
"a",
"last",
"parameter",
"of",
"cookie",
"=",
"somevalue"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/sbio/shell.py#L362-L396 | [
"def",
"precmd",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"shlex",
".",
"split",
"(",
"line",
"or",
"\"\"",
")",
"if",
"args",
"and",
"'cookie='",
"in",
"args",
"[",
"-",
"1",
"]",
":",
"cookie_index",
"=",
"line",
".",
"index",
"(",
"'co... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | drawdaisy | Draw a daisy at x, y | examples/libraries/making_libraries/daisylib.py | def drawdaisy(x, y, color='#fefefe'):
"""
Draw a daisy at x, y
"""
# save location, size etc
_ctx.push()
# save fill and stroke
_fill =_ctx.fill()
_stroke = _ctx.stroke()
sc = (1.0 / _ctx.HEIGHT) * float(y * 0.5) * 4.0
# draw stalk
_ctx.strokewidth(sc * 2.0)
_ctx.s... | def drawdaisy(x, y, color='#fefefe'):
"""
Draw a daisy at x, y
"""
# save location, size etc
_ctx.push()
# save fill and stroke
_fill =_ctx.fill()
_stroke = _ctx.stroke()
sc = (1.0 / _ctx.HEIGHT) * float(y * 0.5) * 4.0
# draw stalk
_ctx.strokewidth(sc * 2.0)
_ctx.s... | [
"Draw",
"a",
"daisy",
"at",
"x",
"y"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/examples/libraries/making_libraries/daisylib.py#L16-L55 | [
"def",
"drawdaisy",
"(",
"x",
",",
"y",
",",
"color",
"=",
"'#fefefe'",
")",
":",
"# save location, size etc",
"_ctx",
".",
"push",
"(",
")",
"# save fill and stroke",
"_fill",
"=",
"_ctx",
".",
"fill",
"(",
")",
"_stroke",
"=",
"_ctx",
".",
"stroke",
"(... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | fft_bandpassfilter | http://www.swharden.com/blog/2009-01-21-signal-filtering-with-python/#comment-16801 | lib/sbaudio/__init__.py | def fft_bandpassfilter(data, fs, lowcut, highcut):
"""
http://www.swharden.com/blog/2009-01-21-signal-filtering-with-python/#comment-16801
"""
fft = np.fft.fft(data)
# n = len(data)
# timestep = 1.0 / fs
# freq = np.fft.fftfreq(n, d=timestep)
bp = fft.copy()
# Zero out fft coefficie... | def fft_bandpassfilter(data, fs, lowcut, highcut):
"""
http://www.swharden.com/blog/2009-01-21-signal-filtering-with-python/#comment-16801
"""
fft = np.fft.fft(data)
# n = len(data)
# timestep = 1.0 / fs
# freq = np.fft.fftfreq(n, d=timestep)
bp = fft.copy()
# Zero out fft coefficie... | [
"http",
":",
"//",
"www",
".",
"swharden",
".",
"com",
"/",
"blog",
"/",
"2009",
"-",
"01",
"-",
"21",
"-",
"signal",
"-",
"filtering",
"-",
"with",
"-",
"python",
"/",
"#comment",
"-",
"16801"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/sbaudio/__init__.py#L14-L34 | [
"def",
"fft_bandpassfilter",
"(",
"data",
",",
"fs",
",",
"lowcut",
",",
"highcut",
")",
":",
"fft",
"=",
"np",
".",
"fft",
".",
"fft",
"(",
"data",
")",
"# n = len(data)",
"# timestep = 1.0 / fs",
"# freq = np.fft.fftfreq(n, d=timestep)",
"bp",
"=",
"fft",
".... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | flatten_fft | Produces a nicer graph, I'm not sure if this is correct | lib/sbaudio/__init__.py | def flatten_fft(scale=1.0):
"""
Produces a nicer graph, I'm not sure if this is correct
"""
_len = len(audio.spectrogram)
for i, v in enumerate(audio.spectrogram):
yield scale * (i * v) / _len | def flatten_fft(scale=1.0):
"""
Produces a nicer graph, I'm not sure if this is correct
"""
_len = len(audio.spectrogram)
for i, v in enumerate(audio.spectrogram):
yield scale * (i * v) / _len | [
"Produces",
"a",
"nicer",
"graph",
"I",
"m",
"not",
"sure",
"if",
"this",
"is",
"correct"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/sbaudio/__init__.py#L46-L52 | [
"def",
"flatten_fft",
"(",
"scale",
"=",
"1.0",
")",
":",
"_len",
"=",
"len",
"(",
"audio",
".",
"spectrogram",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"audio",
".",
"spectrogram",
")",
":",
"yield",
"scale",
"*",
"(",
"i",
"*",
"v",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | scaled_fft | Produces a nicer graph, I'm not sure if this is correct | lib/sbaudio/__init__.py | def scaled_fft(fft, scale=1.0):
"""
Produces a nicer graph, I'm not sure if this is correct
"""
data = np.zeros(len(fft))
for i, v in enumerate(fft):
data[i] = scale * (i * v) / NUM_SAMPLES
return data | def scaled_fft(fft, scale=1.0):
"""
Produces a nicer graph, I'm not sure if this is correct
"""
data = np.zeros(len(fft))
for i, v in enumerate(fft):
data[i] = scale * (i * v) / NUM_SAMPLES
return data | [
"Produces",
"a",
"nicer",
"graph",
"I",
"m",
"not",
"sure",
"if",
"this",
"is",
"correct"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/sbaudio/__init__.py#L55-L63 | [
"def",
"scaled_fft",
"(",
"fft",
",",
"scale",
"=",
"1.0",
")",
":",
"data",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"fft",
")",
")",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"fft",
")",
":",
"data",
"[",
"i",
"]",
"=",
"scale",
"*",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWindowHelper.get_source | Grab contents of 'doc' and return it
:param doc: The active document
:return: | extensions/gedit/gedit2-plugin/shoebotit/__init__.py | def get_source(self, doc):
"""
Grab contents of 'doc' and return it
:param doc: The active document
:return:
"""
start_iter = doc.get_start_iter()
end_iter = doc.get_end_iter()
source = doc.get_text(start_iter, end_iter, False)
return source | def get_source(self, doc):
"""
Grab contents of 'doc' and return it
:param doc: The active document
:return:
"""
start_iter = doc.get_start_iter()
end_iter = doc.get_end_iter()
source = doc.get_text(start_iter, end_iter, False)
return source | [
"Grab",
"contents",
"of",
"doc",
"and",
"return",
"it"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/gedit/gedit2-plugin/shoebotit/__init__.py#L186-L196 | [
"def",
"get_source",
"(",
"self",
",",
"doc",
")",
":",
"start_iter",
"=",
"doc",
".",
"get_start_iter",
"(",
")",
"end_iter",
"=",
"doc",
".",
"get_end_iter",
"(",
")",
"source",
"=",
"doc",
".",
"get_text",
"(",
"start_iter",
",",
"end_iter",
",",
"F... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotPlugin._create_view | Create the gtk.TextView used for shell output | extensions/gedit/gedit2-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/gedit2-plugin/shoebotit/__init__.py#L295-L306 | [
"def",
"_create_view",
"(",
"self",
",",
"name",
"=",
"\"shoebot-output\"",
")",
":",
"view",
"=",
"gtk",
".",
"TextView",
"(",
")",
"view",
".",
"set_editable",
"(",
"False",
")",
"fontdesc",
"=",
"pango",
".",
"FontDescription",
"(",
"\"Monospace\"",
")"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotPlugin._create_view | Create the gtk.TextView inside a Gtk.ScrolledWindow
:return: container, text_view | extensions/gedit/gedit3.12-plugin/shoebotit/__init__.py | def _create_view(self, name="shoebot-output"):
"""
Create the gtk.TextView inside a Gtk.ScrolledWindow
:return: container, text_view
"""
text_view = Gtk.TextView()
text_view.set_editable(False)
fontdesc = Pango.FontDescription("Monospace")
text_view.modif... | def _create_view(self, name="shoebot-output"):
"""
Create the gtk.TextView inside a Gtk.ScrolledWindow
:return: container, text_view
"""
text_view = Gtk.TextView()
text_view.set_editable(False)
fontdesc = Pango.FontDescription("Monospace")
text_view.modif... | [
"Create",
"the",
"gtk",
".",
"TextView",
"inside",
"a",
"Gtk",
".",
"ScrolledWindow",
":",
"return",
":",
"container",
"text_view"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/gedit/gedit3.12-plugin/shoebotit/__init__.py#L49-L67 | [
"def",
"_create_view",
"(",
"self",
",",
"name",
"=",
"\"shoebot-output\"",
")",
":",
"text_view",
"=",
"Gtk",
".",
"TextView",
"(",
")",
"text_view",
".",
"set_editable",
"(",
"False",
")",
"fontdesc",
"=",
"Pango",
".",
"FontDescription",
"(",
"\"Monospace... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | openAnything | URI, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have all the basic stdio read methods (read, readline, r... | shoebot/kgp.py | def openAnything(source, searchpaths=None):
"""URI, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have... | def openAnything(source, searchpaths=None):
"""URI, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have... | [
"URI",
"filename",
"or",
"string",
"--",
">",
"stream",
"This",
"function",
"lets",
"you",
"define",
"parsers",
"that",
"take",
"any",
"input",
"source",
"(",
"URL",
"pathname",
"to",
"local",
"or",
"network",
"file",
"or",
"actual",
"data",
"as",
"a",
"... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L38-L84 | [
"def",
"openAnything",
"(",
"source",
",",
"searchpaths",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"source",
",",
"\"read\"",
")",
":",
"return",
"source",
"if",
"source",
"==",
"\"-\"",
":",
"import",
"sys",
"return",
"sys",
".",
"stdin",
"# try to ... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator._load | load XML input source, return parsed XML document
- a URL of a remote XML file ("http://diveintopython.org/kant.xml")
- a filename of a local XML file ("~/diveintopython/common/py/kant.xml")
- standard input ("-")
- the actual XML document, as a string
:param searchpaths... | shoebot/kgp.py | def _load(self, source, searchpaths=None):
"""load XML input source, return parsed XML document
- a URL of a remote XML file ("http://diveintopython.org/kant.xml")
- a filename of a local XML file ("~/diveintopython/common/py/kant.xml")
- standard input ("-")
- the actual ... | def _load(self, source, searchpaths=None):
"""load XML input source, return parsed XML document
- a URL of a remote XML file ("http://diveintopython.org/kant.xml")
- a filename of a local XML file ("~/diveintopython/common/py/kant.xml")
- standard input ("-")
- the actual ... | [
"load",
"XML",
"input",
"source",
"return",
"parsed",
"XML",
"document",
"-",
"a",
"URL",
"of",
"a",
"remote",
"XML",
"file",
"(",
"http",
":",
"//",
"diveintopython",
".",
"org",
"/",
"kant",
".",
"xml",
")",
"-",
"a",
"filename",
"of",
"a",
"local"... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L96-L109 | [
"def",
"_load",
"(",
"self",
",",
"source",
",",
"searchpaths",
"=",
"None",
")",
":",
"sock",
"=",
"openAnything",
"(",
"source",
",",
"searchpaths",
"=",
"searchpaths",
")",
"xmldoc",
"=",
"minidom",
".",
"parse",
"(",
"sock",
")",
".",
"documentElemen... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.loadGrammar | load context-free grammar | shoebot/kgp.py | def loadGrammar(self, grammar, searchpaths=None):
"""load context-free grammar"""
self.grammar = self._load(grammar, searchpaths=searchpaths)
self.refs = {}
for ref in self.grammar.getElementsByTagName("ref"):
self.refs[ref.attributes["id"].value] = ref | def loadGrammar(self, grammar, searchpaths=None):
"""load context-free grammar"""
self.grammar = self._load(grammar, searchpaths=searchpaths)
self.refs = {}
for ref in self.grammar.getElementsByTagName("ref"):
self.refs[ref.attributes["id"].value] = ref | [
"load",
"context",
"-",
"free",
"grammar"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L111-L116 | [
"def",
"loadGrammar",
"(",
"self",
",",
"grammar",
",",
"searchpaths",
"=",
"None",
")",
":",
"self",
".",
"grammar",
"=",
"self",
".",
"_load",
"(",
"grammar",
",",
"searchpaths",
"=",
"searchpaths",
")",
"self",
".",
"refs",
"=",
"{",
"}",
"for",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.loadSource | load source | shoebot/kgp.py | def loadSource(self, source, searchpaths=None):
"""load source"""
self.source = self._load(source, searchpaths=searchpaths) | def loadSource(self, source, searchpaths=None):
"""load source"""
self.source = self._load(source, searchpaths=searchpaths) | [
"load",
"source"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L118-L120 | [
"def",
"loadSource",
"(",
"self",
",",
"source",
",",
"searchpaths",
"=",
"None",
")",
":",
"self",
".",
"source",
"=",
"self",
".",
"_load",
"(",
"source",
",",
"searchpaths",
"=",
"searchpaths",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.getDefaultSource | guess default source of the current grammar
The default source will be one of the <ref>s that is not
cross-referenced. This sounds complicated but it's not.
Example: The default source for kant.xml is
"<xref id='section'/>", because 'section' is the one <ref>
that... | shoebot/kgp.py | def getDefaultSource(self):
"""guess default source of the current grammar
The default source will be one of the <ref>s that is not
cross-referenced. This sounds complicated but it's not.
Example: The default source for kant.xml is
"<xref id='section'/>", because ... | def getDefaultSource(self):
"""guess default source of the current grammar
The default source will be one of the <ref>s that is not
cross-referenced. This sounds complicated but it's not.
Example: The default source for kant.xml is
"<xref id='section'/>", because ... | [
"guess",
"default",
"source",
"of",
"the",
"current",
"grammar",
"The",
"default",
"source",
"will",
"be",
"one",
"of",
"the",
"<ref",
">",
"s",
"that",
"is",
"not",
"cross",
"-",
"referenced",
".",
"This",
"sounds",
"complicated",
"but",
"it",
"s",
"not... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L122-L140 | [
"def",
"getDefaultSource",
"(",
"self",
")",
":",
"xrefs",
"=",
"{",
"}",
"for",
"xref",
"in",
"self",
".",
"grammar",
".",
"getElementsByTagName",
"(",
"\"xref\"",
")",
":",
"xrefs",
"[",
"xref",
".",
"attributes",
"[",
"\"id\"",
"]",
".",
"value",
"]... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.refresh | reset output buffer, re-parse entire source file, and return output
Since parsing involves a good deal of randomness, this is an
easy way to get new output without having to reload a grammar file
each time. | shoebot/kgp.py | def refresh(self):
"""reset output buffer, re-parse entire source file, and return output
Since parsing involves a good deal of randomness, this is an
easy way to get new output without having to reload a grammar file
each time.
"""
self.reset()
s... | def refresh(self):
"""reset output buffer, re-parse entire source file, and return output
Since parsing involves a good deal of randomness, this is an
easy way to get new output without having to reload a grammar file
each time.
"""
self.reset()
s... | [
"reset",
"output",
"buffer",
"re",
"-",
"parse",
"entire",
"source",
"file",
"and",
"return",
"output",
"Since",
"parsing",
"involves",
"a",
"good",
"deal",
"of",
"randomness",
"this",
"is",
"an",
"easy",
"way",
"to",
"get",
"new",
"output",
"without",
"ha... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L147-L156 | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"reset",
"(",
")",
"self",
".",
"parse",
"(",
"self",
".",
"source",
")",
"return",
"self",
".",
"output",
"(",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.randomChildElement | choose a random child element of a node
This is a utility method used by do_xref and do_choice. | shoebot/kgp.py | def randomChildElement(self, node):
"""choose a random child element of a node
This is a utility method used by do_xref and do_choice.
"""
choices = [e for e in node.childNodes
if e.nodeType == e.ELEMENT_NODE]
chosen = random.choice(choices)
... | def randomChildElement(self, node):
"""choose a random child element of a node
This is a utility method used by do_xref and do_choice.
"""
choices = [e for e in node.childNodes
if e.nodeType == e.ELEMENT_NODE]
chosen = random.choice(choices)
... | [
"choose",
"a",
"random",
"child",
"element",
"of",
"a",
"node",
"This",
"is",
"a",
"utility",
"method",
"used",
"by",
"do_xref",
"and",
"do_choice",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L162-L174 | [
"def",
"randomChildElement",
"(",
"self",
",",
"node",
")",
":",
"choices",
"=",
"[",
"e",
"for",
"e",
"in",
"node",
".",
"childNodes",
"if",
"e",
".",
"nodeType",
"==",
"e",
".",
"ELEMENT_NODE",
"]",
"chosen",
"=",
"random",
".",
"choice",
"(",
"cho... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.parse | parse a single XML node
A parsed XML document (from minidom.parse) is a tree of nodes
of various types. Each node is represented by an instance of the
corresponding Python class (Element for a tag, Text for
text data, Document for the top-level document). The following
... | shoebot/kgp.py | def parse(self, node):
"""parse a single XML node
A parsed XML document (from minidom.parse) is a tree of nodes
of various types. Each node is represented by an instance of the
corresponding Python class (Element for a tag, Text for
text data, Document for the top... | def parse(self, node):
"""parse a single XML node
A parsed XML document (from minidom.parse) is a tree of nodes
of various types. Each node is represented by an instance of the
corresponding Python class (Element for a tag, Text for
text data, Document for the top... | [
"parse",
"a",
"single",
"XML",
"node",
"A",
"parsed",
"XML",
"document",
"(",
"from",
"minidom",
".",
"parse",
")",
"is",
"a",
"tree",
"of",
"nodes",
"of",
"various",
"types",
".",
"Each",
"node",
"is",
"represented",
"by",
"an",
"instance",
"of",
"the... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L176-L188 | [
"def",
"parse",
"(",
"self",
",",
"node",
")",
":",
"parseMethod",
"=",
"getattr",
"(",
"self",
",",
"\"parse_%s\"",
"%",
"node",
".",
"__class__",
".",
"__name__",
")",
"parseMethod",
"(",
"node",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.parse_Text | parse a text node
The text of a text node is usually added to the output buffer
verbatim. The one exception is that <p class='sentence'> sets
a flag to capitalize the first letter of the next word. If
that flag is set, we capitalize the text and reset the flag. | shoebot/kgp.py | def parse_Text(self, node):
"""parse a text node
The text of a text node is usually added to the output buffer
verbatim. The one exception is that <p class='sentence'> sets
a flag to capitalize the first letter of the next word. If
that flag is set, we capitalize... | def parse_Text(self, node):
"""parse a text node
The text of a text node is usually added to the output buffer
verbatim. The one exception is that <p class='sentence'> sets
a flag to capitalize the first letter of the next word. If
that flag is set, we capitalize... | [
"parse",
"a",
"text",
"node",
"The",
"text",
"of",
"a",
"text",
"node",
"is",
"usually",
"added",
"to",
"the",
"output",
"buffer",
"verbatim",
".",
"The",
"one",
"exception",
"is",
"that",
"<p",
"class",
"=",
"sentence",
">",
"sets",
"a",
"flag",
"to",... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L199-L213 | [
"def",
"parse_Text",
"(",
"self",
",",
"node",
")",
":",
"text",
"=",
"node",
".",
"data",
"if",
"self",
".",
"capitalizeNextWord",
":",
"self",
".",
"pieces",
".",
"append",
"(",
"text",
"[",
"0",
"]",
".",
"upper",
"(",
")",
")",
"self",
".",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.parse_Element | parse an element
An XML element corresponds to an actual tag in the source:
<xref id='...'>, <p chance='...'>, <choice>, etc.
Each element type is handled in its own method. Like we did in
parse(), we construct a method name based on the name of the
element ("do_x... | shoebot/kgp.py | def parse_Element(self, node):
"""parse an element
An XML element corresponds to an actual tag in the source:
<xref id='...'>, <p chance='...'>, <choice>, etc.
Each element type is handled in its own method. Like we did in
parse(), we construct a method name based... | def parse_Element(self, node):
"""parse an element
An XML element corresponds to an actual tag in the source:
<xref id='...'>, <p chance='...'>, <choice>, etc.
Each element type is handled in its own method. Like we did in
parse(), we construct a method name based... | [
"parse",
"an",
"element",
"An",
"XML",
"element",
"corresponds",
"to",
"an",
"actual",
"tag",
"in",
"the",
"source",
":",
"<xref",
"id",
"=",
"...",
">",
"<p",
"chance",
"=",
"...",
">",
"<choice",
">",
"etc",
".",
"Each",
"element",
"type",
"is",
"h... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L215-L226 | [
"def",
"parse_Element",
"(",
"self",
",",
"node",
")",
":",
"handlerMethod",
"=",
"getattr",
"(",
"self",
",",
"\"do_%s\"",
"%",
"node",
".",
"tagName",
")",
"handlerMethod",
"(",
"node",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.do_xref | handle <xref id='...'> tag
An <xref id='...'> tag is a cross-reference to a <ref id='...'>
tag. <xref id='sentence'/> evaluates to a randomly chosen child of
<ref id='sentence'>. | shoebot/kgp.py | def do_xref(self, node):
"""handle <xref id='...'> tag
An <xref id='...'> tag is a cross-reference to a <ref id='...'>
tag. <xref id='sentence'/> evaluates to a randomly chosen child of
<ref id='sentence'>.
"""
id = node.attributes["id"].value
se... | def do_xref(self, node):
"""handle <xref id='...'> tag
An <xref id='...'> tag is a cross-reference to a <ref id='...'>
tag. <xref id='sentence'/> evaluates to a randomly chosen child of
<ref id='sentence'>.
"""
id = node.attributes["id"].value
se... | [
"handle",
"<xref",
"id",
"=",
"...",
">",
"tag",
"An",
"<xref",
"id",
"=",
"...",
">",
"tag",
"is",
"a",
"cross",
"-",
"reference",
"to",
"a",
"<ref",
"id",
"=",
"...",
">",
"tag",
".",
"<xref",
"id",
"=",
"sentence",
"/",
">",
"evaluates",
"to",... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L235-L243 | [
"def",
"do_xref",
"(",
"self",
",",
"node",
")",
":",
"id",
"=",
"node",
".",
"attributes",
"[",
"\"id\"",
"]",
".",
"value",
"self",
".",
"parse",
"(",
"self",
".",
"randomChildElement",
"(",
"self",
".",
"refs",
"[",
"id",
"]",
")",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | KantGenerator.do_p | handle <p> tag
The <p> tag is the core of the grammar. It can contain almost
anything: freeform text, <choice> tags, <xref> tags, even other
<p> tags. If a "class='sentence'" attribute is found, a flag
is set and the next word will be capitalized. If a "chance='X'"
... | shoebot/kgp.py | def do_p(self, node):
"""handle <p> tag
The <p> tag is the core of the grammar. It can contain almost
anything: freeform text, <choice> tags, <xref> tags, even other
<p> tags. If a "class='sentence'" attribute is found, a flag
is set and the next word will be cap... | def do_p(self, node):
"""handle <p> tag
The <p> tag is the core of the grammar. It can contain almost
anything: freeform text, <choice> tags, <xref> tags, even other
<p> tags. If a "class='sentence'" attribute is found, a flag
is set and the next word will be cap... | [
"handle",
"<p",
">",
"tag",
"The",
"<p",
">",
"tag",
"is",
"the",
"core",
"of",
"the",
"grammar",
".",
"It",
"can",
"contain",
"almost",
"anything",
":",
"freeform",
"text",
"<choice",
">",
"tags",
"<xref",
">",
"tags",
"even",
"other",
"<p",
">",
"t... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/kgp.py#L245-L266 | [
"def",
"do_p",
"(",
"self",
",",
"node",
")",
":",
"keys",
"=",
"node",
".",
"attributes",
".",
"keys",
"(",
")",
"if",
"\"class\"",
"in",
"keys",
":",
"if",
"node",
".",
"attributes",
"[",
"\"class\"",
"]",
".",
"value",
"==",
"\"sentence\"",
":",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | replace_entities | Replaces HTML special characters by readable characters.
As taken from Leif K-Brooks algorithm on:
http://groups-beta.google.com/group/comp.lang.python | lib/web/html.py | def replace_entities(ustring, placeholder=" "):
"""Replaces HTML special characters by readable characters.
As taken from Leif K-Brooks algorithm on:
http://groups-beta.google.com/group/comp.lang.python
"""
def _repl_func(match):
try:
if match.group(1): # Numeric characte... | def replace_entities(ustring, placeholder=" "):
"""Replaces HTML special characters by readable characters.
As taken from Leif K-Brooks algorithm on:
http://groups-beta.google.com/group/comp.lang.python
"""
def _repl_func(match):
try:
if match.group(1): # Numeric characte... | [
"Replaces",
"HTML",
"special",
"characters",
"by",
"readable",
"characters",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/html.py#L51-L80 | [
"def",
"replace_entities",
"(",
"ustring",
",",
"placeholder",
"=",
"\" \"",
")",
":",
"def",
"_repl_func",
"(",
"match",
")",
":",
"try",
":",
"if",
"match",
".",
"group",
"(",
"1",
")",
":",
"# Numeric character reference",
"return",
"unichr",
"(",
"int"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | open | Returns a connection to a url which you can read().
When the wait amount is exceeded, raises a URLTimeout.
When an error occurs, raises a URLError.
404 errors specifically return a HTTP404NotFound. | lib/web/url.py | def open(url, wait=10):
""" Returns a connection to a url which you can read().
When the wait amount is exceeded, raises a URLTimeout.
When an error occurs, raises a URLError.
404 errors specifically return a HTTP404NotFound.
"""
# If the url is a URLParser, get any POST parameters.
post... | def open(url, wait=10):
""" Returns a connection to a url which you can read().
When the wait amount is exceeded, raises a URLTimeout.
When an error occurs, raises a URLError.
404 errors specifically return a HTTP404NotFound.
"""
# If the url is a URLParser, get any POST parameters.
post... | [
"Returns",
"a",
"connection",
"to",
"a",
"url",
"which",
"you",
"can",
"read",
"()",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/url.py#L181-L223 | [
"def",
"open",
"(",
"url",
",",
"wait",
"=",
"10",
")",
":",
"# If the url is a URLParser, get any POST parameters.",
"post",
"=",
"None",
"if",
"isinstance",
"(",
"url",
",",
"URLParser",
")",
"and",
"url",
".",
"method",
"==",
"\"post\"",
":",
"post",
"=",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | not_found | Returns True when the url generates a "404 Not Found" error. | lib/web/url.py | def not_found(url, wait=10):
""" Returns True when the url generates a "404 Not Found" error.
"""
try: connection = open(url, wait)
except HTTP404NotFound:
return True
except:
return False
return False | def not_found(url, wait=10):
""" Returns True when the url generates a "404 Not Found" error.
"""
try: connection = open(url, wait)
except HTTP404NotFound:
return True
except:
return False
return False | [
"Returns",
"True",
"when",
"the",
"url",
"generates",
"a",
"404",
"Not",
"Found",
"error",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/url.py#L246-L257 | [
"def",
"not_found",
"(",
"url",
",",
"wait",
"=",
"10",
")",
":",
"try",
":",
"connection",
"=",
"open",
"(",
"url",
",",
"wait",
")",
"except",
"HTTP404NotFound",
":",
"return",
"True",
"except",
":",
"return",
"False",
"return",
"False"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | is_type | Determine the MIME-type of the document behind the url.
MIME is more reliable than simply checking the document extension.
Returns True when the MIME-type starts with anything in the list of types. | lib/web/url.py | def is_type(url, types=[], wait=10):
""" Determine the MIME-type of the document behind the url.
MIME is more reliable than simply checking the document extension.
Returns True when the MIME-type starts with anything in the list of types.
"""
# Types can also be a single string for convenience.
... | def is_type(url, types=[], wait=10):
""" Determine the MIME-type of the document behind the url.
MIME is more reliable than simply checking the document extension.
Returns True when the MIME-type starts with anything in the list of types.
"""
# Types can also be a single string for convenience.
... | [
"Determine",
"the",
"MIME",
"-",
"type",
"of",
"the",
"document",
"behind",
"the",
"url",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/url.py#L267-L288 | [
"def",
"is_type",
"(",
"url",
",",
"types",
"=",
"[",
"]",
",",
"wait",
"=",
"10",
")",
":",
"# Types can also be a single string for convenience.",
"if",
"isinstance",
"(",
"types",
",",
"str",
")",
":",
"types",
"=",
"[",
"types",
"]",
"try",
":",
"con... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | requirements | Build requirements based on flags
:param with_pgi: Use 'pgi' instead of 'gi' - False on CPython, True elsewhere
:param with_examples:
:return: | setup.py | def requirements(debug=True, with_examples=True, with_pgi=None):
"""
Build requirements based on flags
:param with_pgi: Use 'pgi' instead of 'gi' - False on CPython, True elsewhere
:param with_examples:
:return:
"""
reqs = list(BASE_REQUIREMENTS)
if with_pgi is None:
with_pgi = ... | def requirements(debug=True, with_examples=True, with_pgi=None):
"""
Build requirements based on flags
:param with_pgi: Use 'pgi' instead of 'gi' - False on CPython, True elsewhere
:param with_examples:
:return:
"""
reqs = list(BASE_REQUIREMENTS)
if with_pgi is None:
with_pgi = ... | [
"Build",
"requirements",
"based",
"on",
"flags"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/setup.py#L141-L172 | [
"def",
"requirements",
"(",
"debug",
"=",
"True",
",",
"with_examples",
"=",
"True",
",",
"with_pgi",
"=",
"None",
")",
":",
"reqs",
"=",
"list",
"(",
"BASE_REQUIREMENTS",
")",
"if",
"with_pgi",
"is",
"None",
":",
"with_pgi",
"=",
"is_jython",
"if",
"deb... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.image | Draws a image form path, in x,y and resize it to width, height dimensions. | shoebot/grammar/nodebox.py | def image(self, path, x, y, width=None, height=None, alpha=1.0, data=None, draw=True, **kwargs):
'''Draws a image form path, in x,y and resize it to width, height dimensions.
'''
return self.Image(path, x, y, width, height, alpha, data, **kwargs) | def image(self, path, x, y, width=None, height=None, alpha=1.0, data=None, draw=True, **kwargs):
'''Draws a image form path, in x,y and resize it to width, height dimensions.
'''
return self.Image(path, x, y, width, height, alpha, data, **kwargs) | [
"Draws",
"a",
"image",
"form",
"path",
"in",
"x",
"y",
"and",
"resize",
"it",
"to",
"width",
"height",
"dimensions",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L75-L78 | [
"def",
"image",
"(",
"self",
",",
"path",
",",
"x",
",",
"y",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"alpha",
"=",
"1.0",
",",
"data",
"=",
"None",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"s... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.rect | Draw a rectangle from x, y of width, height.
:param startx: top left x-coordinate
:param starty: top left y-coordinate
:param width: height Size of rectangle.
:roundness: Corner roundness defaults to 0.0 (a right-angle).
:draw: If True draws immediately.
:fill: Optiona... | shoebot/grammar/nodebox.py | def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
'''
Draw a rectangle from x, y of width, height.
:param startx: top left x-coordinate
:param starty: top left y-coordinate
:param width: height Size of rectangle.
:roundness: Corner roundness defa... | def rect(self, x, y, width, height, roundness=0.0, draw=True, **kwargs):
'''
Draw a rectangle from x, y of width, height.
:param startx: top left x-coordinate
:param starty: top left y-coordinate
:param width: height Size of rectangle.
:roundness: Corner roundness defa... | [
"Draw",
"a",
"rectangle",
"from",
"x",
"y",
"of",
"width",
"height",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L90-L109 | [
"def",
"rect",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"roundness",
"=",
"0.0",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"self",
".",
"BezierPath",
"(",
"*",
"*",
"kwargs",
")",
"path"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.rectmode | Set the current rectmode.
:param mode: CORNER, CENTER, CORNERS
:return: rectmode if mode is None or valid. | shoebot/grammar/nodebox.py | def rectmode(self, mode=None):
'''
Set the current rectmode.
:param mode: CORNER, CENTER, CORNERS
:return: rectmode if mode is None or valid.
'''
if mode in (self.CORNER, self.CENTER, self.CORNERS):
self.rectmode = mode
return self.rectmode
... | def rectmode(self, mode=None):
'''
Set the current rectmode.
:param mode: CORNER, CENTER, CORNERS
:return: rectmode if mode is None or valid.
'''
if mode in (self.CORNER, self.CENTER, self.CORNERS):
self.rectmode = mode
return self.rectmode
... | [
"Set",
"the",
"current",
"rectmode",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L111-L124 | [
"def",
"rectmode",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"mode",
"in",
"(",
"self",
".",
"CORNER",
",",
"self",
".",
"CENTER",
",",
"self",
".",
"CORNERS",
")",
":",
"self",
".",
"rectmode",
"=",
"mode",
"return",
"self",
".",
"r... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.ellipsemode | Set the current ellipse drawing mode.
:param mode: CORNER, CENTER, CORNERS
:return: ellipsemode if mode is None or valid. | shoebot/grammar/nodebox.py | def ellipsemode(self, mode=None):
'''
Set the current ellipse drawing mode.
:param mode: CORNER, CENTER, CORNERS
:return: ellipsemode if mode is None or valid.
'''
if mode in (self.CORNER, self.CENTER, self.CORNERS):
self.ellipsemode = mode
return... | def ellipsemode(self, mode=None):
'''
Set the current ellipse drawing mode.
:param mode: CORNER, CENTER, CORNERS
:return: ellipsemode if mode is None or valid.
'''
if mode in (self.CORNER, self.CENTER, self.CORNERS):
self.ellipsemode = mode
return... | [
"Set",
"the",
"current",
"ellipse",
"drawing",
"mode",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L126-L139 | [
"def",
"ellipsemode",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"mode",
"in",
"(",
"self",
".",
"CORNER",
",",
"self",
".",
"CENTER",
",",
"self",
".",
"CORNERS",
")",
":",
"self",
".",
"ellipsemode",
"=",
"mode",
"return",
"self",
"."... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.circle | Draw a circle
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
:param diameter: Diameter of circle.
:param draw: Draw immediately (defaults to True, set to False to inhibit drawing)
:return: Path object representing circle | shoebot/grammar/nodebox.py | def circle(self, x, y, diameter, draw=True, **kwargs):
'''Draw a circle
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
:param diameter: Diameter of circle.
:param draw: Draw immediately (defaults to True, set to False to inhibit drawin... | def circle(self, x, y, diameter, draw=True, **kwargs):
'''Draw a circle
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
:param diameter: Diameter of circle.
:param draw: Draw immediately (defaults to True, set to False to inhibit drawin... | [
"Draw",
"a",
"circle",
":",
"param",
"x",
":",
"x",
"-",
"coordinate",
"of",
"the",
"top",
"left",
"corner",
":",
"param",
"y",
":",
"y",
"-",
"coordinate",
"of",
"the",
"top",
"left",
"corner",
":",
"param",
"diameter",
":",
"Diameter",
"of",
"circl... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L157-L165 | [
"def",
"circle",
"(",
"self",
",",
"x",
",",
"y",
",",
"diameter",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"ellipse",
"(",
"x",
",",
"y",
",",
"diameter",
",",
"diameter",
",",
"draw",
",",
"*",
"*",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.arrow | Draw an arrow.
Arrows can be two types: NORMAL or FORTYFIVE.
:param x: top left x-coordinate
:param y: top left y-coordinate
:param width: width of arrow
:param type: NORMAL or FORTYFIVE
:draw: If True draws arrow immediately
:return: Path object representing... | shoebot/grammar/nodebox.py | def arrow(self, x, y, width, type=NORMAL, draw=True, **kwargs):
'''Draw an arrow.
Arrows can be two types: NORMAL or FORTYFIVE.
:param x: top left x-coordinate
:param y: top left y-coordinate
:param width: width of arrow
:param type: NORMAL or FORTYFIVE
:draw: ... | def arrow(self, x, y, width, type=NORMAL, draw=True, **kwargs):
'''Draw an arrow.
Arrows can be two types: NORMAL or FORTYFIVE.
:param x: top left x-coordinate
:param y: top left y-coordinate
:param width: width of arrow
:param type: NORMAL or FORTYFIVE
:draw: ... | [
"Draw",
"an",
"arrow",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L182-L225 | [
"def",
"arrow",
"(",
"self",
",",
"x",
",",
"y",
",",
"width",
",",
"type",
"=",
"NORMAL",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Taken from Nodebox",
"path",
"=",
"self",
".",
"BezierPath",
"(",
"*",
"*",
"kwargs",
")",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.star | Draws a star. | shoebot/grammar/nodebox.py | def star(self, startx, starty, points=20, outer=100, inner=50, draw=True, **kwargs):
'''Draws a star.
'''
# Taken from Nodebox.
self.beginpath(**kwargs)
self.moveto(startx, starty + outer)
for i in range(1, int(2 * points)):
angle = i * pi / points
... | def star(self, startx, starty, points=20, outer=100, inner=50, draw=True, **kwargs):
'''Draws a star.
'''
# Taken from Nodebox.
self.beginpath(**kwargs)
self.moveto(startx, starty + outer)
for i in range(1, int(2 * points)):
angle = i * pi / points
... | [
"Draws",
"a",
"star",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L227-L246 | [
"def",
"star",
"(",
"self",
",",
"startx",
",",
"starty",
",",
"points",
"=",
"20",
",",
"outer",
"=",
"100",
",",
"inner",
"=",
"50",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# Taken from Nodebox.",
"self",
".",
"beginpath",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.drawimage | :param image: Image to draw
:param x: optional, x coordinate (default is image.x)
:param y: optional, y coordinate (default is image.y)
:return: | shoebot/grammar/nodebox.py | def drawimage(self, image, x=None, y=None):
"""
:param image: Image to draw
:param x: optional, x coordinate (default is image.x)
:param y: optional, y coordinate (default is image.y)
:return:
"""
if x is None:
x = image.x
if y is None:
... | def drawimage(self, image, x=None, y=None):
"""
:param image: Image to draw
:param x: optional, x coordinate (default is image.x)
:param y: optional, y coordinate (default is image.y)
:return:
"""
if x is None:
x = image.x
if y is None:
... | [
":",
"param",
"image",
":",
"Image",
"to",
"draw",
":",
"param",
"x",
":",
"optional",
"x",
"coordinate",
"(",
"default",
"is",
"image",
".",
"x",
")",
":",
"param",
"y",
":",
"optional",
"y",
"coordinate",
"(",
"default",
"is",
"image",
".",
"y",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L311-L322 | [
"def",
"drawimage",
"(",
"self",
",",
"image",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
")",
":",
"if",
"x",
"is",
"None",
":",
"x",
"=",
"image",
".",
"x",
"if",
"y",
"is",
"None",
":",
"y",
"=",
"image",
".",
"y",
"self",
".",
"image... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.relmoveto | Move relatively to the last point. | shoebot/grammar/nodebox.py | def relmoveto(self, x, y):
'''Move relatively to the last point.'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.relmoveto(x, y) | def relmoveto(self, x, y):
'''Move relatively to the last point.'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.relmoveto(x, y) | [
"Move",
"relatively",
"to",
"the",
"last",
"point",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L327-L331 | [
"def",
"relmoveto",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"self",
".",
"_path",
"is",
"None",
":",
"raise",
"ShoebotError",
"(",
"_",
"(",
"\"No current path. Use beginpath() first.\"",
")",
")",
"self",
".",
"_path",
".",
"relmoveto",
"(",
"x... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.rellineto | Draw a line using relative coordinates. | shoebot/grammar/nodebox.py | def rellineto(self, x, y):
'''Draw a line using relative coordinates.'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.rellineto(x, y) | def rellineto(self, x, y):
'''Draw a line using relative coordinates.'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.rellineto(x, y) | [
"Draw",
"a",
"line",
"using",
"relative",
"coordinates",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L333-L337 | [
"def",
"rellineto",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"self",
".",
"_path",
"is",
"None",
":",
"raise",
"ShoebotError",
"(",
"_",
"(",
"\"No current path. Use beginpath() first.\"",
")",
")",
"self",
".",
"_path",
".",
"rellineto",
"(",
"x... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.relcurveto | Draws a curve relatively to the last point. | shoebot/grammar/nodebox.py | def relcurveto(self, h1x, h1y, h2x, h2y, x, y):
'''Draws a curve relatively to the last point.
'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.relcurveto(h1x, h1y, h2x, h2y, x, y) | def relcurveto(self, h1x, h1y, h2x, h2y, x, y):
'''Draws a curve relatively to the last point.
'''
if self._path is None:
raise ShoebotError(_("No current path. Use beginpath() first."))
self._path.relcurveto(h1x, h1y, h2x, h2y, x, y) | [
"Draws",
"a",
"curve",
"relatively",
"to",
"the",
"last",
"point",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L339-L344 | [
"def",
"relcurveto",
"(",
"self",
",",
"h1x",
",",
"h1y",
",",
"h2x",
",",
"h2y",
",",
"x",
",",
"y",
")",
":",
"if",
"self",
".",
"_path",
"is",
"None",
":",
"raise",
"ShoebotError",
"(",
"_",
"(",
"\"No current path. Use beginpath() first.\"",
")",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.findpath | Constructs a path between the given list of points.
Interpolates the list of points and determines
a smooth bezier path betweem them.
The curvature parameter offers some control on
how separate segments are stitched together:
from straight angles to smooth curves.
Curva... | shoebot/grammar/nodebox.py | def findpath(self, points, curvature=1.0):
"""Constructs a path between the given list of points.
Interpolates the list of points and determines
a smooth bezier path betweem them.
The curvature parameter offers some control on
how separate segments are stitched together:
... | def findpath(self, points, curvature=1.0):
"""Constructs a path between the given list of points.
Interpolates the list of points and determines
a smooth bezier path betweem them.
The curvature parameter offers some control on
how separate segments are stitched together:
... | [
"Constructs",
"a",
"path",
"between",
"the",
"given",
"list",
"of",
"points",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L346-L418 | [
"def",
"findpath",
"(",
"self",
",",
"points",
",",
"curvature",
"=",
"1.0",
")",
":",
"# The list of points consists of Point objects,",
"# but it shouldn't crash on something straightforward",
"# as someone supplying a list of (x,y)-tuples.",
"for",
"i",
",",
"pt",
"in",
"e... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.transform | Set the current transform mode.
:param mode: CENTER or CORNER | shoebot/grammar/nodebox.py | def transform(self, mode=None):
'''
Set the current transform mode.
:param mode: CENTER or CORNER'''
if mode:
self._canvas.mode = mode
return self._canvas.mode | def transform(self, mode=None):
'''
Set the current transform mode.
:param mode: CENTER or CORNER'''
if mode:
self._canvas.mode = mode
return self._canvas.mode | [
"Set",
"the",
"current",
"transform",
"mode",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L432-L439 | [
"def",
"transform",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"mode",
":",
"self",
".",
"_canvas",
".",
"mode",
"=",
"mode",
"return",
"self",
".",
"_canvas",
".",
"mode"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.translate | Translate the current position by (xt, yt) and
optionally set the transform mode.
:param xt: Amount to move horizontally
:param yt: Amount to move vertically
:mode: Set the transform mode to CENTER or CORNER | shoebot/grammar/nodebox.py | def translate(self, xt, yt, mode=None):
'''
Translate the current position by (xt, yt) and
optionally set the transform mode.
:param xt: Amount to move horizontally
:param yt: Amount to move vertically
:mode: Set the transform mode to CENTER or CORNER
'''
... | def translate(self, xt, yt, mode=None):
'''
Translate the current position by (xt, yt) and
optionally set the transform mode.
:param xt: Amount to move horizontally
:param yt: Amount to move vertically
:mode: Set the transform mode to CENTER or CORNER
'''
... | [
"Translate",
"the",
"current",
"position",
"by",
"(",
"xt",
"yt",
")",
"and",
"optionally",
"set",
"the",
"transform",
"mode",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L441-L452 | [
"def",
"translate",
"(",
"self",
",",
"xt",
",",
"yt",
",",
"mode",
"=",
"None",
")",
":",
"self",
".",
"_canvas",
".",
"translate",
"(",
"xt",
",",
"yt",
")",
"if",
"mode",
":",
"self",
".",
"_canvas",
".",
"mode",
"=",
"mode"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.scale | Set a scale at which to draw objects.
1.0 draws objects at their natural size
:param x: Scale on the horizontal plane
:param y: Scale on the vertical plane | shoebot/grammar/nodebox.py | def scale(self, x=1, y=None):
'''
Set a scale at which to draw objects.
1.0 draws objects at their natural size
:param x: Scale on the horizontal plane
:param y: Scale on the vertical plane
'''
if not y:
y = x
if x == 0:
# Cairo b... | def scale(self, x=1, y=None):
'''
Set a scale at which to draw objects.
1.0 draws objects at their natural size
:param x: Scale on the horizontal plane
:param y: Scale on the vertical plane
'''
if not y:
y = x
if x == 0:
# Cairo b... | [
"Set",
"a",
"scale",
"at",
"which",
"to",
"draw",
"objects",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L468-L484 | [
"def",
"scale",
"(",
"self",
",",
"x",
"=",
"1",
",",
"y",
"=",
"None",
")",
":",
"if",
"not",
"y",
":",
"y",
"=",
"x",
"if",
"x",
"==",
"0",
":",
"# Cairo borks on zero values",
"x",
"=",
"1",
"if",
"y",
"==",
"0",
":",
"y",
"=",
"1",
"sel... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.fill | Sets a fill color, applying it to new paths.
:param args: color in supported format | shoebot/grammar/nodebox.py | def fill(self, *args):
'''Sets a fill color, applying it to new paths.
:param args: color in supported format
'''
if args is not None:
self._canvas.fillcolor = self.color(*args)
return self._canvas.fillcolor | def fill(self, *args):
'''Sets a fill color, applying it to new paths.
:param args: color in supported format
'''
if args is not None:
self._canvas.fillcolor = self.color(*args)
return self._canvas.fillcolor | [
"Sets",
"a",
"fill",
"color",
"applying",
"it",
"to",
"new",
"paths",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L541-L548 | [
"def",
"fill",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"args",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"fillcolor",
"=",
"self",
".",
"color",
"(",
"*",
"args",
")",
"return",
"self",
".",
"_canvas",
".",
"fillcolor"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.stroke | Set a stroke color, applying it to new paths.
:param args: color in supported format | shoebot/grammar/nodebox.py | def stroke(self, *args):
'''Set a stroke color, applying it to new paths.
:param args: color in supported format
'''
if args is not None:
self._canvas.strokecolor = self.color(*args)
return self._canvas.strokecolor | def stroke(self, *args):
'''Set a stroke color, applying it to new paths.
:param args: color in supported format
'''
if args is not None:
self._canvas.strokecolor = self.color(*args)
return self._canvas.strokecolor | [
"Set",
"a",
"stroke",
"color",
"applying",
"it",
"to",
"new",
"paths",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L554-L561 | [
"def",
"stroke",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"args",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"strokecolor",
"=",
"self",
".",
"color",
"(",
"*",
"args",
")",
"return",
"self",
".",
"_canvas",
".",
"strokecolor"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.nostroke | Stop applying strokes to new paths.
:return: stroke color before nostroke was called. | shoebot/grammar/nodebox.py | def nostroke(self):
''' Stop applying strokes to new paths.
:return: stroke color before nostroke was called.
'''
c = self._canvas.strokecolor
self._canvas.strokecolor = None
return c | def nostroke(self):
''' Stop applying strokes to new paths.
:return: stroke color before nostroke was called.
'''
c = self._canvas.strokecolor
self._canvas.strokecolor = None
return c | [
"Stop",
"applying",
"strokes",
"to",
"new",
"paths",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L563-L570 | [
"def",
"nostroke",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_canvas",
".",
"strokecolor",
"self",
".",
"_canvas",
".",
"strokecolor",
"=",
"None",
"return",
"c"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.strokewidth | Set the stroke width.
:param w: Stroke width.
:return: If no width was specified then current width is returned. | shoebot/grammar/nodebox.py | def strokewidth(self, w=None):
'''Set the stroke width.
:param w: Stroke width.
:return: If no width was specified then current width is returned.
'''
if w is not None:
self._canvas.strokewidth = w
else:
return self._canvas.strokewidth | def strokewidth(self, w=None):
'''Set the stroke width.
:param w: Stroke width.
:return: If no width was specified then current width is returned.
'''
if w is not None:
self._canvas.strokewidth = w
else:
return self._canvas.strokewidth | [
"Set",
"the",
"stroke",
"width",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L572-L581 | [
"def",
"strokewidth",
"(",
"self",
",",
"w",
"=",
"None",
")",
":",
"if",
"w",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"strokewidth",
"=",
"w",
"else",
":",
"return",
"self",
".",
"_canvas",
".",
"strokewidth"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.font | Set the font to be used with new text instances.
:param fontpath: path to truetype or opentype font.
:param fontsize: size of font
:return: current current fontpath (if fontpath param not set)
Accepts TrueType and OpenType files. Depends on FreeType being
installed. | shoebot/grammar/nodebox.py | def font(self, fontpath=None, fontsize=None):
'''Set the font to be used with new text instances.
:param fontpath: path to truetype or opentype font.
:param fontsize: size of font
:return: current current fontpath (if fontpath param not set)
Accepts TrueType and OpenType files.... | def font(self, fontpath=None, fontsize=None):
'''Set the font to be used with new text instances.
:param fontpath: path to truetype or opentype font.
:param fontsize: size of font
:return: current current fontpath (if fontpath param not set)
Accepts TrueType and OpenType files.... | [
"Set",
"the",
"font",
"to",
"be",
"used",
"with",
"new",
"text",
"instances",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L592-L606 | [
"def",
"font",
"(",
"self",
",",
"fontpath",
"=",
"None",
",",
"fontsize",
"=",
"None",
")",
":",
"if",
"fontpath",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"fontfile",
"=",
"fontpath",
"else",
":",
"return",
"self",
".",
"_canvas",
"."... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.fontsize | Set or return size of current font.
:param fontsize: Size of font.
:return: Size of font (if fontsize was not specified) | shoebot/grammar/nodebox.py | def fontsize(self, fontsize=None):
'''
Set or return size of current font.
:param fontsize: Size of font.
:return: Size of font (if fontsize was not specified)
'''
if fontsize is not None:
self._canvas.fontsize = fontsize
else:
return self... | def fontsize(self, fontsize=None):
'''
Set or return size of current font.
:param fontsize: Size of font.
:return: Size of font (if fontsize was not specified)
'''
if fontsize is not None:
self._canvas.fontsize = fontsize
else:
return self... | [
"Set",
"or",
"return",
"size",
"of",
"current",
"font",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L608-L618 | [
"def",
"fontsize",
"(",
"self",
",",
"fontsize",
"=",
"None",
")",
":",
"if",
"fontsize",
"is",
"not",
"None",
":",
"self",
".",
"_canvas",
".",
"fontsize",
"=",
"fontsize",
"else",
":",
"return",
"self",
".",
"_canvas",
".",
"fontsize"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.text | Draws a string of text according to current font settings.
:param txt: Text to output
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
:param width: text width
:param height: text height
:param outline: If True draws outline tex... | shoebot/grammar/nodebox.py | def text(self, txt, x, y, width=None, height=1000000, outline=False, draw=True, **kwargs):
'''
Draws a string of text according to current font settings.
:param txt: Text to output
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
... | def text(self, txt, x, y, width=None, height=1000000, outline=False, draw=True, **kwargs):
'''
Draws a string of text according to current font settings.
:param txt: Text to output
:param x: x-coordinate of the top left corner
:param y: y-coordinate of the top left corner
... | [
"Draws",
"a",
"string",
"of",
"text",
"according",
"to",
"current",
"font",
"settings",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L620-L640 | [
"def",
"text",
"(",
"self",
",",
"txt",
",",
"x",
",",
"y",
",",
"width",
"=",
"None",
",",
"height",
"=",
"1000000",
",",
"outline",
"=",
"False",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"txt",
"=",
"self",
".",
"Text",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | NodeBot.textheight | Returns the height of a string of text according to the current
font settings.
:param txt: string to measure
:param width: width of a line of text in a block | shoebot/grammar/nodebox.py | def textheight(self, txt, width=None):
'''Returns the height of a string of text according to the current
font settings.
:param txt: string to measure
:param width: width of a line of text in a block
'''
w = width
return self.textmetrics(txt, width=w)[1] | def textheight(self, txt, width=None):
'''Returns the height of a string of text according to the current
font settings.
:param txt: string to measure
:param width: width of a line of text in a block
'''
w = width
return self.textmetrics(txt, width=w)[1] | [
"Returns",
"the",
"height",
"of",
"a",
"string",
"of",
"text",
"according",
"to",
"the",
"current",
"font",
"settings",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L680-L688 | [
"def",
"textheight",
"(",
"self",
",",
"txt",
",",
"width",
"=",
"None",
")",
":",
"w",
"=",
"width",
"return",
"self",
".",
"textmetrics",
"(",
"txt",
",",
"width",
"=",
"w",
")",
"[",
"1",
"]"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph_background | Graph background color. | lib/graph/style.py | def graph_background(s):
""" Graph background color.
"""
if s.background == None:
s._ctx.background(None)
else:
s._ctx.background(s.background)
if s.depth:
try:
clr = colors.color(s.background).darker(0.2)
p = s._ctx.rect(0, 0, s._ctx.WIDTH, s._ct... | def graph_background(s):
""" Graph background color.
"""
if s.background == None:
s._ctx.background(None)
else:
s._ctx.background(s.background)
if s.depth:
try:
clr = colors.color(s.background).darker(0.2)
p = s._ctx.rect(0, 0, s._ctx.WIDTH, s._ct... | [
"Graph",
"background",
"color",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L183-L200 | [
"def",
"graph_background",
"(",
"s",
")",
":",
"if",
"s",
".",
"background",
"==",
"None",
":",
"s",
".",
"_ctx",
".",
"background",
"(",
"None",
")",
"else",
":",
"s",
".",
"_ctx",
".",
"background",
"(",
"s",
".",
"background",
")",
"if",
"s",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | graph_traffic | Visualization of traffic-intensive nodes (based on their centrality). | lib/graph/style.py | def graph_traffic(s, node, alpha=1.0):
""" Visualization of traffic-intensive nodes (based on their centrality).
"""
r = node.__class__(None).r
r += (node.weight+0.5) * r * 5
s._ctx.nostroke()
if s.traffic:
s._ctx.fill(
s.traffic.r,
s.traffic.g,
... | def graph_traffic(s, node, alpha=1.0):
""" Visualization of traffic-intensive nodes (based on their centrality).
"""
r = node.__class__(None).r
r += (node.weight+0.5) * r * 5
s._ctx.nostroke()
if s.traffic:
s._ctx.fill(
s.traffic.r,
s.traffic.g,
... | [
"Visualization",
"of",
"traffic",
"-",
"intensive",
"nodes",
"(",
"based",
"on",
"their",
"centrality",
")",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L204-L219 | [
"def",
"graph_traffic",
"(",
"s",
",",
"node",
",",
"alpha",
"=",
"1.0",
")",
":",
"r",
"=",
"node",
".",
"__class__",
"(",
"None",
")",
".",
"r",
"r",
"+=",
"(",
"node",
".",
"weight",
"+",
"0.5",
")",
"*",
"r",
"*",
"5",
"s",
".",
"_ctx",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | node | Visualization of a default node. | lib/graph/style.py | def node(s, node, alpha=1.0):
""" Visualization of a default node.
"""
if s.depth:
try: colors.shadow(dx=5, dy=5, blur=10, alpha=0.5*alpha)
except: pass
s._ctx.nofill()
s._ctx.nostroke()
if s.fill:
s._ctx.fill(
s.fill.r,
s.fill.g,
... | def node(s, node, alpha=1.0):
""" Visualization of a default node.
"""
if s.depth:
try: colors.shadow(dx=5, dy=5, blur=10, alpha=0.5*alpha)
except: pass
s._ctx.nofill()
s._ctx.nostroke()
if s.fill:
s._ctx.fill(
s.fill.r,
s.fill.g,
... | [
"Visualization",
"of",
"a",
"default",
"node",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L223-L250 | [
"def",
"node",
"(",
"s",
",",
"node",
",",
"alpha",
"=",
"1.0",
")",
":",
"if",
"s",
".",
"depth",
":",
"try",
":",
"colors",
".",
"shadow",
"(",
"dx",
"=",
"5",
",",
"dy",
"=",
"5",
",",
"blur",
"=",
"10",
",",
"alpha",
"=",
"0.5",
"*",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | node_label | Visualization of a node's id. | lib/graph/style.py | def node_label(s, node, alpha=1.0):
""" Visualization of a node's id.
"""
if s.text:
#s._ctx.lineheight(1)
s._ctx.font(s.font)
s._ctx.fontsize(s.fontsize)
s._ctx.nostroke()
s._ctx.fill(
s.text.r,
s.text.g,
s.text.b,
... | def node_label(s, node, alpha=1.0):
""" Visualization of a node's id.
"""
if s.text:
#s._ctx.lineheight(1)
s._ctx.font(s.font)
s._ctx.fontsize(s.fontsize)
s._ctx.nostroke()
s._ctx.fill(
s.text.r,
s.text.g,
s.text.b,
... | [
"Visualization",
"of",
"a",
"node",
"s",
"id",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L254-L300 | [
"def",
"node_label",
"(",
"s",
",",
"node",
",",
"alpha",
"=",
"1.0",
")",
":",
"if",
"s",
".",
"text",
":",
"#s._ctx.lineheight(1) ",
"s",
".",
"_ctx",
".",
"font",
"(",
"s",
".",
"font",
")",
"s",
".",
"_ctx",
".",
"fontsize",
"(",
"s",
".",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | edges | Visualization of the edges in a network. | lib/graph/style.py | def edges(s, edges, alpha=1.0, weighted=False, directed=False):
""" Visualization of the edges in a network.
"""
p = s._ctx.BezierPath()
if directed and s.stroke:
pd = s._ctx.BezierPath()
if weighted and s.fill:
pw = [s._ctx.BezierPath() for i in range(11)... | def edges(s, edges, alpha=1.0, weighted=False, directed=False):
""" Visualization of the edges in a network.
"""
p = s._ctx.BezierPath()
if directed and s.stroke:
pd = s._ctx.BezierPath()
if weighted and s.fill:
pw = [s._ctx.BezierPath() for i in range(11)... | [
"Visualization",
"of",
"the",
"edges",
"in",
"a",
"network",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L304-L381 | [
"def",
"edges",
"(",
"s",
",",
"edges",
",",
"alpha",
"=",
"1.0",
",",
"weighted",
"=",
"False",
",",
"directed",
"=",
"False",
")",
":",
"p",
"=",
"s",
".",
"_ctx",
".",
"BezierPath",
"(",
")",
"if",
"directed",
"and",
"s",
".",
"stroke",
":",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | edge | Visualization of a single edge between two nodes. | lib/graph/style.py | def edge(s, path, edge, alpha=1.0):
""" Visualization of a single edge between two nodes.
"""
path.moveto(edge.node1.x, edge.node1.y)
if edge.node2.style == BACK:
path.curveto(
edge.node1.x,
edge.node2.y,
edge.node2.x,
edge.node2.y,
... | def edge(s, path, edge, alpha=1.0):
""" Visualization of a single edge between two nodes.
"""
path.moveto(edge.node1.x, edge.node1.y)
if edge.node2.style == BACK:
path.curveto(
edge.node1.x,
edge.node2.y,
edge.node2.x,
edge.node2.y,
... | [
"Visualization",
"of",
"a",
"single",
"edge",
"between",
"two",
"nodes",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L385-L404 | [
"def",
"edge",
"(",
"s",
",",
"path",
",",
"edge",
",",
"alpha",
"=",
"1.0",
")",
":",
"path",
".",
"moveto",
"(",
"edge",
".",
"node1",
".",
"x",
",",
"edge",
".",
"node1",
".",
"y",
")",
"if",
"edge",
".",
"node2",
".",
"style",
"==",
"BACK... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | edge_label | Visualization of the label accompanying an edge. | lib/graph/style.py | def edge_label(s, edge, alpha=1.0):
""" Visualization of the label accompanying an edge.
"""
if s.text and edge.label != "":
s._ctx.nostroke()
s._ctx.fill(
s.text.r,
s.text.g,
s.text.b,
s.text.a * alpha*0.75
)
s._ctx... | def edge_label(s, edge, alpha=1.0):
""" Visualization of the label accompanying an edge.
"""
if s.text and edge.label != "":
s._ctx.nostroke()
s._ctx.fill(
s.text.r,
s.text.g,
s.text.b,
s.text.a * alpha*0.75
)
s._ctx... | [
"Visualization",
"of",
"the",
"label",
"accompanying",
"an",
"edge",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L439-L488 | [
"def",
"edge_label",
"(",
"s",
",",
"edge",
",",
"alpha",
"=",
"1.0",
")",
":",
"if",
"s",
".",
"text",
"and",
"edge",
".",
"label",
"!=",
"\"\"",
":",
"s",
".",
"_ctx",
".",
"nostroke",
"(",
")",
"s",
".",
"_ctx",
".",
"fill",
"(",
"s",
".",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | path | Visualization of a shortest path between two nodes. | lib/graph/style.py | def path(s, graph, path):
""" Visualization of a shortest path between two nodes.
"""
def end(n):
r = n.r * 0.35
s._ctx.oval(n.x-r, n.y-r, r*2, r*2)
if path and len(path) > 1 and s.stroke:
s._ctx.nofill()
s._ctx.stroke(
s.stroke.r,
s.stroke.g,
... | def path(s, graph, path):
""" Visualization of a shortest path between two nodes.
"""
def end(n):
r = n.r * 0.35
s._ctx.oval(n.x-r, n.y-r, r*2, r*2)
if path and len(path) > 1 and s.stroke:
s._ctx.nofill()
s._ctx.stroke(
s.stroke.r,
s.stroke.g,
... | [
"Visualization",
"of",
"a",
"shortest",
"path",
"between",
"two",
"nodes",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L492-L525 | [
"def",
"path",
"(",
"s",
",",
"graph",
",",
"path",
")",
":",
"def",
"end",
"(",
"n",
")",
":",
"r",
"=",
"n",
".",
"r",
"*",
"0.35",
"s",
".",
"_ctx",
".",
"oval",
"(",
"n",
".",
"x",
"-",
"r",
",",
"n",
".",
"y",
"-",
"r",
",",
"r",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | styles.create | Creates a new style which inherits from the default style,
or any other style which name is supplied to the optional template parameter. | lib/graph/style.py | def create(self, stylename, **kwargs):
""" Creates a new style which inherits from the default style,
or any other style which name is supplied to the optional template parameter.
"""
if stylename == "default":
self[stylename] = style(stylename, self._ctx, **kwargs)
... | def create(self, stylename, **kwargs):
""" Creates a new style which inherits from the default style,
or any other style which name is supplied to the optional template parameter.
"""
if stylename == "default":
self[stylename] = style(stylename, self._ctx, **kwargs)
... | [
"Creates",
"a",
"new",
"style",
"which",
"inherits",
"from",
"the",
"default",
"style",
"or",
"any",
"other",
"style",
"which",
"name",
"is",
"supplied",
"to",
"the",
"optional",
"template",
"parameter",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L29-L41 | [
"def",
"create",
"(",
"self",
",",
"stylename",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"stylename",
"==",
"\"default\"",
":",
"self",
"[",
"stylename",
"]",
"=",
"style",
"(",
"stylename",
",",
"self",
".",
"_ctx",
",",
"*",
"*",
"kwargs",
")",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | styles.copy | Returns a copy of all styles and a copy of the styleguide. | lib/graph/style.py | def copy(self, graph):
""" Returns a copy of all styles and a copy of the styleguide.
"""
s = styles(graph)
s.guide = self.guide.copy(graph)
dict.__init__(s, [(v.name, v.copy()) for v in self.values()])
return s | def copy(self, graph):
""" Returns a copy of all styles and a copy of the styleguide.
"""
s = styles(graph)
s.guide = self.guide.copy(graph)
dict.__init__(s, [(v.name, v.copy()) for v in self.values()])
return s | [
"Returns",
"a",
"copy",
"of",
"all",
"styles",
"and",
"a",
"copy",
"of",
"the",
"styleguide",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L64-L70 | [
"def",
"copy",
"(",
"self",
",",
"graph",
")",
":",
"s",
"=",
"styles",
"(",
"graph",
")",
"s",
".",
"guide",
"=",
"self",
".",
"guide",
".",
"copy",
"(",
"graph",
")",
"dict",
".",
"__init__",
"(",
"s",
",",
"[",
"(",
"v",
".",
"name",
",",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | styleguide.apply | Check the rules for each node in the graph and apply the style. | lib/graph/style.py | def apply(self):
""" Check the rules for each node in the graph and apply the style.
"""
sorted = self.order + self.keys()
unique = []; [unique.append(x) for x in sorted if x not in unique]
for node in self.graph.nodes:
for s in unique:
if self.has_key... | def apply(self):
""" Check the rules for each node in the graph and apply the style.
"""
sorted = self.order + self.keys()
unique = []; [unique.append(x) for x in sorted if x not in unique]
for node in self.graph.nodes:
for s in unique:
if self.has_key... | [
"Check",
"the",
"rules",
"for",
"each",
"node",
"in",
"the",
"graph",
"and",
"apply",
"the",
"style",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L94-L102 | [
"def",
"apply",
"(",
"self",
")",
":",
"sorted",
"=",
"self",
".",
"order",
"+",
"self",
".",
"keys",
"(",
")",
"unique",
"=",
"[",
"]",
"[",
"unique",
".",
"append",
"(",
"x",
")",
"for",
"x",
"in",
"sorted",
"if",
"x",
"not",
"in",
"unique",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | styleguide.copy | Returns a copy of the styleguide for the given graph. | lib/graph/style.py | def copy(self, graph):
""" Returns a copy of the styleguide for the given graph.
"""
g = styleguide(graph)
g.order = self.order
dict.__init__(g, [(k, v) for k, v in self.iteritems()])
return g | def copy(self, graph):
""" Returns a copy of the styleguide for the given graph.
"""
g = styleguide(graph)
g.order = self.order
dict.__init__(g, [(k, v) for k, v in self.iteritems()])
return g | [
"Returns",
"a",
"copy",
"of",
"the",
"styleguide",
"for",
"the",
"given",
"graph",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/style.py#L104-L110 | [
"def",
"copy",
"(",
"self",
",",
"graph",
")",
":",
"g",
"=",
"styleguide",
"(",
"graph",
")",
"g",
".",
"order",
"=",
"self",
".",
"order",
"dict",
".",
"__init__",
"(",
"g",
",",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | JSONDecoder.raw_decode | Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
with a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a string that may
have extraneous data at the en... | lib/web/simplejson/decoder.py | def raw_decode(self, s, **kw):
"""
Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
with a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a str... | def raw_decode(self, s, **kw):
"""
Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning
with a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a str... | [
"Decode",
"a",
"JSON",
"document",
"from",
"s",
"(",
"a",
"str",
"or",
"unicode",
"beginning",
"with",
"a",
"JSON",
"document",
")",
"and",
"return",
"a",
"2",
"-",
"tuple",
"of",
"the",
"Python",
"representation",
"and",
"the",
"index",
"in",
"s",
"wh... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/simplejson/decoder.py#L327-L341 | [
"def",
"raw_decode",
"(",
"self",
",",
"s",
",",
"*",
"*",
"kw",
")",
":",
"kw",
".",
"setdefault",
"(",
"'context'",
",",
"self",
")",
"try",
":",
"obj",
",",
"end",
"=",
"self",
".",
"_scanner",
".",
"iterscan",
"(",
"s",
",",
"*",
"*",
"kw",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tracking.open_socket | Opens the socket and binds to the given host and port. Uses
SO_REUSEADDR to be as robust as possible. | lib/tuio/__init__.py | def open_socket(self):
"""
Opens the socket and binds to the given host and port. Uses
SO_REUSEADDR to be as robust as possible.
"""
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
se... | def open_socket(self):
"""
Opens the socket and binds to the given host and port. Uses
SO_REUSEADDR to be as robust as possible.
"""
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
se... | [
"Opens",
"the",
"socket",
"and",
"binds",
"to",
"the",
"given",
"host",
"and",
"port",
".",
"Uses",
"SO_REUSEADDR",
"to",
"be",
"as",
"robust",
"as",
"possible",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/__init__.py#L33-L41 | [
"def",
"open_socket",
"(",
"self",
")",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"self",
".",
"socket",
".",
"setsockopt",
"(",
"socket",
".",
"SOL_SOCKET",
",",
"so... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tracking.load_profiles | Loads all possible TUIO profiles and returns a dictionary with the
profile addresses as keys and an instance of a profile as the value | lib/tuio/__init__.py | def load_profiles(self):
"""
Loads all possible TUIO profiles and returns a dictionary with the
profile addresses as keys and an instance of a profile as the value
"""
_profiles = {}
for name, klass in inspect.getmembers(profiles):
if inspect.isclass(klass) a... | def load_profiles(self):
"""
Loads all possible TUIO profiles and returns a dictionary with the
profile addresses as keys and an instance of a profile as the value
"""
_profiles = {}
for name, klass in inspect.getmembers(profiles):
if inspect.isclass(klass) a... | [
"Loads",
"all",
"possible",
"TUIO",
"profiles",
"and",
"returns",
"a",
"dictionary",
"with",
"the",
"profile",
"addresses",
"as",
"keys",
"and",
"an",
"instance",
"of",
"a",
"profile",
"as",
"the",
"value"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/__init__.py#L57-L75 | [
"def",
"load_profiles",
"(",
"self",
")",
":",
"_profiles",
"=",
"{",
"}",
"for",
"name",
",",
"klass",
"in",
"inspect",
".",
"getmembers",
"(",
"profiles",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"klass",
")",
"and",
"name",
".",
"endswith",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tracking.update | Tells the connection manager to receive the next 1024 byte of messages
to analyze. | lib/tuio/__init__.py | def update(self):
"""
Tells the connection manager to receive the next 1024 byte of messages
to analyze.
"""
try:
self.manager.handle(self.socket.recv(1024))
except socket.error:
pass | def update(self):
"""
Tells the connection manager to receive the next 1024 byte of messages
to analyze.
"""
try:
self.manager.handle(self.socket.recv(1024))
except socket.error:
pass | [
"Tells",
"the",
"connection",
"manager",
"to",
"receive",
"the",
"next",
"1024",
"byte",
"of",
"messages",
"to",
"analyze",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/__init__.py#L86-L94 | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"manager",
".",
"handle",
"(",
"self",
".",
"socket",
".",
"recv",
"(",
"1024",
")",
")",
"except",
"socket",
".",
"error",
":",
"pass"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tracking.callback | Gets called by the CallbackManager if a new message was received | lib/tuio/__init__.py | def callback(self, *incoming):
"""
Gets called by the CallbackManager if a new message was received
"""
message = incoming[0]
if message:
address, command = message[0], message[2]
profile = self.get_profile(address)
if profile is not None:
... | def callback(self, *incoming):
"""
Gets called by the CallbackManager if a new message was received
"""
message = incoming[0]
if message:
address, command = message[0], message[2]
profile = self.get_profile(address)
if profile is not None:
... | [
"Gets",
"called",
"by",
"the",
"CallbackManager",
"if",
"a",
"new",
"message",
"was",
"received"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/tuio/__init__.py#L96-L108 | [
"def",
"callback",
"(",
"self",
",",
"*",
"incoming",
")",
":",
"message",
"=",
"incoming",
"[",
"0",
"]",
"if",
"message",
":",
"address",
",",
"command",
"=",
"message",
"[",
"0",
"]",
",",
"message",
"[",
"2",
"]",
"profile",
"=",
"self",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | copytree | copytree that works even if folder already exists | extensions/gedit/gedit2-plugin/install.py | def copytree(src, dst, symlinks=False, ignore=None):
"""
copytree that works even if folder already exists
"""
# http://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth
if not os.path.exists(dst):
os.makedirs(dst)
sh... | def copytree(src, dst, symlinks=False, ignore=None):
"""
copytree that works even if folder already exists
"""
# http://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth
if not os.path.exists(dst):
os.makedirs(dst)
sh... | [
"copytree",
"that",
"works",
"even",
"if",
"folder",
"already",
"exists"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/extensions/gedit/gedit2-plugin/install.py#L28-L56 | [
"def",
"copytree",
"(",
"src",
",",
"dst",
",",
"symlinks",
"=",
"False",
",",
"ignore",
"=",
"None",
")",
":",
"# http://stackoverflow.com/questions/1868714/how-do-i-copy-an-entire-directory-of-files-into-an-existing-directory-using-pyth",
"if",
"not",
"os",
".",
"path",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | dumps | Serialize ``obj`` to a JSON formatted ``str``.
If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
will be skipped instead of raising a ``TypeError``.
If ``ensure_ascii`` is ``False``, then the return value w... | lib/web/simplejson/__init__.py | def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
encoding='utf-8', default=None, **kw):
"""
Serialize ``obj`` to a JSON formatted ``str``.
If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
... | def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
encoding='utf-8', default=None, **kw):
"""
Serialize ``obj`` to a JSON formatted ``str``.
If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
... | [
"Serialize",
"obj",
"to",
"a",
"JSON",
"formatted",
"str",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/simplejson/__init__.py#L188-L241 | [
"def",
"dumps",
"(",
"obj",
",",
"skipkeys",
"=",
"False",
",",
"ensure_ascii",
"=",
"True",
",",
"check_circular",
"=",
"True",
",",
"allow_nan",
"=",
"True",
",",
"cls",
"=",
"None",
",",
"indent",
"=",
"None",
",",
"separators",
"=",
"None",
",",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | search | Returns a Google web query formatted as a GoogleSearch list object. | lib/web/google.py | def search(q, start=0, wait=10, asynchronous=False, cached=False):
""" Returns a Google web query formatted as a GoogleSearch list object.
"""
service = GOOGLE_SEARCH
return GoogleSearch(q, start, service, "", wait, asynchronous, cached) | def search(q, start=0, wait=10, asynchronous=False, cached=False):
""" Returns a Google web query formatted as a GoogleSearch list object.
"""
service = GOOGLE_SEARCH
return GoogleSearch(q, start, service, "", wait, asynchronous, cached) | [
"Returns",
"a",
"Google",
"web",
"query",
"formatted",
"as",
"a",
"GoogleSearch",
"list",
"object",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/google.py#L212-L218 | [
"def",
"search",
"(",
"q",
",",
"start",
"=",
"0",
",",
"wait",
"=",
"10",
",",
"asynchronous",
"=",
"False",
",",
"cached",
"=",
"False",
")",
":",
"service",
"=",
"GOOGLE_SEARCH",
"return",
"GoogleSearch",
"(",
"q",
",",
"start",
",",
"service",
",... | d554c1765c1899fa25727c9fc6805d221585562b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.