partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | PriceDbApplication.add_price | Creates a new price record | pricedb/app.py | def add_price(self, price: PriceModel):
""" Creates a new price record """
# assert isinstance(price, PriceModel)
if not price:
raise ValueError("Cannot add price. The received model is null!")
mapper = mappers.PriceMapper()
entity = mapper.map_model(price)
... | def add_price(self, price: PriceModel):
""" Creates a new price record """
# assert isinstance(price, PriceModel)
if not price:
raise ValueError("Cannot add price. The received model is null!")
mapper = mappers.PriceMapper()
entity = mapper.map_model(price)
... | [
"Creates",
"a",
"new",
"price",
"record"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L18-L28 | [
"def",
"add_price",
"(",
"self",
",",
"price",
":",
"PriceModel",
")",
":",
"# assert isinstance(price, PriceModel)",
"if",
"not",
"price",
":",
"raise",
"ValueError",
"(",
"\"Cannot add price. The received model is null!\"",
")",
"mapper",
"=",
"mappers",
".",
"Price... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.add_price_entity | Adds the price | pricedb/app.py | def add_price_entity(self, price: dal.Price):
""" Adds the price """
from decimal import Decimal
# check if the price already exists in db.
repo = self.get_price_repository()
existing = (
repo.query
.filter(dal.Price.namespace == price.namespace)
... | def add_price_entity(self, price: dal.Price):
""" Adds the price """
from decimal import Decimal
# check if the price already exists in db.
repo = self.get_price_repository()
existing = (
repo.query
.filter(dal.Price.namespace == price.namespace)
... | [
"Adds",
"the",
"price"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L30-L59 | [
"def",
"add_price_entity",
"(",
"self",
",",
"price",
":",
"dal",
".",
"Price",
")",
":",
"from",
"decimal",
"import",
"Decimal",
"# check if the price already exists in db.",
"repo",
"=",
"self",
".",
"get_price_repository",
"(",
")",
"existing",
"=",
"(",
"rep... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.download_price | Download and save price online | pricedb/app.py | def download_price(self, symbol: str, currency: str, agent: str) -> PriceModel:
""" Download and save price online """
price = self.__download_price(symbol, currency, agent)
self.save()
return price | def download_price(self, symbol: str, currency: str, agent: str) -> PriceModel:
""" Download and save price online """
price = self.__download_price(symbol, currency, agent)
self.save()
return price | [
"Download",
"and",
"save",
"price",
"online"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L61-L65 | [
"def",
"download_price",
"(",
"self",
",",
"symbol",
":",
"str",
",",
"currency",
":",
"str",
",",
"agent",
":",
"str",
")",
"->",
"PriceModel",
":",
"price",
"=",
"self",
".",
"__download_price",
"(",
"symbol",
",",
"currency",
",",
"agent",
")",
"sel... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.download_prices | Downloads all the prices that are listed in the Security table.
Accepts filter arguments: currency, agent, symbol, namespace. | pricedb/app.py | def download_prices(self, **kwargs):
""" Downloads all the prices that are listed in the Security table.
Accepts filter arguments: currency, agent, symbol, namespace.
"""
currency: str = kwargs.get('currency', None)
if currency:
currency = currency.upper()
age... | def download_prices(self, **kwargs):
""" Downloads all the prices that are listed in the Security table.
Accepts filter arguments: currency, agent, symbol, namespace.
"""
currency: str = kwargs.get('currency', None)
if currency:
currency = currency.upper()
age... | [
"Downloads",
"all",
"the",
"prices",
"that",
"are",
"listed",
"in",
"the",
"Security",
"table",
".",
"Accepts",
"filter",
"arguments",
":",
"currency",
"agent",
"symbol",
"namespace",
"."
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L67-L95 | [
"def",
"download_prices",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"currency",
":",
"str",
"=",
"kwargs",
".",
"get",
"(",
"'currency'",
",",
"None",
")",
"if",
"currency",
":",
"currency",
"=",
"currency",
".",
"upper",
"(",
")",
"agent",
":"... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.import_prices | Incomplete | pricedb/app.py | def import_prices(self, file_path: str, currency_symbol: str):
""" Incomplete """
from .csv import CsvParser
assert isinstance(file_path, str)
assert isinstance(currency_symbol, str)
self.logger.debug(f"Importing {file_path}")
parser = CsvParser()
prices = parse... | def import_prices(self, file_path: str, currency_symbol: str):
""" Incomplete """
from .csv import CsvParser
assert isinstance(file_path, str)
assert isinstance(currency_symbol, str)
self.logger.debug(f"Importing {file_path}")
parser = CsvParser()
prices = parse... | [
"Incomplete"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L97-L118 | [
"def",
"import_prices",
"(",
"self",
",",
"file_path",
":",
"str",
",",
"currency_symbol",
":",
"str",
")",
":",
"from",
".",
"csv",
"import",
"CsvParser",
"assert",
"isinstance",
"(",
"file_path",
",",
"str",
")",
"assert",
"isinstance",
"(",
"currency_symb... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.session | Returns the current db session | pricedb/app.py | def session(self):
""" Returns the current db session """
if not self.__session:
self.__session = dal.get_default_session()
return self.__session | def session(self):
""" Returns the current db session """
if not self.__session:
self.__session = dal.get_default_session()
return self.__session | [
"Returns",
"the",
"current",
"db",
"session"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L146-L150 | [
"def",
"session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__session",
":",
"self",
".",
"__session",
"=",
"dal",
".",
"get_default_session",
"(",
")",
"return",
"self",
".",
"__session"
] | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.get_prices | Fetches all the prices for the given arguments | pricedb/app.py | def get_prices(self, date: str, currency: str) -> List[PriceModel]:
""" Fetches all the prices for the given arguments """
from .repositories import PriceRepository
session = self.session
repo = PriceRepository(session)
query = repo.query
if date:
query = que... | def get_prices(self, date: str, currency: str) -> List[PriceModel]:
""" Fetches all the prices for the given arguments """
from .repositories import PriceRepository
session = self.session
repo = PriceRepository(session)
query = repo.query
if date:
query = que... | [
"Fetches",
"all",
"the",
"prices",
"for",
"the",
"given",
"arguments"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L152-L172 | [
"def",
"get_prices",
"(",
"self",
",",
"date",
":",
"str",
",",
"currency",
":",
"str",
")",
"->",
"List",
"[",
"PriceModel",
"]",
":",
"from",
".",
"repositories",
"import",
"PriceRepository",
"session",
"=",
"self",
".",
"session",
"repo",
"=",
"PriceR... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.get_prices_on | Returns the latest price on the date | pricedb/app.py | def get_prices_on(self, on_date: str, namespace: str, symbol: str):
""" Returns the latest price on the date """
repo = self.get_price_repository()
query = (
repo.query.filter(dal.Price.namespace == namespace)
.filter(dal.Price.symbol == symbol)
.filter(dal.Pr... | def get_prices_on(self, on_date: str, namespace: str, symbol: str):
""" Returns the latest price on the date """
repo = self.get_price_repository()
query = (
repo.query.filter(dal.Price.namespace == namespace)
.filter(dal.Price.symbol == symbol)
.filter(dal.Pr... | [
"Returns",
"the",
"latest",
"price",
"on",
"the",
"date"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L174-L185 | [
"def",
"get_prices_on",
"(",
"self",
",",
"on_date",
":",
"str",
",",
"namespace",
":",
"str",
",",
"symbol",
":",
"str",
")",
":",
"repo",
"=",
"self",
".",
"get_price_repository",
"(",
")",
"query",
"=",
"(",
"repo",
".",
"query",
".",
"filter",
"(... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.get_price_repository | Price repository | pricedb/app.py | def get_price_repository(self):
""" Price repository """
from .repositories import PriceRepository
if not self.price_repo:
self.price_repo = PriceRepository(self.session)
return self.price_repo | def get_price_repository(self):
""" Price repository """
from .repositories import PriceRepository
if not self.price_repo:
self.price_repo = PriceRepository(self.session)
return self.price_repo | [
"Price",
"repository"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L210-L216 | [
"def",
"get_price_repository",
"(",
"self",
")",
":",
"from",
".",
"repositories",
"import",
"PriceRepository",
"if",
"not",
"self",
".",
"price_repo",
":",
"self",
".",
"price_repo",
"=",
"PriceRepository",
"(",
"self",
".",
"session",
")",
"return",
"self",
... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.get_security_repository | Security repository | pricedb/app.py | def get_security_repository(self):
""" Security repository """
from .repositories import SecurityRepository
if not self.security_repo:
self.security_repo = SecurityRepository(self.session)
return self.security_repo | def get_security_repository(self):
""" Security repository """
from .repositories import SecurityRepository
if not self.security_repo:
self.security_repo = SecurityRepository(self.session)
return self.security_repo | [
"Security",
"repository"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L218-L224 | [
"def",
"get_security_repository",
"(",
"self",
")",
":",
"from",
".",
"repositories",
"import",
"SecurityRepository",
"if",
"not",
"self",
".",
"security_repo",
":",
"self",
".",
"security_repo",
"=",
"SecurityRepository",
"(",
"self",
".",
"session",
")",
"retu... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.prune_all | Prune historical prices for all symbols, leaving only the latest.
Returns the number of items removed. | pricedb/app.py | def prune_all(self) -> int:
"""
Prune historical prices for all symbols, leaving only the latest.
Returns the number of items removed.
"""
from .repositories import PriceRepository
# get all symbols that have prices
repo = PriceRepository()
items = repo.q... | def prune_all(self) -> int:
"""
Prune historical prices for all symbols, leaving only the latest.
Returns the number of items removed.
"""
from .repositories import PriceRepository
# get all symbols that have prices
repo = PriceRepository()
items = repo.q... | [
"Prune",
"historical",
"prices",
"for",
"all",
"symbols",
"leaving",
"only",
"the",
"latest",
".",
"Returns",
"the",
"number",
"of",
"items",
"removed",
"."
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L226-L245 | [
"def",
"prune_all",
"(",
"self",
")",
"->",
"int",
":",
"from",
".",
"repositories",
"import",
"PriceRepository",
"# get all symbols that have prices",
"repo",
"=",
"PriceRepository",
"(",
")",
"items",
"=",
"repo",
".",
"query",
".",
"distinct",
"(",
"dal",
"... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.prune | Delete all but the latest available price for the given symbol.
Returns the number of items removed. | pricedb/app.py | def prune(self, symbol: SecuritySymbol):
"""
Delete all but the latest available price for the given symbol.
Returns the number of items removed.
"""
from .repositories import PriceRepository
assert isinstance(symbol, SecuritySymbol)
self.logger.debug(f"pruning ... | def prune(self, symbol: SecuritySymbol):
"""
Delete all but the latest available price for the given symbol.
Returns the number of items removed.
"""
from .repositories import PriceRepository
assert isinstance(symbol, SecuritySymbol)
self.logger.debug(f"pruning ... | [
"Delete",
"all",
"but",
"the",
"latest",
"available",
"price",
"for",
"the",
"given",
"symbol",
".",
"Returns",
"the",
"number",
"of",
"items",
"removed",
"."
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L247-L280 | [
"def",
"prune",
"(",
"self",
",",
"symbol",
":",
"SecuritySymbol",
")",
":",
"from",
".",
"repositories",
"import",
"PriceRepository",
"assert",
"isinstance",
"(",
"symbol",
",",
"SecuritySymbol",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"f\"pruning pric... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.save | Save changes | pricedb/app.py | def save(self):
""" Save changes """
if self.__session:
self.session.commit()
else:
self.logger.warning("Save called but no session open.") | def save(self):
""" Save changes """
if self.__session:
self.session.commit()
else:
self.logger.warning("Save called but no session open.") | [
"Save",
"changes"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L282-L287 | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"__session",
":",
"self",
".",
"session",
".",
"commit",
"(",
")",
"else",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"Save called but no session open.\"",
")"
] | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.__download_price | Downloads and parses the price | pricedb/app.py | def __download_price(self, symbol: str, currency: str, agent: str):
""" Downloads and parses the price """
from finance_quote_python import Quote
assert isinstance(symbol, str)
assert isinstance(currency, str)
assert isinstance(agent, str)
if not symbol:
ret... | def __download_price(self, symbol: str, currency: str, agent: str):
""" Downloads and parses the price """
from finance_quote_python import Quote
assert isinstance(symbol, str)
assert isinstance(currency, str)
assert isinstance(agent, str)
if not symbol:
ret... | [
"Downloads",
"and",
"parses",
"the",
"price"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L289-L321 | [
"def",
"__download_price",
"(",
"self",
",",
"symbol",
":",
"str",
",",
"currency",
":",
"str",
",",
"agent",
":",
"str",
")",
":",
"from",
"finance_quote_python",
"import",
"Quote",
"assert",
"isinstance",
"(",
"symbol",
",",
"str",
")",
"assert",
"isinst... | b4fd366b7763891c690fe3000b8840e656da023e |
test | PriceDbApplication.__get_securities | Fetches the securities that match the given filters | pricedb/app.py | def __get_securities(self, currency: str, agent: str, symbol: str,
namespace: str) -> List[dal.Security]:
""" Fetches the securities that match the given filters """
repo = self.get_security_repository()
query = repo.query
if currency is not None:
qu... | def __get_securities(self, currency: str, agent: str, symbol: str,
namespace: str) -> List[dal.Security]:
""" Fetches the securities that match the given filters """
repo = self.get_security_repository()
query = repo.query
if currency is not None:
qu... | [
"Fetches",
"the",
"securities",
"that",
"match",
"the",
"given",
"filters"
] | MisterY/price-database | python | https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/app.py#L323-L345 | [
"def",
"__get_securities",
"(",
"self",
",",
"currency",
":",
"str",
",",
"agent",
":",
"str",
",",
"symbol",
":",
"str",
",",
"namespace",
":",
"str",
")",
"->",
"List",
"[",
"dal",
".",
"Security",
"]",
":",
"repo",
"=",
"self",
".",
"get_security_... | b4fd366b7763891c690fe3000b8840e656da023e |
test | Node.partial | Return partial of original function call | pythonwhat/probe.py | def partial(self):
"""Return partial of original function call"""
ba = self.data["bound_args"]
return state_partial(self.data["func"], *ba.args[1:], **ba.kwargs) | def partial(self):
"""Return partial of original function call"""
ba = self.data["bound_args"]
return state_partial(self.data["func"], *ba.args[1:], **ba.kwargs) | [
"Return",
"partial",
"of",
"original",
"function",
"call"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/probe.py#L121-L124 | [
"def",
"partial",
"(",
"self",
")",
":",
"ba",
"=",
"self",
".",
"data",
"[",
"\"bound_args\"",
"]",
"return",
"state_partial",
"(",
"self",
".",
"data",
"[",
"\"func\"",
"]",
",",
"*",
"ba",
".",
"args",
"[",
"1",
":",
"]",
",",
"*",
"*",
"ba",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | Node.update_child_calls | Replace child nodes on original function call with their partials | pythonwhat/probe.py | def update_child_calls(self):
"""Replace child nodes on original function call with their partials"""
for node in filter(lambda n: len(n.arg_name), self.child_list):
self.data["bound_args"].arguments[node.arg_name] = node.partial()
self.updated = True | def update_child_calls(self):
"""Replace child nodes on original function call with their partials"""
for node in filter(lambda n: len(n.arg_name), self.child_list):
self.data["bound_args"].arguments[node.arg_name] = node.partial()
self.updated = True | [
"Replace",
"child",
"nodes",
"on",
"original",
"function",
"call",
"with",
"their",
"partials"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/probe.py#L126-L131 | [
"def",
"update_child_calls",
"(",
"self",
")",
":",
"for",
"node",
"in",
"filter",
"(",
"lambda",
"n",
":",
"len",
"(",
"n",
".",
"arg_name",
")",
",",
"self",
".",
"child_list",
")",
":",
"self",
".",
"data",
"[",
"\"bound_args\"",
"]",
".",
"argume... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | Node.descend | Descend depth first into all child nodes | pythonwhat/probe.py | def descend(self, include_me=True):
"""Descend depth first into all child nodes"""
if include_me:
yield self
for child in self.child_list:
yield child
yield from child.descend() | def descend(self, include_me=True):
"""Descend depth first into all child nodes"""
if include_me:
yield self
for child in self.child_list:
yield child
yield from child.descend() | [
"Descend",
"depth",
"first",
"into",
"all",
"child",
"nodes"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/probe.py#L146-L153 | [
"def",
"descend",
"(",
"self",
",",
"include_me",
"=",
"True",
")",
":",
"if",
"include_me",
":",
"yield",
"self",
"for",
"child",
"in",
"self",
".",
"child_list",
":",
"yield",
"child",
"yield",
"from",
"child",
".",
"descend",
"(",
")"
] | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | multi_dec | Decorator for multi to remove nodes for original test functions from root node | pythonwhat/sct_syntax.py | def multi_dec(f):
"""Decorator for multi to remove nodes for original test functions from root node"""
@wraps(f)
def wrapper(*args, **kwargs):
args = (
args[0] if len(args) == 1 and isinstance(args[0], (list, tuple)) else args
)
for arg in args:
if isinstance... | def multi_dec(f):
"""Decorator for multi to remove nodes for original test functions from root node"""
@wraps(f)
def wrapper(*args, **kwargs):
args = (
args[0] if len(args) == 1 and isinstance(args[0], (list, tuple)) else args
)
for arg in args:
if isinstance... | [
"Decorator",
"for",
"multi",
"to",
"remove",
"nodes",
"for",
"original",
"test",
"functions",
"from",
"root",
"node"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/sct_syntax.py#L13-L27 | [
"def",
"multi_dec",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"(",
"args",
"[",
"0",
"]",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_equal_part_len | Verify that a part that is zoomed in on has equal length.
Typically used in the context of ``check_function_def()``
Arguments:
name (str): name of the part for which to check the length to the corresponding part in the solution.
unequal_msg (str): Message in case the lengths do not match.
... | pythonwhat/checks/has_funcs.py | def has_equal_part_len(state, name, unequal_msg):
"""Verify that a part that is zoomed in on has equal length.
Typically used in the context of ``check_function_def()``
Arguments:
name (str): name of the part for which to check the length to the corresponding part in the solution.
unequal_... | def has_equal_part_len(state, name, unequal_msg):
"""Verify that a part that is zoomed in on has equal length.
Typically used in the context of ``check_function_def()``
Arguments:
name (str): name of the part for which to check the length to the corresponding part in the solution.
unequal_... | [
"Verify",
"that",
"a",
"part",
"that",
"is",
"zoomed",
"in",
"on",
"has",
"equal",
"length",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L77-L106 | [
"def",
"has_equal_part_len",
"(",
"state",
",",
"name",
",",
"unequal_msg",
")",
":",
"d",
"=",
"dict",
"(",
"stu_len",
"=",
"len",
"(",
"state",
".",
"student_parts",
"[",
"name",
"]",
")",
",",
"sol_len",
"=",
"len",
"(",
"state",
".",
"solution_part... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_equal_ast | Test whether abstract syntax trees match between the student and solution code.
``has_equal_ast()`` can be used in two ways:
* As a robust version of ``has_code()``. By setting ``code``, you can look for the AST representation of ``code`` in the student's submission.
But be aware that ``a`` and ``a = 1`... | pythonwhat/checks/has_funcs.py | def has_equal_ast(state, incorrect_msg=None, code=None, exact=True, append=None):
"""Test whether abstract syntax trees match between the student and solution code.
``has_equal_ast()`` can be used in two ways:
* As a robust version of ``has_code()``. By setting ``code``, you can look for the AST represent... | def has_equal_ast(state, incorrect_msg=None, code=None, exact=True, append=None):
"""Test whether abstract syntax trees match between the student and solution code.
``has_equal_ast()`` can be used in two ways:
* As a robust version of ``has_code()``. By setting ``code``, you can look for the AST represent... | [
"Test",
"whether",
"abstract",
"syntax",
"trees",
"match",
"between",
"the",
"student",
"and",
"solution",
"code",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L112-L200 | [
"def",
"has_equal_ast",
"(",
"state",
",",
"incorrect_msg",
"=",
"None",
",",
"code",
"=",
"None",
",",
"exact",
"=",
"True",
",",
"append",
"=",
"None",
")",
":",
"if",
"utils",
".",
"v2_only",
"(",
")",
":",
"state",
".",
"assert_is_not",
"(",
"[",... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_code | Test the student code.
Tests if the student typed a (pattern of) text. It is advised to use ``has_equal_ast()`` instead of ``has_code()``,
as it is more robust to small syntactical differences that don't change the code's behavior.
Args:
text (str): the text that is searched for
pattern (b... | pythonwhat/checks/has_funcs.py | def has_code(state, text, pattern=True, not_typed_msg=None):
"""Test the student code.
Tests if the student typed a (pattern of) text. It is advised to use ``has_equal_ast()`` instead of ``has_code()``,
as it is more robust to small syntactical differences that don't change the code's behavior.
Args:
... | def has_code(state, text, pattern=True, not_typed_msg=None):
"""Test the student code.
Tests if the student typed a (pattern of) text. It is advised to use ``has_equal_ast()`` instead of ``has_code()``,
as it is more robust to small syntactical differences that don't change the code's behavior.
Args:
... | [
"Test",
"the",
"student",
"code",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L420-L456 | [
"def",
"has_code",
"(",
"state",
",",
"text",
",",
"pattern",
"=",
"True",
",",
"not_typed_msg",
"=",
"None",
")",
":",
"if",
"not",
"not_typed_msg",
":",
"if",
"pattern",
":",
"not_typed_msg",
"=",
"\"Could not find the correct pattern in your code.\"",
"else",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_import | Checks whether student imported a package or function correctly.
Python features many ways to import packages.
All of these different methods revolve around the ``import``, ``from`` and ``as`` keywords.
``has_import()`` provides a robust way to check whether a student correctly imported a certain package.
... | pythonwhat/checks/has_funcs.py | def has_import(
state,
name,
same_as=False,
not_imported_msg="Did you import `{{pkg}}`?",
incorrect_as_msg="Did you import `{{pkg}}` as `{{alias}}`?",
):
"""Checks whether student imported a package or function correctly.
Python features many ways to import packages.
All of these differ... | def has_import(
state,
name,
same_as=False,
not_imported_msg="Did you import `{{pkg}}`?",
incorrect_as_msg="Did you import `{{pkg}}` as `{{alias}}`?",
):
"""Checks whether student imported a package or function correctly.
Python features many ways to import packages.
All of these differ... | [
"Checks",
"whether",
"student",
"imported",
"a",
"package",
"or",
"function",
"correctly",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L459-L534 | [
"def",
"has_import",
"(",
"state",
",",
"name",
",",
"same_as",
"=",
"False",
",",
"not_imported_msg",
"=",
"\"Did you import `{{pkg}}`?\"",
",",
"incorrect_as_msg",
"=",
"\"Did you import `{{pkg}}` as `{{alias}}`?\"",
",",
")",
":",
"student_imports",
"=",
"state",
"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_output | Search student output for a pattern.
Among the student and solution process, the student submission and solution code as a string,
the ``Ex()`` state also contains the output that a student generated with his or her submission.
With ``has_output()``, you can access this output and match it against a regul... | pythonwhat/checks/has_funcs.py | def has_output(state, text, pattern=True, no_output_msg=None):
"""Search student output for a pattern.
Among the student and solution process, the student submission and solution code as a string,
the ``Ex()`` state also contains the output that a student generated with his or her submission.
With ``h... | def has_output(state, text, pattern=True, no_output_msg=None):
"""Search student output for a pattern.
Among the student and solution process, the student submission and solution code as a string,
the ``Ex()`` state also contains the output that a student generated with his or her submission.
With ``h... | [
"Search",
"student",
"output",
"for",
"a",
"pattern",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L537-L575 | [
"def",
"has_output",
"(",
"state",
",",
"text",
",",
"pattern",
"=",
"True",
",",
"no_output_msg",
"=",
"None",
")",
":",
"if",
"not",
"no_output_msg",
":",
"no_output_msg",
"=",
"\"You did not output the correct things.\"",
"_msg",
"=",
"state",
".",
"build_mes... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_printout | Check if the right printouts happened.
``has_printout()`` will look for the printout in the solution code that you specified with ``index`` (0 in this case), rerun the ``print()`` call in
the solution process, capture its output, and verify whether the output is present in the output of the student.
This ... | pythonwhat/checks/has_funcs.py | def has_printout(
state, index, not_printed_msg=None, pre_code=None, name=None, copy=False
):
"""Check if the right printouts happened.
``has_printout()`` will look for the printout in the solution code that you specified with ``index`` (0 in this case), rerun the ``print()`` call in
the solution proce... | def has_printout(
state, index, not_printed_msg=None, pre_code=None, name=None, copy=False
):
"""Check if the right printouts happened.
``has_printout()`` will look for the printout in the solution code that you specified with ``index`` (0 in this case), rerun the ``print()`` call in
the solution proce... | [
"Check",
"if",
"the",
"right",
"printouts",
"happened",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L578-L696 | [
"def",
"has_printout",
"(",
"state",
",",
"index",
",",
"not_printed_msg",
"=",
"None",
",",
"pre_code",
"=",
"None",
",",
"name",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"extra_msg",
"=",
"\"If you want to check printouts done in e.g. a for loop, you ha... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_no_error | Check whether the submission did not generate a runtime error.
If all SCTs for an exercise pass, before marking the submission as correct pythonwhat will automatically check whether
the student submission generated an error. This means it is not needed to use ``has_no_error()`` explicitly.
However, in som... | pythonwhat/checks/has_funcs.py | def has_no_error(
state,
incorrect_msg="Have a look at the console: your code contains an error. Fix it and try again!",
):
"""Check whether the submission did not generate a runtime error.
If all SCTs for an exercise pass, before marking the submission as correct pythonwhat will automatically check wh... | def has_no_error(
state,
incorrect_msg="Have a look at the console: your code contains an error. Fix it and try again!",
):
"""Check whether the submission did not generate a runtime error.
If all SCTs for an exercise pass, before marking the submission as correct pythonwhat will automatically check wh... | [
"Check",
"whether",
"the",
"submission",
"did",
"not",
"generate",
"a",
"runtime",
"error",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L699-L760 | [
"def",
"has_no_error",
"(",
"state",
",",
"incorrect_msg",
"=",
"\"Have a look at the console: your code contains an error. Fix it and try again!\"",
",",
")",
":",
"state",
".",
"assert_root",
"(",
"\"has_no_error\"",
")",
"if",
"state",
".",
"reporter",
".",
"errors",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_chosen | Test multiple choice exercise.
Test for a MultipleChoiceExercise. The correct answer (as an integer) and feedback messages
are passed to this function.
Args:
correct (int): the index of the correct answer (should be an instruction). Starts at 1.
msgs (list(str)): a list containing all feed... | pythonwhat/checks/has_funcs.py | def has_chosen(state, correct, msgs):
"""Test multiple choice exercise.
Test for a MultipleChoiceExercise. The correct answer (as an integer) and feedback messages
are passed to this function.
Args:
correct (int): the index of the correct answer (should be an instruction). Starts at 1.
... | def has_chosen(state, correct, msgs):
"""Test multiple choice exercise.
Test for a MultipleChoiceExercise. The correct answer (as an integer) and feedback messages
are passed to this function.
Args:
correct (int): the index of the correct answer (should be an instruction). Starts at 1.
... | [
"Test",
"multiple",
"choice",
"exercise",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/has_funcs.py#L766-L802 | [
"def",
"has_chosen",
"(",
"state",
",",
"correct",
",",
"msgs",
")",
":",
"if",
"not",
"issubclass",
"(",
"type",
"(",
"correct",
")",
",",
"int",
")",
":",
"raise",
"InstructorError",
"(",
"\"Inside `has_chosen()`, the argument `correct` should be an integer.\"",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_function | Check whether a particular function is called.
``check_function()`` is typically followed by:
- ``check_args()`` to check whether the arguments were specified.
In turn, ``check_args()`` can be followed by ``has_equal_value()`` or ``has_equal_ast()``
to assert that the arguments were correctly ... | pythonwhat/checks/check_function.py | def check_function(
state,
name,
index=0,
missing_msg=None,
params_not_matched_msg=None,
expand_msg=None,
signature=True,
):
"""Check whether a particular function is called.
``check_function()`` is typically followed by:
- ``check_args()`` to check whether the arguments we... | def check_function(
state,
name,
index=0,
missing_msg=None,
params_not_matched_msg=None,
expand_msg=None,
signature=True,
):
"""Check whether a particular function is called.
``check_function()`` is typically followed by:
- ``check_args()`` to check whether the arguments we... | [
"Check",
"whether",
"a",
"particular",
"function",
"is",
"called",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_function.py#L40-L177 | [
"def",
"check_function",
"(",
"state",
",",
"name",
",",
"index",
"=",
"0",
",",
"missing_msg",
"=",
"None",
",",
"params_not_matched_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
",",
"signature",
"=",
"True",
",",
")",
":",
"append_missing",
"=",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | process_task | Decorator to (optionally) run function in a process. | pythonwhat/tasks.py | def process_task(f):
"""Decorator to (optionally) run function in a process."""
sig = inspect.signature(f)
@wraps(f)
def wrapper(*args, **kwargs):
# get bound arguments for call
ba = sig.bind_partial(*args, **kwargs)
# when process is specified, remove from args and use to execu... | def process_task(f):
"""Decorator to (optionally) run function in a process."""
sig = inspect.signature(f)
@wraps(f)
def wrapper(*args, **kwargs):
# get bound arguments for call
ba = sig.bind_partial(*args, **kwargs)
# when process is specified, remove from args and use to execu... | [
"Decorator",
"to",
"(",
"optionally",
")",
"run",
"function",
"in",
"a",
"process",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/tasks.py#L18-L37 | [
"def",
"process_task",
"(",
"f",
")",
":",
"sig",
"=",
"inspect",
".",
"signature",
"(",
"f",
")",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# get bound arguments for call",
"ba",
"=",
"sig",... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | getResultFromProcess | Get a value from process, return tuple of value, res if succesful | pythonwhat/tasks.py | def getResultFromProcess(res, tempname, process):
"""Get a value from process, return tuple of value, res if succesful"""
if not isinstance(res, (UndefinedValue, Exception)):
value = getRepresentation(tempname, process)
return value, res
else:
return res, str(res) | def getResultFromProcess(res, tempname, process):
"""Get a value from process, return tuple of value, res if succesful"""
if not isinstance(res, (UndefinedValue, Exception)):
value = getRepresentation(tempname, process)
return value, res
else:
return res, str(res) | [
"Get",
"a",
"value",
"from",
"process",
"return",
"tuple",
"of",
"value",
"res",
"if",
"succesful"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/tasks.py#L297-L303 | [
"def",
"getResultFromProcess",
"(",
"res",
",",
"tempname",
",",
"process",
")",
":",
"if",
"not",
"isinstance",
"(",
"res",
",",
"(",
"UndefinedValue",
",",
"Exception",
")",
")",
":",
"value",
"=",
"getRepresentation",
"(",
"tempname",
",",
"process",
")... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | assign_from_ast | Creates code to assign name (or tuple of names) node from expr
This is useful for recreating destructuring assignment behavior, like
a, *b = [1,2,3]. | pythonwhat/utils_env.py | def assign_from_ast(node, expr):
"""
Creates code to assign name (or tuple of names) node from expr
This is useful for recreating destructuring assignment behavior, like
a, *b = [1,2,3].
"""
if isinstance(expr, str):
expr = ast.Name(id=expr, ctx=ast.Load())
mod = ast.Module([ast.Ass... | def assign_from_ast(node, expr):
"""
Creates code to assign name (or tuple of names) node from expr
This is useful for recreating destructuring assignment behavior, like
a, *b = [1,2,3].
"""
if isinstance(expr, str):
expr = ast.Name(id=expr, ctx=ast.Load())
mod = ast.Module([ast.Ass... | [
"Creates",
"code",
"to",
"assign",
"name",
"(",
"or",
"tuple",
"of",
"names",
")",
"node",
"from",
"expr"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/utils_env.py#L4-L15 | [
"def",
"assign_from_ast",
"(",
"node",
",",
"expr",
")",
":",
"if",
"isinstance",
"(",
"expr",
",",
"str",
")",
":",
"expr",
"=",
"ast",
".",
"Name",
"(",
"id",
"=",
"expr",
",",
"ctx",
"=",
"ast",
".",
"Load",
"(",
")",
")",
"mod",
"=",
"ast",... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | override | Override the solution code with something arbitrary.
There might be cases in which you want to temporarily override the solution code
so you can allow for alternative ways of solving an exercise.
When you use ``override()`` in an SCT chain, the remainder of that SCT chain will
run as if the solution co... | pythonwhat/checks/check_logic.py | def override(state, solution):
"""Override the solution code with something arbitrary.
There might be cases in which you want to temporarily override the solution code
so you can allow for alternative ways of solving an exercise.
When you use ``override()`` in an SCT chain, the remainder of that SCT ch... | def override(state, solution):
"""Override the solution code with something arbitrary.
There might be cases in which you want to temporarily override the solution code
so you can allow for alternative ways of solving an exercise.
When you use ``override()`` in an SCT chain, the remainder of that SCT ch... | [
"Override",
"the",
"solution",
"code",
"with",
"something",
"arbitrary",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_logic.py#L101-L138 | [
"def",
"override",
"(",
"state",
",",
"solution",
")",
":",
"# the old ast may be a number of node types, but generally either a",
"# (1) ast.Module, or for single expressions...",
"# (2) whatever was grabbed using module.body[0]",
"# (3) module.body[0].value, when module.body[0] is an Expr no... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | set_context | Update context values for student and solution environments.
When ``has_equal_x()`` is used after this, the context values (in ``for`` loops and function definitions, for example)
will have the values specified through his function. It is the function equivalent of the ``context_vals`` argument of
the ... | pythonwhat/checks/check_logic.py | def set_context(state, *args, **kwargs):
"""Update context values for student and solution environments.
When ``has_equal_x()`` is used after this, the context values (in ``for`` loops and function definitions, for example)
will have the values specified through his function. It is the function equival... | def set_context(state, *args, **kwargs):
"""Update context values for student and solution environments.
When ``has_equal_x()`` is used after this, the context values (in ``for`` loops and function definitions, for example)
will have the values specified through his function. It is the function equival... | [
"Update",
"context",
"values",
"for",
"student",
"and",
"solution",
"environments",
".",
"When",
"has_equal_x",
"()",
"is",
"used",
"after",
"this",
"the",
"context",
"values",
"(",
"in",
"for",
"loops",
"and",
"function",
"definitions",
"for",
"example",
")",... | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_logic.py#L141-L230 | [
"def",
"set_context",
"(",
"state",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"stu_crnt",
"=",
"state",
".",
"student_context",
".",
"context",
"sol_crnt",
"=",
"state",
".",
"solution_context",
".",
"context",
"# for now, you can't specify both",
"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | set_env | Update/set environemnt variables for student and solution environments.
When ``has_equal_x()`` is used after this, the variables specified through this function will
be available in the student and solution process. Note that you will not see these variables
in the student process of the state produced by ... | pythonwhat/checks/check_logic.py | def set_env(state, **kwargs):
"""Update/set environemnt variables for student and solution environments.
When ``has_equal_x()`` is used after this, the variables specified through this function will
be available in the student and solution process. Note that you will not see these variables
in the stud... | def set_env(state, **kwargs):
"""Update/set environemnt variables for student and solution environments.
When ``has_equal_x()`` is used after this, the variables specified through this function will
be available in the student and solution process. Note that you will not see these variables
in the stud... | [
"Update",
"/",
"set",
"environemnt",
"variables",
"for",
"student",
"and",
"solution",
"environments",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_logic.py#L233-L271 | [
"def",
"set_env",
"(",
"state",
",",
"*",
"*",
"kwargs",
")",
":",
"stu_crnt",
"=",
"state",
".",
"student_env",
".",
"context",
"sol_crnt",
"=",
"state",
".",
"solution_env",
".",
"context",
"stu_new",
"=",
"stu_crnt",
".",
"update",
"(",
"kwargs",
")",... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_object | Check object existence (and equality)
Check whether an object is defined in the student's process, and zoom in on its value in both
student and solution process to inspect quality (with has_equal_value().
In ``pythonbackend``, both the student's submission as well as the solution code are executed, in sep... | pythonwhat/checks/check_object.py | def check_object(
state, index, missing_msg=None, expand_msg=None, typestr="variable"
):
"""Check object existence (and equality)
Check whether an object is defined in the student's process, and zoom in on its value in both
student and solution process to inspect quality (with has_equal_value().
I... | def check_object(
state, index, missing_msg=None, expand_msg=None, typestr="variable"
):
"""Check object existence (and equality)
Check whether an object is defined in the student's process, and zoom in on its value in both
student and solution process to inspect quality (with has_equal_value().
I... | [
"Check",
"object",
"existence",
"(",
"and",
"equality",
")"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_object.py#L20-L196 | [
"def",
"check_object",
"(",
"state",
",",
"index",
",",
"missing_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
",",
"typestr",
"=",
"\"variable\"",
")",
":",
"# Only do the assertion if PYTHONWHAT_V2_ONLY is set to '1'",
"if",
"v2_only",
"(",
")",
":",
"extra... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | is_instance | Check whether an object is an instance of a certain class.
``is_instance()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
inst (class): The class that the object should have.
not_instance_msg (str):... | pythonwhat/checks/check_object.py | def is_instance(state, inst, not_instance_msg=None):
"""Check whether an object is an instance of a certain class.
``is_instance()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
inst (class): The class ... | def is_instance(state, inst, not_instance_msg=None):
"""Check whether an object is an instance of a certain class.
``is_instance()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
inst (class): The class ... | [
"Check",
"whether",
"an",
"object",
"is",
"an",
"instance",
"of",
"a",
"certain",
"class",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_object.py#L199-L243 | [
"def",
"is_instance",
"(",
"state",
",",
"inst",
",",
"not_instance_msg",
"=",
"None",
")",
":",
"state",
".",
"assert_is",
"(",
"[",
"\"object_assignments\"",
"]",
",",
"\"is_instance\"",
",",
"[",
"\"check_object\"",
"]",
")",
"sol_name",
"=",
"state",
"."... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_df | Check whether a DataFrame was defined and it is the right type
``check_df()`` is a combo of ``check_object()`` and ``is_instance()`` that checks whether the specified object exists
and whether the specified object is pandas DataFrame.
You can continue checking the data frame with ``check_keys()`` func... | pythonwhat/checks/check_object.py | def check_df(
state, index, missing_msg=None, not_instance_msg=None, expand_msg=None
):
"""Check whether a DataFrame was defined and it is the right type
``check_df()`` is a combo of ``check_object()`` and ``is_instance()`` that checks whether the specified object exists
and whether the specified o... | def check_df(
state, index, missing_msg=None, not_instance_msg=None, expand_msg=None
):
"""Check whether a DataFrame was defined and it is the right type
``check_df()`` is a combo of ``check_object()`` and ``is_instance()`` that checks whether the specified object exists
and whether the specified o... | [
"Check",
"whether",
"a",
"DataFrame",
"was",
"defined",
"and",
"it",
"is",
"the",
"right",
"type",
"check_df",
"()",
"is",
"a",
"combo",
"of",
"check_object",
"()",
"and",
"is_instance",
"()",
"that",
"checks",
"whether",
"the",
"specified",
"object",
"exist... | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_object.py#L246-L296 | [
"def",
"check_df",
"(",
"state",
",",
"index",
",",
"missing_msg",
"=",
"None",
",",
"not_instance_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
")",
":",
"child",
"=",
"check_object",
"(",
"state",
",",
"index",
",",
"missing_msg",
"=",
"missing_msg"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_keys | Check whether an object (dict, DataFrame, etc) has a key.
``check_keys()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
key (str): Name of the key that the object should have.
missing_msg (str): Whe... | pythonwhat/checks/check_object.py | def check_keys(state, key, missing_msg=None, expand_msg=None):
"""Check whether an object (dict, DataFrame, etc) has a key.
``check_keys()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
key (str): Name ... | def check_keys(state, key, missing_msg=None, expand_msg=None):
"""Check whether an object (dict, DataFrame, etc) has a key.
``check_keys()`` can currently only be used when chained from ``check_object()``, the function that is
used to 'zoom in' on the object of interest.
Args:
key (str): Name ... | [
"Check",
"whether",
"an",
"object",
"(",
"dict",
"DataFrame",
"etc",
")",
"has",
"a",
"key",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_object.py#L299-L369 | [
"def",
"check_keys",
"(",
"state",
",",
"key",
",",
"missing_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
")",
":",
"state",
".",
"assert_is",
"(",
"[",
"\"object_assignments\"",
"]",
",",
"\"is_instance\"",
",",
"[",
"\"check_object\"",
",",
"\"check_... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | TargetVars.defined_items | Return copy of instance, omitting entries that are EMPTY | pythonwhat/parsing.py | def defined_items(self):
"""Return copy of instance, omitting entries that are EMPTY"""
return self.__class__(
[(k, v) for k, v in self.items() if v is not self.EMPTY], is_empty=False
) | def defined_items(self):
"""Return copy of instance, omitting entries that are EMPTY"""
return self.__class__(
[(k, v) for k, v in self.items() if v is not self.EMPTY], is_empty=False
) | [
"Return",
"copy",
"of",
"instance",
"omitting",
"entries",
"that",
"are",
"EMPTY"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/parsing.py#L60-L64 | [
"def",
"defined_items",
"(",
"self",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"self",
".",
"EMPTY",
"]",
",",
"is_empty"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | State.to_child | Dive into nested tree.
Set the current state as a state with a subtree of this syntax tree as
student tree and solution tree. This is necessary when testing if statements or
for loops for example. | pythonwhat/State.py | def to_child(self, append_message="", node_name="", **kwargs):
"""Dive into nested tree.
Set the current state as a state with a subtree of this syntax tree as
student tree and solution tree. This is necessary when testing if statements or
for loops for example.
"""
base... | def to_child(self, append_message="", node_name="", **kwargs):
"""Dive into nested tree.
Set the current state as a state with a subtree of this syntax tree as
student tree and solution tree. This is necessary when testing if statements or
for loops for example.
"""
base... | [
"Dive",
"into",
"nested",
"tree",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/State.py#L109-L166 | [
"def",
"to_child",
"(",
"self",
",",
"append_message",
"=",
"\"\"",
",",
"node_name",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"base_kwargs",
"=",
"{",
"attr",
":",
"getattr",
"(",
"self",
",",
"attr",
")",
"for",
"attr",
"in",
"self",
".",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | Dispatcher._getx | getter for Parser outputs | pythonwhat/State.py | def _getx(self, Parser, ext_attr, tree):
"""getter for Parser outputs"""
# return cached output if possible
cache_key = Parser.__name__ + str(hash(tree))
if self._parser_cache.get(cache_key):
p = self._parser_cache[cache_key]
else:
# otherwise, run parser ... | def _getx(self, Parser, ext_attr, tree):
"""getter for Parser outputs"""
# return cached output if possible
cache_key = Parser.__name__ + str(hash(tree))
if self._parser_cache.get(cache_key):
p = self._parser_cache[cache_key]
else:
# otherwise, run parser ... | [
"getter",
"for",
"Parser",
"outputs"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/State.py#L282-L301 | [
"def",
"_getx",
"(",
"self",
",",
"Parser",
",",
"ext_attr",
",",
"tree",
")",
":",
"# return cached output if possible",
"cache_key",
"=",
"Parser",
".",
"__name__",
"+",
"str",
"(",
"hash",
"(",
"tree",
")",
")",
"if",
"self",
".",
"_parser_cache",
".",
... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_context_loop | When dispatched on loops, has_context the target vars are the attribute _target_vars.
Note: This is to allow people to call has_context on a node (e.g. for_loop) rather than
one of its attributes (e.g. body). Purely for convenience. | pythonwhat/checks/check_has_context.py | def has_context_loop(state, incorrect_msg, exact_names):
"""When dispatched on loops, has_context the target vars are the attribute _target_vars.
Note: This is to allow people to call has_context on a node (e.g. for_loop) rather than
one of its attributes (e.g. body). Purely for convenience.
"""
... | def has_context_loop(state, incorrect_msg, exact_names):
"""When dispatched on loops, has_context the target vars are the attribute _target_vars.
Note: This is to allow people to call has_context on a node (e.g. for_loop) rather than
one of its attributes (e.g. body). Purely for convenience.
"""
... | [
"When",
"dispatched",
"on",
"loops",
"has_context",
"the",
"target",
"vars",
"are",
"the",
"attribute",
"_target_vars",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_has_context.py#L64-L76 | [
"def",
"has_context_loop",
"(",
"state",
",",
"incorrect_msg",
",",
"exact_names",
")",
":",
"return",
"_test",
"(",
"state",
",",
"incorrect_msg",
"or",
"MSG_INCORRECT_LOOP",
",",
"exact_names",
",",
"tv_name",
"=",
"\"_target_vars\"",
",",
"highlight_name",
"=",... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | has_context_with | When dispatched on with statements, has_context loops over each context manager.
Note: This is to allow people to call has_context on the with statement, rather than
having to manually loop over each context manager.
e.g. Ex().check_with(0).has_context() vs Ex().check_with(0).check_context(0).... | pythonwhat/checks/check_has_context.py | def has_context_with(state, incorrect_msg, exact_names):
"""When dispatched on with statements, has_context loops over each context manager.
Note: This is to allow people to call has_context on the with statement, rather than
having to manually loop over each context manager.
e.g. Ex().che... | def has_context_with(state, incorrect_msg, exact_names):
"""When dispatched on with statements, has_context loops over each context manager.
Note: This is to allow people to call has_context on the with statement, rather than
having to manually loop over each context manager.
e.g. Ex().che... | [
"When",
"dispatched",
"on",
"with",
"statements",
"has_context",
"loops",
"over",
"each",
"context",
"manager",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_has_context.py#L80-L93 | [
"def",
"has_context_with",
"(",
"state",
",",
"incorrect_msg",
",",
"exact_names",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"state",
".",
"solution_parts",
"[",
"\"context\"",
"]",
")",
")",
":",
"ctxt_state",
"=",
"check_part_index",
"(",
"st... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_part | Return child state with name part as its ast tree | pythonwhat/checks/check_funcs.py | def check_part(state, name, part_msg, missing_msg=None, expand_msg=None):
"""Return child state with name part as its ast tree"""
if missing_msg is None:
missing_msg = "Are you sure you defined the {{part}}? "
if expand_msg is None:
expand_msg = "Did you correctly specify the {{part}}? "
... | def check_part(state, name, part_msg, missing_msg=None, expand_msg=None):
"""Return child state with name part as its ast tree"""
if missing_msg is None:
missing_msg = "Are you sure you defined the {{part}}? "
if expand_msg is None:
expand_msg = "Did you correctly specify the {{part}}? "
... | [
"Return",
"child",
"state",
"with",
"name",
"part",
"as",
"its",
"ast",
"tree"
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_funcs.py#L52-L71 | [
"def",
"check_part",
"(",
"state",
",",
"name",
",",
"part_msg",
",",
"missing_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
")",
":",
"if",
"missing_msg",
"is",
"None",
":",
"missing_msg",
"=",
"\"Are you sure you defined the {{part}}? \"",
"if",
"expand_m... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_part_index | Return child state with indexed name part as its ast tree.
``index`` can be:
- an integer, in which case the student/solution_parts are indexed by position.
- a string, in which case the student/solution_parts are expected to be a dictionary.
- a list of indices (which can be integer or string), in wh... | pythonwhat/checks/check_funcs.py | def check_part_index(state, name, index, part_msg, missing_msg=None, expand_msg=None):
"""Return child state with indexed name part as its ast tree.
``index`` can be:
- an integer, in which case the student/solution_parts are indexed by position.
- a string, in which case the student/solution_parts ar... | def check_part_index(state, name, index, part_msg, missing_msg=None, expand_msg=None):
"""Return child state with indexed name part as its ast tree.
``index`` can be:
- an integer, in which case the student/solution_parts are indexed by position.
- a string, in which case the student/solution_parts ar... | [
"Return",
"child",
"state",
"with",
"indexed",
"name",
"part",
"as",
"its",
"ast",
"tree",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_funcs.py#L74-L114 | [
"def",
"check_part_index",
"(",
"state",
",",
"name",
",",
"index",
",",
"part_msg",
",",
"missing_msg",
"=",
"None",
",",
"expand_msg",
"=",
"None",
")",
":",
"if",
"missing_msg",
"is",
"None",
":",
"missing_msg",
"=",
"\"Are you sure you defined the {{part}}? ... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_args | Check whether a function argument is specified.
This function can follow ``check_function()`` in an SCT chain and verifies whether an argument is specified.
If you want to go on and check whether the argument was correctly specified, you can can continue chaining with
``has_equal_value()`` (value-based che... | pythonwhat/checks/check_funcs.py | def check_args(state, name, missing_msg=None):
"""Check whether a function argument is specified.
This function can follow ``check_function()`` in an SCT chain and verifies whether an argument is specified.
If you want to go on and check whether the argument was correctly specified, you can can continue ch... | def check_args(state, name, missing_msg=None):
"""Check whether a function argument is specified.
This function can follow ``check_function()`` in an SCT chain and verifies whether an argument is specified.
If you want to go on and check whether the argument was correctly specified, you can can continue ch... | [
"Check",
"whether",
"a",
"function",
"argument",
"is",
"specified",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_funcs.py#L212-L280 | [
"def",
"check_args",
"(",
"state",
",",
"name",
",",
"missing_msg",
"=",
"None",
")",
":",
"if",
"missing_msg",
"is",
"None",
":",
"missing_msg",
"=",
"\"Did you specify the {{part}}?\"",
"if",
"name",
"in",
"[",
"\"*args\"",
",",
"\"**kwargs\"",
"]",
":",
"... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | check_call | When checking a function definition of lambda function,
prepare has_equal_x for checking the call of a user-defined function.
Args:
callstr (str): call string that specifies how the function should be called, e.g. `f(1, a = 2)`.
``check_call()`` will replace ``f`` with the function/lambda yo... | pythonwhat/checks/check_funcs.py | def check_call(state, callstr, argstr=None, expand_msg=None):
"""When checking a function definition of lambda function,
prepare has_equal_x for checking the call of a user-defined function.
Args:
callstr (str): call string that specifies how the function should be called, e.g. `f(1, a = 2)`.
... | def check_call(state, callstr, argstr=None, expand_msg=None):
"""When checking a function definition of lambda function,
prepare has_equal_x for checking the call of a user-defined function.
Args:
callstr (str): call string that specifies how the function should be called, e.g. `f(1, a = 2)`.
... | [
"When",
"checking",
"a",
"function",
"definition",
"of",
"lambda",
"function",
"prepare",
"has_equal_x",
"for",
"checking",
"the",
"call",
"of",
"a",
"user",
"-",
"defined",
"function",
"."
] | datacamp/pythonwhat | python | https://github.com/datacamp/pythonwhat/blob/ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f/pythonwhat/checks/check_funcs.py#L302-L344 | [
"def",
"check_call",
"(",
"state",
",",
"callstr",
",",
"argstr",
"=",
"None",
",",
"expand_msg",
"=",
"None",
")",
":",
"state",
".",
"assert_is",
"(",
"[",
"\"function_defs\"",
",",
"\"lambda_functions\"",
"]",
",",
"\"check_call\"",
",",
"[",
"\"check_fun... | ffbf7f8436a51f77c22f3bed75ba3bc37a5c666f |
test | detect_openmp | Does this compiler support OpenMP parallelization? | setup.py | def detect_openmp():
"""Does this compiler support OpenMP parallelization?"""
compiler = new_compiler()
print("Checking for OpenMP support... ")
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
if not hasopenmp:
compiler.add_library('gomp')
hasopenmp = hasfunction(compiler, 'om... | def detect_openmp():
"""Does this compiler support OpenMP parallelization?"""
compiler = new_compiler()
print("Checking for OpenMP support... ")
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
if not hasopenmp:
compiler.add_library('gomp')
hasopenmp = hasfunction(compiler, 'om... | [
"Does",
"this",
"compiler",
"support",
"OpenMP",
"parallelization?"
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/setup.py#L16-L28 | [
"def",
"detect_openmp",
"(",
")",
":",
"compiler",
"=",
"new_compiler",
"(",
")",
"print",
"(",
"\"Checking for OpenMP support... \"",
")",
"hasopenmp",
"=",
"hasfunction",
"(",
"compiler",
",",
"'omp_get_num_threads()'",
")",
"needs_gomp",
"=",
"hasopenmp",
"if",
... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | make_plots | zs = np.linspace(0., 1., 1000)
rp = 0.1
wrapped = wrapper(_quadratic_ld._quadratic_ld, zs, rp, 0.1, 0.3, 1)
t = timeit.timeit(wrapped,number=10000)
print("time:", t) | batman/plots.py | def make_plots():
import matplotlib.pyplot as plt
"""zs = np.linspace(0., 1., 1000)
rp = 0.1
wrapped = wrapper(_quadratic_ld._quadratic_ld, zs, rp, 0.1, 0.3, 1)
t = timeit.timeit(wrapped,number=10000)
print("time:", t)"""
"""zs = np.linspace(0., 1., 1000)
rp = 0.1
u = [0., 0.7, 0.0, -0.3]
f = _nonlinear_ld._n... | def make_plots():
import matplotlib.pyplot as plt
"""zs = np.linspace(0., 1., 1000)
rp = 0.1
wrapped = wrapper(_quadratic_ld._quadratic_ld, zs, rp, 0.1, 0.3, 1)
t = timeit.timeit(wrapped,number=10000)
print("time:", t)"""
"""zs = np.linspace(0., 1., 1000)
rp = 0.1
u = [0., 0.7, 0.0, -0.3]
f = _nonlinear_ld._n... | [
"zs",
"=",
"np",
".",
"linspace",
"(",
"0",
".",
"1",
".",
"1000",
")",
"rp",
"=",
"0",
".",
"1",
"wrapped",
"=",
"wrapper",
"(",
"_quadratic_ld",
".",
"_quadratic_ld",
"zs",
"rp",
"0",
".",
"1",
"0",
".",
"3",
"1",
")",
"t",
"=",
"timeit",
"... | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/plots.py#L34-L83 | [
"def",
"make_plots",
"(",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"\"\"\"zs = np.linspace(0., 1., 1000)\n\trp = 0.1\n\tu = [0., 0.7, 0.0, -0.3]\n\tf = _nonlinear_ld._nonlinear_ld(zs, rp, u[0], u[1], u[2], u[3], 1.0e-2, 4)\n\tfhi = _nonlinear_ld._nonlinear_ld(zs, rp, u[0],... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | TransitModel.light_curve | Calculate a model light curve.
:param params: Transit parameters
:type params: A `TransitParams` instance
:return: Relative flux
:rtype: ndarray
:Example:
>>> flux = m.light_curve(params) | batman/transitmodel.py | def light_curve(self, params):
"""
Calculate a model light curve.
:param params: Transit parameters
:type params: A `TransitParams` instance
:return: Relative flux
:rtype: ndarray
:Example:
>>> flux = m.light_curve(params)
"""
#recalculates rsky and fac if necessary
if params.t0 != self.t0 or... | def light_curve(self, params):
"""
Calculate a model light curve.
:param params: Transit parameters
:type params: A `TransitParams` instance
:return: Relative flux
:rtype: ndarray
:Example:
>>> flux = m.light_curve(params)
"""
#recalculates rsky and fac if necessary
if params.t0 != self.t0 or... | [
"Calculate",
"a",
"model",
"light",
"curve",
"."
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L215-L273 | [
"def",
"light_curve",
"(",
"self",
",",
"params",
")",
":",
"#recalculates rsky and fac if necessary",
"if",
"params",
".",
"t0",
"!=",
"self",
".",
"t0",
"or",
"params",
".",
"per",
"!=",
"self",
".",
"per",
"or",
"params",
".",
"a",
"!=",
"self",
".",
... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | TransitModel.get_t_periastron | Return the time of periastron passage (calculated using `params.t0`). | batman/transitmodel.py | def get_t_periastron(self, params):
"""
Return the time of periastron passage (calculated using `params.t0`).
"""
phase = self._get_phase(params, "primary")
return params.t0 - params.per*phase | def get_t_periastron(self, params):
"""
Return the time of periastron passage (calculated using `params.t0`).
"""
phase = self._get_phase(params, "primary")
return params.t0 - params.per*phase | [
"Return",
"the",
"time",
"of",
"periastron",
"passage",
"(",
"calculated",
"using",
"params",
".",
"t0",
")",
"."
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L284-L289 | [
"def",
"get_t_periastron",
"(",
"self",
",",
"params",
")",
":",
"phase",
"=",
"self",
".",
"_get_phase",
"(",
"params",
",",
"\"primary\"",
")",
"return",
"params",
".",
"t0",
"-",
"params",
".",
"per",
"*",
"phase"
] | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | TransitModel.get_t_secondary | Return the time of secondary eclipse center (calculated using `params.t0`). | batman/transitmodel.py | def get_t_secondary(self, params):
"""
Return the time of secondary eclipse center (calculated using `params.t0`).
"""
phase = self._get_phase(params, "primary")
phase2 = self._get_phase(params, "secondary")
return params.t0 + params.per*(phase2-phase) | def get_t_secondary(self, params):
"""
Return the time of secondary eclipse center (calculated using `params.t0`).
"""
phase = self._get_phase(params, "primary")
phase2 = self._get_phase(params, "secondary")
return params.t0 + params.per*(phase2-phase) | [
"Return",
"the",
"time",
"of",
"secondary",
"eclipse",
"center",
"(",
"calculated",
"using",
"params",
".",
"t0",
")",
"."
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L291-L297 | [
"def",
"get_t_secondary",
"(",
"self",
",",
"params",
")",
":",
"phase",
"=",
"self",
".",
"_get_phase",
"(",
"params",
",",
"\"primary\"",
")",
"phase2",
"=",
"self",
".",
"_get_phase",
"(",
"params",
",",
"\"secondary\"",
")",
"return",
"params",
".",
... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | TransitModel.get_t_conjunction | Return the time of primary transit center (calculated using `params.t_secondary`). | batman/transitmodel.py | def get_t_conjunction(self, params):
"""
Return the time of primary transit center (calculated using `params.t_secondary`).
"""
phase = self._get_phase(params, "primary")
phase2 = self._get_phase(params, "secondary")
return params.t_secondary + params.per*(phase-phase2) | def get_t_conjunction(self, params):
"""
Return the time of primary transit center (calculated using `params.t_secondary`).
"""
phase = self._get_phase(params, "primary")
phase2 = self._get_phase(params, "secondary")
return params.t_secondary + params.per*(phase-phase2) | [
"Return",
"the",
"time",
"of",
"primary",
"transit",
"center",
"(",
"calculated",
"using",
"params",
".",
"t_secondary",
")",
"."
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L299-L305 | [
"def",
"get_t_conjunction",
"(",
"self",
",",
"params",
")",
":",
"phase",
"=",
"self",
".",
"_get_phase",
"(",
"params",
",",
"\"primary\"",
")",
"phase2",
"=",
"self",
".",
"_get_phase",
"(",
"params",
",",
"\"secondary\"",
")",
"return",
"params",
".",
... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | TransitModel.get_true_anomaly | Return the true anomaly at each time | batman/transitmodel.py | def get_true_anomaly(self):
"""
Return the true anomaly at each time
"""
self.f = _rsky._getf(self.t_supersample, self.t0, self.per, self.a,
self.inc*pi/180., self.ecc, self.w*pi/180.,
self.transittype, self.nthreads)
return self.f | def get_true_anomaly(self):
"""
Return the true anomaly at each time
"""
self.f = _rsky._getf(self.t_supersample, self.t0, self.per, self.a,
self.inc*pi/180., self.ecc, self.w*pi/180.,
self.transittype, self.nthreads)
return self.f | [
"Return",
"the",
"true",
"anomaly",
"at",
"each",
"time"
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/transitmodel.py#L307-L314 | [
"def",
"get_true_anomaly",
"(",
"self",
")",
":",
"self",
".",
"f",
"=",
"_rsky",
".",
"_getf",
"(",
"self",
".",
"t_supersample",
",",
"self",
".",
"t0",
",",
"self",
".",
"per",
",",
"self",
".",
"a",
",",
"self",
".",
"inc",
"*",
"pi",
"/",
... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | detect | Does this compiler support OpenMP parallelization? | batman/openmp.py | def detect():
"""Does this compiler support OpenMP parallelization?"""
compiler = new_compiler()
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
if not hasopenmp:
compiler.add_library('gomp')
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
re... | def detect():
"""Does this compiler support OpenMP parallelization?"""
compiler = new_compiler()
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
if not hasopenmp:
compiler.add_library('gomp')
hasopenmp = hasfunction(compiler, 'omp_get_num_threads()')
needs_gomp = hasopenmp
re... | [
"Does",
"this",
"compiler",
"support",
"OpenMP",
"parallelization?"
] | lkreidberg/batman | python | https://github.com/lkreidberg/batman/blob/77f3275c12a01ef5b7a89b1aeb6272a7c28452a1/batman/openmp.py#L15-L24 | [
"def",
"detect",
"(",
")",
":",
"compiler",
"=",
"new_compiler",
"(",
")",
"hasopenmp",
"=",
"hasfunction",
"(",
"compiler",
",",
"'omp_get_num_threads()'",
")",
"needs_gomp",
"=",
"hasopenmp",
"if",
"not",
"hasopenmp",
":",
"compiler",
".",
"add_library",
"("... | 77f3275c12a01ef5b7a89b1aeb6272a7c28452a1 |
test | LDAPLoginForm.validate_ldap | Validate the username/password data against ldap directory | flask_ldap3_login/forms.py | def validate_ldap(self):
logging.debug('Validating LDAPLoginForm against LDAP')
'Validate the username/password data against ldap directory'
ldap_mgr = current_app.ldap3_login_manager
username = self.username.data
password = self.password.data
result = ldap_mgr.authentic... | def validate_ldap(self):
logging.debug('Validating LDAPLoginForm against LDAP')
'Validate the username/password data against ldap directory'
ldap_mgr = current_app.ldap3_login_manager
username = self.username.data
password = self.password.data
result = ldap_mgr.authentic... | [
"Validate",
"the",
"username",
"/",
"password",
"data",
"against",
"ldap",
"directory"
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/forms.py#L31-L53 | [
"def",
"validate_ldap",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"'Validating LDAPLoginForm against LDAP'",
")",
"ldap_mgr",
"=",
"current_app",
".",
"ldap3_login_manager",
"username",
"=",
"self",
".",
"username",
".",
"data",
"password",
"=",
"self",... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAPLoginForm.validate | Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
also calls `validate_ldap` | flask_ldap3_login/forms.py | def validate(self, *args, **kwargs):
"""
Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
also calls `validate_ldap`
"""
valid = FlaskForm.validate(self, *args, **kwargs)
if ... | def validate(self, *args, **kwargs):
"""
Validates the form by calling `validate` on each field, passing any
extra `Form.validate_<fieldname>` validators to the field validator.
also calls `validate_ldap`
"""
valid = FlaskForm.validate(self, *args, **kwargs)
if ... | [
"Validates",
"the",
"form",
"by",
"calling",
"validate",
"on",
"each",
"field",
"passing",
"any",
"extra",
"Form",
".",
"validate_<fieldname",
">",
"validators",
"to",
"the",
"field",
"validator",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/forms.py#L55-L69 | [
"def",
"validate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"valid",
"=",
"FlaskForm",
".",
"validate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"valid",
":",
"logging",
".",
"debug",
"(",... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.init_app | Configures this extension with the given app. This registers an
``teardown_appcontext`` call, and attaches this ``LDAP3LoginManager``
to it as ``app.ldap3_login_manager``.
Args:
app (flask.Flask): The flask app to initialise with | flask_ldap3_login/__init__.py | def init_app(self, app):
'''
Configures this extension with the given app. This registers an
``teardown_appcontext`` call, and attaches this ``LDAP3LoginManager``
to it as ``app.ldap3_login_manager``.
Args:
app (flask.Flask): The flask app to initialise with
... | def init_app(self, app):
'''
Configures this extension with the given app. This registers an
``teardown_appcontext`` call, and attaches this ``LDAP3LoginManager``
to it as ``app.ldap3_login_manager``.
Args:
app (flask.Flask): The flask app to initialise with
... | [
"Configures",
"this",
"extension",
"with",
"the",
"given",
"app",
".",
"This",
"registers",
"an",
"teardown_appcontext",
"call",
"and",
"attaches",
"this",
"LDAP3LoginManager",
"to",
"it",
"as",
"app",
".",
"ldap3_login_manager",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L63-L86 | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"app",
".",
"ldap3_login_manager",
"=",
"self",
"servers",
"=",
"list",
"(",
"self",
".",
"_server_pool",
")",
"for",
"s",
"in",
"servers",
":",
"self",
".",
"_server_pool",
".",
"remove",
"(",
"s",... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.init_config | Configures this extension with a given configuration dictionary.
This allows use of this extension without a flask app.
Args:
config (dict): A dictionary with configuration keys | flask_ldap3_login/__init__.py | def init_config(self, config):
'''
Configures this extension with a given configuration dictionary.
This allows use of this extension without a flask app.
Args:
config (dict): A dictionary with configuration keys
'''
self.config.update(config)
self.... | def init_config(self, config):
'''
Configures this extension with a given configuration dictionary.
This allows use of this extension without a flask app.
Args:
config (dict): A dictionary with configuration keys
'''
self.config.update(config)
self.... | [
"Configures",
"this",
"extension",
"with",
"a",
"given",
"configuration",
"dictionary",
".",
"This",
"allows",
"use",
"of",
"this",
"extension",
"without",
"a",
"flask",
"app",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L88-L146 | [
"def",
"init_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"config",
".",
"update",
"(",
"config",
")",
"self",
".",
"config",
".",
"setdefault",
"(",
"'LDAP_PORT'",
",",
"389",
")",
"self",
".",
"config",
".",
"setdefault",
"(",
"'LDAP_H... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.add_server | Add an additional server to the server pool and return the
freshly created server.
Args:
hostname (str): Hostname of the server
port (int): Port of the server
use_ssl (bool): True if SSL is to be used when connecting.
tls_ctx (ldap3.Tls): An optional TLS ... | flask_ldap3_login/__init__.py | def add_server(self, hostname, port, use_ssl, tls_ctx=None):
"""
Add an additional server to the server pool and return the
freshly created server.
Args:
hostname (str): Hostname of the server
port (int): Port of the server
use_ssl (bool): True if SSL... | def add_server(self, hostname, port, use_ssl, tls_ctx=None):
"""
Add an additional server to the server pool and return the
freshly created server.
Args:
hostname (str): Hostname of the server
port (int): Port of the server
use_ssl (bool): True if SSL... | [
"Add",
"an",
"additional",
"server",
"to",
"the",
"server",
"pool",
"and",
"return",
"the",
"freshly",
"created",
"server",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L148-L172 | [
"def",
"add_server",
"(",
"self",
",",
"hostname",
",",
"port",
",",
"use_ssl",
",",
"tls_ctx",
"=",
"None",
")",
":",
"if",
"not",
"use_ssl",
"and",
"tls_ctx",
":",
"raise",
"ValueError",
"(",
"\"Cannot specify a TLS context and not use SSL!\"",
")",
"server",
... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager._contextualise_connection | Add a connection to the appcontext so it can be freed/unbound at
a later time if an exception occured and it was not freed.
Args:
connection (ldap3.Connection): Connection to add to the appcontext | flask_ldap3_login/__init__.py | def _contextualise_connection(self, connection):
"""
Add a connection to the appcontext so it can be freed/unbound at
a later time if an exception occured and it was not freed.
Args:
connection (ldap3.Connection): Connection to add to the appcontext
"""
ctx... | def _contextualise_connection(self, connection):
"""
Add a connection to the appcontext so it can be freed/unbound at
a later time if an exception occured and it was not freed.
Args:
connection (ldap3.Connection): Connection to add to the appcontext
"""
ctx... | [
"Add",
"a",
"connection",
"to",
"the",
"appcontext",
"so",
"it",
"can",
"be",
"freed",
"/",
"unbound",
"at",
"a",
"later",
"time",
"if",
"an",
"exception",
"occured",
"and",
"it",
"was",
"not",
"freed",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L174-L189 | [
"def",
"_contextualise_connection",
"(",
"self",
",",
"connection",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"is",
"not",
"None",
":",
"if",
"not",
"hasattr",
"(",
"ctx",
",",
"'ldap3_manager_connections'",
")",
":",
"ctx",
".",
"ldap3_manag... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager._decontextualise_connection | Remove a connection from the appcontext.
Args:
connection (ldap3.Connection): connection to remove from the
appcontext | flask_ldap3_login/__init__.py | def _decontextualise_connection(self, connection):
"""
Remove a connection from the appcontext.
Args:
connection (ldap3.Connection): connection to remove from the
appcontext
"""
ctx = stack.top
if ctx is not None and connection in ctx.ldap3_... | def _decontextualise_connection(self, connection):
"""
Remove a connection from the appcontext.
Args:
connection (ldap3.Connection): connection to remove from the
appcontext
"""
ctx = stack.top
if ctx is not None and connection in ctx.ldap3_... | [
"Remove",
"a",
"connection",
"from",
"the",
"appcontext",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L191-L203 | [
"def",
"_decontextualise_connection",
"(",
"self",
",",
"connection",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"is",
"not",
"None",
"and",
"connection",
"in",
"ctx",
".",
"ldap3_manager_connections",
":",
"ctx",
".",
"ldap3_manager_connections",
... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.teardown | Cleanup after a request. Close any open connections. | flask_ldap3_login/__init__.py | def teardown(self, exception):
"""
Cleanup after a request. Close any open connections.
"""
ctx = stack.top
if ctx is not None:
if hasattr(ctx, 'ldap3_manager_connections'):
for connection in ctx.ldap3_manager_connections:
self.des... | def teardown(self, exception):
"""
Cleanup after a request. Close any open connections.
"""
ctx = stack.top
if ctx is not None:
if hasattr(ctx, 'ldap3_manager_connections'):
for connection in ctx.ldap3_manager_connections:
self.des... | [
"Cleanup",
"after",
"a",
"request",
".",
"Close",
"any",
"open",
"connections",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L205-L219 | [
"def",
"teardown",
"(",
"self",
",",
"exception",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"is",
"not",
"None",
":",
"if",
"hasattr",
"(",
"ctx",
",",
"'ldap3_manager_connections'",
")",
":",
"for",
"connection",
"in",
"ctx",
".",
"ldap3... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.authenticate | An abstracted authentication method. Decides whether to perform a
direct bind or a search bind based upon the login attribute configured
in the config.
Args:
username (str): Username of the user to bind
password (str): User's password to bind with.
Returns:
... | flask_ldap3_login/__init__.py | def authenticate(self, username, password):
"""
An abstracted authentication method. Decides whether to perform a
direct bind or a search bind based upon the login attribute configured
in the config.
Args:
username (str): Username of the user to bind
pass... | def authenticate(self, username, password):
"""
An abstracted authentication method. Decides whether to perform a
direct bind or a search bind based upon the login attribute configured
in the config.
Args:
username (str): Username of the user to bind
pass... | [
"An",
"abstracted",
"authentication",
"method",
".",
"Decides",
"whether",
"to",
"perform",
"a",
"direct",
"bind",
"or",
"a",
"search",
"bind",
"based",
"upon",
"the",
"login",
"attribute",
"configured",
"in",
"the",
"config",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L247-L275 | [
"def",
"authenticate",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_BIND_DIRECT_CREDENTIALS'",
")",
":",
"result",
"=",
"self",
".",
"authenticate_direct_credentials",
"(",
"username",
",",
"pass... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.authenticate_direct_credentials | Performs a direct bind, however using direct credentials. Can be used
if interfacing with an Active Directory domain controller which
authenticates using username@domain.com directly.
Performing this kind of lookup limits the information we can get from
ldap. Instead we can only deduce ... | flask_ldap3_login/__init__.py | def authenticate_direct_credentials(self, username, password):
"""
Performs a direct bind, however using direct credentials. Can be used
if interfacing with an Active Directory domain controller which
authenticates using username@domain.com directly.
Performing this kind of look... | def authenticate_direct_credentials(self, username, password):
"""
Performs a direct bind, however using direct credentials. Can be used
if interfacing with an Active Directory domain controller which
authenticates using username@domain.com directly.
Performing this kind of look... | [
"Performs",
"a",
"direct",
"bind",
"however",
"using",
"direct",
"credentials",
".",
"Can",
"be",
"used",
"if",
"interfacing",
"with",
"an",
"Active",
"Directory",
"domain",
"controller",
"which",
"authenticates",
"using",
"username@domain",
".",
"com",
"directly"... | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L277-L356 | [
"def",
"authenticate_direct_credentials",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"bind_user",
"=",
"'{}{}{}'",
".",
"format",
"(",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_BIND_DIRECT_PREFIX'",
")",
",",
"username",
",",
"self",
".",
... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.authenticate_direct_bind | Performs a direct bind. We can do this since the RDN is the same
as the login attribute. Hence we just string together a dn to find
this user with.
Args:
username (str): Username of the user to bind (the field specified
as LDAP_BIND_RDN_ATTR)
password (st... | flask_ldap3_login/__init__.py | def authenticate_direct_bind(self, username, password):
"""
Performs a direct bind. We can do this since the RDN is the same
as the login attribute. Hence we just string together a dn to find
this user with.
Args:
username (str): Username of the user to bind (the fie... | def authenticate_direct_bind(self, username, password):
"""
Performs a direct bind. We can do this since the RDN is the same
as the login attribute. Hence we just string together a dn to find
this user with.
Args:
username (str): Username of the user to bind (the fie... | [
"Performs",
"a",
"direct",
"bind",
".",
"We",
"can",
"do",
"this",
"since",
"the",
"RDN",
"is",
"the",
"same",
"as",
"the",
"login",
"attribute",
".",
"Hence",
"we",
"just",
"string",
"together",
"a",
"dn",
"to",
"find",
"this",
"user",
"with",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L358-L411 | [
"def",
"authenticate_direct_bind",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"bind_user",
"=",
"'{rdn}={username},{user_search_dn}'",
".",
"format",
"(",
"rdn",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_USER_RDN_ATTR'",
")",
",",
"userna... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.authenticate_search_bind | Performs a search bind to authenticate a user. This is
required when a the login attribute is not the same
as the RDN, since we cannot string together their DN on
the fly, instead we have to find it in the LDAP, then attempt
to bind with their credentials.
Args:
user... | flask_ldap3_login/__init__.py | def authenticate_search_bind(self, username, password):
"""
Performs a search bind to authenticate a user. This is
required when a the login attribute is not the same
as the RDN, since we cannot string together their DN on
the fly, instead we have to find it in the LDAP, then att... | def authenticate_search_bind(self, username, password):
"""
Performs a search bind to authenticate a user. This is
required when a the login attribute is not the same
as the RDN, since we cannot string together their DN on
the fly, instead we have to find it in the LDAP, then att... | [
"Performs",
"a",
"search",
"bind",
"to",
"authenticate",
"a",
"user",
".",
"This",
"is",
"required",
"when",
"a",
"the",
"login",
"attribute",
"is",
"not",
"the",
"same",
"as",
"the",
"RDN",
"since",
"we",
"cannot",
"string",
"together",
"their",
"DN",
"... | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L413-L528 | [
"def",
"authenticate_search_bind",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"connection",
"=",
"self",
".",
"_make_connection",
"(",
"bind_user",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_BIND_USER_DN'",
")",
",",
"bind_password",
"="... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.get_user_groups | Gets a list of groups a user at dn is a member of
Args:
dn (str): The dn of the user to find memberships for.
_connection (ldap3.Connection): A connection object to use when
searching. If not given, a temporary connection will be
created, and destroyed af... | flask_ldap3_login/__init__.py | def get_user_groups(self, dn, group_search_dn=None, _connection=None):
"""
Gets a list of groups a user at dn is a member of
Args:
dn (str): The dn of the user to find memberships for.
_connection (ldap3.Connection): A connection object to use when
search... | def get_user_groups(self, dn, group_search_dn=None, _connection=None):
"""
Gets a list of groups a user at dn is a member of
Args:
dn (str): The dn of the user to find memberships for.
_connection (ldap3.Connection): A connection object to use when
search... | [
"Gets",
"a",
"list",
"of",
"groups",
"a",
"user",
"at",
"dn",
"is",
"a",
"member",
"of"
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L530-L591 | [
"def",
"get_user_groups",
"(",
"self",
",",
"dn",
",",
"group_search_dn",
"=",
"None",
",",
"_connection",
"=",
"None",
")",
":",
"connection",
"=",
"_connection",
"if",
"not",
"connection",
":",
"connection",
"=",
"self",
".",
"_make_connection",
"(",
"bind... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.get_user_info | Gets info about a user specified at dn.
Args:
dn (str): The dn of the user to find
_connection (ldap3.Connection): A connection object to use when
searching. If not given, a temporary connection will be
created, and destroyed after use.
Returns:
... | flask_ldap3_login/__init__.py | def get_user_info(self, dn, _connection=None):
"""
Gets info about a user specified at dn.
Args:
dn (str): The dn of the user to find
_connection (ldap3.Connection): A connection object to use when
searching. If not given, a temporary connection will be
... | def get_user_info(self, dn, _connection=None):
"""
Gets info about a user specified at dn.
Args:
dn (str): The dn of the user to find
_connection (ldap3.Connection): A connection object to use when
searching. If not given, a temporary connection will be
... | [
"Gets",
"info",
"about",
"a",
"user",
"specified",
"at",
"dn",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L593-L612 | [
"def",
"get_user_info",
"(",
"self",
",",
"dn",
",",
"_connection",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_object",
"(",
"dn",
"=",
"dn",
",",
"filter",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_USER_OBJECT_FILTER'",
")",
",",
"at... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.get_user_info_for_username | Gets info about a user at a specified username by searching the
Users DN. Username attribute is the same as specified as
LDAP_USER_LOGIN_ATTR.
Args:
username (str): Username of the user to search for.
_connection (ldap3.Connection): A connection object to use when
... | flask_ldap3_login/__init__.py | def get_user_info_for_username(self, username, _connection=None):
"""
Gets info about a user at a specified username by searching the
Users DN. Username attribute is the same as specified as
LDAP_USER_LOGIN_ATTR.
Args:
username (str): Username of the user to search ... | def get_user_info_for_username(self, username, _connection=None):
"""
Gets info about a user at a specified username by searching the
Users DN. Username attribute is the same as specified as
LDAP_USER_LOGIN_ATTR.
Args:
username (str): Username of the user to search ... | [
"Gets",
"info",
"about",
"a",
"user",
"at",
"a",
"specified",
"username",
"by",
"searching",
"the",
"Users",
"DN",
".",
"Username",
"attribute",
"is",
"the",
"same",
"as",
"specified",
"as",
"LDAP_USER_LOGIN_ATTR",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L614-L640 | [
"def",
"get_user_info_for_username",
"(",
"self",
",",
"username",
",",
"_connection",
"=",
"None",
")",
":",
"ldap_filter",
"=",
"'(&({0}={1}){2})'",
".",
"format",
"(",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_USER_LOGIN_ATTR'",
")",
",",
"username",
"... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.get_object | Gets an object at the specified dn and returns it.
Args:
dn (str): The dn of the object to find.
filter (str): The LDAP syntax search filter.
attributes (list): A list of LDAP attributes to get when searching.
_connection (ldap3.Connection): A connection object t... | flask_ldap3_login/__init__.py | def get_object(self, dn, filter, attributes, _connection=None):
"""
Gets an object at the specified dn and returns it.
Args:
dn (str): The dn of the object to find.
filter (str): The LDAP syntax search filter.
attributes (list): A list of LDAP attributes to g... | def get_object(self, dn, filter, attributes, _connection=None):
"""
Gets an object at the specified dn and returns it.
Args:
dn (str): The dn of the object to find.
filter (str): The LDAP syntax search filter.
attributes (list): A list of LDAP attributes to g... | [
"Gets",
"an",
"object",
"at",
"the",
"specified",
"dn",
"and",
"returns",
"it",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L663-L702 | [
"def",
"get_object",
"(",
"self",
",",
"dn",
",",
"filter",
",",
"attributes",
",",
"_connection",
"=",
"None",
")",
":",
"connection",
"=",
"_connection",
"if",
"not",
"connection",
":",
"connection",
"=",
"self",
".",
"_make_connection",
"(",
"bind_user",
... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.connection | Convenience property for externally accessing an authenticated
connection to the server. This connection is automatically
handled by the appcontext, so you do not have to perform an unbind.
Returns:
ldap3.Connection: A bound ldap3.Connection
Raises:
ldap3.core.ex... | flask_ldap3_login/__init__.py | def connection(self):
"""
Convenience property for externally accessing an authenticated
connection to the server. This connection is automatically
handled by the appcontext, so you do not have to perform an unbind.
Returns:
ldap3.Connection: A bound ldap3.Connection... | def connection(self):
"""
Convenience property for externally accessing an authenticated
connection to the server. This connection is automatically
handled by the appcontext, so you do not have to perform an unbind.
Returns:
ldap3.Connection: A bound ldap3.Connection... | [
"Convenience",
"property",
"for",
"externally",
"accessing",
"an",
"authenticated",
"connection",
"to",
"the",
"server",
".",
"This",
"connection",
"is",
"automatically",
"handled",
"by",
"the",
"appcontext",
"so",
"you",
"do",
"not",
"have",
"to",
"perform",
"a... | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L705-L736 | [
"def",
"connection",
"(",
"self",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
"ctx",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Working outside of the Flask application \"",
"\"context. If you wish to make a connection outside of a flask\"",
"\" application conte... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.make_connection | Make a connection to the LDAP Directory.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
config['LDAP_BIND_AUTHENTICATION_TYPE'] is used.
bind_password (str): Password to bind to the dir... | flask_ldap3_login/__init__.py | def make_connection(self, bind_user=None, bind_password=None, **kwargs):
"""
Make a connection to the LDAP Directory.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
config['LDAP_BIN... | def make_connection(self, bind_user=None, bind_password=None, **kwargs):
"""
Make a connection to the LDAP Directory.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
config['LDAP_BIN... | [
"Make",
"a",
"connection",
"to",
"the",
"LDAP",
"Directory",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L738-L756 | [
"def",
"make_connection",
"(",
"self",
",",
"bind_user",
"=",
"None",
",",
"bind_password",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_make_connection",
"(",
"bind_user",
",",
"bind_password",
",",
"contextualise",
"=",
"False",... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager._make_connection | Make a connection.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
config['LDAP_BIND_AUTHENTICATION_TYPE'] is used.
bind_password (str): Password to bind to the directory with
... | flask_ldap3_login/__init__.py | def _make_connection(self, bind_user=None, bind_password=None,
contextualise=True, **kwargs):
"""
Make a connection.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
... | def _make_connection(self, bind_user=None, bind_password=None,
contextualise=True, **kwargs):
"""
Make a connection.
Args:
bind_user (str): User to bind with. If `None`, AUTH_ANONYMOUS is
used, otherwise authentication specified with
... | [
"Make",
"a",
"connection",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L758-L797 | [
"def",
"_make_connection",
"(",
"self",
",",
"bind_user",
"=",
"None",
",",
"bind_password",
"=",
"None",
",",
"contextualise",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"authentication",
"=",
"ldap3",
".",
"ANONYMOUS",
"if",
"bind_user",
":",
"authe... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.destroy_connection | Destroys a connection. Removes the connection from the appcontext, and
unbinds it.
Args:
connection (ldap3.Connection): The connnection to destroy | flask_ldap3_login/__init__.py | def destroy_connection(self, connection):
"""
Destroys a connection. Removes the connection from the appcontext, and
unbinds it.
Args:
connection (ldap3.Connection): The connnection to destroy
"""
log.debug("Destroying connection at <{0}>".format(hex(id(con... | def destroy_connection(self, connection):
"""
Destroys a connection. Removes the connection from the appcontext, and
unbinds it.
Args:
connection (ldap3.Connection): The connnection to destroy
"""
log.debug("Destroying connection at <{0}>".format(hex(id(con... | [
"Destroys",
"a",
"connection",
".",
"Removes",
"the",
"connection",
"from",
"the",
"appcontext",
"and",
"unbinds",
"it",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L799-L810 | [
"def",
"destroy_connection",
"(",
"self",
",",
"connection",
")",
":",
"log",
".",
"debug",
"(",
"\"Destroying connection at <{0}>\"",
".",
"format",
"(",
"hex",
"(",
"id",
"(",
"connection",
")",
")",
")",
")",
"self",
".",
"_decontextualise_connection",
"(",... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | LDAP3LoginManager.compiled_sub_dn | Returns:
str: A DN with the DN Base appended to the end.
Args:
prepend (str): The dn to prepend to the base. | flask_ldap3_login/__init__.py | def compiled_sub_dn(self, prepend):
"""
Returns:
str: A DN with the DN Base appended to the end.
Args:
prepend (str): The dn to prepend to the base.
"""
prepend = prepend.strip()
if prepend == '':
return self.config.get('LDAP_BASE_DN')... | def compiled_sub_dn(self, prepend):
"""
Returns:
str: A DN with the DN Base appended to the end.
Args:
prepend (str): The dn to prepend to the base.
"""
prepend = prepend.strip()
if prepend == '':
return self.config.get('LDAP_BASE_DN')... | [
"Returns",
":",
"str",
":",
"A",
"DN",
"with",
"the",
"DN",
"Base",
"appended",
"to",
"the",
"end",
"."
] | nickw444/flask-ldap3-login | python | https://github.com/nickw444/flask-ldap3-login/blob/3cf0faff52d0e04d4813119a2ba36d706e6fb31f/flask_ldap3_login/__init__.py#L832-L846 | [
"def",
"compiled_sub_dn",
"(",
"self",
",",
"prepend",
")",
":",
"prepend",
"=",
"prepend",
".",
"strip",
"(",
")",
"if",
"prepend",
"==",
"''",
":",
"return",
"self",
".",
"config",
".",
"get",
"(",
"'LDAP_BASE_DN'",
")",
"return",
"'{prepend},{base}'",
... | 3cf0faff52d0e04d4813119a2ba36d706e6fb31f |
test | search | query a s3 endpoint for an image based on a string
EXAMPLE QUERIES:
[empty] list all container collections
vsoch/dinosaur look for containers with name vsoch/dinosaur | sregistry/main/s3/query.py | def search(self, query=None, args=None):
'''query a s3 endpoint for an image based on a string
EXAMPLE QUERIES:
[empty] list all container collections
vsoch/dinosaur look for containers with name vsoch/dinosaur
'''
if query is not None:
return self._container_se... | def search(self, query=None, args=None):
'''query a s3 endpoint for an image based on a string
EXAMPLE QUERIES:
[empty] list all container collections
vsoch/dinosaur look for containers with name vsoch/dinosaur
'''
if query is not None:
return self._container_se... | [
"query",
"a",
"s3",
"endpoint",
"for",
"an",
"image",
"based",
"on",
"a",
"string"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/s3/query.py#L18-L33 | [
"def",
"search",
"(",
"self",
",",
"query",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"if",
"query",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_container_search",
"(",
"query",
")",
"# Search collections across all fields",
"return",
"self",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search_all | a "show all" search that doesn't require a query
Parameters
==========
quiet: if quiet is True, we only are using the function to return
rows of results. | sregistry/main/s3/query.py | def search_all(self, quiet=False):
'''a "show all" search that doesn't require a query
Parameters
==========
quiet: if quiet is True, we only are using the function to return
rows of results.
'''
results = []
for obj in self.bucket.objects.all():
subsr... | def search_all(self, quiet=False):
'''a "show all" search that doesn't require a query
Parameters
==========
quiet: if quiet is True, we only are using the function to return
rows of results.
'''
results = []
for obj in self.bucket.objects.all():
subsr... | [
"a",
"show",
"all",
"search",
"that",
"doesn",
"t",
"require",
"a",
"query",
"Parameters",
"==========",
"quiet",
":",
"if",
"quiet",
"is",
"True",
"we",
"only",
"are",
"using",
"the",
"function",
"to",
"return",
"rows",
"of",
"results",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/s3/query.py#L41-L77 | [
"def",
"search_all",
"(",
"self",
",",
"quiet",
"=",
"False",
")",
":",
"results",
"=",
"[",
"]",
"for",
"obj",
"in",
"self",
".",
"bucket",
".",
"objects",
".",
"all",
"(",
")",
":",
"subsrc",
"=",
"obj",
".",
"Object",
"(",
")",
"# Metadata bug w... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | container_search | search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across collections is True, details are
not shown | sregistry/main/s3/query.py | def container_search(self, query, across_collections=False):
'''search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across c... | def container_search(self, query, across_collections=False):
'''search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across c... | [
"search",
"for",
"a",
"specific",
"container",
".",
"If",
"across",
"collections",
"is",
"False",
"the",
"query",
"is",
"parsed",
"as",
"a",
"full",
"container",
"name",
"and",
"a",
"specific",
"container",
"is",
"returned",
".",
"If",
"across_collections",
... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/s3/query.py#L80-L103 | [
"def",
"container_search",
"(",
"self",
",",
"query",
",",
"across_collections",
"=",
"False",
")",
":",
"results",
"=",
"self",
".",
"_search_all",
"(",
"quiet",
"=",
"True",
")",
"matches",
"=",
"[",
"]",
"for",
"result",
"in",
"results",
":",
"# This ... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search | query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in registry
vsoch do a general search for the expression "vsoch"
vsoch/ list all containers in collection vsoch
/... | sregistry/main/registry/query.py | def search(self, query=None, args=None):
'''query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in registry
vsoch do a general search for the expression "vsoch"
vsoch/ ... | def search(self, query=None, args=None):
'''query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in registry
vsoch do a general search for the expression "vsoch"
vsoch/ ... | [
"query",
"a",
"Singularity",
"registry",
"for",
"a",
"list",
"of",
"images",
".",
"If",
"query",
"is",
"None",
"collections",
"are",
"listed",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/registry/query.py#L20-L55 | [
"def",
"search",
"(",
"self",
",",
"query",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"if",
"query",
"is",
"not",
"None",
":",
"# List all containers in collection query/",
"if",
"query",
".",
"endswith",
"(",
"'/'",
")",
":",
"# collection search",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | collection_search | collection search will list all containers for a specific
collection. We assume query is the name of a collection | sregistry/main/registry/query.py | def collection_search(self, query):
'''collection search will list all containers for a specific
collection. We assume query is the name of a collection'''
query = query.lower().strip('/')
url = '%s/collection/%s' %(self.base, query)
result = self._get(url)
if len(result) == 0:
bot.inf... | def collection_search(self, query):
'''collection search will list all containers for a specific
collection. We assume query is the name of a collection'''
query = query.lower().strip('/')
url = '%s/collection/%s' %(self.base, query)
result = self._get(url)
if len(result) == 0:
bot.inf... | [
"collection",
"search",
"will",
"list",
"all",
"containers",
"for",
"a",
"specific",
"collection",
".",
"We",
"assume",
"query",
"is",
"the",
"name",
"of",
"a",
"collection"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/registry/query.py#L87-L107 | [
"def",
"collection_search",
"(",
"self",
",",
"query",
")",
":",
"query",
"=",
"query",
".",
"lower",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"url",
"=",
"'%s/collection/%s'",
"%",
"(",
"self",
".",
"base",
",",
"query",
")",
"result",
"=",
"self",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | label_search | search across labels | sregistry/main/registry/query.py | def label_search(self, key=None, value=None):
'''search across labels'''
if key is not None:
key = key.lower()
if value is not None:
value = value.lower()
show_details = True
if key is None and value is None:
url = '%s/labels/search' % (self.base)
show_details = Fa... | def label_search(self, key=None, value=None):
'''search across labels'''
if key is not None:
key = key.lower()
if value is not None:
value = value.lower()
show_details = True
if key is None and value is None:
url = '%s/labels/search' % (self.base)
show_details = Fa... | [
"search",
"across",
"labels"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/registry/query.py#L109-L149 | [
"def",
"label_search",
"(",
"self",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"if",
"key",
"is",
"not",
"None",
":",
"key",
"=",
"key",
".",
"lower",
"(",
")",
"if",
"value",
"is",
"not",
"None",
":",
"value",
"=",
"value",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | container_search | search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across collections is True, details are
not shown | sregistry/main/registry/query.py | def container_search(self, query, across_collections=False):
'''search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across c... | def container_search(self, query, across_collections=False):
'''search for a specific container. If across collections is False,
the query is parsed as a full container name and a specific container
is returned. If across_collections is True, the container is searched
for across collections. If across c... | [
"search",
"for",
"a",
"specific",
"container",
".",
"If",
"across",
"collections",
"is",
"False",
"the",
"query",
"is",
"parsed",
"as",
"a",
"full",
"container",
"name",
"and",
"a",
"specific",
"container",
"is",
"returned",
".",
"If",
"across_collections",
... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/registry/query.py#L152-L192 | [
"def",
"container_search",
"(",
"self",
",",
"query",
",",
"across_collections",
"=",
"False",
")",
":",
"query",
"=",
"query",
".",
"lower",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"q",
"=",
"parse_image_name",
"(",
"remove_uri",
"(",
"query",
")",
"... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search | query a GitLab artifacts folder for a list of images.
If query is None, collections are listed. | sregistry/main/gitlab/query.py | def search(self, query=None, args=None):
'''query a GitLab artifacts folder for a list of images.
If query is None, collections are listed.
'''
if query is None:
bot.exit('You must include a collection query, <collection>/<repo>')
# or default to listing (searching) all things.
retur... | def search(self, query=None, args=None):
'''query a GitLab artifacts folder for a list of images.
If query is None, collections are listed.
'''
if query is None:
bot.exit('You must include a collection query, <collection>/<repo>')
# or default to listing (searching) all things.
retur... | [
"query",
"a",
"GitLab",
"artifacts",
"folder",
"for",
"a",
"list",
"of",
"images",
".",
"If",
"query",
"is",
"None",
"collections",
"are",
"listed",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/gitlab/query.py#L26-L34 | [
"def",
"search",
"(",
"self",
",",
"query",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"if",
"query",
"is",
"None",
":",
"bot",
".",
"exit",
"(",
"'You must include a collection query, <collection>/<repo>'",
")",
"# or default to listing (searching) all things... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search_all | a "show all" search that doesn't require a query
the user is shown URLs to | sregistry/main/gitlab/query.py | def search_all(self, collection, job_id=None):
'''a "show all" search that doesn't require a query
the user is shown URLs to
'''
results = [['job_id', 'browser']]
url = "%s/projects/%s/jobs" %(self.api_base,
quote_plus(collection.strip('/')))
response =... | def search_all(self, collection, job_id=None):
'''a "show all" search that doesn't require a query
the user is shown URLs to
'''
results = [['job_id', 'browser']]
url = "%s/projects/%s/jobs" %(self.api_base,
quote_plus(collection.strip('/')))
response =... | [
"a",
"show",
"all",
"search",
"that",
"doesn",
"t",
"require",
"a",
"query",
"the",
"user",
"is",
"shown",
"URLs",
"to"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/gitlab/query.py#L37-L77 | [
"def",
"search_all",
"(",
"self",
",",
"collection",
",",
"job_id",
"=",
"None",
")",
":",
"results",
"=",
"[",
"[",
"'job_id'",
",",
"'browser'",
"]",
"]",
"url",
"=",
"\"%s/projects/%s/jobs\"",
"%",
"(",
"self",
".",
"api_base",
",",
"quote_plus",
"(",... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | ApiConnection._client_tagged | ensure that the client name is included in a list of tags. This is
important for matching builders to the correct client. We exit
on fail.
Parameters
==========
tags: a list of tags to look for client name in | sregistry/main/base/__init__.py | def _client_tagged(self, tags):
'''ensure that the client name is included in a list of tags. This is
important for matching builders to the correct client. We exit
on fail.
Parameters
==========
tags: a list of tags to look for client name in
... | def _client_tagged(self, tags):
'''ensure that the client name is included in a list of tags. This is
important for matching builders to the correct client. We exit
on fail.
Parameters
==========
tags: a list of tags to look for client name in
... | [
"ensure",
"that",
"the",
"client",
"name",
"is",
"included",
"in",
"a",
"list",
"of",
"tags",
".",
"This",
"is",
"important",
"for",
"matching",
"builders",
"to",
"the",
"correct",
"client",
".",
"We",
"exit",
"on",
"fail",
".",
"Parameters",
"==========",... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/base/__init__.py#L65-L82 | [
"def",
"_client_tagged",
"(",
"self",
",",
"tags",
")",
":",
"# We must match the client to a tag",
"name",
"=",
"self",
".",
"client_name",
".",
"lower",
"(",
")",
"tags",
"=",
"[",
"t",
".",
"lower",
"(",
")",
"for",
"t",
"in",
"tags",
"]",
"if",
"na... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | ApiConnection.speak | a function for the client to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client. | sregistry/main/base/__init__.py | def speak(self):
'''
a function for the client to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client.
'''
if self.quiet is Fals... | def speak(self):
'''
a function for the client to announce him or herself, depending
on the level specified. If you want your client to have additional
announced things here, then implement the class `_speak` for your
client.
'''
if self.quiet is Fals... | [
"a",
"function",
"for",
"the",
"client",
"to",
"announce",
"him",
"or",
"herself",
"depending",
"on",
"the",
"level",
"specified",
".",
"If",
"you",
"want",
"your",
"client",
"to",
"have",
"additional",
"announced",
"things",
"here",
"then",
"implement",
"th... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/base/__init__.py#L85-L97 | [
"def",
"speak",
"(",
"self",
")",
":",
"if",
"self",
".",
"quiet",
"is",
"False",
":",
"bot",
".",
"info",
"(",
"'[client|%s] [database|%s]'",
"%",
"(",
"self",
".",
"client_name",
",",
"self",
".",
"database",
")",
")",
"self",
".",
"_speak",
"(",
"... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | ApiConnection.announce | the client will announce itself given that a command is not in a
particular predefined list. | sregistry/main/base/__init__.py | def announce(self, command=None):
'''the client will announce itself given that a command is not in a
particular predefined list.
'''
if command is not None:
if command not in ['get'] and self.quiet is False:
self.speak() | def announce(self, command=None):
'''the client will announce itself given that a command is not in a
particular predefined list.
'''
if command is not None:
if command not in ['get'] and self.quiet is False:
self.speak() | [
"the",
"client",
"will",
"announce",
"itself",
"given",
"that",
"a",
"command",
"is",
"not",
"in",
"a",
"particular",
"predefined",
"list",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/base/__init__.py#L109-L115 | [
"def",
"announce",
"(",
"self",
",",
"command",
"=",
"None",
")",
":",
"if",
"command",
"is",
"not",
"None",
":",
"if",
"command",
"not",
"in",
"[",
"'get'",
"]",
"and",
"self",
".",
"quiet",
"is",
"False",
":",
"self",
".",
"speak",
"(",
")"
] | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | Client._update_secrets | The user is required to have an application secrets file in his
or her environment. The client exists with error
if the variable isn't found. | sregistry/main/google_drive/__init__.py | def _update_secrets(self):
'''The user is required to have an application secrets file in his
or her environment. The client exists with error
if the variable isn't found.
'''
env = 'SREGISTRY_GOOGLE_DRIVE_CREDENTIALS'
self._secrets = self._get_and_update_setting(e... | def _update_secrets(self):
'''The user is required to have an application secrets file in his
or her environment. The client exists with error
if the variable isn't found.
'''
env = 'SREGISTRY_GOOGLE_DRIVE_CREDENTIALS'
self._secrets = self._get_and_update_setting(e... | [
"The",
"user",
"is",
"required",
"to",
"have",
"an",
"application",
"secrets",
"file",
"in",
"his",
"or",
"her",
"environment",
".",
"The",
"client",
"exists",
"with",
"error",
"if",
"the",
"variable",
"isn",
"t",
"found",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_drive/__init__.py#L46-L61 | [
"def",
"_update_secrets",
"(",
"self",
")",
":",
"env",
"=",
"'SREGISTRY_GOOGLE_DRIVE_CREDENTIALS'",
"self",
".",
"_secrets",
"=",
"self",
".",
"_get_and_update_setting",
"(",
"env",
")",
"self",
".",
"_base",
"=",
"self",
".",
"_get_and_update_setting",
"(",
"'... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | Client._get_service | get service client for the google drive API
:param version: version to use (default is v3) | sregistry/main/google_drive/__init__.py | def _get_service(self, version='v3'):
'''get service client for the google drive API
:param version: version to use (default is v3)
'''
invalid = True
# The user hasn't disabled cache of credentials
if self._credential_cache is not None:
storage = Storage(sel... | def _get_service(self, version='v3'):
'''get service client for the google drive API
:param version: version to use (default is v3)
'''
invalid = True
# The user hasn't disabled cache of credentials
if self._credential_cache is not None:
storage = Storage(sel... | [
"get",
"service",
"client",
"for",
"the",
"google",
"drive",
"API",
":",
"param",
"version",
":",
"version",
"to",
"use",
"(",
"default",
"is",
"v3",
")"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_drive/__init__.py#L73-L106 | [
"def",
"_get_service",
"(",
"self",
",",
"version",
"=",
"'v3'",
")",
":",
"invalid",
"=",
"True",
"# The user hasn't disabled cache of credentials",
"if",
"self",
".",
"_credential_cache",
"is",
"not",
"None",
":",
"storage",
"=",
"Storage",
"(",
"self",
".",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | add | dummy add simple returns an object that mimics a database entry, so the
calling function (in push or pull) can interact with it equally. Most
variables (other than image_path) are not used. | sregistry/database/dummy.py | def add(self, image_path=None,
image_uri=None,
image_name=None,
url=None,
metadata=None,
save=True,
copy=False):
'''dummy add simple returns an object that mimics a database entry, so the
calling function (in push or pull) ... | def add(self, image_path=None,
image_uri=None,
image_name=None,
url=None,
metadata=None,
save=True,
copy=False):
'''dummy add simple returns an object that mimics a database entry, so the
calling function (in push or pull) ... | [
"dummy",
"add",
"simple",
"returns",
"an",
"object",
"that",
"mimics",
"a",
"database",
"entry",
"so",
"the",
"calling",
"function",
"(",
"in",
"push",
"or",
"pull",
")",
"can",
"interact",
"with",
"it",
"equally",
".",
"Most",
"variables",
"(",
"other",
... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/database/dummy.py#L20-L57 | [
"def",
"add",
"(",
"self",
",",
"image_path",
"=",
"None",
",",
"image_uri",
"=",
"None",
",",
"image_name",
"=",
"None",
",",
"url",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"save",
"=",
"True",
",",
"copy",
"=",
"False",
")",
":",
"# We ca... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search | query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in singularity hub
vsoch do a general search for collection "vsoch"
vsoch/dinosaur list details of container vsoch/dinosaur
... | sregistry/main/hub/query.py | def search(self, query=None, **kwargs):
'''query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in singularity hub
vsoch do a general search for collection "vsoch"
vsoch/dinosaur ... | def search(self, query=None, **kwargs):
'''query a Singularity registry for a list of images.
If query is None, collections are listed.
EXAMPLE QUERIES:
[empty] list all collections in singularity hub
vsoch do a general search for collection "vsoch"
vsoch/dinosaur ... | [
"query",
"a",
"Singularity",
"registry",
"for",
"a",
"list",
"of",
"images",
".",
"If",
"query",
"is",
"None",
"collections",
"are",
"listed",
"."
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/hub/query.py#L20-L38 | [
"def",
"search",
"(",
"self",
",",
"query",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"query",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_search_collection",
"(",
"query",
")",
"# Search collections across all fields",
"return",
"self",
... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | list_all | a "show all" search that doesn't require a query | sregistry/main/hub/query.py | def list_all(self, **kwargs):
'''a "show all" search that doesn't require a query'''
quiet=False
if "quiet" in kwargs:
quiet = kwargs['quiet']
bot.spinner.start()
url = '%s/collections/' %self.base
results = self._paginate_get(url)
bot.spinner.stop()
if len(results) == 0:
... | def list_all(self, **kwargs):
'''a "show all" search that doesn't require a query'''
quiet=False
if "quiet" in kwargs:
quiet = kwargs['quiet']
bot.spinner.start()
url = '%s/collections/' %self.base
results = self._paginate_get(url)
bot.spinner.stop()
if len(results) == 0:
... | [
"a",
"show",
"all",
"search",
"that",
"doesn",
"t",
"require",
"a",
"query"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/hub/query.py#L46-L73 | [
"def",
"list_all",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"quiet",
"=",
"False",
"if",
"\"quiet\"",
"in",
"kwargs",
":",
"quiet",
"=",
"kwargs",
"[",
"'quiet'",
"]",
"bot",
".",
"spinner",
".",
"start",
"(",
")",
"url",
"=",
"'%s/collections... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | search_collection | collection search will list all containers for a specific
collection. We assume query is the name of a collection | sregistry/main/hub/query.py | def search_collection(self, query):
'''collection search will list all containers for a specific
collection. We assume query is the name of a collection'''
query = query.lower().strip('/')
q = parse_image_name(remove_uri(query), defaults=False)
# Workaround for now - the Singularity Hub search... | def search_collection(self, query):
'''collection search will list all containers for a specific
collection. We assume query is the name of a collection'''
query = query.lower().strip('/')
q = parse_image_name(remove_uri(query), defaults=False)
# Workaround for now - the Singularity Hub search... | [
"collection",
"search",
"will",
"list",
"all",
"containers",
"for",
"a",
"specific",
"collection",
".",
"We",
"assume",
"query",
"is",
"the",
"name",
"of",
"a",
"collection"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/hub/query.py#L76-L96 | [
"def",
"search_collection",
"(",
"self",
",",
"query",
")",
":",
"query",
"=",
"query",
".",
"lower",
"(",
")",
".",
"strip",
"(",
"'/'",
")",
"q",
"=",
"parse_image_name",
"(",
"remove_uri",
"(",
"query",
")",
",",
"defaults",
"=",
"False",
")",
"# ... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | pull | pull an image from gitlab. The image is found based on the
uri that should correspond to a gitlab repository, and then
the branch, job name, artifact folder, and tag of the container.
The minimum that we need are the job id, collection, and job name. Eg:
job_id|collection|job_name (or)
... | sregistry/main/gitlab/pull.py | def pull(self, images, file_name=None, save=True, **kwargs):
'''pull an image from gitlab. The image is found based on the
uri that should correspond to a gitlab repository, and then
the branch, job name, artifact folder, and tag of the container.
The minimum that we need are the job id, colle... | def pull(self, images, file_name=None, save=True, **kwargs):
'''pull an image from gitlab. The image is found based on the
uri that should correspond to a gitlab repository, and then
the branch, job name, artifact folder, and tag of the container.
The minimum that we need are the job id, colle... | [
"pull",
"an",
"image",
"from",
"gitlab",
".",
"The",
"image",
"is",
"found",
"based",
"on",
"the",
"uri",
"that",
"should",
"correspond",
"to",
"a",
"gitlab",
"repository",
"and",
"then",
"the",
"branch",
"job",
"name",
"artifact",
"folder",
"and",
"tag",
... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/gitlab/pull.py#L21-L129 | [
"def",
"pull",
"(",
"self",
",",
"images",
",",
"file_name",
"=",
"None",
",",
"save",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"force",
"=",
"False",
"if",
"\"force\"",
"in",
"kwargs",
":",
"force",
"=",
"kwargs",
"[",
"'force'",
"]",
"if",... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | Workers.run | run will send a list of tasks,
a tuple with arguments, through a function.
the arguments should be ordered correctly.
:param func: the function to run with multiprocessing.pool
:param tasks: a list of tasks, each a tuple
of arguments to process
:param func2:... | sregistry/main/workers/worker.py | def run(self, func, tasks, func2=None):
'''run will send a list of tasks,
a tuple with arguments, through a function.
the arguments should be ordered correctly.
:param func: the function to run with multiprocessing.pool
:param tasks: a list of tasks, each a tuple
... | def run(self, func, tasks, func2=None):
'''run will send a list of tasks,
a tuple with arguments, through a function.
the arguments should be ordered correctly.
:param func: the function to run with multiprocessing.pool
:param tasks: a list of tasks, each a tuple
... | [
"run",
"will",
"send",
"a",
"list",
"of",
"tasks",
"a",
"tuple",
"with",
"arguments",
"through",
"a",
"function",
".",
"the",
"arguments",
"should",
"be",
"ordered",
"correctly",
".",
":",
"param",
"func",
":",
"the",
"function",
"to",
"run",
"with",
"mu... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/workers/worker.py#L42-L109 | [
"def",
"run",
"(",
"self",
",",
"func",
",",
"tasks",
",",
"func2",
"=",
"None",
")",
":",
"# Keep track of some progress for the user",
"progress",
"=",
"1",
"total",
"=",
"len",
"(",
"tasks",
")",
"# if we don't have tasks, don't run",
"if",
"len",
"(",
"tas... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | get_cache | get_cache will return the user's cache for singularity.
:param subfolder: a subfolder in the cache base to retrieve, specifically | sregistry/utils/cache.py | def get_cache(subfolder=None, quiet=False):
'''get_cache will return the user's cache for singularity.
:param subfolder: a subfolder in the cache base to retrieve, specifically
'''
DISABLE_CACHE = convert2boolean(getenv("SINGULARITY_DISABLE_CACHE",
default=Fal... | def get_cache(subfolder=None, quiet=False):
'''get_cache will return the user's cache for singularity.
:param subfolder: a subfolder in the cache base to retrieve, specifically
'''
DISABLE_CACHE = convert2boolean(getenv("SINGULARITY_DISABLE_CACHE",
default=Fal... | [
"get_cache",
"will",
"return",
"the",
"user",
"s",
"cache",
"for",
"singularity",
".",
":",
"param",
"subfolder",
":",
"a",
"subfolder",
"in",
"the",
"cache",
"base",
"to",
"retrieve",
"specifically"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/utils/cache.py#L59-L85 | [
"def",
"get_cache",
"(",
"subfolder",
"=",
"None",
",",
"quiet",
"=",
"False",
")",
":",
"DISABLE_CACHE",
"=",
"convert2boolean",
"(",
"getenv",
"(",
"\"SINGULARITY_DISABLE_CACHE\"",
",",
"default",
"=",
"False",
")",
")",
"if",
"DISABLE_CACHE",
":",
"SINGULAR... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | push | push an image to Google Cloud Storage, meaning uploading it
path: should correspond to an absolte image path (or derive it)
name: should be the complete uri that the user has requested to push.
tag: should correspond with an image tag. This is provided to mirror Docker | sregistry/main/google_build/push.py | def push(self, path, name, tag=None):
'''push an image to Google Cloud Storage, meaning uploading it
path: should correspond to an absolte image path (or derive it)
name: should be the complete uri that the user has requested to push.
tag: should correspond with an image tag. This is provided to mi... | def push(self, path, name, tag=None):
'''push an image to Google Cloud Storage, meaning uploading it
path: should correspond to an absolte image path (or derive it)
name: should be the complete uri that the user has requested to push.
tag: should correspond with an image tag. This is provided to mi... | [
"push",
"an",
"image",
"to",
"Google",
"Cloud",
"Storage",
"meaning",
"uploading",
"it",
"path",
":",
"should",
"correspond",
"to",
"an",
"absolte",
"image",
"path",
"(",
"or",
"derive",
"it",
")",
"name",
":",
"should",
"be",
"the",
"complete",
"uri",
"... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_build/push.py#L26-L58 | [
"def",
"push",
"(",
"self",
",",
"path",
",",
"name",
",",
"tag",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"bot",
".",
"debug",
"(",
"\"PUSH %s\"",
"%",
"path",
")",
"if",
"not",
"os",
".",
"path"... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | upload | upload a file from a source to a destination. The client is expected
to have a bucket (self._bucket) that is created when instantiated.
This would be the method to do the same using the storage client,
but not easily done for resumable
blob = self._bucket.blob(destination)
blob... | sregistry/main/google_build/push.py | def upload(self, source,
destination,
bucket,
chunk_size = 2 * 1024 * 1024,
metadata=None,
keep_private=True):
'''upload a file from a source to a destination. The client is expected
to have a bucket (self._bucket) that ... | def upload(self, source,
destination,
bucket,
chunk_size = 2 * 1024 * 1024,
metadata=None,
keep_private=True):
'''upload a file from a source to a destination. The client is expected
to have a bucket (self._bucket) that ... | [
"upload",
"a",
"file",
"from",
"a",
"source",
"to",
"a",
"destination",
".",
"The",
"client",
"is",
"expected",
"to",
"have",
"a",
"bucket",
"(",
"self",
".",
"_bucket",
")",
"that",
"is",
"created",
"when",
"instantiated",
".",
"This",
"would",
"be",
... | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/google_build/push.py#L63-L123 | [
"def",
"upload",
"(",
"self",
",",
"source",
",",
"destination",
",",
"bucket",
",",
"chunk_size",
"=",
"2",
"*",
"1024",
"*",
"1024",
",",
"metadata",
"=",
"None",
",",
"keep_private",
"=",
"True",
")",
":",
"env",
"=",
"'SREGISTRY_GOOGLE_STORAGE_PRIVATE'... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
test | update_headers | update headers with a token & other fields | sregistry/main/base/headers.py | def update_headers(self,fields=None):
'''update headers with a token & other fields
'''
do_reset = True
if hasattr(self, 'headers'):
if self.headers is not None:
do_reset = False
if do_reset is True:
self._reset_headers()
if fields is not None:
for key,value... | def update_headers(self,fields=None):
'''update headers with a token & other fields
'''
do_reset = True
if hasattr(self, 'headers'):
if self.headers is not None:
do_reset = False
if do_reset is True:
self._reset_headers()
if fields is not None:
for key,value... | [
"update",
"headers",
"with",
"a",
"token",
"&",
"other",
"fields"
] | singularityhub/sregistry-cli | python | https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/base/headers.py#L31-L47 | [
"def",
"update_headers",
"(",
"self",
",",
"fields",
"=",
"None",
")",
":",
"do_reset",
"=",
"True",
"if",
"hasattr",
"(",
"self",
",",
"'headers'",
")",
":",
"if",
"self",
".",
"headers",
"is",
"not",
"None",
":",
"do_reset",
"=",
"False",
"if",
"do... | abc96140a1d15b5e96d83432e1e0e1f4f8f36331 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.