repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ribozz/sphinx-argparse | sphinxarg/markdown.py | raw | def raw(node):
"""
Add some raw html (possibly as a block)
"""
o = nodes.raw(node.literal, node.literal, format='html')
if node.sourcepos is not None:
o.line = node.sourcepos[0][0]
for n in MarkDown(node):
o += n
return o | python | def raw(node):
"""
Add some raw html (possibly as a block)
"""
o = nodes.raw(node.literal, node.literal, format='html')
if node.sourcepos is not None:
o.line = node.sourcepos[0][0]
for n in MarkDown(node):
o += n
return o | [
"def",
"raw",
"(",
"node",
")",
":",
"o",
"=",
"nodes",
".",
"raw",
"(",
"node",
".",
"literal",
",",
"node",
".",
"literal",
",",
"format",
"=",
"'html'",
")",
"if",
"node",
".",
"sourcepos",
"is",
"not",
"None",
":",
"o",
".",
"line",
"=",
"n... | Add some raw html (possibly as a block) | [
"Add",
"some",
"raw",
"html",
"(",
"possibly",
"as",
"a",
"block",
")"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L173-L182 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | title | def title(node):
"""
A title node. It has no children
"""
return nodes.title(node.first_child.literal, node.first_child.literal) | python | def title(node):
"""
A title node. It has no children
"""
return nodes.title(node.first_child.literal, node.first_child.literal) | [
"def",
"title",
"(",
"node",
")",
":",
"return",
"nodes",
".",
"title",
"(",
"node",
".",
"first_child",
".",
"literal",
",",
"node",
".",
"first_child",
".",
"literal",
")"
] | A title node. It has no children | [
"A",
"title",
"node",
".",
"It",
"has",
"no",
"children"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L192-L196 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | section | def section(node):
"""
A section in reStructuredText, which needs a title (the first child)
This is a custom type
"""
title = '' # All sections need an id
if node.first_child is not None:
if node.first_child.t == u'heading':
title = node.first_child.first_child.literal
o... | python | def section(node):
"""
A section in reStructuredText, which needs a title (the first child)
This is a custom type
"""
title = '' # All sections need an id
if node.first_child is not None:
if node.first_child.t == u'heading':
title = node.first_child.first_child.literal
o... | [
"def",
"section",
"(",
"node",
")",
":",
"title",
"=",
"''",
"# All sections need an id",
"if",
"node",
".",
"first_child",
"is",
"not",
"None",
":",
"if",
"node",
".",
"first_child",
".",
"t",
"==",
"u'heading'",
":",
"title",
"=",
"node",
".",
"first_c... | A section in reStructuredText, which needs a title (the first child)
This is a custom type | [
"A",
"section",
"in",
"reStructuredText",
"which",
"needs",
"a",
"title",
"(",
"the",
"first",
"child",
")",
"This",
"is",
"a",
"custom",
"type"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L199-L211 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | block_quote | def block_quote(node):
"""
A block quote
"""
o = nodes.block_quote()
o.line = node.sourcepos[0][0]
for n in MarkDown(node):
o += n
return o | python | def block_quote(node):
"""
A block quote
"""
o = nodes.block_quote()
o.line = node.sourcepos[0][0]
for n in MarkDown(node):
o += n
return o | [
"def",
"block_quote",
"(",
"node",
")",
":",
"o",
"=",
"nodes",
".",
"block_quote",
"(",
")",
"o",
".",
"line",
"=",
"node",
".",
"sourcepos",
"[",
"0",
"]",
"[",
"0",
"]",
"for",
"n",
"in",
"MarkDown",
"(",
"node",
")",
":",
"o",
"+=",
"n",
... | A block quote | [
"A",
"block",
"quote"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L214-L222 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | image | def image(node):
"""
An image element
The first child is the alt text. reStructuredText can't handle titles
"""
o = nodes.image(uri=node.destination)
if node.first_child is not None:
o['alt'] = node.first_child.literal
return o | python | def image(node):
"""
An image element
The first child is the alt text. reStructuredText can't handle titles
"""
o = nodes.image(uri=node.destination)
if node.first_child is not None:
o['alt'] = node.first_child.literal
return o | [
"def",
"image",
"(",
"node",
")",
":",
"o",
"=",
"nodes",
".",
"image",
"(",
"uri",
"=",
"node",
".",
"destination",
")",
"if",
"node",
".",
"first_child",
"is",
"not",
"None",
":",
"o",
"[",
"'alt'",
"]",
"=",
"node",
".",
"first_child",
".",
"l... | An image element
The first child is the alt text. reStructuredText can't handle titles | [
"An",
"image",
"element"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L225-L234 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | listItem | def listItem(node):
"""
An item in a list
"""
o = nodes.list_item()
for n in MarkDown(node):
o += n
return o | python | def listItem(node):
"""
An item in a list
"""
o = nodes.list_item()
for n in MarkDown(node):
o += n
return o | [
"def",
"listItem",
"(",
"node",
")",
":",
"o",
"=",
"nodes",
".",
"list_item",
"(",
")",
"for",
"n",
"in",
"MarkDown",
"(",
"node",
")",
":",
"o",
"+=",
"n",
"return",
"o"
] | An item in a list | [
"An",
"item",
"in",
"a",
"list"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L237-L244 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | listNode | def listNode(node):
"""
A list (numbered or not)
For numbered lists, the suffix is only rendered as . in html
"""
if node.list_data['type'] == u'bullet':
o = nodes.bullet_list(bullet=node.list_data['bullet_char'])
else:
o = nodes.enumerated_list(suffix=node.list_data['delimiter']... | python | def listNode(node):
"""
A list (numbered or not)
For numbered lists, the suffix is only rendered as . in html
"""
if node.list_data['type'] == u'bullet':
o = nodes.bullet_list(bullet=node.list_data['bullet_char'])
else:
o = nodes.enumerated_list(suffix=node.list_data['delimiter']... | [
"def",
"listNode",
"(",
"node",
")",
":",
"if",
"node",
".",
"list_data",
"[",
"'type'",
"]",
"==",
"u'bullet'",
":",
"o",
"=",
"nodes",
".",
"bullet_list",
"(",
"bullet",
"=",
"node",
".",
"list_data",
"[",
"'bullet_char'",
"]",
")",
"else",
":",
"o... | A list (numbered or not)
For numbered lists, the suffix is only rendered as . in html | [
"A",
"list",
"(",
"numbered",
"or",
"not",
")",
"For",
"numbered",
"lists",
"the",
"suffix",
"is",
"only",
"rendered",
"as",
".",
"in",
"html"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L247-L258 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | MarkDown | def MarkDown(node):
"""
Returns a list of nodes, containing CommonMark nodes converted to docutils nodes
"""
cur = node.first_child
# Go into each child, in turn
output = []
while cur is not None:
t = cur.t
if t == 'paragraph':
output.append(paragraph(cur))
... | python | def MarkDown(node):
"""
Returns a list of nodes, containing CommonMark nodes converted to docutils nodes
"""
cur = node.first_child
# Go into each child, in turn
output = []
while cur is not None:
t = cur.t
if t == 'paragraph':
output.append(paragraph(cur))
... | [
"def",
"MarkDown",
"(",
"node",
")",
":",
"cur",
"=",
"node",
".",
"first_child",
"# Go into each child, in turn",
"output",
"=",
"[",
"]",
"while",
"cur",
"is",
"not",
"None",
":",
"t",
"=",
"cur",
".",
"t",
"if",
"t",
"==",
"'paragraph'",
":",
"outpu... | Returns a list of nodes, containing CommonMark nodes converted to docutils nodes | [
"Returns",
"a",
"list",
"of",
"nodes",
"containing",
"CommonMark",
"nodes",
"converted",
"to",
"docutils",
"nodes"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L261-L311 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | finalizeSection | def finalizeSection(section):
"""
Correct the nxt and parent for each child
"""
cur = section.first_child
last = section.last_child
if last is not None:
last.nxt = None
while cur is not None:
cur.parent = section
cur = cur.nxt | python | def finalizeSection(section):
"""
Correct the nxt and parent for each child
"""
cur = section.first_child
last = section.last_child
if last is not None:
last.nxt = None
while cur is not None:
cur.parent = section
cur = cur.nxt | [
"def",
"finalizeSection",
"(",
"section",
")",
":",
"cur",
"=",
"section",
".",
"first_child",
"last",
"=",
"section",
".",
"last_child",
"if",
"last",
"is",
"not",
"None",
":",
"last",
".",
"nxt",
"=",
"None",
"while",
"cur",
"is",
"not",
"None",
":",... | Correct the nxt and parent for each child | [
"Correct",
"the",
"nxt",
"and",
"parent",
"for",
"each",
"child"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L314-L325 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | nestSections | def nestSections(block, level=1):
"""
Sections aren't handled by CommonMark at the moment.
This function adds sections to a block of nodes.
'title' nodes with an assigned level below 'level' will be put in a child section.
If there are no child nodes with titles of level 'level' then nothing is done... | python | def nestSections(block, level=1):
"""
Sections aren't handled by CommonMark at the moment.
This function adds sections to a block of nodes.
'title' nodes with an assigned level below 'level' will be put in a child section.
If there are no child nodes with titles of level 'level' then nothing is done... | [
"def",
"nestSections",
"(",
"block",
",",
"level",
"=",
"1",
")",
":",
"cur",
"=",
"block",
".",
"first_child",
"if",
"cur",
"is",
"not",
"None",
":",
"children",
"=",
"[",
"]",
"# Do we need to do anything?",
"nest",
"=",
"False",
"while",
"cur",
"is",
... | Sections aren't handled by CommonMark at the moment.
This function adds sections to a block of nodes.
'title' nodes with an assigned level below 'level' will be put in a child section.
If there are no child nodes with titles of level 'level' then nothing is done | [
"Sections",
"aren",
"t",
"handled",
"by",
"CommonMark",
"at",
"the",
"moment",
".",
"This",
"function",
"adds",
"sections",
"to",
"a",
"block",
"of",
"nodes",
".",
"title",
"nodes",
"with",
"an",
"assigned",
"level",
"below",
"level",
"will",
"be",
"put",
... | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L328-L390 | train |
ribozz/sphinx-argparse | sphinxarg/markdown.py | parseMarkDownBlock | def parseMarkDownBlock(text):
"""
Parses a block of text, returning a list of docutils nodes
>>> parseMarkdownBlock("Some\n====\n\nblock of text\n\nHeader\n======\n\nblah\n")
[]
"""
block = Parser().parse(text)
# CommonMark can't nest sections, so do it manually
nestSections(block)
... | python | def parseMarkDownBlock(text):
"""
Parses a block of text, returning a list of docutils nodes
>>> parseMarkdownBlock("Some\n====\n\nblock of text\n\nHeader\n======\n\nblah\n")
[]
"""
block = Parser().parse(text)
# CommonMark can't nest sections, so do it manually
nestSections(block)
... | [
"def",
"parseMarkDownBlock",
"(",
"text",
")",
":",
"block",
"=",
"Parser",
"(",
")",
".",
"parse",
"(",
"text",
")",
"# CommonMark can't nest sections, so do it manually",
"nestSections",
"(",
"block",
")",
"return",
"MarkDown",
"(",
"block",
")"
] | Parses a block of text, returning a list of docutils nodes
>>> parseMarkdownBlock("Some\n====\n\nblock of text\n\nHeader\n======\n\nblah\n")
[] | [
"Parses",
"a",
"block",
"of",
"text",
"returning",
"a",
"list",
"of",
"docutils",
"nodes"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/markdown.py#L393-L404 | train |
ribozz/sphinx-argparse | sphinxarg/ext.py | renderList | def renderList(l, markDownHelp, settings=None):
"""
Given a list of reStructuredText or MarkDown sections, return a docutils node list
"""
if len(l) == 0:
return []
if markDownHelp:
from sphinxarg.markdown import parseMarkDownBlock
return parseMarkDownBlock('\n\n'.join(l) + '... | python | def renderList(l, markDownHelp, settings=None):
"""
Given a list of reStructuredText or MarkDown sections, return a docutils node list
"""
if len(l) == 0:
return []
if markDownHelp:
from sphinxarg.markdown import parseMarkDownBlock
return parseMarkDownBlock('\n\n'.join(l) + '... | [
"def",
"renderList",
"(",
"l",
",",
"markDownHelp",
",",
"settings",
"=",
"None",
")",
":",
"if",
"len",
"(",
"l",
")",
"==",
"0",
":",
"return",
"[",
"]",
"if",
"markDownHelp",
":",
"from",
"sphinxarg",
".",
"markdown",
"import",
"parseMarkDownBlock",
... | Given a list of reStructuredText or MarkDown sections, return a docutils node list | [
"Given",
"a",
"list",
"of",
"reStructuredText",
"or",
"MarkDown",
"sections",
"return",
"a",
"docutils",
"node",
"list"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/ext.py#L54-L75 | train |
ribozz/sphinx-argparse | sphinxarg/ext.py | print_action_groups | def print_action_groups(data, nested_content, markDownHelp=False, settings=None):
"""
Process all 'action groups', which are also include 'Options' and 'Required
arguments'. A list of nodes is returned.
"""
definitions = map_nested_definitions(nested_content)
nodes_list = []
if 'action_group... | python | def print_action_groups(data, nested_content, markDownHelp=False, settings=None):
"""
Process all 'action groups', which are also include 'Options' and 'Required
arguments'. A list of nodes is returned.
"""
definitions = map_nested_definitions(nested_content)
nodes_list = []
if 'action_group... | [
"def",
"print_action_groups",
"(",
"data",
",",
"nested_content",
",",
"markDownHelp",
"=",
"False",
",",
"settings",
"=",
"None",
")",
":",
"definitions",
"=",
"map_nested_definitions",
"(",
"nested_content",
")",
"nodes_list",
"=",
"[",
"]",
"if",
"'action_gro... | Process all 'action groups', which are also include 'Options' and 'Required
arguments'. A list of nodes is returned. | [
"Process",
"all",
"action",
"groups",
"which",
"are",
"also",
"include",
"Options",
"and",
"Required",
"arguments",
".",
"A",
"list",
"of",
"nodes",
"is",
"returned",
"."
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/ext.py#L78-L162 | train |
ribozz/sphinx-argparse | sphinxarg/ext.py | print_subcommands | def print_subcommands(data, nested_content, markDownHelp=False, settings=None):
"""
Each subcommand is a dictionary with the following keys:
['usage', 'action_groups', 'bare_usage', 'name', 'help']
In essence, this is all tossed in a new section with the title 'name'.
Apparently there can also be ... | python | def print_subcommands(data, nested_content, markDownHelp=False, settings=None):
"""
Each subcommand is a dictionary with the following keys:
['usage', 'action_groups', 'bare_usage', 'name', 'help']
In essence, this is all tossed in a new section with the title 'name'.
Apparently there can also be ... | [
"def",
"print_subcommands",
"(",
"data",
",",
"nested_content",
",",
"markDownHelp",
"=",
"False",
",",
"settings",
"=",
"None",
")",
":",
"definitions",
"=",
"map_nested_definitions",
"(",
"nested_content",
")",
"items",
"=",
"[",
"]",
"if",
"'children'",
"in... | Each subcommand is a dictionary with the following keys:
['usage', 'action_groups', 'bare_usage', 'name', 'help']
In essence, this is all tossed in a new section with the title 'name'.
Apparently there can also be a 'description' entry. | [
"Each",
"subcommand",
"is",
"a",
"dictionary",
"with",
"the",
"following",
"keys",
":"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/ext.py#L165-L221 | train |
ribozz/sphinx-argparse | sphinxarg/ext.py | ensureUniqueIDs | def ensureUniqueIDs(items):
"""
If action groups are repeated, then links in the table of contents will
just go to the first of the repeats. This may not be desirable, particularly
in the case of subcommands where the option groups have different members.
This function updates the title IDs by addin... | python | def ensureUniqueIDs(items):
"""
If action groups are repeated, then links in the table of contents will
just go to the first of the repeats. This may not be desirable, particularly
in the case of subcommands where the option groups have different members.
This function updates the title IDs by addin... | [
"def",
"ensureUniqueIDs",
"(",
"items",
")",
":",
"s",
"=",
"set",
"(",
")",
"for",
"item",
"in",
"items",
":",
"for",
"n",
"in",
"item",
".",
"traverse",
"(",
"descend",
"=",
"True",
",",
"siblings",
"=",
"True",
",",
"ascend",
"=",
"False",
")",
... | If action groups are repeated, then links in the table of contents will
just go to the first of the repeats. This may not be desirable, particularly
in the case of subcommands where the option groups have different members.
This function updates the title IDs by adding _repeatX, where X is a number
so t... | [
"If",
"action",
"groups",
"are",
"repeated",
"then",
"links",
"in",
"the",
"table",
"of",
"contents",
"will",
"just",
"go",
"to",
"the",
"first",
"of",
"the",
"repeats",
".",
"This",
"may",
"not",
"be",
"desirable",
"particularly",
"in",
"the",
"case",
"... | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/ext.py#L224-L246 | train |
ribozz/sphinx-argparse | sphinxarg/ext.py | ArgParseDirective._construct_manpage_specific_structure | def _construct_manpage_specific_structure(self, parser_info):
"""
Construct a typical man page consisting of the following elements:
NAME (automatically generated, out of our control)
SYNOPSIS
DESCRIPTION
OPTIONS
FILES
SEE ALSO
... | python | def _construct_manpage_specific_structure(self, parser_info):
"""
Construct a typical man page consisting of the following elements:
NAME (automatically generated, out of our control)
SYNOPSIS
DESCRIPTION
OPTIONS
FILES
SEE ALSO
... | [
"def",
"_construct_manpage_specific_structure",
"(",
"self",
",",
"parser_info",
")",
":",
"items",
"=",
"[",
"]",
"# SYNOPSIS section",
"synopsis_section",
"=",
"nodes",
".",
"section",
"(",
"''",
",",
"nodes",
".",
"title",
"(",
"text",
"=",
"'Synopsis'",
")... | Construct a typical man page consisting of the following elements:
NAME (automatically generated, out of our control)
SYNOPSIS
DESCRIPTION
OPTIONS
FILES
SEE ALSO
BUGS | [
"Construct",
"a",
"typical",
"man",
"page",
"consisting",
"of",
"the",
"following",
"elements",
":",
"NAME",
"(",
"automatically",
"generated",
"out",
"of",
"our",
"control",
")",
"SYNOPSIS",
"DESCRIPTION",
"OPTIONS",
"FILES",
"SEE",
"ALSO",
"BUGS"
] | 178672cd5c846440ff7ecd695e3708feea13e4b4 | https://github.com/ribozz/sphinx-argparse/blob/178672cd5c846440ff7ecd695e3708feea13e4b4/sphinxarg/ext.py#L258-L343 | train |
ddorn/GUI | GUI/vracabulous.py | FocusSelector.select | def select(self, item):
"""Select an arbitrary item, by possition or by reference."""
self._on_unselect[self._selected]()
self.selected().unfocus()
if isinstance(item, int):
self._selected = item % len(self)
else:
self._selected = self.items.index(item)
... | python | def select(self, item):
"""Select an arbitrary item, by possition or by reference."""
self._on_unselect[self._selected]()
self.selected().unfocus()
if isinstance(item, int):
self._selected = item % len(self)
else:
self._selected = self.items.index(item)
... | [
"def",
"select",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"_on_unselect",
"[",
"self",
".",
"_selected",
"]",
"(",
")",
"self",
".",
"selected",
"(",
")",
".",
"unfocus",
"(",
")",
"if",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"s... | Select an arbitrary item, by possition or by reference. | [
"Select",
"an",
"arbitrary",
"item",
"by",
"possition",
"or",
"by",
"reference",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L71-L82 | train |
ddorn/GUI | GUI/vracabulous.py | FocusSelector.on_select | def on_select(self, item, action):
"""
Add an action to make when an object is selected.
Only one action can be stored this way.
"""
if not isinstance(item, int):
item = self.items.index(item)
self._on_select[item] = action | python | def on_select(self, item, action):
"""
Add an action to make when an object is selected.
Only one action can be stored this way.
"""
if not isinstance(item, int):
item = self.items.index(item)
self._on_select[item] = action | [
"def",
"on_select",
"(",
"self",
",",
"item",
",",
"action",
")",
":",
"if",
"not",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"item",
"=",
"self",
".",
"items",
".",
"index",
"(",
"item",
")",
"self",
".",
"_on_select",
"[",
"item",
"]",
"... | Add an action to make when an object is selected.
Only one action can be stored this way. | [
"Add",
"an",
"action",
"to",
"make",
"when",
"an",
"object",
"is",
"selected",
".",
"Only",
"one",
"action",
"can",
"be",
"stored",
"this",
"way",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L96-L105 | train |
ddorn/GUI | GUI/vracabulous.py | FocusSelector.on_unselect | def on_unselect(self, item, action):
"""Add an action to make when an object is unfocused."""
if not isinstance(item, int):
item = self.items.index(item)
self._on_unselect[item] = action | python | def on_unselect(self, item, action):
"""Add an action to make when an object is unfocused."""
if not isinstance(item, int):
item = self.items.index(item)
self._on_unselect[item] = action | [
"def",
"on_unselect",
"(",
"self",
",",
"item",
",",
"action",
")",
":",
"if",
"not",
"isinstance",
"(",
"item",
",",
"int",
")",
":",
"item",
"=",
"self",
".",
"items",
".",
"index",
"(",
"item",
")",
"self",
".",
"_on_unselect",
"[",
"item",
"]",... | Add an action to make when an object is unfocused. | [
"Add",
"an",
"action",
"to",
"make",
"when",
"an",
"object",
"is",
"unfocused",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L107-L112 | train |
ddorn/GUI | GUI/vracabulous.py | Window.add | def add(self, widget, condition=lambda: 42):
"""
Add a widget to the widows.
The widget will auto render. You can use the function like that if you want to keep the widget accecible :
self.my_widget = self.add(my_widget)
"""
assert callable(condition)
assert... | python | def add(self, widget, condition=lambda: 42):
"""
Add a widget to the widows.
The widget will auto render. You can use the function like that if you want to keep the widget accecible :
self.my_widget = self.add(my_widget)
"""
assert callable(condition)
assert... | [
"def",
"add",
"(",
"self",
",",
"widget",
",",
"condition",
"=",
"lambda",
":",
"42",
")",
":",
"assert",
"callable",
"(",
"condition",
")",
"assert",
"isinstance",
"(",
"widget",
",",
"BaseWidget",
")",
"self",
".",
"_widgets",
".",
"append",
"(",
"("... | Add a widget to the widows.
The widget will auto render. You can use the function like that if you want to keep the widget accecible :
self.my_widget = self.add(my_widget) | [
"Add",
"a",
"widget",
"to",
"the",
"widows",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L228-L240 | train |
ddorn/GUI | GUI/vracabulous.py | Window.remove | def remove(self, widget):
"""Remove a widget from the window."""
for i, (wid, _) in enumerate(self._widgets):
if widget is wid:
del self._widgets[i]
return True
raise ValueError('Widget not in list') | python | def remove(self, widget):
"""Remove a widget from the window."""
for i, (wid, _) in enumerate(self._widgets):
if widget is wid:
del self._widgets[i]
return True
raise ValueError('Widget not in list') | [
"def",
"remove",
"(",
"self",
",",
"widget",
")",
":",
"for",
"i",
",",
"(",
"wid",
",",
"_",
")",
"in",
"enumerate",
"(",
"self",
".",
"_widgets",
")",
":",
"if",
"widget",
"is",
"wid",
":",
"del",
"self",
".",
"_widgets",
"[",
"i",
"]",
"retu... | Remove a widget from the window. | [
"Remove",
"a",
"widget",
"from",
"the",
"window",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L242-L249 | train |
ddorn/GUI | GUI/vracabulous.py | Window.update_on_event | def update_on_event(self, e):
"""Process a single event."""
if e.type == QUIT:
self.running = False
elif e.type == KEYDOWN:
if e.key == K_ESCAPE:
self.running = False
elif e.key == K_F4 and e.mod & KMOD_ALT: # Alt+F4 --> quits
... | python | def update_on_event(self, e):
"""Process a single event."""
if e.type == QUIT:
self.running = False
elif e.type == KEYDOWN:
if e.key == K_ESCAPE:
self.running = False
elif e.key == K_F4 and e.mod & KMOD_ALT: # Alt+F4 --> quits
... | [
"def",
"update_on_event",
"(",
"self",
",",
"e",
")",
":",
"if",
"e",
".",
"type",
"==",
"QUIT",
":",
"self",
".",
"running",
"=",
"False",
"elif",
"e",
".",
"type",
"==",
"KEYDOWN",
":",
"if",
"e",
".",
"key",
"==",
"K_ESCAPE",
":",
"self",
".",... | Process a single event. | [
"Process",
"a",
"single",
"event",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L251-L265 | train |
ddorn/GUI | GUI/vracabulous.py | Window.update | def update(self):
"""Get all events and process them by calling update_on_event()"""
events = pygame.event.get()
for e in events:
self.update_on_event(e)
for wid, cond in self._widgets:
if cond():
wid.update(events) | python | def update(self):
"""Get all events and process them by calling update_on_event()"""
events = pygame.event.get()
for e in events:
self.update_on_event(e)
for wid, cond in self._widgets:
if cond():
wid.update(events) | [
"def",
"update",
"(",
"self",
")",
":",
"events",
"=",
"pygame",
".",
"event",
".",
"get",
"(",
")",
"for",
"e",
"in",
"events",
":",
"self",
".",
"update_on_event",
"(",
"e",
")",
"for",
"wid",
",",
"cond",
"in",
"self",
".",
"_widgets",
":",
"i... | Get all events and process them by calling update_on_event() | [
"Get",
"all",
"events",
"and",
"process",
"them",
"by",
"calling",
"update_on_event",
"()"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L267-L275 | train |
ddorn/GUI | GUI/vracabulous.py | Window.render | def render(self):
"""Render the screen. Here you must draw everything."""
self.screen.fill(self.BACKGROUND_COLOR)
for wid, cond in self._widgets:
if cond():
wid.render(self.screen)
if self.BORDER_COLOR is not None:
pygame.draw.rect(self.screen, s... | python | def render(self):
"""Render the screen. Here you must draw everything."""
self.screen.fill(self.BACKGROUND_COLOR)
for wid, cond in self._widgets:
if cond():
wid.render(self.screen)
if self.BORDER_COLOR is not None:
pygame.draw.rect(self.screen, s... | [
"def",
"render",
"(",
"self",
")",
":",
"self",
".",
"screen",
".",
"fill",
"(",
"self",
".",
"BACKGROUND_COLOR",
")",
"for",
"wid",
",",
"cond",
"in",
"self",
".",
"_widgets",
":",
"if",
"cond",
"(",
")",
":",
"wid",
".",
"render",
"(",
"self",
... | Render the screen. Here you must draw everything. | [
"Render",
"the",
"screen",
".",
"Here",
"you",
"must",
"draw",
"everything",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L277-L289 | train |
ddorn/GUI | GUI/vracabulous.py | Window.update_screen | def update_screen(self):
"""Refresh the screen. You don't need to override this except to update only small portins of the screen."""
self.clock.tick(self.FPS)
pygame.display.update() | python | def update_screen(self):
"""Refresh the screen. You don't need to override this except to update only small portins of the screen."""
self.clock.tick(self.FPS)
pygame.display.update() | [
"def",
"update_screen",
"(",
"self",
")",
":",
"self",
".",
"clock",
".",
"tick",
"(",
"self",
".",
"FPS",
")",
"pygame",
".",
"display",
".",
"update",
"(",
")"
] | Refresh the screen. You don't need to override this except to update only small portins of the screen. | [
"Refresh",
"the",
"screen",
".",
"You",
"don",
"t",
"need",
"to",
"override",
"this",
"except",
"to",
"update",
"only",
"small",
"portins",
"of",
"the",
"screen",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L292-L295 | train |
ddorn/GUI | GUI/vracabulous.py | Window.run | def run(self):
"""The run loop. Returns self.destroy()"""
while self.running:
self.update()
self.render()
self.update_screen()
return self.destroy() | python | def run(self):
"""The run loop. Returns self.destroy()"""
while self.running:
self.update()
self.render()
self.update_screen()
return self.destroy() | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"self",
".",
"running",
":",
"self",
".",
"update",
"(",
")",
"self",
".",
"render",
"(",
")",
"self",
".",
"update_screen",
"(",
")",
"return",
"self",
".",
"destroy",
"(",
")"
] | The run loop. Returns self.destroy() | [
"The",
"run",
"loop",
".",
"Returns",
"self",
".",
"destroy",
"()"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L302-L309 | train |
ddorn/GUI | GUI/vracabulous.py | Window.new_screen | def new_screen(self):
"""Makes a new screen with a size of SCREEN_SIZE, and VIDEO_OPTION as flags. Sets the windows name to NAME."""
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.display.set_caption(self.NAME)
screen_s = self.SCREEN_SIZE
video_options = self.VIDEO_OPTIONS
... | python | def new_screen(self):
"""Makes a new screen with a size of SCREEN_SIZE, and VIDEO_OPTION as flags. Sets the windows name to NAME."""
os.environ['SDL_VIDEO_CENTERED'] = '1'
pygame.display.set_caption(self.NAME)
screen_s = self.SCREEN_SIZE
video_options = self.VIDEO_OPTIONS
... | [
"def",
"new_screen",
"(",
"self",
")",
":",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"pygame",
".",
"display",
".",
"set_caption",
"(",
"self",
".",
"NAME",
")",
"screen_s",
"=",
"self",
".",
"SCREEN_SIZE",
"video_options",
"=",
... | Makes a new screen with a size of SCREEN_SIZE, and VIDEO_OPTION as flags. Sets the windows name to NAME. | [
"Makes",
"a",
"new",
"screen",
"with",
"a",
"size",
"of",
"SCREEN_SIZE",
"and",
"VIDEO_OPTION",
"as",
"flags",
".",
"Sets",
"the",
"windows",
"name",
"to",
"NAME",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L311-L334 | train |
ddorn/GUI | GUI/math.py | merge_rects | def merge_rects(rect1, rect2):
"""Return the smallest rect containning two rects"""
r = pygame.Rect(rect1)
t = pygame.Rect(rect2)
right = max(r.right, t.right)
bot = max(r.bottom, t.bottom)
x = min(t.x, r.x)
y = min(t.y, r.y)
return pygame.Rect(x, y, right - x, bot - y) | python | def merge_rects(rect1, rect2):
"""Return the smallest rect containning two rects"""
r = pygame.Rect(rect1)
t = pygame.Rect(rect2)
right = max(r.right, t.right)
bot = max(r.bottom, t.bottom)
x = min(t.x, r.x)
y = min(t.y, r.y)
return pygame.Rect(x, y, right - x, bot - y) | [
"def",
"merge_rects",
"(",
"rect1",
",",
"rect2",
")",
":",
"r",
"=",
"pygame",
".",
"Rect",
"(",
"rect1",
")",
"t",
"=",
"pygame",
".",
"Rect",
"(",
"rect2",
")",
"right",
"=",
"max",
"(",
"r",
".",
"right",
",",
"t",
".",
"right",
")",
"bot",... | Return the smallest rect containning two rects | [
"Return",
"the",
"smallest",
"rect",
"containning",
"two",
"rects"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/math.py#L18-L28 | train |
ddorn/GUI | GUI/math.py | V2.normnorm | def normnorm(self):
"""
Return a vecor noraml to this one with a norm of one
:return: V2
"""
n = self.norm()
return V2(-self.y / n, self.x / n) | python | def normnorm(self):
"""
Return a vecor noraml to this one with a norm of one
:return: V2
"""
n = self.norm()
return V2(-self.y / n, self.x / n) | [
"def",
"normnorm",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"norm",
"(",
")",
"return",
"V2",
"(",
"-",
"self",
".",
"y",
"/",
"n",
",",
"self",
".",
"x",
"/",
"n",
")"
] | Return a vecor noraml to this one with a norm of one
:return: V2 | [
"Return",
"a",
"vecor",
"noraml",
"to",
"this",
"one",
"with",
"a",
"norm",
"of",
"one"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/math.py#L109-L117 | train |
ddorn/GUI | GUI/draw.py | line | def line(surf, start, end, color=BLACK, width=1, style=FLAT):
"""Draws an antialiased line on the surface."""
width = round(width, 1)
if width == 1:
# return pygame.draw.aaline(surf, color, start, end)
return gfxdraw.line(surf, *start, *end, color)
start = V2(*start)
end = V2(*end)... | python | def line(surf, start, end, color=BLACK, width=1, style=FLAT):
"""Draws an antialiased line on the surface."""
width = round(width, 1)
if width == 1:
# return pygame.draw.aaline(surf, color, start, end)
return gfxdraw.line(surf, *start, *end, color)
start = V2(*start)
end = V2(*end)... | [
"def",
"line",
"(",
"surf",
",",
"start",
",",
"end",
",",
"color",
"=",
"BLACK",
",",
"width",
"=",
"1",
",",
"style",
"=",
"FLAT",
")",
":",
"width",
"=",
"round",
"(",
"width",
",",
"1",
")",
"if",
"width",
"==",
"1",
":",
"# return pygame.dra... | Draws an antialiased line on the surface. | [
"Draws",
"an",
"antialiased",
"line",
"on",
"the",
"surface",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L17-L52 | train |
ddorn/GUI | GUI/draw.py | circle | def circle(surf, xy, r, color=BLACK):
"""Draw an antialiased filled circle on the given surface"""
x, y = xy
x = round(x)
y = round(y)
r = round(r)
gfxdraw.filled_circle(surf, x, y, r, color)
gfxdraw.aacircle(surf, x, y, r, color)
r += 1
return pygame.Rect(x - r, y - r, 2 * r, 2 ... | python | def circle(surf, xy, r, color=BLACK):
"""Draw an antialiased filled circle on the given surface"""
x, y = xy
x = round(x)
y = round(y)
r = round(r)
gfxdraw.filled_circle(surf, x, y, r, color)
gfxdraw.aacircle(surf, x, y, r, color)
r += 1
return pygame.Rect(x - r, y - r, 2 * r, 2 ... | [
"def",
"circle",
"(",
"surf",
",",
"xy",
",",
"r",
",",
"color",
"=",
"BLACK",
")",
":",
"x",
",",
"y",
"=",
"xy",
"x",
"=",
"round",
"(",
"x",
")",
"y",
"=",
"round",
"(",
"y",
")",
"r",
"=",
"round",
"(",
"r",
")",
"gfxdraw",
".",
"fill... | Draw an antialiased filled circle on the given surface | [
"Draw",
"an",
"antialiased",
"filled",
"circle",
"on",
"the",
"given",
"surface"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L55-L68 | train |
ddorn/GUI | GUI/draw.py | ring | def ring(surf, xy, r, width, color):
"""Draws a ring"""
r2 = r - width
x0, y0 = xy
x = r2
y = 0
err = 0
# collect points of the inner circle
right = {}
while x >= y:
right[x] = y
right[y] = x
right[-x] = y
right[-y] = x
y += 1
if er... | python | def ring(surf, xy, r, width, color):
"""Draws a ring"""
r2 = r - width
x0, y0 = xy
x = r2
y = 0
err = 0
# collect points of the inner circle
right = {}
while x >= y:
right[x] = y
right[y] = x
right[-x] = y
right[-y] = x
y += 1
if er... | [
"def",
"ring",
"(",
"surf",
",",
"xy",
",",
"r",
",",
"width",
",",
"color",
")",
":",
"r2",
"=",
"r",
"-",
"width",
"x0",
",",
"y0",
"=",
"xy",
"x",
"=",
"r2",
"y",
"=",
"0",
"err",
"=",
"0",
"# collect points of the inner circle",
"right",
"=",... | Draws a ring | [
"Draws",
"a",
"ring"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L71-L122 | train |
ddorn/GUI | GUI/draw.py | roundrect | def roundrect(surface, rect, color, rounding=5, unit=PIXEL):
"""
Draw an antialiased round rectangle on the surface.
surface : destination
rect : rectangle
color : rgb or rgba
radius : 0 <= radius <= 1
:source: http://pygame.org/project-AAfilledRoundedRect-2349-.html
"""
if u... | python | def roundrect(surface, rect, color, rounding=5, unit=PIXEL):
"""
Draw an antialiased round rectangle on the surface.
surface : destination
rect : rectangle
color : rgb or rgba
radius : 0 <= radius <= 1
:source: http://pygame.org/project-AAfilledRoundedRect-2349-.html
"""
if u... | [
"def",
"roundrect",
"(",
"surface",
",",
"rect",
",",
"color",
",",
"rounding",
"=",
"5",
",",
"unit",
"=",
"PIXEL",
")",
":",
"if",
"unit",
"==",
"PERCENT",
":",
"rounding",
"=",
"int",
"(",
"min",
"(",
"rect",
".",
"size",
")",
"/",
"2",
"*",
... | Draw an antialiased round rectangle on the surface.
surface : destination
rect : rectangle
color : rgb or rgba
radius : 0 <= radius <= 1
:source: http://pygame.org/project-AAfilledRoundedRect-2349-.html | [
"Draw",
"an",
"antialiased",
"round",
"rectangle",
"on",
"the",
"surface",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L125-L165 | train |
ddorn/GUI | GUI/draw.py | polygon | def polygon(surf, points, color):
"""Draw an antialiased filled polygon on a surface"""
gfxdraw.aapolygon(surf, points, color)
gfxdraw.filled_polygon(surf, points, color)
x = min([x for (x, y) in points])
y = min([y for (x, y) in points])
xm = max([x for (x, y) in points])
ym = max([y for ... | python | def polygon(surf, points, color):
"""Draw an antialiased filled polygon on a surface"""
gfxdraw.aapolygon(surf, points, color)
gfxdraw.filled_polygon(surf, points, color)
x = min([x for (x, y) in points])
y = min([y for (x, y) in points])
xm = max([x for (x, y) in points])
ym = max([y for ... | [
"def",
"polygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
":",
"gfxdraw",
".",
"aapolygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
"gfxdraw",
".",
"filled_polygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
"x",
"=",
"min",
"(",
... | Draw an antialiased filled polygon on a surface | [
"Draw",
"an",
"antialiased",
"filled",
"polygon",
"on",
"a",
"surface"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L168-L179 | train |
ddorn/GUI | GUI/buttons.py | BaseButton.click | def click(self, force_no_call=False, milis=None):
"""
Call when the button is pressed. This start the callback function in a thread
If :milis is given, will release the button after :milis miliseconds
"""
if self.clicked:
return False
if not force_no_call an... | python | def click(self, force_no_call=False, milis=None):
"""
Call when the button is pressed. This start the callback function in a thread
If :milis is given, will release the button after :milis miliseconds
"""
if self.clicked:
return False
if not force_no_call an... | [
"def",
"click",
"(",
"self",
",",
"force_no_call",
"=",
"False",
",",
"milis",
"=",
"None",
")",
":",
"if",
"self",
".",
"clicked",
":",
"return",
"False",
"if",
"not",
"force_no_call",
"and",
"self",
".",
"flags",
"&",
"self",
".",
"CALL_ON_PRESS",
":... | Call when the button is pressed. This start the callback function in a thread
If :milis is given, will release the button after :milis miliseconds | [
"Call",
"when",
"the",
"button",
"is",
"pressed",
".",
"This",
"start",
"the",
"callback",
"function",
"in",
"a",
"thread",
"If",
":",
"milis",
"is",
"given",
"will",
"release",
"the",
"button",
"after",
":",
"milis",
"miliseconds"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L42-L60 | train |
ddorn/GUI | GUI/buttons.py | Button._get_color | def _get_color(self):
"""Return the color of the button, depending on its state"""
if self.clicked and self.hovered: # the mouse is over the button
color = mix(self.color, BLACK, 0.8)
elif self.hovered and not self.flags & self.NO_HOVER:
color = mix(self.color, BLACK, 0... | python | def _get_color(self):
"""Return the color of the button, depending on its state"""
if self.clicked and self.hovered: # the mouse is over the button
color = mix(self.color, BLACK, 0.8)
elif self.hovered and not self.flags & self.NO_HOVER:
color = mix(self.color, BLACK, 0... | [
"def",
"_get_color",
"(",
"self",
")",
":",
"if",
"self",
".",
"clicked",
"and",
"self",
".",
"hovered",
":",
"# the mouse is over the button",
"color",
"=",
"mix",
"(",
"self",
".",
"color",
",",
"BLACK",
",",
"0.8",
")",
"elif",
"self",
".",
"hovered",... | Return the color of the button, depending on its state | [
"Return",
"the",
"color",
"of",
"the",
"button",
"depending",
"on",
"its",
"state"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L118-L130 | train |
ddorn/GUI | GUI/buttons.py | Button._front_delta | def _front_delta(self):
"""Return the offset of the colored part."""
if self.flags & self.NO_MOVE:
return Separator(0, 0)
if self.clicked and self.hovered: # the mouse is over the button
delta = 2
elif self.hovered and not self.flags & self.NO_HOVER:
... | python | def _front_delta(self):
"""Return the offset of the colored part."""
if self.flags & self.NO_MOVE:
return Separator(0, 0)
if self.clicked and self.hovered: # the mouse is over the button
delta = 2
elif self.hovered and not self.flags & self.NO_HOVER:
... | [
"def",
"_front_delta",
"(",
"self",
")",
":",
"if",
"self",
".",
"flags",
"&",
"self",
".",
"NO_MOVE",
":",
"return",
"Separator",
"(",
"0",
",",
"0",
")",
"if",
"self",
".",
"clicked",
"and",
"self",
".",
"hovered",
":",
"# the mouse is over the button"... | Return the offset of the colored part. | [
"Return",
"the",
"offset",
"of",
"the",
"colored",
"part",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L133-L147 | train |
ddorn/GUI | GUI/buttons.py | Button.update | def update(self, event_or_list):
"""Update the button with the events."""
for e in super().update(event_or_list):
if e.type == MOUSEBUTTONDOWN:
if e.pos in self:
self.click()
else:
self.release(force_no_call=True)
... | python | def update(self, event_or_list):
"""Update the button with the events."""
for e in super().update(event_or_list):
if e.type == MOUSEBUTTONDOWN:
if e.pos in self:
self.click()
else:
self.release(force_no_call=True)
... | [
"def",
"update",
"(",
"self",
",",
"event_or_list",
")",
":",
"for",
"e",
"in",
"super",
"(",
")",
".",
"update",
"(",
"event_or_list",
")",
":",
"if",
"e",
".",
"type",
"==",
"MOUSEBUTTONDOWN",
":",
"if",
"e",
".",
"pos",
"in",
"self",
":",
"self"... | Update the button with the events. | [
"Update",
"the",
"button",
"with",
"the",
"events",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L166-L183 | train |
ddorn/GUI | GUI/buttons.py | Button.render | def render(self, surf):
"""Render the button on a surface."""
pos, size = self.topleft, self.size
if not self.flags & self.NO_SHADOW:
if self.flags & self.NO_ROUNDING:
pygame.draw.rect(surf, LIGHT_GREY, (pos + self._bg_delta, size))
else:
... | python | def render(self, surf):
"""Render the button on a surface."""
pos, size = self.topleft, self.size
if not self.flags & self.NO_SHADOW:
if self.flags & self.NO_ROUNDING:
pygame.draw.rect(surf, LIGHT_GREY, (pos + self._bg_delta, size))
else:
... | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"pos",
",",
"size",
"=",
"self",
".",
"topleft",
",",
"self",
".",
"size",
"if",
"not",
"self",
".",
"flags",
"&",
"self",
".",
"NO_SHADOW",
":",
"if",
"self",
".",
"flags",
"&",
"self",
".",
... | Render the button on a surface. | [
"Render",
"the",
"button",
"on",
"a",
"surface",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L185-L201 | train |
ddorn/GUI | GUI/buttons.py | RoundButton.render | def render(self, surf):
"""Draw the button on the surface."""
if not self.flags & self.NO_SHADOW:
circle(surf, self.center + self._bg_delta, self.width / 2, LIGHT_GREY)
circle(surf, self.center + self._front_delta, self.width / 2, self._get_color())
self.text.center = self.c... | python | def render(self, surf):
"""Draw the button on the surface."""
if not self.flags & self.NO_SHADOW:
circle(surf, self.center + self._bg_delta, self.width / 2, LIGHT_GREY)
circle(surf, self.center + self._front_delta, self.width / 2, self._get_color())
self.text.center = self.c... | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"if",
"not",
"self",
".",
"flags",
"&",
"self",
".",
"NO_SHADOW",
":",
"circle",
"(",
"surf",
",",
"self",
".",
"center",
"+",
"self",
".",
"_bg_delta",
",",
"self",
".",
"width",
"/",
"2",
","... | Draw the button on the surface. | [
"Draw",
"the",
"button",
"on",
"the",
"surface",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L211-L218 | train |
ddorn/GUI | GUI/buttons.py | IconButton.get_darker_image | def get_darker_image(self):
"""Returns an icon 80% more dark"""
icon_pressed = self.icon.copy()
for x in range(self.w):
for y in range(self.h):
r, g, b, *_ = tuple(self.icon.get_at((x, y)))
const = 0.8
r = int(const * r)
... | python | def get_darker_image(self):
"""Returns an icon 80% more dark"""
icon_pressed = self.icon.copy()
for x in range(self.w):
for y in range(self.h):
r, g, b, *_ = tuple(self.icon.get_at((x, y)))
const = 0.8
r = int(const * r)
... | [
"def",
"get_darker_image",
"(",
"self",
")",
":",
"icon_pressed",
"=",
"self",
".",
"icon",
".",
"copy",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"self",
".",
"w",
")",
":",
"for",
"y",
"in",
"range",
"(",
"self",
".",
"h",
")",
":",
"r",
",",... | Returns an icon 80% more dark | [
"Returns",
"an",
"icon",
"80%",
"more",
"dark"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L244-L257 | train |
ddorn/GUI | GUI/buttons.py | IconButton.render | def render(self, surf):
"""Render the button"""
if self.clicked:
icon = self.icon_pressed
else:
icon = self.icon
surf.blit(icon, self) | python | def render(self, surf):
"""Render the button"""
if self.clicked:
icon = self.icon_pressed
else:
icon = self.icon
surf.blit(icon, self) | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"if",
"self",
".",
"clicked",
":",
"icon",
"=",
"self",
".",
"icon_pressed",
"else",
":",
"icon",
"=",
"self",
".",
"icon",
"surf",
".",
"blit",
"(",
"icon",
",",
"self",
")"
] | Render the button | [
"Render",
"the",
"button"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L259-L267 | train |
ddorn/GUI | GUI/buttons.py | SlideBar.set | def set(self, value):
"""Set the value of the bar. If the value is out of bound, sets it to an extremum"""
value = min(self.max, max(self.min, value))
self._value = value
start_new_thread(self.func, (self.get(),)) | python | def set(self, value):
"""Set the value of the bar. If the value is out of bound, sets it to an extremum"""
value = min(self.max, max(self.min, value))
self._value = value
start_new_thread(self.func, (self.get(),)) | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"min",
"(",
"self",
".",
"max",
",",
"max",
"(",
"self",
".",
"min",
",",
"value",
")",
")",
"self",
".",
"_value",
"=",
"value",
"start_new_thread",
"(",
"self",
".",
"func",
",",
... | Set the value of the bar. If the value is out of bound, sets it to an extremum | [
"Set",
"the",
"value",
"of",
"the",
"bar",
".",
"If",
"the",
"value",
"is",
"out",
"of",
"bound",
"sets",
"it",
"to",
"an",
"extremum"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L327-L331 | train |
ddorn/GUI | GUI/buttons.py | SlideBar._start | def _start(self):
"""Starts checking if the SB is shifted"""
# TODO : make an update method instead
last_call = 42
while self._focus:
sleep(1 / 100)
mouse = pygame.mouse.get_pos()
last_value = self.get()
self.value_px = mouse[0]
... | python | def _start(self):
"""Starts checking if the SB is shifted"""
# TODO : make an update method instead
last_call = 42
while self._focus:
sleep(1 / 100)
mouse = pygame.mouse.get_pos()
last_value = self.get()
self.value_px = mouse[0]
... | [
"def",
"_start",
"(",
"self",
")",
":",
"# TODO : make an update method instead",
"last_call",
"=",
"42",
"while",
"self",
".",
"_focus",
":",
"sleep",
"(",
"1",
"/",
"100",
")",
"mouse",
"=",
"pygame",
".",
"mouse",
".",
"get_pos",
"(",
")",
"last_value",... | Starts checking if the SB is shifted | [
"Starts",
"checking",
"if",
"the",
"SB",
"is",
"shifted"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L333-L352 | train |
ddorn/GUI | GUI/buttons.py | SlideBar.value_px | def value_px(self):
"""The position in pixels of the cursor"""
step = self.w / (self.max - self.min)
return self.x + step * (self.get() - self.min) | python | def value_px(self):
"""The position in pixels of the cursor"""
step = self.w / (self.max - self.min)
return self.x + step * (self.get() - self.min) | [
"def",
"value_px",
"(",
"self",
")",
":",
"step",
"=",
"self",
".",
"w",
"/",
"(",
"self",
".",
"max",
"-",
"self",
".",
"min",
")",
"return",
"self",
".",
"x",
"+",
"step",
"*",
"(",
"self",
".",
"get",
"(",
")",
"-",
"self",
".",
"min",
"... | The position in pixels of the cursor | [
"The",
"position",
"in",
"pixels",
"of",
"the",
"cursor"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L361-L364 | train |
ddorn/GUI | GUI/buttons.py | SlideBar.render | def render(self, display):
"""Renders the bar on the display"""
# the bar
bar_rect = pygame.Rect(0, 0, self.width, self.height // 3)
bar_rect.center = self.center
display.fill(self.bg_color, bar_rect)
# the cursor
circle(display, (self.value_px, self.centery), s... | python | def render(self, display):
"""Renders the bar on the display"""
# the bar
bar_rect = pygame.Rect(0, 0, self.width, self.height // 3)
bar_rect.center = self.center
display.fill(self.bg_color, bar_rect)
# the cursor
circle(display, (self.value_px, self.centery), s... | [
"def",
"render",
"(",
"self",
",",
"display",
")",
":",
"# the bar",
"bar_rect",
"=",
"pygame",
".",
"Rect",
"(",
"0",
",",
"0",
",",
"self",
".",
"width",
",",
"self",
".",
"height",
"//",
"3",
")",
"bar_rect",
".",
"center",
"=",
"self",
".",
"... | Renders the bar on the display | [
"Renders",
"the",
"bar",
"on",
"the",
"display"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L375-L388 | train |
ddorn/GUI | GUI/base.py | BaseWidget.__update | def __update(self):
"""
This is called each time an attribute is asked, to be sure every params are updated, beceause of callbacks.
"""
# I can not set the size attr because it is my property, so I set the width and height separately
width, height = self.size
super(BaseW... | python | def __update(self):
"""
This is called each time an attribute is asked, to be sure every params are updated, beceause of callbacks.
"""
# I can not set the size attr because it is my property, so I set the width and height separately
width, height = self.size
super(BaseW... | [
"def",
"__update",
"(",
"self",
")",
":",
"# I can not set the size attr because it is my property, so I set the width and height separately",
"width",
",",
"height",
"=",
"self",
".",
"size",
"super",
"(",
"BaseWidget",
",",
"self",
")",
".",
"__setattr__",
"(",
"\"wid... | This is called each time an attribute is asked, to be sure every params are updated, beceause of callbacks. | [
"This",
"is",
"called",
"each",
"time",
"an",
"attribute",
"is",
"asked",
"to",
"be",
"sure",
"every",
"params",
"are",
"updated",
"beceause",
"of",
"callbacks",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/base.py#L83-L92 | train |
erikrose/peep | peep.py | activate | def activate(specifier):
"""Make a compatible version of pip importable. Raise a RuntimeError if we
couldn't."""
try:
for distro in require(specifier):
distro.activate()
except (VersionConflict, DistributionNotFound):
raise RuntimeError('The installed version of pip is too ol... | python | def activate(specifier):
"""Make a compatible version of pip importable. Raise a RuntimeError if we
couldn't."""
try:
for distro in require(specifier):
distro.activate()
except (VersionConflict, DistributionNotFound):
raise RuntimeError('The installed version of pip is too ol... | [
"def",
"activate",
"(",
"specifier",
")",
":",
"try",
":",
"for",
"distro",
"in",
"require",
"(",
"specifier",
")",
":",
"distro",
".",
"activate",
"(",
")",
"except",
"(",
"VersionConflict",
",",
"DistributionNotFound",
")",
":",
"raise",
"RuntimeError",
... | Make a compatible version of pip importable. Raise a RuntimeError if we
couldn't. | [
"Make",
"a",
"compatible",
"version",
"of",
"pip",
"importable",
".",
"Raise",
"a",
"RuntimeError",
"if",
"we",
"couldn",
"t",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L65-L73 | train |
erikrose/peep | peep.py | path_and_line | def path_and_line(req):
"""Return the path and line number of the file from which an
InstallRequirement came.
"""
path, line = (re.match(r'-r (.*) \(line (\d+)\)$',
req.comes_from).groups())
return path, int(line) | python | def path_and_line(req):
"""Return the path and line number of the file from which an
InstallRequirement came.
"""
path, line = (re.match(r'-r (.*) \(line (\d+)\)$',
req.comes_from).groups())
return path, int(line) | [
"def",
"path_and_line",
"(",
"req",
")",
":",
"path",
",",
"line",
"=",
"(",
"re",
".",
"match",
"(",
"r'-r (.*) \\(line (\\d+)\\)$'",
",",
"req",
".",
"comes_from",
")",
".",
"groups",
"(",
")",
")",
"return",
"path",
",",
"int",
"(",
"line",
")"
] | Return the path and line number of the file from which an
InstallRequirement came. | [
"Return",
"the",
"path",
"and",
"line",
"number",
"of",
"the",
"file",
"from",
"which",
"an",
"InstallRequirement",
"came",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L164-L171 | train |
erikrose/peep | peep.py | hashes_above | def hashes_above(path, line_number):
"""Yield hashes from contiguous comment lines before line ``line_number``.
"""
def hash_lists(path):
"""Yield lists of hashes appearing between non-comment lines.
The lists will be in order of appearance and, for each non-empty
list, their place... | python | def hashes_above(path, line_number):
"""Yield hashes from contiguous comment lines before line ``line_number``.
"""
def hash_lists(path):
"""Yield lists of hashes appearing between non-comment lines.
The lists will be in order of appearance and, for each non-empty
list, their place... | [
"def",
"hashes_above",
"(",
"path",
",",
"line_number",
")",
":",
"def",
"hash_lists",
"(",
"path",
")",
":",
"\"\"\"Yield lists of hashes appearing between non-comment lines.\n\n The lists will be in order of appearance and, for each non-empty\n list, their place in the re... | Yield hashes from contiguous comment lines before line ``line_number``. | [
"Yield",
"hashes",
"from",
"contiguous",
"comment",
"lines",
"before",
"line",
"line_number",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L174-L200 | train |
erikrose/peep | peep.py | run_pip | def run_pip(initial_args):
"""Delegate to pip the given args (starting with the subcommand), and raise
``PipException`` if something goes wrong."""
status_code = pip.main(initial_args)
# Clear out the registrations in the pip "logger" singleton. Otherwise,
# loggers keep getting appended to it with... | python | def run_pip(initial_args):
"""Delegate to pip the given args (starting with the subcommand), and raise
``PipException`` if something goes wrong."""
status_code = pip.main(initial_args)
# Clear out the registrations in the pip "logger" singleton. Otherwise,
# loggers keep getting appended to it with... | [
"def",
"run_pip",
"(",
"initial_args",
")",
":",
"status_code",
"=",
"pip",
".",
"main",
"(",
"initial_args",
")",
"# Clear out the registrations in the pip \"logger\" singleton. Otherwise,",
"# loggers keep getting appended to it with every run. Pip assumes only one",
"# command inv... | Delegate to pip the given args (starting with the subcommand), and raise
``PipException`` if something goes wrong. | [
"Delegate",
"to",
"pip",
"the",
"given",
"args",
"(",
"starting",
"with",
"the",
"subcommand",
")",
"and",
"raise",
"PipException",
"if",
"something",
"goes",
"wrong",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L203-L214 | train |
erikrose/peep | peep.py | hash_of_file | def hash_of_file(path):
"""Return the hash of a downloaded file."""
with open(path, 'rb') as archive:
sha = sha256()
while True:
data = archive.read(2 ** 20)
if not data:
break
sha.update(data)
return encoded_hash(sha) | python | def hash_of_file(path):
"""Return the hash of a downloaded file."""
with open(path, 'rb') as archive:
sha = sha256()
while True:
data = archive.read(2 ** 20)
if not data:
break
sha.update(data)
return encoded_hash(sha) | [
"def",
"hash_of_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"archive",
":",
"sha",
"=",
"sha256",
"(",
")",
"while",
"True",
":",
"data",
"=",
"archive",
".",
"read",
"(",
"2",
"**",
"20",
")",
"if",
"not",
... | Return the hash of a downloaded file. | [
"Return",
"the",
"hash",
"of",
"a",
"downloaded",
"file",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L217-L226 | train |
erikrose/peep | peep.py | requirement_args | def requirement_args(argv, want_paths=False, want_other=False):
"""Return an iterable of filtered arguments.
:arg argv: Arguments, starting after the subcommand
:arg want_paths: If True, the returned iterable includes the paths to any
requirements files following a ``-r`` or ``--requirement`` optio... | python | def requirement_args(argv, want_paths=False, want_other=False):
"""Return an iterable of filtered arguments.
:arg argv: Arguments, starting after the subcommand
:arg want_paths: If True, the returned iterable includes the paths to any
requirements files following a ``-r`` or ``--requirement`` optio... | [
"def",
"requirement_args",
"(",
"argv",
",",
"want_paths",
"=",
"False",
",",
"want_other",
"=",
"False",
")",
":",
"was_r",
"=",
"False",
"for",
"arg",
"in",
"argv",
":",
"# Allow for requirements files named \"-r\", don't freak out if there's a",
"# trailing \"-r\", e... | Return an iterable of filtered arguments.
:arg argv: Arguments, starting after the subcommand
:arg want_paths: If True, the returned iterable includes the paths to any
requirements files following a ``-r`` or ``--requirement`` option.
:arg want_other: If True, the returned iterable includes the arg... | [
"Return",
"an",
"iterable",
"of",
"filtered",
"arguments",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L247-L269 | train |
erikrose/peep | peep.py | peep_hash | def peep_hash(argv):
"""Return the peep hash of one or more files, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand
"""
parser = OptionParser(
usage='usage: %prog hash file [file ...]',
description='Print a peep... | python | def peep_hash(argv):
"""Return the peep hash of one or more files, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand
"""
parser = OptionParser(
usage='usage: %prog hash file [file ...]',
description='Print a peep... | [
"def",
"peep_hash",
"(",
"argv",
")",
":",
"parser",
"=",
"OptionParser",
"(",
"usage",
"=",
"'usage: %prog hash file [file ...]'",
",",
"description",
"=",
"'Print a peep hash line for one or more files: for '",
"'example, \"# sha256: '",
"'oz42dZy6Gowxw8AelDtO4gRgTW_xPdooH484k7... | Return the peep hash of one or more files, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand | [
"Return",
"the",
"peep",
"hash",
"of",
"one",
"or",
"more",
"files",
"returning",
"a",
"shell",
"status",
"code",
"or",
"raising",
"a",
"PipException",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L287-L306 | train |
erikrose/peep | peep.py | memoize | def memoize(func):
"""Memoize a method that should return the same result every time on a
given instance.
"""
@wraps(func)
def memoizer(self):
if not hasattr(self, '_cache'):
self._cache = {}
if func.__name__ not in self._cache:
self._cache[func.__name__] = f... | python | def memoize(func):
"""Memoize a method that should return the same result every time on a
given instance.
"""
@wraps(func)
def memoizer(self):
if not hasattr(self, '_cache'):
self._cache = {}
if func.__name__ not in self._cache:
self._cache[func.__name__] = f... | [
"def",
"memoize",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"memoizer",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_cache'",
")",
":",
"self",
".",
"_cache",
"=",
"{",
"}",
"if",
"func",
".",
"__name__"... | Memoize a method that should return the same result every time on a
given instance. | [
"Memoize",
"a",
"method",
"that",
"should",
"return",
"the",
"same",
"result",
"every",
"time",
"on",
"a",
"given",
"instance",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L321-L333 | train |
erikrose/peep | peep.py | package_finder | def package_finder(argv):
"""Return a PackageFinder respecting command-line options.
:arg argv: Everything after the subcommand
"""
# We instantiate an InstallCommand and then use some of its private
# machinery--its arg parser--for our own purposes, like a virus. This
# approach is portable a... | python | def package_finder(argv):
"""Return a PackageFinder respecting command-line options.
:arg argv: Everything after the subcommand
"""
# We instantiate an InstallCommand and then use some of its private
# machinery--its arg parser--for our own purposes, like a virus. This
# approach is portable a... | [
"def",
"package_finder",
"(",
"argv",
")",
":",
"# We instantiate an InstallCommand and then use some of its private",
"# machinery--its arg parser--for our own purposes, like a virus. This",
"# approach is portable across many pip versions, where more fine-grained",
"# ones are not. Ignoring opti... | Return a PackageFinder respecting command-line options.
:arg argv: Everything after the subcommand | [
"Return",
"a",
"PackageFinder",
"respecting",
"command",
"-",
"line",
"options",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L336-L390 | train |
erikrose/peep | peep.py | bucket | def bucket(things, key):
"""Return a map of key -> list of things."""
ret = defaultdict(list)
for thing in things:
ret[key(thing)].append(thing)
return ret | python | def bucket(things, key):
"""Return a map of key -> list of things."""
ret = defaultdict(list)
for thing in things:
ret[key(thing)].append(thing)
return ret | [
"def",
"bucket",
"(",
"things",
",",
"key",
")",
":",
"ret",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"thing",
"in",
"things",
":",
"ret",
"[",
"key",
"(",
"thing",
")",
"]",
".",
"append",
"(",
"thing",
")",
"return",
"ret"
] | Return a map of key -> list of things. | [
"Return",
"a",
"map",
"of",
"key",
"-",
">",
"list",
"of",
"things",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L793-L798 | train |
erikrose/peep | peep.py | first_every_last | def first_every_last(iterable, first, every, last):
"""Execute something before the first item of iter, something else for each
item, and a third thing after the last.
If there are no items in the iterable, don't execute anything.
"""
did_first = False
for item in iterable:
if not did_... | python | def first_every_last(iterable, first, every, last):
"""Execute something before the first item of iter, something else for each
item, and a third thing after the last.
If there are no items in the iterable, don't execute anything.
"""
did_first = False
for item in iterable:
if not did_... | [
"def",
"first_every_last",
"(",
"iterable",
",",
"first",
",",
"every",
",",
"last",
")",
":",
"did_first",
"=",
"False",
"for",
"item",
"in",
"iterable",
":",
"if",
"not",
"did_first",
":",
"did_first",
"=",
"True",
"first",
"(",
"item",
")",
"every",
... | Execute something before the first item of iter, something else for each
item, and a third thing after the last.
If there are no items in the iterable, don't execute anything. | [
"Execute",
"something",
"before",
"the",
"first",
"item",
"of",
"iter",
"something",
"else",
"for",
"each",
"item",
"and",
"a",
"third",
"thing",
"after",
"the",
"last",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L801-L815 | train |
erikrose/peep | peep.py | downloaded_reqs_from_path | def downloaded_reqs_from_path(path, argv):
"""Return a list of DownloadedReqs representing the requirements parsed
out of a given requirements file.
:arg path: The path to the requirements file
:arg argv: The commandline args, starting after the subcommand
"""
finder = package_finder(argv)
... | python | def downloaded_reqs_from_path(path, argv):
"""Return a list of DownloadedReqs representing the requirements parsed
out of a given requirements file.
:arg path: The path to the requirements file
:arg argv: The commandline args, starting after the subcommand
"""
finder = package_finder(argv)
... | [
"def",
"downloaded_reqs_from_path",
"(",
"path",
",",
"argv",
")",
":",
"finder",
"=",
"package_finder",
"(",
"argv",
")",
"return",
"[",
"DownloadedReq",
"(",
"req",
",",
"argv",
",",
"finder",
")",
"for",
"req",
"in",
"_parse_requirements",
"(",
"path",
... | Return a list of DownloadedReqs representing the requirements parsed
out of a given requirements file.
:arg path: The path to the requirements file
:arg argv: The commandline args, starting after the subcommand | [
"Return",
"a",
"list",
"of",
"DownloadedReqs",
"representing",
"the",
"requirements",
"parsed",
"out",
"of",
"a",
"given",
"requirements",
"file",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L834-L844 | train |
erikrose/peep | peep.py | peep_install | def peep_install(argv):
"""Perform the ``peep install`` subcommand, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand
"""
output = []
out = output.append
reqs = []
try:
req_paths = list(requirement_args(argv,... | python | def peep_install(argv):
"""Perform the ``peep install`` subcommand, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand
"""
output = []
out = output.append
reqs = []
try:
req_paths = list(requirement_args(argv,... | [
"def",
"peep_install",
"(",
"argv",
")",
":",
"output",
"=",
"[",
"]",
"out",
"=",
"output",
".",
"append",
"reqs",
"=",
"[",
"]",
"try",
":",
"req_paths",
"=",
"list",
"(",
"requirement_args",
"(",
"argv",
",",
"want_paths",
"=",
"True",
")",
")",
... | Perform the ``peep install`` subcommand, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand | [
"Perform",
"the",
"peep",
"install",
"subcommand",
"returning",
"a",
"shell",
"status",
"code",
"or",
"raising",
"a",
"PipException",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L847-L898 | train |
erikrose/peep | peep.py | peep_port | def peep_port(paths):
"""Convert a peep requirements file to one compatble with pip-8 hashing.
Loses comments and tromps on URLs, so the result will need a little manual
massaging, but the hard part--the hash conversion--is done for you.
"""
if not paths:
print('Please specify one or more ... | python | def peep_port(paths):
"""Convert a peep requirements file to one compatble with pip-8 hashing.
Loses comments and tromps on URLs, so the result will need a little manual
massaging, but the hard part--the hash conversion--is done for you.
"""
if not paths:
print('Please specify one or more ... | [
"def",
"peep_port",
"(",
"paths",
")",
":",
"if",
"not",
"paths",
":",
"print",
"(",
"'Please specify one or more requirements files so I have '",
"'something to port.\\n'",
")",
"return",
"COMMAND_LINE_ERROR",
"comes_from",
"=",
"None",
"for",
"req",
"in",
"chain",
"... | Convert a peep requirements file to one compatble with pip-8 hashing.
Loses comments and tromps on URLs, so the result will need a little manual
massaging, but the hard part--the hash conversion--is done for you. | [
"Convert",
"a",
"peep",
"requirements",
"file",
"to",
"one",
"compatble",
"with",
"pip",
"-",
"8",
"hashing",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L901-L932 | train |
erikrose/peep | peep.py | main | def main():
"""Be the top-level entrypoint. Return a shell status code."""
commands = {'hash': peep_hash,
'install': peep_install,
'port': peep_port}
try:
if len(argv) >= 2 and argv[1] in commands:
return commands[argv[1]](argv[2:])
else:
... | python | def main():
"""Be the top-level entrypoint. Return a shell status code."""
commands = {'hash': peep_hash,
'install': peep_install,
'port': peep_port}
try:
if len(argv) >= 2 and argv[1] in commands:
return commands[argv[1]](argv[2:])
else:
... | [
"def",
"main",
"(",
")",
":",
"commands",
"=",
"{",
"'hash'",
":",
"peep_hash",
",",
"'install'",
":",
"peep_install",
",",
"'port'",
":",
"peep_port",
"}",
"try",
":",
"if",
"len",
"(",
"argv",
")",
">=",
"2",
"and",
"argv",
"[",
"1",
"]",
"in",
... | Be the top-level entrypoint. Return a shell status code. | [
"Be",
"the",
"top",
"-",
"level",
"entrypoint",
".",
"Return",
"a",
"shell",
"status",
"code",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L935-L947 | train |
erikrose/peep | peep.py | DownloadedReq._version | def _version(self):
"""Deduce the version number of the downloaded package from its filename."""
# TODO: Can we delete this method and just print the line from the
# reqs file verbatim instead?
def version_of_archive(filename, package_name):
# Since we know the project_name, ... | python | def _version(self):
"""Deduce the version number of the downloaded package from its filename."""
# TODO: Can we delete this method and just print the line from the
# reqs file verbatim instead?
def version_of_archive(filename, package_name):
# Since we know the project_name, ... | [
"def",
"_version",
"(",
"self",
")",
":",
"# TODO: Can we delete this method and just print the line from the",
"# reqs file verbatim instead?",
"def",
"version_of_archive",
"(",
"filename",
",",
"package_name",
")",
":",
"# Since we know the project_name, we can strip that off the l... | Deduce the version number of the downloaded package from its filename. | [
"Deduce",
"the",
"version",
"number",
"of",
"the",
"downloaded",
"package",
"from",
"its",
"filename",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L432-L471 | train |
erikrose/peep | peep.py | DownloadedReq._is_always_unsatisfied | def _is_always_unsatisfied(self):
"""Returns whether this requirement is always unsatisfied
This would happen in cases where we can't determine the version
from the filename.
"""
# If this is a github sha tarball, then it is always unsatisfied
# because the url has a co... | python | def _is_always_unsatisfied(self):
"""Returns whether this requirement is always unsatisfied
This would happen in cases where we can't determine the version
from the filename.
"""
# If this is a github sha tarball, then it is always unsatisfied
# because the url has a co... | [
"def",
"_is_always_unsatisfied",
"(",
"self",
")",
":",
"# If this is a github sha tarball, then it is always unsatisfied",
"# because the url has a commit sha in it and not the version",
"# number.",
"url",
"=",
"self",
".",
"_url",
"(",
")",
"if",
"url",
":",
"filename",
"=... | Returns whether this requirement is always unsatisfied
This would happen in cases where we can't determine the version
from the filename. | [
"Returns",
"whether",
"this",
"requirement",
"is",
"always",
"unsatisfied"
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L473-L490 | train |
erikrose/peep | peep.py | DownloadedReq._download | def _download(self, link):
"""Download a file, and return its name within my temp dir.
This does no verification of HTTPS certs, but our checking hashes
makes that largely unimportant. It would be nice to be able to use the
requests lib, which can verify certs, but it is guaranteed to b... | python | def _download(self, link):
"""Download a file, and return its name within my temp dir.
This does no verification of HTTPS certs, but our checking hashes
makes that largely unimportant. It would be nice to be able to use the
requests lib, which can verify certs, but it is guaranteed to b... | [
"def",
"_download",
"(",
"self",
",",
"link",
")",
":",
"# Based on pip 1.4.1's URLOpener but with cert verification removed",
"def",
"opener",
"(",
"is_https",
")",
":",
"if",
"is_https",
":",
"opener",
"=",
"build_opener",
"(",
"HTTPSHandler",
"(",
")",
")",
"# ... | Download a file, and return its name within my temp dir.
This does no verification of HTTPS certs, but our checking hashes
makes that largely unimportant. It would be nice to be able to use the
requests lib, which can verify certs, but it is guaranteed to be
available only in pip >= 1.5... | [
"Download",
"a",
"file",
"and",
"return",
"its",
"name",
"within",
"my",
"temp",
"dir",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L497-L586 | train |
erikrose/peep | peep.py | DownloadedReq._downloaded_filename | def _downloaded_filename(self):
"""Download the package's archive if necessary, and return its
filename.
--no-deps is implied, as we have reimplemented the bits that would
ordinarily do dependency resolution.
"""
# Peep doesn't support requirements that don't come down ... | python | def _downloaded_filename(self):
"""Download the package's archive if necessary, and return its
filename.
--no-deps is implied, as we have reimplemented the bits that would
ordinarily do dependency resolution.
"""
# Peep doesn't support requirements that don't come down ... | [
"def",
"_downloaded_filename",
"(",
"self",
")",
":",
"# Peep doesn't support requirements that don't come down as a single",
"# file, because it can't hash them. Thus, it doesn't support editable",
"# requirements, because pip itself doesn't support editable",
"# requirements except for \"local p... | Download the package's archive if necessary, and return its
filename.
--no-deps is implied, as we have reimplemented the bits that would
ordinarily do dependency resolution. | [
"Download",
"the",
"package",
"s",
"archive",
"if",
"necessary",
"and",
"return",
"its",
"filename",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L590-L639 | train |
erikrose/peep | peep.py | DownloadedReq.install | def install(self):
"""Install the package I represent, without dependencies.
Obey typical pip-install options passed in on the command line.
"""
other_args = list(requirement_args(self._argv, want_other=True))
archive_path = join(self._temp_path, self._downloaded_filename())
... | python | def install(self):
"""Install the package I represent, without dependencies.
Obey typical pip-install options passed in on the command line.
"""
other_args = list(requirement_args(self._argv, want_other=True))
archive_path = join(self._temp_path, self._downloaded_filename())
... | [
"def",
"install",
"(",
"self",
")",
":",
"other_args",
"=",
"list",
"(",
"requirement_args",
"(",
"self",
".",
"_argv",
",",
"want_other",
"=",
"True",
")",
")",
"archive_path",
"=",
"join",
"(",
"self",
".",
"_temp_path",
",",
"self",
".",
"_downloaded_... | Install the package I represent, without dependencies.
Obey typical pip-install options passed in on the command line. | [
"Install",
"the",
"package",
"I",
"represent",
"without",
"dependencies",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L641-L652 | train |
erikrose/peep | peep.py | DownloadedReq._project_name | def _project_name(self):
"""Return the inner Requirement's "unsafe name".
Raise ValueError if there is no name.
"""
name = getattr(self._req.req, 'project_name', '')
if name:
return name
name = getattr(self._req.req, 'name', '')
if name:
... | python | def _project_name(self):
"""Return the inner Requirement's "unsafe name".
Raise ValueError if there is no name.
"""
name = getattr(self._req.req, 'project_name', '')
if name:
return name
name = getattr(self._req.req, 'name', '')
if name:
... | [
"def",
"_project_name",
"(",
"self",
")",
":",
"name",
"=",
"getattr",
"(",
"self",
".",
"_req",
".",
"req",
",",
"'project_name'",
",",
"''",
")",
"if",
"name",
":",
"return",
"name",
"name",
"=",
"getattr",
"(",
"self",
".",
"_req",
".",
"req",
"... | Return the inner Requirement's "unsafe name".
Raise ValueError if there is no name. | [
"Return",
"the",
"inner",
"Requirement",
"s",
"unsafe",
"name",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L659-L671 | train |
erikrose/peep | peep.py | DownloadedReq._class | def _class(self):
"""Return the class I should be, spanning a continuum of goodness."""
try:
self._project_name()
except ValueError:
return MalformedReq
if self._is_satisfied():
return SatisfiedReq
if not self._expected_hashes():
re... | python | def _class(self):
"""Return the class I should be, spanning a continuum of goodness."""
try:
self._project_name()
except ValueError:
return MalformedReq
if self._is_satisfied():
return SatisfiedReq
if not self._expected_hashes():
re... | [
"def",
"_class",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_project_name",
"(",
")",
"except",
"ValueError",
":",
"return",
"MalformedReq",
"if",
"self",
".",
"_is_satisfied",
"(",
")",
":",
"return",
"SatisfiedReq",
"if",
"not",
"self",
".",
"_ex... | Return the class I should be, spanning a continuum of goodness. | [
"Return",
"the",
"class",
"I",
"should",
"be",
"spanning",
"a",
"continuum",
"of",
"goodness",
"."
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L694-L706 | train |
toloco/pyoanda | pyoanda/order.py | Order.check | def check(self):
"""
Logic extracted from:
http://developer.oanda.com/rest-live/orders/#createNewOrder
"""
for k in iter(self.__dict__.keys()):
if k not in self.__allowed:
raise TypeError("Parameter not allowed {}".format(k))
for k in self.__r... | python | def check(self):
"""
Logic extracted from:
http://developer.oanda.com/rest-live/orders/#createNewOrder
"""
for k in iter(self.__dict__.keys()):
if k not in self.__allowed:
raise TypeError("Parameter not allowed {}".format(k))
for k in self.__r... | [
"def",
"check",
"(",
"self",
")",
":",
"for",
"k",
"in",
"iter",
"(",
"self",
".",
"__dict__",
".",
"keys",
"(",
")",
")",
":",
"if",
"k",
"not",
"in",
"self",
".",
"__allowed",
":",
"raise",
"TypeError",
"(",
"\"Parameter not allowed {}\"",
".",
"fo... | Logic extracted from:
http://developer.oanda.com/rest-live/orders/#createNewOrder | [
"Logic",
"extracted",
"from",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#createNewOrder"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/order.py#L21-L67 | train |
ddorn/GUI | GUI/gui_examples/login.py | gui | def gui():
"""Main function"""
global SCREEN_SIZE
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1'
screen = new_widow()
pygame.display.set_caption('Client swag')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
clock = pygame.time.Clock(... | python | def gui():
"""Main function"""
global SCREEN_SIZE
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1'
screen = new_widow()
pygame.display.set_caption('Client swag')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
clock = pygame.time.Clock(... | [
"def",
"gui",
"(",
")",
":",
"global",
"SCREEN_SIZE",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"screen",
"=",
"new_widow",
"(",
")",
"pygame",
".",
"display",
".",
"set_caption",
"(",
... | Main function | [
"Main",
"function"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/login.py#L25-L134 | train |
ddorn/GUI | GUI/gui_examples/empty_template.py | gui | def gui():
"""Main function"""
global SCREEN_SIZE
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1' # centers the windows
screen = new_screen()
pygame.display.set_caption('Empty project')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
... | python | def gui():
"""Main function"""
global SCREEN_SIZE
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1' # centers the windows
screen = new_screen()
pygame.display.set_caption('Empty project')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
... | [
"def",
"gui",
"(",
")",
":",
"global",
"SCREEN_SIZE",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"# centers the windows",
"screen",
"=",
"new_screen",
"(",
")",
"pygame",
".",
"display",
"... | Main function | [
"Main",
"function"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/empty_template.py#L25-L72 | train |
toloco/pyoanda | pyoanda/client.py | Client.__get_response | def __get_response(self, uri, params=None, method="get", stream=False):
"""Creates a response object with the given params and option
Parameters
----------
url : string
The full URL to request.
params: dict
A list of parameters to ... | python | def __get_response(self, uri, params=None, method="get", stream=False):
"""Creates a response object with the given params and option
Parameters
----------
url : string
The full URL to request.
params: dict
A list of parameters to ... | [
"def",
"__get_response",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
",",
"stream",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"session\"",
")",
"or",
"not",
"self",
".",
"session",
":"... | Creates a response object with the given params and option
Parameters
----------
url : string
The full URL to request.
params: dict
A list of parameters to send with the request. This
will be sent as data for methods that ... | [
"Creates",
"a",
"response",
"object",
"with",
"the",
"given",
"params",
"and",
"option"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L54-L91 | train |
toloco/pyoanda | pyoanda/client.py | Client.__call | def __call(self, uri, params=None, method="get"):
"""Only returns the response, nor the status_code
"""
try:
resp = self.__get_response(uri, params, method, False)
rjson = resp.json(**self.json_options)
assert resp.ok
except AssertionError:
... | python | def __call(self, uri, params=None, method="get"):
"""Only returns the response, nor the status_code
"""
try:
resp = self.__get_response(uri, params, method, False)
rjson = resp.json(**self.json_options)
assert resp.ok
except AssertionError:
... | [
"def",
"__call",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"__get_response",
"(",
"uri",
",",
"params",
",",
"method",
",",
"False",
")",
"rjson",
"=",
"resp"... | Only returns the response, nor the status_code | [
"Only",
"returns",
"the",
"response",
"nor",
"the",
"status_code"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L93-L108 | train |
toloco/pyoanda | pyoanda/client.py | Client.__call_stream | def __call_stream(self, uri, params=None, method="get"):
"""Returns an stream response
"""
try:
resp = self.__get_response(uri, params, method, True)
assert resp.ok
except AssertionError:
raise BadRequest(resp.status_code)
except Exception as e... | python | def __call_stream(self, uri, params=None, method="get"):
"""Returns an stream response
"""
try:
resp = self.__get_response(uri, params, method, True)
assert resp.ok
except AssertionError:
raise BadRequest(resp.status_code)
except Exception as e... | [
"def",
"__call_stream",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"__get_response",
"(",
"uri",
",",
"params",
",",
"method",
",",
"True",
")",
"assert",
"resp"... | Returns an stream response | [
"Returns",
"an",
"stream",
"response"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L110-L121 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_instruments | def get_instruments(self):
"""
See more:
http://developer.oanda.com/rest-live/rates/#getInstrumentList
"""
url = "{0}/{1}/instruments".format(self.domain, self.API_VERSION)
params = {"accountId": self.account_id}
try:
response = self._Client__c... | python | def get_instruments(self):
"""
See more:
http://developer.oanda.com/rest-live/rates/#getInstrumentList
"""
url = "{0}/{1}/instruments".format(self.domain, self.API_VERSION)
params = {"accountId": self.account_id}
try:
response = self._Client__c... | [
"def",
"get_instruments",
"(",
"self",
")",
":",
"url",
"=",
"\"{0}/{1}/instruments\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"accountId\"",
":",
"self",
".",
"account_id",
"}",
"try",
":",
... | See more:
http://developer.oanda.com/rest-live/rates/#getInstrumentList | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#getInstrumentList"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L123-L137 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_prices | def get_prices(self, instruments, stream=True):
"""
See more:
http://developer.oanda.com/rest-live/rates/#getCurrentPrices
"""
url = "{0}/{1}/prices".format(
self.domain_stream if stream else self.domain,
self.API_VERSION
)
params =... | python | def get_prices(self, instruments, stream=True):
"""
See more:
http://developer.oanda.com/rest-live/rates/#getCurrentPrices
"""
url = "{0}/{1}/prices".format(
self.domain_stream if stream else self.domain,
self.API_VERSION
)
params =... | [
"def",
"get_prices",
"(",
"self",
",",
"instruments",
",",
"stream",
"=",
"True",
")",
":",
"url",
"=",
"\"{0}/{1}/prices\"",
".",
"format",
"(",
"self",
".",
"domain_stream",
"if",
"stream",
"else",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
... | See more:
http://developer.oanda.com/rest-live/rates/#getCurrentPrices | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#getCurrentPrices"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L139-L160 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_instrument_history | def get_instrument_history(self, instrument, candle_format="bidask",
granularity='S5', count=500,
daily_alignment=None, alignment_timezone=None,
weekly_alignment="Monday", start=None,
end=None):
... | python | def get_instrument_history(self, instrument, candle_format="bidask",
granularity='S5', count=500,
daily_alignment=None, alignment_timezone=None,
weekly_alignment="Monday", start=None,
end=None):
... | [
"def",
"get_instrument_history",
"(",
"self",
",",
"instrument",
",",
"candle_format",
"=",
"\"bidask\"",
",",
"granularity",
"=",
"'S5'",
",",
"count",
"=",
"500",
",",
"daily_alignment",
"=",
"None",
",",
"alignment_timezone",
"=",
"None",
",",
"weekly_alignme... | See more:
http://developer.oanda.com/rest-live/rates/#retrieveInstrumentHistory | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#retrieveInstrumentHistory"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L162-L189 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_orders | def get_orders(self, instrument=None, count=50):
"""
See more:
http://developer.oanda.com/rest-live/orders/#getOrdersForAnAccount
"""
url = "{0}/{1}/accounts/{2}/orders".format(
self.domain,
self.API_VERSION,
self.account_id
)
... | python | def get_orders(self, instrument=None, count=50):
"""
See more:
http://developer.oanda.com/rest-live/orders/#getOrdersForAnAccount
"""
url = "{0}/{1}/accounts/{2}/orders".format(
self.domain,
self.API_VERSION,
self.account_id
)
... | [
"def",
"get_orders",
"(",
"self",
",",
"instrument",
"=",
"None",
",",
"count",
"=",
"50",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/orders\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
... | See more:
http://developer.oanda.com/rest-live/orders/#getOrdersForAnAccount | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#getOrdersForAnAccount"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L191-L207 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_order | def get_order(self, order_id):
"""
See more:
http://developer.oanda.com/rest-live/orders/#getInformationForAnOrder
"""
url = "{0}/{1}/accounts/{2}/orders/{3}".format(
self.domain,
self.API_VERSION,
self.account_id,
order_id
... | python | def get_order(self, order_id):
"""
See more:
http://developer.oanda.com/rest-live/orders/#getInformationForAnOrder
"""
url = "{0}/{1}/accounts/{2}/orders/{3}".format(
self.domain,
self.API_VERSION,
self.account_id,
order_id
... | [
"def",
"get_order",
"(",
"self",
",",
"order_id",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/orders/{3}\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
",",
"order_id",
")",
"try",
":",
"re... | See more:
http://developer.oanda.com/rest-live/orders/#getInformationForAnOrder | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#getInformationForAnOrder"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L209-L225 | train |
toloco/pyoanda | pyoanda/client.py | Client.create_order | def create_order(self, order):
"""
See more:
http://developer.oanda.com/rest-live/orders/#createNewOrder
"""
url = "{0}/{1}/accounts/{2}/orders".format(
self.domain,
self.API_VERSION,
self.account_id
)
try:
r... | python | def create_order(self, order):
"""
See more:
http://developer.oanda.com/rest-live/orders/#createNewOrder
"""
url = "{0}/{1}/accounts/{2}/orders".format(
self.domain,
self.API_VERSION,
self.account_id
)
try:
r... | [
"def",
"create_order",
"(",
"self",
",",
"order",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/orders\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
")",
"try",
":",
"return",
"self",
".",
... | See more:
http://developer.oanda.com/rest-live/orders/#createNewOrder | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#createNewOrder"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L227-L246 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_trades | def get_trades(self, max_id=None, count=None, instrument=None, ids=None):
""" Get a list of open trades
Parameters
----------
max_id : int
The server will return trades with id less than or equal
to this, in descending order (for pagination)
... | python | def get_trades(self, max_id=None, count=None, instrument=None, ids=None):
""" Get a list of open trades
Parameters
----------
max_id : int
The server will return trades with id less than or equal
to this, in descending order (for pagination)
... | [
"def",
"get_trades",
"(",
"self",
",",
"max_id",
"=",
"None",
",",
"count",
"=",
"None",
",",
"instrument",
"=",
"None",
",",
"ids",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/trades\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"... | Get a list of open trades
Parameters
----------
max_id : int
The server will return trades with id less than or equal
to this, in descending order (for pagination)
count : int
Maximum number of open trades to return. Defaul... | [
"Get",
"a",
"list",
"of",
"open",
"trades"
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L288-L327 | train |
toloco/pyoanda | pyoanda/client.py | Client.update_trade | def update_trade(
self,
trade_id,
stop_loss=None,
take_profit=None,
trailing_stop=None
):
""" Modify an existing trade.
Note: Only the specified parameters will be modified. All
other parameters will remain unchanged. To remove an
... | python | def update_trade(
self,
trade_id,
stop_loss=None,
take_profit=None,
trailing_stop=None
):
""" Modify an existing trade.
Note: Only the specified parameters will be modified. All
other parameters will remain unchanged. To remove an
... | [
"def",
"update_trade",
"(",
"self",
",",
"trade_id",
",",
"stop_loss",
"=",
"None",
",",
"take_profit",
"=",
"None",
",",
"trailing_stop",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/trades/{3}\"",
".",
"format",
"(",
"self",
".",
"domain",
",... | Modify an existing trade.
Note: Only the specified parameters will be modified. All
other parameters will remain unchanged. To remove an
optional parameter, set its value to 0.
Parameters
----------
trade_id : int
The id of the tr... | [
"Modify",
"an",
"existing",
"trade",
"."
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L353-L397 | train |
toloco/pyoanda | pyoanda/client.py | Client.request_transaction_history | def request_transaction_history(self):
""" Request full account history.
Submit a request for a full transaction history. A
successfully accepted submission results in a response
containing a URL in the Location header to a file that will
be available once the r... | python | def request_transaction_history(self):
""" Request full account history.
Submit a request for a full transaction history. A
successfully accepted submission results in a response
containing a URL in the Location header to a file that will
be available once the r... | [
"def",
"request_transaction_history",
"(",
"self",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/alltransactions\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
")",
"try",
":",
"resp",
"=",
"self... | Request full account history.
Submit a request for a full transaction history. A
successfully accepted submission results in a response
containing a URL in the Location header to a file that will
be available once the request is served. Response for the
URL ... | [
"Request",
"full",
"account",
"history",
"."
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L562-L587 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_transaction_history | def get_transaction_history(self, max_wait=5.0):
""" Download full account history.
Uses request_transaction_history to get the transaction
history URL, then polls the given URL until it's ready (or
the max_wait time is reached) and provides the decoded
response.... | python | def get_transaction_history(self, max_wait=5.0):
""" Download full account history.
Uses request_transaction_history to get the transaction
history URL, then polls the given URL until it's ready (or
the max_wait time is reached) and provides the decoded
response.... | [
"def",
"get_transaction_history",
"(",
"self",
",",
"max_wait",
"=",
"5.0",
")",
":",
"url",
"=",
"self",
".",
"request_transaction_history",
"(",
")",
"if",
"not",
"url",
":",
"return",
"False",
"ready",
"=",
"False",
"start",
"=",
"time",
"(",
")",
"de... | Download full account history.
Uses request_transaction_history to get the transaction
history URL, then polls the given URL until it's ready (or
the max_wait time is reached) and provides the decoded
response.
Parameters
----------
m... | [
"Download",
"full",
"account",
"history",
"."
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L589-L642 | train |
toloco/pyoanda | pyoanda/client.py | Client.create_account | def create_account(self, currency=None):
""" Create a new account.
This call is only available on the sandbox system. Please
create accounts on fxtrade.oanda.com on our production
system.
See more:
http://developer.oanda.com/rest-sandbox/accounts/#-a... | python | def create_account(self, currency=None):
""" Create a new account.
This call is only available on the sandbox system. Please
create accounts on fxtrade.oanda.com on our production
system.
See more:
http://developer.oanda.com/rest-sandbox/accounts/#-a... | [
"def",
"create_account",
"(",
"self",
",",
"currency",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"currency\"",
":",
"currency",
"}",
"... | Create a new account.
This call is only available on the sandbox system. Please
create accounts on fxtrade.oanda.com on our production
system.
See more:
http://developer.oanda.com/rest-sandbox/accounts/#-a-name-createtestaccount-a-create-a-test-account | [
"Create",
"a",
"new",
"account",
"."
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L644-L661 | train |
toloco/pyoanda | pyoanda/client.py | Client.get_accounts | def get_accounts(self, username=None):
""" Get a list of accounts owned by the user.
Parameters
----------
username : string
The name of the user. Note: This is only required on the
sandbox, on production systems your access token will
... | python | def get_accounts(self, username=None):
""" Get a list of accounts owned by the user.
Parameters
----------
username : string
The name of the user. Note: This is only required on the
sandbox, on production systems your access token will
... | [
"def",
"get_accounts",
"(",
"self",
",",
"username",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
"tr... | Get a list of accounts owned by the user.
Parameters
----------
username : string
The name of the user. Note: This is only required on the
sandbox, on production systems your access token will
identify you.
See more:
... | [
"Get",
"a",
"list",
"of",
"accounts",
"owned",
"by",
"the",
"user",
"."
] | 26b3f28a89d07c5c20d2a645884505387f1daae8 | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L663-L683 | train |
ddorn/GUI | GUI/menu.py | MenuElement.choose | def choose(self):
"""Marks the item as the one the user is in."""
if not self.choosed:
self.choosed = True
self.pos = self.pos + Sep(5, 0) | python | def choose(self):
"""Marks the item as the one the user is in."""
if not self.choosed:
self.choosed = True
self.pos = self.pos + Sep(5, 0) | [
"def",
"choose",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"choosed",
":",
"self",
".",
"choosed",
"=",
"True",
"self",
".",
"pos",
"=",
"self",
".",
"pos",
"+",
"Sep",
"(",
"5",
",",
"0",
")"
] | Marks the item as the one the user is in. | [
"Marks",
"the",
"item",
"as",
"the",
"one",
"the",
"user",
"is",
"in",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L127-L131 | train |
ddorn/GUI | GUI/menu.py | MenuElement.stop_choose | def stop_choose(self):
"""Marks the item as the one the user is not in."""
if self.choosed:
self.choosed = False
self.pos = self.pos + Sep(-5, 0) | python | def stop_choose(self):
"""Marks the item as the one the user is not in."""
if self.choosed:
self.choosed = False
self.pos = self.pos + Sep(-5, 0) | [
"def",
"stop_choose",
"(",
"self",
")",
":",
"if",
"self",
".",
"choosed",
":",
"self",
".",
"choosed",
"=",
"False",
"self",
".",
"pos",
"=",
"self",
".",
"pos",
"+",
"Sep",
"(",
"-",
"5",
",",
"0",
")"
] | Marks the item as the one the user is not in. | [
"Marks",
"the",
"item",
"as",
"the",
"one",
"the",
"user",
"is",
"not",
"in",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L133-L137 | train |
ddorn/GUI | GUI/menu.py | MenuElement.get_darker_color | def get_darker_color(self):
"""The color of the clicked version of the MenuElement. Darker than the normal one."""
# we change a bit the color in one direction
if bw_contrasted(self._true_color, 30) == WHITE:
color = mix(self._true_color, WHITE, 0.9)
else:
color =... | python | def get_darker_color(self):
"""The color of the clicked version of the MenuElement. Darker than the normal one."""
# we change a bit the color in one direction
if bw_contrasted(self._true_color, 30) == WHITE:
color = mix(self._true_color, WHITE, 0.9)
else:
color =... | [
"def",
"get_darker_color",
"(",
"self",
")",
":",
"# we change a bit the color in one direction",
"if",
"bw_contrasted",
"(",
"self",
".",
"_true_color",
",",
"30",
")",
"==",
"WHITE",
":",
"color",
"=",
"mix",
"(",
"self",
".",
"_true_color",
",",
"WHITE",
",... | The color of the clicked version of the MenuElement. Darker than the normal one. | [
"The",
"color",
"of",
"the",
"clicked",
"version",
"of",
"the",
"MenuElement",
".",
"Darker",
"than",
"the",
"normal",
"one",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L145-L153 | train |
ddorn/GUI | GUI/menu.py | MenuElement.render | def render(self, screen):
"""Renders the MenuElement"""
self.rect.render(screen)
super(MenuElement, self).render(screen) | python | def render(self, screen):
"""Renders the MenuElement"""
self.rect.render(screen)
super(MenuElement, self).render(screen) | [
"def",
"render",
"(",
"self",
",",
"screen",
")",
":",
"self",
".",
"rect",
".",
"render",
"(",
"screen",
")",
"super",
"(",
"MenuElement",
",",
"self",
")",
".",
"render",
"(",
"screen",
")"
] | Renders the MenuElement | [
"Renders",
"the",
"MenuElement"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L155-L158 | train |
ddorn/GUI | GUI/gui_examples/bezier.py | gui | def gui():
"""Main function"""
# #######
# setup all objects
# #######
zones = [ALL]
last_zones = []
COLORS.remove(WHITE)
screen = pygame.display.set_mode(SCREEN_SIZE, DOUBLEBUF)
pygame.display.set_caption('Bezier simulator')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTT... | python | def gui():
"""Main function"""
# #######
# setup all objects
# #######
zones = [ALL]
last_zones = []
COLORS.remove(WHITE)
screen = pygame.display.set_mode(SCREEN_SIZE, DOUBLEBUF)
pygame.display.set_caption('Bezier simulator')
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTT... | [
"def",
"gui",
"(",
")",
":",
"# #######",
"# setup all objects",
"# #######",
"zones",
"=",
"[",
"ALL",
"]",
"last_zones",
"=",
"[",
"]",
"COLORS",
".",
"remove",
"(",
"WHITE",
")",
"screen",
"=",
"pygame",
".",
"display",
".",
"set_mode",
"(",
"SCREEN_S... | Main function | [
"Main",
"function"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/bezier.py#L17-L105 | train |
ddorn/GUI | GUI/gui_examples/morpion.py | gui | def gui():
"""Main function"""
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1'
clock = pygame.time.Clock()
screen = pygame.display.set_mode(SCREEN_SIZE, DOUBLEBUF | NOFRAME)
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
game = Morpion()
... | python | def gui():
"""Main function"""
# #######
# setup all objects
# #######
os.environ['SDL_VIDEO_CENTERED'] = '1'
clock = pygame.time.Clock()
screen = pygame.display.set_mode(SCREEN_SIZE, DOUBLEBUF | NOFRAME)
pygame.event.set_allowed([QUIT, KEYDOWN, MOUSEBUTTONDOWN])
game = Morpion()
... | [
"def",
"gui",
"(",
")",
":",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"clock",
"=",
"pygame",
".",
"time",
".",
"Clock",
"(",
")",
"screen",
"=",
"pygame",
".",
"display",
".",
"... | Main function | [
"Main",
"function"
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/morpion.py#L188-L248 | train |
ddorn/GUI | GUI/font.py | Font.px_to_pt | def px_to_pt(self, px):
"""Convert a size in pxel to a size in points."""
if px < 200:
pt = self.PX_TO_PT[px]
else:
pt = int(floor((px - 1.21) / 1.332))
return pt | python | def px_to_pt(self, px):
"""Convert a size in pxel to a size in points."""
if px < 200:
pt = self.PX_TO_PT[px]
else:
pt = int(floor((px - 1.21) / 1.332))
return pt | [
"def",
"px_to_pt",
"(",
"self",
",",
"px",
")",
":",
"if",
"px",
"<",
"200",
":",
"pt",
"=",
"self",
".",
"PX_TO_PT",
"[",
"px",
"]",
"else",
":",
"pt",
"=",
"int",
"(",
"floor",
"(",
"(",
"px",
"-",
"1.21",
")",
"/",
"1.332",
")",
")",
"re... | Convert a size in pxel to a size in points. | [
"Convert",
"a",
"size",
"in",
"pxel",
"to",
"a",
"size",
"in",
"points",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/font.py#L45-L52 | train |
ddorn/GUI | GUI/font.py | Font.set_size | def set_size(self, pt=None, px=None):
"""
Set the size of the font, in px or pt.
The px method is a bit inacurate, there can be one or two px less, and max 4 for big numbers (like 503)
but the size is never over-estimated. It makes almost the good value.
"""
assert (pt,... | python | def set_size(self, pt=None, px=None):
"""
Set the size of the font, in px or pt.
The px method is a bit inacurate, there can be one or two px less, and max 4 for big numbers (like 503)
but the size is never over-estimated. It makes almost the good value.
"""
assert (pt,... | [
"def",
"set_size",
"(",
"self",
",",
"pt",
"=",
"None",
",",
"px",
"=",
"None",
")",
":",
"assert",
"(",
"pt",
",",
"px",
")",
"!=",
"(",
"None",
",",
"None",
")",
"if",
"pt",
"is",
"not",
"None",
":",
"self",
".",
"__init__",
"(",
"pt",
",",... | Set the size of the font, in px or pt.
The px method is a bit inacurate, there can be one or two px less, and max 4 for big numbers (like 503)
but the size is never over-estimated. It makes almost the good value. | [
"Set",
"the",
"size",
"of",
"the",
"font",
"in",
"px",
"or",
"pt",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/font.py#L54-L67 | train |
ddorn/GUI | GUI/text.py | SimpleText.text | def text(self):
"""Return the string to render."""
if callable(self._text):
return str(self._text())
return str(self._text) | python | def text(self):
"""Return the string to render."""
if callable(self._text):
return str(self._text())
return str(self._text) | [
"def",
"text",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"_text",
")",
":",
"return",
"str",
"(",
"self",
".",
"_text",
"(",
")",
")",
"return",
"str",
"(",
"self",
".",
"_text",
")"
] | Return the string to render. | [
"Return",
"the",
"string",
"to",
"render",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L55-L59 | train |
ddorn/GUI | GUI/text.py | SimpleText.color | def color(self, value):
"""Set the color to a new value (tuple). Renders the text if needed."""
if value != self.color:
self._color = value
self._render() | python | def color(self, value):
"""Set the color to a new value (tuple). Renders the text if needed."""
if value != self.color:
self._color = value
self._render() | [
"def",
"color",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"color",
":",
"self",
".",
"_color",
"=",
"value",
"self",
".",
"_render",
"(",
")"
] | Set the color to a new value (tuple). Renders the text if needed. | [
"Set",
"the",
"color",
"to",
"a",
"new",
"value",
"(",
"tuple",
")",
".",
"Renders",
"the",
"text",
"if",
"needed",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L76-L81 | train |
ddorn/GUI | GUI/text.py | SimpleText.bg_color | def bg_color(self, value):
"""Sets the color to a new value (tuple). Renders the text if needed."""
if value != self.bg_color:
self._bg_color = value
self._render() | python | def bg_color(self, value):
"""Sets the color to a new value (tuple). Renders the text if needed."""
if value != self.bg_color:
self._bg_color = value
self._render() | [
"def",
"bg_color",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"bg_color",
":",
"self",
".",
"_bg_color",
"=",
"value",
"self",
".",
"_render",
"(",
")"
] | Sets the color to a new value (tuple). Renders the text if needed. | [
"Sets",
"the",
"color",
"to",
"a",
"new",
"value",
"(",
"tuple",
")",
".",
"Renders",
"the",
"text",
"if",
"needed",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L84-L89 | train |
ddorn/GUI | GUI/text.py | SimpleText.set_font_size | def set_font_size(self, pt=None, px=None):
"""Set the font size to the desired size, in pt or px."""
self.font.set_size(pt, px)
self._render() | python | def set_font_size(self, pt=None, px=None):
"""Set the font size to the desired size, in pt or px."""
self.font.set_size(pt, px)
self._render() | [
"def",
"set_font_size",
"(",
"self",
",",
"pt",
"=",
"None",
",",
"px",
"=",
"None",
")",
":",
"self",
".",
"font",
".",
"set_size",
"(",
"pt",
",",
"px",
")",
"self",
".",
"_render",
"(",
")"
] | Set the font size to the desired size, in pt or px. | [
"Set",
"the",
"font",
"size",
"to",
"the",
"desired",
"size",
"in",
"pt",
"or",
"px",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L91-L95 | train |
ddorn/GUI | GUI/text.py | SimpleText._render | def _render(self):
"""
Render the text.
Avoid using this fonction too many time as it is slow as it is low to render text and blit it.
"""
self._last_text = self.text
self._surface = self.font.render(self.text, True, self.color, self.bg_color)
rect = self._surf... | python | def _render(self):
"""
Render the text.
Avoid using this fonction too many time as it is slow as it is low to render text and blit it.
"""
self._last_text = self.text
self._surface = self.font.render(self.text, True, self.color, self.bg_color)
rect = self._surf... | [
"def",
"_render",
"(",
"self",
")",
":",
"self",
".",
"_last_text",
"=",
"self",
".",
"text",
"self",
".",
"_surface",
"=",
"self",
".",
"font",
".",
"render",
"(",
"self",
".",
"text",
",",
"True",
",",
"self",
".",
"color",
",",
"self",
".",
"b... | Render the text.
Avoid using this fonction too many time as it is slow as it is low to render text and blit it. | [
"Render",
"the",
"text",
"."
] | e1fcb5286d24e0995f280d5180222e51895c368c | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L97-L109 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.