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 | draw_list | Draws list markup with indentation in NodeBox.
Draw list markup at x, y coordinates
using indented bullets or numbers.
The callback is a command that takes a str and an int. | lib/web/wikipedia.py | def draw_list(markup, x, y, w, padding=5, callback=None):
""" Draws list markup with indentation in NodeBox.
Draw list markup at x, y coordinates
using indented bullets or numbers.
The callback is a command that takes a str and an int.
"""
try: from web import _ctx
except: pa... | def draw_list(markup, x, y, w, padding=5, callback=None):
""" Draws list markup with indentation in NodeBox.
Draw list markup at x, y coordinates
using indented bullets or numbers.
The callback is a command that takes a str and an int.
"""
try: from web import _ctx
except: pa... | [
"Draws",
"list",
"markup",
"with",
"indentation",
"in",
"NodeBox",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1412-L1449 | [
"def",
"draw_list",
"(",
"markup",
",",
"x",
",",
"y",
",",
"w",
",",
"padding",
"=",
"5",
",",
"callback",
"=",
"None",
")",
":",
"try",
":",
"from",
"web",
"import",
"_ctx",
"except",
":",
"pass",
"i",
"=",
"1",
"for",
"chunk",
"in",
"markup",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | draw_table | This is a very poor algorithm to draw Wikipedia tables in NodeBox. | lib/web/wikipedia.py | def draw_table(table, x, y, w, padding=5):
""" This is a very poor algorithm to draw Wikipedia tables in NodeBox.
"""
try: from web import _ctx
except: pass
f = _ctx.fill()
_ctx.stroke(f)
h = _ctx.textheight(" ") + padding*2
row_y = y
if table.title != "":
... | def draw_table(table, x, y, w, padding=5):
""" This is a very poor algorithm to draw Wikipedia tables in NodeBox.
"""
try: from web import _ctx
except: pass
f = _ctx.fill()
_ctx.stroke(f)
h = _ctx.textheight(" ") + padding*2
row_y = y
if table.title != "":
... | [
"This",
"is",
"a",
"very",
"poor",
"algorithm",
"to",
"draw",
"Wikipedia",
"tables",
"in",
"NodeBox",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1451-L1534 | [
"def",
"draw_table",
"(",
"table",
",",
"x",
",",
"y",
",",
"w",
",",
"padding",
"=",
"5",
")",
":",
"try",
":",
"from",
"web",
"import",
"_ctx",
"except",
":",
"pass",
"f",
"=",
"_ctx",
".",
"fill",
"(",
")",
"_ctx",
".",
"stroke",
"(",
"f",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse | Parses data from Wikipedia page markup.
The markup comes from Wikipedia's edit page.
We parse it here into objects containing plain text.
The light version parses only links to other articles, it's faster than a full parse. | lib/web/wikipedia.py | def parse(self, light=False):
""" Parses data from Wikipedia page markup.
The markup comes from Wikipedia's edit page.
We parse it here into objects containing plain text.
The light version parses only links to other articles, it's faster than a full parse.
"""
... | def parse(self, light=False):
""" Parses data from Wikipedia page markup.
The markup comes from Wikipedia's edit page.
We parse it here into objects containing plain text.
The light version parses only links to other articles, it's faster than a full parse.
"""
... | [
"Parses",
"data",
"from",
"Wikipedia",
"page",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L499-L538 | [
"def",
"parse",
"(",
"self",
",",
"light",
"=",
"False",
")",
":",
"markup",
"=",
"self",
".",
"markup",
"self",
".",
"disambiguation",
"=",
"self",
".",
"parse_disambiguation",
"(",
"markup",
")",
"self",
".",
"categories",
"=",
"self",
".",
"parse_cate... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.plain | Strips Wikipedia markup from given text.
This creates a "plain" version of the markup,
stripping images and references and the like.
Does some commonsense maintenance as well,
like collapsing multiple spaces.
If you specified full_strip=False for WikipediaPage instance,
... | lib/web/wikipedia.py | def plain(self, markup):
""" Strips Wikipedia markup from given text.
This creates a "plain" version of the markup,
stripping images and references and the like.
Does some commonsense maintenance as well,
like collapsing multiple spaces.
If you specified... | def plain(self, markup):
""" Strips Wikipedia markup from given text.
This creates a "plain" version of the markup,
stripping images and references and the like.
Does some commonsense maintenance as well,
like collapsing multiple spaces.
If you specified... | [
"Strips",
"Wikipedia",
"markup",
"from",
"given",
"text",
".",
"This",
"creates",
"a",
"plain",
"version",
"of",
"the",
"markup",
"stripping",
"images",
"and",
"references",
"and",
"the",
"like",
".",
"Does",
"some",
"commonsense",
"maintenance",
"as",
"well",... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L540-L632 | [
"def",
"plain",
"(",
"self",
",",
"markup",
")",
":",
"# Strip bold and italic.",
"if",
"self",
".",
"full_strip",
":",
"markup",
"=",
"markup",
".",
"replace",
"(",
"\"'''\"",
",",
"\"\"",
")",
"markup",
"=",
"markup",
".",
"replace",
"(",
"\"''\"",
","... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.convert_pre | Substitutes <pre> to Wikipedia markup by adding a space at the start of a line. | lib/web/wikipedia.py | def convert_pre(self, markup):
""" Substitutes <pre> to Wikipedia markup by adding a space at the start of a line.
"""
for m in re.findall(self.re["preformatted"], markup):
markup = markup.replace(m, m.replace("\n", "\n "))
markup = re.sub("<pre.*?>\n{0,... | def convert_pre(self, markup):
""" Substitutes <pre> to Wikipedia markup by adding a space at the start of a line.
"""
for m in re.findall(self.re["preformatted"], markup):
markup = markup.replace(m, m.replace("\n", "\n "))
markup = re.sub("<pre.*?>\n{0,... | [
"Substitutes",
"<pre",
">",
"to",
"Wikipedia",
"markup",
"by",
"adding",
"a",
"space",
"at",
"the",
"start",
"of",
"a",
"line",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L634-L644 | [
"def",
"convert_pre",
"(",
"self",
",",
"markup",
")",
":",
"for",
"m",
"in",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"preformatted\"",
"]",
",",
"markup",
")",
":",
"markup",
"=",
"markup",
".",
"replace",
"(",
"m",
",",
"m",
".",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.convert_li | Subtitutes <li> content to Wikipedia markup. | lib/web/wikipedia.py | def convert_li(self, markup):
""" Subtitutes <li> content to Wikipedia markup.
"""
for li in re.findall("<li;*?>", markup):
markup = re.sub(li, "\n* ", markup)
markup = markup.replace("</li>", "")
return markup | def convert_li(self, markup):
""" Subtitutes <li> content to Wikipedia markup.
"""
for li in re.findall("<li;*?>", markup):
markup = re.sub(li, "\n* ", markup)
markup = markup.replace("</li>", "")
return markup | [
"Subtitutes",
"<li",
">",
"content",
"to",
"Wikipedia",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L646-L655 | [
"def",
"convert_li",
"(",
"self",
",",
"markup",
")",
":",
"for",
"li",
"in",
"re",
".",
"findall",
"(",
"\"<li;*?>\"",
",",
"markup",
")",
":",
"markup",
"=",
"re",
".",
"sub",
"(",
"li",
",",
"\"\\n* \"",
",",
"markup",
")",
"markup",
"=",
"marku... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.convert_table | Subtitutes <table> content to Wikipedia markup. | lib/web/wikipedia.py | def convert_table(self, markup):
""" Subtitutes <table> content to Wikipedia markup.
"""
for table in re.findall(self.re["html-table"], markup):
wiki = table
wiki = re.sub(r"<table(.*?)>", "{|\\1", wiki)
wiki = re.sub(r"<tr(.*?)>", "|-\\1", w... | def convert_table(self, markup):
""" Subtitutes <table> content to Wikipedia markup.
"""
for table in re.findall(self.re["html-table"], markup):
wiki = table
wiki = re.sub(r"<table(.*?)>", "{|\\1", wiki)
wiki = re.sub(r"<tr(.*?)>", "|-\\1", w... | [
"Subtitutes",
"<table",
">",
"content",
"to",
"Wikipedia",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L657-L672 | [
"def",
"convert_table",
"(",
"self",
",",
"markup",
")",
":",
"for",
"table",
"in",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"html-table\"",
"]",
",",
"markup",
")",
":",
"wiki",
"=",
"table",
"wiki",
"=",
"re",
".",
"sub",
"(",
"r\"<ta... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_links | Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.
The return value is a list contain... | lib/web/wikipedia.py | def parse_links(self, markup):
""" Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.... | def parse_links(self, markup):
""" Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.... | [
"Returns",
"a",
"list",
"of",
"internal",
"Wikipedia",
"links",
"in",
"the",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L674-L709 | [
"def",
"parse_links",
"(",
"self",
",",
"markup",
")",
":",
"links",
"=",
"[",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"link\"",
"]",
",",
"markup",
")",
"for",
"link",
"in",
"m",
":",
"# We don't like [[{{{1|Universe (disam... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_images | Returns a list of images found in the markup.
An image has a pathname, a description in plain text
and a list of properties Wikipedia uses to size and place images.
# A Wikipedia image looks like:
# [[Image:Columbia Supercomputer - NASA Advanced Supercomputing Facility.jpg|righ... | lib/web/wikipedia.py | def parse_images(self, markup, treshold=6):
""" Returns a list of images found in the markup.
An image has a pathname, a description in plain text
and a list of properties Wikipedia uses to size and place images.
# A Wikipedia image looks like:
# [[Image:Columb... | def parse_images(self, markup, treshold=6):
""" Returns a list of images found in the markup.
An image has a pathname, a description in plain text
and a list of properties Wikipedia uses to size and place images.
# A Wikipedia image looks like:
# [[Image:Columb... | [
"Returns",
"a",
"list",
"of",
"images",
"found",
"in",
"the",
"markup",
".",
"An",
"image",
"has",
"a",
"pathname",
"a",
"description",
"in",
"plain",
"text",
"and",
"a",
"list",
"of",
"properties",
"Wikipedia",
"uses",
"to",
"size",
"and",
"place",
"ima... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L711-L751 | [
"def",
"parse_images",
"(",
"self",
",",
"markup",
",",
"treshold",
"=",
"6",
")",
":",
"images",
"=",
"[",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"image\"",
"]",
",",
"markup",
")",
"for",
"p",
"in",
"m",
":",
"p",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_balanced_image | Corrects Wikipedia image markup.
Images have a description inside their link markup that
can contain link markup itself, make sure the outer "[" and "]" brackets
delimiting the image are balanced correctly (e.g. no [[ ]] ]]).
Called from parse_images(). | lib/web/wikipedia.py | def parse_balanced_image(self, markup):
""" Corrects Wikipedia image markup.
Images have a description inside their link markup that
can contain link markup itself, make sure the outer "[" and "]" brackets
delimiting the image are balanced correctly (e.g. no [[ ]] ]]).
... | def parse_balanced_image(self, markup):
""" Corrects Wikipedia image markup.
Images have a description inside their link markup that
can contain link markup itself, make sure the outer "[" and "]" brackets
delimiting the image are balanced correctly (e.g. no [[ ]] ]]).
... | [
"Corrects",
"Wikipedia",
"image",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L753-L773 | [
"def",
"parse_balanced_image",
"(",
"self",
",",
"markup",
")",
":",
"opened",
"=",
"0",
"closed",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"markup",
")",
")",
":",
"if",
"markup",
"[",
"i",
"]",
"==",
"\"[\"",
":",
"opened",
"+=",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_gallery_images | Parses images from the <gallery></gallery> section.
Images inside <gallery> tags do not have outer "[[" brackets.
Add these and then parse again. | lib/web/wikipedia.py | def parse_gallery_images(self, markup):
""" Parses images from the <gallery></gallery> section.
Images inside <gallery> tags do not have outer "[[" brackets.
Add these and then parse again.
"""
gallery = re.search(self.re["gallery"], markup)
... | def parse_gallery_images(self, markup):
""" Parses images from the <gallery></gallery> section.
Images inside <gallery> tags do not have outer "[[" brackets.
Add these and then parse again.
"""
gallery = re.search(self.re["gallery"], markup)
... | [
"Parses",
"images",
"from",
"the",
"<gallery",
">",
"<",
"/",
"gallery",
">",
"section",
".",
"Images",
"inside",
"<gallery",
">",
"tags",
"do",
"not",
"have",
"outer",
"[[",
"brackets",
".",
"Add",
"these",
"and",
"then",
"parse",
"again",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L775-L792 | [
"def",
"parse_gallery_images",
"(",
"self",
",",
"markup",
")",
":",
"gallery",
"=",
"re",
".",
"search",
"(",
"self",
".",
"re",
"[",
"\"gallery\"",
"]",
",",
"markup",
")",
"if",
"gallery",
":",
"gallery",
"=",
"gallery",
".",
"group",
"(",
"1",
")... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_paragraph | Creates a list from lines of text in a paragraph.
Each line of text is a new item in the list,
except lists and preformatted chunks (<li> and <pre>),
these are kept together as a single chunk.
Lists are formatted using parse_paragraph_list().
Empty line... | lib/web/wikipedia.py | def parse_paragraph(self, markup):
""" Creates a list from lines of text in a paragraph.
Each line of text is a new item in the list,
except lists and preformatted chunks (<li> and <pre>),
these are kept together as a single chunk.
Lists are formatted u... | def parse_paragraph(self, markup):
""" Creates a list from lines of text in a paragraph.
Each line of text is a new item in the list,
except lists and preformatted chunks (<li> and <pre>),
these are kept together as a single chunk.
Lists are formatted u... | [
"Creates",
"a",
"list",
"from",
"lines",
"of",
"text",
"in",
"a",
"paragraph",
".",
"Each",
"line",
"of",
"text",
"is",
"a",
"new",
"item",
"in",
"the",
"list",
"except",
"lists",
"and",
"preformatted",
"chunks",
"(",
"<li",
">",
"and",
"<pre",
">",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L794-L841 | [
"def",
"parse_paragraph",
"(",
"self",
",",
"markup",
")",
":",
"s",
"=",
"self",
".",
"plain",
"(",
"markup",
")",
"# Add an extra linebreak between the last list item",
"# and the normal line following after it, so they don't stick together, e.g.",
"# **[[Alin Magic]], magic us... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_paragraph_list | Formats bullets and numbering of Wikipedia lists.
List items are marked by "*", "#" or ";" at the start of a line.
We treat ";" the same as "*",
and replace "#" with real numbering (e.g. "2.").
Sublists (e.g. *** and ###) get indented by tabs.
Called from parse_... | lib/web/wikipedia.py | def parse_paragraph_list(self, markup, indent="\t"):
""" Formats bullets and numbering of Wikipedia lists.
List items are marked by "*", "#" or ";" at the start of a line.
We treat ";" the same as "*",
and replace "#" with real numbering (e.g. "2.").
Sublists (e... | def parse_paragraph_list(self, markup, indent="\t"):
""" Formats bullets and numbering of Wikipedia lists.
List items are marked by "*", "#" or ";" at the start of a line.
We treat ";" the same as "*",
and replace "#" with real numbering (e.g. "2.").
Sublists (e... | [
"Formats",
"bullets",
"and",
"numbering",
"of",
"Wikipedia",
"lists",
".",
"List",
"items",
"are",
"marked",
"by",
"*",
"#",
"or",
";",
"at",
"the",
"start",
"of",
"a",
"line",
".",
"We",
"treat",
";",
"the",
"same",
"as",
"*",
"and",
"replace",
"#",... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L843-L879 | [
"def",
"parse_paragraph_list",
"(",
"self",
",",
"markup",
",",
"indent",
"=",
"\"\\t\"",
")",
":",
"def",
"lastleft",
"(",
"ch",
",",
"str",
")",
":",
"n",
"=",
"0",
"while",
"n",
"<",
"len",
"(",
"str",
")",
"and",
"str",
"[",
"n",
"]",
"==",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.connect_paragraph | Create parent/child links to other paragraphs.
The paragraphs parameters is a list of all the paragraphs
parsed up till now.
The parent is the previous paragraph whose depth is less.
The parent's children include this paragraph.
Called from parse_paragr... | lib/web/wikipedia.py | def connect_paragraph(self, paragraph, paragraphs):
""" Create parent/child links to other paragraphs.
The paragraphs parameters is a list of all the paragraphs
parsed up till now.
The parent is the previous paragraph whose depth is less.
The parent's c... | def connect_paragraph(self, paragraph, paragraphs):
""" Create parent/child links to other paragraphs.
The paragraphs parameters is a list of all the paragraphs
parsed up till now.
The parent is the previous paragraph whose depth is less.
The parent's c... | [
"Create",
"parent",
"/",
"child",
"links",
"to",
"other",
"paragraphs",
".",
"The",
"paragraphs",
"parameters",
"is",
"a",
"list",
"of",
"all",
"the",
"paragraphs",
"parsed",
"up",
"till",
"now",
".",
"The",
"parent",
"is",
"the",
"previous",
"paragraph",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L895-L918 | [
"def",
"connect_paragraph",
"(",
"self",
",",
"paragraph",
",",
"paragraphs",
")",
":",
"if",
"paragraph",
".",
"depth",
">",
"0",
":",
"n",
"=",
"range",
"(",
"len",
"(",
"paragraphs",
")",
")",
"n",
".",
"reverse",
"(",
")",
"for",
"i",
"in",
"n"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_paragraph_references | Updates references with content from specific paragraphs.
The "references", "notes", "external links" paragraphs
are double-checked for references. Not all items in the list
might have been referenced inside the article, or the item
might contain more info than we initially par... | lib/web/wikipedia.py | def parse_paragraph_references(self, markup):
""" Updates references with content from specific paragraphs.
The "references", "notes", "external links" paragraphs
are double-checked for references. Not all items in the list
might have been referenced inside the article... | def parse_paragraph_references(self, markup):
""" Updates references with content from specific paragraphs.
The "references", "notes", "external links" paragraphs
are double-checked for references. Not all items in the list
might have been referenced inside the article... | [
"Updates",
"references",
"with",
"content",
"from",
"specific",
"paragraphs",
".",
"The",
"references",
"notes",
"external",
"links",
"paragraphs",
"are",
"double",
"-",
"checked",
"for",
"references",
".",
"Not",
"all",
"items",
"in",
"the",
"list",
"might",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L920-L952 | [
"def",
"parse_paragraph_references",
"(",
"self",
",",
"markup",
")",
":",
"for",
"chunk",
"in",
"markup",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"# We already parsed this, it contains the self.ref mark.",
"# See if we can strip more notes from it.",
"m",
"=",
"re",
".... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_paragraphs | Returns a list of paragraphs in the markup.
A paragraph has a title and multiple lines of plain text.
A paragraph might have parent and child paragraphs,
denoting subtitles or bigger chapters.
A paragraph might have links to additional articles.
Formats... | lib/web/wikipedia.py | def parse_paragraphs(self, markup):
""" Returns a list of paragraphs in the markup.
A paragraph has a title and multiple lines of plain text.
A paragraph might have parent and child paragraphs,
denoting subtitles or bigger chapters.
A paragraph might ha... | def parse_paragraphs(self, markup):
""" Returns a list of paragraphs in the markup.
A paragraph has a title and multiple lines of plain text.
A paragraph might have parent and child paragraphs,
denoting subtitles or bigger chapters.
A paragraph might ha... | [
"Returns",
"a",
"list",
"of",
"paragraphs",
"in",
"the",
"markup",
".",
"A",
"paragraph",
"has",
"a",
"title",
"and",
"multiple",
"lines",
"of",
"plain",
"text",
".",
"A",
"paragraph",
"might",
"have",
"parent",
"and",
"child",
"paragraphs",
"denoting",
"s... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L954-L1044 | [
"def",
"parse_paragraphs",
"(",
"self",
",",
"markup",
")",
":",
"# Paragraphs to exclude.",
"refs",
"=",
"[",
"\"references\"",
",",
"\"notes\"",
",",
"\"notes and references\"",
",",
"\"external links\"",
",",
"\"further reading\"",
"]",
"exclude",
"=",
"[",
"\"se... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_table_row | Parses a row of cells in a Wikipedia table.
Cells in the row are separated by "||".
A "!" indicates a row of heading columns.
Each cell can contain properties before a "|",
# e.g. align="right" | Cell 2 (right aligned). | lib/web/wikipedia.py | def parse_table_row(self, markup, row):
""" Parses a row of cells in a Wikipedia table.
Cells in the row are separated by "||".
A "!" indicates a row of heading columns.
Each cell can contain properties before a "|",
# e.g. align="right" | Cell 2 (right aligned). ... | def parse_table_row(self, markup, row):
""" Parses a row of cells in a Wikipedia table.
Cells in the row are separated by "||".
A "!" indicates a row of heading columns.
Each cell can contain properties before a "|",
# e.g. align="right" | Cell 2 (right aligned). ... | [
"Parses",
"a",
"row",
"of",
"cells",
"in",
"a",
"Wikipedia",
"table",
".",
"Cells",
"in",
"the",
"row",
"are",
"separated",
"by",
"||",
".",
"A",
"!",
"indicates",
"a",
"row",
"of",
"heading",
"columns",
".",
"Each",
"cell",
"can",
"contain",
"properti... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1046-L1075 | [
"def",
"parse_table_row",
"(",
"self",
",",
"markup",
",",
"row",
")",
":",
"if",
"row",
"==",
"None",
":",
"row",
"=",
"WikipediaTableRow",
"(",
")",
"markup",
"=",
"markup",
".",
"replace",
"(",
"\"!!\"",
",",
"\"||\"",
")",
"for",
"cell",
"in",
"m... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.connect_table | Creates a link from the table to paragraph and vice versa.
Finds the first heading above the table in the markup.
This is the title of the paragraph the table belongs to. | lib/web/wikipedia.py | def connect_table(self, table, chunk, markup):
""" Creates a link from the table to paragraph and vice versa.
Finds the first heading above the table in the markup.
This is the title of the paragraph the table belongs to.
"""
k = markup.find(chunk)
i =... | def connect_table(self, table, chunk, markup):
""" Creates a link from the table to paragraph and vice versa.
Finds the first heading above the table in the markup.
This is the title of the paragraph the table belongs to.
"""
k = markup.find(chunk)
i =... | [
"Creates",
"a",
"link",
"from",
"the",
"table",
"to",
"paragraph",
"and",
"vice",
"versa",
".",
"Finds",
"the",
"first",
"heading",
"above",
"the",
"table",
"in",
"the",
"markup",
".",
"This",
"is",
"the",
"title",
"of",
"the",
"paragraph",
"the",
"table... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1077-L1093 | [
"def",
"connect_table",
"(",
"self",
",",
"table",
",",
"chunk",
",",
"markup",
")",
":",
"k",
"=",
"markup",
".",
"find",
"(",
"chunk",
")",
"i",
"=",
"markup",
".",
"rfind",
"(",
"\"\\n=\"",
",",
"0",
",",
"k",
")",
"j",
"=",
"markup",
".",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_tables | Returns a list of tables in the markup.
A Wikipedia table looks like:
{| border="1"
|-
|Cell 1 (no modifier - not aligned)
|-
|align="right" |Cell 2 (right aligned)
|-
|} | lib/web/wikipedia.py | def parse_tables(self, markup):
""" Returns a list of tables in the markup.
A Wikipedia table looks like:
{| border="1"
|-
|Cell 1 (no modifier - not aligned)
|-
|align="right" |Cell 2 (right aligned)
|-
|}
"""
tables = ... | def parse_tables(self, markup):
""" Returns a list of tables in the markup.
A Wikipedia table looks like:
{| border="1"
|-
|Cell 1 (no modifier - not aligned)
|-
|align="right" |Cell 2 (right aligned)
|-
|}
"""
tables = ... | [
"Returns",
"a",
"list",
"of",
"tables",
"in",
"the",
"markup",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1095-L1145 | [
"def",
"parse_tables",
"(",
"self",
",",
"markup",
")",
":",
"tables",
"=",
"[",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"table\"",
"]",
",",
"markup",
")",
"for",
"chunk",
"in",
"m",
":",
"table",
"=",
"WikipediaTable",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_references | Returns a list of references found in the markup.
References appear inline as <ref> footnotes,
http:// external links, or {{cite}} citations.
We replace it with (1)-style footnotes.
Additional references data is gathered in
parse_paragraph_references() when we parse par... | lib/web/wikipedia.py | def parse_references(self, markup):
""" Returns a list of references found in the markup.
References appear inline as <ref> footnotes,
http:// external links, or {{cite}} citations.
We replace it with (1)-style footnotes.
Additional references data is gathered in
... | def parse_references(self, markup):
""" Returns a list of references found in the markup.
References appear inline as <ref> footnotes,
http:// external links, or {{cite}} citations.
We replace it with (1)-style footnotes.
Additional references data is gathered in
... | [
"Returns",
"a",
"list",
"of",
"references",
"found",
"in",
"the",
"markup",
".",
"References",
"appear",
"inline",
"as",
"<ref",
">",
"footnotes",
"http",
":",
"//",
"external",
"links",
"or",
"{{",
"cite",
"}}",
"citations",
".",
"We",
"replace",
"it",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1147-L1244 | [
"def",
"parse_references",
"(",
"self",
",",
"markup",
")",
":",
"references",
"=",
"[",
"]",
"# A Wikipedia reference note looks like:",
"# <ref>In 1946, [[ENIAC]] consumed an estimated 174 kW. ",
"# By comparison, a typical personal computer may use around 400 W; ",
"# over four hund... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_categories | Returns a list of categories the page belongs to.
# A Wikipedia category link looks like:
# [[Category:Computing]]
# This indicates the page is included in the given category.
# If "Category" is preceded by ":" this indicates a link to a category. | lib/web/wikipedia.py | def parse_categories(self, markup):
""" Returns a list of categories the page belongs to.
# A Wikipedia category link looks like:
# [[Category:Computing]]
# This indicates the page is included in the given category.
# If "Category" is preceded by ":" this indicates a li... | def parse_categories(self, markup):
""" Returns a list of categories the page belongs to.
# A Wikipedia category link looks like:
# [[Category:Computing]]
# This indicates the page is included in the given category.
# If "Category" is preceded by ":" this indicates a li... | [
"Returns",
"a",
"list",
"of",
"categories",
"the",
"page",
"belongs",
"to",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1246-L1270 | [
"def",
"parse_categories",
"(",
"self",
",",
"markup",
")",
":",
"categories",
"=",
"[",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"category\"",
"]",
",",
"markup",
")",
"for",
"category",
"in",
"m",
":",
"category",
"=",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_translations | Returns a dictionary of translations for the page title.
A Wikipedia language link looks like: [[af:Rekenaar]].
The parser will also fetch links like "user:" and "media:"
but these are stripped against the dictionary of
Wikipedia languages.
You can get a transla... | lib/web/wikipedia.py | def parse_translations(self, markup):
""" Returns a dictionary of translations for the page title.
A Wikipedia language link looks like: [[af:Rekenaar]].
The parser will also fetch links like "user:" and "media:"
but these are stripped against the dictionary of
... | def parse_translations(self, markup):
""" Returns a dictionary of translations for the page title.
A Wikipedia language link looks like: [[af:Rekenaar]].
The parser will also fetch links like "user:" and "media:"
but these are stripped against the dictionary of
... | [
"Returns",
"a",
"dictionary",
"of",
"translations",
"for",
"the",
"page",
"title",
".",
"A",
"Wikipedia",
"language",
"link",
"looks",
"like",
":",
"[[",
"af",
":",
"Rekenaar",
"]]",
".",
"The",
"parser",
"will",
"also",
"fetch",
"links",
"like",
"user",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1272-L1294 | [
"def",
"parse_translations",
"(",
"self",
",",
"markup",
")",
":",
"global",
"languages",
"translations",
"=",
"{",
"}",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"translation\"",
"]",
",",
"markup",
")",
"for",
"language",
",",
"t... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_disambiguation | Gets the Wikipedia disambiguation page for this article.
A Wikipedia disambiguation link refers to other pages
with the same title but of smaller significance,
e.g. {{dablink|For the IEEE magazine see [[Computer (magazine)]].}} | lib/web/wikipedia.py | def parse_disambiguation(self, markup):
""" Gets the Wikipedia disambiguation page for this article.
A Wikipedia disambiguation link refers to other pages
with the same title but of smaller significance,
e.g. {{dablink|For the IEEE magazine see [[Computer (magazine)]].}... | def parse_disambiguation(self, markup):
""" Gets the Wikipedia disambiguation page for this article.
A Wikipedia disambiguation link refers to other pages
with the same title but of smaller significance,
e.g. {{dablink|For the IEEE magazine see [[Computer (magazine)]].}... | [
"Gets",
"the",
"Wikipedia",
"disambiguation",
"page",
"for",
"this",
"article",
".",
"A",
"Wikipedia",
"disambiguation",
"link",
"refers",
"to",
"other",
"pages",
"with",
"the",
"same",
"title",
"but",
"of",
"smaller",
"significance",
"e",
".",
"g",
".",
"{{... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1296-L1310 | [
"def",
"parse_disambiguation",
"(",
"self",
",",
"markup",
")",
":",
"m",
"=",
"re",
".",
"search",
"(",
"self",
".",
"re",
"[",
"\"disambiguation\"",
"]",
",",
"markup",
")",
"if",
"m",
":",
"return",
"self",
".",
"parse_links",
"(",
"m",
".",
"grou... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | WikipediaPage.parse_important | Returns a list of words that appear in bold in the article.
Things like table titles are not added to the list,
these are probably bold because it makes the layout nice,
not necessarily because they are important. | lib/web/wikipedia.py | def parse_important(self, markup):
""" Returns a list of words that appear in bold in the article.
Things like table titles are not added to the list,
these are probably bold because it makes the layout nice,
not necessarily because they are important.
... | def parse_important(self, markup):
""" Returns a list of words that appear in bold in the article.
Things like table titles are not added to the list,
these are probably bold because it makes the layout nice,
not necessarily because they are important.
... | [
"Returns",
"a",
"list",
"of",
"words",
"that",
"appear",
"in",
"bold",
"in",
"the",
"article",
".",
"Things",
"like",
"table",
"titles",
"are",
"not",
"added",
"to",
"the",
"list",
"these",
"are",
"probably",
"bold",
"because",
"it",
"makes",
"the",
"lay... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L1312-L1330 | [
"def",
"parse_important",
"(",
"self",
",",
"markup",
")",
":",
"important",
"=",
"[",
"]",
"table_titles",
"=",
"[",
"table",
".",
"title",
"for",
"table",
"in",
"self",
".",
"tables",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Variable.sanitize | Given a Variable and a value, cleans it out | shoebot/data/variable.py | def sanitize(self, val):
"""Given a Variable and a value, cleans it out"""
if self.type == NUMBER:
try:
return clamp(self.min, self.max, float(val))
except ValueError:
return 0.0
elif self.type == TEXT:
try:
retu... | def sanitize(self, val):
"""Given a Variable and a value, cleans it out"""
if self.type == NUMBER:
try:
return clamp(self.min, self.max, float(val))
except ValueError:
return 0.0
elif self.type == TEXT:
try:
retu... | [
"Given",
"a",
"Variable",
"and",
"a",
"value",
"cleans",
"it",
"out"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/variable.py#L59-L75 | [
"def",
"sanitize",
"(",
"self",
",",
"val",
")",
":",
"if",
"self",
".",
"type",
"==",
"NUMBER",
":",
"try",
":",
"return",
"clamp",
"(",
"self",
".",
"min",
",",
"self",
".",
"max",
",",
"float",
"(",
"val",
")",
")",
"except",
"ValueError",
":"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Variable.compliesTo | Return whether I am compatible with the given var:
- Type should be the same
- My value should be inside the given vars' min/max range. | shoebot/data/variable.py | def compliesTo(self, v):
"""Return whether I am compatible with the given var:
- Type should be the same
- My value should be inside the given vars' min/max range.
"""
if self.type == v.type:
if self.type == NUMBER:
if self.value < self.min o... | def compliesTo(self, v):
"""Return whether I am compatible with the given var:
- Type should be the same
- My value should be inside the given vars' min/max range.
"""
if self.type == v.type:
if self.type == NUMBER:
if self.value < self.min o... | [
"Return",
"whether",
"I",
"am",
"compatible",
"with",
"the",
"given",
"var",
":",
"-",
"Type",
"should",
"be",
"the",
"same",
"-",
"My",
"value",
"should",
"be",
"inside",
"the",
"given",
"vars",
"min",
"/",
"max",
"range",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/variable.py#L77-L87 | [
"def",
"compliesTo",
"(",
"self",
",",
"v",
")",
":",
"if",
"self",
".",
"type",
"==",
"v",
".",
"type",
":",
"if",
"self",
".",
"type",
"==",
"NUMBER",
":",
"if",
"self",
".",
"value",
"<",
"self",
".",
"min",
"or",
"self",
".",
"value",
">",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | isList | Convenience method that works with all 2.x versions of Python
to determine whether or not something is listlike. | lib/web/BeautifulSoup.py | def isList(l):
"""Convenience method that works with all 2.x versions of Python
to determine whether or not something is listlike."""
return hasattr(l, '__iter__') \
or (type(l) in (types.ListType, types.TupleType)) | def isList(l):
"""Convenience method that works with all 2.x versions of Python
to determine whether or not something is listlike."""
return hasattr(l, '__iter__') \
or (type(l) in (types.ListType, types.TupleType)) | [
"Convenience",
"method",
"that",
"works",
"with",
"all",
"2",
".",
"x",
"versions",
"of",
"Python",
"to",
"determine",
"whether",
"or",
"not",
"something",
"is",
"listlike",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L946-L950 | [
"def",
"isList",
"(",
"l",
")",
":",
"return",
"hasattr",
"(",
"l",
",",
"'__iter__'",
")",
"or",
"(",
"type",
"(",
"l",
")",
"in",
"(",
"types",
".",
"ListType",
",",
"types",
".",
"TupleType",
")",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | isString | Convenience method that works with all 2.x versions of Python
to determine whether or not something is stringlike. | lib/web/BeautifulSoup.py | def isString(s):
"""Convenience method that works with all 2.x versions of Python
to determine whether or not something is stringlike."""
try:
return isinstance(s, unicode) or isinstance(s, basestring)
except NameError:
return isinstance(s, str) | def isString(s):
"""Convenience method that works with all 2.x versions of Python
to determine whether or not something is stringlike."""
try:
return isinstance(s, unicode) or isinstance(s, basestring)
except NameError:
return isinstance(s, str) | [
"Convenience",
"method",
"that",
"works",
"with",
"all",
"2",
".",
"x",
"versions",
"of",
"Python",
"to",
"determine",
"whether",
"or",
"not",
"something",
"is",
"stringlike",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L952-L958 | [
"def",
"isString",
"(",
"s",
")",
":",
"try",
":",
"return",
"isinstance",
"(",
"s",
",",
"unicode",
")",
"or",
"isinstance",
"(",
"s",
",",
"basestring",
")",
"except",
"NameError",
":",
"return",
"isinstance",
"(",
"s",
",",
"str",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | buildTagMap | Turns a list of maps, lists, or scalars into a single map.
Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and
NESTING_RESET_TAGS maps out of lists and partial maps. | lib/web/BeautifulSoup.py | def buildTagMap(default, *args):
"""Turns a list of maps, lists, or scalars into a single map.
Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and
NESTING_RESET_TAGS maps out of lists and partial maps."""
built = {}
for portion in args:
if hasattr(portion, 'items'):
#It's a m... | def buildTagMap(default, *args):
"""Turns a list of maps, lists, or scalars into a single map.
Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and
NESTING_RESET_TAGS maps out of lists and partial maps."""
built = {}
for portion in args:
if hasattr(portion, 'items'):
#It's a m... | [
"Turns",
"a",
"list",
"of",
"maps",
"lists",
"or",
"scalars",
"into",
"a",
"single",
"map",
".",
"Used",
"to",
"build",
"the",
"SELF_CLOSING_TAGS",
"NESTABLE_TAGS",
"and",
"NESTING_RESET_TAGS",
"maps",
"out",
"of",
"lists",
"and",
"partial",
"maps",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L960-L977 | [
"def",
"buildTagMap",
"(",
"default",
",",
"*",
"args",
")",
":",
"built",
"=",
"{",
"}",
"for",
"portion",
"in",
"args",
":",
"if",
"hasattr",
"(",
"portion",
",",
"'items'",
")",
":",
"#It's a map. Merge it.",
"for",
"k",
",",
"v",
"in",
"portion",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.setup | Sets up the initial relations between this element and
other elements. | lib/web/BeautifulSoup.py | def setup(self, parent=None, previous=None):
"""Sets up the initial relations between this element and
other elements."""
self.parent = parent
self.previous = previous
self.next = None
self.previousSibling = None
self.nextSibling = None
if self.parent and ... | def setup(self, parent=None, previous=None):
"""Sets up the initial relations between this element and
other elements."""
self.parent = parent
self.previous = previous
self.next = None
self.previousSibling = None
self.nextSibling = None
if self.parent and ... | [
"Sets",
"up",
"the",
"initial",
"relations",
"between",
"this",
"element",
"and",
"other",
"elements",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L113-L123 | [
"def",
"setup",
"(",
"self",
",",
"parent",
"=",
"None",
",",
"previous",
"=",
"None",
")",
":",
"self",
".",
"parent",
"=",
"parent",
"self",
".",
"previous",
"=",
"previous",
"self",
".",
"next",
"=",
"None",
"self",
".",
"previousSibling",
"=",
"N... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.extract | Destructively rips this element out of the tree. | lib/web/BeautifulSoup.py | def extract(self):
"""Destructively rips this element out of the tree."""
if self.parent:
try:
self.parent.contents.remove(self)
except ValueError:
pass
#Find the two elements that would be next to each other if
#this element (and ... | def extract(self):
"""Destructively rips this element out of the tree."""
if self.parent:
try:
self.parent.contents.remove(self)
except ValueError:
pass
#Find the two elements that would be next to each other if
#this element (and ... | [
"Destructively",
"rips",
"this",
"element",
"out",
"of",
"the",
"tree",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L139-L166 | [
"def",
"extract",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
":",
"try",
":",
"self",
".",
"parent",
".",
"contents",
".",
"remove",
"(",
"self",
")",
"except",
"ValueError",
":",
"pass",
"#Find the two elements that would be next to each other if",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement._lastRecursiveChild | Finds the last element beneath this object to be parsed. | lib/web/BeautifulSoup.py | def _lastRecursiveChild(self):
"Finds the last element beneath this object to be parsed."
lastChild = self
while hasattr(lastChild, 'contents') and lastChild.contents:
lastChild = lastChild.contents[-1]
return lastChild | def _lastRecursiveChild(self):
"Finds the last element beneath this object to be parsed."
lastChild = self
while hasattr(lastChild, 'contents') and lastChild.contents:
lastChild = lastChild.contents[-1]
return lastChild | [
"Finds",
"the",
"last",
"element",
"beneath",
"this",
"object",
"to",
"be",
"parsed",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L168-L173 | [
"def",
"_lastRecursiveChild",
"(",
"self",
")",
":",
"lastChild",
"=",
"self",
"while",
"hasattr",
"(",
"lastChild",
",",
"'contents'",
")",
"and",
"lastChild",
".",
"contents",
":",
"lastChild",
"=",
"lastChild",
".",
"contents",
"[",
"-",
"1",
"]",
"retu... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findNext | Returns the first item that matches the given criteria and
appears after this Tag in the document. | lib/web/BeautifulSoup.py | def findNext(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the first item that matches the given criteria and
appears after this Tag in the document."""
return self._findOne(self.findAllNext, name, attrs, text, **kwargs) | def findNext(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the first item that matches the given criteria and
appears after this Tag in the document."""
return self._findOne(self.findAllNext, name, attrs, text, **kwargs) | [
"Returns",
"the",
"first",
"item",
"that",
"matches",
"the",
"given",
"criteria",
"and",
"appears",
"after",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L239-L242 | [
"def",
"findNext",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findOne",
"(",
"self",
".",
"findAllNext",
",",
"name",
",",
"attrs",
","... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findAllNext | Returns all items that match the given criteria and appear
after this Tag in the document. | lib/web/BeautifulSoup.py | def findAllNext(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns all items that match the given criteria and appear
after this Tag in the document."""
return self._findAll(name, attrs, text, limit, self.nextGenerator,
**kwar... | def findAllNext(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns all items that match the given criteria and appear
after this Tag in the document."""
return self._findAll(name, attrs, text, limit, self.nextGenerator,
**kwar... | [
"Returns",
"all",
"items",
"that",
"match",
"the",
"given",
"criteria",
"and",
"appear",
"after",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L244-L249 | [
"def",
"findAllNext",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findAll",
"(",
"name",
",",
"attrs",
",",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findNextSibling | Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document. | lib/web/BeautifulSoup.py | def findNextSibling(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document."""
return self._findOne(self.findNextSiblings, name, attrs, text,
**kwargs) | def findNextSibling(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document."""
return self._findOne(self.findNextSiblings, name, attrs, text,
**kwargs) | [
"Returns",
"the",
"closest",
"sibling",
"to",
"this",
"Tag",
"that",
"matches",
"the",
"given",
"criteria",
"and",
"appears",
"after",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L251-L255 | [
"def",
"findNextSibling",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findOne",
"(",
"self",
".",
"findNextSiblings",
",",
"name",
",",
"a... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findNextSiblings | Returns the siblings of this Tag that match the given
criteria and appear after this Tag in the document. | lib/web/BeautifulSoup.py | def findNextSiblings(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns the siblings of this Tag that match the given
criteria and appear after this Tag in the document."""
return self._findAll(name, attrs, text, limit,
s... | def findNextSiblings(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns the siblings of this Tag that match the given
criteria and appear after this Tag in the document."""
return self._findAll(name, attrs, text, limit,
s... | [
"Returns",
"the",
"siblings",
"of",
"this",
"Tag",
"that",
"match",
"the",
"given",
"criteria",
"and",
"appear",
"after",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L257-L262 | [
"def",
"findNextSiblings",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findAll",
"(",
"name",
",",
"attrs",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findPrevious | Returns the first item that matches the given criteria and
appears before this Tag in the document. | lib/web/BeautifulSoup.py | def findPrevious(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the first item that matches the given criteria and
appears before this Tag in the document."""
return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs) | def findPrevious(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the first item that matches the given criteria and
appears before this Tag in the document."""
return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs) | [
"Returns",
"the",
"first",
"item",
"that",
"matches",
"the",
"given",
"criteria",
"and",
"appears",
"before",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L265-L268 | [
"def",
"findPrevious",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findOne",
"(",
"self",
".",
"findAllPrevious",
",",
"name",
",",
"attrs... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findAllPrevious | Returns all items that match the given criteria and appear
before this Tag in the document. | lib/web/BeautifulSoup.py | def findAllPrevious(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns all items that match the given criteria and appear
before this Tag in the document."""
return self._findAll(name, attrs, text, limit, self.previousGenerator,
... | def findAllPrevious(self, name=None, attrs={}, text=None, limit=None,
**kwargs):
"""Returns all items that match the given criteria and appear
before this Tag in the document."""
return self._findAll(name, attrs, text, limit, self.previousGenerator,
... | [
"Returns",
"all",
"items",
"that",
"match",
"the",
"given",
"criteria",
"and",
"appear",
"before",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L270-L275 | [
"def",
"findAllPrevious",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findAll",
"(",
"name",
",",
"attrs",
",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findPreviousSibling | Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document. | lib/web/BeautifulSoup.py | def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document."""
return self._findOne(self.findPreviousSiblings, name, attrs, text,
**kw... | def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs):
"""Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document."""
return self._findOne(self.findPreviousSiblings, name, attrs, text,
**kw... | [
"Returns",
"the",
"closest",
"sibling",
"to",
"this",
"Tag",
"that",
"matches",
"the",
"given",
"criteria",
"and",
"appears",
"before",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L278-L282 | [
"def",
"findPreviousSibling",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findOne",
"(",
"self",
".",
"findPreviousSiblings",
",",
"name",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findPreviousSiblings | Returns the siblings of this Tag that match the given
criteria and appear before this Tag in the document. | lib/web/BeautifulSoup.py | def findPreviousSiblings(self, name=None, attrs={}, text=None,
limit=None, **kwargs):
"""Returns the siblings of this Tag that match the given
criteria and appear before this Tag in the document."""
return self._findAll(name, attrs, text, limit,
... | def findPreviousSiblings(self, name=None, attrs={}, text=None,
limit=None, **kwargs):
"""Returns the siblings of this Tag that match the given
criteria and appear before this Tag in the document."""
return self._findAll(name, attrs, text, limit,
... | [
"Returns",
"the",
"siblings",
"of",
"this",
"Tag",
"that",
"match",
"the",
"given",
"criteria",
"and",
"appear",
"before",
"this",
"Tag",
"in",
"the",
"document",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L284-L289 | [
"def",
"findPreviousSiblings",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findAll",
"(",
"name",
",",
"attrs",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findParent | Returns the closest parent of this Tag that matches the given
criteria. | lib/web/BeautifulSoup.py | def findParent(self, name=None, attrs={}, **kwargs):
"""Returns the closest parent of this Tag that matches the given
criteria."""
# NOTE: We can't use _findOne because findParents takes a different
# set of arguments.
r = None
l = self.findParents(name, attrs, 1)
... | def findParent(self, name=None, attrs={}, **kwargs):
"""Returns the closest parent of this Tag that matches the given
criteria."""
# NOTE: We can't use _findOne because findParents takes a different
# set of arguments.
r = None
l = self.findParents(name, attrs, 1)
... | [
"Returns",
"the",
"closest",
"parent",
"of",
"this",
"Tag",
"that",
"matches",
"the",
"given",
"criteria",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L292-L301 | [
"def",
"findParent",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"*",
"*",
"kwargs",
")",
":",
"# NOTE: We can't use _findOne because findParents takes a different",
"# set of arguments.",
"r",
"=",
"None",
"l",
"=",
"self",
".",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.findParents | Returns the parents of this Tag that match the given
criteria. | lib/web/BeautifulSoup.py | def findParents(self, name=None, attrs={}, limit=None, **kwargs):
"""Returns the parents of this Tag that match the given
criteria."""
return self._findAll(name, attrs, None, limit, self.parentGenerator,
**kwargs) | def findParents(self, name=None, attrs={}, limit=None, **kwargs):
"""Returns the parents of this Tag that match the given
criteria."""
return self._findAll(name, attrs, None, limit, self.parentGenerator,
**kwargs) | [
"Returns",
"the",
"parents",
"of",
"this",
"Tag",
"that",
"match",
"the",
"given",
"criteria",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L303-L308 | [
"def",
"findParents",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_findAll",
"(",
"name",
",",
"attrs",
",",
"None",
",",
"limit",
",",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement._findAll | Iterates over a generator looking for things that match. | lib/web/BeautifulSoup.py | def _findAll(self, name, attrs, text, limit, generator, **kwargs):
"Iterates over a generator looking for things that match."
if isinstance(name, SoupStrainer):
strainer = name
else:
# Build a SoupStrainer
strainer = SoupStrainer(name, attrs, text, **kwargs)
... | def _findAll(self, name, attrs, text, limit, generator, **kwargs):
"Iterates over a generator looking for things that match."
if isinstance(name, SoupStrainer):
strainer = name
else:
# Build a SoupStrainer
strainer = SoupStrainer(name, attrs, text, **kwargs)
... | [
"Iterates",
"over",
"a",
"generator",
"looking",
"for",
"things",
"that",
"match",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L320-L341 | [
"def",
"_findAll",
"(",
"self",
",",
"name",
",",
"attrs",
",",
"text",
",",
"limit",
",",
"generator",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"SoupStrainer",
")",
":",
"strainer",
"=",
"name",
"else",
":",
"# Build ... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | PageElement.toEncoding | Encodes an object to a string in some encoding, or to Unicode.
. | lib/web/BeautifulSoup.py | def toEncoding(self, s, encoding=None):
"""Encodes an object to a string in some encoding, or to Unicode.
."""
if isinstance(s, unicode):
if encoding:
s = s.encode(encoding)
elif isinstance(s, str):
if encoding:
s = s.encode(encodin... | def toEncoding(self, s, encoding=None):
"""Encodes an object to a string in some encoding, or to Unicode.
."""
if isinstance(s, unicode):
if encoding:
s = s.encode(encoding)
elif isinstance(s, str):
if encoding:
s = s.encode(encodin... | [
"Encodes",
"an",
"object",
"to",
"a",
"string",
"in",
"some",
"encoding",
"or",
"to",
"Unicode",
".",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L380-L396 | [
"def",
"toEncoding",
"(",
"self",
",",
"s",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"if",
"encoding",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"encoding",
")",
"elif",
"isinstance",
"(",
"s",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag._invert | Cheap function to invert a hash. | lib/web/BeautifulSoup.py | def _invert(h):
"Cheap function to invert a hash."
i = {}
for k,v in h.items():
i[v] = k
return i | def _invert(h):
"Cheap function to invert a hash."
i = {}
for k,v in h.items():
i[v] = k
return i | [
"Cheap",
"function",
"to",
"invert",
"a",
"hash",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L457-L462 | [
"def",
"_invert",
"(",
"h",
")",
":",
"i",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"h",
".",
"items",
"(",
")",
":",
"i",
"[",
"v",
"]",
"=",
"k",
"return",
"i"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag._convertEntities | Used in a call to re.sub to replace HTML, XML, and numeric
entities with the appropriate Unicode characters. If HTML
entities are being converted, any unrecognized entities are
escaped. | lib/web/BeautifulSoup.py | def _convertEntities(self, match):
"""Used in a call to re.sub to replace HTML, XML, and numeric
entities with the appropriate Unicode characters. If HTML
entities are being converted, any unrecognized entities are
escaped."""
x = match.group(1)
if self.convertHTMLEntitie... | def _convertEntities(self, match):
"""Used in a call to re.sub to replace HTML, XML, and numeric
entities with the appropriate Unicode characters. If HTML
entities are being converted, any unrecognized entities are
escaped."""
x = match.group(1)
if self.convertHTMLEntitie... | [
"Used",
"in",
"a",
"call",
"to",
"re",
".",
"sub",
"to",
"replace",
"HTML",
"XML",
"and",
"numeric",
"entities",
"with",
"the",
"appropriate",
"Unicode",
"characters",
".",
"If",
"HTML",
"entities",
"are",
"being",
"converted",
"any",
"unrecognized",
"entiti... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L472-L495 | [
"def",
"_convertEntities",
"(",
"self",
",",
"match",
")",
":",
"x",
"=",
"match",
".",
"group",
"(",
"1",
")",
"if",
"self",
".",
"convertHTMLEntities",
"and",
"x",
"in",
"name2codepoint",
":",
"return",
"unichr",
"(",
"name2codepoint",
"[",
"x",
"]",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag.decompose | Recursively destroys the contents of this tree. | lib/web/BeautifulSoup.py | def decompose(self):
"""Recursively destroys the contents of this tree."""
contents = [i for i in self.contents]
for i in contents:
if isinstance(i, Tag):
i.decompose()
else:
i.extract()
self.extract() | def decompose(self):
"""Recursively destroys the contents of this tree."""
contents = [i for i in self.contents]
for i in contents:
if isinstance(i, Tag):
i.decompose()
else:
i.extract()
self.extract() | [
"Recursively",
"destroys",
"the",
"contents",
"of",
"this",
"tree",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L711-L719 | [
"def",
"decompose",
"(",
"self",
")",
":",
"contents",
"=",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"contents",
"]",
"for",
"i",
"in",
"contents",
":",
"if",
"isinstance",
"(",
"i",
",",
"Tag",
")",
":",
"i",
".",
"decompose",
"(",
")",
"else",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag.renderContents | Renders the contents of this tag as a string in the given
encoding. If encoding is None, returns a Unicode string.. | lib/web/BeautifulSoup.py | def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING,
prettyPrint=False, indentLevel=0):
"""Renders the contents of this tag as a string in the given
encoding. If encoding is None, returns a Unicode string.."""
s=[]
for c in self:
text = None
... | def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING,
prettyPrint=False, indentLevel=0):
"""Renders the contents of this tag as a string in the given
encoding. If encoding is None, returns a Unicode string.."""
s=[]
for c in self:
text = None
... | [
"Renders",
"the",
"contents",
"of",
"this",
"tag",
"as",
"a",
"string",
"in",
"the",
"given",
"encoding",
".",
"If",
"encoding",
"is",
"None",
"returns",
"a",
"Unicode",
"string",
".."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L724-L743 | [
"def",
"renderContents",
"(",
"self",
",",
"encoding",
"=",
"DEFAULT_OUTPUT_ENCODING",
",",
"prettyPrint",
"=",
"False",
",",
"indentLevel",
"=",
"0",
")",
":",
"s",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
":",
"text",
"=",
"None",
"if",
"isinstance",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag.find | Return only the first child of this Tag matching the given
criteria. | lib/web/BeautifulSoup.py | def find(self, name=None, attrs={}, recursive=True, text=None,
**kwargs):
"""Return only the first child of this Tag matching the given
criteria."""
r = None
l = self.findAll(name, attrs, recursive, text, 1, **kwargs)
if l:
r = l[0]
return r | def find(self, name=None, attrs={}, recursive=True, text=None,
**kwargs):
"""Return only the first child of this Tag matching the given
criteria."""
r = None
l = self.findAll(name, attrs, recursive, text, 1, **kwargs)
if l:
r = l[0]
return r | [
"Return",
"only",
"the",
"first",
"child",
"of",
"this",
"Tag",
"matching",
"the",
"given",
"criteria",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L747-L755 | [
"def",
"find",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"recursive",
"=",
"True",
",",
"text",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"None",
"l",
"=",
"self",
".",
"findAll",
"(",
"name",
",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag.findAll | Extracts a list of Tag objects that match the given
criteria. You can specify the name of the Tag and any
attributes you want the Tag to have.
The value of a key-value pair in the 'attrs' map can be a
string, a list of strings, a regular expression object, or a
callable that ta... | lib/web/BeautifulSoup.py | def findAll(self, name=None, attrs={}, recursive=True, text=None,
limit=None, **kwargs):
"""Extracts a list of Tag objects that match the given
criteria. You can specify the name of the Tag and any
attributes you want the Tag to have.
The value of a key-value pair in th... | def findAll(self, name=None, attrs={}, recursive=True, text=None,
limit=None, **kwargs):
"""Extracts a list of Tag objects that match the given
criteria. You can specify the name of the Tag and any
attributes you want the Tag to have.
The value of a key-value pair in th... | [
"Extracts",
"a",
"list",
"of",
"Tag",
"objects",
"that",
"match",
"the",
"given",
"criteria",
".",
"You",
"can",
"specify",
"the",
"name",
"of",
"the",
"Tag",
"and",
"any",
"attributes",
"you",
"want",
"the",
"Tag",
"to",
"have",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L758-L772 | [
"def",
"findAll",
"(",
"self",
",",
"name",
"=",
"None",
",",
"attrs",
"=",
"{",
"}",
",",
"recursive",
"=",
"True",
",",
"text",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"generator",
"=",
"self",
".",
"recursive... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Tag._getAttrMap | Initializes a map representation of this tag's attributes,
if not already initialized. | lib/web/BeautifulSoup.py | def _getAttrMap(self):
"""Initializes a map representation of this tag's attributes,
if not already initialized."""
if not getattr(self, 'attrMap'):
self.attrMap = {}
for (key, value) in self.attrs:
self.attrMap[key] = value
return self.attrMap | def _getAttrMap(self):
"""Initializes a map representation of this tag's attributes,
if not already initialized."""
if not getattr(self, 'attrMap'):
self.attrMap = {}
for (key, value) in self.attrs:
self.attrMap[key] = value
return self.attrMap | [
"Initializes",
"a",
"map",
"representation",
"of",
"this",
"tag",
"s",
"attributes",
"if",
"not",
"already",
"initialized",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L787-L794 | [
"def",
"_getAttrMap",
"(",
"self",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"'attrMap'",
")",
":",
"self",
".",
"attrMap",
"=",
"{",
"}",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
".",
"attrs",
":",
"self",
".",
"attrMap",
"[... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.convert_charref | This method fixes a bug in Python's SGMLParser. | lib/web/BeautifulSoup.py | def convert_charref(self, name):
"""This method fixes a bug in Python's SGMLParser."""
try:
n = int(name)
except ValueError:
return
if not 0 <= n <= 127 : # ASCII ends at 127, not 255
return
return self.convert_codepoint(n) | def convert_charref(self, name):
"""This method fixes a bug in Python's SGMLParser."""
try:
n = int(name)
except ValueError:
return
if not 0 <= n <= 127 : # ASCII ends at 127, not 255
return
return self.convert_codepoint(n) | [
"This",
"method",
"fixes",
"a",
"bug",
"in",
"Python",
"s",
"SGMLParser",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1094-L1102 | [
"def",
"convert_charref",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"n",
"=",
"int",
"(",
"name",
")",
"except",
"ValueError",
":",
"return",
"if",
"not",
"0",
"<=",
"n",
"<=",
"127",
":",
"# ASCII ends at 127, not 255",
"return",
"return",
"self",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.isSelfClosingTag | Returns true iff the given string is the name of a
self-closing tag according to this parser. | lib/web/BeautifulSoup.py | def isSelfClosingTag(self, name):
"""Returns true iff the given string is the name of a
self-closing tag according to this parser."""
return self.SELF_CLOSING_TAGS.has_key(name) \
or self.instanceSelfClosingTags.has_key(name) | def isSelfClosingTag(self, name):
"""Returns true iff the given string is the name of a
self-closing tag according to this parser."""
return self.SELF_CLOSING_TAGS.has_key(name) \
or self.instanceSelfClosingTags.has_key(name) | [
"Returns",
"true",
"iff",
"the",
"given",
"string",
"is",
"the",
"name",
"of",
"a",
"self",
"-",
"closing",
"tag",
"according",
"to",
"this",
"parser",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1150-L1154 | [
"def",
"isSelfClosingTag",
"(",
"self",
",",
"name",
")",
":",
"return",
"self",
".",
"SELF_CLOSING_TAGS",
".",
"has_key",
"(",
"name",
")",
"or",
"self",
".",
"instanceSelfClosingTags",
".",
"has_key",
"(",
"name",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup._popToTag | Pops the tag stack up to and including the most recent
instance of the given tag. If inclusivePop is false, pops the tag
stack up to but *not* including the most recent instqance of
the given tag. | lib/web/BeautifulSoup.py | def _popToTag(self, name, inclusivePop=True):
"""Pops the tag stack up to and including the most recent
instance of the given tag. If inclusivePop is false, pops the tag
stack up to but *not* including the most recent instqance of
the given tag."""
#print "Popping to %s" % name
... | def _popToTag(self, name, inclusivePop=True):
"""Pops the tag stack up to and including the most recent
instance of the given tag. If inclusivePop is false, pops the tag
stack up to but *not* including the most recent instqance of
the given tag."""
#print "Popping to %s" % name
... | [
"Pops",
"the",
"tag",
"stack",
"up",
"to",
"and",
"including",
"the",
"most",
"recent",
"instance",
"of",
"the",
"given",
"tag",
".",
"If",
"inclusivePop",
"is",
"false",
"pops",
"the",
"tag",
"stack",
"up",
"to",
"but",
"*",
"not",
"*",
"including",
"... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1210-L1230 | [
"def",
"_popToTag",
"(",
"self",
",",
"name",
",",
"inclusivePop",
"=",
"True",
")",
":",
"#print \"Popping to %s\" % name",
"if",
"name",
"==",
"self",
".",
"ROOT_TAG_NAME",
":",
"return",
"numPops",
"=",
"0",
"mostRecentTag",
"=",
"None",
"for",
"i",
"in",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup._toStringSubclass | Adds a certain piece of text to the tree as a NavigableString
subclass. | lib/web/BeautifulSoup.py | def _toStringSubclass(self, text, subclass):
"""Adds a certain piece of text to the tree as a NavigableString
subclass."""
self.endData()
self.handle_data(text)
self.endData(subclass) | def _toStringSubclass(self, text, subclass):
"""Adds a certain piece of text to the tree as a NavigableString
subclass."""
self.endData()
self.handle_data(text)
self.endData(subclass) | [
"Adds",
"a",
"certain",
"piece",
"of",
"text",
"to",
"the",
"tree",
"as",
"a",
"NavigableString",
"subclass",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1324-L1329 | [
"def",
"_toStringSubclass",
"(",
"self",
",",
"text",
",",
"subclass",
")",
":",
"self",
".",
"endData",
"(",
")",
"self",
".",
"handle_data",
"(",
"text",
")",
"self",
".",
"endData",
"(",
"subclass",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.handle_pi | Handle a processing instruction as a ProcessingInstruction
object, possibly one with a %SOUP-ENCODING% slot into which an
encoding will be plugged later. | lib/web/BeautifulSoup.py | def handle_pi(self, text):
"""Handle a processing instruction as a ProcessingInstruction
object, possibly one with a %SOUP-ENCODING% slot into which an
encoding will be plugged later."""
if text[:3] == "xml":
text = u"xml version='1.0' encoding='%SOUP-ENCODING%'"
self... | def handle_pi(self, text):
"""Handle a processing instruction as a ProcessingInstruction
object, possibly one with a %SOUP-ENCODING% slot into which an
encoding will be plugged later."""
if text[:3] == "xml":
text = u"xml version='1.0' encoding='%SOUP-ENCODING%'"
self... | [
"Handle",
"a",
"processing",
"instruction",
"as",
"a",
"ProcessingInstruction",
"object",
"possibly",
"one",
"with",
"a",
"%SOUP",
"-",
"ENCODING%",
"slot",
"into",
"which",
"an",
"encoding",
"will",
"be",
"plugged",
"later",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1331-L1337 | [
"def",
"handle_pi",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
"[",
":",
"3",
"]",
"==",
"\"xml\"",
":",
"text",
"=",
"u\"xml version='1.0' encoding='%SOUP-ENCODING%'\"",
"self",
".",
"_toStringSubclass",
"(",
"text",
",",
"ProcessingInstruction",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.handle_charref | Handle character references as data. | lib/web/BeautifulSoup.py | def handle_charref(self, ref):
"Handle character references as data."
if self.convertEntities:
data = unichr(int(ref))
else:
data = '&#%s;' % ref
self.handle_data(data) | def handle_charref(self, ref):
"Handle character references as data."
if self.convertEntities:
data = unichr(int(ref))
else:
data = '&#%s;' % ref
self.handle_data(data) | [
"Handle",
"character",
"references",
"as",
"data",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1343-L1349 | [
"def",
"handle_charref",
"(",
"self",
",",
"ref",
")",
":",
"if",
"self",
".",
"convertEntities",
":",
"data",
"=",
"unichr",
"(",
"int",
"(",
"ref",
")",
")",
"else",
":",
"data",
"=",
"'&#%s;'",
"%",
"ref",
"self",
".",
"handle_data",
"(",
"data",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.handle_entityref | Handle entity references as data, possibly converting known
HTML and/or XML entity references to the corresponding Unicode
characters. | lib/web/BeautifulSoup.py | def handle_entityref(self, ref):
"""Handle entity references as data, possibly converting known
HTML and/or XML entity references to the corresponding Unicode
characters."""
data = None
if self.convertHTMLEntities:
try:
data = unichr(name2codepoint[ref... | def handle_entityref(self, ref):
"""Handle entity references as data, possibly converting known
HTML and/or XML entity references to the corresponding Unicode
characters."""
data = None
if self.convertHTMLEntities:
try:
data = unichr(name2codepoint[ref... | [
"Handle",
"entity",
"references",
"as",
"data",
"possibly",
"converting",
"known",
"HTML",
"and",
"/",
"or",
"XML",
"entity",
"references",
"to",
"the",
"corresponding",
"Unicode",
"characters",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1351-L1392 | [
"def",
"handle_entityref",
"(",
"self",
",",
"ref",
")",
":",
"data",
"=",
"None",
"if",
"self",
".",
"convertHTMLEntities",
":",
"try",
":",
"data",
"=",
"unichr",
"(",
"name2codepoint",
"[",
"ref",
"]",
")",
"except",
"KeyError",
":",
"pass",
"if",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulStoneSoup.parse_declaration | Treat a bogus SGML declaration as raw data. Treat a CDATA
declaration as a CData object. | lib/web/BeautifulSoup.py | def parse_declaration(self, i):
"""Treat a bogus SGML declaration as raw data. Treat a CDATA
declaration as a CData object."""
j = None
if self.rawdata[i:i+9] == '<![CDATA[':
k = self.rawdata.find(']]>', i)
if k == -1:
k = len(self.rawdata)
... | def parse_declaration(self, i):
"""Treat a bogus SGML declaration as raw data. Treat a CDATA
declaration as a CData object."""
j = None
if self.rawdata[i:i+9] == '<![CDATA[':
k = self.rawdata.find(']]>', i)
if k == -1:
k = len(self.rawdata)
... | [
"Treat",
"a",
"bogus",
"SGML",
"declaration",
"as",
"raw",
"data",
".",
"Treat",
"a",
"CDATA",
"declaration",
"as",
"a",
"CData",
"object",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1398-L1416 | [
"def",
"parse_declaration",
"(",
"self",
",",
"i",
")",
":",
"j",
"=",
"None",
"if",
"self",
".",
"rawdata",
"[",
"i",
":",
"i",
"+",
"9",
"]",
"==",
"'<![CDATA['",
":",
"k",
"=",
"self",
".",
"rawdata",
".",
"find",
"(",
"']]>'",
",",
"i",
")"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | BeautifulSoup.start_meta | Beautiful Soup can detect a charset included in a META tag,
try to convert the document to that charset, and re-parse the
document from the beginning. | lib/web/BeautifulSoup.py | def start_meta(self, attrs):
"""Beautiful Soup can detect a charset included in a META tag,
try to convert the document to that charset, and re-parse the
document from the beginning."""
httpEquiv = None
contentType = None
contentTypeIndex = None
tagNeedsEncodingSu... | def start_meta(self, attrs):
"""Beautiful Soup can detect a charset included in a META tag,
try to convert the document to that charset, and re-parse the
document from the beginning."""
httpEquiv = None
contentType = None
contentTypeIndex = None
tagNeedsEncodingSu... | [
"Beautiful",
"Soup",
"can",
"detect",
"a",
"charset",
"included",
"in",
"a",
"META",
"tag",
"try",
"to",
"convert",
"the",
"document",
"to",
"that",
"charset",
"and",
"re",
"-",
"parse",
"the",
"document",
"from",
"the",
"beginning",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1524-L1569 | [
"def",
"start_meta",
"(",
"self",
",",
"attrs",
")",
":",
"httpEquiv",
"=",
"None",
"contentType",
"=",
"None",
"contentTypeIndex",
"=",
"None",
"tagNeedsEncodingSubstitution",
"=",
"False",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"attrs",
")... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | UnicodeDammit._subMSChar | Changes a MS smart quote character to an XML or HTML
entity. | lib/web/BeautifulSoup.py | def _subMSChar(self, orig):
"""Changes a MS smart quote character to an XML or HTML
entity."""
sub = self.MS_CHARS.get(orig)
if type(sub) == types.TupleType:
if self.smartQuotesTo == 'xml':
sub = '&#x%s;' % sub[1]
else:
sub = '&%s;'... | def _subMSChar(self, orig):
"""Changes a MS smart quote character to an XML or HTML
entity."""
sub = self.MS_CHARS.get(orig)
if type(sub) == types.TupleType:
if self.smartQuotesTo == 'xml':
sub = '&#x%s;' % sub[1]
else:
sub = '&%s;'... | [
"Changes",
"a",
"MS",
"smart",
"quote",
"character",
"to",
"an",
"XML",
"or",
"HTML",
"entity",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1751-L1760 | [
"def",
"_subMSChar",
"(",
"self",
",",
"orig",
")",
":",
"sub",
"=",
"self",
".",
"MS_CHARS",
".",
"get",
"(",
"orig",
")",
"if",
"type",
"(",
"sub",
")",
"==",
"types",
".",
"TupleType",
":",
"if",
"self",
".",
"smartQuotesTo",
"==",
"'xml'",
":",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | UnicodeDammit._toUnicode | Given a string and its encoding, decodes the string into Unicode.
%encoding is a string recognized by encodings.aliases | lib/web/BeautifulSoup.py | def _toUnicode(self, data, encoding):
'''Given a string and its encoding, decodes the string into Unicode.
%encoding is a string recognized by encodings.aliases'''
# strip Byte Order Mark (if present)
if (len(data) >= 4) and (data[:2] == '\xfe\xff') \
and (data[2:4] != '\... | def _toUnicode(self, data, encoding):
'''Given a string and its encoding, decodes the string into Unicode.
%encoding is a string recognized by encodings.aliases'''
# strip Byte Order Mark (if present)
if (len(data) >= 4) and (data[:2] == '\xfe\xff') \
and (data[2:4] != '\... | [
"Given",
"a",
"string",
"and",
"its",
"encoding",
"decodes",
"the",
"string",
"into",
"Unicode",
".",
"%encoding",
"is",
"a",
"string",
"recognized",
"by",
"encodings",
".",
"aliases"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1790-L1813 | [
"def",
"_toUnicode",
"(",
"self",
",",
"data",
",",
"encoding",
")",
":",
"# strip Byte Order Mark (if present)",
"if",
"(",
"len",
"(",
"data",
")",
">=",
"4",
")",
"and",
"(",
"data",
"[",
":",
"2",
"]",
"==",
"'\\xfe\\xff'",
")",
"and",
"(",
"data",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | UnicodeDammit._detectEncoding | Given a document, tries to detect its XML encoding. | lib/web/BeautifulSoup.py | def _detectEncoding(self, xml_data, isHTML=False):
"""Given a document, tries to detect its XML encoding."""
xml_encoding = sniffed_xml_encoding = None
try:
if xml_data[:4] == '\x4c\x6f\xa7\x94':
# EBCDIC
xml_data = self._ebcdic_to_ascii(xml_data)
... | def _detectEncoding(self, xml_data, isHTML=False):
"""Given a document, tries to detect its XML encoding."""
xml_encoding = sniffed_xml_encoding = None
try:
if xml_data[:4] == '\x4c\x6f\xa7\x94':
# EBCDIC
xml_data = self._ebcdic_to_ascii(xml_data)
... | [
"Given",
"a",
"document",
"tries",
"to",
"detect",
"its",
"XML",
"encoding",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/BeautifulSoup.py#L1815-L1880 | [
"def",
"_detectEncoding",
"(",
"self",
",",
"xml_data",
",",
"isHTML",
"=",
"False",
")",
":",
"xml_encoding",
"=",
"sniffed_xml_encoding",
"=",
"None",
"try",
":",
"if",
"xml_data",
"[",
":",
"4",
"]",
"==",
"'\\x4c\\x6f\\xa7\\x94'",
":",
"# EBCDIC",
"xml_d... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | shoebot_example | Decorator to run some code in a bot instance. | shoebot/diagnose.py | def shoebot_example(**shoebot_kwargs):
"""
Decorator to run some code in a bot instance.
"""
def decorator(f):
def run():
from shoebot import ShoebotInstallError # https://github.com/shoebot/shoebot/issues/206
print(" Shoebot - %s:" % f.__name__.replace("_", " "))
... | def shoebot_example(**shoebot_kwargs):
"""
Decorator to run some code in a bot instance.
"""
def decorator(f):
def run():
from shoebot import ShoebotInstallError # https://github.com/shoebot/shoebot/issues/206
print(" Shoebot - %s:" % f.__name__.replace("_", " "))
... | [
"Decorator",
"to",
"run",
"some",
"code",
"in",
"a",
"bot",
"instance",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/diagnose.py#L122-L150 | [
"def",
"shoebot_example",
"(",
"*",
"*",
"shoebot_kwargs",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"def",
"run",
"(",
")",
":",
"from",
"shoebot",
"import",
"ShoebotInstallError",
"# https://github.com/shoebot/shoebot/issues/206",
"print",
"(",
"\" Sh... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | Image._get_center | Returns the center point of the path, disregarding transforms. | shoebot/data/img.py | def _get_center(self):
'''Returns the center point of the path, disregarding transforms.
'''
x = (self.x + self.width / 2)
y = (self.y + self.height / 2)
return (x, y) | def _get_center(self):
'''Returns the center point of the path, disregarding transforms.
'''
x = (self.x + self.width / 2)
y = (self.y + self.height / 2)
return (x, y) | [
"Returns",
"the",
"center",
"point",
"of",
"the",
"path",
"disregarding",
"transforms",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/data/img.py#L135-L140 | [
"def",
"_get_center",
"(",
"self",
")",
":",
"x",
"=",
"(",
"self",
".",
"x",
"+",
"self",
".",
"width",
"/",
"2",
")",
"y",
"=",
"(",
"self",
".",
"y",
"+",
"self",
".",
"height",
"/",
"2",
")",
"return",
"(",
"x",
",",
"y",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWidget.scale_context_and_center | Scale context based on difference between bot size and widget | shoebot/gui/gtk_drawingarea.py | def scale_context_and_center(self, cr):
"""
Scale context based on difference between bot size and widget
"""
bot_width, bot_height = self.bot_size
if self.width != bot_width or self.height != bot_height:
# Scale up by largest dimension
if self.width < sel... | def scale_context_and_center(self, cr):
"""
Scale context based on difference between bot size and widget
"""
bot_width, bot_height = self.bot_size
if self.width != bot_width or self.height != bot_height:
# Scale up by largest dimension
if self.width < sel... | [
"Scale",
"context",
"based",
"on",
"difference",
"between",
"bot",
"size",
"and",
"widget"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_drawingarea.py#L78-L98 | [
"def",
"scale_context_and_center",
"(",
"self",
",",
"cr",
")",
":",
"bot_width",
",",
"bot_height",
"=",
"self",
".",
"bot_size",
"if",
"self",
".",
"width",
"!=",
"bot_width",
"or",
"self",
".",
"height",
"!=",
"bot_height",
":",
"# Scale up by largest dimen... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWidget.draw | Draw just the exposed part of the backing store, scaled to fit | shoebot/gui/gtk_drawingarea.py | def draw(self, widget, cr):
'''
Draw just the exposed part of the backing store, scaled to fit
'''
if self.bot_size is None:
# No bot to draw yet.
self.draw_default_image(cr)
return
cr = driver.ensure_pycairo_context(cr)
surfa... | def draw(self, widget, cr):
'''
Draw just the exposed part of the backing store, scaled to fit
'''
if self.bot_size is None:
# No bot to draw yet.
self.draw_default_image(cr)
return
cr = driver.ensure_pycairo_context(cr)
surfa... | [
"Draw",
"just",
"the",
"exposed",
"part",
"of",
"the",
"backing",
"store",
"scaled",
"to",
"fit"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_drawingarea.py#L100-L113 | [
"def",
"draw",
"(",
"self",
",",
"widget",
",",
"cr",
")",
":",
"if",
"self",
".",
"bot_size",
"is",
"None",
":",
"# No bot to draw yet.",
"self",
".",
"draw_default_image",
"(",
"cr",
")",
"return",
"cr",
"=",
"driver",
".",
"ensure_pycairo_context",
"(",... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWidget.create_rcontext | Creates a recording surface for the bot to draw on
:param size: The width and height of bot | shoebot/gui/gtk_drawingarea.py | def create_rcontext(self, size, frame):
'''
Creates a recording surface for the bot to draw on
:param size: The width and height of bot
'''
self.frame = frame
width, height = size
meta_surface = cairo.RecordingSurface(cairo.CONTENT_COLOR_ALPHA, (0, 0, width, heig... | def create_rcontext(self, size, frame):
'''
Creates a recording surface for the bot to draw on
:param size: The width and height of bot
'''
self.frame = frame
width, height = size
meta_surface = cairo.RecordingSurface(cairo.CONTENT_COLOR_ALPHA, (0, 0, width, heig... | [
"Creates",
"a",
"recording",
"surface",
"for",
"the",
"bot",
"to",
"draw",
"on"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_drawingarea.py#L115-L126 | [
"def",
"create_rcontext",
"(",
"self",
",",
"size",
",",
"frame",
")",
":",
"self",
".",
"frame",
"=",
"frame",
"width",
",",
"height",
"=",
"size",
"meta_surface",
"=",
"cairo",
".",
"RecordingSurface",
"(",
"cairo",
".",
"CONTENT_COLOR_ALPHA",
",",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotWidget.do_drawing | Update the backing store from a cairo context and
schedule a redraw (expose event)
:param size: width, height in pixels of bot
:param frame: frame # thar was drawn
:param cairo_ctx: cairo context the bot was drawn on | shoebot/gui/gtk_drawingarea.py | def do_drawing(self, size, frame, cairo_ctx):
'''
Update the backing store from a cairo context and
schedule a redraw (expose event)
:param size: width, height in pixels of bot
:param frame: frame # thar was drawn
:param cairo_ctx: cairo context the bot was drawn on
... | def do_drawing(self, size, frame, cairo_ctx):
'''
Update the backing store from a cairo context and
schedule a redraw (expose event)
:param size: width, height in pixels of bot
:param frame: frame # thar was drawn
:param cairo_ctx: cairo context the bot was drawn on
... | [
"Update",
"the",
"backing",
"store",
"from",
"a",
"cairo",
"context",
"and",
"schedule",
"a",
"redraw",
"(",
"expose",
"event",
")"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_drawingarea.py#L128-L157 | [
"def",
"do_drawing",
"(",
"self",
",",
"size",
",",
"frame",
",",
"cairo_ctx",
")",
":",
"if",
"self",
".",
"get_window",
"(",
")",
"and",
"not",
"self",
".",
"bot_size",
":",
"# Get initial size for window",
"self",
".",
"set_size_request",
"(",
"*",
"siz... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | JSONEncoder.encode | Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}' | lib/web/simplejson/encoder.py | def encode(self, o):
"""
Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}'
"""
# This is for extremely simple cases and benchmarks.
if isinstance(o, basestring):
... | def encode(self, o):
"""
Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}'
"""
# This is for extremely simple cases and benchmarks.
if isinstance(o, basestring):
... | [
"Return",
"a",
"JSON",
"string",
"representation",
"of",
"a",
"Python",
"data",
"structure",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/simplejson/encoder.py#L345-L367 | [
"def",
"encode",
"(",
"self",
",",
"o",
")",
":",
"# This is for extremely simple cases and benchmarks.",
"if",
"isinstance",
"(",
"o",
",",
"basestring",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"str",
")",
":",
"_encoding",
"=",
"self",
".",
"encoding"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | JSONEncoder.iterencode | Encode the given object and yield each string
representation as available.
For example::
for chunk in JSONEncoder().iterencode(bigobject):
mysocket.write(chunk) | lib/web/simplejson/encoder.py | def iterencode(self, o):
"""
Encode the given object and yield each string
representation as available.
For example::
for chunk in JSONEncoder().iterencode(bigobject):
mysocket.write(chunk)
"""
if self.check_circular:
... | def iterencode(self, o):
"""
Encode the given object and yield each string
representation as available.
For example::
for chunk in JSONEncoder().iterencode(bigobject):
mysocket.write(chunk)
"""
if self.check_circular:
... | [
"Encode",
"the",
"given",
"object",
"and",
"yield",
"each",
"string",
"representation",
"as",
"available",
".",
"For",
"example",
"::",
"for",
"chunk",
"in",
"JSONEncoder",
"()",
".",
"iterencode",
"(",
"bigobject",
")",
":",
"mysocket",
".",
"write",
"(",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/simplejson/encoder.py#L369-L383 | [
"def",
"iterencode",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"check_circular",
":",
"markers",
"=",
"{",
"}",
"else",
":",
"markers",
"=",
"None",
"return",
"self",
".",
"_iterencode",
"(",
"o",
",",
"markers",
")"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | GtkInputDeviceMixin.get_key_map | Return a dict in the form of
SHOEBOT_KEY_NAME, GTK_VALUE
Shoebot key names look like KEY_LEFT, whereas Gdk uses KEY_Left
- Shoebot key names are derived from Nodebox 1, which was a mac
app. | shoebot/gui/gtk_input_device.py | def get_key_map(self):
'''
Return a dict in the form of
SHOEBOT_KEY_NAME, GTK_VALUE
Shoebot key names look like KEY_LEFT, whereas Gdk uses KEY_Left
- Shoebot key names are derived from Nodebox 1, which was a mac
app.
'''
kdict = {}
for gdk_name... | def get_key_map(self):
'''
Return a dict in the form of
SHOEBOT_KEY_NAME, GTK_VALUE
Shoebot key names look like KEY_LEFT, whereas Gdk uses KEY_Left
- Shoebot key names are derived from Nodebox 1, which was a mac
app.
'''
kdict = {}
for gdk_name... | [
"Return",
"a",
"dict",
"in",
"the",
"form",
"of"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/gtk_input_device.py#L60-L74 | [
"def",
"get_key_map",
"(",
"self",
")",
":",
"kdict",
"=",
"{",
"}",
"for",
"gdk_name",
"in",
"dir",
"(",
"Gdk",
")",
":",
"nb_name",
"=",
"gdk_name",
".",
"upper",
"(",
")",
"kdict",
"[",
"nb_name",
"]",
"=",
"getattr",
"(",
"Gdk",
",",
"gdk_name"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | LSystem._grow | Recurse through the system.
When a segment is drawn, the LSsytem.segment() method will be called.
You can customize this method to create your own visualizations.
It takes an optional time parameter.
If you divide this parameter by LSsytem.duration() you get
a... | lib/lsystem/__init__.py | def _grow(self, generation, rule, angle, length, time=maxint, draw=True):
""" Recurse through the system.
When a segment is drawn, the LSsytem.segment() method will be called.
You can customize this method to create your own visualizations.
It takes an optional time parameter. ... | def _grow(self, generation, rule, angle, length, time=maxint, draw=True):
""" Recurse through the system.
When a segment is drawn, the LSsytem.segment() method will be called.
You can customize this method to create your own visualizations.
It takes an optional time parameter. ... | [
"Recurse",
"through",
"the",
"system",
".",
"When",
"a",
"segment",
"is",
"drawn",
"the",
"LSsytem",
".",
"segment",
"()",
"method",
"will",
"be",
"called",
".",
"You",
"can",
"customize",
"this",
"method",
"to",
"create",
"your",
"own",
"visualizations",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/lsystem/__init__.py#L64-L146 | [
"def",
"_grow",
"(",
"self",
",",
"generation",
",",
"rule",
",",
"angle",
",",
"length",
",",
"time",
"=",
"maxint",
",",
"draw",
"=",
"True",
")",
":",
"if",
"generation",
"==",
"0",
":",
"# We are at the bottom of the system so now we now the total time neede... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | CairoImageSink._output_file | If filename was used output a filename, along with multifile
numbered filenames will be used.
If buff was specified it is returned.
:return: Output buff or filename. | shoebot/core/cairo_sink.py | def _output_file(self, frame):
"""
If filename was used output a filename, along with multifile
numbered filenames will be used.
If buff was specified it is returned.
:return: Output buff or filename.
"""
if self.buff:
return self.buff
elif s... | def _output_file(self, frame):
"""
If filename was used output a filename, along with multifile
numbered filenames will be used.
If buff was specified it is returned.
:return: Output buff or filename.
"""
if self.buff:
return self.buff
elif s... | [
"If",
"filename",
"was",
"used",
"output",
"a",
"filename",
"along",
"with",
"multifile",
"numbered",
"filenames",
"will",
"be",
"used",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/cairo_sink.py#L64-L78 | [
"def",
"_output_file",
"(",
"self",
",",
"frame",
")",
":",
"if",
"self",
".",
"buff",
":",
"return",
"self",
".",
"buff",
"elif",
"self",
".",
"multifile",
":",
"return",
"self",
".",
"file_root",
"+",
"\"_%03d\"",
"%",
"frame",
"+",
"self",
".",
"f... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | CairoImageSink.create_rcontext | Called when CairoCanvas needs a cairo context to draw on | shoebot/core/cairo_sink.py | def create_rcontext(self, size, frame):
"""
Called when CairoCanvas needs a cairo context to draw on
"""
if self.format == 'pdf':
surface = cairo.PDFSurface(self._output_file(frame), *size)
elif self.format in ('ps', 'eps'):
surface = cairo.PSSurface(self.... | def create_rcontext(self, size, frame):
"""
Called when CairoCanvas needs a cairo context to draw on
"""
if self.format == 'pdf':
surface = cairo.PDFSurface(self._output_file(frame), *size)
elif self.format in ('ps', 'eps'):
surface = cairo.PSSurface(self.... | [
"Called",
"when",
"CairoCanvas",
"needs",
"a",
"cairo",
"context",
"to",
"draw",
"on"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/cairo_sink.py#L80-L94 | [
"def",
"create_rcontext",
"(",
"self",
",",
"size",
",",
"frame",
")",
":",
"if",
"self",
".",
"format",
"==",
"'pdf'",
":",
"surface",
"=",
"cairo",
".",
"PDFSurface",
"(",
"self",
".",
"_output_file",
"(",
"frame",
")",
",",
"*",
"size",
")",
"elif... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | CairoImageSink.rendering_finished | Called when CairoCanvas has rendered a bot | shoebot/core/cairo_sink.py | def rendering_finished(self, size, frame, cairo_ctx):
"""
Called when CairoCanvas has rendered a bot
"""
surface = cairo_ctx.get_target()
if self.format == 'png':
surface.write_to_png(self._output_file(frame))
surface.finish()
surface.flush() | def rendering_finished(self, size, frame, cairo_ctx):
"""
Called when CairoCanvas has rendered a bot
"""
surface = cairo_ctx.get_target()
if self.format == 'png':
surface.write_to_png(self._output_file(frame))
surface.finish()
surface.flush() | [
"Called",
"when",
"CairoCanvas",
"has",
"rendered",
"a",
"bot"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/cairo_sink.py#L96-L104 | [
"def",
"rendering_finished",
"(",
"self",
",",
"size",
",",
"frame",
",",
"cairo_ctx",
")",
":",
"surface",
"=",
"cairo_ctx",
".",
"get_target",
"(",
")",
"if",
"self",
".",
"format",
"==",
"'png'",
":",
"surface",
".",
"write_to_png",
"(",
"self",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | CairoCanvas.output_closure | Function to output to a cairo surface
target is a cairo Context or filename
if file_number is set, then files will be numbered
(this is usually set to the current frame number) | shoebot/core/cairo_canvas.py | def output_closure(self, target, file_number=None):
'''
Function to output to a cairo surface
target is a cairo Context or filename
if file_number is set, then files will be numbered
(this is usually set to the current frame number)
'''
def output_context(ctx):
... | def output_closure(self, target, file_number=None):
'''
Function to output to a cairo surface
target is a cairo Context or filename
if file_number is set, then files will be numbered
(this is usually set to the current frame number)
'''
def output_context(ctx):
... | [
"Function",
"to",
"output",
"to",
"a",
"cairo",
"surface"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/core/cairo_canvas.py#L124-L176 | [
"def",
"output_closure",
"(",
"self",
",",
"target",
",",
"file_number",
"=",
"None",
")",
":",
"def",
"output_context",
"(",
"ctx",
")",
":",
"target_ctx",
"=",
"target",
"target_ctx",
".",
"set_source_surface",
"(",
"ctx",
".",
"get_target",
"(",
")",
")... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | UrbanDictionaryDefinition._parse | Strips links from the definition and gathers them in a links property. | lib/web/urbandictionary.py | def _parse(self):
""" Strips links from the definition and gathers them in a links property.
"""
p1 = "\[.*?\](.*?)\[\/.*?\]"
p2 = "\[(.*?)\]"
self.links = []
for p in (p1,p2):
for link in re.findall(p, self.description):
self... | def _parse(self):
""" Strips links from the definition and gathers them in a links property.
"""
p1 = "\[.*?\](.*?)\[\/.*?\]"
p2 = "\[(.*?)\]"
self.links = []
for p in (p1,p2):
for link in re.findall(p, self.description):
self... | [
"Strips",
"links",
"from",
"the",
"definition",
"and",
"gathers",
"them",
"in",
"a",
"links",
"property",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/urbandictionary.py#L21-L34 | [
"def",
"_parse",
"(",
"self",
")",
":",
"p1",
"=",
"\"\\[.*?\\](.*?)\\[\\/.*?\\]\"",
"p2",
"=",
"\"\\[(.*?)\\]\"",
"self",
".",
"links",
"=",
"[",
"]",
"for",
"p",
"in",
"(",
"p1",
",",
"p2",
")",
":",
"for",
"link",
"in",
"re",
".",
"findall",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | create_canvas | Create canvas and sink for attachment to a bot
canvas is what draws images, 'sink' is the final consumer of the images
:param src: Defaults for title or outputfile if not specified.
:param format: CairoImageSink image format, if using buff instead of outputfile
:param buff: CairoImageSink buffer obje... | shoebot/__init__.py | def create_canvas(src, format=None, outputfile=None, multifile=False, buff=None, window=False, title=None,
fullscreen=None, show_vars=False):
"""
Create canvas and sink for attachment to a bot
canvas is what draws images, 'sink' is the final consumer of the images
:param src: Default... | def create_canvas(src, format=None, outputfile=None, multifile=False, buff=None, window=False, title=None,
fullscreen=None, show_vars=False):
"""
Create canvas and sink for attachment to a bot
canvas is what draws images, 'sink' is the final consumer of the images
:param src: Default... | [
"Create",
"canvas",
"and",
"sink",
"for",
"attachment",
"to",
"a",
"bot"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/__init__.py#L73-L126 | [
"def",
"create_canvas",
"(",
"src",
",",
"format",
"=",
"None",
",",
"outputfile",
"=",
"None",
",",
"multifile",
"=",
"False",
",",
"buff",
"=",
"None",
",",
"window",
"=",
"False",
",",
"title",
"=",
"None",
",",
"fullscreen",
"=",
"None",
",",
"sh... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | create_bot | Create a canvas and a bot with the same canvas attached to it
bot parameters
:param grammar: DRAWBOT or NODEBOX - decides what kind of bot is created
:param vars: preset dictionary of vars from the called
canvas parameters:
... everything else ...
See create_canvas for details on those parame... | shoebot/__init__.py | def create_bot(src=None, grammar=NODEBOX, format=None, outputfile=None, iterations=1, buff=None, window=False,
title=None, fullscreen=None, server=False, port=7777, show_vars=False, vars=None, namespace=None):
"""
Create a canvas and a bot with the same canvas attached to it
bot parameters
... | def create_bot(src=None, grammar=NODEBOX, format=None, outputfile=None, iterations=1, buff=None, window=False,
title=None, fullscreen=None, server=False, port=7777, show_vars=False, vars=None, namespace=None):
"""
Create a canvas and a bot with the same canvas attached to it
bot parameters
... | [
"Create",
"a",
"canvas",
"and",
"a",
"bot",
"with",
"the",
"same",
"canvas",
"attached",
"to",
"it"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/__init__.py#L129-L157 | [
"def",
"create_bot",
"(",
"src",
"=",
"None",
",",
"grammar",
"=",
"NODEBOX",
",",
"format",
"=",
"None",
",",
"outputfile",
"=",
"None",
",",
"iterations",
"=",
"1",
",",
"buff",
"=",
"None",
",",
"window",
"=",
"False",
",",
"title",
"=",
"None",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | run | Create and run a bot, the arguments all correspond to sanitized
commandline options.
:param background_thread: If True then use a background thread.
Other args are split into create_args and run_args
See create_bot for details on create_args
run_args are passed to bot.run - see Nodebot.run or D... | shoebot/__init__.py | def run(src,
grammar=NODEBOX,
format=None,
outputfile=None,
iterations=1,
buff=None,
window=True,
title=None,
fullscreen=None,
close_window=False,
server=False,
port=7777,
show_vars=False,
vars=None,
namespac... | def run(src,
grammar=NODEBOX,
format=None,
outputfile=None,
iterations=1,
buff=None,
window=True,
title=None,
fullscreen=None,
close_window=False,
server=False,
port=7777,
show_vars=False,
vars=None,
namespac... | [
"Create",
"and",
"run",
"a",
"bot",
"the",
"arguments",
"all",
"correspond",
"to",
"sanitized",
"commandline",
"options",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/__init__.py#L217-L335 | [
"def",
"run",
"(",
"src",
",",
"grammar",
"=",
"NODEBOX",
",",
"format",
"=",
"None",
",",
"outputfile",
"=",
"None",
",",
"iterations",
"=",
"1",
",",
"buff",
"=",
"None",
",",
"window",
"=",
"True",
",",
"title",
"=",
"None",
",",
"fullscreen",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | ShoebotEditorWindow.save_as | Return True if the buffer was saved | shoebot/ide/ide.py | def save_as(self):
"""
Return True if the buffer was saved
"""
chooser = ShoebotFileChooserDialog(_('Save File'), None, Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT,
Gtk.STOCK_C... | def save_as(self):
"""
Return True if the buffer was saved
"""
chooser = ShoebotFileChooserDialog(_('Save File'), None, Gtk.FileChooserAction.SAVE,
(Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT,
Gtk.STOCK_C... | [
"Return",
"True",
"if",
"the",
"buffer",
"was",
"saved"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/ide/ide.py#L834-L850 | [
"def",
"save_as",
"(",
"self",
")",
":",
"chooser",
"=",
"ShoebotFileChooserDialog",
"(",
"_",
"(",
"'Save File'",
")",
",",
"None",
",",
"Gtk",
".",
"FileChooserAction",
".",
"SAVE",
",",
"(",
"Gtk",
".",
"STOCK_SAVE",
",",
"Gtk",
".",
"ResponseType",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | VarWindow.add_variables | Add all widgets to specified vbox
:param container:
:return: | shoebot/gui/var_window.py | def add_variables(self):
"""
Add all widgets to specified vbox
:param container:
:return:
"""
for k, v in self.bot._vars.items():
if not hasattr(v, 'type'):
raise AttributeError(
'%s is not a Shoebot Variable - see https://s... | def add_variables(self):
"""
Add all widgets to specified vbox
:param container:
:return:
"""
for k, v in self.bot._vars.items():
if not hasattr(v, 'type'):
raise AttributeError(
'%s is not a Shoebot Variable - see https://s... | [
"Add",
"all",
"widgets",
"to",
"specified",
"vbox",
":",
"param",
"container",
":",
":",
"return",
":"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/var_window.py#L50-L60 | [
"def",
"add_variables",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"bot",
".",
"_vars",
".",
"items",
"(",
")",
":",
"if",
"not",
"hasattr",
"(",
"v",
",",
"'type'",
")",
":",
"raise",
"AttributeError",
"(",
"'%s is not a Shoebot... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | VarWindow.update_var | :return: success, err_msg_if_failed | shoebot/gui/var_window.py | def update_var(self, name, value):
"""
:return: success, err_msg_if_failed
"""
widget = self.widgets.get(name)
if widget is None:
return False, 'No widget found matching, {}'.format(name)
try:
if isinstance(widget, Gtk.CheckButton):
... | def update_var(self, name, value):
"""
:return: success, err_msg_if_failed
"""
widget = self.widgets.get(name)
if widget is None:
return False, 'No widget found matching, {}'.format(name)
try:
if isinstance(widget, Gtk.CheckButton):
... | [
":",
"return",
":",
"success",
"err_msg_if_failed"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/var_window.py#L147-L166 | [
"def",
"update_var",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"widget",
"=",
"self",
".",
"widgets",
".",
"get",
"(",
"name",
")",
"if",
"widget",
"is",
"None",
":",
"return",
"False",
",",
"'No widget found matching, {}'",
".",
"format",
"(",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | VarWindow.widget_changed | Called when a slider is adjusted. | shoebot/gui/var_window.py | def widget_changed(self, widget, v):
''' Called when a slider is adjusted. '''
# set the appropriate bot var
if v.type is NUMBER:
self.bot._namespace[v.name] = widget.get_value()
self.bot._vars[v.name].value = widget.get_value() ## Not sure if this is how to do this - st... | def widget_changed(self, widget, v):
''' Called when a slider is adjusted. '''
# set the appropriate bot var
if v.type is NUMBER:
self.bot._namespace[v.name] = widget.get_value()
self.bot._vars[v.name].value = widget.get_value() ## Not sure if this is how to do this - st... | [
"Called",
"when",
"a",
"slider",
"is",
"adjusted",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/var_window.py#L168-L182 | [
"def",
"widget_changed",
"(",
"self",
",",
"widget",
",",
"v",
")",
":",
"# set the appropriate bot var",
"if",
"v",
".",
"type",
"is",
"NUMBER",
":",
"self",
".",
"bot",
".",
"_namespace",
"[",
"v",
".",
"name",
"]",
"=",
"widget",
".",
"get_value",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | VarWindow.var_added | var was added in the bot while it ran, possibly
by livecoding
:param v:
:return: | shoebot/gui/var_window.py | def var_added(self, v):
"""
var was added in the bot while it ran, possibly
by livecoding
:param v:
:return:
"""
self.add_variable(v)
self.window.set_size_request(400, 35 * len(self.widgets.keys()))
self.window.show_all() | def var_added(self, v):
"""
var was added in the bot while it ran, possibly
by livecoding
:param v:
:return:
"""
self.add_variable(v)
self.window.set_size_request(400, 35 * len(self.widgets.keys()))
self.window.show_all() | [
"var",
"was",
"added",
"in",
"the",
"bot",
"while",
"it",
"ran",
"possibly",
"by",
"livecoding"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/var_window.py#L184-L195 | [
"def",
"var_added",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"add_variable",
"(",
"v",
")",
"self",
".",
"window",
".",
"set_size_request",
"(",
"400",
",",
"35",
"*",
"len",
"(",
"self",
".",
"widgets",
".",
"keys",
"(",
")",
")",
")",
"sel... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | VarWindow.var_deleted | var was added in the bot
:param v:
:return: | shoebot/gui/var_window.py | def var_deleted(self, v):
"""
var was added in the bot
:param v:
:return:
"""
widget = self.widgets[v.name]
# widgets are all in a single container ..
parent = widget.get_parent()
self.container.remove(parent)
del self.widgets[v.name]
... | def var_deleted(self, v):
"""
var was added in the bot
:param v:
:return:
"""
widget = self.widgets[v.name]
# widgets are all in a single container ..
parent = widget.get_parent()
self.container.remove(parent)
del self.widgets[v.name]
... | [
"var",
"was",
"added",
"in",
"the",
"bot"
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/gui/var_window.py#L197-L212 | [
"def",
"var_deleted",
"(",
"self",
",",
"v",
")",
":",
"widget",
"=",
"self",
".",
"widgets",
"[",
"v",
".",
"name",
"]",
"# widgets are all in a single container ..",
"parent",
"=",
"widget",
".",
"get_parent",
"(",
")",
"self",
".",
"container",
".",
"re... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | parse | Returns cached copies unless otherwise specified. | lib/svg/__init__.py | def parse(svg, cached=False, _copy=True):
""" Returns cached copies unless otherwise specified.
"""
if not cached:
dom = parser.parseString(svg)
paths = parse_node(dom, [])
else:
id = _cache.id(svg)
if not _cache.has_key(id):
dom = parser.parseString... | def parse(svg, cached=False, _copy=True):
""" Returns cached copies unless otherwise specified.
"""
if not cached:
dom = parser.parseString(svg)
paths = parse_node(dom, [])
else:
id = _cache.id(svg)
if not _cache.has_key(id):
dom = parser.parseString... | [
"Returns",
"cached",
"copies",
"unless",
"otherwise",
"specified",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/__init__.py#L56-L71 | [
"def",
"parse",
"(",
"svg",
",",
"cached",
"=",
"False",
",",
"_copy",
"=",
"True",
")",
":",
"if",
"not",
"cached",
":",
"dom",
"=",
"parser",
".",
"parseString",
"(",
"svg",
")",
"paths",
"=",
"parse_node",
"(",
"dom",
",",
"[",
"]",
")",
"else... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | get_attribute | Returns XML element's attribute, or default if none. | lib/svg/__init__.py | def get_attribute(element, attribute, default=0):
""" Returns XML element's attribute, or default if none.
"""
a = element.getAttribute(attribute)
if a == "":
return default
return a | def get_attribute(element, attribute, default=0):
""" Returns XML element's attribute, or default if none.
"""
a = element.getAttribute(attribute)
if a == "":
return default
return a | [
"Returns",
"XML",
"element",
"s",
"attribute",
"or",
"default",
"if",
"none",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/__init__.py#L85-L93 | [
"def",
"get_attribute",
"(",
"element",
",",
"attribute",
",",
"default",
"=",
"0",
")",
":",
"a",
"=",
"element",
".",
"getAttribute",
"(",
"attribute",
")",
"if",
"a",
"==",
"\"\"",
":",
"return",
"default",
"return",
"a"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | parse_node | Recurse the node tree and find drawable tags.
Recures all the children in the node.
If a child is something we can draw,
a line, rect, oval or path,
parse it to a PathElement drawable with drawpath() | lib/svg/__init__.py | def parse_node(node, paths=[], ignore=["pattern"]):
""" Recurse the node tree and find drawable tags.
Recures all the children in the node.
If a child is something we can draw,
a line, rect, oval or path,
parse it to a PathElement drawable with drawpath()
"""
# Ignore pat... | def parse_node(node, paths=[], ignore=["pattern"]):
""" Recurse the node tree and find drawable tags.
Recures all the children in the node.
If a child is something we can draw,
a line, rect, oval or path,
parse it to a PathElement drawable with drawpath()
"""
# Ignore pat... | [
"Recurse",
"the",
"node",
"tree",
"and",
"find",
"drawable",
"tags",
".",
"Recures",
"all",
"the",
"children",
"in",
"the",
"node",
".",
"If",
"a",
"child",
"is",
"something",
"we",
"can",
"draw",
"a",
"line",
"rect",
"oval",
"or",
"path",
"parse",
"it... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/__init__.py#L97-L137 | [
"def",
"parse_node",
"(",
"node",
",",
"paths",
"=",
"[",
"]",
",",
"ignore",
"=",
"[",
"\"pattern\"",
"]",
")",
":",
"# Ignore paths in Illustrator pattern swatches etc.",
"if",
"node",
".",
"nodeType",
"==",
"node",
".",
"ELEMENT_NODE",
"and",
"node",
".",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | parse_transform | Transform the path according to a defined matrix.
Attempts to extract a transform="matrix()|translate()" attribute.
Transforms the path accordingly. | lib/svg/__init__.py | def parse_transform(e, path):
""" Transform the path according to a defined matrix.
Attempts to extract a transform="matrix()|translate()" attribute.
Transforms the path accordingly.
"""
t = get_attribute(e, "transform", default="")
for mode in ("matrix", "translate"):
... | def parse_transform(e, path):
""" Transform the path according to a defined matrix.
Attempts to extract a transform="matrix()|translate()" attribute.
Transforms the path accordingly.
"""
t = get_attribute(e, "transform", default="")
for mode in ("matrix", "translate"):
... | [
"Transform",
"the",
"path",
"according",
"to",
"a",
"defined",
"matrix",
".",
"Attempts",
"to",
"extract",
"a",
"transform",
"=",
"matrix",
"()",
"|translate",
"()",
"attribute",
".",
"Transforms",
"the",
"path",
"accordingly",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/__init__.py#L398-L429 | [
"def",
"parse_transform",
"(",
"e",
",",
"path",
")",
":",
"t",
"=",
"get_attribute",
"(",
"e",
",",
"\"transform\"",
",",
"default",
"=",
"\"\"",
")",
"for",
"mode",
"in",
"(",
"\"matrix\"",
",",
"\"translate\"",
")",
":",
"if",
"t",
".",
"startswith"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | add_color_info | Expand the path with color information.
Attempts to extract fill and stroke colors
from the element and adds it to path attributes. | lib/svg/__init__.py | def add_color_info(e, path):
""" Expand the path with color information.
Attempts to extract fill and stroke colors
from the element and adds it to path attributes.
"""
_ctx.colormode(RGB, 1.0)
def _color(hex, alpha=1.0):
if hex == "none": return None
n =... | def add_color_info(e, path):
""" Expand the path with color information.
Attempts to extract fill and stroke colors
from the element and adds it to path attributes.
"""
_ctx.colormode(RGB, 1.0)
def _color(hex, alpha=1.0):
if hex == "none": return None
n =... | [
"Expand",
"the",
"path",
"with",
"color",
"information",
".",
"Attempts",
"to",
"extract",
"fill",
"and",
"stroke",
"colors",
"from",
"the",
"element",
"and",
"adds",
"it",
"to",
"path",
"attributes",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/svg/__init__.py#L433-L500 | [
"def",
"add_color_info",
"(",
"e",
",",
"path",
")",
":",
"_ctx",
".",
"colormode",
"(",
"RGB",
",",
"1.0",
")",
"def",
"_color",
"(",
"hex",
",",
"alpha",
"=",
"1.0",
")",
":",
"if",
"hex",
"==",
"\"none\"",
":",
"return",
"None",
"n",
"=",
"int... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | MorgueFileImage.download | Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator.
Once it is done downloading, this image will have its path property
set to an image file in the cache. | lib/web/morguefile.py | def download(self, size=SIZE_LARGE, thumbnail=False, wait=60, asynchronous=False):
""" Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator.
Once it is done downloading, this image will have its path property
set to an... | def download(self, size=SIZE_LARGE, thumbnail=False, wait=60, asynchronous=False):
""" Downloads this image to cache.
Calling the download() method instantiates an asynchronous URLAccumulator.
Once it is done downloading, this image will have its path property
set to an... | [
"Downloads",
"this",
"image",
"to",
"cache",
".",
"Calling",
"the",
"download",
"()",
"method",
"instantiates",
"an",
"asynchronous",
"URLAccumulator",
".",
"Once",
"it",
"is",
"done",
"downloading",
"this",
"image",
"will",
"have",
"its",
"path",
"property",
... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/morguefile.py#L56-L78 | [
"def",
"download",
"(",
"self",
",",
"size",
"=",
"SIZE_LARGE",
",",
"thumbnail",
"=",
"False",
",",
"wait",
"=",
"60",
",",
"asynchronous",
"=",
"False",
")",
":",
"if",
"thumbnail",
"==",
"True",
":",
"size",
"=",
"SIZE_THUMBNAIL",
"# backwards compatibi... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | events.copy | Returns a copy of the event handler, remembering the last node clicked. | lib/graph/event.py | def copy(self, graph):
""" Returns a copy of the event handler, remembering the last node clicked.
"""
e = events(graph, self._ctx)
e.clicked = self.clicked
return e | def copy(self, graph):
""" Returns a copy of the event handler, remembering the last node clicked.
"""
e = events(graph, self._ctx)
e.clicked = self.clicked
return e | [
"Returns",
"a",
"copy",
"of",
"the",
"event",
"handler",
"remembering",
"the",
"last",
"node",
"clicked",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L34-L41 | [
"def",
"copy",
"(",
"self",
",",
"graph",
")",
":",
"e",
"=",
"events",
"(",
"graph",
",",
"self",
".",
"_ctx",
")",
"e",
".",
"clicked",
"=",
"self",
".",
"clicked",
"return",
"e"
] | d554c1765c1899fa25727c9fc6805d221585562b |
valid | events.update | Interacts with the graph by clicking or dragging nodes.
Hovering a node fires the callback function events.hover().
Clicking a node fires the callback function events.click(). | lib/graph/event.py | def update(self):
""" Interacts with the graph by clicking or dragging nodes.
Hovering a node fires the callback function events.hover().
Clicking a node fires the callback function events.click().
"""
if self.mousedown:
# When not pressing or dragg... | def update(self):
""" Interacts with the graph by clicking or dragging nodes.
Hovering a node fires the callback function events.hover().
Clicking a node fires the callback function events.click().
"""
if self.mousedown:
# When not pressing or dragg... | [
"Interacts",
"with",
"the",
"graph",
"by",
"clicking",
"or",
"dragging",
"nodes",
".",
"Hovering",
"a",
"node",
"fires",
"the",
"callback",
"function",
"events",
".",
"hover",
"()",
".",
"Clicking",
"a",
"node",
"fires",
"the",
"callback",
"function",
"event... | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L61-L105 | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"mousedown",
":",
"# When not pressing or dragging, check each node.",
"if",
"not",
"self",
".",
"pressed",
"and",
"not",
"self",
".",
"dragged",
":",
"for",
"n",
"in",
"self",
".",
"graph",
".",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | events.drag | Drags given node to mouse location. | lib/graph/event.py | def drag(self, node):
""" Drags given node to mouse location.
"""
dx = self.mouse.x - self.graph.x
dy = self.mouse.y - self.graph.y
# A dashed line indicates the drag vector.
s = self.graph.styles.default
self._ctx.nofill()
self._ctx.nostroke()
... | def drag(self, node):
""" Drags given node to mouse location.
"""
dx = self.mouse.x - self.graph.x
dy = self.mouse.y - self.graph.y
# A dashed line indicates the drag vector.
s = self.graph.styles.default
self._ctx.nofill()
self._ctx.nostroke()
... | [
"Drags",
"given",
"node",
"to",
"mouse",
"location",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L107-L136 | [
"def",
"drag",
"(",
"self",
",",
"node",
")",
":",
"dx",
"=",
"self",
".",
"mouse",
".",
"x",
"-",
"self",
".",
"graph",
".",
"x",
"dy",
"=",
"self",
".",
"mouse",
".",
"y",
"-",
"self",
".",
"graph",
".",
"y",
"# A dashed line indicates the drag v... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | events.hover | Displays a popup when hovering over a node. | lib/graph/event.py | def hover(self, node):
""" Displays a popup when hovering over a node.
"""
if self.popup == False: return
if self.popup == True or self.popup.node != node:
if self.popup_text.has_key(node.id):
texts = self.popup_text[node.id]
else... | def hover(self, node):
""" Displays a popup when hovering over a node.
"""
if self.popup == False: return
if self.popup == True or self.popup.node != node:
if self.popup_text.has_key(node.id):
texts = self.popup_text[node.id]
else... | [
"Displays",
"a",
"popup",
"when",
"hovering",
"over",
"a",
"node",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L138-L150 | [
"def",
"hover",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"popup",
"==",
"False",
":",
"return",
"if",
"self",
".",
"popup",
"==",
"True",
"or",
"self",
".",
"popup",
".",
"node",
"!=",
"node",
":",
"if",
"self",
".",
"popup_text",
"... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | popup.textpath | Returns a cached textpath of the given text in queue. | lib/graph/event.py | def textpath(self, i):
""" Returns a cached textpath of the given text in queue.
"""
if len(self._textpaths) == i:
self._ctx.font(self.font, self.fontsize)
txt = self.q[i]
if len(self.q) > 1:
# Indicate current text (e.g. 5/13... | def textpath(self, i):
""" Returns a cached textpath of the given text in queue.
"""
if len(self._textpaths) == i:
self._ctx.font(self.font, self.fontsize)
txt = self.q[i]
if len(self.q) > 1:
# Indicate current text (e.g. 5/13... | [
"Returns",
"a",
"cached",
"textpath",
"of",
"the",
"given",
"text",
"in",
"queue",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L204-L219 | [
"def",
"textpath",
"(",
"self",
",",
"i",
")",
":",
"if",
"len",
"(",
"self",
".",
"_textpaths",
")",
"==",
"i",
":",
"self",
".",
"_ctx",
".",
"font",
"(",
"self",
".",
"font",
",",
"self",
".",
"fontsize",
")",
"txt",
"=",
"self",
".",
"q",
... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | popup.update | Rotates the queued texts and determines display time. | lib/graph/event.py | def update(self):
""" Rotates the queued texts and determines display time.
"""
if self.delay > 0:
# It takes a while for the popup to appear.
self.delay -= 1; return
if self.fi == 0:
# Only one text in queue, displayed i... | def update(self):
""" Rotates the queued texts and determines display time.
"""
if self.delay > 0:
# It takes a while for the popup to appear.
self.delay -= 1; return
if self.fi == 0:
# Only one text in queue, displayed i... | [
"Rotates",
"the",
"queued",
"texts",
"and",
"determines",
"display",
"time",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L221-L243 | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"delay",
">",
"0",
":",
"# It takes a while for the popup to appear.",
"self",
".",
"delay",
"-=",
"1",
"return",
"if",
"self",
".",
"fi",
"==",
"0",
":",
"# Only one text in queue, displayed infinitely.... | d554c1765c1899fa25727c9fc6805d221585562b |
valid | popup.draw | Draws a popup rectangle with a rotating text queue. | lib/graph/event.py | def draw(self):
""" Draws a popup rectangle with a rotating text queue.
"""
if len(self.q) > 0:
self.update()
if self.delay == 0:
# Rounded rectangle in the given background color.
p,... | def draw(self):
""" Draws a popup rectangle with a rotating text queue.
"""
if len(self.q) > 0:
self.update()
if self.delay == 0:
# Rounded rectangle in the given background color.
p,... | [
"Draws",
"a",
"popup",
"rectangle",
"with",
"a",
"rotating",
"text",
"queue",
"."
] | shoebot/shoebot | python | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/graph/event.py#L245-L281 | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"q",
")",
">",
"0",
":",
"self",
".",
"update",
"(",
")",
"if",
"self",
".",
"delay",
"==",
"0",
":",
"# Rounded rectangle in the given background color.",
"p",
",",
"h",
"=",
"self... | d554c1765c1899fa25727c9fc6805d221585562b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.