id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,000 | MostAwesomeDude/blackjack | blackjack.py | Node.delete_min | def delete_min(self):
"""
Delete the left-most value from a tree.
"""
# Base case: If there are no nodes lesser than this node, then this is the
# node to delete.
if self.left is NULL:
return NULL, self.value
# Acquire more reds if necessary to conti... | python | def delete_min(self):
"""
Delete the left-most value from a tree.
"""
# Base case: If there are no nodes lesser than this node, then this is the
# node to delete.
if self.left is NULL:
return NULL, self.value
# Acquire more reds if necessary to conti... | [
"def",
"delete_min",
"(",
"self",
")",
":",
"# Base case: If there are no nodes lesser than this node, then this is the",
"# node to delete.",
"if",
"self",
".",
"left",
"is",
"NULL",
":",
"return",
"NULL",
",",
"self",
".",
"value",
"# Acquire more reds if necessary to con... | Delete the left-most value from a tree. | [
"Delete",
"the",
"left",
"-",
"most",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L158-L178 |
41,001 | MostAwesomeDude/blackjack | blackjack.py | Node.delete_max | def delete_max(self):
"""
Delete the right-most value from a tree.
"""
# Attempt to rotate left-leaning reds to the right.
if self.left.red:
self = self.rotate_right()
# Base case: If there are no selfs greater than this self, then this is
# the self... | python | def delete_max(self):
"""
Delete the right-most value from a tree.
"""
# Attempt to rotate left-leaning reds to the right.
if self.left.red:
self = self.rotate_right()
# Base case: If there are no selfs greater than this self, then this is
# the self... | [
"def",
"delete_max",
"(",
"self",
")",
":",
"# Attempt to rotate left-leaning reds to the right.",
"if",
"self",
".",
"left",
".",
"red",
":",
"self",
"=",
"self",
".",
"rotate_right",
"(",
")",
"# Base case: If there are no selfs greater than this self, then this is",
"#... | Delete the right-most value from a tree. | [
"Delete",
"the",
"right",
"-",
"most",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L180-L204 |
41,002 | MostAwesomeDude/blackjack | blackjack.py | Node.delete | def delete(self, value, key):
"""
Delete a value from a tree.
"""
# Base case: The empty tree cannot possibly have the desired value.
if self is NULL:
raise KeyError(value)
direction = cmp(key(value), key(self.value))
# Because we lean to the left, ... | python | def delete(self, value, key):
"""
Delete a value from a tree.
"""
# Base case: The empty tree cannot possibly have the desired value.
if self is NULL:
raise KeyError(value)
direction = cmp(key(value), key(self.value))
# Because we lean to the left, ... | [
"def",
"delete",
"(",
"self",
",",
"value",
",",
"key",
")",
":",
"# Base case: The empty tree cannot possibly have the desired value.",
"if",
"self",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"value",
")",
"direction",
"=",
"cmp",
"(",
"key",
"(",
"value",
... | Delete a value from a tree. | [
"Delete",
"a",
"value",
"from",
"a",
"tree",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L206-L264 |
41,003 | MostAwesomeDude/blackjack | blackjack.py | BJ.pop_max | def pop_max(self):
"""
Remove the maximum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_max()
self._len -= 1
return value | python | def pop_max(self):
"""
Remove the maximum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_max()
self._len -= 1
return value | [
"def",
"pop_max",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"\"pop from an empty blackjack\"",
")",
"self",
".",
"root",
",",
"value",
"=",
"self",
".",
"root",
".",
"delete_max",
"(",
")",
"self",
"... | Remove the maximum value and return it. | [
"Remove",
"the",
"maximum",
"value",
"and",
"return",
"it",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L339-L349 |
41,004 | MostAwesomeDude/blackjack | blackjack.py | BJ.pop_min | def pop_min(self):
"""
Remove the minimum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_min()
self._len -= 1
return value | python | def pop_min(self):
"""
Remove the minimum value and return it.
"""
if self.root is NULL:
raise KeyError("pop from an empty blackjack")
self.root, value = self.root.delete_min()
self._len -= 1
return value | [
"def",
"pop_min",
"(",
"self",
")",
":",
"if",
"self",
".",
"root",
"is",
"NULL",
":",
"raise",
"KeyError",
"(",
"\"pop from an empty blackjack\"",
")",
"self",
".",
"root",
",",
"value",
"=",
"self",
".",
"root",
".",
"delete_min",
"(",
")",
"self",
"... | Remove the minimum value and return it. | [
"Remove",
"the",
"minimum",
"value",
"and",
"return",
"it",
"."
] | 1346642e353719ab68c0dc3573aa33b688431bf8 | https://github.com/MostAwesomeDude/blackjack/blob/1346642e353719ab68c0dc3573aa33b688431bf8/blackjack.py#L351-L361 |
41,005 | SeattleTestbed/seash | pyreadline/console/console.py | install_readline | def install_readline(hook):
'''Set up things for the interpreter to call
our function like GNU readline.'''
global readline_hook, readline_ref
# save the hook so the wrapper can call it
readline_hook = hook
# get the address of PyOS_ReadlineFunctionPointer so we can update it
PyOS_RF... | python | def install_readline(hook):
'''Set up things for the interpreter to call
our function like GNU readline.'''
global readline_hook, readline_ref
# save the hook so the wrapper can call it
readline_hook = hook
# get the address of PyOS_ReadlineFunctionPointer so we can update it
PyOS_RF... | [
"def",
"install_readline",
"(",
"hook",
")",
":",
"global",
"readline_hook",
",",
"readline_ref",
"# save the hook so the wrapper can call it\r",
"readline_hook",
"=",
"hook",
"# get the address of PyOS_ReadlineFunctionPointer so we can update it\r",
"PyOS_RFP",
"=",
"c_void_p",
... | Set up things for the interpreter to call
our function like GNU readline. | [
"Set",
"up",
"things",
"for",
"the",
"interpreter",
"to",
"call",
"our",
"function",
"like",
"GNU",
"readline",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L803-L820 |
41,006 | SeattleTestbed/seash | pyreadline/console/console.py | Console.fixcoord | def fixcoord(self, x, y):
u'''Return a long with x and y packed inside,
also handle negative x and y.'''
if x < 0 or y < 0:
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if x < 0:
x = info.s... | python | def fixcoord(self, x, y):
u'''Return a long with x and y packed inside,
also handle negative x and y.'''
if x < 0 or y < 0:
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if x < 0:
x = info.s... | [
"def",
"fixcoord",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"if",
"x",
"<",
"0",
"or",
"y",
"<",
"0",
":",
"info",
"=",
"CONSOLE_SCREEN_BUFFER_INFO",
"(",
")",
"self",
".",
"GetConsoleScreenBufferInfo",
"(",
"self",
".",
"hout",
",",
"byref",
"(",
... | u'''Return a long with x and y packed inside,
also handle negative x and y. | [
"u",
"Return",
"a",
"long",
"with",
"x",
"and",
"y",
"packed",
"inside",
"also",
"handle",
"negative",
"x",
"and",
"y",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L239-L251 |
41,007 | SeattleTestbed/seash | pyreadline/console/console.py | Console.write_scrolling | def write_scrolling(self, text, attr=None):
u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I reme... | python | def write_scrolling(self, text, attr=None):
u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I reme... | [
"def",
"write_scrolling",
"(",
"self",
",",
"text",
",",
"attr",
"=",
"None",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"pos",
"(",
")",
"w",
",",
"h",
"=",
"self",
".",
"size",
"(",
")",
"scroll",
"=",
"0",
"# the result\r",
"# split the string i... | u'''write text at current cursor position while watching for scrolling.
If the window scrolls because you are at the bottom of the screen
buffer, all positions that you are storing will be shifted by the
scroll amount. For example, I remember the cursor position of the
prompt so th... | [
"u",
"write",
"text",
"at",
"current",
"cursor",
"position",
"while",
"watching",
"for",
"scrolling",
".",
"If",
"the",
"window",
"scrolls",
"because",
"you",
"are",
"at",
"the",
"bottom",
"of",
"the",
"screen",
"buffer",
"all",
"positions",
"that",
"you",
... | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L294-L348 |
41,008 | SeattleTestbed/seash | pyreadline/console/console.py | Console.page | def page(self, attr=None, fill=u' '):
u'''Fill the entire screen.'''
if attr is None:
attr = self.attr
if len(fill) != 1:
raise ValueError
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if info.d... | python | def page(self, attr=None, fill=u' '):
u'''Fill the entire screen.'''
if attr is None:
attr = self.attr
if len(fill) != 1:
raise ValueError
info = CONSOLE_SCREEN_BUFFER_INFO()
self.GetConsoleScreenBufferInfo(self.hout, byref(info))
if info.d... | [
"def",
"page",
"(",
"self",
",",
"attr",
"=",
"None",
",",
"fill",
"=",
"u' '",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"self",
".",
"attr",
"if",
"len",
"(",
"fill",
")",
"!=",
"1",
":",
"raise",
"ValueError",
"info",
"=",
"CON... | u'''Fill the entire screen. | [
"u",
"Fill",
"the",
"entire",
"screen",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L400-L419 |
41,009 | SeattleTestbed/seash | pyreadline/console/console.py | Console.scroll | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style... | python | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style... | [
"def",
"scroll",
"(",
"self",
",",
"rect",
",",
"dx",
",",
"dy",
",",
"attr",
"=",
"None",
",",
"fill",
"=",
"' '",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"self",
".",
"attr",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"re... | u'''Scroll a rectangle. | [
"u",
"Scroll",
"a",
"rectangle",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L453-L465 |
41,010 | SeattleTestbed/seash | pyreadline/console/console.py | Console.get | def get(self):
u'''Get next event from queue.'''
inputHookFunc = c_void_p.from_address(self.inputHookPtr).value
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
if inputHookFunc:
call_function(inputHookFunc, ())
status = self.Rea... | python | def get(self):
u'''Get next event from queue.'''
inputHookFunc = c_void_p.from_address(self.inputHookPtr).value
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
if inputHookFunc:
call_function(inputHookFunc, ())
status = self.Rea... | [
"def",
"get",
"(",
"self",
")",
":",
"inputHookFunc",
"=",
"c_void_p",
".",
"from_address",
"(",
"self",
".",
"inputHookPtr",
")",
".",
"value",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"while",
"1",
":",
"if",
"... | u'''Get next event from queue. | [
"u",
"Get",
"next",
"event",
"from",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L493-L506 |
41,011 | SeattleTestbed/seash | pyreadline/console/console.py | Console.getchar | def getchar(self):
u'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
status = self.ReadConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if (status and
... | python | def getchar(self):
u'''Get next character from queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
while 1:
status = self.ReadConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if (status and
... | [
"def",
"getchar",
"(",
"self",
")",
":",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"while",
"1",
":",
"status",
"=",
"self",
".",
"ReadConsoleInputW",
"(",
"self",
".",
"hin",
",",
"byref",
"(",
"Cevent",
")",
"... | u'''Get next character from queue. | [
"u",
"Get",
"next",
"character",
"from",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L526-L541 |
41,012 | SeattleTestbed/seash | pyreadline/console/console.py | Console.peek | def peek(self):
u'''Check event queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
status = self.PeekConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if status and count == 1:
return event(self, Cevent) | python | def peek(self):
u'''Check event queue.'''
Cevent = INPUT_RECORD()
count = DWORD(0)
status = self.PeekConsoleInputW(self.hin,
byref(Cevent), 1, byref(count))
if status and count == 1:
return event(self, Cevent) | [
"def",
"peek",
"(",
"self",
")",
":",
"Cevent",
"=",
"INPUT_RECORD",
"(",
")",
"count",
"=",
"DWORD",
"(",
"0",
")",
"status",
"=",
"self",
".",
"PeekConsoleInputW",
"(",
"self",
".",
"hin",
",",
"byref",
"(",
"Cevent",
")",
",",
"1",
",",
"byref",... | u'''Check event queue. | [
"u",
"Check",
"event",
"queue",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L543-L550 |
41,013 | SeattleTestbed/seash | pyreadline/console/console.py | Console.cursor | def cursor(self, visible=None, size=None):
u'''Set cursor on or off.'''
info = CONSOLE_CURSOR_INFO()
if self.GetConsoleCursorInfo(self.hout, byref(info)):
if visible is not None:
info.bVisible = visible
if size is not None:
info.dwSi... | python | def cursor(self, visible=None, size=None):
u'''Set cursor on or off.'''
info = CONSOLE_CURSOR_INFO()
if self.GetConsoleCursorInfo(self.hout, byref(info)):
if visible is not None:
info.bVisible = visible
if size is not None:
info.dwSi... | [
"def",
"cursor",
"(",
"self",
",",
"visible",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"info",
"=",
"CONSOLE_CURSOR_INFO",
"(",
")",
"if",
"self",
".",
"GetConsoleCursorInfo",
"(",
"self",
".",
"hout",
",",
"byref",
"(",
"info",
")",
")",
":"... | u'''Set cursor on or off. | [
"u",
"Set",
"cursor",
"on",
"or",
"off",
"."
] | 40f9d2285662ff8b61e0468b4196acee089b273b | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L580-L588 |
41,014 | MisanthropicBit/colorise | colorise/decorators.py | inherit_docstrings | def inherit_docstrings(cls):
"""Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class.
"""
@functools.wraps(cls)
def _inherit_docstrings(cls):
if not isinstance(cls, (type, colorise.compat.ClassType)):
r... | python | def inherit_docstrings(cls):
"""Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class.
"""
@functools.wraps(cls)
def _inherit_docstrings(cls):
if not isinstance(cls, (type, colorise.compat.ClassType)):
r... | [
"def",
"inherit_docstrings",
"(",
"cls",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"cls",
")",
"def",
"_inherit_docstrings",
"(",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
",",
"(",
"type",
",",
"colorise",
".",
"compat",
".",
"Class... | Class decorator for inheriting docstrings.
Automatically inherits base class doc-strings if not present in the
derived class. | [
"Class",
"decorator",
"for",
"inheriting",
"docstrings",
"."
] | e630df74b8b27680a43c370ddbe98766be50158c | https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/decorators.py#L12-L35 |
41,015 | lsst-sqre/lander | lander/ltdclient.py | upload | def upload(config):
"""Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials.
"""
token = get_keeper_token(config['keeper_url'],
... | python | def upload(config):
"""Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials.
"""
token = get_keeper_token(config['keeper_url'],
... | [
"def",
"upload",
"(",
"config",
")",
":",
"token",
"=",
"get_keeper_token",
"(",
"config",
"[",
"'keeper_url'",
"]",
",",
"config",
"[",
"'keeper_user'",
"]",
",",
"config",
"[",
"'keeper_password'",
"]",
")",
"build_resource",
"=",
"register_build",
"(",
"c... | Upload the build documentation site to LSST the Docs.
Parameters
----------
config : `lander.config.Configuration`
Site configuration, which includes upload information and credentials. | [
"Upload",
"the",
"build",
"documentation",
"site",
"to",
"LSST",
"the",
"Docs",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/ltdclient.py#L8-L32 |
41,016 | lsst-sqre/lander | lander/ltdclient.py | get_keeper_token | def get_keeper_token(base_url, username, password):
"""Get a temporary auth token from LTD Keeper."""
token_endpoint = base_url + '/token'
r = requests.get(token_endpoint, auth=(username, password))
if r.status_code != 200:
raise RuntimeError('Could not authenticate to {0}: error {1:d}\n{2}'.
... | python | def get_keeper_token(base_url, username, password):
"""Get a temporary auth token from LTD Keeper."""
token_endpoint = base_url + '/token'
r = requests.get(token_endpoint, auth=(username, password))
if r.status_code != 200:
raise RuntimeError('Could not authenticate to {0}: error {1:d}\n{2}'.
... | [
"def",
"get_keeper_token",
"(",
"base_url",
",",
"username",
",",
"password",
")",
":",
"token_endpoint",
"=",
"base_url",
"+",
"'/token'",
"r",
"=",
"requests",
".",
"get",
"(",
"token_endpoint",
",",
"auth",
"=",
"(",
"username",
",",
"password",
")",
")... | Get a temporary auth token from LTD Keeper. | [
"Get",
"a",
"temporary",
"auth",
"token",
"from",
"LTD",
"Keeper",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/ltdclient.py#L35-L42 |
41,017 | ponty/confduino | confduino/examples/atmega88.py | install | def install(
board_id='atmega88',
mcu='atmega88',
f_cpu=20000000,
upload='usbasp',
core='arduino',
replace_existing=True,
):
"""install atmega88 board."""
board = AutoBunch()
board.name = TEMPL.format(mcu=mcu, f_cpu=f_cpu, upload=upload)
board.upload.using = upload
board.up... | python | def install(
board_id='atmega88',
mcu='atmega88',
f_cpu=20000000,
upload='usbasp',
core='arduino',
replace_existing=True,
):
"""install atmega88 board."""
board = AutoBunch()
board.name = TEMPL.format(mcu=mcu, f_cpu=f_cpu, upload=upload)
board.upload.using = upload
board.up... | [
"def",
"install",
"(",
"board_id",
"=",
"'atmega88'",
",",
"mcu",
"=",
"'atmega88'",
",",
"f_cpu",
"=",
"20000000",
",",
"upload",
"=",
"'usbasp'",
",",
"core",
"=",
"'arduino'",
",",
"replace_existing",
"=",
"True",
",",
")",
":",
"board",
"=",
"AutoBun... | install atmega88 board. | [
"install",
"atmega88",
"board",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/atmega88.py#L9-L32 |
41,018 | RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData._compute_bgid | def _compute_bgid(self, bg=None):
"""Return a unique identifier for the background data"""
if bg is None:
bg = self._bgdata
if isinstance(bg, qpimage.QPImage):
# Single QPImage
if "identifier" in bg:
return bg["identifier"]
else:
... | python | def _compute_bgid(self, bg=None):
"""Return a unique identifier for the background data"""
if bg is None:
bg = self._bgdata
if isinstance(bg, qpimage.QPImage):
# Single QPImage
if "identifier" in bg:
return bg["identifier"]
else:
... | [
"def",
"_compute_bgid",
"(",
"self",
",",
"bg",
"=",
"None",
")",
":",
"if",
"bg",
"is",
"None",
":",
"bg",
"=",
"self",
".",
"_bgdata",
"if",
"isinstance",
"(",
"bg",
",",
"qpimage",
".",
"QPImage",
")",
":",
"# Single QPImage",
"if",
"\"identifier\""... | Return a unique identifier for the background data | [
"Return",
"a",
"unique",
"identifier",
"for",
"the",
"background",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L85-L112 |
41,019 | RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.identifier | def identifier(self):
"""Return a unique identifier for the given data set"""
if self.background_identifier is None:
idsum = self._identifier_data()
else:
idsum = hash_obj([self._identifier_data(),
self.background_identifier])
return ... | python | def identifier(self):
"""Return a unique identifier for the given data set"""
if self.background_identifier is None:
idsum = self._identifier_data()
else:
idsum = hash_obj([self._identifier_data(),
self.background_identifier])
return ... | [
"def",
"identifier",
"(",
"self",
")",
":",
"if",
"self",
".",
"background_identifier",
"is",
"None",
":",
"idsum",
"=",
"self",
".",
"_identifier_data",
"(",
")",
"else",
":",
"idsum",
"=",
"hash_obj",
"(",
"[",
"self",
".",
"_identifier_data",
"(",
")"... | Return a unique identifier for the given data set | [
"Return",
"a",
"unique",
"identifier",
"for",
"the",
"given",
"data",
"set"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L141-L148 |
41,020 | RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.get_time | def get_time(self, idx):
"""Return time of data at index `idx`
Returns nan if the time is not defined"""
# raw data
qpi = self.get_qpimage_raw(idx)
if "time" in qpi.meta:
thetime = qpi.meta["time"]
else:
thetime = np.nan
return thetime | python | def get_time(self, idx):
"""Return time of data at index `idx`
Returns nan if the time is not defined"""
# raw data
qpi = self.get_qpimage_raw(idx)
if "time" in qpi.meta:
thetime = qpi.meta["time"]
else:
thetime = np.nan
return thetime | [
"def",
"get_time",
"(",
"self",
",",
"idx",
")",
":",
"# raw data",
"qpi",
"=",
"self",
".",
"get_qpimage_raw",
"(",
"idx",
")",
"if",
"\"time\"",
"in",
"qpi",
".",
"meta",
":",
"thetime",
"=",
"qpi",
".",
"meta",
"[",
"\"time\"",
"]",
"else",
":",
... | Return time of data at index `idx`
Returns nan if the time is not defined | [
"Return",
"time",
"of",
"data",
"at",
"index",
"idx"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L166-L176 |
41,021 | RI-imaging/qpformat | qpformat/file_formats/dataset.py | SeriesData.set_bg | def set_bg(self, dataset):
"""Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
... | python | def set_bg(self, dataset):
"""Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
... | [
"def",
"set_bg",
"(",
"self",
",",
"dataset",
")",
":",
"if",
"isinstance",
"(",
"dataset",
",",
"qpimage",
".",
"QPImage",
")",
":",
"# Single QPImage",
"self",
".",
"_bgdata",
"=",
"[",
"dataset",
"]",
"elif",
"(",
"isinstance",
"(",
"dataset",
",",
... | Set background data
Parameters
----------
dataset: `DataSet`, `qpimage.QPImage`, or int
If the ``len(dataset)`` matches ``len(self)``,
then background correction is performed
element-wise. Otherwise, ``len(dataset)``
must be one and is used for al... | [
"Set",
"background",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L293-L324 |
41,022 | RI-imaging/qpformat | qpformat/file_formats/dataset.py | SingleData.get_time | def get_time(self, idx=0):
"""Time of the data
Returns nan if the time is not defined
"""
thetime = super(SingleData, self).get_time(idx=0)
return thetime | python | def get_time(self, idx=0):
"""Time of the data
Returns nan if the time is not defined
"""
thetime = super(SingleData, self).get_time(idx=0)
return thetime | [
"def",
"get_time",
"(",
"self",
",",
"idx",
"=",
"0",
")",
":",
"thetime",
"=",
"super",
"(",
"SingleData",
",",
"self",
")",
".",
"get_time",
"(",
"idx",
"=",
"0",
")",
"return",
"thetime"
] | Time of the data
Returns nan if the time is not defined | [
"Time",
"of",
"the",
"data"
] | 364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb | https://github.com/RI-imaging/qpformat/blob/364e29d7d9e8b9f1d7a4a25c753d1baf9d73d5eb/qpformat/file_formats/dataset.py#L374-L380 |
41,023 | justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.do | def do(self, fn, message=None, *args, **kwargs):
"""Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail)
"""
self.items.put(ChainItem(fn, self.do, me... | python | def do(self, fn, message=None, *args, **kwargs):
"""Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail)
"""
self.items.put(ChainItem(fn, self.do, me... | [
"def",
"do",
"(",
"self",
",",
"fn",
",",
"message",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"items",
".",
"put",
"(",
"ChainItem",
"(",
"fn",
",",
"self",
".",
"do",
",",
"message",
",",
"*",
"args",
",... | Add a 'do' action to the steps. This is a function to execute
:param fn: A function
:param message: Message indicating what this function does (used for debugging if assertions fail) | [
"Add",
"a",
"do",
"action",
"to",
"the",
"steps",
".",
"This",
"is",
"a",
"function",
"to",
"execute"
] | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L47-L54 |
41,024 | justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.expect | def expect(self, value, message='Failed: "{actual} {operator} {expected}" after step "{step}"', operator='=='):
"""Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that ... | python | def expect(self, value, message='Failed: "{actual} {operator} {expected}" after step "{step}"', operator='=='):
"""Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that ... | [
"def",
"expect",
"(",
"self",
",",
"value",
",",
"message",
"=",
"'Failed: \"{actual} {operator} {expected}\" after step \"{step}\"'",
",",
"operator",
"=",
"'=='",
")",
":",
"if",
"operator",
"not",
"in",
"self",
".",
"valid_operators",
":",
"raise",
"ValueError",
... | Add an 'assertion' action to the steps. This will evaluate the return value of the last 'do' step and
compare it to the value passed here using the specified operator.
Checks that the first function will return 2
>>> AssertionChain().do(lambda: 1 + 1, 'add 1 + 1').expect(2)
This will c... | [
"Add",
"an",
"assertion",
"action",
"to",
"the",
"steps",
".",
"This",
"will",
"evaluate",
"the",
"return",
"value",
"of",
"the",
"last",
"do",
"step",
"and",
"compare",
"it",
"to",
"the",
"value",
"passed",
"here",
"using",
"the",
"specified",
"operator",... | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L56-L78 |
41,025 | justiniso/AssertionChain | assertionchain/assertionchain.py | AssertionChain.perform | def perform(self):
"""Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed
"""
last_value = None
last_step = None
while self.items.qsize():
item = self.items.get()
if ... | python | def perform(self):
"""Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed
"""
last_value = None
last_step = None
while self.items.qsize():
item = self.items.get()
if ... | [
"def",
"perform",
"(",
"self",
")",
":",
"last_value",
"=",
"None",
"last_step",
"=",
"None",
"while",
"self",
".",
"items",
".",
"qsize",
"(",
")",
":",
"item",
"=",
"self",
".",
"items",
".",
"get",
"(",
")",
"if",
"item",
".",
"flag",
"==",
"s... | Runs through all of the steps in the chain and runs each of them in sequence.
:return: The value from the lat "do" step performed | [
"Runs",
"through",
"all",
"of",
"the",
"steps",
"in",
"the",
"chain",
"and",
"runs",
"each",
"of",
"them",
"in",
"sequence",
"."
] | 8578447904beeae4e18b9390055ac364deef10ca | https://github.com/justiniso/AssertionChain/blob/8578447904beeae4e18b9390055ac364deef10ca/assertionchain/assertionchain.py#L80-L114 |
41,026 | rossdylan/sham | sham/storage/pools.py | StoragePool.get_volumes | def get_volumes(self):
"""
Return a list of all Volumes in this Storage Pool
"""
vols = [self.find_volume(name) for name in self.virsp.listVolumes()]
return vols | python | def get_volumes(self):
"""
Return a list of all Volumes in this Storage Pool
"""
vols = [self.find_volume(name) for name in self.virsp.listVolumes()]
return vols | [
"def",
"get_volumes",
"(",
"self",
")",
":",
"vols",
"=",
"[",
"self",
".",
"find_volume",
"(",
"name",
")",
"for",
"name",
"in",
"self",
".",
"virsp",
".",
"listVolumes",
"(",
")",
"]",
"return",
"vols"
] | Return a list of all Volumes in this Storage Pool | [
"Return",
"a",
"list",
"of",
"all",
"Volumes",
"in",
"this",
"Storage",
"Pool"
] | d938ae3da43814c3c45ae95b6116bd87282c8691 | https://github.com/rossdylan/sham/blob/d938ae3da43814c3c45ae95b6116bd87282c8691/sham/storage/pools.py#L14-L19 |
41,027 | ponty/confduino | confduino/examples/dapa.py | install | def install(replace_existing=False):
"""install dapa programmer."""
bunch = AutoBunch()
bunch.name = 'DAPA'
bunch.protocol = 'dapa'
bunch.force = 'true'
# bunch.delay=200
install_programmer('dapa', bunch, replace_existing=replace_existing) | python | def install(replace_existing=False):
"""install dapa programmer."""
bunch = AutoBunch()
bunch.name = 'DAPA'
bunch.protocol = 'dapa'
bunch.force = 'true'
# bunch.delay=200
install_programmer('dapa', bunch, replace_existing=replace_existing) | [
"def",
"install",
"(",
"replace_existing",
"=",
"False",
")",
":",
"bunch",
"=",
"AutoBunch",
"(",
")",
"bunch",
".",
"name",
"=",
"'DAPA'",
"bunch",
".",
"protocol",
"=",
"'dapa'",
"bunch",
".",
"force",
"=",
"'true'",
"# bunch.delay=200",
"install_programm... | install dapa programmer. | [
"install",
"dapa",
"programmer",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/dapa.py#L7-L15 |
41,028 | helixyte/everest | everest/representers/dataelements.py | SimpleMemberDataElement.get_terminal_converted | def get_terminal_converted(self, attr):
"""
Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string.
... | python | def get_terminal_converted(self, attr):
"""
Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string.
... | [
"def",
"get_terminal_converted",
"(",
"self",
",",
"attr",
")",
":",
"value",
"=",
"self",
".",
"data",
".",
"get",
"(",
"attr",
".",
"repr_name",
")",
"return",
"self",
".",
"converter_registry",
".",
"convert_to_representation",
"(",
"value",
",",
"attr",
... | Returns the value of the specified attribute converted to a
representation value.
:param attr: Attribute to retrieve.
:type attr: :class:`everest.representers.attributes.MappedAttribute`
:returns: Representation string. | [
"Returns",
"the",
"value",
"of",
"the",
"specified",
"attribute",
"converted",
"to",
"a",
"representation",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/dataelements.py#L256-L268 |
41,029 | helixyte/everest | everest/representers/dataelements.py | SimpleMemberDataElement.set_terminal_converted | def set_terminal_converted(self, attr, repr_value):
"""
Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set.
"""
value = ... | python | def set_terminal_converted(self, attr, repr_value):
"""
Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set.
"""
value = ... | [
"def",
"set_terminal_converted",
"(",
"self",
",",
"attr",
",",
"repr_value",
")",
":",
"value",
"=",
"self",
".",
"converter_registry",
".",
"convert_from_representation",
"(",
"repr_value",
",",
"attr",
".",
"value_type",
")",
"self",
".",
"data",
"[",
"attr... | Converts the given representation value and sets the specified
attribute value to the converted value.
:param attr: Attribute to set.
:param str repr_value: String value of the attribute to set. | [
"Converts",
"the",
"given",
"representation",
"value",
"and",
"sets",
"the",
"specified",
"attribute",
"value",
"to",
"the",
"converted",
"value",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/dataelements.py#L270-L281 |
41,030 | dariusbakunas/rawdisk | rawdisk/plugins/filesystems/efi_system/efi_system_volume.py | EfiSystemVolume.load | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume. \
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError:
self.logger.error('Unable to ... | python | def load(self, filename, offset):
"""Will eventually load information for Apple_Boot volume. \
Not yet implemented"""
try:
self.offset = offset
# self.fd = open(filename, 'rb')
# self.fd.close()
except IOError:
self.logger.error('Unable to ... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"offset",
")",
":",
"try",
":",
"self",
".",
"offset",
"=",
"offset",
"# self.fd = open(filename, 'rb')",
"# self.fd.close()",
"except",
"IOError",
":",
"self",
".",
"logger",
".",
"error",
"(",
"'Unable to loa... | Will eventually load information for Apple_Boot volume. \
Not yet implemented | [
"Will",
"eventually",
"load",
"information",
"for",
"Apple_Boot",
"volume",
".",
"\\",
"Not",
"yet",
"implemented"
] | 1dc9d0b377fe5da3c406ccec4abc238c54167403 | https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/efi_system/efi_system_volume.py#L15-L23 |
41,031 | erikvw/django-collect-offline-files | django_collect_offline_files/transaction/transaction_file_sender.py | TransactionFileSender.send | def send(self, filenames=None):
"""Sends the file to the remote host and archives
the sent file locally.
"""
try:
with self.ssh_client.connect() as ssh_conn:
with self.sftp_client.connect(ssh_conn) as sftp_conn:
for filename in filenames:
... | python | def send(self, filenames=None):
"""Sends the file to the remote host and archives
the sent file locally.
"""
try:
with self.ssh_client.connect() as ssh_conn:
with self.sftp_client.connect(ssh_conn) as sftp_conn:
for filename in filenames:
... | [
"def",
"send",
"(",
"self",
",",
"filenames",
"=",
"None",
")",
":",
"try",
":",
"with",
"self",
".",
"ssh_client",
".",
"connect",
"(",
")",
"as",
"ssh_conn",
":",
"with",
"self",
".",
"sftp_client",
".",
"connect",
"(",
"ssh_conn",
")",
"as",
"sftp... | Sends the file to the remote host and archives
the sent file locally. | [
"Sends",
"the",
"file",
"to",
"the",
"remote",
"host",
"and",
"archives",
"the",
"sent",
"file",
"locally",
"."
] | 78f61c823ea3926eb88206b019b5dca3c36017da | https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_file_sender.py#L39-L55 |
41,032 | AtomHash/evernode | evernode/classes/render.py | Render.compile | def compile(self, name, folder=None, data=None):
"""
renders template_name + self.extension file with data using jinja
"""
template_name = name.replace(os.sep, "")
if folder is None:
folder = ""
full_name = os.path.join(
folder.strip(os.sep... | python | def compile(self, name, folder=None, data=None):
"""
renders template_name + self.extension file with data using jinja
"""
template_name = name.replace(os.sep, "")
if folder is None:
folder = ""
full_name = os.path.join(
folder.strip(os.sep... | [
"def",
"compile",
"(",
"self",
",",
"name",
",",
"folder",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"template_name",
"=",
"name",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"\"\"",
")",
"if",
"folder",
"is",
"None",
":",
"folder",
"=",
"... | renders template_name + self.extension file with data using jinja | [
"renders",
"template_name",
"+",
"self",
".",
"extension",
"file",
"with",
"data",
"using",
"jinja"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/render.py#L46-L62 |
41,033 | AtomHash/evernode | evernode/classes/jwt.py | JWT.create_token | def create_token(self, data, token_valid_for=180) -> str:
""" Create encrypted JWT """
jwt_token = jwt.encode({
'data': data,
'exp': datetime.utcnow() + timedelta(seconds=token_valid_for)},
self.app_secret)
return Security.encrypt(jwt_token) | python | def create_token(self, data, token_valid_for=180) -> str:
""" Create encrypted JWT """
jwt_token = jwt.encode({
'data': data,
'exp': datetime.utcnow() + timedelta(seconds=token_valid_for)},
self.app_secret)
return Security.encrypt(jwt_token) | [
"def",
"create_token",
"(",
"self",
",",
"data",
",",
"token_valid_for",
"=",
"180",
")",
"->",
"str",
":",
"jwt_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"'data'",
":",
"data",
",",
"'exp'",
":",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"timedel... | Create encrypted JWT | [
"Create",
"encrypted",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L38-L44 |
41,034 | AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_token | def verify_token(self, token) -> bool:
""" Verify encrypted JWT """
try:
self.data = jwt.decode(Security.decrypt(token), self.app_secret)
return True
except (Exception, BaseException) as error:
self.errors.append(error)
return False
... | python | def verify_token(self, token) -> bool:
""" Verify encrypted JWT """
try:
self.data = jwt.decode(Security.decrypt(token), self.app_secret)
return True
except (Exception, BaseException) as error:
self.errors.append(error)
return False
... | [
"def",
"verify_token",
"(",
"self",
",",
"token",
")",
"->",
"bool",
":",
"try",
":",
"self",
".",
"data",
"=",
"jwt",
".",
"decode",
"(",
"Security",
".",
"decrypt",
"(",
"token",
")",
",",
"self",
".",
"app_secret",
")",
"return",
"True",
"except",... | Verify encrypted JWT | [
"Verify",
"encrypted",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L46-L54 |
41,035 | AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_http_auth_token | def verify_http_auth_token(self) -> bool:
""" Use request information to validate JWT """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_token(authorization_token):
if self.data is not None:
sel... | python | def verify_http_auth_token(self) -> bool:
""" Use request information to validate JWT """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_token(authorization_token):
if self.data is not None:
sel... | [
"def",
"verify_http_auth_token",
"(",
"self",
")",
"->",
"bool",
":",
"authorization_token",
"=",
"self",
".",
"get_http_token",
"(",
")",
"if",
"authorization_token",
"is",
"not",
"None",
":",
"if",
"self",
".",
"verify_token",
"(",
"authorization_token",
")",
... | Use request information to validate JWT | [
"Use",
"request",
"information",
"to",
"validate",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L56-L67 |
41,036 | AtomHash/evernode | evernode/classes/jwt.py | JWT.create_token_with_refresh_token | def create_token_with_refresh_token(self, data, token_valid_for=180,
refresh_token_valid_for=86400):
""" Create an encrypted JWT with a refresh_token """
refresh_token = None
refresh_token = jwt.encode({
'exp':
datetime.ut... | python | def create_token_with_refresh_token(self, data, token_valid_for=180,
refresh_token_valid_for=86400):
""" Create an encrypted JWT with a refresh_token """
refresh_token = None
refresh_token = jwt.encode({
'exp':
datetime.ut... | [
"def",
"create_token_with_refresh_token",
"(",
"self",
",",
"data",
",",
"token_valid_for",
"=",
"180",
",",
"refresh_token_valid_for",
"=",
"86400",
")",
":",
"refresh_token",
"=",
"None",
"refresh_token",
"=",
"jwt",
".",
"encode",
"(",
"{",
"'exp'",
":",
"d... | Create an encrypted JWT with a refresh_token | [
"Create",
"an",
"encrypted",
"JWT",
"with",
"a",
"refresh_token"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L69-L83 |
41,037 | AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_refresh_token | def verify_refresh_token(self, expired_token) -> bool:
""" Use request information to validate refresh JWT """
try:
decoded_token = jwt.decode(
Security.decrypt(expired_token),
self.app_secret,
options={'verify_exp': False})
... | python | def verify_refresh_token(self, expired_token) -> bool:
""" Use request information to validate refresh JWT """
try:
decoded_token = jwt.decode(
Security.decrypt(expired_token),
self.app_secret,
options={'verify_exp': False})
... | [
"def",
"verify_refresh_token",
"(",
"self",
",",
"expired_token",
")",
"->",
"bool",
":",
"try",
":",
"decoded_token",
"=",
"jwt",
".",
"decode",
"(",
"Security",
".",
"decrypt",
"(",
"expired_token",
")",
",",
"self",
".",
"app_secret",
",",
"options",
"=... | Use request information to validate refresh JWT | [
"Use",
"request",
"information",
"to",
"validate",
"refresh",
"JWT"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L85-L104 |
41,038 | AtomHash/evernode | evernode/classes/jwt.py | JWT.verify_http_auth_refresh_token | def verify_http_auth_refresh_token(self) -> bool:
""" Use expired token to check refresh token information """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_refresh_token(authorization_token):
if self.data is not N... | python | def verify_http_auth_refresh_token(self) -> bool:
""" Use expired token to check refresh token information """
authorization_token = self.get_http_token()
if authorization_token is not None:
if self.verify_refresh_token(authorization_token):
if self.data is not N... | [
"def",
"verify_http_auth_refresh_token",
"(",
"self",
")",
"->",
"bool",
":",
"authorization_token",
"=",
"self",
".",
"get_http_token",
"(",
")",
"if",
"authorization_token",
"is",
"not",
"None",
":",
"if",
"self",
".",
"verify_refresh_token",
"(",
"authorization... | Use expired token to check refresh token information | [
"Use",
"expired",
"token",
"to",
"check",
"refresh",
"token",
"information"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/jwt.py#L106-L117 |
41,039 | AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.status | def status(self, status_code=None):
""" Set status or Get Status """
if status_code is not None:
self.response_model.status = status_code
# return string for response support
return str(self.response_model.status) | python | def status(self, status_code=None):
""" Set status or Get Status """
if status_code is not None:
self.response_model.status = status_code
# return string for response support
return str(self.response_model.status) | [
"def",
"status",
"(",
"self",
",",
"status_code",
"=",
"None",
")",
":",
"if",
"status_code",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"status",
"=",
"status_code",
"# return string for response support\r",
"return",
"str",
"(",
"self",
".... | Set status or Get Status | [
"Set",
"status",
"or",
"Get",
"Status"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L28-L33 |
41,040 | AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.message | def message(self, message=None):
""" Set response message """
if message is not None:
self.response_model.message = message
return self.response_model.message | python | def message(self, message=None):
""" Set response message """
if message is not None:
self.response_model.message = message
return self.response_model.message | [
"def",
"message",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"if",
"message",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"message",
"=",
"message",
"return",
"self",
".",
"response_model",
".",
"message"
] | Set response message | [
"Set",
"response",
"message"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L35-L39 |
41,041 | AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.data | def data(self, data=None):
""" Set response data """
if data is not None:
self.response_model.data = data
return self.response_model.data | python | def data(self, data=None):
""" Set response data """
if data is not None:
self.response_model.data = data
return self.response_model.data | [
"def",
"data",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"response_model",
".",
"data",
"=",
"data",
"return",
"self",
".",
"response_model",
".",
"data"
] | Set response data | [
"Set",
"response",
"data"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L41-L45 |
41,042 | AtomHash/evernode | evernode/classes/base_response.py | BaseResponse.quick_response | def quick_response(self, status_code):
""" Quickly construct response using a status code """
translator = Translator(environ=self.environ)
if status_code == 404:
self.status(404)
self.message(translator.trans('http_messages.404'))
elif status_code == 401:
... | python | def quick_response(self, status_code):
""" Quickly construct response using a status code """
translator = Translator(environ=self.environ)
if status_code == 404:
self.status(404)
self.message(translator.trans('http_messages.404'))
elif status_code == 401:
... | [
"def",
"quick_response",
"(",
"self",
",",
"status_code",
")",
":",
"translator",
"=",
"Translator",
"(",
"environ",
"=",
"self",
".",
"environ",
")",
"if",
"status_code",
"==",
"404",
":",
"self",
".",
"status",
"(",
"404",
")",
"self",
".",
"message",
... | Quickly construct response using a status code | [
"Quickly",
"construct",
"response",
"using",
"a",
"status",
"code"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/base_response.py#L55-L69 |
41,043 | Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | memoize | def memoize(func):
"""Cache forever."""
cache = {}
def memoizer():
if 0 not in cache:
cache[0] = func()
return cache[0]
return functools.wraps(func)(memoizer) | python | def memoize(func):
"""Cache forever."""
cache = {}
def memoizer():
if 0 not in cache:
cache[0] = func()
return cache[0]
return functools.wraps(func)(memoizer) | [
"def",
"memoize",
"(",
"func",
")",
":",
"cache",
"=",
"{",
"}",
"def",
"memoizer",
"(",
")",
":",
"if",
"0",
"not",
"in",
"cache",
":",
"cache",
"[",
"0",
"]",
"=",
"func",
"(",
")",
"return",
"cache",
"[",
"0",
"]",
"return",
"functools",
"."... | Cache forever. | [
"Cache",
"forever",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L9-L16 |
41,044 | Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | getinputencoding | def getinputencoding(stream=None):
"""Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin.
"""
if stream is None:
stream = sys.stdin
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | python | def getinputencoding(stream=None):
"""Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin.
"""
if stream is None:
stream = sys.stdin
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | [
"def",
"getinputencoding",
"(",
"stream",
"=",
"None",
")",
":",
"if",
"stream",
"is",
"None",
":",
"stream",
"=",
"sys",
".",
"stdin",
"encoding",
"=",
"stream",
".",
"encoding",
"if",
"not",
"encoding",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
... | Return preferred encoding for reading from ``stream``.
``stream`` defaults to sys.stdin. | [
"Return",
"preferred",
"encoding",
"for",
"reading",
"from",
"stream",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L34-L44 |
41,045 | Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | getoutputencoding | def getoutputencoding(stream=None):
"""Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout.
"""
if stream is None:
stream = sys.stdout
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | python | def getoutputencoding(stream=None):
"""Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout.
"""
if stream is None:
stream = sys.stdout
encoding = stream.encoding
if not encoding:
encoding = getpreferredencoding()
return encoding | [
"def",
"getoutputencoding",
"(",
"stream",
"=",
"None",
")",
":",
"if",
"stream",
"is",
"None",
":",
"stream",
"=",
"sys",
".",
"stdout",
"encoding",
"=",
"stream",
".",
"encoding",
"if",
"not",
"encoding",
":",
"encoding",
"=",
"getpreferredencoding",
"("... | Return preferred encoding for writing to ``stream``.
``stream`` defaults to sys.stdout. | [
"Return",
"preferred",
"encoding",
"for",
"writing",
"to",
"stream",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L47-L57 |
41,046 | Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | decode | def decode(string, encoding=None, errors=None):
"""Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getprefe... | python | def decode(string, encoding=None, errors=None):
"""Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getprefe... | [
"def",
"decode",
"(",
"string",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
")",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"getpreferrederr... | Decode from specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler. | [
"Decode",
"from",
"specified",
"encoding",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L60-L70 |
41,047 | Jarn/jarn.mkrelease | jarn/mkrelease/utils.py | encode | def encode(string, encoding=None, errors=None):
"""Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getpreferr... | python | def encode(string, encoding=None, errors=None):
"""Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler.
"""
if encoding is None:
encoding = getpreferredencoding()
if errors is None:
errors = getpreferr... | [
"def",
"encode",
"(",
"string",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"encoding",
"=",
"getpreferredencoding",
"(",
")",
"if",
"errors",
"is",
"None",
":",
"errors",
"=",
"getpreferrederr... | Encode to specified encoding.
``encoding`` defaults to the preferred encoding.
``errors`` defaults to the preferred error handler. | [
"Encode",
"to",
"specified",
"encoding",
"."
] | 844377f37a3cdc0a154148790a926f991019ec4a | https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L73-L83 |
41,048 | helixyte/everest | everest/views/base.py | RepresentingResourceView._get_response_mime_type | def _get_response_mime_type(self):
"""
Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view.
"""
view_name = self.request.view_n... | python | def _get_response_mime_type(self):
"""
Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view.
"""
view_name = self.request.view_n... | [
"def",
"_get_response_mime_type",
"(",
"self",
")",
":",
"view_name",
"=",
"self",
".",
"request",
".",
"view_name",
"if",
"view_name",
"!=",
"''",
":",
"mime_type",
"=",
"get_registered_mime_type_for_name",
"(",
"view_name",
")",
"else",
":",
"mime_type",
"=",
... | Returns the reponse MIME type for this view.
:raises: :class:`pyramid.httpexceptions.HTTPNotAcceptable` if the
MIME content type(s) the client specified can not be handled by
the view. | [
"Returns",
"the",
"reponse",
"MIME",
"type",
"for",
"this",
"view",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L175-L217 |
41,049 | helixyte/everest | everest/views/base.py | RepresentingResourceView._get_result | def _get_result(self, resource):
"""
Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
... | python | def _get_result(self, resource):
"""
Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
... | [
"def",
"_get_result",
"(",
"self",
",",
"resource",
")",
":",
"if",
"self",
".",
"_convert_response",
":",
"self",
".",
"_update_response_body",
"(",
"resource",
")",
"result",
"=",
"self",
".",
"request",
".",
"response",
"else",
":",
"result",
"=",
"dict... | Converts the given resource to a result to be returned from the view.
Unless a custom renderer is employed, this will involve creating
a representer and using it to convert the resource to a string.
:param resource: Resource to convert.
:type resource: Object implementing
:cla... | [
"Converts",
"the",
"given",
"resource",
"to",
"a",
"result",
"to",
"be",
"returned",
"from",
"the",
"view",
".",
"Unless",
"a",
"custom",
"renderer",
"is",
"employed",
"this",
"will",
"involve",
"creating",
"a",
"representer",
"and",
"using",
"it",
"to",
"... | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L244-L262 |
41,050 | helixyte/everest | everest/views/base.py | RepresentingResourceView._update_response_body | def _update_response_body(self, resource):
"""
Creates a representer and updates the response body with the byte
representation created for the given resource.
"""
rpr = self._get_response_representer(resource)
# Set content type and body of the response.
self.req... | python | def _update_response_body(self, resource):
"""
Creates a representer and updates the response body with the byte
representation created for the given resource.
"""
rpr = self._get_response_representer(resource)
# Set content type and body of the response.
self.req... | [
"def",
"_update_response_body",
"(",
"self",
",",
"resource",
")",
":",
"rpr",
"=",
"self",
".",
"_get_response_representer",
"(",
"resource",
")",
"# Set content type and body of the response.",
"self",
".",
"request",
".",
"response",
".",
"content_type",
"=",
"rp... | Creates a representer and updates the response body with the byte
representation created for the given resource. | [
"Creates",
"a",
"representer",
"and",
"updates",
"the",
"response",
"body",
"with",
"the",
"byte",
"representation",
"created",
"for",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L264-L274 |
41,051 | helixyte/everest | everest/views/base.py | RepresentingResourceView._update_response_location_header | def _update_response_location_header(self, resource):
"""
Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource.
"""
location = resource_to_url(resource, request=self.request)
loc_hdr = ('Location', location)
... | python | def _update_response_location_header(self, resource):
"""
Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource.
"""
location = resource_to_url(resource, request=self.request)
loc_hdr = ('Location', location)
... | [
"def",
"_update_response_location_header",
"(",
"self",
",",
"resource",
")",
":",
"location",
"=",
"resource_to_url",
"(",
"resource",
",",
"request",
"=",
"self",
".",
"request",
")",
"loc_hdr",
"=",
"(",
"'Location'",
",",
"location",
")",
"hdr_names",
"=",... | Adds a new or replaces an existing Location header to the response
headers pointing to the URL of the given resource. | [
"Adds",
"a",
"new",
"or",
"replaces",
"an",
"existing",
"Location",
"header",
"to",
"the",
"response",
"headers",
"pointing",
"to",
"the",
"URL",
"of",
"the",
"given",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L276-L292 |
41,052 | helixyte/everest | everest/views/base.py | ModifyingResourceView._get_request_representer | def _get_request_representer(self):
"""
Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported.
"""
try:
mime_type = \
get_registered_mime_type_for_... | python | def _get_request_representer(self):
"""
Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported.
"""
try:
mime_type = \
get_registered_mime_type_for_... | [
"def",
"_get_request_representer",
"(",
"self",
")",
":",
"try",
":",
"mime_type",
"=",
"get_registered_mime_type_for_string",
"(",
"self",
".",
"request",
".",
"content_type",
")",
"except",
"KeyError",
":",
"# The client sent a content type we do not support (415).",
"r... | Returns a representer for the content type specified in the request.
:raises HTTPUnsupportedMediaType: If the specified content type is
not supported. | [
"Returns",
"a",
"representer",
"for",
"the",
"content",
"type",
"specified",
"in",
"the",
"request",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L421-L434 |
41,053 | helixyte/everest | everest/views/base.py | ModifyingResourceView._extract_request_data | def _extract_request_data(self):
"""
Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object imple... | python | def _extract_request_data(self):
"""
Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object imple... | [
"def",
"_extract_request_data",
"(",
"self",
")",
":",
"rpr",
"=",
"self",
".",
"_get_request_representer",
"(",
")",
"return",
"rpr",
".",
"data_from_bytes",
"(",
"self",
".",
"request",
".",
"body",
")"
] | Extracts the data from the representation submitted in the request
body and returns it.
This default implementation uses a representer for the content type
specified by the request to perform the extraction and returns an
object implementing the
:class:`everest.representers.inte... | [
"Extracts",
"the",
"data",
"from",
"the",
"representation",
"submitted",
"in",
"the",
"request",
"body",
"and",
"returns",
"it",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L436-L451 |
41,054 | helixyte/everest | everest/views/base.py | ModifyingResourceView._handle_conflict | def _handle_conflict(self, name):
"""
Handles requests that triggered a conflict.
Respond with a 409 "Conflict"
"""
err = HTTPConflict('Member "%s" already exists!' % name).exception
return self.request.get_response(err) | python | def _handle_conflict(self, name):
"""
Handles requests that triggered a conflict.
Respond with a 409 "Conflict"
"""
err = HTTPConflict('Member "%s" already exists!' % name).exception
return self.request.get_response(err) | [
"def",
"_handle_conflict",
"(",
"self",
",",
"name",
")",
":",
"err",
"=",
"HTTPConflict",
"(",
"'Member \"%s\" already exists!'",
"%",
"name",
")",
".",
"exception",
"return",
"self",
".",
"request",
".",
"get_response",
"(",
"err",
")"
] | Handles requests that triggered a conflict.
Respond with a 409 "Conflict" | [
"Handles",
"requests",
"that",
"triggered",
"a",
"conflict",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L479-L486 |
41,055 | helixyte/everest | everest/views/base.py | WarnAndResubmitUserMessageChecker.check | def check(self):
"""
Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed.
"""
... | python | def check(self):
"""
Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed.
"""
... | [
"def",
"check",
"(",
"self",
")",
":",
"request",
"=",
"get_current_request",
"(",
")",
"ignore_guid",
"=",
"request",
".",
"params",
".",
"get",
"(",
"'ignore-message'",
")",
"coll",
"=",
"request",
".",
"root",
"[",
"'_messages'",
"]",
"vote",
"=",
"Fa... | Implements user message checking for views.
Checks if the current request has an explicit "ignore-message"
parameter (a GUID) pointing to a message with identical text from a
previous request, in which case further processing is allowed. | [
"Implements",
"user",
"message",
"checking",
"for",
"views",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L522-L538 |
41,056 | helixyte/everest | everest/views/base.py | WarnAndResubmitUserMessageChecker.create_307_response | def create_307_response(self):
"""
Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request.
"""
request = get_current_request()
msg_mb = UserMessageMember(self.... | python | def create_307_response(self):
"""
Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request.
"""
request = get_current_request()
msg_mb = UserMessageMember(self.... | [
"def",
"create_307_response",
"(",
"self",
")",
":",
"request",
"=",
"get_current_request",
"(",
")",
"msg_mb",
"=",
"UserMessageMember",
"(",
"self",
".",
"message",
")",
"coll",
"=",
"request",
".",
"root",
"[",
"'_messages'",
"]",
"coll",
".",
"add",
"(... | Creates a 307 "Temporary Redirect" response including a HTTP Warning
header with code 299 that contains the user message received during
processing the request. | [
"Creates",
"a",
"307",
"Temporary",
"Redirect",
"response",
"including",
"a",
"HTTP",
"Warning",
"header",
"with",
"code",
"299",
"that",
"contains",
"the",
"user",
"message",
"received",
"during",
"processing",
"the",
"request",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/views/base.py#L540-L560 |
41,057 | CMUSTRUDEL/strudel.utils | stutils/sysutils.py | mkdir | def mkdir(*args):
"""Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True
"""
path = ''
for chunk in args:
path = os.path.join(path, chunk)
if not os.path.isdir(p... | python | def mkdir(*args):
"""Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True
"""
path = ''
for chunk in args:
path = os.path.join(path, chunk)
if not os.path.isdir(p... | [
"def",
"mkdir",
"(",
"*",
"args",
")",
":",
"path",
"=",
"''",
"for",
"chunk",
"in",
"args",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"chunk",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":"... | Create a directory specified by a sequence of subdirectories
>>> mkdir("/tmp", "foo", "bar", "baz")
'/tmp/foo/bar/baz'
>>> os.path.isdir('/tmp/foo/bar/baz')
True | [
"Create",
"a",
"directory",
"specified",
"by",
"a",
"sequence",
"of",
"subdirectories"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/sysutils.py#L11-L24 |
41,058 | CMUSTRUDEL/strudel.utils | stutils/sysutils.py | shell | def shell(cmd, *args, **kwargs):
# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]
""" Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
... | python | def shell(cmd, *args, **kwargs):
# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]
""" Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
... | [
"def",
"shell",
"(",
"cmd",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Union[str, unicode], *Union[str, unicode], **Any) ->Tuple[int, str]",
"if",
"kwargs",
".",
"get",
"(",
"'rel_path'",
")",
"and",
"not",
"cmd",
".",
"startswith",
"(",
"\"/... | Execute shell command and return output
Args:
cmd (str): the command itself, i.e. part until the first space
*args: positional arguments, i.e. other space-separated parts
rel_path (bool): execute relative to the path (default: `False`)
raise_on_status(bool): bool, raise exception if... | [
"Execute",
"shell",
"command",
"and",
"return",
"output"
] | 888ef72fcdb851b5873092bc9c4d6958733691f2 | https://github.com/CMUSTRUDEL/strudel.utils/blob/888ef72fcdb851b5873092bc9c4d6958733691f2/stutils/sysutils.py#L27-L64 |
41,059 | Yipit/eventlib | eventlib/listener.py | listen_for_events | def listen_for_events():
"""Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play.
"""
import_event_modules()
conn = redis_connection.get_connection()
pubsub = conn.pubsub()
pubsub.subscribe("eventlib")
for message in pu... | python | def listen_for_events():
"""Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play.
"""
import_event_modules()
conn = redis_connection.get_connection()
pubsub = conn.pubsub()
pubsub.subscribe("eventlib")
for message in pu... | [
"def",
"listen_for_events",
"(",
")",
":",
"import_event_modules",
"(",
")",
"conn",
"=",
"redis_connection",
".",
"get_connection",
"(",
")",
"pubsub",
"=",
"conn",
".",
"pubsub",
"(",
")",
"pubsub",
".",
"subscribe",
"(",
"\"eventlib\"",
")",
"for",
"messa... | Pubsub event listener
Listen for events in the pubsub bus and calls the process function
when somebody comes to play. | [
"Pubsub",
"event",
"listener"
] | 0cf29e5251a59fcbfc727af5f5157a3bb03832e2 | https://github.com/Yipit/eventlib/blob/0cf29e5251a59fcbfc727af5f5157a3bb03832e2/eventlib/listener.py#L21-L37 |
41,060 | rajeevs1992/pyhealthvault | src/healthvaultlib/helpers/requestmanager.py | RequestManager.sendrequest | def sendrequest(self, request):
'''
Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py
'''
url = urlparse.urlparse(self.connection.healthserviceurl)
conn = None
if url.scheme == 'https':
... | python | def sendrequest(self, request):
'''
Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py
'''
url = urlparse.urlparse(self.connection.healthserviceurl)
conn = None
if url.scheme == 'https':
... | [
"def",
"sendrequest",
"(",
"self",
",",
"request",
")",
":",
"url",
"=",
"urlparse",
".",
"urlparse",
"(",
"self",
".",
"connection",
".",
"healthserviceurl",
")",
"conn",
"=",
"None",
"if",
"url",
".",
"scheme",
"==",
"'https'",
":",
"conn",
"=",
"htt... | Recieves a request xml as a string and posts it
to the health service url specified in the
settings.py | [
"Recieves",
"a",
"request",
"xml",
"as",
"a",
"string",
"and",
"posts",
"it",
"to",
"the",
"health",
"service",
"url",
"specified",
"in",
"the",
"settings",
".",
"py"
] | 2b6fa7c1687300bcc2e501368883fbb13dc80495 | https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/helpers/requestmanager.py#L94-L117 |
41,061 | helixyte/everest | everest/repositories/filesystem/repository.py | FileSystemRepository.commit | def commit(self, unit_of_work):
"""
Dump all resources that were modified by the given session back into
the repository.
"""
MemoryRepository.commit(self, unit_of_work)
if self.is_initialized:
entity_classes_to_dump = set()
for state in unit_of_wor... | python | def commit(self, unit_of_work):
"""
Dump all resources that were modified by the given session back into
the repository.
"""
MemoryRepository.commit(self, unit_of_work)
if self.is_initialized:
entity_classes_to_dump = set()
for state in unit_of_wor... | [
"def",
"commit",
"(",
"self",
",",
"unit_of_work",
")",
":",
"MemoryRepository",
".",
"commit",
"(",
"self",
",",
"unit_of_work",
")",
"if",
"self",
".",
"is_initialized",
":",
"entity_classes_to_dump",
"=",
"set",
"(",
")",
"for",
"state",
"in",
"unit_of_wo... | Dump all resources that were modified by the given session back into
the repository. | [
"Dump",
"all",
"resources",
"that",
"were",
"modified",
"by",
"the",
"given",
"session",
"back",
"into",
"the",
"repository",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/repositories/filesystem/repository.py#L44-L55 |
41,062 | lsst-sqre/lander | lander/config.py | Configuration._validate_pdf_file | def _validate_pdf_file(self):
"""Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails.
"""
if self['pdf_path'] is None:
self._logger.error('--pdf argument must be set')
sys.exi... | python | def _validate_pdf_file(self):
"""Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails.
"""
if self['pdf_path'] is None:
self._logger.error('--pdf argument must be set')
sys.exi... | [
"def",
"_validate_pdf_file",
"(",
"self",
")",
":",
"if",
"self",
"[",
"'pdf_path'",
"]",
"is",
"None",
":",
"self",
".",
"_logger",
".",
"error",
"(",
"'--pdf argument must be set'",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"if",
"not",
"os",
".",
"pat... | Validate that the pdf_path configuration is set and the referenced
file exists.
Exits the program with status 1 if validation fails. | [
"Validate",
"that",
"the",
"pdf_path",
"configuration",
"is",
"set",
"and",
"the",
"referenced",
"file",
"exists",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L221-L232 |
41,063 | lsst-sqre/lander | lander/config.py | Configuration._get_docushare_url | def _get_docushare_url(handle, validate=True):
"""Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performi... | python | def _get_docushare_url(handle, validate=True):
"""Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performi... | [
"def",
"_get_docushare_url",
"(",
"handle",
",",
"validate",
"=",
"True",
")",
":",
"logger",
"=",
"structlog",
".",
"get_logger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"'Using Configuration._get_docushare_url'",
")",
"# Make a short link to the DocuShare... | Get a docushare URL given document's handle.
Parameters
----------
handle : `str`
Handle name, such as ``'LDM-151'``.
validate : `bool`, optional
Set to `True` to request that the link resolves by performing
a HEAD request over the network. `False` di... | [
"Get",
"a",
"docushare",
"URL",
"given",
"document",
"s",
"handle",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L246-L296 |
41,064 | lsst-sqre/lander | lander/config.py | Configuration._init_defaults | def _init_defaults(self):
"""Create a `dict` of default configurations."""
defaults = {
'build_dir': None,
'build_datetime': datetime.datetime.now(dateutil.tz.tzutc()),
'pdf_path': None,
'extra_downloads': list(),
'environment': None,
... | python | def _init_defaults(self):
"""Create a `dict` of default configurations."""
defaults = {
'build_dir': None,
'build_datetime': datetime.datetime.now(dateutil.tz.tzutc()),
'pdf_path': None,
'extra_downloads': list(),
'environment': None,
... | [
"def",
"_init_defaults",
"(",
"self",
")",
":",
"defaults",
"=",
"{",
"'build_dir'",
":",
"None",
",",
"'build_datetime'",
":",
"datetime",
".",
"datetime",
".",
"now",
"(",
"dateutil",
".",
"tz",
".",
"tzutc",
"(",
")",
")",
",",
"'pdf_path'",
":",
"N... | Create a `dict` of default configurations. | [
"Create",
"a",
"dict",
"of",
"default",
"configurations",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/config.py#L335-L369 |
41,065 | clinicedc/edc-permissions | edc_permissions/utils/generic.py | create_permissions_from_tuples | def create_permissions_from_tuples(model, codename_tpls):
"""Creates custom permissions on model "model".
"""
if codename_tpls:
model_cls = django_apps.get_model(model)
content_type = ContentType.objects.get_for_model(model_cls)
for codename_tpl in codename_tpls:
app_labe... | python | def create_permissions_from_tuples(model, codename_tpls):
"""Creates custom permissions on model "model".
"""
if codename_tpls:
model_cls = django_apps.get_model(model)
content_type = ContentType.objects.get_for_model(model_cls)
for codename_tpl in codename_tpls:
app_labe... | [
"def",
"create_permissions_from_tuples",
"(",
"model",
",",
"codename_tpls",
")",
":",
"if",
"codename_tpls",
":",
"model_cls",
"=",
"django_apps",
".",
"get_model",
"(",
"model",
")",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
... | Creates custom permissions on model "model". | [
"Creates",
"custom",
"permissions",
"on",
"model",
"model",
"."
] | d1aee39a8ddaf4b7741d9306139ddd03625d4e1a | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/utils/generic.py#L108-L124 |
41,066 | clinicedc/edc-permissions | edc_permissions/utils/generic.py | remove_historical_group_permissions | def remove_historical_group_permissions(group=None, allowed_permissions=None):
"""Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`.
"""
allowed_permissions = allowed_permissions or ["view"]
for a... | python | def remove_historical_group_permissions(group=None, allowed_permissions=None):
"""Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`.
"""
allowed_permissions = allowed_permissions or ["view"]
for a... | [
"def",
"remove_historical_group_permissions",
"(",
"group",
"=",
"None",
",",
"allowed_permissions",
"=",
"None",
")",
":",
"allowed_permissions",
"=",
"allowed_permissions",
"or",
"[",
"\"view\"",
"]",
"for",
"action",
"in",
"allowed_permissions",
":",
"for",
"perm... | Removes group permissions for historical models
except those whose prefix is in `allowed_historical_permissions`.
Default removes all except `view`. | [
"Removes",
"group",
"permissions",
"for",
"historical",
"models",
"except",
"those",
"whose",
"prefix",
"is",
"in",
"allowed_historical_permissions",
"."
] | d1aee39a8ddaf4b7741d9306139ddd03625d4e1a | https://github.com/clinicedc/edc-permissions/blob/d1aee39a8ddaf4b7741d9306139ddd03625d4e1a/edc_permissions/utils/generic.py#L214-L226 |
41,067 | brmscheiner/ideogram | ideogram/converter.py | traversal | def traversal(root):
'''Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated.'''
stack = [root]
while len(stack) > 0:
node = stack.pop()
if ha... | python | def traversal(root):
'''Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated.'''
stack = [root]
while len(stack) > 0:
node = stack.pop()
if ha... | [
"def",
"traversal",
"(",
"root",
")",
":",
"stack",
"=",
"[",
"root",
"]",
"while",
"len",
"(",
"stack",
")",
">",
"0",
":",
"node",
"=",
"stack",
".",
"pop",
"(",
")",
"if",
"hasattr",
"(",
"node",
",",
"'children'",
")",
":",
"if",
"node",
".... | Tree traversal function that generates nodes. For each subtree, the
deepest node is evaluated first. Then, the next-deepest nodes are
evaluated until all the nodes in the subtree are generated. | [
"Tree",
"traversal",
"function",
"that",
"generates",
"nodes",
".",
"For",
"each",
"subtree",
"the",
"deepest",
"node",
"is",
"evaluated",
"first",
".",
"Then",
"the",
"next",
"-",
"deepest",
"nodes",
"are",
"evaluated",
"until",
"all",
"the",
"nodes",
"in",... | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L27-L47 |
41,068 | brmscheiner/ideogram | ideogram/converter.py | firstPass | def firstPass(ASTs,verbose):
'''Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys.'''
fdefs=dict()
cdefs=dict()
imp_obj_strs=dict()
imp_mods=dict()
for... | python | def firstPass(ASTs,verbose):
'''Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys.'''
fdefs=dict()
cdefs=dict()
imp_obj_strs=dict()
imp_mods=dict()
for... | [
"def",
"firstPass",
"(",
"ASTs",
",",
"verbose",
")",
":",
"fdefs",
"=",
"dict",
"(",
")",
"cdefs",
"=",
"dict",
"(",
")",
"imp_obj_strs",
"=",
"dict",
"(",
")",
"imp_mods",
"=",
"dict",
"(",
")",
"for",
"(",
"root",
",",
"path",
")",
"in",
"ASTs... | Return a dictionary of function definition nodes, a dictionary of
imported object names and a dictionary of imported module names. All three
dictionaries use source file paths as keys. | [
"Return",
"a",
"dictionary",
"of",
"function",
"definition",
"nodes",
"a",
"dictionary",
"of",
"imported",
"object",
"names",
"and",
"a",
"dictionary",
"of",
"imported",
"module",
"names",
".",
"All",
"three",
"dictionaries",
"use",
"source",
"file",
"paths",
... | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L49-L81 |
41,069 | brmscheiner/ideogram | ideogram/converter.py | formatBodyNode | def formatBodyNode(root,path):
'''Format the root node for use as the body node.'''
body = root
body.name = "body"
body.weight = calcFnWeight(body)
body.path = path
body.pclass = None
return body | python | def formatBodyNode(root,path):
'''Format the root node for use as the body node.'''
body = root
body.name = "body"
body.weight = calcFnWeight(body)
body.path = path
body.pclass = None
return body | [
"def",
"formatBodyNode",
"(",
"root",
",",
"path",
")",
":",
"body",
"=",
"root",
"body",
".",
"name",
"=",
"\"body\"",
"body",
".",
"weight",
"=",
"calcFnWeight",
"(",
"body",
")",
"body",
".",
"path",
"=",
"path",
"body",
".",
"pclass",
"=",
"None"... | Format the root node for use as the body node. | [
"Format",
"the",
"root",
"node",
"for",
"use",
"as",
"the",
"body",
"node",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L104-L111 |
41,070 | brmscheiner/ideogram | ideogram/converter.py | formatFunctionNode | def formatFunctionNode(node,path,stack):
'''Add some helpful attributes to node.'''
#node.name is already defined by AST module
node.weight = calcFnWeight(node)
node.path = path
node.pclass = getCurrentClass(stack)
return node | python | def formatFunctionNode(node,path,stack):
'''Add some helpful attributes to node.'''
#node.name is already defined by AST module
node.weight = calcFnWeight(node)
node.path = path
node.pclass = getCurrentClass(stack)
return node | [
"def",
"formatFunctionNode",
"(",
"node",
",",
"path",
",",
"stack",
")",
":",
"#node.name is already defined by AST module",
"node",
".",
"weight",
"=",
"calcFnWeight",
"(",
"node",
")",
"node",
".",
"path",
"=",
"path",
"node",
".",
"pclass",
"=",
"getCurren... | Add some helpful attributes to node. | [
"Add",
"some",
"helpful",
"attributes",
"to",
"node",
"."
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L113-L119 |
41,071 | brmscheiner/ideogram | ideogram/converter.py | getSourceFnDef | def getSourceFnDef(stack,fdefs,path):
'''VERY VERY SLOW'''
found = False
for x in stack:
if isinstance(x, ast.FunctionDef):
for y in fdefs[path]:
if ast.dump(x)==ast.dump(y): #probably causing the slowness
found = True
return y
... | python | def getSourceFnDef(stack,fdefs,path):
'''VERY VERY SLOW'''
found = False
for x in stack:
if isinstance(x, ast.FunctionDef):
for y in fdefs[path]:
if ast.dump(x)==ast.dump(y): #probably causing the slowness
found = True
return y
... | [
"def",
"getSourceFnDef",
"(",
"stack",
",",
"fdefs",
",",
"path",
")",
":",
"found",
"=",
"False",
"for",
"x",
"in",
"stack",
":",
"if",
"isinstance",
"(",
"x",
",",
"ast",
".",
"FunctionDef",
")",
":",
"for",
"y",
"in",
"fdefs",
"[",
"path",
"]",
... | VERY VERY SLOW | [
"VERY",
"VERY",
"SLOW"
] | 422bf566c51fd56f7bbb6e75b16d18d52b4c7568 | https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/converter.py#L134-L148 |
41,072 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/mongo/mongo_util.py | delete_database | def delete_database(mongo_uri, database_name):
"""
Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
"""
client = pymongo.MongoClient(mongo_uri)
client.drop_dat... | python | def delete_database(mongo_uri, database_name):
"""
Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
"""
client = pymongo.MongoClient(mongo_uri)
client.drop_dat... | [
"def",
"delete_database",
"(",
"mongo_uri",
",",
"database_name",
")",
":",
"client",
"=",
"pymongo",
".",
"MongoClient",
"(",
"mongo_uri",
")",
"client",
".",
"drop_database",
"(",
"database_name",
")"
] | Delete a mongo database using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string. | [
"Delete",
"a",
"mongo",
"database",
"using",
"pymongo",
".",
"Mongo",
"daemon",
"assumed",
"to",
"be",
"running",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/mongo_util.py#L18-L27 |
41,073 | MKLab-ITI/reveal-user-annotation | reveal_user_annotation/mongo/mongo_util.py | delete_collection | def delete_collection(mongo_uri, database_name, collection_name):
"""
Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo c... | python | def delete_collection(mongo_uri, database_name, collection_name):
"""
Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo c... | [
"def",
"delete_collection",
"(",
"mongo_uri",
",",
"database_name",
",",
"collection_name",
")",
":",
"client",
"=",
"pymongo",
".",
"MongoClient",
"(",
"mongo_uri",
")",
"db",
"=",
"client",
"[",
"database_name",
"]",
"db",
".",
"drop_collection",
"(",
"colle... | Delete a mongo document collection using pymongo. Mongo daemon assumed to be running.
Inputs: - mongo_uri: A MongoDB URI.
- database_name: The mongo database name as a python string.
- collection_name: The mongo collection as a python string. | [
"Delete",
"a",
"mongo",
"document",
"collection",
"using",
"pymongo",
".",
"Mongo",
"daemon",
"assumed",
"to",
"be",
"running",
"."
] | ed019c031857b091e5601f53ba3f01a499a0e3ef | https://github.com/MKLab-ITI/reveal-user-annotation/blob/ed019c031857b091e5601f53ba3f01a499a0e3ef/reveal_user_annotation/mongo/mongo_util.py#L30-L42 |
41,074 | helixyte/everest | everest/resources/staging.py | create_staging_collection | def create_staging_collection(resource):
"""
Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
ent_cls = ... | python | def create_staging_collection(resource):
"""
Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface.
"""
ent_cls = ... | [
"def",
"create_staging_collection",
"(",
"resource",
")",
":",
"ent_cls",
"=",
"get_entity_class",
"(",
"resource",
")",
"coll_cls",
"=",
"get_collection_class",
"(",
"resource",
")",
"agg",
"=",
"StagingAggregate",
"(",
"ent_cls",
")",
"return",
"coll_cls",
".",
... | Helper function to create a staging collection for the given registered
resource.
:param resource: registered resource
:type resource: class implementing or instance providing or subclass of
a registered resource interface. | [
"Helper",
"function",
"to",
"create",
"a",
"staging",
"collection",
"for",
"the",
"given",
"registered",
"resource",
"."
] | 70c9b93c3061db5cb62428349d18b8fb8566411b | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/staging.py#L114-L126 |
41,075 | Nekroze/partpy | examples/contacts.py | ContactsParser.parse | def parse(self):
"""Run the parser over the entire sourestring and return the results."""
try:
return self.parse_top_level()
except PartpyError as ex:
self.error = True
print(ex.pretty_print()) | python | def parse(self):
"""Run the parser over the entire sourestring and return the results."""
try:
return self.parse_top_level()
except PartpyError as ex:
self.error = True
print(ex.pretty_print()) | [
"def",
"parse",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"parse_top_level",
"(",
")",
"except",
"PartpyError",
"as",
"ex",
":",
"self",
".",
"error",
"=",
"True",
"print",
"(",
"ex",
".",
"pretty_print",
"(",
")",
")"
] | Run the parser over the entire sourestring and return the results. | [
"Run",
"the",
"parser",
"over",
"the",
"entire",
"sourestring",
"and",
"return",
"the",
"results",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L23-L29 |
41,076 | Nekroze/partpy | examples/contacts.py | ContactsParser.parse_top_level | def parse_top_level(self):
"""The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them.
"""
contacts = []
while not self.eos:
... | python | def parse_top_level(self):
"""The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them.
"""
contacts = []
while not self.eos:
... | [
"def",
"parse_top_level",
"(",
"self",
")",
":",
"contacts",
"=",
"[",
"]",
"while",
"not",
"self",
".",
"eos",
":",
"contact",
"=",
"self",
".",
"parse_contact",
"(",
")",
"# match a contact expression.",
"if",
"not",
"contact",
":",
"# There was no contact s... | The top level parser will do a loop where it looks for a single
contact parse and then eats all whitespace until there is no more
input left or another contact is found to be parsed and stores them. | [
"The",
"top",
"level",
"parser",
"will",
"do",
"a",
"loop",
"where",
"it",
"looks",
"for",
"a",
"single",
"contact",
"parse",
"and",
"then",
"eats",
"all",
"whitespace",
"until",
"there",
"is",
"no",
"more",
"input",
"left",
"or",
"another",
"contact",
"... | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L31-L48 |
41,077 | Nekroze/partpy | examples/contacts.py | ContactsParser.parse_contact | def parse_contact(self):
"""Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned.
"""
self.parse_whitespace()
name = self.parse_name() # parse a ... | python | def parse_contact(self):
"""Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned.
"""
self.parse_whitespace()
name = self.parse_name() # parse a ... | [
"def",
"parse_contact",
"(",
"self",
")",
":",
"self",
".",
"parse_whitespace",
"(",
")",
"name",
"=",
"self",
".",
"parse_name",
"(",
")",
"# parse a name expression and get the string.",
"if",
"not",
"name",
":",
"# No name was found so shout it out.",
"raise",
"P... | Parse a top level contact expression, these consist of a name
expression a special char and an email expression.
The characters found in a name and email expression are returned. | [
"Parse",
"a",
"top",
"level",
"contact",
"expression",
"these",
"consist",
"of",
"a",
"name",
"expression",
"a",
"special",
"char",
"and",
"an",
"email",
"expression",
"."
] | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L50-L71 |
41,078 | Nekroze/partpy | examples/contacts.py | ContactsParser.parse_name | def parse_name(self):
"""This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output."""
name = []
while True:
# Match the current char until it d... | python | def parse_name(self):
"""This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output."""
name = []
while True:
# Match the current char until it d... | [
"def",
"parse_name",
"(",
"self",
")",
":",
"name",
"=",
"[",
"]",
"while",
"True",
":",
"# Match the current char until it doesnt match the given pattern:",
"# first char must be an uppercase alpha and the rest must be lower",
"# cased alphas.",
"part",
"=",
"self",
".",
"ma... | This function uses string patterns to match a title cased name.
This is done in a loop until there are no more names to match so as
to be able to include surnames etc. in the output. | [
"This",
"function",
"uses",
"string",
"patterns",
"to",
"match",
"a",
"title",
"cased",
"name",
".",
"This",
"is",
"done",
"in",
"a",
"loop",
"until",
"there",
"are",
"no",
"more",
"names",
"to",
"match",
"so",
"as",
"to",
"be",
"able",
"to",
"include"... | dbb7d2fb285464fc43d85bc31f5af46192d301f6 | https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/examples/contacts.py#L84-L104 |
41,079 | VJftw/invoke-tools | idflow/flow.py | Flow.get_development_container_name | def get_development_container_name(self):
"""
Returns the development container name
"""
if self.__prefix:
return "{0}:{1}-{2}-dev".format(
self.__repository,
self.__prefix,
self.__branch)
else:
return "{0}:{... | python | def get_development_container_name(self):
"""
Returns the development container name
"""
if self.__prefix:
return "{0}:{1}-{2}-dev".format(
self.__repository,
self.__prefix,
self.__branch)
else:
return "{0}:{... | [
"def",
"get_development_container_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}:{1}-{2}-dev\"",
".",
"format",
"(",
"self",
".",
"__repository",
",",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
")",
"else",
":"... | Returns the development container name | [
"Returns",
"the",
"development",
"container",
"name"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L59-L71 |
41,080 | VJftw/invoke-tools | idflow/flow.py | Flow.get_build_container_tag | def get_build_container_tag(self):
"""
Return the build container tag
"""
if self.__prefix:
return "{0}-{1}-{2}".format(
self.__prefix,
self.__branch,
self.__version)
else:
return "{0}-{1}".format(
... | python | def get_build_container_tag(self):
"""
Return the build container tag
"""
if self.__prefix:
return "{0}-{1}-{2}".format(
self.__prefix,
self.__branch,
self.__version)
else:
return "{0}-{1}".format(
... | [
"def",
"get_build_container_tag",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}-{1}-{2}\"",
".",
"format",
"(",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
",",
"self",
".",
"__version",
")",
"else",
":",
"return",
... | Return the build container tag | [
"Return",
"the",
"build",
"container",
"tag"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L73-L85 |
41,081 | VJftw/invoke-tools | idflow/flow.py | Flow.get_branch_container_tag | def get_branch_container_tag(self):
"""
Returns the branch container tag
"""
if self.__prefix:
return "{0}-{1}".format(
self.__prefix,
self.__branch)
else:
return "{0}".format(self.__branch) | python | def get_branch_container_tag(self):
"""
Returns the branch container tag
"""
if self.__prefix:
return "{0}-{1}".format(
self.__prefix,
self.__branch)
else:
return "{0}".format(self.__branch) | [
"def",
"get_branch_container_tag",
"(",
"self",
")",
":",
"if",
"self",
".",
"__prefix",
":",
"return",
"\"{0}-{1}\"",
".",
"format",
"(",
"self",
".",
"__prefix",
",",
"self",
".",
"__branch",
")",
"else",
":",
"return",
"\"{0}\"",
".",
"format",
"(",
"... | Returns the branch container tag | [
"Returns",
"the",
"branch",
"container",
"tag"
] | 9584a1f8a402118310b6f2a495062f388fc8dc3a | https://github.com/VJftw/invoke-tools/blob/9584a1f8a402118310b6f2a495062f388fc8dc3a/idflow/flow.py#L95-L104 |
41,082 | callowayproject/Calloway | calloway/apps/django_ext/views.py | custom_server_error | def custom_server_error(request, template_name='500.html', admin_template_name='500A.html'):
"""
500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback... | python | def custom_server_error(request, template_name='500.html', admin_template_name='500A.html'):
"""
500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback... | [
"def",
"custom_server_error",
"(",
"request",
",",
"template_name",
"=",
"'500.html'",
",",
"admin_template_name",
"=",
"'500A.html'",
")",
":",
"trace",
"=",
"None",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
"and",
"(",
"request",
".",
... | 500 error handler. Displays a full trackback for superusers and the first line of the
traceback for staff members.
Templates: `500.html` or `500A.html` (admin)
Context: trace
Holds the traceback information for debugging. | [
"500",
"error",
"handler",
".",
"Displays",
"a",
"full",
"trackback",
"for",
"superusers",
"and",
"the",
"first",
"line",
"of",
"the",
"traceback",
"for",
"staff",
"members",
"."
] | d22e98d41fbd298ab6393ba7bd84a75528be9f81 | https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/views.py#L6-L31 |
41,083 | skylander86/ycsettings | ycsettings/settings.py | parse_n_jobs | def parse_n_jobs(s):
"""
This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
... | python | def parse_n_jobs(s):
"""
This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
... | [
"def",
"parse_n_jobs",
"(",
"s",
")",
":",
"n_jobs",
"=",
"None",
"N",
"=",
"cpu_count",
"(",
")",
"if",
"isinstance",
"(",
"s",
",",
"int",
")",
":",
"n_jobs",
"=",
"s",
"elif",
"isinstance",
"(",
"s",
",",
"float",
")",
":",
"n_jobs",
"=",
"int... | This function parses a "math"-like string as a function of CPU count.
It is useful for specifying the number of jobs.
For example, on an 8-core machine::
assert parse_n_jobs('0.5 * n') == 4
assert parse_n_jobs('2n') == 16
assert parse_n_jobs('n') == 8
assert parse_n_jobs('4') =... | [
"This",
"function",
"parses",
"a",
"math",
"-",
"like",
"string",
"as",
"a",
"function",
"of",
"CPU",
"count",
".",
"It",
"is",
"useful",
"for",
"specifying",
"the",
"number",
"of",
"jobs",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L456-L495 |
41,084 | skylander86/ycsettings | ycsettings/settings.py | Settings._load_settings_from_source | def _load_settings_from_source(self, source):
"""
Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict
"""
if not source:
pass
elif source == 'env_settings_ur... | python | def _load_settings_from_source(self, source):
"""
Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict
"""
if not source:
pass
elif source == 'env_settings_ur... | [
"def",
"_load_settings_from_source",
"(",
"self",
",",
"source",
")",
":",
"if",
"not",
"source",
":",
"pass",
"elif",
"source",
"==",
"'env_settings_uri'",
":",
"for",
"env_settings_uri_key",
"in",
"self",
".",
"env_settings_uri_keys",
":",
"env_settings_uri",
"=... | Loads the relevant settings from the specified ``source``.
:returns: a standard :func:`dict` containing the settings from the source
:rtype: dict | [
"Loads",
"the",
"relevant",
"settings",
"from",
"the",
"specified",
"source",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L93-L158 |
41,085 | skylander86/ycsettings | ycsettings/settings.py | Settings.get | def get(self, key, *, default=None, cast_func=None, case_sensitive=None, raise_exception=None, warn_missing=None, use_cache=True, additional_sources=[]):
"""
Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
... | python | def get(self, key, *, default=None, cast_func=None, case_sensitive=None, raise_exception=None, warn_missing=None, use_cache=True, additional_sources=[]):
"""
Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"*",
",",
"default",
"=",
"None",
",",
"cast_func",
"=",
"None",
",",
"case_sensitive",
"=",
"None",
",",
"raise_exception",
"=",
"None",
",",
"warn_missing",
"=",
"None",
",",
"use_cache",
"=",
"True",
",",
... | Gets the setting specified by ``key``. For efficiency, we cache the retrieval of settings to avoid multiple searches through the sources list.
:param str key: settings key to retrieve
:param str default: use this as default value when the setting key is not found
:param func cast_func: cast the... | [
"Gets",
"the",
"setting",
"specified",
"by",
"key",
".",
"For",
"efficiency",
"we",
"cache",
"the",
"retrieval",
"of",
"settings",
"to",
"avoid",
"multiple",
"searches",
"through",
"the",
"sources",
"list",
"."
] | 3f363673a6cb1823ebb18c4d640d87aa49202344 | https://github.com/skylander86/ycsettings/blob/3f363673a6cb1823ebb18c4d640d87aa49202344/ycsettings/settings.py#L230-L289 |
41,086 | hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._in_list | def _in_list(self, original_list, item):
"""
Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item... | python | def _in_list(self, original_list, item):
"""
Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item... | [
"def",
"_in_list",
"(",
"self",
",",
"original_list",
",",
"item",
")",
":",
"# pylint: disable=no-self-use",
"for",
"item_list",
"in",
"original_list",
":",
"if",
"item",
"is",
"item_list",
":",
"return",
"True",
"return",
"False"
] | Check that an item as contained in a list.
:param original_list: The list.
:type original_list: list(object)
:param item: The item.
:type item: hatemile.util.html.htmldomelement.HTMLDOMElement
:return: True if the item contained in the list or False if not.
:rtype: bool | [
"Check",
"that",
"an",
"item",
"as",
"contained",
"in",
"a",
"list",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L49-L65 |
41,087 | hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._sort_results | def _sort_results(self, results):
"""
Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag
"""
parents = []
groups = []
for result in r... | python | def _sort_results(self, results):
"""
Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag
"""
parents = []
groups = []
for result in r... | [
"def",
"_sort_results",
"(",
"self",
",",
"results",
")",
":",
"parents",
"=",
"[",
"]",
"groups",
"=",
"[",
"]",
"for",
"result",
"in",
"results",
":",
"if",
"not",
"self",
".",
"_in_list",
"(",
"parents",
",",
"result",
".",
"parent",
")",
":",
"... | Order the results.
:param results: The disordened results.
:type results: array.bs4.element.Tag
:return: The ordened results.
:rtype: array.bs4.element.Tag | [
"Order",
"the",
"results",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L67-L92 |
41,088 | hatemile/hatemile-for-python | hatemile/util/html/bs/bshtmldomparser.py | BeautifulSoupHTMLDOMParser._fix_data_select | def _fix_data_select(self):
"""
Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search.
"""
elements = self.document.select('*')
for element in elements:
attributes = element.attrs.keys()
data_attributes = list()
... | python | def _fix_data_select(self):
"""
Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search.
"""
elements = self.document.select('*')
for element in elements:
attributes = element.attrs.keys()
data_attributes = list()
... | [
"def",
"_fix_data_select",
"(",
"self",
")",
":",
"elements",
"=",
"self",
".",
"document",
".",
"select",
"(",
"'*'",
")",
"for",
"element",
"in",
"elements",
":",
"attributes",
"=",
"element",
".",
"attrs",
".",
"keys",
"(",
")",
"data_attributes",
"="... | Replace all hyphens of data attributes for 'aaaaa', to avoid error in
search. | [
"Replace",
"all",
"hyphens",
"of",
"data",
"attributes",
"for",
"aaaaa",
"to",
"avoid",
"error",
"in",
"search",
"."
] | 1e914f9aa09f6f8d78282af131311546ecba9fb8 | https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/util/html/bs/bshtmldomparser.py#L94-L120 |
41,089 | tBaxter/activity-monitor | activity_monitor/templatetags/activity_tags.py | render_activity | def render_activity(activity, grouped_activity=None, *args, **kwargs):
"""
Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would... | python | def render_activity(activity, grouped_activity=None, *args, **kwargs):
"""
Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would... | [
"def",
"render_activity",
"(",
"activity",
",",
"grouped_activity",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"template_name",
"=",
"'activity_monitor/includes/models/{0.app_label}_{0.model}.html'",
".",
"format",
"(",
"activity",
".",
"conte... | Given an activity, will attempt to render the matching template snippet
for that activity's content object
or will return a simple representation of the activity.
Also takes an optional 'grouped_activity' argument that would match up with
what is produced by utils.group_activity | [
"Given",
"an",
"activity",
"will",
"attempt",
"to",
"render",
"the",
"matching",
"template",
"snippet",
"for",
"that",
"activity",
"s",
"content",
"object",
"or",
"will",
"return",
"a",
"simple",
"representation",
"of",
"the",
"activity",
"."
] | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/templatetags/activity_tags.py#L38-L58 |
41,090 | tBaxter/activity-monitor | activity_monitor/templatetags/activity_tags.py | show_activity_count | def show_activity_count(date=None):
"""
Simple filter to get activity count for a given day.
Defaults to today.
"""
if not date:
today = datetime.datetime.now() - datetime.timedelta(hours = 24)
return Activity.objects.filter(timestamp__gte=today).count()
return Activity.objects.f... | python | def show_activity_count(date=None):
"""
Simple filter to get activity count for a given day.
Defaults to today.
"""
if not date:
today = datetime.datetime.now() - datetime.timedelta(hours = 24)
return Activity.objects.filter(timestamp__gte=today).count()
return Activity.objects.f... | [
"def",
"show_activity_count",
"(",
"date",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"today",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"24",
")",
"return",
"Activity",
".",
"... | Simple filter to get activity count for a given day.
Defaults to today. | [
"Simple",
"filter",
"to",
"get",
"activity",
"count",
"for",
"a",
"given",
"day",
".",
"Defaults",
"to",
"today",
"."
] | be6c6edc7c6b4141923b47376502cde0f785eb68 | https://github.com/tBaxter/activity-monitor/blob/be6c6edc7c6b4141923b47376502cde0f785eb68/activity_monitor/templatetags/activity_tags.py#L62-L70 |
41,091 | AtomHash/evernode | evernode/classes/app.py | __root_path | def __root_path(self):
""" Just checks the root path if set """
if self.root_path is not None:
if os.path.isdir(self.root_path):
sys.path.append(self.root_path)
return
raise RuntimeError('EverNode requires a valid root path.'
... | python | def __root_path(self):
""" Just checks the root path if set """
if self.root_path is not None:
if os.path.isdir(self.root_path):
sys.path.append(self.root_path)
return
raise RuntimeError('EverNode requires a valid root path.'
... | [
"def",
"__root_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"root_path",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"root_path",
")",
":",
"sys",
".",
"path",
".",
"append",
"(",
"self",
".",
"root_path",... | Just checks the root path if set | [
"Just",
"checks",
"the",
"root",
"path",
"if",
"set"
] | b2fb91555fb937a3f3eba41db56dee26f9b034be | https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/app.py#L37-L45 |
41,092 | lsst-sqre/lander | lander/lander.py | Lander.write_metadata | def write_metadata(self, output_path):
"""Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build.
"""
if self._config.lsstdoc is None:
... | python | def write_metadata(self, output_path):
"""Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build.
"""
if self._config.lsstdoc is None:
... | [
"def",
"write_metadata",
"(",
"self",
",",
"output_path",
")",
":",
"if",
"self",
".",
"_config",
".",
"lsstdoc",
"is",
"None",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'No known LSST LaTeX source (--tex argument). '",
"'Not writing a metadata.jsonld file.'",
... | Build a JSON-LD dataset for LSST Projectmeta.
Parameters
----------
output_path : `str`
File path where the ``metadata.jsonld`` should be written for the
build. | [
"Build",
"a",
"JSON",
"-",
"LD",
"dataset",
"for",
"LSST",
"Projectmeta",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/lander.py#L89-L117 |
41,093 | lsst-sqre/lander | lander/lander.py | Lander.upload_site | def upload_site(self):
"""Upload a previously-built site to LSST the Docs."""
if not os.path.isdir(self._config['build_dir']):
message = 'Site not built at {0}'.format(self._config['build_dir'])
self._logger.error(message)
raise RuntimeError(message)
ltdclien... | python | def upload_site(self):
"""Upload a previously-built site to LSST the Docs."""
if not os.path.isdir(self._config['build_dir']):
message = 'Site not built at {0}'.format(self._config['build_dir'])
self._logger.error(message)
raise RuntimeError(message)
ltdclien... | [
"def",
"upload_site",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
".",
"_config",
"[",
"'build_dir'",
"]",
")",
":",
"message",
"=",
"'Site not built at {0}'",
".",
"format",
"(",
"self",
".",
"_config",
"[",
"'bui... | Upload a previously-built site to LSST the Docs. | [
"Upload",
"a",
"previously",
"-",
"built",
"site",
"to",
"LSST",
"the",
"Docs",
"."
] | 5e4f6123e48b451ba21963724ace0dc59798618e | https://github.com/lsst-sqre/lander/blob/5e4f6123e48b451ba21963724ace0dc59798618e/lander/lander.py#L119-L126 |
41,094 | ponty/confduino | confduino/liblist.py | libraries | def libraries():
"""return installed library names."""
ls = libraries_dir().dirs()
ls = [str(x.name) for x in ls]
ls.sort()
return ls | python | def libraries():
"""return installed library names."""
ls = libraries_dir().dirs()
ls = [str(x.name) for x in ls]
ls.sort()
return ls | [
"def",
"libraries",
"(",
")",
":",
"ls",
"=",
"libraries_dir",
"(",
")",
".",
"dirs",
"(",
")",
"ls",
"=",
"[",
"str",
"(",
"x",
".",
"name",
")",
"for",
"x",
"in",
"ls",
"]",
"ls",
".",
"sort",
"(",
")",
"return",
"ls"
] | return installed library names. | [
"return",
"installed",
"library",
"names",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/liblist.py#L26-L31 |
41,095 | ponty/confduino | confduino/liblist.py | lib_examples | def lib_examples(lib):
"""return library examples.
EXAMPLE1,EXAMPLE2,..
"""
d = lib_examples_dir(lib)
if not d.exists():
return []
ls = d.dirs()
ls = [x.name for x in ls]
ls.sort()
return ls | python | def lib_examples(lib):
"""return library examples.
EXAMPLE1,EXAMPLE2,..
"""
d = lib_examples_dir(lib)
if not d.exists():
return []
ls = d.dirs()
ls = [x.name for x in ls]
ls.sort()
return ls | [
"def",
"lib_examples",
"(",
"lib",
")",
":",
"d",
"=",
"lib_examples_dir",
"(",
"lib",
")",
"if",
"not",
"d",
".",
"exists",
"(",
")",
":",
"return",
"[",
"]",
"ls",
"=",
"d",
".",
"dirs",
"(",
")",
"ls",
"=",
"[",
"x",
".",
"name",
"for",
"x... | return library examples.
EXAMPLE1,EXAMPLE2,.. | [
"return",
"library",
"examples",
"."
] | f4c261e5e84997f145a8bdd001f471db74c9054b | https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/liblist.py#L61-L73 |
41,096 | vicalloy/lbutils | lbutils/utils.py | safe_eval | def safe_eval(source, *args, **kwargs):
""" eval without import """
source = source.replace('import', '') # import is not allowed
return eval(source, *args, **kwargs) | python | def safe_eval(source, *args, **kwargs):
""" eval without import """
source = source.replace('import', '') # import is not allowed
return eval(source, *args, **kwargs) | [
"def",
"safe_eval",
"(",
"source",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"source",
"=",
"source",
".",
"replace",
"(",
"'import'",
",",
"''",
")",
"# import is not allowed",
"return",
"eval",
"(",
"source",
",",
"*",
"args",
",",
"*",
... | eval without import | [
"eval",
"without",
"import"
] | 66ae7e73bc939f073cdc1b91602a95e67caf4ba6 | https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/utils.py#L15-L18 |
41,097 | asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.intersect | def intersect(self, **kwargs):
"""
Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a part... | python | def intersect(self, **kwargs):
"""
Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a part... | [
"def",
"intersect",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ls",
"=",
"None",
"if",
"\"linestring\"",
"in",
"kwargs",
":",
"ls",
"=",
"kwargs",
".",
"pop",
"(",
"'linestring'",
")",
"spoint",
"=",
"Point",
"(",
"ls",
".",
"coords",
"[",
"0... | Intersect a Line or Point Collection and the Shoreline
Returns the point of intersection along the coastline
Should also return a linestring buffer around the interseciton point
so we can calculate the direction to bounce a particle. | [
"Intersect",
"a",
"Line",
"or",
"Point",
"Collection",
"and",
"the",
"Shoreline"
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L104-L173 |
41,098 | asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.__bounce | def __bounce(self, **kwargs):
"""
Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwis... | python | def __bounce(self, **kwargs):
"""
Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwis... | [
"def",
"__bounce",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"start_point",
"=",
"kwargs",
".",
"pop",
"(",
"'start_point'",
")",
"hit_point",
"=",
"kwargs",
".",
"pop",
"(",
"'hit_point'",
")",
"end_point",
"=",
"kwargs",
".",
"pop",
"(",
"'end_... | Bounce off of the shoreline.
NOTE: This does not work, but left here for future implementation
feature = Linestring of two points, being the line segment the particle hit.
angle = decimal degrees from 0 (x-axis), couter-clockwise (math style) | [
"Bounce",
"off",
"of",
"the",
"shoreline",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L190-L230 |
41,099 | asascience-open/paegan-transport | paegan/transport/shoreline.py | Shoreline.__reverse | def __reverse(self, **kwargs):
"""
Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in.
"""
start_point = kwargs.pop('start_point')
hit_point = kwargs.pop('hit_point')
... | python | def __reverse(self, **kwargs):
"""
Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in.
"""
start_point = kwargs.pop('start_point')
hit_point = kwargs.pop('hit_point')
... | [
"def",
"__reverse",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"start_point",
"=",
"kwargs",
".",
"pop",
"(",
"'start_point'",
")",
"hit_point",
"=",
"kwargs",
".",
"pop",
"(",
"'hit_point'",
")",
"distance",
"=",
"kwargs",
".",
"pop",
"(",
"'dist... | Reverse particle just off of the shore in the direction that it came in.
Adds a slight random factor to the distance and angle it is reversed in. | [
"Reverse",
"particle",
"just",
"off",
"of",
"the",
"shore",
"in",
"the",
"direction",
"that",
"it",
"came",
"in",
".",
"Adds",
"a",
"slight",
"random",
"factor",
"to",
"the",
"distance",
"and",
"angle",
"it",
"is",
"reversed",
"in",
"."
] | 99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3 | https://github.com/asascience-open/paegan-transport/blob/99a7f4ea24f0f42d9b34d1fb0e87ab2c49315bd3/paegan/transport/shoreline.py#L232-L286 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.