repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
ofir123/py-printer | pyprinter/printer.py | _in_qtconsole | def _in_qtconsole() -> bool:
"""
A small utility function which determines if we're running in QTConsole's context.
"""
try:
from IPython import get_ipython
try:
from ipykernel.zmqshell import ZMQInteractiveShell
shell_object = ZMQInteractiveShell
except I... | python | def _in_qtconsole() -> bool:
"""
A small utility function which determines if we're running in QTConsole's context.
"""
try:
from IPython import get_ipython
try:
from ipykernel.zmqshell import ZMQInteractiveShell
shell_object = ZMQInteractiveShell
except I... | [
"def",
"_in_qtconsole",
"(",
")",
"->",
"bool",
":",
"try",
":",
"from",
"IPython",
"import",
"get_ipython",
"try",
":",
"from",
"ipykernel",
".",
"zmqshell",
"import",
"ZMQInteractiveShell",
"shell_object",
"=",
"ZMQInteractiveShell",
"except",
"ImportError",
":"... | A small utility function which determines if we're running in QTConsole's context. | [
"A",
"small",
"utility",
"function",
"which",
"determines",
"if",
"we",
"re",
"running",
"in",
"QTConsole",
"s",
"context",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L368-L382 |
ofir123/py-printer | pyprinter/printer.py | get_console_width | def get_console_width() -> int:
"""
A small utility function for getting the current console window's width.
:return: The current console window's width.
"""
# Assigning the value once, as frequent call to this function
# causes a major slow down(ImportErrors + isinstance).
global _IN_QT
... | python | def get_console_width() -> int:
"""
A small utility function for getting the current console window's width.
:return: The current console window's width.
"""
# Assigning the value once, as frequent call to this function
# causes a major slow down(ImportErrors + isinstance).
global _IN_QT
... | [
"def",
"get_console_width",
"(",
")",
"->",
"int",
":",
"# Assigning the value once, as frequent call to this function",
"# causes a major slow down(ImportErrors + isinstance).",
"global",
"_IN_QT",
"if",
"_IN_QT",
"is",
"None",
":",
"_IN_QT",
"=",
"_in_qtconsole",
"(",
")",
... | A small utility function for getting the current console window's width.
:return: The current console window's width. | [
"A",
"small",
"utility",
"function",
"for",
"getting",
"the",
"current",
"console",
"window",
"s",
"width",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L385-L408 |
ofir123/py-printer | pyprinter/printer.py | Printer.group | def group(self, indent: int = DEFAULT_INDENT, add_line: bool = True) -> _TextGroup:
"""
Returns a context manager which adds an indentation before each line.
:param indent: Number of spaces to print.
:param add_line: If True, a new line will be printed after the group.
:return: ... | python | def group(self, indent: int = DEFAULT_INDENT, add_line: bool = True) -> _TextGroup:
"""
Returns a context manager which adds an indentation before each line.
:param indent: Number of spaces to print.
:param add_line: If True, a new line will be printed after the group.
:return: ... | [
"def",
"group",
"(",
"self",
",",
"indent",
":",
"int",
"=",
"DEFAULT_INDENT",
",",
"add_line",
":",
"bool",
"=",
"True",
")",
"->",
"_TextGroup",
":",
"return",
"_TextGroup",
"(",
"self",
",",
"indent",
",",
"add_line",
")"
] | Returns a context manager which adds an indentation before each line.
:param indent: Number of spaces to print.
:param add_line: If True, a new line will be printed after the group.
:return: A TextGroup context manager. | [
"Returns",
"a",
"context",
"manager",
"which",
"adds",
"an",
"indentation",
"before",
"each",
"line",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L112-L120 |
ofir123/py-printer | pyprinter/printer.py | Printer._split_lines | def _split_lines(self, original_lines: List[str]) -> List[str]:
"""
Splits the original lines list according to the current console width and group indentations.
:param original_lines: The original lines list to split.
:return: A list of the new width-formatted lines.
"""
... | python | def _split_lines(self, original_lines: List[str]) -> List[str]:
"""
Splits the original lines list according to the current console width and group indentations.
:param original_lines: The original lines list to split.
:return: A list of the new width-formatted lines.
"""
... | [
"def",
"_split_lines",
"(",
"self",
",",
"original_lines",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"console_width",
"=",
"get_console_width",
"(",
")",
"# We take indent into account only in the inner group lines.",
"max_line_length",
... | Splits the original lines list according to the current console width and group indentations.
:param original_lines: The original lines list to split.
:return: A list of the new width-formatted lines. | [
"Splits",
"the",
"original",
"lines",
"list",
"according",
"to",
"the",
"current",
"console",
"width",
"and",
"group",
"indentations",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L122-L179 |
ofir123/py-printer | pyprinter/printer.py | Printer.write | def write(self, text: str):
"""
Prints text to the screen.
Supports colors by using the color constants.
To use colors, add the color before the text you want to print.
:param text: The text to print.
"""
# Default color is NORMAL.
last_color = (self._DAR... | python | def write(self, text: str):
"""
Prints text to the screen.
Supports colors by using the color constants.
To use colors, add the color before the text you want to print.
:param text: The text to print.
"""
# Default color is NORMAL.
last_color = (self._DAR... | [
"def",
"write",
"(",
"self",
",",
"text",
":",
"str",
")",
":",
"# Default color is NORMAL.",
"last_color",
"=",
"(",
"self",
".",
"_DARK_CODE",
",",
"0",
")",
"# We use splitlines with keepends in order to keep the line breaks.",
"# Then we split by using the console width... | Prints text to the screen.
Supports colors by using the color constants.
To use colors, add the color before the text you want to print.
:param text: The text to print. | [
"Prints",
"text",
"to",
"the",
"screen",
".",
"Supports",
"colors",
"by",
"using",
"the",
"color",
"constants",
".",
"To",
"use",
"colors",
"add",
"the",
"color",
"before",
"the",
"text",
"you",
"want",
"to",
"print",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L181-L233 |
ofir123/py-printer | pyprinter/printer.py | Printer.write_aligned | def write_aligned(self, key: str, value: str, not_important_keys: Optional[List[str]] = None,
is_list: bool = False, align_size: Optional[int] = None, key_color: str = PURPLE,
value_color: str = GREEN, dark_key_color: str = DARK_PURPLE, dark_value_color: str = DARK_GREEN,
... | python | def write_aligned(self, key: str, value: str, not_important_keys: Optional[List[str]] = None,
is_list: bool = False, align_size: Optional[int] = None, key_color: str = PURPLE,
value_color: str = GREEN, dark_key_color: str = DARK_PURPLE, dark_value_color: str = DARK_GREEN,
... | [
"def",
"write_aligned",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"str",
",",
"not_important_keys",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
"is_list",
":",
"bool",
"=",
"False",
",",
"align_size",
":",
"Opt... | Prints keys and values aligned to align_size.
:param key: The name of the property to print.
:param value: The value of the property to print.
:param not_important_keys: Properties that will be printed in a darker color.
:param is_list: True if the value is a list of items.
:par... | [
"Prints",
"keys",
"and",
"values",
"aligned",
"to",
"align_size",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L244-L281 |
ofir123/py-printer | pyprinter/printer.py | Printer.write_title | def write_title(self, title: str, title_color: str = YELLOW, hyphen_line_color: str = WHITE):
"""
Prints title with hyphen line underneath it.
:param title: The title to print.
:param title_color: The title text color (default is yellow).
:param hyphen_line_color: The hyphen lin... | python | def write_title(self, title: str, title_color: str = YELLOW, hyphen_line_color: str = WHITE):
"""
Prints title with hyphen line underneath it.
:param title: The title to print.
:param title_color: The title text color (default is yellow).
:param hyphen_line_color: The hyphen lin... | [
"def",
"write_title",
"(",
"self",
",",
"title",
":",
"str",
",",
"title_color",
":",
"str",
"=",
"YELLOW",
",",
"hyphen_line_color",
":",
"str",
"=",
"WHITE",
")",
":",
"self",
".",
"write_line",
"(",
"title_color",
"+",
"title",
")",
"self",
".",
"wr... | Prints title with hyphen line underneath it.
:param title: The title to print.
:param title_color: The title text color (default is yellow).
:param hyphen_line_color: The hyphen line color (default is white). | [
"Prints",
"title",
"with",
"hyphen",
"line",
"underneath",
"it",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L283-L292 |
DeastinY/informationminer | informationminer/POSTagger.py | generate_pos_tagger | def generate_pos_tagger(check_accuracy=False):
"""Accuracy is about 0.94 with 90% training data."""
global tagger
logging.debug("Reading TIGER corpus")
corp = nltk.corpus.ConllCorpusReader(DIR_PATH, TIGER_FILE_NAME,
['ignore', 'words', 'ignore', 'ignore', 'pos'],... | python | def generate_pos_tagger(check_accuracy=False):
"""Accuracy is about 0.94 with 90% training data."""
global tagger
logging.debug("Reading TIGER corpus")
corp = nltk.corpus.ConllCorpusReader(DIR_PATH, TIGER_FILE_NAME,
['ignore', 'words', 'ignore', 'ignore', 'pos'],... | [
"def",
"generate_pos_tagger",
"(",
"check_accuracy",
"=",
"False",
")",
":",
"global",
"tagger",
"logging",
".",
"debug",
"(",
"\"Reading TIGER corpus\"",
")",
"corp",
"=",
"nltk",
".",
"corpus",
".",
"ConllCorpusReader",
"(",
"DIR_PATH",
",",
"TIGER_FILE_NAME",
... | Accuracy is about 0.94 with 90% training data. | [
"Accuracy",
"is",
"about",
"0",
".",
"94",
"with",
"90%",
"training",
"data",
"."
] | train | https://github.com/DeastinY/informationminer/blob/c9c778cf403bc2398f8481070ba6896032a64ca2/informationminer/POSTagger.py#L16-L41 |
klahnakoski/pyLibrary | pyLibrary/sql/util.py | find_holes | def find_holes(db_module, db, table_name, column_name, _range, filter=None):
"""
FIND HOLES IN A DENSE COLUMN OF INTEGERS
RETURNS A LIST OF {"min"min, "max":max} OBJECTS
"""
if not filter:
filter = {"match_all": {}}
_range = wrap(_range)
params = {
"min": _range.min,
... | python | def find_holes(db_module, db, table_name, column_name, _range, filter=None):
"""
FIND HOLES IN A DENSE COLUMN OF INTEGERS
RETURNS A LIST OF {"min"min, "max":max} OBJECTS
"""
if not filter:
filter = {"match_all": {}}
_range = wrap(_range)
params = {
"min": _range.min,
... | [
"def",
"find_holes",
"(",
"db_module",
",",
"db",
",",
"table_name",
",",
"column_name",
",",
"_range",
",",
"filter",
"=",
"None",
")",
":",
"if",
"not",
"filter",
":",
"filter",
"=",
"{",
"\"match_all\"",
":",
"{",
"}",
"}",
"_range",
"=",
"wrap",
... | FIND HOLES IN A DENSE COLUMN OF INTEGERS
RETURNS A LIST OF {"min"min, "max":max} OBJECTS | [
"FIND",
"HOLES",
"IN",
"A",
"DENSE",
"COLUMN",
"OF",
"INTEGERS",
"RETURNS",
"A",
"LIST",
"OF",
"{",
"min",
"min",
"max",
":",
"max",
"}",
"OBJECTS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/sql/util.py#L19-L78 |
klahnakoski/pyLibrary | pyLibrary/sql/util.py | values2rows | def values2rows(values, column_names):
"""
CONVERT LIST OF JSON-IZABLE DATA STRUCTURE TO DATABASE ROW
value - THE STRUCTURE TO CONVERT INTO row
column_names - FOR ORDERING THE ALLOWED COLUMNS (EXTRA ATTRIBUTES ARE
LOST) THE COLUMN NAMES ARE EXPECTED TO HAVE dots (.)
... | python | def values2rows(values, column_names):
"""
CONVERT LIST OF JSON-IZABLE DATA STRUCTURE TO DATABASE ROW
value - THE STRUCTURE TO CONVERT INTO row
column_names - FOR ORDERING THE ALLOWED COLUMNS (EXTRA ATTRIBUTES ARE
LOST) THE COLUMN NAMES ARE EXPECTED TO HAVE dots (.)
... | [
"def",
"values2rows",
"(",
"values",
",",
"column_names",
")",
":",
"values",
"=",
"wrap",
"(",
"values",
")",
"lookup",
"=",
"{",
"name",
":",
"i",
"for",
"i",
",",
"name",
"in",
"enumerate",
"(",
"column_names",
")",
"}",
"output",
"=",
"[",
"]",
... | CONVERT LIST OF JSON-IZABLE DATA STRUCTURE TO DATABASE ROW
value - THE STRUCTURE TO CONVERT INTO row
column_names - FOR ORDERING THE ALLOWED COLUMNS (EXTRA ATTRIBUTES ARE
LOST) THE COLUMN NAMES ARE EXPECTED TO HAVE dots (.)
FOR DEEPER PROPERTIES | [
"CONVERT",
"LIST",
"OF",
"JSON",
"-",
"IZABLE",
"DATA",
"STRUCTURE",
"TO",
"DATABASE",
"ROW",
"value",
"-",
"THE",
"STRUCTURE",
"TO",
"CONVERT",
"INTO",
"row",
"column_names",
"-",
"FOR",
"ORDERING",
"THE",
"ALLOWED",
"COLUMNS",
"(",
"EXTRA",
"ATTRIBUTES",
"... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/sql/util.py#L81-L99 |
cathalgarvey/deadlock | deadlock/core.py | make_lock_securely | def make_lock_securely(email = None, warn_only = False):
"Terminal oriented; produces a prompt for user input of email and password. Returns crypto.UserLock."
email = email or input("Please provide email address: ")
while True:
passphrase = getpass.getpass("Please type a secure passphrase (with spac... | python | def make_lock_securely(email = None, warn_only = False):
"Terminal oriented; produces a prompt for user input of email and password. Returns crypto.UserLock."
email = email or input("Please provide email address: ")
while True:
passphrase = getpass.getpass("Please type a secure passphrase (with spac... | [
"def",
"make_lock_securely",
"(",
"email",
"=",
"None",
",",
"warn_only",
"=",
"False",
")",
":",
"email",
"=",
"email",
"or",
"input",
"(",
"\"Please provide email address: \"",
")",
"while",
"True",
":",
"passphrase",
"=",
"getpass",
".",
"getpass",
"(",
"... | Terminal oriented; produces a prompt for user input of email and password. Returns crypto.UserLock. | [
"Terminal",
"oriented",
";",
"produces",
"a",
"prompt",
"for",
"user",
"input",
"of",
"email",
"and",
"password",
".",
"Returns",
"crypto",
".",
"UserLock",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L48-L59 |
cathalgarvey/deadlock | deadlock/core.py | encrypt_file | def encrypt_file(file_path, sender, recipients):
"Returns encrypted binary file content if successful"
for recipient_key in recipients:
crypto.assert_type_and_length('recipient_key', recipient_key, (str, crypto.UserLock))
crypto.assert_type_and_length("sender_key", sender, crypto.UserLock)
if (n... | python | def encrypt_file(file_path, sender, recipients):
"Returns encrypted binary file content if successful"
for recipient_key in recipients:
crypto.assert_type_and_length('recipient_key', recipient_key, (str, crypto.UserLock))
crypto.assert_type_and_length("sender_key", sender, crypto.UserLock)
if (n... | [
"def",
"encrypt_file",
"(",
"file_path",
",",
"sender",
",",
"recipients",
")",
":",
"for",
"recipient_key",
"in",
"recipients",
":",
"crypto",
".",
"assert_type_and_length",
"(",
"'recipient_key'",
",",
"recipient_key",
",",
"(",
"str",
",",
"crypto",
".",
"U... | Returns encrypted binary file content if successful | [
"Returns",
"encrypted",
"binary",
"file",
"content",
"if",
"successful"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L61-L71 |
cathalgarvey/deadlock | deadlock/core.py | decrypt_file | def decrypt_file(file_path, recipient_key, *, base64=False):
"Returns (filename, file_contents) if successful"
crypto.assert_type_and_length('recipient_key', recipient_key, crypto.UserLock)
with open(file_path, "rb") as I:
contents = I.read()
if base64:
contents = crypto.b64decod... | python | def decrypt_file(file_path, recipient_key, *, base64=False):
"Returns (filename, file_contents) if successful"
crypto.assert_type_and_length('recipient_key', recipient_key, crypto.UserLock)
with open(file_path, "rb") as I:
contents = I.read()
if base64:
contents = crypto.b64decod... | [
"def",
"decrypt_file",
"(",
"file_path",
",",
"recipient_key",
",",
"*",
",",
"base64",
"=",
"False",
")",
":",
"crypto",
".",
"assert_type_and_length",
"(",
"'recipient_key'",
",",
"recipient_key",
",",
"crypto",
".",
"UserLock",
")",
"with",
"open",
"(",
"... | Returns (filename, file_contents) if successful | [
"Returns",
"(",
"filename",
"file_contents",
")",
"if",
"successful"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L73-L81 |
cathalgarvey/deadlock | deadlock/core.py | encrypt_folder | def encrypt_folder(path, sender, recipients):
"""
This helper function should zip the contents of a folder and encrypt it as
a zip-file. Recipients are responsible for opening the zip-file.
"""
for recipient_key in recipients:
crypto.assert_type_and_length('recipient_key', recipient_key, (st... | python | def encrypt_folder(path, sender, recipients):
"""
This helper function should zip the contents of a folder and encrypt it as
a zip-file. Recipients are responsible for opening the zip-file.
"""
for recipient_key in recipients:
crypto.assert_type_and_length('recipient_key', recipient_key, (st... | [
"def",
"encrypt_folder",
"(",
"path",
",",
"sender",
",",
"recipients",
")",
":",
"for",
"recipient_key",
"in",
"recipients",
":",
"crypto",
".",
"assert_type_and_length",
"(",
"'recipient_key'",
",",
"recipient_key",
",",
"(",
"str",
",",
"crypto",
".",
"User... | This helper function should zip the contents of a folder and encrypt it as
a zip-file. Recipients are responsible for opening the zip-file. | [
"This",
"helper",
"function",
"should",
"zip",
"the",
"contents",
"of",
"a",
"folder",
"and",
"encrypt",
"it",
"as",
"a",
"zip",
"-",
"file",
".",
"Recipients",
"are",
"responsible",
"for",
"opening",
"the",
"zip",
"-",
"file",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L83-L104 |
cathalgarvey/deadlock | deadlock/core.py | get_profile | def get_profile(A):
"Fail-soft profile getter; if no profile is present assume none and quietly ignore."
try:
with open(os.path.expanduser(A.profile)) as I:
profile = json.load(I)
return profile
except:
return {} | python | def get_profile(A):
"Fail-soft profile getter; if no profile is present assume none and quietly ignore."
try:
with open(os.path.expanduser(A.profile)) as I:
profile = json.load(I)
return profile
except:
return {} | [
"def",
"get_profile",
"(",
"A",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"A",
".",
"profile",
")",
")",
"as",
"I",
":",
"profile",
"=",
"json",
".",
"load",
"(",
"I",
")",
"return",
"profile",
"except"... | Fail-soft profile getter; if no profile is present assume none and quietly ignore. | [
"Fail",
"-",
"soft",
"profile",
"getter",
";",
"if",
"no",
"profile",
"is",
"present",
"assume",
"none",
"and",
"quietly",
"ignore",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L123-L130 |
cathalgarvey/deadlock | deadlock/core.py | main_encrypt | def main_encrypt(A):
"Encrypt to recipient list using primary key OR prompted key. Recipients may be IDs or petnames."
profile = get_profile(A)
localKeys = profile.get('local keys', [])
if not localKeys:
localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
else:
localKeys =... | python | def main_encrypt(A):
"Encrypt to recipient list using primary key OR prompted key. Recipients may be IDs or petnames."
profile = get_profile(A)
localKeys = profile.get('local keys', [])
if not localKeys:
localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
else:
localKeys =... | [
"def",
"main_encrypt",
"(",
"A",
")",
":",
"profile",
"=",
"get_profile",
"(",
"A",
")",
"localKeys",
"=",
"profile",
".",
"get",
"(",
"'local keys'",
",",
"[",
"]",
")",
"if",
"not",
"localKeys",
":",
"localKeys",
"=",
"[",
"make_lock_securely",
"(",
... | Encrypt to recipient list using primary key OR prompted key. Recipients may be IDs or petnames. | [
"Encrypt",
"to",
"recipient",
"list",
"using",
"primary",
"key",
"OR",
"prompted",
"key",
".",
"Recipients",
"may",
"be",
"IDs",
"or",
"petnames",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L136-L166 |
cathalgarvey/deadlock | deadlock/core.py | main_decrypt | def main_decrypt(A):
"Get all local keys OR prompt user for key, then attempt to decrypt with each."
profile = get_profile(A)
localKeys = profile.get('local keys', [])
if not localKeys:
localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
else:
localKeys = [crypto.UserLock.... | python | def main_decrypt(A):
"Get all local keys OR prompt user for key, then attempt to decrypt with each."
profile = get_profile(A)
localKeys = profile.get('local keys', [])
if not localKeys:
localKeys = [make_lock_securely(warn_only = A.ignore_entropy)]
else:
localKeys = [crypto.UserLock.... | [
"def",
"main_decrypt",
"(",
"A",
")",
":",
"profile",
"=",
"get_profile",
"(",
"A",
")",
"localKeys",
"=",
"profile",
".",
"get",
"(",
"'local keys'",
",",
"[",
"]",
")",
"if",
"not",
"localKeys",
":",
"localKeys",
"=",
"[",
"make_lock_securely",
"(",
... | Get all local keys OR prompt user for key, then attempt to decrypt with each. | [
"Get",
"all",
"local",
"keys",
"OR",
"prompt",
"user",
"for",
"key",
"then",
"attempt",
"to",
"decrypt",
"with",
"each",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/core.py#L168-L193 |
openfisca/openfisca-france-indirect-taxation | openfisca_france_indirect_taxation/build_survey_data/step_4_homogeneisation_revenus_menages.py | build_homogeneisation_revenus_menages | def build_homogeneisation_revenus_menages(temporary_store = None, year = None):
assert temporary_store is not None
"""Build menage consumption by categorie fiscale dataframe """
assert year is not None
# Load data
bdf_survey_collection = SurveyCollection.load(
collection = 'budget_des_famil... | python | def build_homogeneisation_revenus_menages(temporary_store = None, year = None):
assert temporary_store is not None
"""Build menage consumption by categorie fiscale dataframe """
assert year is not None
# Load data
bdf_survey_collection = SurveyCollection.load(
collection = 'budget_des_famil... | [
"def",
"build_homogeneisation_revenus_menages",
"(",
"temporary_store",
"=",
"None",
",",
"year",
"=",
"None",
")",
":",
"assert",
"temporary_store",
"is",
"not",
"None",
"assert",
"year",
"is",
"not",
"None",
"# Load data",
"bdf_survey_collection",
"=",
"SurveyColl... | Build menage consumption by categorie fiscale dataframe | [
"Build",
"menage",
"consumption",
"by",
"categorie",
"fiscale",
"dataframe"
] | train | https://github.com/openfisca/openfisca-france-indirect-taxation/blob/b4bc7da90a1126ebfc3af2c3ec61de5a2b70bb2e/openfisca_france_indirect_taxation/build_survey_data/step_4_homogeneisation_revenus_menages.py#L46-L387 |
inveniosoftware/invenio-collections | invenio_collections/views.py | collection | def collection(name=None):
"""Render the collection page.
It renders it either with a collection specific template (aka
collection_{collection_name}.html) or with the default collection
template (collection.html).
"""
if name is None:
collection = Collection.query.get_or_404(1)
else... | python | def collection(name=None):
"""Render the collection page.
It renders it either with a collection specific template (aka
collection_{collection_name}.html) or with the default collection
template (collection.html).
"""
if name is None:
collection = Collection.query.get_or_404(1)
else... | [
"def",
"collection",
"(",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"collection",
"=",
"Collection",
".",
"query",
".",
"get_or_404",
"(",
"1",
")",
"else",
":",
"collection",
"=",
"Collection",
".",
"query",
".",
"filter",
"(",
... | Render the collection page.
It renders it either with a collection specific template (aka
collection_{collection_name}.html) or with the default collection
template (collection.html). | [
"Render",
"the",
"collection",
"page",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/views.py#L44-L63 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.url | def url(self):
""":class:`str`: The URL to the highscores page on Tibia.com containing the results."""
return self.get_url(self.world, self.category, self.vocation, self.page) | python | def url(self):
""":class:`str`: The URL to the highscores page on Tibia.com containing the results."""
return self.get_url(self.world, self.category, self.vocation, self.page) | [
"def",
"url",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_url",
"(",
"self",
".",
"world",
",",
"self",
".",
"category",
",",
"self",
".",
"vocation",
",",
"self",
".",
"page",
")"
] | :class:`str`: The URL to the highscores page on Tibia.com containing the results. | [
":",
"class",
":",
"str",
":",
"The",
"URL",
"to",
"the",
"highscores",
"page",
"on",
"Tibia",
".",
"com",
"containing",
"the",
"results",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L65-L67 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.url_tibiadata | def url_tibiadata(self):
""":class:`str`: The URL to the highscores page on TibiaData.com containing the results."""
return self.get_url_tibiadata(self.world, self.category, self.vocation) | python | def url_tibiadata(self):
""":class:`str`: The URL to the highscores page on TibiaData.com containing the results."""
return self.get_url_tibiadata(self.world, self.category, self.vocation) | [
"def",
"url_tibiadata",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_url_tibiadata",
"(",
"self",
".",
"world",
",",
"self",
".",
"category",
",",
"self",
".",
"vocation",
")"
] | :class:`str`: The URL to the highscores page on TibiaData.com containing the results. | [
":",
"class",
":",
"str",
":",
"The",
"URL",
"to",
"the",
"highscores",
"page",
"on",
"TibiaData",
".",
"com",
"containing",
"the",
"results",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L70-L72 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.from_content | def from_content(cls, content):
"""Creates an instance of the class from the html content of a highscores page.
Notes
-----
Tibia.com only shows up to 25 entries per page, so in order to obtain the full highscores, all 12 pages must
be parsed and merged into one.
Parame... | python | def from_content(cls, content):
"""Creates an instance of the class from the html content of a highscores page.
Notes
-----
Tibia.com only shows up to 25 entries per page, so in order to obtain the full highscores, all 12 pages must
be parsed and merged into one.
Parame... | [
"def",
"from_content",
"(",
"cls",
",",
"content",
")",
":",
"parsed_content",
"=",
"parse_tibiacom_content",
"(",
"content",
")",
"tables",
"=",
"cls",
".",
"_parse_tables",
"(",
"parsed_content",
")",
"filters",
"=",
"tables",
".",
"get",
"(",
"\"Highscores ... | Creates an instance of the class from the html content of a highscores page.
Notes
-----
Tibia.com only shows up to 25 entries per page, so in order to obtain the full highscores, all 12 pages must
be parsed and merged into one.
Parameters
----------
content: :c... | [
"Creates",
"an",
"instance",
"of",
"the",
"class",
"from",
"the",
"html",
"content",
"of",
"a",
"highscores",
"page",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L75-L119 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.from_tibiadata | def from_tibiadata(cls, content, vocation=None):
"""Builds a highscores object from a TibiaData highscores response.
Notes
-----
Since TibiaData.com's response doesn't contain any indication of the vocation filter applied,
:py:attr:`vocation` can't be determined from the respons... | python | def from_tibiadata(cls, content, vocation=None):
"""Builds a highscores object from a TibiaData highscores response.
Notes
-----
Since TibiaData.com's response doesn't contain any indication of the vocation filter applied,
:py:attr:`vocation` can't be determined from the respons... | [
"def",
"from_tibiadata",
"(",
"cls",
",",
"content",
",",
"vocation",
"=",
"None",
")",
":",
"json_content",
"=",
"parse_json",
"(",
"content",
")",
"try",
":",
"highscores_json",
"=",
"json_content",
"[",
"\"highscores\"",
"]",
"if",
"\"error\"",
"in",
"hig... | Builds a highscores object from a TibiaData highscores response.
Notes
-----
Since TibiaData.com's response doesn't contain any indication of the vocation filter applied,
:py:attr:`vocation` can't be determined from the response, so the attribute must be assigned manually.
If t... | [
"Builds",
"a",
"highscores",
"object",
"from",
"a",
"TibiaData",
"highscores",
"response",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L122-L174 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.get_url | def get_url(cls, world, category=Category.EXPERIENCE, vocation=VocationFilter.ALL, page=1):
"""Gets the Tibia.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :class:`Cat... | python | def get_url(cls, world, category=Category.EXPERIENCE, vocation=VocationFilter.ALL, page=1):
"""Gets the Tibia.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :class:`Cat... | [
"def",
"get_url",
"(",
"cls",
",",
"world",
",",
"category",
"=",
"Category",
".",
"EXPERIENCE",
",",
"vocation",
"=",
"VocationFilter",
".",
"ALL",
",",
"page",
"=",
"1",
")",
":",
"return",
"HIGHSCORES_URL",
"%",
"(",
"world",
",",
"category",
".",
"... | Gets the Tibia.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :class:`Category`
The desired highscores category.
vocation: :class:`VocationFiler`
... | [
"Gets",
"the",
"Tibia",
".",
"com",
"URL",
"of",
"the",
"highscores",
"for",
"the",
"given",
"parameters",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L177-L195 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores.get_url_tibiadata | def get_url_tibiadata(cls, world, category=Category.EXPERIENCE, vocation=VocationFilter.ALL):
"""Gets the TibiaData.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :clas... | python | def get_url_tibiadata(cls, world, category=Category.EXPERIENCE, vocation=VocationFilter.ALL):
"""Gets the TibiaData.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :clas... | [
"def",
"get_url_tibiadata",
"(",
"cls",
",",
"world",
",",
"category",
"=",
"Category",
".",
"EXPERIENCE",
",",
"vocation",
"=",
"VocationFilter",
".",
"ALL",
")",
":",
"return",
"HIGHSCORES_URL_TIBIADATA",
"%",
"(",
"world",
",",
"category",
".",
"value",
"... | Gets the TibiaData.com URL of the highscores for the given parameters.
Parameters
----------
world: :class:`str`
The game world of the desired highscores.
category: :class:`Category`
The desired highscores category.
vocation: :class:`VocationFiler`
... | [
"Gets",
"the",
"TibiaData",
".",
"com",
"URL",
"of",
"the",
"highscores",
"for",
"the",
"given",
"parameters",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L198-L214 |
Galarzaa90/tibia.py | tibiapy/highscores.py | Highscores._parse_entry | def _parse_entry(self, cols):
"""Parses an entry's row and adds the result to py:attr:`entries`.
Parameters
----------
cols: :class:`bs4.ResultSet`
The list of columns for that entry.
"""
rank, name, vocation, *values = [c.text.replace('\xa0', ' ').strip() fo... | python | def _parse_entry(self, cols):
"""Parses an entry's row and adds the result to py:attr:`entries`.
Parameters
----------
cols: :class:`bs4.ResultSet`
The list of columns for that entry.
"""
rank, name, vocation, *values = [c.text.replace('\xa0', ' ').strip() fo... | [
"def",
"_parse_entry",
"(",
"self",
",",
"cols",
")",
":",
"rank",
",",
"name",
",",
"vocation",
",",
"",
"*",
"values",
"=",
"[",
"c",
".",
"text",
".",
"replace",
"(",
"'\\xa0'",
",",
"' '",
")",
".",
"strip",
"(",
")",
"for",
"c",
"in",
"col... | Parses an entry's row and adds the result to py:attr:`entries`.
Parameters
----------
cols: :class:`bs4.ResultSet`
The list of columns for that entry. | [
"Parses",
"an",
"entry",
"s",
"row",
"and",
"adds",
"the",
"result",
"to",
"py",
":",
"attr",
":",
"entries",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/highscores.py#L241-L262 |
cburgmer/upsidedown | upsidedown.py | transform | def transform(string, transliterations=None):
"""
Transform the string to "upside-down" writing.
Example:
>>> import upsidedown
>>> print(upsidedown.transform('Hello World!'))
¡pꞁɹoM oꞁꞁǝH
For languages with diacritics you might want to supply a transliteration to
work aro... | python | def transform(string, transliterations=None):
"""
Transform the string to "upside-down" writing.
Example:
>>> import upsidedown
>>> print(upsidedown.transform('Hello World!'))
¡pꞁɹoM oꞁꞁǝH
For languages with diacritics you might want to supply a transliteration to
work aro... | [
"def",
"transform",
"(",
"string",
",",
"transliterations",
"=",
"None",
")",
":",
"transliterations",
"=",
"transliterations",
"or",
"TRANSLITERATIONS",
"for",
"character",
"in",
"transliterations",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"character",
... | Transform the string to "upside-down" writing.
Example:
>>> import upsidedown
>>> print(upsidedown.transform('Hello World!'))
¡pꞁɹoM oꞁꞁǝH
For languages with diacritics you might want to supply a transliteration to
work around missing (rendering of) upside-down forms:
>>> ... | [
"Transform",
"the",
"string",
"to",
"upside",
"-",
"down",
"writing",
"."
] | train | https://github.com/cburgmer/upsidedown/blob/0bc80421d197cbda0f824a44ceed5c4fcb5cf8ba/upsidedown.py#L84-L124 |
cburgmer/upsidedown | upsidedown.py | main | def main():
"""Main method for running upsidedown.py from the command line."""
import sys
output = []
line = sys.stdin.readline()
while line:
line = line.strip("\n")
output.append(transform(line))
line = sys.stdin.readline()
output.reverse()
print("\n".join(output)... | python | def main():
"""Main method for running upsidedown.py from the command line."""
import sys
output = []
line = sys.stdin.readline()
while line:
line = line.strip("\n")
output.append(transform(line))
line = sys.stdin.readline()
output.reverse()
print("\n".join(output)... | [
"def",
"main",
"(",
")",
":",
"import",
"sys",
"output",
"=",
"[",
"]",
"line",
"=",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
"while",
"line",
":",
"line",
"=",
"line",
".",
"strip",
"(",
"\"\\n\"",
")",
"output",
".",
"append",
"(",
"tran... | Main method for running upsidedown.py from the command line. | [
"Main",
"method",
"for",
"running",
"upsidedown",
".",
"py",
"from",
"the",
"command",
"line",
"."
] | train | https://github.com/cburgmer/upsidedown/blob/0bc80421d197cbda0f824a44ceed5c4fcb5cf8ba/upsidedown.py#L126-L139 |
klahnakoski/pyLibrary | pyLibrary/aws/__init__.py | capture_termination_signal | def capture_termination_signal(please_stop):
"""
WILL SIGNAL please_stop WHEN THIS AWS INSTANCE IS DUE FOR SHUTDOWN
"""
def worker(please_stop):
seen_problem = False
while not please_stop:
request_time = (time.time() - timer.START)/60 # MINUTES
try:
... | python | def capture_termination_signal(please_stop):
"""
WILL SIGNAL please_stop WHEN THIS AWS INSTANCE IS DUE FOR SHUTDOWN
"""
def worker(please_stop):
seen_problem = False
while not please_stop:
request_time = (time.time() - timer.START)/60 # MINUTES
try:
... | [
"def",
"capture_termination_signal",
"(",
"please_stop",
")",
":",
"def",
"worker",
"(",
"please_stop",
")",
":",
"seen_problem",
"=",
"False",
"while",
"not",
"please_stop",
":",
"request_time",
"=",
"(",
"time",
".",
"time",
"(",
")",
"-",
"timer",
".",
... | WILL SIGNAL please_stop WHEN THIS AWS INSTANCE IS DUE FOR SHUTDOWN | [
"WILL",
"SIGNAL",
"please_stop",
"WHEN",
"THIS",
"AWS",
"INSTANCE",
"IS",
"DUE",
"FOR",
"SHUTDOWN"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/__init__.py#L135-L162 |
klahnakoski/pyLibrary | pyLibrary/aws/__init__.py | Queue.pop_message | def pop_message(self, wait=SECOND, till=None):
"""
RETURN TUPLE (message, payload) CALLER IS RESPONSIBLE FOR CALLING message.delete() WHEN DONE
"""
if till is not None and not isinstance(till, Signal):
Log.error("Expecting a signal")
message = self.queue.read(wait_ti... | python | def pop_message(self, wait=SECOND, till=None):
"""
RETURN TUPLE (message, payload) CALLER IS RESPONSIBLE FOR CALLING message.delete() WHEN DONE
"""
if till is not None and not isinstance(till, Signal):
Log.error("Expecting a signal")
message = self.queue.read(wait_ti... | [
"def",
"pop_message",
"(",
"self",
",",
"wait",
"=",
"SECOND",
",",
"till",
"=",
"None",
")",
":",
"if",
"till",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"till",
",",
"Signal",
")",
":",
"Log",
".",
"error",
"(",
"\"Expecting a signal\"",
... | RETURN TUPLE (message, payload) CALLER IS RESPONSIBLE FOR CALLING message.delete() WHEN DONE | [
"RETURN",
"TUPLE",
"(",
"message",
"payload",
")",
"CALLER",
"IS",
"RESPONSIBLE",
"FOR",
"CALLING",
"message",
".",
"delete",
"()",
"WHEN",
"DONE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/aws/__init__.py#L95-L108 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.never | def never(self):
"""
Inspected function should never be called
Return: self
"""
def check(): #pylint: disable=missing-docstring
return not super(SinonExpectation, self).called
self.valid_list.append(check)
return self | python | def never(self):
"""
Inspected function should never be called
Return: self
"""
def check(): #pylint: disable=missing-docstring
return not super(SinonExpectation, self).called
self.valid_list.append(check)
return self | [
"def",
"never",
"(",
"self",
")",
":",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"not",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"called",
"self",
".",
"valid_list",
".",
"append",
"(",
"check",
")",
"re... | Inspected function should never be called
Return: self | [
"Inspected",
"function",
"should",
"never",
"be",
"called",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L51-L59 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.once | def once(self):
"""
Inspected function should be called one time
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledOnce
self.valid_list.append(check)
return self | python | def once(self):
"""
Inspected function should be called one time
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledOnce
self.valid_list.append(check)
return self | [
"def",
"once",
"(",
"self",
")",
":",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"calledOnce",
"self",
".",
"valid_list",
".",
"append",
"(",
"check",
")",
"return",... | Inspected function should be called one time
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"one",
"time",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L61-L69 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.twice | def twice(self):
"""
Inspected function should be called two times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledTwice
self.valid_list.append(check)
return self | python | def twice(self):
"""
Inspected function should be called two times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledTwice
self.valid_list.append(check)
return self | [
"def",
"twice",
"(",
"self",
")",
":",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"calledTwice",
"self",
".",
"valid_list",
".",
"append",
"(",
"check",
")",
"return... | Inspected function should be called two times
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"two",
"times",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L71-L79 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.thrice | def thrice(self):
"""
Inspected function should be called three times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledThrice
self.valid_list.append(check)
return self | python | def thrice(self):
"""
Inspected function should be called three times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledThrice
self.valid_list.append(check)
return self | [
"def",
"thrice",
"(",
"self",
")",
":",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"calledThrice",
"self",
".",
"valid_list",
".",
"append",
"(",
"check",
")",
"retu... | Inspected function should be called three times
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"three",
"times",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L81-L90 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.exactly | def exactly(self, number):
"""
Inspected function should be called exactly number times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return True if number == super(SinonExpectation, self).callCount else False
self.valid_list.append(check)
... | python | def exactly(self, number):
"""
Inspected function should be called exactly number times
Return: self
"""
def check(): #pylint: disable=missing-docstring
return True if number == super(SinonExpectation, self).callCount else False
self.valid_list.append(check)
... | [
"def",
"exactly",
"(",
"self",
",",
"number",
")",
":",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"True",
"if",
"number",
"==",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"callCount",
"else",
"False",
"self"... | Inspected function should be called exactly number times
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"exactly",
"number",
"times",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L92-L100 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.withArgs | def withArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Inspected function should be called with some of specified arguments
Args: any
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledWi... | python | def withArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Inspected function should be called with some of specified arguments
Args: any
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).calledWi... | [
"def",
"withArgs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"calle... | Inspected function should be called with some of specified arguments
Args: any
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"with",
"some",
"of",
"specified",
"arguments",
"Args",
":",
"any",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L102-L111 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.withExactArgs | def withExactArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Inspected function should be called with full of specified arguments
Args: any
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).cal... | python | def withExactArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Inspected function should be called with full of specified arguments
Args: any
Return: self
"""
def check(): #pylint: disable=missing-docstring
return super(SinonExpectation, self).cal... | [
"def",
"withExactArgs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"def",
"check",
"(",
")",
":",
"#pylint: disable=missing-docstring",
"return",
"super",
"(",
"SinonExpectation",
",",
"self",
")",
".",
"... | Inspected function should be called with full of specified arguments
Args: any
Return: self | [
"Inspected",
"function",
"should",
"be",
"called",
"with",
"full",
"of",
"specified",
"arguments",
"Args",
":",
"any",
"Return",
":",
"self"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L113-L122 |
note35/sinon | sinon/lib/mock.py | SinonExpectation.verify | def verify(self):
"""
Running all conditions in the instance variable valid_list
Return:
True: pass all conditions
False: fail at more than one condition
"""
if self not in self._queue:
return False
valid = True
for check in sel... | python | def verify(self):
"""
Running all conditions in the instance variable valid_list
Return:
True: pass all conditions
False: fail at more than one condition
"""
if self not in self._queue:
return False
valid = True
for check in sel... | [
"def",
"verify",
"(",
"self",
")",
":",
"if",
"self",
"not",
"in",
"self",
".",
"_queue",
":",
"return",
"False",
"valid",
"=",
"True",
"for",
"check",
"in",
"self",
".",
"valid_list",
":",
"valid",
"=",
"valid",
"&",
"check",
"(",
")",
"return",
"... | Running all conditions in the instance variable valid_list
Return:
True: pass all conditions
False: fail at more than one condition | [
"Running",
"all",
"conditions",
"in",
"the",
"instance",
"variable",
"valid_list",
"Return",
":",
"True",
":",
"pass",
"all",
"conditions",
"False",
":",
"fail",
"at",
"more",
"than",
"one",
"condition"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L124-L136 |
note35/sinon | sinon/lib/mock.py | SinonMock.expects | def expects(self, prop):
"""
Adding new property of object as inspector into exp_list
Args: string (property of object)
Return: SinonExpectation
"""
expectation = SinonExpectation(self.obj, prop)
self.exp_list.append(expectation)
return expectation | python | def expects(self, prop):
"""
Adding new property of object as inspector into exp_list
Args: string (property of object)
Return: SinonExpectation
"""
expectation = SinonExpectation(self.obj, prop)
self.exp_list.append(expectation)
return expectation | [
"def",
"expects",
"(",
"self",
",",
"prop",
")",
":",
"expectation",
"=",
"SinonExpectation",
"(",
"self",
".",
"obj",
",",
"prop",
")",
"self",
".",
"exp_list",
".",
"append",
"(",
"expectation",
")",
"return",
"expectation"
] | Adding new property of object as inspector into exp_list
Args: string (property of object)
Return: SinonExpectation | [
"Adding",
"new",
"property",
"of",
"object",
"as",
"inspector",
"into",
"exp_list",
"Args",
":",
"string",
"(",
"property",
"of",
"object",
")",
"Return",
":",
"SinonExpectation"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L171-L179 |
note35/sinon | sinon/lib/mock.py | SinonMock.verify | def verify(self):
"""
Verifying all inspectors in exp_list
Return:
True: pass all inspectors
False: fail at more than one inspector
"""
for expectation in self.exp_list:
if hasattr(expectation, "verify") and not expectation.verify():
... | python | def verify(self):
"""
Verifying all inspectors in exp_list
Return:
True: pass all inspectors
False: fail at more than one inspector
"""
for expectation in self.exp_list:
if hasattr(expectation, "verify") and not expectation.verify():
... | [
"def",
"verify",
"(",
"self",
")",
":",
"for",
"expectation",
"in",
"self",
".",
"exp_list",
":",
"if",
"hasattr",
"(",
"expectation",
",",
"\"verify\"",
")",
"and",
"not",
"expectation",
".",
"verify",
"(",
")",
":",
"return",
"False",
"return",
"True"
... | Verifying all inspectors in exp_list
Return:
True: pass all inspectors
False: fail at more than one inspector | [
"Verifying",
"all",
"inspectors",
"in",
"exp_list",
"Return",
":",
"True",
":",
"pass",
"all",
"inspectors",
"False",
":",
"fail",
"at",
"more",
"than",
"one",
"inspector"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L181-L191 |
note35/sinon | sinon/lib/mock.py | SinonMock.restore | def restore(self):
"""
Destroy all inspectors in exp_list and SinonMock itself
"""
for expectation in self.exp_list:
try:
expectation.restore()
except ReferenceError:
pass #ignore removed expectation
self._queue.remove(self) | python | def restore(self):
"""
Destroy all inspectors in exp_list and SinonMock itself
"""
for expectation in self.exp_list:
try:
expectation.restore()
except ReferenceError:
pass #ignore removed expectation
self._queue.remove(self) | [
"def",
"restore",
"(",
"self",
")",
":",
"for",
"expectation",
"in",
"self",
".",
"exp_list",
":",
"try",
":",
"expectation",
".",
"restore",
"(",
")",
"except",
"ReferenceError",
":",
"pass",
"#ignore removed expectation",
"self",
".",
"_queue",
".",
"remov... | Destroy all inspectors in exp_list and SinonMock itself | [
"Destroy",
"all",
"inspectors",
"in",
"exp_list",
"and",
"SinonMock",
"itself"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/mock.py#L193-L202 |
anomaly/vishnu | vishnu/util.py | google_app_engine_ndb_delete_expired_sessions | def google_app_engine_ndb_delete_expired_sessions(dormant_for=86400, limit=500):
"""
Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, de... | python | def google_app_engine_ndb_delete_expired_sessions(dormant_for=86400, limit=500):
"""
Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, de... | [
"def",
"google_app_engine_ndb_delete_expired_sessions",
"(",
"dormant_for",
"=",
"86400",
",",
"limit",
"=",
"500",
")",
":",
"from",
"vishnu",
".",
"backend",
".",
"client",
".",
"google_app_engine_ndb",
"import",
"VishnuSession",
"from",
"google",
".",
"appengine"... | Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, defaults to 24 hours.
:type dormant_for: int
:param limit: amount to delete in one call... | [
"Deletes",
"expired",
"sessions",
"A",
"session",
"is",
"expired",
"if",
"it",
"expires",
"date",
"is",
"set",
"and",
"has",
"passed",
"or",
"if",
"it",
"has",
"not",
"been",
"accessed",
"for",
"a",
"given",
"period",
"of",
"time",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/util.py#L3-L30 |
anomaly/vishnu | vishnu/util.py | google_cloud_datastore_delete_expired_sessions | def google_cloud_datastore_delete_expired_sessions(dormant_for=86400, limit=500):
"""
Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, d... | python | def google_cloud_datastore_delete_expired_sessions(dormant_for=86400, limit=500):
"""
Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, d... | [
"def",
"google_cloud_datastore_delete_expired_sessions",
"(",
"dormant_for",
"=",
"86400",
",",
"limit",
"=",
"500",
")",
":",
"from",
"vishnu",
".",
"backend",
".",
"client",
".",
"google_cloud_datastore",
"import",
"TABLE_NAME",
"from",
"google",
".",
"cloud",
"... | Deletes expired sessions
A session is expired if it expires date is set and has passed or
if it has not been accessed for a given period of time.
:param dormant_for: seconds since last access to delete sessions, defaults to 24 hours.
:type dormant_for: int
:param limit: amount to delete in one call... | [
"Deletes",
"expired",
"sessions",
"A",
"session",
"is",
"expired",
"if",
"it",
"expires",
"date",
"is",
"set",
"and",
"has",
"passed",
"or",
"if",
"it",
"has",
"not",
"been",
"accessed",
"for",
"a",
"given",
"period",
"of",
"time",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/util.py#L37-L74 |
klahnakoski/pyLibrary | jx_base/schema.py | Schema.values | def values(self, name):
"""
RETURN VALUES FOR THE GIVEN PATH NAME
:param name:
:return:
"""
return list(self.lookup_variables.get(unnest_path(name), Null)) | python | def values(self, name):
"""
RETURN VALUES FOR THE GIVEN PATH NAME
:param name:
:return:
"""
return list(self.lookup_variables.get(unnest_path(name), Null)) | [
"def",
"values",
"(",
"self",
",",
"name",
")",
":",
"return",
"list",
"(",
"self",
".",
"lookup_variables",
".",
"get",
"(",
"unnest_path",
"(",
"name",
")",
",",
"Null",
")",
")"
] | RETURN VALUES FOR THE GIVEN PATH NAME
:param name:
:return: | [
"RETURN",
"VALUES",
"FOR",
"THE",
"GIVEN",
"PATH",
"NAME",
":",
"param",
"name",
":",
":",
"return",
":"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/schema.py#L61-L67 |
klahnakoski/pyLibrary | jx_base/schema.py | Schema.leaves | def leaves(self, name):
"""
RETURN LEAVES OF GIVEN PATH NAME
pull leaves, considering query_path and namespace
pull all first-level properties
pull leaves, including parent leaves
pull the head of any tree by name
:param name:
:return:
"""
... | python | def leaves(self, name):
"""
RETURN LEAVES OF GIVEN PATH NAME
pull leaves, considering query_path and namespace
pull all first-level properties
pull leaves, including parent leaves
pull the head of any tree by name
:param name:
:return:
"""
... | [
"def",
"leaves",
"(",
"self",
",",
"name",
")",
":",
"return",
"list",
"(",
"self",
".",
"lookup_leaves",
".",
"get",
"(",
"unnest_path",
"(",
"name",
")",
",",
"Null",
")",
")"
] | RETURN LEAVES OF GIVEN PATH NAME
pull leaves, considering query_path and namespace
pull all first-level properties
pull leaves, including parent leaves
pull the head of any tree by name
:param name:
:return: | [
"RETURN",
"LEAVES",
"OF",
"GIVEN",
"PATH",
"NAME",
"pull",
"leaves",
"considering",
"query_path",
"and",
"namespace",
"pull",
"all",
"first",
"-",
"level",
"properties",
"pull",
"leaves",
"including",
"parent",
"leaves",
"pull",
"the",
"head",
"of",
"any",
"tr... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/schema.py#L69-L80 |
klahnakoski/pyLibrary | jx_base/schema.py | Schema.map_to_es | def map_to_es(self):
"""
RETURN A MAP FROM THE NAMESPACE TO THE es_column NAME
"""
full_name = self.query_path
return set_default(
{
relative_field(c.name, full_name): c.es_column
for k, cs in self.lookup.items()
# if st... | python | def map_to_es(self):
"""
RETURN A MAP FROM THE NAMESPACE TO THE es_column NAME
"""
full_name = self.query_path
return set_default(
{
relative_field(c.name, full_name): c.es_column
for k, cs in self.lookup.items()
# if st... | [
"def",
"map_to_es",
"(",
"self",
")",
":",
"full_name",
"=",
"self",
".",
"query_path",
"return",
"set_default",
"(",
"{",
"relative_field",
"(",
"c",
".",
"name",
",",
"full_name",
")",
":",
"c",
".",
"es_column",
"for",
"k",
",",
"cs",
"in",
"self",
... | RETURN A MAP FROM THE NAMESPACE TO THE es_column NAME | [
"RETURN",
"A",
"MAP",
"FROM",
"THE",
"NAMESPACE",
"TO",
"THE",
"es_column",
"NAME"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/schema.py#L82-L100 |
flying-sheep/get_version | get_version.py | get_version_from_dirname | def get_version_from_dirname(name, parent):
"""Extracted sdist"""
parent = parent.resolve()
logger.info(f"dirname: Trying to get version of {name} from dirname {parent}")
name_re = name.replace("_", "[_-]")
re_dirname = re.compile(f"{name_re}-{RE_VERSION}$")
if not re_dirname.match(parent.name)... | python | def get_version_from_dirname(name, parent):
"""Extracted sdist"""
parent = parent.resolve()
logger.info(f"dirname: Trying to get version of {name} from dirname {parent}")
name_re = name.replace("_", "[_-]")
re_dirname = re.compile(f"{name_re}-{RE_VERSION}$")
if not re_dirname.match(parent.name)... | [
"def",
"get_version_from_dirname",
"(",
"name",
",",
"parent",
")",
":",
"parent",
"=",
"parent",
".",
"resolve",
"(",
")",
"logger",
".",
"info",
"(",
"f\"dirname: Trying to get version of {name} from dirname {parent}\"",
")",
"name_re",
"=",
"name",
".",
"replace"... | Extracted sdist | [
"Extracted",
"sdist"
] | train | https://github.com/flying-sheep/get_version/blob/1042779cdbf15b3c971744a5dae780706af3433b/get_version.py#L50-L62 |
kedpter/secret_miner | pjutils.py | execute_by_options | def execute_by_options(args):
"""execute by argument dictionary
Args:
args (dict): command line argument dictionary
"""
if args['subcommand'] == 'sphinx':
s = Sphinx(proj_info)
if args['quickstart']:
s.quickstart()
elif args['gen_code_api']:
s.ge... | python | def execute_by_options(args):
"""execute by argument dictionary
Args:
args (dict): command line argument dictionary
"""
if args['subcommand'] == 'sphinx':
s = Sphinx(proj_info)
if args['quickstart']:
s.quickstart()
elif args['gen_code_api']:
s.ge... | [
"def",
"execute_by_options",
"(",
"args",
")",
":",
"if",
"args",
"[",
"'subcommand'",
"]",
"==",
"'sphinx'",
":",
"s",
"=",
"Sphinx",
"(",
"proj_info",
")",
"if",
"args",
"[",
"'quickstart'",
"]",
":",
"s",
".",
"quickstart",
"(",
")",
"elif",
"args",... | execute by argument dictionary
Args:
args (dict): command line argument dictionary | [
"execute",
"by",
"argument",
"dictionary"
] | train | https://github.com/kedpter/secret_miner/blob/3b4ebe58e11fb688d7e8928ebaa2871fc43717e4/pjutils.py#L417-L448 |
kedpter/secret_miner | pjutils.py | Editor.editline_with_regex | def editline_with_regex(self, regex_tgtline, to_replace):
"""find the first matched line, then replace
Args:
regex_tgtline (str): regular expression used to match the target line
to_replace (str): line you wanna use to replace
"""
for idx, line in enumerate(s... | python | def editline_with_regex(self, regex_tgtline, to_replace):
"""find the first matched line, then replace
Args:
regex_tgtline (str): regular expression used to match the target line
to_replace (str): line you wanna use to replace
"""
for idx, line in enumerate(s... | [
"def",
"editline_with_regex",
"(",
"self",
",",
"regex_tgtline",
",",
"to_replace",
")",
":",
"for",
"idx",
",",
"line",
"in",
"enumerate",
"(",
"self",
".",
"_swp_lines",
")",
":",
"mobj",
"=",
"re",
".",
"match",
"(",
"regex_tgtline",
",",
"line",
")",... | find the first matched line, then replace
Args:
regex_tgtline (str): regular expression used to match the target line
to_replace (str): line you wanna use to replace | [
"find",
"the",
"first",
"matched",
"line",
"then",
"replace"
] | train | https://github.com/kedpter/secret_miner/blob/3b4ebe58e11fb688d7e8928ebaa2871fc43717e4/pjutils.py#L83-L97 |
kedpter/secret_miner | pjutils.py | Sphinx.gen_code_api | def gen_code_api(self):
"""TODO: Docstring for gen_code_api."""
# edit config file
conf_editor = Editor(self.conf_fpath)
# insert code path for searching
conf_editor.editline_with_regex(r'^# import os', 'import os')
conf_editor.editline_with_regex(r'^# import sys', 'im... | python | def gen_code_api(self):
"""TODO: Docstring for gen_code_api."""
# edit config file
conf_editor = Editor(self.conf_fpath)
# insert code path for searching
conf_editor.editline_with_regex(r'^# import os', 'import os')
conf_editor.editline_with_regex(r'^# import sys', 'im... | [
"def",
"gen_code_api",
"(",
"self",
")",
":",
"# edit config file",
"conf_editor",
"=",
"Editor",
"(",
"self",
".",
"conf_fpath",
")",
"# insert code path for searching",
"conf_editor",
".",
"editline_with_regex",
"(",
"r'^# import os'",
",",
"'import os'",
")",
"conf... | TODO: Docstring for gen_code_api. | [
"TODO",
":",
"Docstring",
"for",
"gen_code_api",
"."
] | train | https://github.com/kedpter/secret_miner/blob/3b4ebe58e11fb688d7e8928ebaa2871fc43717e4/pjutils.py#L257-L281 |
note35/sinon | sinon/lib/util/Wrapper.py | wrap_spy | def wrap_spy(function, owner=None):
"""
Surrounds the given 'function' with a spy wrapper that tracks usage data, such as:
* call count
* arguments it was called with
* keyword argument it was called with
* return values
* etc.
Parameters:
function: function, could be ... | python | def wrap_spy(function, owner=None):
"""
Surrounds the given 'function' with a spy wrapper that tracks usage data, such as:
* call count
* arguments it was called with
* keyword argument it was called with
* return values
* etc.
Parameters:
function: function, could be ... | [
"def",
"wrap_spy",
"(",
"function",
",",
"owner",
"=",
"None",
")",
":",
"def",
"__set__",
"(",
"value",
",",
"new_list",
")",
":",
"\"\"\"\n For python 2.x compatibility\n \"\"\"",
"setattr",
"(",
"wrapped",
",",
"value",
",",
"new_list",
")",
"de... | Surrounds the given 'function' with a spy wrapper that tracks usage data, such as:
* call count
* arguments it was called with
* keyword argument it was called with
* return values
* etc.
Parameters:
function: function, could be one of 3 things:
1. the orig... | [
"Surrounds",
"the",
"given",
"function",
"with",
"a",
"spy",
"wrapper",
"that",
"tracks",
"usage",
"data",
"such",
"as",
":",
"*",
"call",
"count",
"*",
"arguments",
"it",
"was",
"called",
"with",
"*",
"keyword",
"argument",
"it",
"was",
"called",
"with",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/util/Wrapper.py#L32-L96 |
anomaly/vishnu | vishnu/backend/client/google_cloud_datastore.py | Client.save | def save(self, sync_only=False):
"""
:param sync_only:
:type: bool
"""
entity = datastore.Entity(key=self._key)
entity["last_accessed"] = self.last_accessed
# todo: restore sync only
entity["data"] = self._data
if self.expires:
entity... | python | def save(self, sync_only=False):
"""
:param sync_only:
:type: bool
"""
entity = datastore.Entity(key=self._key)
entity["last_accessed"] = self.last_accessed
# todo: restore sync only
entity["data"] = self._data
if self.expires:
entity... | [
"def",
"save",
"(",
"self",
",",
"sync_only",
"=",
"False",
")",
":",
"entity",
"=",
"datastore",
".",
"Entity",
"(",
"key",
"=",
"self",
".",
"_key",
")",
"entity",
"[",
"\"last_accessed\"",
"]",
"=",
"self",
".",
"last_accessed",
"# todo: restore sync on... | :param sync_only:
:type: bool | [
":",
"param",
"sync_only",
":",
":",
"type",
":",
"bool"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/backend/client/google_cloud_datastore.py#L43-L57 |
note35/sinon | sinon/lib/stub.py | SinonStub.__default_custom_function | def __default_custom_function(self, *args, **kwargs):
"""
If the user does not specify a custom function with which to replace the original,
then this is the function that we shall use. This function allows the user to call
returns/throws to customize the return value.
A... | python | def __default_custom_function(self, *args, **kwargs):
"""
If the user does not specify a custom function with which to replace the original,
then this is the function that we shall use. This function allows the user to call
returns/throws to customize the return value.
A... | [
"def",
"__default_custom_function",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"index_list",
"=",
"self",
".",
"__get_matching_withargs_indices",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"# if there are 'withArgs' conditions that migh... | If the user does not specify a custom function with which to replace the original,
then this is the function that we shall use. This function allows the user to call
returns/throws to customize the return value.
Args:
args: tuple, the arguments inputed by the user
... | [
"If",
"the",
"user",
"does",
"not",
"specify",
"a",
"custom",
"function",
"with",
"which",
"to",
"replace",
"the",
"original",
"then",
"this",
"is",
"the",
"function",
"that",
"we",
"shall",
"use",
".",
"This",
"function",
"allows",
"the",
"user",
"to",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L32-L51 |
note35/sinon | sinon/lib/stub.py | SinonStub.__get_matching_indices | def __get_matching_indices(self, args, kwargs, args_list, kwargs_list):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, a list of argument tuples
kwargs_list: list, a l... | python | def __get_matching_indices(self, args, kwargs, args_list, kwargs_list):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, a list of argument tuples
kwargs_list: list, a l... | [
"def",
"__get_matching_indices",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"args_list",
",",
"kwargs_list",
")",
":",
"if",
"args",
"and",
"kwargs",
":",
"if",
"args",
"in",
"args_list",
"and",
"kwargs",
"in",
"kwargs_list",
":",
"args_indices",
"=",
"... | Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, a list of argument tuples
kwargs_list: list, a list of keyword argument dictionaries
Returns:
list, the list of indices ... | [
"Args",
":",
"args",
":",
"tuple",
"the",
"arguments",
"inputed",
"by",
"the",
"user",
"kwargs",
":",
"dictionary",
"the",
"keyword",
"arguments",
"inputed",
"by",
"the",
"user",
"args_list",
":",
"list",
"a",
"list",
"of",
"argument",
"tuples",
"kwargs_list... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L53-L77 |
note35/sinon | sinon/lib/stub.py | SinonStub.__get_matching_withargs_indices | def __get_matching_withargs_indices(self, *args, **kwargs):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
Returns:
list, the list of indices in conditions for which the user args/kwargs m... | python | def __get_matching_withargs_indices(self, *args, **kwargs):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
Returns:
list, the list of indices in conditions for which the user args/kwargs m... | [
"def",
"__get_matching_withargs_indices",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__get_matching_indices",
"(",
"args",
",",
"kwargs",
",",
"self",
".",
"_conditions",
"[",
"\"args\"",
"]",
",",
"self",
"."... | Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
Returns:
list, the list of indices in conditions for which the user args/kwargs match | [
"Args",
":",
"args",
":",
"tuple",
"the",
"arguments",
"inputed",
"by",
"the",
"user",
"kwargs",
":",
"dictionary",
"the",
"keyword",
"arguments",
"inputed",
"by",
"the",
"user",
"Returns",
":",
"list",
"the",
"list",
"of",
"indices",
"in",
"conditions",
"... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L79-L87 |
note35/sinon | sinon/lib/stub.py | SinonStub.__get_call_count | def __get_call_count(self, args, kwargs, args_list, kwargs_list):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, the tuples of args from all the times this stub was called
... | python | def __get_call_count(self, args, kwargs, args_list, kwargs_list):
"""
Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, the tuples of args from all the times this stub was called
... | [
"def",
"__get_call_count",
"(",
"self",
",",
"args",
",",
"kwargs",
",",
"args_list",
",",
"kwargs_list",
")",
":",
"return",
"len",
"(",
"self",
".",
"__get_matching_indices",
"(",
"args",
",",
"kwargs",
",",
"args_list",
",",
"kwargs_list",
")",
")"
] | Args:
args: tuple, the arguments inputed by the user
kwargs: dictionary, the keyword arguments inputed by the user
args_list: list, the tuples of args from all the times this stub was called
kwargs_list: list, the dictionaries of kwargs from all the times this stub was ca... | [
"Args",
":",
"args",
":",
"tuple",
"the",
"arguments",
"inputed",
"by",
"the",
"user",
"kwargs",
":",
"dictionary",
"the",
"keyword",
"arguments",
"inputed",
"by",
"the",
"user",
"args_list",
":",
"list",
"the",
"tuples",
"of",
"args",
"from",
"all",
"the"... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L89-L99 |
note35/sinon | sinon/lib/stub.py | SinonStub.__get_return_value_withargs | def __get_return_value_withargs(self, index_list, *args, **kwargs):
"""
Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) One or more 'withArgs' condit... | python | def __get_return_value_withargs(self, index_list, *args, **kwargs):
"""
Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) One or more 'withArgs' condit... | [
"def",
"__get_return_value_withargs",
"(",
"self",
",",
"index_list",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"c",
"=",
"self",
".",
"_conditions",
"args_list",
"=",
"self",
".",
"_wrapper",
".",
"args_list",
"kwargs_list",
"=",
"self",
".",
... | Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) One or more 'withArgs' conditions were applicable in this case
Args:
index_list: list, the list of in... | [
"Pre",
"-",
"conditions",
":",
"(",
"1",
")",
"The",
"user",
"has",
"created",
"a",
"stub",
"and",
"specified",
"the",
"stub",
"behaviour",
"(",
"2",
")",
"The",
"user",
"has",
"called",
"the",
"stub",
"function",
"with",
"the",
"specified",
"args",
"a... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L101-L135 |
note35/sinon | sinon/lib/stub.py | SinonStub.__get_return_value_no_withargs | def __get_return_value_no_withargs(self, *args, **kwargs):
"""
Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) No 'withArgs' conditions were applicab... | python | def __get_return_value_no_withargs(self, *args, **kwargs):
"""
Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) No 'withArgs' conditions were applicab... | [
"def",
"__get_return_value_no_withargs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"c",
"=",
"self",
".",
"_conditions",
"call_count",
"=",
"self",
".",
"_wrapper",
".",
"callCount",
"# if there might be applicable onCall conditions",
"if",... | Pre-conditions:
(1) The user has created a stub and specified the stub behaviour
(2) The user has called the stub function with the specified "args" and "kwargs"
(3) No 'withArgs' conditions were applicable in this case
Args:
args: tuple, the arguments inputed by the... | [
"Pre",
"-",
"conditions",
":",
"(",
"1",
")",
"The",
"user",
"has",
"created",
"a",
"stub",
"and",
"specified",
"the",
"stub",
"behaviour",
"(",
"2",
")",
"The",
"user",
"has",
"called",
"the",
"stub",
"function",
"with",
"the",
"specified",
"args",
"a... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L137-L161 |
note35/sinon | sinon/lib/stub.py | SinonStub._append_condition | def _append_condition(self, sinon_stub_condition, func):
'''
Permanently saves the current (volatile) conditions, which would be otherwise lost
In the _conditions dictionary, the keys "args", "kwargs", "oncall" and "action"
each refer to a list. All 4 lists have a value appended each ti... | python | def _append_condition(self, sinon_stub_condition, func):
'''
Permanently saves the current (volatile) conditions, which would be otherwise lost
In the _conditions dictionary, the keys "args", "kwargs", "oncall" and "action"
each refer to a list. All 4 lists have a value appended each ti... | [
"def",
"_append_condition",
"(",
"self",
",",
"sinon_stub_condition",
",",
"func",
")",
":",
"self",
".",
"_conditions",
"[",
"\"args\"",
"]",
".",
"append",
"(",
"sinon_stub_condition",
".",
"_cond_args",
")",
"self",
".",
"_conditions",
"[",
"\"kwargs\"",
"]... | Permanently saves the current (volatile) conditions, which would be otherwise lost
In the _conditions dictionary, the keys "args", "kwargs", "oncall" and "action"
each refer to a list. All 4 lists have a value appended each time the user calls
returns or throws to add a condition to the stub. H... | [
"Permanently",
"saves",
"the",
"current",
"(",
"volatile",
")",
"conditions",
"which",
"would",
"be",
"otherwise",
"lost"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L163-L185 |
note35/sinon | sinon/lib/stub.py | SinonStub.withArgs | def withArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified argument(s) into the condition list.
For example, when the stub function is called w... | python | def withArgs(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified argument(s) into the condition list.
For example, when the stub function is called w... | [
"def",
"withArgs",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"cond_args",
"=",
"args",
"if",
"len",
"(",
"args",
")",
">",
"0",
"else",
"None",
"cond_kwargs",
"=",
"kwargs",
"if",
"len",
"(",
"kw... | Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified argument(s) into the condition list.
For example, when the stub function is called with argument 1, it will return "#":
stub.withArgs(1).returns("#")
... | [
"Adds",
"a",
"condition",
"for",
"when",
"the",
"stub",
"is",
"called",
".",
"When",
"the",
"condition",
"is",
"met",
"a",
"special",
"return",
"value",
"can",
"be",
"returned",
".",
"Adds",
"the",
"specified",
"argument",
"(",
"s",
")",
"into",
"the",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L187-L204 |
note35/sinon | sinon/lib/stub.py | SinonStub.onCall | def onCall(self, n): #pylint: disable=invalid-name
"""
Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified call number into the condition
list.
For example, when the stub function is called the secon... | python | def onCall(self, n): #pylint: disable=invalid-name
"""
Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified call number into the condition
list.
For example, when the stub function is called the secon... | [
"def",
"onCall",
"(",
"self",
",",
"n",
")",
":",
"#pylint: disable=invalid-name",
"cond_oncall",
"=",
"n",
"+",
"1",
"return",
"_SinonStubCondition",
"(",
"copy",
"=",
"self",
".",
"_copy",
",",
"oncall",
"=",
"cond_oncall",
",",
"cond_args",
"=",
"self",
... | Adds a condition for when the stub is called. When the condition is met, a special
return value can be returned. Adds the specified call number into the condition
list.
For example, when the stub function is called the second time, it will return "#":
stub.onCall(1).returns("#")
... | [
"Adds",
"a",
"condition",
"for",
"when",
"the",
"stub",
"is",
"called",
".",
"When",
"the",
"condition",
"is",
"met",
"a",
"special",
"return",
"value",
"can",
"be",
"returned",
".",
"Adds",
"the",
"specified",
"call",
"number",
"into",
"the",
"condition",... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L206-L227 |
note35/sinon | sinon/lib/stub.py | SinonStub.throws | def throws(self, exception=Exception):
"""
Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized... | python | def throws(self, exception=Exception):
"""
Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized... | [
"def",
"throws",
"(",
"self",
",",
"exception",
"=",
"Exception",
")",
":",
"def",
"exception_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"exception",
"self",
".",
"_conditions",
"[",
"\"default\"",
"]",
"=",
"exception_functio... | Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized exception)
Return: a SinonStub object (able to be ... | [
"Customizes",
"the",
"stub",
"function",
"to",
"raise",
"an",
"exception",
".",
"If",
"conditions",
"like",
"withArgs",
"or",
"onCall",
"were",
"specified",
"then",
"the",
"return",
"value",
"will",
"only",
"be",
"returned",
"when",
"the",
"conditions",
"are",... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L258-L269 |
note35/sinon | sinon/lib/stub.py | _SinonStubCondition.returns | def returns(self, obj):
"""
Customizes the return values of the stub function. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: obj (anything)
Return: a SinonStub object (able to be chained)
... | python | def returns(self, obj):
"""
Customizes the return values of the stub function. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: obj (anything)
Return: a SinonStub object (able to be chained)
... | [
"def",
"returns",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"_copy",
".",
"_append_condition",
"(",
"self",
",",
"lambda",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"obj",
")",
"return",
"self"
] | Customizes the return values of the stub function. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: obj (anything)
Return: a SinonStub object (able to be chained) | [
"Customizes",
"the",
"return",
"values",
"of",
"the",
"stub",
"function",
".",
"If",
"conditions",
"like",
"withArgs",
"or",
"onCall",
"were",
"specified",
"then",
"the",
"return",
"value",
"will",
"only",
"be",
"returned",
"when",
"the",
"conditions",
"are",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L321-L330 |
note35/sinon | sinon/lib/stub.py | _SinonStubCondition.throws | def throws(self, exception=Exception):
"""
Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized... | python | def throws(self, exception=Exception):
"""
Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized... | [
"def",
"throws",
"(",
"self",
",",
"exception",
"=",
"Exception",
")",
":",
"def",
"exception_function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"exception",
"self",
".",
"_copy",
".",
"_append_condition",
"(",
"self",
",",
"excepti... | Customizes the stub function to raise an exception. If conditions like withArgs or onCall
were specified, then the return value will only be returned when the conditions are met.
Args: exception (by default=Exception, it could be any customized exception)
Return: a SinonStub object (able to be ... | [
"Customizes",
"the",
"stub",
"function",
"to",
"raise",
"an",
"exception",
".",
"If",
"conditions",
"like",
"withArgs",
"or",
"onCall",
"were",
"specified",
"then",
"the",
"return",
"value",
"will",
"only",
"be",
"returned",
"when",
"the",
"conditions",
"are",... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/stub.py#L332-L343 |
jeremyschulman/halutz | halutz/utils.py | humanize_api_path | def humanize_api_path(api_path):
"""
Converts an API path to a humaized string, for example:
# >>> In [2]: humanize_api_path('/api/vlan/{id}')
# >>> Out[2]: u'ApiVlanId'
Parameters
----------
api_path : str
An API path string.
Returns
-------
str - humazined f... | python | def humanize_api_path(api_path):
"""
Converts an API path to a humaized string, for example:
# >>> In [2]: humanize_api_path('/api/vlan/{id}')
# >>> Out[2]: u'ApiVlanId'
Parameters
----------
api_path : str
An API path string.
Returns
-------
str - humazined f... | [
"def",
"humanize_api_path",
"(",
"api_path",
")",
":",
"return",
"reduce",
"(",
"lambda",
"val",
",",
"func",
":",
"func",
"(",
"val",
")",
",",
"[",
"parameterize",
",",
"underscore",
",",
"camelize",
"]",
",",
"unicode",
"(",
"api_path",
")",
")"
] | Converts an API path to a humaized string, for example:
# >>> In [2]: humanize_api_path('/api/vlan/{id}')
# >>> Out[2]: u'ApiVlanId'
Parameters
----------
api_path : str
An API path string.
Returns
-------
str - humazined form. | [
"Converts",
"an",
"API",
"path",
"to",
"a",
"humaized",
"string",
"for",
"example",
":"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/utils.py#L10-L29 |
jeremyschulman/halutz | halutz/utils.py | modeltag_nonref_schemas | def modeltag_nonref_schemas(spec):
"""
This function will go through the OpenAPI 'paths' and look for any
command parameters that have non "$ref" schemas defined. If the
parameter does have a $ref schema, then the bravado library will
do this x-model tagging. But it does not do it for schemas that... | python | def modeltag_nonref_schemas(spec):
"""
This function will go through the OpenAPI 'paths' and look for any
command parameters that have non "$ref" schemas defined. If the
parameter does have a $ref schema, then the bravado library will
do this x-model tagging. But it does not do it for schemas that... | [
"def",
"modeltag_nonref_schemas",
"(",
"spec",
")",
":",
"for",
"path_name",
",",
"path_data",
"in",
"six",
".",
"iteritems",
"(",
"spec",
"[",
"'paths'",
"]",
")",
":",
"for",
"path_cmd",
",",
"cmd_data",
"in",
"six",
".",
"iteritems",
"(",
"path_data",
... | This function will go through the OpenAPI 'paths' and look for any
command parameters that have non "$ref" schemas defined. If the
parameter does have a $ref schema, then the bravado library will
do this x-model tagging. But it does not do it for schemas that
are defined inside the path/command struct... | [
"This",
"function",
"will",
"go",
"through",
"the",
"OpenAPI",
"paths",
"and",
"look",
"for",
"any",
"command",
"parameters",
"that",
"have",
"non",
"$ref",
"schemas",
"defined",
".",
"If",
"the",
"parameter",
"does",
"have",
"a",
"$ref",
"schema",
"then",
... | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/utils.py#L32-L61 |
jeremyschulman/halutz | halutz/utils.py | assign_operation_ids | def assign_operation_ids(spec, operids):
""" used to assign caller provided operationId values into a spec """
empty_dict = {}
for path_name, path_data in six.iteritems(spec['paths']):
for method, method_data in six.iteritems(path_data):
oper_id = operids.get(path_name, empty_dict).get... | python | def assign_operation_ids(spec, operids):
""" used to assign caller provided operationId values into a spec """
empty_dict = {}
for path_name, path_data in six.iteritems(spec['paths']):
for method, method_data in six.iteritems(path_data):
oper_id = operids.get(path_name, empty_dict).get... | [
"def",
"assign_operation_ids",
"(",
"spec",
",",
"operids",
")",
":",
"empty_dict",
"=",
"{",
"}",
"for",
"path_name",
",",
"path_data",
"in",
"six",
".",
"iteritems",
"(",
"spec",
"[",
"'paths'",
"]",
")",
":",
"for",
"method",
",",
"method_data",
"in",... | used to assign caller provided operationId values into a spec | [
"used",
"to",
"assign",
"caller",
"provided",
"operationId",
"values",
"into",
"a",
"spec"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/utils.py#L67-L76 |
ofir123/py-printer | pyprinter/table.py | Table.pretty_print | def pretty_print(self, printer: Optional[Printer] = None, align: int = ALIGN_CENTER, border: bool = False):
"""
Pretty prints the table.
:param printer: The printer to print with.
:param align: The alignment of the cells(Table.ALIGN_CENTER/ALIGN_LEFT/ALIGN_RIGHT)
:param border: ... | python | def pretty_print(self, printer: Optional[Printer] = None, align: int = ALIGN_CENTER, border: bool = False):
"""
Pretty prints the table.
:param printer: The printer to print with.
:param align: The alignment of the cells(Table.ALIGN_CENTER/ALIGN_LEFT/ALIGN_RIGHT)
:param border: ... | [
"def",
"pretty_print",
"(",
"self",
",",
"printer",
":",
"Optional",
"[",
"Printer",
"]",
"=",
"None",
",",
"align",
":",
"int",
"=",
"ALIGN_CENTER",
",",
"border",
":",
"bool",
"=",
"False",
")",
":",
"if",
"printer",
"is",
"None",
":",
"printer",
"... | Pretty prints the table.
:param printer: The printer to print with.
:param align: The alignment of the cells(Table.ALIGN_CENTER/ALIGN_LEFT/ALIGN_RIGHT)
:param border: Whether to add a border around the table | [
"Pretty",
"prints",
"the",
"table",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L44-L67 |
ofir123/py-printer | pyprinter/table.py | Table.rows | def rows(self) -> List[List[str]]:
"""
Returns the table rows.
"""
return [list(d.values()) for d in self.data] | python | def rows(self) -> List[List[str]]:
"""
Returns the table rows.
"""
return [list(d.values()) for d in self.data] | [
"def",
"rows",
"(",
"self",
")",
"->",
"List",
"[",
"List",
"[",
"str",
"]",
"]",
":",
"return",
"[",
"list",
"(",
"d",
".",
"values",
"(",
")",
")",
"for",
"d",
"in",
"self",
".",
"data",
"]"
] | Returns the table rows. | [
"Returns",
"the",
"table",
"rows",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L70-L74 |
ofir123/py-printer | pyprinter/table.py | Table.set_column_size_limit | def set_column_size_limit(self, column_name: str, size_limit: int):
"""
Sets the size limit of a specific column.
:param column_name: The name of the column to change.
:param size_limit: The max size of the column width.
"""
if self._column_size_map.get(column_name):
... | python | def set_column_size_limit(self, column_name: str, size_limit: int):
"""
Sets the size limit of a specific column.
:param column_name: The name of the column to change.
:param size_limit: The max size of the column width.
"""
if self._column_size_map.get(column_name):
... | [
"def",
"set_column_size_limit",
"(",
"self",
",",
"column_name",
":",
"str",
",",
"size_limit",
":",
"int",
")",
":",
"if",
"self",
".",
"_column_size_map",
".",
"get",
"(",
"column_name",
")",
":",
"self",
".",
"_column_size_map",
"[",
"column_name",
"]",
... | Sets the size limit of a specific column.
:param column_name: The name of the column to change.
:param size_limit: The max size of the column width. | [
"Sets",
"the",
"size",
"limit",
"of",
"a",
"specific",
"column",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L83-L93 |
ofir123/py-printer | pyprinter/table.py | Table._get_pretty_table | def _get_pretty_table(self, indent: int = 0, align: int = ALIGN_CENTER, border: bool = False) -> PrettyTable:
"""
Returns the table format of the scheme, i.e.:
<table name>
+----------------+----------------
| <field1> | <field2>...
+----------------+--------... | python | def _get_pretty_table(self, indent: int = 0, align: int = ALIGN_CENTER, border: bool = False) -> PrettyTable:
"""
Returns the table format of the scheme, i.e.:
<table name>
+----------------+----------------
| <field1> | <field2>...
+----------------+--------... | [
"def",
"_get_pretty_table",
"(",
"self",
",",
"indent",
":",
"int",
"=",
"0",
",",
"align",
":",
"int",
"=",
"ALIGN_CENTER",
",",
"border",
":",
"bool",
"=",
"False",
")",
"->",
"PrettyTable",
":",
"rows",
"=",
"self",
".",
"rows",
"columns",
"=",
"s... | Returns the table format of the scheme, i.e.:
<table name>
+----------------+----------------
| <field1> | <field2>...
+----------------+----------------
| value1(field1) | value1(field2)
| value2(field1) | value2(field2)
| value3(field1) | value3(... | [
"Returns",
"the",
"table",
"format",
"of",
"the",
"scheme",
"i",
".",
"e",
".",
":"
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L95-L129 |
ofir123/py-printer | pyprinter/table.py | Table.get_as_html | def get_as_html(self) -> str:
"""
Returns the table object as an HTML string.
:return: HTML representation of the table.
"""
table_string = self._get_pretty_table().get_html_string()
title = ('{:^' + str(len(table_string.splitlines()[0])) + '}').format(self.title)
... | python | def get_as_html(self) -> str:
"""
Returns the table object as an HTML string.
:return: HTML representation of the table.
"""
table_string = self._get_pretty_table().get_html_string()
title = ('{:^' + str(len(table_string.splitlines()[0])) + '}').format(self.title)
... | [
"def",
"get_as_html",
"(",
"self",
")",
"->",
"str",
":",
"table_string",
"=",
"self",
".",
"_get_pretty_table",
"(",
")",
".",
"get_html_string",
"(",
")",
"title",
"=",
"(",
"'{:^'",
"+",
"str",
"(",
"len",
"(",
"table_string",
".",
"splitlines",
"(",
... | Returns the table object as an HTML string.
:return: HTML representation of the table. | [
"Returns",
"the",
"table",
"object",
"as",
"an",
"HTML",
"string",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L131-L139 |
ofir123/py-printer | pyprinter/table.py | Table.get_as_csv | def get_as_csv(self, output_file_path: Optional[str] = None) -> str:
"""
Returns the table object as a CSV string.
:param output_file_path: The output file to save the CSV to, or None.
:return: CSV representation of the table.
"""
output = StringIO() if not output_file_p... | python | def get_as_csv(self, output_file_path: Optional[str] = None) -> str:
"""
Returns the table object as a CSV string.
:param output_file_path: The output file to save the CSV to, or None.
:return: CSV representation of the table.
"""
output = StringIO() if not output_file_p... | [
"def",
"get_as_csv",
"(",
"self",
",",
"output_file_path",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"str",
":",
"output",
"=",
"StringIO",
"(",
")",
"if",
"not",
"output_file_path",
"else",
"open",
"(",
"output_file_path",
",",
"'w'",
")... | Returns the table object as a CSV string.
:param output_file_path: The output file to save the CSV to, or None.
:return: CSV representation of the table. | [
"Returns",
"the",
"table",
"object",
"as",
"a",
"CSV",
"string",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/table.py#L141-L158 |
ff0000/scarlet | scarlet/scheduling/models.py | Schedulable.schedule | def schedule(self, when=None, action=None, **kwargs):
"""
Schedule an update of this object.
when: The date for the update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kw... | python | def schedule(self, when=None, action=None, **kwargs):
"""
Schedule an update of this object.
when: The date for the update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kw... | [
"def",
"schedule",
"(",
"self",
",",
"when",
"=",
"None",
",",
"action",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# when is empty or passed, just save it now.",
"if",
"not",
"when",
"or",
"when",
"<=",
"timezone",
".",
"now",
"(",
")",
":",
"self... | Schedule an update of this object.
when: The date for the update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kwargs will be set on self and then self
is saved.
kwargs: ... | [
"Schedule",
"an",
"update",
"of",
"this",
"object",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/scheduling/models.py#L31-L59 |
ff0000/scarlet | scarlet/scheduling/models.py | Schedulable.do_scheduled_update | def do_scheduled_update(self, action, **kwargs):
"""
Do the actual update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kwargs will be set on self and then self
is saved.
... | python | def do_scheduled_update(self, action, **kwargs):
"""
Do the actual update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kwargs will be set on self and then self
is saved.
... | [
"def",
"do_scheduled_update",
"(",
"self",
",",
"action",
",",
"*",
"*",
"kwargs",
")",
":",
"action",
"=",
"getattr",
"(",
"self",
",",
"action",
",",
"None",
")",
"if",
"callable",
"(",
"action",
")",
":",
"return",
"action",
"(",
"*",
"*",
"kwargs... | Do the actual update.
action: if provided it will be looked up
on the implementing class and called with
**kwargs. If action is not provided each k/v pair
in kwargs will be set on self and then self
is saved.
kwargs: any other you passed for this update
passed a... | [
"Do",
"the",
"actual",
"update",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/scheduling/models.py#L61-L82 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | get_md5_hash | def get_md5_hash(file_path):
"""
Calculate the MD5 checksum for a file.
:param string file_path:
Path to the file
:return:
MD5 checksum
"""
checksum = hashlib.md5()
with open(file_path, 'rb') as f:
for chunk in iter(lambda: f.read(128 * checksum.block_size), b''):
... | python | def get_md5_hash(file_path):
"""
Calculate the MD5 checksum for a file.
:param string file_path:
Path to the file
:return:
MD5 checksum
"""
checksum = hashlib.md5()
with open(file_path, 'rb') as f:
for chunk in iter(lambda: f.read(128 * checksum.block_size), b''):
... | [
"def",
"get_md5_hash",
"(",
"file_path",
")",
":",
"checksum",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"as",
"f",
":",
"for",
"chunk",
"in",
"iter",
"(",
"lambda",
":",
"f",
".",
"read",
"(",
"128",... | Calculate the MD5 checksum for a file.
:param string file_path:
Path to the file
:return:
MD5 checksum | [
"Calculate",
"the",
"MD5",
"checksum",
"for",
"a",
"file",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L77-L90 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | FileRecordSearch.as_dict | def as_dict(self):
"""
Convert this FileRecordSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this FileRecordSearch instance
"""
d = {}
_add_value(d, 'obstory_ids', self.obstory_ids)
_add_value(d, ... | python | def as_dict(self):
"""
Convert this FileRecordSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this FileRecordSearch instance
"""
d = {}
_add_value(d, 'obstory_ids', self.obstory_ids)
_add_value(d, ... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"_add_value",
"(",
"d",
",",
"'obstory_ids'",
",",
"self",
".",
"obstory_ids",
")",
"_add_value",
"(",
"d",
",",
"'lat_min'",
",",
"self",
".",
"lat_min",
")",
"_add_value",
"(",
"d",
",",
... | Convert this FileRecordSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this FileRecordSearch instance | [
"Convert",
"this",
"FileRecordSearch",
"to",
"a",
"dict",
"ready",
"for",
"serialization",
"to",
"JSON",
"for",
"use",
"in",
"the",
"API",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L268-L293 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | FileRecordSearch.from_dict | def from_dict(d):
"""
Builds a new instance of FileRecordSearch from a dict
:param Object d: the dict to parse
:return: a new FileRecordSearch based on the supplied dict
"""
obstory_ids = _value_from_dict(d, 'obstory_ids')
lat_min = _value_from_dict(d, 'lat_min')... | python | def from_dict(d):
"""
Builds a new instance of FileRecordSearch from a dict
:param Object d: the dict to parse
:return: a new FileRecordSearch based on the supplied dict
"""
obstory_ids = _value_from_dict(d, 'obstory_ids')
lat_min = _value_from_dict(d, 'lat_min')... | [
"def",
"from_dict",
"(",
"d",
")",
":",
"obstory_ids",
"=",
"_value_from_dict",
"(",
"d",
",",
"'obstory_ids'",
")",
"lat_min",
"=",
"_value_from_dict",
"(",
"d",
",",
"'lat_min'",
")",
"lat_max",
"=",
"_value_from_dict",
"(",
"d",
",",
"'lat_max'",
")",
"... | Builds a new instance of FileRecordSearch from a dict
:param Object d: the dict to parse
:return: a new FileRecordSearch based on the supplied dict | [
"Builds",
"a",
"new",
"instance",
"of",
"FileRecordSearch",
"from",
"a",
"dict"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L296-L330 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | ObservationGroupSearch.as_dict | def as_dict(self):
"""
Convert this ObservationGroupSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservationGroupSearch instance
"""
d = {}
_add_string(d, 'obstory_name', self.obstory_name)
... | python | def as_dict(self):
"""
Convert this ObservationGroupSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservationGroupSearch instance
"""
d = {}
_add_string(d, 'obstory_name', self.obstory_name)
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"_add_string",
"(",
"d",
",",
"'obstory_name'",
",",
"self",
".",
"obstory_name",
")",
"_add_string",
"(",
"d",
",",
"'semantic_type'",
",",
"self",
".",
"semantic_type",
")",
"_add_value",
"("... | Convert this ObservationGroupSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservationGroupSearch instance | [
"Convert",
"this",
"ObservationGroupSearch",
"to",
"a",
"dict",
"ready",
"for",
"serialization",
"to",
"JSON",
"for",
"use",
"in",
"the",
"API",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L531-L548 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | ObservatoryMetadataSearch.as_dict | def as_dict(self):
"""
Convert this ObservatoryMetadataSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservatoryMetadataSearch instance
"""
d = {}
_add_value(d, 'obstory_ids', self.obstory_ids)
... | python | def as_dict(self):
"""
Convert this ObservatoryMetadataSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservatoryMetadataSearch instance
"""
d = {}
_add_value(d, 'obstory_ids', self.obstory_ids)
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"_add_value",
"(",
"d",
",",
"'obstory_ids'",
",",
"self",
".",
"obstory_ids",
")",
"_add_string",
"(",
"d",
",",
"'field_name'",
",",
"self",
".",
"field_name",
")",
"_add_value",
"(",
"d",
... | Convert this ObservatoryMetadataSearch to a dict, ready for serialization to JSON for use in the API.
:return:
Dict representation of this ObservatoryMetadataSearch instance | [
"Convert",
"this",
"ObservatoryMetadataSearch",
"to",
"a",
"dict",
"ready",
"for",
"serialization",
"to",
"JSON",
"for",
"use",
"in",
"the",
"API",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L648-L669 |
camsci/meteor-pi | src/pythonModules/meteorpi_model/meteorpi_model/__init__.py | ObservatoryMetadata.type | def type(self):
"""Returns 'number', 'string', 'date' or 'unknown' based on the type of the value"""
if isinstance(self.value, numbers.Number):
return "number"
if isinstance(self.value, basestring):
return "string"
return "unknown" | python | def type(self):
"""Returns 'number', 'string', 'date' or 'unknown' based on the type of the value"""
if isinstance(self.value, numbers.Number):
return "number"
if isinstance(self.value, basestring):
return "string"
return "unknown" | [
"def",
"type",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"numbers",
".",
"Number",
")",
":",
"return",
"\"number\"",
"if",
"isinstance",
"(",
"self",
".",
"value",
",",
"basestring",
")",
":",
"return",
"\"string\"",
"r... | Returns 'number', 'string', 'date' or 'unknown' based on the type of the value | [
"Returns",
"number",
"string",
"date",
"or",
"unknown",
"based",
"on",
"the",
"type",
"of",
"the",
"value"
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_model/meteorpi_model/__init__.py#L972-L978 |
grampajoe/pymosh | pymosh/riff.py | RiffIndexChunk._data | def _data(self):
"""Read data from the file."""
current_position = self.file.tell()
self.file.seek(self.position)
data = self.file.read(self.length)
self.file.seek(current_position)
if self.length % 2:
data += '\x00' # Padding byte
return data | python | def _data(self):
"""Read data from the file."""
current_position = self.file.tell()
self.file.seek(self.position)
data = self.file.read(self.length)
self.file.seek(current_position)
if self.length % 2:
data += '\x00' # Padding byte
return data | [
"def",
"_data",
"(",
"self",
")",
":",
"current_position",
"=",
"self",
".",
"file",
".",
"tell",
"(",
")",
"self",
".",
"file",
".",
"seek",
"(",
"self",
".",
"position",
")",
"data",
"=",
"self",
".",
"file",
".",
"read",
"(",
"self",
".",
"len... | Read data from the file. | [
"Read",
"data",
"from",
"the",
"file",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L44-L52 |
grampajoe/pymosh | pymosh/riff.py | RiffIndexList.find | def find(self, header, list_type=None):
"""Find the first chunk with specified header and optional list type."""
for chunk in self:
if chunk.header == header and (list_type is None or (header in
list_headers and chunk.type == list_type)):
return chunk
... | python | def find(self, header, list_type=None):
"""Find the first chunk with specified header and optional list type."""
for chunk in self:
if chunk.header == header and (list_type is None or (header in
list_headers and chunk.type == list_type)):
return chunk
... | [
"def",
"find",
"(",
"self",
",",
"header",
",",
"list_type",
"=",
"None",
")",
":",
"for",
"chunk",
"in",
"self",
":",
"if",
"chunk",
".",
"header",
"==",
"header",
"and",
"(",
"list_type",
"is",
"None",
"or",
"(",
"header",
"in",
"list_headers",
"an... | Find the first chunk with specified header and optional list type. | [
"Find",
"the",
"first",
"chunk",
"with",
"specified",
"header",
"and",
"optional",
"list",
"type",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L99-L115 |
grampajoe/pymosh | pymosh/riff.py | RiffIndexList.find_all | def find_all(self, header, list_type=None):
"""Find all direct children with header and optional list type."""
found = []
for chunk in self:
if chunk.header == header and (not list_type or (header in
list_headers and chunk.type == list_type)):
found.ap... | python | def find_all(self, header, list_type=None):
"""Find all direct children with header and optional list type."""
found = []
for chunk in self:
if chunk.header == header and (not list_type or (header in
list_headers and chunk.type == list_type)):
found.ap... | [
"def",
"find_all",
"(",
"self",
",",
"header",
",",
"list_type",
"=",
"None",
")",
":",
"found",
"=",
"[",
"]",
"for",
"chunk",
"in",
"self",
":",
"if",
"chunk",
".",
"header",
"==",
"header",
"and",
"(",
"not",
"list_type",
"or",
"(",
"header",
"i... | Find all direct children with header and optional list type. | [
"Find",
"all",
"direct",
"children",
"with",
"header",
"and",
"optional",
"list",
"type",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L117-L124 |
grampajoe/pymosh | pymosh/riff.py | RiffIndexList.replace | def replace(self, child, replacement):
"""Replace a child chunk with something else."""
for i in range(len(self.chunks)):
if self.chunks[i] == child:
self.chunks[i] = replacement | python | def replace(self, child, replacement):
"""Replace a child chunk with something else."""
for i in range(len(self.chunks)):
if self.chunks[i] == child:
self.chunks[i] = replacement | [
"def",
"replace",
"(",
"self",
",",
"child",
",",
"replacement",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"chunks",
")",
")",
":",
"if",
"self",
".",
"chunks",
"[",
"i",
"]",
"==",
"child",
":",
"self",
".",
"chunks",
... | Replace a child chunk with something else. | [
"Replace",
"a",
"child",
"chunk",
"with",
"something",
"else",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L126-L130 |
grampajoe/pymosh | pymosh/riff.py | RiffIndexList.remove | def remove(self, child):
"""Remove a child element."""
for i in range(len(self)):
if self[i] == child:
del self[i] | python | def remove(self, child):
"""Remove a child element."""
for i in range(len(self)):
if self[i] == child:
del self[i] | [
"def",
"remove",
"(",
"self",
",",
"child",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"if",
"self",
"[",
"i",
"]",
"==",
"child",
":",
"del",
"self",
"[",
"i",
"]"
] | Remove a child element. | [
"Remove",
"a",
"child",
"element",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L132-L136 |
grampajoe/pymosh | pymosh/riff.py | RiffDataChunk.from_data | def from_data(data):
"""Create a chunk from data including header and length bytes."""
header, length = struct.unpack('4s<I', data[:8])
data = data[8:]
return RiffDataChunk(header, data) | python | def from_data(data):
"""Create a chunk from data including header and length bytes."""
header, length = struct.unpack('4s<I', data[:8])
data = data[8:]
return RiffDataChunk(header, data) | [
"def",
"from_data",
"(",
"data",
")",
":",
"header",
",",
"length",
"=",
"struct",
".",
"unpack",
"(",
"'4s<I'",
",",
"data",
"[",
":",
"8",
"]",
")",
"data",
"=",
"data",
"[",
"8",
":",
"]",
"return",
"RiffDataChunk",
"(",
"header",
",",
"data",
... | Create a chunk from data including header and length bytes. | [
"Create",
"a",
"chunk",
"from",
"data",
"including",
"header",
"and",
"length",
"bytes",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/riff.py#L147-L151 |
commonwealth-of-puerto-rico/libre | libre/apps/main/sites.py | AdminMixin.get_urls | def get_urls(self):
"""Add our dashboard view to the admin urlconf. Deleted the default index."""
from django.conf.urls import patterns, url
from views import DashboardWelcomeView
urls = super(AdminMixin, self).get_urls()
del urls[0]
custom_url = patterns(
''... | python | def get_urls(self):
"""Add our dashboard view to the admin urlconf. Deleted the default index."""
from django.conf.urls import patterns, url
from views import DashboardWelcomeView
urls = super(AdminMixin, self).get_urls()
del urls[0]
custom_url = patterns(
''... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"from",
"django",
".",
"conf",
".",
"urls",
"import",
"patterns",
",",
"url",
"from",
"views",
"import",
"DashboardWelcomeView",
"urls",
"=",
"super",
"(",
"AdminMixin",
",",
"self",
")",
".",
"get_urls",
"(",
")... | Add our dashboard view to the admin urlconf. Deleted the default index. | [
"Add",
"our",
"dashboard",
"view",
"to",
"the",
"admin",
"urlconf",
".",
"Deleted",
"the",
"default",
"index",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/main/sites.py#L11-L23 |
klahnakoski/pyLibrary | mo_collections/matrix.py | index_to_coordinate | def index_to_coordinate(dims):
"""
RETURN A FUNCTION THAT WILL TAKE AN INDEX, AND MAP IT TO A coordinate IN dims
:param dims: TUPLE WITH NUMBER OF POINTS IN EACH DIMENSION
:return: FUNCTION
"""
_ = divmod # SO WE KEEP THE IMPORT
num_dims = len(dims)
if num_dims == 0:
return _z... | python | def index_to_coordinate(dims):
"""
RETURN A FUNCTION THAT WILL TAKE AN INDEX, AND MAP IT TO A coordinate IN dims
:param dims: TUPLE WITH NUMBER OF POINTS IN EACH DIMENSION
:return: FUNCTION
"""
_ = divmod # SO WE KEEP THE IMPORT
num_dims = len(dims)
if num_dims == 0:
return _z... | [
"def",
"index_to_coordinate",
"(",
"dims",
")",
":",
"_",
"=",
"divmod",
"# SO WE KEEP THE IMPORT",
"num_dims",
"=",
"len",
"(",
"dims",
")",
"if",
"num_dims",
"==",
"0",
":",
"return",
"_zero_dim",
"prod",
"=",
"[",
"1",
"]",
"*",
"num_dims",
"acc",
"="... | RETURN A FUNCTION THAT WILL TAKE AN INDEX, AND MAP IT TO A coordinate IN dims
:param dims: TUPLE WITH NUMBER OF POINTS IN EACH DIMENSION
:return: FUNCTION | [
"RETURN",
"A",
"FUNCTION",
"THAT",
"WILL",
"TAKE",
"AN",
"INDEX",
"AND",
"MAP",
"IT",
"TO",
"A",
"coordinate",
"IN",
"dims"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L358-L401 |
klahnakoski/pyLibrary | mo_collections/matrix.py | Matrix.groupby | def groupby(self, io_select):
"""
SLICE THIS MATRIX INTO ONES WITH LESS DIMENSIONALITY
io_select - 1 IF GROUPING BY THIS DIMENSION, 0 IF FLATTENING
return -
"""
# offsets WILL SERVE TO MASK DIMS WE ARE NOT GROUPING BY, AND SERVE AS RELATIVE INDEX FOR EACH COORDINATE
... | python | def groupby(self, io_select):
"""
SLICE THIS MATRIX INTO ONES WITH LESS DIMENSIONALITY
io_select - 1 IF GROUPING BY THIS DIMENSION, 0 IF FLATTENING
return -
"""
# offsets WILL SERVE TO MASK DIMS WE ARE NOT GROUPING BY, AND SERVE AS RELATIVE INDEX FOR EACH COORDINATE
... | [
"def",
"groupby",
"(",
"self",
",",
"io_select",
")",
":",
"# offsets WILL SERVE TO MASK DIMS WE ARE NOT GROUPING BY, AND SERVE AS RELATIVE INDEX FOR EACH COORDINATE",
"offsets",
"=",
"[",
"]",
"new_dim",
"=",
"[",
"]",
"acc",
"=",
"1",
"for",
"i",
",",
"d",
"in",
"... | SLICE THIS MATRIX INTO ONES WITH LESS DIMENSIONALITY
io_select - 1 IF GROUPING BY THIS DIMENSION, 0 IF FLATTENING
return - | [
"SLICE",
"THIS",
"MATRIX",
"INTO",
"ONES",
"WITH",
"LESS",
"DIMENSIONALITY",
"io_select",
"-",
"1",
"IF",
"GROUPING",
"BY",
"THIS",
"DIMENSION",
"0",
"IF",
"FLATTENING",
"return",
"-"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L179-L206 |
klahnakoski/pyLibrary | mo_collections/matrix.py | Matrix.forall | def forall(self, method):
"""
IT IS EXPECTED THE method ACCEPTS (value, coord, cube), WHERE
value - VALUE FOUND AT ELEMENT
coord - THE COORDINATES OF THE ELEMENT (PLEASE, READ ONLY)
cube - THE WHOLE CUBE, FOR USE IN WINDOW FUNCTIONS
"""
for c in self._all_combos()... | python | def forall(self, method):
"""
IT IS EXPECTED THE method ACCEPTS (value, coord, cube), WHERE
value - VALUE FOUND AT ELEMENT
coord - THE COORDINATES OF THE ELEMENT (PLEASE, READ ONLY)
cube - THE WHOLE CUBE, FOR USE IN WINDOW FUNCTIONS
"""
for c in self._all_combos()... | [
"def",
"forall",
"(",
"self",
",",
"method",
")",
":",
"for",
"c",
"in",
"self",
".",
"_all_combos",
"(",
")",
":",
"method",
"(",
"self",
"[",
"c",
"]",
",",
"c",
",",
"self",
".",
"cube",
")"
] | IT IS EXPECTED THE method ACCEPTS (value, coord, cube), WHERE
value - VALUE FOUND AT ELEMENT
coord - THE COORDINATES OF THE ELEMENT (PLEASE, READ ONLY)
cube - THE WHOLE CUBE, FOR USE IN WINDOW FUNCTIONS | [
"IT",
"IS",
"EXPECTED",
"THE",
"method",
"ACCEPTS",
"(",
"value",
"coord",
"cube",
")",
"WHERE",
"value",
"-",
"VALUE",
"FOUND",
"AT",
"ELEMENT",
"coord",
"-",
"THE",
"COORDINATES",
"OF",
"THE",
"ELEMENT",
"(",
"PLEASE",
"READ",
"ONLY",
")",
"cube",
"-",... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L216-L224 |
klahnakoski/pyLibrary | mo_collections/matrix.py | Matrix.items | def items(self):
"""
ITERATE THROUGH ALL coord, value PAIRS
"""
for c in self._all_combos():
_, value = _getitem(self.cube, c)
yield c, value | python | def items(self):
"""
ITERATE THROUGH ALL coord, value PAIRS
"""
for c in self._all_combos():
_, value = _getitem(self.cube, c)
yield c, value | [
"def",
"items",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"_all_combos",
"(",
")",
":",
"_",
",",
"value",
"=",
"_getitem",
"(",
"self",
".",
"cube",
",",
"c",
")",
"yield",
"c",
",",
"value"
] | ITERATE THROUGH ALL coord, value PAIRS | [
"ITERATE",
"THROUGH",
"ALL",
"coord",
"value",
"PAIRS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L226-L232 |
klahnakoski/pyLibrary | mo_collections/matrix.py | Matrix._all_combos | def _all_combos(self):
"""
RETURN AN ITERATOR OF ALL COORDINATES
"""
combos = _product(self.dims)
if not combos:
return
calc = [(coalesce(_product(self.dims[i+1:]), 1), mm) for i, mm in enumerate(self.dims)]
for c in xrange(combos):
yield... | python | def _all_combos(self):
"""
RETURN AN ITERATOR OF ALL COORDINATES
"""
combos = _product(self.dims)
if not combos:
return
calc = [(coalesce(_product(self.dims[i+1:]), 1), mm) for i, mm in enumerate(self.dims)]
for c in xrange(combos):
yield... | [
"def",
"_all_combos",
"(",
"self",
")",
":",
"combos",
"=",
"_product",
"(",
"self",
".",
"dims",
")",
"if",
"not",
"combos",
":",
"return",
"calc",
"=",
"[",
"(",
"coalesce",
"(",
"_product",
"(",
"self",
".",
"dims",
"[",
"i",
"+",
"1",
":",
"]... | RETURN AN ITERATOR OF ALL COORDINATES | [
"RETURN",
"AN",
"ITERATOR",
"OF",
"ALL",
"COORDINATES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/matrix.py#L234-L245 |
klahnakoski/pyLibrary | pyLibrary/env/pulse.py | Publisher.send | def send(self, topic, message):
"""Publishes a pulse message to the proper exchange."""
if not message:
Log.error("Expecting a message")
message._prepare()
if not self.connection:
self.connect()
producer = Producer(
channel=self.connection,... | python | def send(self, topic, message):
"""Publishes a pulse message to the proper exchange."""
if not message:
Log.error("Expecting a message")
message._prepare()
if not self.connection:
self.connect()
producer = Producer(
channel=self.connection,... | [
"def",
"send",
"(",
"self",
",",
"topic",
",",
"message",
")",
":",
"if",
"not",
"message",
":",
"Log",
".",
"error",
"(",
"\"Expecting a message\"",
")",
"message",
".",
"_prepare",
"(",
")",
"if",
"not",
"self",
".",
"connection",
":",
"self",
".",
... | Publishes a pulse message to the proper exchange. | [
"Publishes",
"a",
"pulse",
"message",
"to",
"the",
"proper",
"exchange",
"."
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/pulse.py#L176-L207 |
tetframework/Tonnikala | tonnikala/ir/nodes.py | Extends.add_child | def add_child(self, child):
"""
Add a child to the tree. Extends discards all comments
and whitespace Text. On non-whitespace Text, and any
other nodes, raise a syntax error.
"""
if isinstance(child, Comment):
return
# ignore Text nodes with whitespa... | python | def add_child(self, child):
"""
Add a child to the tree. Extends discards all comments
and whitespace Text. On non-whitespace Text, and any
other nodes, raise a syntax error.
"""
if isinstance(child, Comment):
return
# ignore Text nodes with whitespa... | [
"def",
"add_child",
"(",
"self",
",",
"child",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"Comment",
")",
":",
"return",
"# ignore Text nodes with whitespace-only content",
"if",
"isinstance",
"(",
"child",
",",
"Text",
")",
"and",
"not",
"child",
".",
... | Add a child to the tree. Extends discards all comments
and whitespace Text. On non-whitespace Text, and any
other nodes, raise a syntax error. | [
"Add",
"a",
"child",
"to",
"the",
"tree",
".",
"Extends",
"discards",
"all",
"comments",
"and",
"whitespace",
"Text",
".",
"On",
"non",
"-",
"whitespace",
"Text",
"and",
"any",
"other",
"nodes",
"raise",
"a",
"syntax",
"error",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/ir/nodes.py#L334-L348 |
klahnakoski/pyLibrary | pyLibrary/sql/sqlite.py | Sqlite.query | def query(self, command):
"""
WILL BLOCK CALLING THREAD UNTIL THE command IS COMPLETED
:param command: COMMAND FOR SQLITE
:return: list OF RESULTS
"""
if self.closed:
Log.error("database is closed")
signal = _allocate_lock()
signal.acquire()
... | python | def query(self, command):
"""
WILL BLOCK CALLING THREAD UNTIL THE command IS COMPLETED
:param command: COMMAND FOR SQLITE
:return: list OF RESULTS
"""
if self.closed:
Log.error("database is closed")
signal = _allocate_lock()
signal.acquire()
... | [
"def",
"query",
"(",
"self",
",",
"command",
")",
":",
"if",
"self",
".",
"closed",
":",
"Log",
".",
"error",
"(",
"\"database is closed\"",
")",
"signal",
"=",
"_allocate_lock",
"(",
")",
"signal",
".",
"acquire",
"(",
")",
"result",
"=",
"Data",
"(",... | WILL BLOCK CALLING THREAD UNTIL THE command IS COMPLETED
:param command: COMMAND FOR SQLITE
:return: list OF RESULTS | [
"WILL",
"BLOCK",
"CALLING",
"THREAD",
"UNTIL",
"THE",
"command",
"IS",
"COMPLETED",
":",
"param",
"command",
":",
"COMMAND",
"FOR",
"SQLITE",
":",
"return",
":",
"list",
"OF",
"RESULTS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/sql/sqlite.py#L163-L189 |
klahnakoski/pyLibrary | pyLibrary/sql/sqlite.py | Sqlite.close | def close(self):
"""
OPTIONAL COMMIT-AND-CLOSE
IF THIS IS NOT DONE, THEN THE THREAD THAT SPAWNED THIS INSTANCE
:return:
"""
self.closed = True
signal = _allocate_lock()
signal.acquire()
self.queue.add(CommandItem(COMMIT, None, signal, None, None))
... | python | def close(self):
"""
OPTIONAL COMMIT-AND-CLOSE
IF THIS IS NOT DONE, THEN THE THREAD THAT SPAWNED THIS INSTANCE
:return:
"""
self.closed = True
signal = _allocate_lock()
signal.acquire()
self.queue.add(CommandItem(COMMIT, None, signal, None, None))
... | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"closed",
"=",
"True",
"signal",
"=",
"_allocate_lock",
"(",
")",
"signal",
".",
"acquire",
"(",
")",
"self",
".",
"queue",
".",
"add",
"(",
"CommandItem",
"(",
"COMMIT",
",",
"None",
",",
"signal",... | OPTIONAL COMMIT-AND-CLOSE
IF THIS IS NOT DONE, THEN THE THREAD THAT SPAWNED THIS INSTANCE
:return: | [
"OPTIONAL",
"COMMIT",
"-",
"AND",
"-",
"CLOSE",
"IF",
"THIS",
"IS",
"NOT",
"DONE",
"THEN",
"THE",
"THREAD",
"THAT",
"SPAWNED",
"THIS",
"INSTANCE",
":",
"return",
":"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/sql/sqlite.py#L191-L203 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/exporter.py | MeteorExporter.handle_next_export | def handle_next_export(self):
"""
Retrieve and fully evaluate the next export task, including resolution of any sub-tasks requested by the
import client such as requests for binary data, observation, etc.
:return:
An instance of ExportStateCache, the 'state' field contains t... | python | def handle_next_export(self):
"""
Retrieve and fully evaluate the next export task, including resolution of any sub-tasks requested by the
import client such as requests for binary data, observation, etc.
:return:
An instance of ExportStateCache, the 'state' field contains t... | [
"def",
"handle_next_export",
"(",
"self",
")",
":",
"state",
"=",
"None",
"while",
"True",
":",
"state",
"=",
"self",
".",
"_handle_next_export_subtask",
"(",
"export_state",
"=",
"state",
")",
"if",
"state",
"is",
"None",
":",
"return",
"None",
"elif",
"s... | Retrieve and fully evaluate the next export task, including resolution of any sub-tasks requested by the
import client such as requests for binary data, observation, etc.
:return:
An instance of ExportStateCache, the 'state' field contains the state of the export after running as many
... | [
"Retrieve",
"and",
"fully",
"evaluate",
"the",
"next",
"export",
"task",
"including",
"resolution",
"of",
"any",
"sub",
"-",
"tasks",
"requested",
"by",
"the",
"import",
"client",
"such",
"as",
"requests",
"for",
"binary",
"data",
"observation",
"etc",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/exporter.py#L47-L71 |
camsci/meteor-pi | src/pythonModules/meteorpi_db/meteorpi_db/exporter.py | MeteorExporter._handle_next_export_subtask | def _handle_next_export_subtask(self, export_state=None):
"""
Process the next export sub-task, if there is one.
:param ExportState export_state:
If provided, this is used instead of the database queue, in effect directing the exporter to process the
previous export agai... | python | def _handle_next_export_subtask(self, export_state=None):
"""
Process the next export sub-task, if there is one.
:param ExportState export_state:
If provided, this is used instead of the database queue, in effect directing the exporter to process the
previous export agai... | [
"def",
"_handle_next_export_subtask",
"(",
"self",
",",
"export_state",
"=",
"None",
")",
":",
"# Use a cached state, or generate a new one if required",
"if",
"export_state",
"is",
"None",
"or",
"export_state",
".",
"export_task",
"is",
"None",
":",
"export",
"=",
"s... | Process the next export sub-task, if there is one.
:param ExportState export_state:
If provided, this is used instead of the database queue, in effect directing the exporter to process the
previous export again. This is used to avoid having to query the database when we know already wha... | [
"Process",
"the",
"next",
"export",
"sub",
"-",
"task",
"if",
"there",
"is",
"one",
"."
] | train | https://github.com/camsci/meteor-pi/blob/7b01527650bd1b2b76d6f364e8122e25b8812c8d/src/pythonModules/meteorpi_db/meteorpi_db/exporter.py#L73-L125 |
delfick/nose-of-yeti | noseOfYeti/plugins/support/spec_options.py | extract_options_dict | def extract_options_dict(template, options):
"""Extract options from a dictionary against the template"""
for option, val in template.items():
if options and option in options:
yield option, options[option]
else:
yield option, Default(template[option]['default'](os.enviro... | python | def extract_options_dict(template, options):
"""Extract options from a dictionary against the template"""
for option, val in template.items():
if options and option in options:
yield option, options[option]
else:
yield option, Default(template[option]['default'](os.enviro... | [
"def",
"extract_options_dict",
"(",
"template",
",",
"options",
")",
":",
"for",
"option",
",",
"val",
"in",
"template",
".",
"items",
"(",
")",
":",
"if",
"options",
"and",
"option",
"in",
"options",
":",
"yield",
"option",
",",
"options",
"[",
"option"... | Extract options from a dictionary against the template | [
"Extract",
"options",
"from",
"a",
"dictionary",
"against",
"the",
"template"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/plugins/support/spec_options.py#L70-L76 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.