partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Window.update_screen | Refresh the screen. You don't need to override this except to update only small portins of the screen. | GUI/vracabulous.py | 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):
"""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() | [
"Refresh",
"the",
"screen",
".",
"You",
"don",
"t",
"need",
"to",
"override",
"this",
"except",
"to",
"update",
"only",
"small",
"portins",
"of",
"the",
"screen",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L292-L295 | [
"def",
"update_screen",
"(",
"self",
")",
":",
"self",
".",
"clock",
".",
"tick",
"(",
"self",
".",
"FPS",
")",
"pygame",
".",
"display",
".",
"update",
"(",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Window.run | The run loop. Returns self.destroy() | GUI/vracabulous.py | 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):
"""The run loop. Returns self.destroy()"""
while self.running:
self.update()
self.render()
self.update_screen()
return self.destroy() | [
"The",
"run",
"loop",
".",
"Returns",
"self",
".",
"destroy",
"()"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L302-L309 | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"self",
".",
"running",
":",
"self",
".",
"update",
"(",
")",
"self",
".",
"render",
"(",
")",
"self",
".",
"update_screen",
"(",
")",
"return",
"self",
".",
"destroy",
"(",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Window.new_screen | Makes a new screen with a size of SCREEN_SIZE, and VIDEO_OPTION as flags. Sets the windows name to NAME. | GUI/vracabulous.py | 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):
"""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
... | [
"Makes",
"a",
"new",
"screen",
"with",
"a",
"size",
"of",
"SCREEN_SIZE",
"and",
"VIDEO_OPTION",
"as",
"flags",
".",
"Sets",
"the",
"windows",
"name",
"to",
"NAME",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/vracabulous.py#L311-L334 | [
"def",
"new_screen",
"(",
"self",
")",
":",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"pygame",
".",
"display",
".",
"set_caption",
"(",
"self",
".",
"NAME",
")",
"screen_s",
"=",
"self",
".",
"SCREEN_SIZE",
"video_options",
"=",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | merge_rects | Return the smallest rect containning two rects | GUI/math.py | 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):
"""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) | [
"Return",
"the",
"smallest",
"rect",
"containning",
"two",
"rects"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/math.py#L18-L28 | [
"def",
"merge_rects",
"(",
"rect1",
",",
"rect2",
")",
":",
"r",
"=",
"pygame",
".",
"Rect",
"(",
"rect1",
")",
"t",
"=",
"pygame",
".",
"Rect",
"(",
"rect2",
")",
"right",
"=",
"max",
"(",
"r",
".",
"right",
",",
"t",
".",
"right",
")",
"bot",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | V2.normnorm | Return a vecor noraml to this one with a norm of one
:return: V2 | GUI/math.py | 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):
"""
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) | [
"Return",
"a",
"vecor",
"noraml",
"to",
"this",
"one",
"with",
"a",
"norm",
"of",
"one"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/math.py#L109-L117 | [
"def",
"normnorm",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"norm",
"(",
")",
"return",
"V2",
"(",
"-",
"self",
".",
"y",
"/",
"n",
",",
"self",
".",
"x",
"/",
"n",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | line | Draws an antialiased line on the surface. | GUI/draw.py | 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):
"""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)... | [
"Draws",
"an",
"antialiased",
"line",
"on",
"the",
"surface",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L17-L52 | [
"def",
"line",
"(",
"surf",
",",
"start",
",",
"end",
",",
"color",
"=",
"BLACK",
",",
"width",
"=",
"1",
",",
"style",
"=",
"FLAT",
")",
":",
"width",
"=",
"round",
"(",
"width",
",",
"1",
")",
"if",
"width",
"==",
"1",
":",
"# return pygame.dra... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | circle | Draw an antialiased filled circle on the given surface | GUI/draw.py | 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):
"""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 ... | [
"Draw",
"an",
"antialiased",
"filled",
"circle",
"on",
"the",
"given",
"surface"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L55-L68 | [
"def",
"circle",
"(",
"surf",
",",
"xy",
",",
"r",
",",
"color",
"=",
"BLACK",
")",
":",
"x",
",",
"y",
"=",
"xy",
"x",
"=",
"round",
"(",
"x",
")",
"y",
"=",
"round",
"(",
"y",
")",
"r",
"=",
"round",
"(",
"r",
")",
"gfxdraw",
".",
"fill... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | ring | Draws a ring | GUI/draw.py | 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):
"""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... | [
"Draws",
"a",
"ring"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L71-L122 | [
"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",
"=",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | roundrect | 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 | GUI/draw.py | 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):
"""
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... | [
"Draw",
"an",
"antialiased",
"round",
"rectangle",
"on",
"the",
"surface",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L125-L165 | [
"def",
"roundrect",
"(",
"surface",
",",
"rect",
",",
"color",
",",
"rounding",
"=",
"5",
",",
"unit",
"=",
"PIXEL",
")",
":",
"if",
"unit",
"==",
"PERCENT",
":",
"rounding",
"=",
"int",
"(",
"min",
"(",
"rect",
".",
"size",
")",
"/",
"2",
"*",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | polygon | Draw an antialiased filled polygon on a surface | GUI/draw.py | 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):
"""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 ... | [
"Draw",
"an",
"antialiased",
"filled",
"polygon",
"on",
"a",
"surface"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/draw.py#L168-L179 | [
"def",
"polygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
":",
"gfxdraw",
".",
"aapolygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
"gfxdraw",
".",
"filled_polygon",
"(",
"surf",
",",
"points",
",",
"color",
")",
"x",
"=",
"min",
"(",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | BaseButton.click | 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 | GUI/buttons.py | 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):
"""
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... | [
"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"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L42-L60 | [
"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",
":... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Button._get_color | Return the color of the button, depending on its state | GUI/buttons.py | 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):
"""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... | [
"Return",
"the",
"color",
"of",
"the",
"button",
"depending",
"on",
"its",
"state"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L118-L130 | [
"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",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Button._front_delta | Return the offset of the colored part. | GUI/buttons.py | 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):
"""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:
... | [
"Return",
"the",
"offset",
"of",
"the",
"colored",
"part",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L133-L147 | [
"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"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Button.update | Update the button with the events. | GUI/buttons.py | 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):
"""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)
... | [
"Update",
"the",
"button",
"with",
"the",
"events",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L166-L183 | [
"def",
"update",
"(",
"self",
",",
"event_or_list",
")",
":",
"for",
"e",
"in",
"super",
"(",
")",
".",
"update",
"(",
"event_or_list",
")",
":",
"if",
"e",
".",
"type",
"==",
"MOUSEBUTTONDOWN",
":",
"if",
"e",
".",
"pos",
"in",
"self",
":",
"self"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Button.render | Render the button on a surface. | GUI/buttons.py | 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):
"""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:
... | [
"Render",
"the",
"button",
"on",
"a",
"surface",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L185-L201 | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"pos",
",",
"size",
"=",
"self",
".",
"topleft",
",",
"self",
".",
"size",
"if",
"not",
"self",
".",
"flags",
"&",
"self",
".",
"NO_SHADOW",
":",
"if",
"self",
".",
"flags",
"&",
"self",
".",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | RoundButton.render | Draw the button on the surface. | GUI/buttons.py | 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):
"""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... | [
"Draw",
"the",
"button",
"on",
"the",
"surface",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L211-L218 | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"if",
"not",
"self",
".",
"flags",
"&",
"self",
".",
"NO_SHADOW",
":",
"circle",
"(",
"surf",
",",
"self",
".",
"center",
"+",
"self",
".",
"_bg_delta",
",",
"self",
".",
"width",
"/",
"2",
","... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | IconButton.get_darker_image | Returns an icon 80% more dark | GUI/buttons.py | 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):
"""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)
... | [
"Returns",
"an",
"icon",
"80%",
"more",
"dark"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L244-L257 | [
"def",
"get_darker_image",
"(",
"self",
")",
":",
"icon_pressed",
"=",
"self",
".",
"icon",
".",
"copy",
"(",
")",
"for",
"x",
"in",
"range",
"(",
"self",
".",
"w",
")",
":",
"for",
"y",
"in",
"range",
"(",
"self",
".",
"h",
")",
":",
"r",
",",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | IconButton.render | Render the button | GUI/buttons.py | 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):
"""Render the button"""
if self.clicked:
icon = self.icon_pressed
else:
icon = self.icon
surf.blit(icon, self) | [
"Render",
"the",
"button"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L259-L267 | [
"def",
"render",
"(",
"self",
",",
"surf",
")",
":",
"if",
"self",
".",
"clicked",
":",
"icon",
"=",
"self",
".",
"icon_pressed",
"else",
":",
"icon",
"=",
"self",
".",
"icon",
"surf",
".",
"blit",
"(",
"icon",
",",
"self",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SlideBar.set | Set the value of the bar. If the value is out of bound, sets it to an extremum | GUI/buttons.py | 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):
"""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(),)) | [
"Set",
"the",
"value",
"of",
"the",
"bar",
".",
"If",
"the",
"value",
"is",
"out",
"of",
"bound",
"sets",
"it",
"to",
"an",
"extremum"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L327-L331 | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"min",
"(",
"self",
".",
"max",
",",
"max",
"(",
"self",
".",
"min",
",",
"value",
")",
")",
"self",
".",
"_value",
"=",
"value",
"start_new_thread",
"(",
"self",
".",
"func",
",",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SlideBar._start | Starts checking if the SB is shifted | GUI/buttons.py | 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):
"""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]
... | [
"Starts",
"checking",
"if",
"the",
"SB",
"is",
"shifted"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L333-L352 | [
"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",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SlideBar.value_px | The position in pixels of the cursor | GUI/buttons.py | 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):
"""The position in pixels of the cursor"""
step = self.w / (self.max - self.min)
return self.x + step * (self.get() - self.min) | [
"The",
"position",
"in",
"pixels",
"of",
"the",
"cursor"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L361-L364 | [
"def",
"value_px",
"(",
"self",
")",
":",
"step",
"=",
"self",
".",
"w",
"/",
"(",
"self",
".",
"max",
"-",
"self",
".",
"min",
")",
"return",
"self",
".",
"x",
"+",
"step",
"*",
"(",
"self",
".",
"get",
"(",
")",
"-",
"self",
".",
"min",
"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SlideBar.render | Renders the bar on the display | GUI/buttons.py | 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):
"""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... | [
"Renders",
"the",
"bar",
"on",
"the",
"display"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/buttons.py#L375-L388 | [
"def",
"render",
"(",
"self",
",",
"display",
")",
":",
"# the bar",
"bar_rect",
"=",
"pygame",
".",
"Rect",
"(",
"0",
",",
"0",
",",
"self",
".",
"width",
",",
"self",
".",
"height",
"//",
"3",
")",
"bar_rect",
".",
"center",
"=",
"self",
".",
"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | BaseWidget.__update | This is called each time an attribute is asked, to be sure every params are updated, beceause of callbacks. | GUI/base.py | 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):
"""
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... | [
"This",
"is",
"called",
"each",
"time",
"an",
"attribute",
"is",
"asked",
"to",
"be",
"sure",
"every",
"params",
"are",
"updated",
"beceause",
"of",
"callbacks",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/base.py#L83-L92 | [
"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... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | activate | Make a compatible version of pip importable. Raise a RuntimeError if we
couldn't. | peep.py | 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):
"""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... | [
"Make",
"a",
"compatible",
"version",
"of",
"pip",
"importable",
".",
"Raise",
"a",
"RuntimeError",
"if",
"we",
"couldn",
"t",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L65-L73 | [
"def",
"activate",
"(",
"specifier",
")",
":",
"try",
":",
"for",
"distro",
"in",
"require",
"(",
"specifier",
")",
":",
"distro",
".",
"activate",
"(",
")",
"except",
"(",
"VersionConflict",
",",
"DistributionNotFound",
")",
":",
"raise",
"RuntimeError",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | path_and_line | Return the path and line number of the file from which an
InstallRequirement came. | peep.py | 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):
"""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) | [
"Return",
"the",
"path",
"and",
"line",
"number",
"of",
"the",
"file",
"from",
"which",
"an",
"InstallRequirement",
"came",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L164-L171 | [
"def",
"path_and_line",
"(",
"req",
")",
":",
"path",
",",
"line",
"=",
"(",
"re",
".",
"match",
"(",
"r'-r (.*) \\(line (\\d+)\\)$'",
",",
"req",
".",
"comes_from",
")",
".",
"groups",
"(",
")",
")",
"return",
"path",
",",
"int",
"(",
"line",
")"
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | hashes_above | Yield hashes from contiguous comment lines before line ``line_number``. | peep.py | 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):
"""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... | [
"Yield",
"hashes",
"from",
"contiguous",
"comment",
"lines",
"before",
"line",
"line_number",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L174-L200 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | run_pip | Delegate to pip the given args (starting with the subcommand), and raise
``PipException`` if something goes wrong. | peep.py | 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):
"""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... | [
"Delegate",
"to",
"pip",
"the",
"given",
"args",
"(",
"starting",
"with",
"the",
"subcommand",
")",
"and",
"raise",
"PipException",
"if",
"something",
"goes",
"wrong",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L203-L214 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | hash_of_file | Return the hash of a downloaded file. | peep.py | 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):
"""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) | [
"Return",
"the",
"hash",
"of",
"a",
"downloaded",
"file",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L217-L226 | [
"def",
"hash_of_file",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"archive",
":",
"sha",
"=",
"sha256",
"(",
")",
"while",
"True",
":",
"data",
"=",
"archive",
".",
"read",
"(",
"2",
"**",
"20",
")",
"if",
"not",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | requirement_args | 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... | peep.py | 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):
"""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... | [
"Return",
"an",
"iterable",
"of",
"filtered",
"arguments",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L247-L269 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | peep_hash | 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 | peep.py | 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):
"""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... | [
"Return",
"the",
"peep",
"hash",
"of",
"one",
"or",
"more",
"files",
"returning",
"a",
"shell",
"status",
"code",
"or",
"raising",
"a",
"PipException",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L287-L306 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | memoize | Memoize a method that should return the same result every time on a
given instance. | peep.py | 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):
"""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... | [
"Memoize",
"a",
"method",
"that",
"should",
"return",
"the",
"same",
"result",
"every",
"time",
"on",
"a",
"given",
"instance",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L321-L333 | [
"def",
"memoize",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"memoizer",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_cache'",
")",
":",
"self",
".",
"_cache",
"=",
"{",
"}",
"if",
"func",
".",
"__name__"... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | package_finder | Return a PackageFinder respecting command-line options.
:arg argv: Everything after the subcommand | peep.py | 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):
"""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... | [
"Return",
"a",
"PackageFinder",
"respecting",
"command",
"-",
"line",
"options",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L336-L390 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | bucket | Return a map of key -> list of things. | peep.py | 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):
"""Return a map of key -> list of things."""
ret = defaultdict(list)
for thing in things:
ret[key(thing)].append(thing)
return ret | [
"Return",
"a",
"map",
"of",
"key",
"-",
">",
"list",
"of",
"things",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L793-L798 | [
"def",
"bucket",
"(",
"things",
",",
"key",
")",
":",
"ret",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"thing",
"in",
"things",
":",
"ret",
"[",
"key",
"(",
"thing",
")",
"]",
".",
"append",
"(",
"thing",
")",
"return",
"ret"
] | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | 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. | peep.py | 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):
"""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_... | [
"Execute",
"something",
"before",
"the",
"first",
"item",
"of",
"iter",
"something",
"else",
"for",
"each",
"item",
"and",
"a",
"third",
"thing",
"after",
"the",
"last",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L801-L815 | [
"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",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | downloaded_reqs_from_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 | peep.py | 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):
"""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)
... | [
"Return",
"a",
"list",
"of",
"DownloadedReqs",
"representing",
"the",
"requirements",
"parsed",
"out",
"of",
"a",
"given",
"requirements",
"file",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L834-L844 | [
"def",
"downloaded_reqs_from_path",
"(",
"path",
",",
"argv",
")",
":",
"finder",
"=",
"package_finder",
"(",
"argv",
")",
"return",
"[",
"DownloadedReq",
"(",
"req",
",",
"argv",
",",
"finder",
")",
"for",
"req",
"in",
"_parse_requirements",
"(",
"path",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | peep_install | Perform the ``peep install`` subcommand, returning a shell status code
or raising a PipException.
:arg argv: The commandline args, starting after the subcommand | peep.py | 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):
"""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,... | [
"Perform",
"the",
"peep",
"install",
"subcommand",
"returning",
"a",
"shell",
"status",
"code",
"or",
"raising",
"a",
"PipException",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L847-L898 | [
"def",
"peep_install",
"(",
"argv",
")",
":",
"output",
"=",
"[",
"]",
"out",
"=",
"output",
".",
"append",
"reqs",
"=",
"[",
"]",
"try",
":",
"req_paths",
"=",
"list",
"(",
"requirement_args",
"(",
"argv",
",",
"want_paths",
"=",
"True",
")",
")",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | peep_port | 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. | peep.py | 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):
"""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 ... | [
"Convert",
"a",
"peep",
"requirements",
"file",
"to",
"one",
"compatble",
"with",
"pip",
"-",
"8",
"hashing",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L901-L932 | [
"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",
"... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | main | Be the top-level entrypoint. Return a shell status code. | peep.py | 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():
"""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:
... | [
"Be",
"the",
"top",
"-",
"level",
"entrypoint",
".",
"Return",
"a",
"shell",
"status",
"code",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L935-L947 | [
"def",
"main",
"(",
")",
":",
"commands",
"=",
"{",
"'hash'",
":",
"peep_hash",
",",
"'install'",
":",
"peep_install",
",",
"'port'",
":",
"peep_port",
"}",
"try",
":",
"if",
"len",
"(",
"argv",
")",
">=",
"2",
"and",
"argv",
"[",
"1",
"]",
"in",
... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._version | Deduce the version number of the downloaded package from its filename. | peep.py | 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):
"""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, ... | [
"Deduce",
"the",
"version",
"number",
"of",
"the",
"downloaded",
"package",
"from",
"its",
"filename",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L432-L471 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._is_always_unsatisfied | Returns whether this requirement is always unsatisfied
This would happen in cases where we can't determine the version
from the filename. | peep.py | 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):
"""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... | [
"Returns",
"whether",
"this",
"requirement",
"is",
"always",
"unsatisfied"
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L473-L490 | [
"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",
"=... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._download | 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... | peep.py | 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):
"""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... | [
"Download",
"a",
"file",
"and",
"return",
"its",
"name",
"within",
"my",
"temp",
"dir",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L497-L586 | [
"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",
"(",
")",
")",
"# ... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._downloaded_filename | 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.py | 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):
"""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 ... | [
"Download",
"the",
"package",
"s",
"archive",
"if",
"necessary",
"and",
"return",
"its",
"filename",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L590-L639 | [
"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... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq.install | Install the package I represent, without dependencies.
Obey typical pip-install options passed in on the command line. | peep.py | 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):
"""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())
... | [
"Install",
"the",
"package",
"I",
"represent",
"without",
"dependencies",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L641-L652 | [
"def",
"install",
"(",
"self",
")",
":",
"other_args",
"=",
"list",
"(",
"requirement_args",
"(",
"self",
".",
"_argv",
",",
"want_other",
"=",
"True",
")",
")",
"archive_path",
"=",
"join",
"(",
"self",
".",
"_temp_path",
",",
"self",
".",
"_downloaded_... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._project_name | Return the inner Requirement's "unsafe name".
Raise ValueError if there is no name. | peep.py | 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):
"""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:
... | [
"Return",
"the",
"inner",
"Requirement",
"s",
"unsafe",
"name",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L659-L671 | [
"def",
"_project_name",
"(",
"self",
")",
":",
"name",
"=",
"getattr",
"(",
"self",
".",
"_req",
".",
"req",
",",
"'project_name'",
",",
"''",
")",
"if",
"name",
":",
"return",
"name",
"name",
"=",
"getattr",
"(",
"self",
".",
"_req",
".",
"req",
"... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | DownloadedReq._class | Return the class I should be, spanning a continuum of goodness. | peep.py | 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):
"""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... | [
"Return",
"the",
"class",
"I",
"should",
"be",
"spanning",
"a",
"continuum",
"of",
"goodness",
"."
] | erikrose/peep | python | https://github.com/erikrose/peep/blob/c16f08c7f61e2f2afecb7cd1c93752bdd96c4968/peep.py#L694-L706 | [
"def",
"_class",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_project_name",
"(",
")",
"except",
"ValueError",
":",
"return",
"MalformedReq",
"if",
"self",
".",
"_is_satisfied",
"(",
")",
":",
"return",
"SatisfiedReq",
"if",
"not",
"self",
".",
"_ex... | c16f08c7f61e2f2afecb7cd1c93752bdd96c4968 |
train | Order.check | Logic extracted from:
http://developer.oanda.com/rest-live/orders/#createNewOrder | pyoanda/order.py | 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):
"""
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... | [
"Logic",
"extracted",
"from",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#createNewOrder"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/order.py#L21-L67 | [
"def",
"check",
"(",
"self",
")",
":",
"for",
"k",
"in",
"iter",
"(",
"self",
".",
"__dict__",
".",
"keys",
"(",
")",
")",
":",
"if",
"k",
"not",
"in",
"self",
".",
"__allowed",
":",
"raise",
"TypeError",
"(",
"\"Parameter not allowed {}\"",
".",
"fo... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | gui | Main function | GUI/gui_examples/login.py | 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():
"""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(... | [
"Main",
"function"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/login.py#L25-L134 | [
"def",
"gui",
"(",
")",
":",
"global",
"SCREEN_SIZE",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"screen",
"=",
"new_widow",
"(",
")",
"pygame",
".",
"display",
".",
"set_caption",
"(",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | gui | Main function | GUI/gui_examples/empty_template.py | 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():
"""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])
... | [
"Main",
"function"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/empty_template.py#L25-L72 | [
"def",
"gui",
"(",
")",
":",
"global",
"SCREEN_SIZE",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"# centers the windows",
"screen",
"=",
"new_screen",
"(",
")",
"pygame",
".",
"display",
"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Client.__get_response | 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 ... | pyoanda/client.py | 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):
"""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 ... | [
"Creates",
"a",
"response",
"object",
"with",
"the",
"given",
"params",
"and",
"option"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L54-L91 | [
"def",
"__get_response",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
",",
"stream",
"=",
"False",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"session\"",
")",
"or",
"not",
"self",
".",
"session",
":"... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.__call | Only returns the response, nor the status_code | pyoanda/client.py | 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"):
"""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:
... | [
"Only",
"returns",
"the",
"response",
"nor",
"the",
"status_code"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L93-L108 | [
"def",
"__call",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"__get_response",
"(",
"uri",
",",
"params",
",",
"method",
",",
"False",
")",
"rjson",
"=",
"resp"... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.__call_stream | Returns an stream response | pyoanda/client.py | 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"):
"""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... | [
"Returns",
"an",
"stream",
"response"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L110-L121 | [
"def",
"__call_stream",
"(",
"self",
",",
"uri",
",",
"params",
"=",
"None",
",",
"method",
"=",
"\"get\"",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"__get_response",
"(",
"uri",
",",
"params",
",",
"method",
",",
"True",
")",
"assert",
"resp"... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_instruments | See more:
http://developer.oanda.com/rest-live/rates/#getInstrumentList | pyoanda/client.py | 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):
"""
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... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#getInstrumentList"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L123-L137 | [
"def",
"get_instruments",
"(",
"self",
")",
":",
"url",
"=",
"\"{0}/{1}/instruments\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"accountId\"",
":",
"self",
".",
"account_id",
"}",
"try",
":",
... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_prices | See more:
http://developer.oanda.com/rest-live/rates/#getCurrentPrices | pyoanda/client.py | 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):
"""
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 =... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#getCurrentPrices"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L139-L160 | [
"def",
"get_prices",
"(",
"self",
",",
"instruments",
",",
"stream",
"=",
"True",
")",
":",
"url",
"=",
"\"{0}/{1}/prices\"",
".",
"format",
"(",
"self",
".",
"domain_stream",
"if",
"stream",
"else",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_instrument_history | See more:
http://developer.oanda.com/rest-live/rates/#retrieveInstrumentHistory | pyoanda/client.py | 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_alignment="Monday", start=None,
end=None):
... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"rates",
"/",
"#retrieveInstrumentHistory"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L162-L189 | [
"def",
"get_instrument_history",
"(",
"self",
",",
"instrument",
",",
"candle_format",
"=",
"\"bidask\"",
",",
"granularity",
"=",
"'S5'",
",",
"count",
"=",
"500",
",",
"daily_alignment",
"=",
"None",
",",
"alignment_timezone",
"=",
"None",
",",
"weekly_alignme... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_orders | See more:
http://developer.oanda.com/rest-live/orders/#getOrdersForAnAccount | pyoanda/client.py | 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):
"""
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
)
... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#getOrdersForAnAccount"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L191-L207 | [
"def",
"get_orders",
"(",
"self",
",",
"instrument",
"=",
"None",
",",
"count",
"=",
"50",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/orders\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_order | See more:
http://developer.oanda.com/rest-live/orders/#getInformationForAnOrder | pyoanda/client.py | 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):
"""
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
... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#getInformationForAnOrder"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L209-L225 | [
"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... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.create_order | See more:
http://developer.oanda.com/rest-live/orders/#createNewOrder | pyoanda/client.py | 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):
"""
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... | [
"See",
"more",
":",
"http",
":",
"//",
"developer",
".",
"oanda",
".",
"com",
"/",
"rest",
"-",
"live",
"/",
"orders",
"/",
"#createNewOrder"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L227-L246 | [
"def",
"create_order",
"(",
"self",
",",
"order",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/orders\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
")",
"try",
":",
"return",
"self",
".",
... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_trades | 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... | pyoanda/client.py | 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):
""" 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)
... | [
"Get",
"a",
"list",
"of",
"open",
"trades"
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L288-L327 | [
"def",
"get_trades",
"(",
"self",
",",
"max_id",
"=",
"None",
",",
"count",
"=",
"None",
",",
"instrument",
"=",
"None",
",",
"ids",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/trades\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.update_trade | 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... | pyoanda/client.py | 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
):
""" Modify an existing trade.
Note: Only the specified parameters will be modified. All
other parameters will remain unchanged. To remove an
... | [
"Modify",
"an",
"existing",
"trade",
"."
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L353-L397 | [
"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",
",... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.request_transaction_history | 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 ... | pyoanda/client.py | 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):
""" 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... | [
"Request",
"full",
"account",
"history",
"."
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L562-L587 | [
"def",
"request_transaction_history",
"(",
"self",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts/{2}/alltransactions\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
",",
"self",
".",
"account_id",
")",
"try",
":",
"resp",
"=",
"self... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_transaction_history | 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... | pyoanda/client.py | 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):
""" 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.... | [
"Download",
"full",
"account",
"history",
"."
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L589-L642 | [
"def",
"get_transaction_history",
"(",
"self",
",",
"max_wait",
"=",
"5.0",
")",
":",
"url",
"=",
"self",
".",
"request_transaction_history",
"(",
")",
"if",
"not",
"url",
":",
"return",
"False",
"ready",
"=",
"False",
"start",
"=",
"time",
"(",
")",
"de... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.create_account | 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 | pyoanda/client.py | 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):
""" 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... | [
"Create",
"a",
"new",
"account",
"."
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L644-L661 | [
"def",
"create_account",
"(",
"self",
",",
"currency",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"currency\"",
":",
"currency",
"}",
"... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | Client.get_accounts | 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:
... | pyoanda/client.py | 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):
""" 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
... | [
"Get",
"a",
"list",
"of",
"accounts",
"owned",
"by",
"the",
"user",
"."
] | toloco/pyoanda | python | https://github.com/toloco/pyoanda/blob/26b3f28a89d07c5c20d2a645884505387f1daae8/pyoanda/client.py#L663-L683 | [
"def",
"get_accounts",
"(",
"self",
",",
"username",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}/accounts\"",
".",
"format",
"(",
"self",
".",
"domain",
",",
"self",
".",
"API_VERSION",
")",
"params",
"=",
"{",
"\"username\"",
":",
"username",
"}",
"tr... | 26b3f28a89d07c5c20d2a645884505387f1daae8 |
train | MenuElement.choose | Marks the item as the one the user is in. | GUI/menu.py | 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):
"""Marks the item as the one the user is in."""
if not self.choosed:
self.choosed = True
self.pos = self.pos + Sep(5, 0) | [
"Marks",
"the",
"item",
"as",
"the",
"one",
"the",
"user",
"is",
"in",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L127-L131 | [
"def",
"choose",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"choosed",
":",
"self",
".",
"choosed",
"=",
"True",
"self",
".",
"pos",
"=",
"self",
".",
"pos",
"+",
"Sep",
"(",
"5",
",",
"0",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | MenuElement.stop_choose | Marks the item as the one the user is not in. | GUI/menu.py | 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):
"""Marks the item as the one the user is not in."""
if self.choosed:
self.choosed = False
self.pos = self.pos + Sep(-5, 0) | [
"Marks",
"the",
"item",
"as",
"the",
"one",
"the",
"user",
"is",
"not",
"in",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L133-L137 | [
"def",
"stop_choose",
"(",
"self",
")",
":",
"if",
"self",
".",
"choosed",
":",
"self",
".",
"choosed",
"=",
"False",
"self",
".",
"pos",
"=",
"self",
".",
"pos",
"+",
"Sep",
"(",
"-",
"5",
",",
"0",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | MenuElement.get_darker_color | The color of the clicked version of the MenuElement. Darker than the normal one. | GUI/menu.py | 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):
"""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 =... | [
"The",
"color",
"of",
"the",
"clicked",
"version",
"of",
"the",
"MenuElement",
".",
"Darker",
"than",
"the",
"normal",
"one",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L145-L153 | [
"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",
",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | MenuElement.render | Renders the MenuElement | GUI/menu.py | def render(self, screen):
"""Renders the MenuElement"""
self.rect.render(screen)
super(MenuElement, self).render(screen) | def render(self, screen):
"""Renders the MenuElement"""
self.rect.render(screen)
super(MenuElement, self).render(screen) | [
"Renders",
"the",
"MenuElement"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/menu.py#L155-L158 | [
"def",
"render",
"(",
"self",
",",
"screen",
")",
":",
"self",
".",
"rect",
".",
"render",
"(",
"screen",
")",
"super",
"(",
"MenuElement",
",",
"self",
")",
".",
"render",
"(",
"screen",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | gui | Main function | GUI/gui_examples/bezier.py | 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():
"""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... | [
"Main",
"function"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/bezier.py#L17-L105 | [
"def",
"gui",
"(",
")",
":",
"# #######",
"# setup all objects",
"# #######",
"zones",
"=",
"[",
"ALL",
"]",
"last_zones",
"=",
"[",
"]",
"COLORS",
".",
"remove",
"(",
"WHITE",
")",
"screen",
"=",
"pygame",
".",
"display",
".",
"set_mode",
"(",
"SCREEN_S... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | gui | Main function | GUI/gui_examples/morpion.py | 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():
"""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()
... | [
"Main",
"function"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/gui_examples/morpion.py#L188-L248 | [
"def",
"gui",
"(",
")",
":",
"# #######",
"# setup all objects",
"# #######",
"os",
".",
"environ",
"[",
"'SDL_VIDEO_CENTERED'",
"]",
"=",
"'1'",
"clock",
"=",
"pygame",
".",
"time",
".",
"Clock",
"(",
")",
"screen",
"=",
"pygame",
".",
"display",
".",
"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Font.px_to_pt | Convert a size in pxel to a size in points. | GUI/font.py | 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):
"""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 | [
"Convert",
"a",
"size",
"in",
"pxel",
"to",
"a",
"size",
"in",
"points",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/font.py#L45-L52 | [
"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... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | Font.set_size | 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. | GUI/font.py | 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):
"""
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,... | [
"Set",
"the",
"size",
"of",
"the",
"font",
"in",
"px",
"or",
"pt",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/font.py#L54-L67 | [
"def",
"set_size",
"(",
"self",
",",
"pt",
"=",
"None",
",",
"px",
"=",
"None",
")",
":",
"assert",
"(",
"pt",
",",
"px",
")",
"!=",
"(",
"None",
",",
"None",
")",
"if",
"pt",
"is",
"not",
"None",
":",
"self",
".",
"__init__",
"(",
"pt",
",",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText.text | Return the string to render. | GUI/text.py | def text(self):
"""Return the string to render."""
if callable(self._text):
return str(self._text())
return str(self._text) | def text(self):
"""Return the string to render."""
if callable(self._text):
return str(self._text())
return str(self._text) | [
"Return",
"the",
"string",
"to",
"render",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L55-L59 | [
"def",
"text",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"_text",
")",
":",
"return",
"str",
"(",
"self",
".",
"_text",
"(",
")",
")",
"return",
"str",
"(",
"self",
".",
"_text",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText.color | Set the color to a new value (tuple). Renders the text if needed. | GUI/text.py | 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):
"""Set the color to a new value (tuple). Renders the text if needed."""
if value != self.color:
self._color = value
self._render() | [
"Set",
"the",
"color",
"to",
"a",
"new",
"value",
"(",
"tuple",
")",
".",
"Renders",
"the",
"text",
"if",
"needed",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L76-L81 | [
"def",
"color",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"color",
":",
"self",
".",
"_color",
"=",
"value",
"self",
".",
"_render",
"(",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText.bg_color | Sets the color to a new value (tuple). Renders the text if needed. | GUI/text.py | 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):
"""Sets the color to a new value (tuple). Renders the text if needed."""
if value != self.bg_color:
self._bg_color = value
self._render() | [
"Sets",
"the",
"color",
"to",
"a",
"new",
"value",
"(",
"tuple",
")",
".",
"Renders",
"the",
"text",
"if",
"needed",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L84-L89 | [
"def",
"bg_color",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"bg_color",
":",
"self",
".",
"_bg_color",
"=",
"value",
"self",
".",
"_render",
"(",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText.set_font_size | Set the font size to the desired size, in pt or px. | GUI/text.py | 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):
"""Set the font size to the desired size, in pt or px."""
self.font.set_size(pt, px)
self._render() | [
"Set",
"the",
"font",
"size",
"to",
"the",
"desired",
"size",
"in",
"pt",
"or",
"px",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L91-L95 | [
"def",
"set_font_size",
"(",
"self",
",",
"pt",
"=",
"None",
",",
"px",
"=",
"None",
")",
":",
"self",
".",
"font",
".",
"set_size",
"(",
"pt",
",",
"px",
")",
"self",
".",
"_render",
"(",
")"
] | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText._render | Render the text.
Avoid using this fonction too many time as it is slow as it is low to render text and blit it. | GUI/text.py | 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):
"""
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... | [
"Render",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L97-L109 | [
"def",
"_render",
"(",
"self",
")",
":",
"self",
".",
"_last_text",
"=",
"self",
".",
"text",
"self",
".",
"_surface",
"=",
"self",
".",
"font",
".",
"render",
"(",
"self",
".",
"text",
",",
"True",
",",
"self",
".",
"color",
",",
"self",
".",
"b... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | SimpleText.render | Render basicly the text. | GUI/text.py | def render(self, display):
"""Render basicly the text."""
# to handle changing objects / callable
if self.text != self._last_text:
self._render()
display.blit(self._surface, (self.topleft, self.size)) | def render(self, display):
"""Render basicly the text."""
# to handle changing objects / callable
if self.text != self._last_text:
self._render()
display.blit(self._surface, (self.topleft, self.size)) | [
"Render",
"basicly",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L111-L117 | [
"def",
"render",
"(",
"self",
",",
"display",
")",
":",
"# to handle changing objects / callable",
"if",
"self",
".",
"text",
"!=",
"self",
".",
"_last_text",
":",
"self",
".",
"_render",
"(",
")",
"display",
".",
"blit",
"(",
"self",
".",
"_surface",
",",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.cursor | The position of the cursor in the text. | GUI/text.py | def cursor(self):
"""The position of the cursor in the text."""
if self._cursor < 0:
self.cursor = 0
if self._cursor > len(self):
self.cursor = len(self)
return self._cursor | def cursor(self):
"""The position of the cursor in the text."""
if self._cursor < 0:
self.cursor = 0
if self._cursor > len(self):
self.cursor = len(self)
return self._cursor | [
"The",
"position",
"of",
"the",
"cursor",
"in",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L151-L159 | [
"def",
"cursor",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cursor",
"<",
"0",
":",
"self",
".",
"cursor",
"=",
"0",
"if",
"self",
".",
"_cursor",
">",
"len",
"(",
"self",
")",
":",
"self",
".",
"cursor",
"=",
"len",
"(",
"self",
")",
"return"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.move_cursor_one_letter | Move the cursor of one letter to the right (1) or the the left. | GUI/text.py | def move_cursor_one_letter(self, letter=RIGHT):
"""Move the cursor of one letter to the right (1) or the the left."""
assert letter in (self.RIGHT, self.LEFT)
if letter == self.RIGHT:
self.cursor += 1
if self.cursor > len(self.text):
self.cursor -= 1
... | def move_cursor_one_letter(self, letter=RIGHT):
"""Move the cursor of one letter to the right (1) or the the left."""
assert letter in (self.RIGHT, self.LEFT)
if letter == self.RIGHT:
self.cursor += 1
if self.cursor > len(self.text):
self.cursor -= 1
... | [
"Move",
"the",
"cursor",
"of",
"one",
"letter",
"to",
"the",
"right",
"(",
"1",
")",
"or",
"the",
"the",
"left",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L184-L195 | [
"def",
"move_cursor_one_letter",
"(",
"self",
",",
"letter",
"=",
"RIGHT",
")",
":",
"assert",
"letter",
"in",
"(",
"self",
".",
"RIGHT",
",",
"self",
".",
"LEFT",
")",
"if",
"letter",
"==",
"self",
".",
"RIGHT",
":",
"self",
".",
"cursor",
"+=",
"1"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.move_cursor_one_word | Move the cursor of one word to the right (1) or the the left (-1). | GUI/text.py | def move_cursor_one_word(self, word=LEFT):
"""Move the cursor of one word to the right (1) or the the left (-1)."""
assert word in (self.RIGHT, self.LEFT)
if word == self.RIGHT:
papy = self.text.find(' ', self.cursor) + 1
if not papy:
papy = len(self)
... | def move_cursor_one_word(self, word=LEFT):
"""Move the cursor of one word to the right (1) or the the left (-1)."""
assert word in (self.RIGHT, self.LEFT)
if word == self.RIGHT:
papy = self.text.find(' ', self.cursor) + 1
if not papy:
papy = len(self)
... | [
"Move",
"the",
"cursor",
"of",
"one",
"word",
"to",
"the",
"right",
"(",
"1",
")",
"or",
"the",
"the",
"left",
"(",
"-",
"1",
")",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L197-L211 | [
"def",
"move_cursor_one_word",
"(",
"self",
",",
"word",
"=",
"LEFT",
")",
":",
"assert",
"word",
"in",
"(",
"self",
".",
"RIGHT",
",",
"self",
".",
"LEFT",
")",
"if",
"word",
"==",
"self",
".",
"RIGHT",
":",
"papy",
"=",
"self",
".",
"text",
".",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.delete_one_letter | Delete one letter the right or the the left of the cursor. | GUI/text.py | def delete_one_letter(self, letter=RIGHT):
"""Delete one letter the right or the the left of the cursor."""
assert letter in (self.RIGHT, self.LEFT)
if letter == self.LEFT:
papy = self.cursor
self.text = self.text[:self.cursor - 1] + self.text[self.cursor:]
... | def delete_one_letter(self, letter=RIGHT):
"""Delete one letter the right or the the left of the cursor."""
assert letter in (self.RIGHT, self.LEFT)
if letter == self.LEFT:
papy = self.cursor
self.text = self.text[:self.cursor - 1] + self.text[self.cursor:]
... | [
"Delete",
"one",
"letter",
"the",
"right",
"or",
"the",
"the",
"left",
"of",
"the",
"cursor",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L213-L224 | [
"def",
"delete_one_letter",
"(",
"self",
",",
"letter",
"=",
"RIGHT",
")",
":",
"assert",
"letter",
"in",
"(",
"self",
".",
"RIGHT",
",",
"self",
".",
"LEFT",
")",
"if",
"letter",
"==",
"self",
".",
"LEFT",
":",
"papy",
"=",
"self",
".",
"cursor",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.delete_one_word | Delete one word the right or the the left of the cursor. | GUI/text.py | def delete_one_word(self, word=RIGHT):
"""Delete one word the right or the the left of the cursor."""
assert word in (self.RIGHT, self.LEFT)
if word == self.RIGHT:
papy = self.text.find(' ', self.cursor) + 1
if not papy:
papy = len(self.text)
... | def delete_one_word(self, word=RIGHT):
"""Delete one word the right or the the left of the cursor."""
assert word in (self.RIGHT, self.LEFT)
if word == self.RIGHT:
papy = self.text.find(' ', self.cursor) + 1
if not papy:
papy = len(self.text)
... | [
"Delete",
"one",
"word",
"the",
"right",
"or",
"the",
"the",
"left",
"of",
"the",
"cursor",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L226-L242 | [
"def",
"delete_one_word",
"(",
"self",
",",
"word",
"=",
"RIGHT",
")",
":",
"assert",
"word",
"in",
"(",
"self",
".",
"RIGHT",
",",
"self",
".",
"LEFT",
")",
"if",
"word",
"==",
"self",
".",
"RIGHT",
":",
"papy",
"=",
"self",
".",
"text",
".",
"f... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.add_letter | Add a letter at the cursor pos. | GUI/text.py | def add_letter(self, letter):
"""Add a letter at the cursor pos."""
assert isinstance(letter, str)
assert len(letter) == 1
self.text = self.text[:self.cursor] + letter + self.text[self.cursor:]
self.cursor += 1 | def add_letter(self, letter):
"""Add a letter at the cursor pos."""
assert isinstance(letter, str)
assert len(letter) == 1
self.text = self.text[:self.cursor] + letter + self.text[self.cursor:]
self.cursor += 1 | [
"Add",
"a",
"letter",
"at",
"the",
"cursor",
"pos",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L244-L250 | [
"def",
"add_letter",
"(",
"self",
",",
"letter",
")",
":",
"assert",
"isinstance",
"(",
"letter",
",",
"str",
")",
"assert",
"len",
"(",
"letter",
")",
"==",
"1",
"self",
".",
"text",
"=",
"self",
".",
"text",
"[",
":",
"self",
".",
"cursor",
"]",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox.update | Update the text and position of cursor according to the event passed. | GUI/text.py | def update(self, event_or_list):
"""Update the text and position of cursor according to the event passed."""
event_or_list = super().update(event_or_list)
for e in event_or_list:
if e.type == KEYDOWN:
if e.key == K_RIGHT:
if e.mod * KMOD_CTRL:
... | def update(self, event_or_list):
"""Update the text and position of cursor according to the event passed."""
event_or_list = super().update(event_or_list)
for e in event_or_list:
if e.type == KEYDOWN:
if e.key == K_RIGHT:
if e.mod * KMOD_CTRL:
... | [
"Update",
"the",
"text",
"and",
"position",
"of",
"cursor",
"according",
"to",
"the",
"event",
"passed",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L256-L291 | [
"def",
"update",
"(",
"self",
",",
"event_or_list",
")",
":",
"event_or_list",
"=",
"super",
"(",
")",
".",
"update",
"(",
"event_or_list",
")",
"for",
"e",
"in",
"event_or_list",
":",
"if",
"e",
".",
"type",
"==",
"KEYDOWN",
":",
"if",
"e",
".",
"ke... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLineTextBox._render | Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. | GUI/text.py | def _render(self):
"""
Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
"""
self._last_text = self.text
self._surface = self.font.render(self.text, True, self.color, self.bg_color)
size = self.wid... | def _render(self):
"""
Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
"""
self._last_text = self.text
self._surface = self.font.render(self.text, True, self.color, self.bg_color)
size = self.wid... | [
"Render",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L293-L304 | [
"def",
"_render",
"(",
"self",
")",
":",
"self",
".",
"_last_text",
"=",
"self",
".",
"text",
"self",
".",
"_surface",
"=",
"self",
".",
"font",
".",
"render",
"(",
"self",
".",
"text",
",",
"True",
",",
"self",
".",
"color",
",",
"self",
".",
"b... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLinePassBox.shawn_text | The text displayed instead of the real one. | GUI/text.py | def shawn_text(self):
"""The text displayed instead of the real one."""
if len(self._shawn_text) == len(self):
return self._shawn_text
if self.style == self.DOTS:
return chr(0x2022) * len(self)
ranges = [
(902, 1366),
(192, 683),
... | def shawn_text(self):
"""The text displayed instead of the real one."""
if len(self._shawn_text) == len(self):
return self._shawn_text
if self.style == self.DOTS:
return chr(0x2022) * len(self)
ranges = [
(902, 1366),
(192, 683),
... | [
"The",
"text",
"displayed",
"instead",
"of",
"the",
"real",
"one",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L348-L372 | [
"def",
"shawn_text",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_shawn_text",
")",
"==",
"len",
"(",
"self",
")",
":",
"return",
"self",
".",
"_shawn_text",
"if",
"self",
".",
"style",
"==",
"self",
".",
"DOTS",
":",
"return",
"chr",
"(... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLinePassBox.cursor_pos | The cursor position in pixels. | GUI/text.py | def cursor_pos(self):
"""The cursor position in pixels."""
if len(self) == 0:
return self.left + self.default_text.get_width()
papy = self._surface.get_width()
if papy > self.w:
shift = papy - self.width
else:
shift = 0
return self.le... | def cursor_pos(self):
"""The cursor position in pixels."""
if len(self) == 0:
return self.left + self.default_text.get_width()
papy = self._surface.get_width()
if papy > self.w:
shift = papy - self.width
else:
shift = 0
return self.le... | [
"The",
"cursor",
"position",
"in",
"pixels",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L374-L385 | [
"def",
"cursor_pos",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
")",
"==",
"0",
":",
"return",
"self",
".",
"left",
"+",
"self",
".",
"default_text",
".",
"get_width",
"(",
")",
"papy",
"=",
"self",
".",
"_surface",
".",
"get_width",
"(",
")"... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLinePassBox._render | Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it. | GUI/text.py | def _render(self):
"""
Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
"""
self._last_text = self.shawn_text
self._surface = self.font.render(self.shawn_text, True, self.color, self.bg_color)
siz... | def _render(self):
"""
Render the text.
Avoid using this fonction too many times as it is slow as it is slow to render text and blit it.
"""
self._last_text = self.shawn_text
self._surface = self.font.render(self.shawn_text, True, self.color, self.bg_color)
siz... | [
"Render",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L387-L398 | [
"def",
"_render",
"(",
"self",
")",
":",
"self",
".",
"_last_text",
"=",
"self",
".",
"shawn_text",
"self",
".",
"_surface",
"=",
"self",
".",
"font",
".",
"render",
"(",
"self",
".",
"shawn_text",
",",
"True",
",",
"self",
".",
"color",
",",
"self",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | InLinePassBox.render | Render basicly the text. | GUI/text.py | def render(self, display):
"""Render basicly the text."""
# to handle changing objects / callable
if self.shawn_text != self._last_text:
self._render()
if self.text:
papy = self._surface.get_width()
if papy <= self.width:
display.blit... | def render(self, display):
"""Render basicly the text."""
# to handle changing objects / callable
if self.shawn_text != self._last_text:
self._render()
if self.text:
papy = self._surface.get_width()
if papy <= self.width:
display.blit... | [
"Render",
"basicly",
"the",
"text",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L400-L418 | [
"def",
"render",
"(",
"self",
",",
"display",
")",
":",
"# to handle changing objects / callable",
"if",
"self",
".",
"shawn_text",
"!=",
"self",
".",
"_last_text",
":",
"self",
".",
"_render",
"(",
")",
"if",
"self",
".",
"text",
":",
"papy",
"=",
"self",... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | LaText.latex_to_img | Return a pygame image from a latex template. | GUI/text.py | def latex_to_img(tex):
"""Return a pygame image from a latex template."""
with tempfile.TemporaryDirectory() as tmpdirname:
with open(tmpdirname + r'\tex.tex', 'w') as f:
f.write(tex)
os.system(r"latex {0}\tex.tex -halt-on-error -interaction=batchmode -disable-in... | def latex_to_img(tex):
"""Return a pygame image from a latex template."""
with tempfile.TemporaryDirectory() as tmpdirname:
with open(tmpdirname + r'\tex.tex', 'w') as f:
f.write(tex)
os.system(r"latex {0}\tex.tex -halt-on-error -interaction=batchmode -disable-in... | [
"Return",
"a",
"pygame",
"image",
"from",
"a",
"latex",
"template",
"."
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/text.py#L443-L456 | [
"def",
"latex_to_img",
"(",
"tex",
")",
":",
"with",
"tempfile",
".",
"TemporaryDirectory",
"(",
")",
"as",
"tmpdirname",
":",
"with",
"open",
"(",
"tmpdirname",
"+",
"r'\\tex.tex'",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"tex",
")",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | mix | Return the mix of two colors at a state of :pos:
Retruns color1 * pos + color2 * (1 - pos) | GUI/colors.py | def mix(color1, color2, pos=0.5):
"""
Return the mix of two colors at a state of :pos:
Retruns color1 * pos + color2 * (1 - pos)
"""
opp_pos = 1 - pos
red = color1[0] * pos + color2[0] * opp_pos
green = color1[1] * pos + color2[1] * opp_pos
blue = color1[2] * pos + color2[2] * opp_pos
... | def mix(color1, color2, pos=0.5):
"""
Return the mix of two colors at a state of :pos:
Retruns color1 * pos + color2 * (1 - pos)
"""
opp_pos = 1 - pos
red = color1[0] * pos + color2[0] * opp_pos
green = color1[1] * pos + color2[1] * opp_pos
blue = color1[2] * pos + color2[2] * opp_pos
... | [
"Return",
"the",
"mix",
"of",
"two",
"colors",
"at",
"a",
"state",
"of",
":",
"pos",
":"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/colors.py#L13-L24 | [
"def",
"mix",
"(",
"color1",
",",
"color2",
",",
"pos",
"=",
"0.5",
")",
":",
"opp_pos",
"=",
"1",
"-",
"pos",
"red",
"=",
"color1",
"[",
"0",
"]",
"*",
"pos",
"+",
"color2",
"[",
"0",
"]",
"*",
"opp_pos",
"green",
"=",
"color1",
"[",
"1",
"]... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | name2rgb | Convert the name of a color into its RGB value | GUI/colors.py | def name2rgb(name):
"""Convert the name of a color into its RGB value"""
try:
import colour
except ImportError:
raise ImportError('You need colour to be installed: pip install colour')
c = colour.Color(name)
color = int(c.red * 255), int(c.green * 255), int(c.blue * 255)
return ... | def name2rgb(name):
"""Convert the name of a color into its RGB value"""
try:
import colour
except ImportError:
raise ImportError('You need colour to be installed: pip install colour')
c = colour.Color(name)
color = int(c.red * 255), int(c.green * 255), int(c.blue * 255)
return ... | [
"Convert",
"the",
"name",
"of",
"a",
"color",
"into",
"its",
"RGB",
"value"
] | ddorn/GUI | python | https://github.com/ddorn/GUI/blob/e1fcb5286d24e0995f280d5180222e51895c368c/GUI/colors.py#L27-L36 | [
"def",
"name2rgb",
"(",
"name",
")",
":",
"try",
":",
"import",
"colour",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'You need colour to be installed: pip install colour'",
")",
"c",
"=",
"colour",
".",
"Color",
"(",
"name",
")",
"color",
"=",
... | e1fcb5286d24e0995f280d5180222e51895c368c |
train | parse_page | Parse the command man page. | tldr/parser.py | def parse_page(page):
"""Parse the command man page."""
colors = get_config()['colors']
with io.open(page, encoding='utf-8') as f:
lines = f.readlines()
output_lines = []
for line in lines[1:]:
if is_headline(line):
continue
elif is_description(line):
... | def parse_page(page):
"""Parse the command man page."""
colors = get_config()['colors']
with io.open(page, encoding='utf-8') as f:
lines = f.readlines()
output_lines = []
for line in lines[1:]:
if is_headline(line):
continue
elif is_description(line):
... | [
"Parse",
"the",
"command",
"man",
"page",
"."
] | lord63/tldr.py | python | https://github.com/lord63/tldr.py/blob/73cf9f86254691b2476910ea6a743b6d8bd04963/tldr/parser.py#L12-L34 | [
"def",
"parse_page",
"(",
"page",
")",
":",
"colors",
"=",
"get_config",
"(",
")",
"[",
"'colors'",
"]",
"with",
"io",
".",
"open",
"(",
"page",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
... | 73cf9f86254691b2476910ea6a743b6d8bd04963 |
train | configure_logging | Configure the module logging engine. | sftpclone/sftpclone.py | def configure_logging(level=logging.DEBUG):
"""Configure the module logging engine."""
if level == logging.DEBUG:
# For debugging purposes, log from everyone!
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s'
)
re... | def configure_logging(level=logging.DEBUG):
"""Configure the module logging engine."""
if level == logging.DEBUG:
# For debugging purposes, log from everyone!
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(message)s'
)
re... | [
"Configure",
"the",
"module",
"logging",
"engine",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L33-L50 | [
"def",
"configure_logging",
"(",
"level",
"=",
"logging",
".",
"DEBUG",
")",
":",
"if",
"level",
"==",
"logging",
".",
"DEBUG",
":",
"# For debugging purposes, log from everyone!",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"DEBUG",
",",
... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | path_join | Wrapper around `os.path.join`.
Makes sure to join paths of the same type (bytes). | sftpclone/sftpclone.py | def path_join(*args):
"""
Wrapper around `os.path.join`.
Makes sure to join paths of the same type (bytes).
"""
args = (paramiko.py3compat.u(arg) for arg in args)
return os.path.join(*args) | def path_join(*args):
"""
Wrapper around `os.path.join`.
Makes sure to join paths of the same type (bytes).
"""
args = (paramiko.py3compat.u(arg) for arg in args)
return os.path.join(*args) | [
"Wrapper",
"around",
"os",
".",
"path",
".",
"join",
".",
"Makes",
"sure",
"to",
"join",
"paths",
"of",
"the",
"same",
"type",
"(",
"bytes",
")",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L53-L59 | [
"def",
"path_join",
"(",
"*",
"args",
")",
":",
"args",
"=",
"(",
"paramiko",
".",
"py3compat",
".",
"u",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"*",
"args",
")"
] | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | parse_username_password_hostname | Parse a command line string and return username, password, remote hostname and remote path.
:param remote_url: A command line string.
:return: A tuple, containing username, password, remote hostname and remote path. | sftpclone/sftpclone.py | def parse_username_password_hostname(remote_url):
"""
Parse a command line string and return username, password, remote hostname and remote path.
:param remote_url: A command line string.
:return: A tuple, containing username, password, remote hostname and remote path.
"""
assert remote_url
... | def parse_username_password_hostname(remote_url):
"""
Parse a command line string and return username, password, remote hostname and remote path.
:param remote_url: A command line string.
:return: A tuple, containing username, password, remote hostname and remote path.
"""
assert remote_url
... | [
"Parse",
"a",
"command",
"line",
"string",
"and",
"return",
"username",
"password",
"remote",
"hostname",
"and",
"remote",
"path",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L62-L85 | [
"def",
"parse_username_password_hostname",
"(",
"remote_url",
")",
":",
"assert",
"remote_url",
"assert",
"':'",
"in",
"remote_url",
"if",
"'@'",
"in",
"remote_url",
":",
"username",
",",
"hostname",
"=",
"remote_url",
".",
"rsplit",
"(",
"'@'",
",",
"1",
")",... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | get_ssh_agent_keys | Ask the SSH agent for a list of keys, and return it.
:return: A reference to the SSH agent and a list of keys. | sftpclone/sftpclone.py | def get_ssh_agent_keys(logger):
"""
Ask the SSH agent for a list of keys, and return it.
:return: A reference to the SSH agent and a list of keys.
"""
agent, agent_keys = None, None
try:
agent = paramiko.agent.Agent()
_agent_keys = agent.get_keys()
if not _agent_keys:
... | def get_ssh_agent_keys(logger):
"""
Ask the SSH agent for a list of keys, and return it.
:return: A reference to the SSH agent and a list of keys.
"""
agent, agent_keys = None, None
try:
agent = paramiko.agent.Agent()
_agent_keys = agent.get_keys()
if not _agent_keys:
... | [
"Ask",
"the",
"SSH",
"agent",
"for",
"a",
"list",
"of",
"keys",
"and",
"return",
"it",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L88-L113 | [
"def",
"get_ssh_agent_keys",
"(",
"logger",
")",
":",
"agent",
",",
"agent_keys",
"=",
"None",
",",
"None",
"try",
":",
"agent",
"=",
"paramiko",
".",
"agent",
".",
"Agent",
"(",
")",
"_agent_keys",
"=",
"agent",
".",
"get_keys",
"(",
")",
"if",
"not",... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | create_parser | Create the CLI argument parser. | sftpclone/sftpclone.py | def create_parser():
"""Create the CLI argument parser."""
parser = argparse.ArgumentParser(
description='Sync a local and a remote folder through SFTP.'
)
parser.add_argument(
"path",
type=str,
metavar="local-path",
help="the path of the local folder",
)
... | def create_parser():
"""Create the CLI argument parser."""
parser = argparse.ArgumentParser(
description='Sync a local and a remote folder through SFTP.'
)
parser.add_argument(
"path",
type=str,
metavar="local-path",
help="the path of the local folder",
)
... | [
"Create",
"the",
"CLI",
"argument",
"parser",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L628-L747 | [
"def",
"create_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Sync a local and a remote folder through SFTP.'",
")",
"parser",
".",
"add_argument",
"(",
"\"path\"",
",",
"type",
"=",
"str",
",",
"metavar",
"=",... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | main | The main. | sftpclone/sftpclone.py | def main(args=None):
"""The main."""
parser = create_parser()
args = vars(parser.parse_args(args))
log_mapping = {
'CRITICAL': logging.CRITICAL,
'ERROR': logging.ERROR,
'WARNING': logging.WARNING,
'INFO': logging.INFO,
'DEBUG': logging.DEBUG,
'NOTSET': lo... | def main(args=None):
"""The main."""
parser = create_parser()
args = vars(parser.parse_args(args))
log_mapping = {
'CRITICAL': logging.CRITICAL,
'ERROR': logging.ERROR,
'WARNING': logging.WARNING,
'INFO': logging.INFO,
'DEBUG': logging.DEBUG,
'NOTSET': lo... | [
"The",
"main",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L750-L806 | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"parser",
"=",
"create_parser",
"(",
")",
"args",
"=",
"vars",
"(",
"parser",
".",
"parse_args",
"(",
"args",
")",
")",
"log_mapping",
"=",
"{",
"'CRITICAL'",
":",
"logging",
".",
"CRITICAL",
",",
"'... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
train | SFTPClone._must_be_deleted | Return True if the remote correspondent of local_path has to be deleted.
i.e. if it doesn't exists locally or if it has a different type from the remote one. | sftpclone/sftpclone.py | def _must_be_deleted(local_path, r_st):
"""Return True if the remote correspondent of local_path has to be deleted.
i.e. if it doesn't exists locally or if it has a different type from the remote one."""
# if the file doesn't exists
if not os.path.lexists(local_path):
return... | def _must_be_deleted(local_path, r_st):
"""Return True if the remote correspondent of local_path has to be deleted.
i.e. if it doesn't exists locally or if it has a different type from the remote one."""
# if the file doesn't exists
if not os.path.lexists(local_path):
return... | [
"Return",
"True",
"if",
"the",
"remote",
"correspondent",
"of",
"local_path",
"has",
"to",
"be",
"deleted",
"."
] | unbit/sftpclone | python | https://github.com/unbit/sftpclone/blob/1cc89478e680fc4e0d12b1a15b5bafd0390d05da/sftpclone/sftpclone.py#L369-L382 | [
"def",
"_must_be_deleted",
"(",
"local_path",
",",
"r_st",
")",
":",
"# if the file doesn't exists",
"if",
"not",
"os",
".",
"path",
".",
"lexists",
"(",
"local_path",
")",
":",
"return",
"True",
"# or if the file type is different",
"l_st",
"=",
"os",
".",
"lst... | 1cc89478e680fc4e0d12b1a15b5bafd0390d05da |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.