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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Bdb.get_stack_data | Get the stack frames data at each of the hooks above (Ie. for each
line of the Python code) | nbtutor/ipython/debugger.py | def get_stack_data(self, frame, traceback, event_type):
"""Get the stack frames data at each of the hooks above (Ie. for each
line of the Python code)"""
heap_data = Heap(self.options)
stack_data = StackFrames(self.options)
stack_frames, cur_frame_ind = self.get_stack(frame, trac... | def get_stack_data(self, frame, traceback, event_type):
"""Get the stack frames data at each of the hooks above (Ie. for each
line of the Python code)"""
heap_data = Heap(self.options)
stack_data = StackFrames(self.options)
stack_frames, cur_frame_ind = self.get_stack(frame, trac... | [
"Get",
"the",
"stack",
"frames",
"data",
"at",
"each",
"of",
"the",
"hooks",
"above",
"(",
"Ie",
".",
"for",
"each",
"line",
"of",
"the",
"Python",
"code",
")"
] | lgpage/nbtutor | python | https://github.com/lgpage/nbtutor/blob/07798a044cf6e1fd4eaac2afddeef3e13348dbcd/nbtutor/ipython/debugger.py#L84-L130 | [
"def",
"get_stack_data",
"(",
"self",
",",
"frame",
",",
"traceback",
",",
"event_type",
")",
":",
"heap_data",
"=",
"Heap",
"(",
"self",
".",
"options",
")",
"stack_data",
"=",
"StackFrames",
"(",
"self",
".",
"options",
")",
"stack_frames",
",",
"cur_fra... | 07798a044cf6e1fd4eaac2afddeef3e13348dbcd |
valid | filter_dict | Return a new dict with specified keys excluded from the origional dict
Args:
d (dict): origional dict
exclude (list): The keys that are excluded | nbtutor/ipython/utils.py | def filter_dict(d, exclude):
"""Return a new dict with specified keys excluded from the origional dict
Args:
d (dict): origional dict
exclude (list): The keys that are excluded
"""
ret = {}
for key, value in d.items():
if key not in exclude:
ret.update({key: valu... | def filter_dict(d, exclude):
"""Return a new dict with specified keys excluded from the origional dict
Args:
d (dict): origional dict
exclude (list): The keys that are excluded
"""
ret = {}
for key, value in d.items():
if key not in exclude:
ret.update({key: valu... | [
"Return",
"a",
"new",
"dict",
"with",
"specified",
"keys",
"excluded",
"from",
"the",
"origional",
"dict"
] | lgpage/nbtutor | python | https://github.com/lgpage/nbtutor/blob/07798a044cf6e1fd4eaac2afddeef3e13348dbcd/nbtutor/ipython/utils.py#L79-L90 | [
"def",
"filter_dict",
"(",
"d",
",",
"exclude",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"exclude",
":",
"ret",
".",
"update",
"(",
"{",
"key",
":",
"value",
... | 07798a044cf6e1fd4eaac2afddeef3e13348dbcd |
valid | redirect_stdout | Redirect the stdout
Args:
new_stdout (io.StringIO): New stdout to use instead | nbtutor/ipython/utils.py | def redirect_stdout(new_stdout):
"""Redirect the stdout
Args:
new_stdout (io.StringIO): New stdout to use instead
"""
old_stdout, sys.stdout = sys.stdout, new_stdout
try:
yield None
finally:
sys.stdout = old_stdout | def redirect_stdout(new_stdout):
"""Redirect the stdout
Args:
new_stdout (io.StringIO): New stdout to use instead
"""
old_stdout, sys.stdout = sys.stdout, new_stdout
try:
yield None
finally:
sys.stdout = old_stdout | [
"Redirect",
"the",
"stdout"
] | lgpage/nbtutor | python | https://github.com/lgpage/nbtutor/blob/07798a044cf6e1fd4eaac2afddeef3e13348dbcd/nbtutor/ipython/utils.py#L94-L104 | [
"def",
"redirect_stdout",
"(",
"new_stdout",
")",
":",
"old_stdout",
",",
"sys",
".",
"stdout",
"=",
"sys",
".",
"stdout",
",",
"new_stdout",
"try",
":",
"yield",
"None",
"finally",
":",
"sys",
".",
"stdout",
"=",
"old_stdout"
] | 07798a044cf6e1fd4eaac2afddeef3e13348dbcd |
valid | format | Return a string representation of the Python object
Args:
obj: The Python object
options: Format options | nbtutor/ipython/utils.py | def format(obj, options):
"""Return a string representation of the Python object
Args:
obj: The Python object
options: Format options
"""
formatters = {
float_types: lambda x: '{:.{}g}'.format(x, options.digits),
}
for _types, fmtr in formatters.items():
if isins... | def format(obj, options):
"""Return a string representation of the Python object
Args:
obj: The Python object
options: Format options
"""
formatters = {
float_types: lambda x: '{:.{}g}'.format(x, options.digits),
}
for _types, fmtr in formatters.items():
if isins... | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"Python",
"object"
] | lgpage/nbtutor | python | https://github.com/lgpage/nbtutor/blob/07798a044cf6e1fd4eaac2afddeef3e13348dbcd/nbtutor/ipython/utils.py#L107-L125 | [
"def",
"format",
"(",
"obj",
",",
"options",
")",
":",
"formatters",
"=",
"{",
"float_types",
":",
"lambda",
"x",
":",
"'{:.{}g}'",
".",
"format",
"(",
"x",
",",
"options",
".",
"digits",
")",
",",
"}",
"for",
"_types",
",",
"fmtr",
"in",
"formatters... | 07798a044cf6e1fd4eaac2afddeef3e13348dbcd |
valid | get_type_info | Get type information for a Python object
Args:
obj: The Python object
Returns:
tuple: (object type "catagory", object type name) | nbtutor/ipython/utils.py | def get_type_info(obj):
"""Get type information for a Python object
Args:
obj: The Python object
Returns:
tuple: (object type "catagory", object type name)
"""
if isinstance(obj, primitive_types):
return ('primitive', type(obj).__name__)
if isinstance(obj, sequence_type... | def get_type_info(obj):
"""Get type information for a Python object
Args:
obj: The Python object
Returns:
tuple: (object type "catagory", object type name)
"""
if isinstance(obj, primitive_types):
return ('primitive', type(obj).__name__)
if isinstance(obj, sequence_type... | [
"Get",
"type",
"information",
"for",
"a",
"Python",
"object"
] | lgpage/nbtutor | python | https://github.com/lgpage/nbtutor/blob/07798a044cf6e1fd4eaac2afddeef3e13348dbcd/nbtutor/ipython/utils.py#L128-L162 | [
"def",
"get_type_info",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"primitive_types",
")",
":",
"return",
"(",
"'primitive'",
",",
"type",
"(",
"obj",
")",
".",
"__name__",
")",
"if",
"isinstance",
"(",
"obj",
",",
"sequence_types",
")",
... | 07798a044cf6e1fd4eaac2afddeef3e13348dbcd |
valid | Wallet.refresh | Reloads the wallet and its accounts. By default, this method is called only once,
on :class:`Wallet` initialization. When the wallet is accessed by multiple clients or
exists in multiple instances, calling `refresh()` will be necessary to update
the list of accounts. | monero/wallet.py | def refresh(self):
"""
Reloads the wallet and its accounts. By default, this method is called only once,
on :class:`Wallet` initialization. When the wallet is accessed by multiple clients or
exists in multiple instances, calling `refresh()` will be necessary to update
the list of... | def refresh(self):
"""
Reloads the wallet and its accounts. By default, this method is called only once,
on :class:`Wallet` initialization. When the wallet is accessed by multiple clients or
exists in multiple instances, calling `refresh()` will be necessary to update
the list of... | [
"Reloads",
"the",
"wallet",
"and",
"its",
"accounts",
".",
"By",
"default",
"this",
"method",
"is",
"called",
"only",
"once",
"on",
":",
"class",
":",
"Wallet",
"initialization",
".",
"When",
"the",
"wallet",
"is",
"accessed",
"by",
"multiple",
"clients",
... | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L38-L55 | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"accounts",
"=",
"self",
".",
"accounts",
"or",
"[",
"]",
"idx",
"=",
"0",
"for",
"_acc",
"in",
"self",
".",
"_backend",
".",
"accounts",
"(",
")",
":",
"_acc",
".",
"wallet",
"=",
"self",
"tr... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.spend_key | Returns private spend key. None if wallet is view-only.
:rtype: str or None | monero/wallet.py | def spend_key(self):
"""
Returns private spend key. None if wallet is view-only.
:rtype: str or None
"""
key = self._backend.spend_key()
if key == numbers.EMPTY_KEY:
return None
return key | def spend_key(self):
"""
Returns private spend key. None if wallet is view-only.
:rtype: str or None
"""
key = self._backend.spend_key()
if key == numbers.EMPTY_KEY:
return None
return key | [
"Returns",
"private",
"spend",
"key",
".",
"None",
"if",
"wallet",
"is",
"view",
"-",
"only",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L65-L74 | [
"def",
"spend_key",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"_backend",
".",
"spend_key",
"(",
")",
"if",
"key",
"==",
"numbers",
".",
"EMPTY_KEY",
":",
"return",
"None",
"return",
"key"
] | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.new_account | Creates new account, appends it to the :class:`Wallet`'s account list and returns it.
:param label: account label as `str`
:rtype: :class:`Account` | monero/wallet.py | def new_account(self, label=None):
"""
Creates new account, appends it to the :class:`Wallet`'s account list and returns it.
:param label: account label as `str`
:rtype: :class:`Account`
"""
acc, addr = self._backend.new_account(label=label)
assert acc.index == l... | def new_account(self, label=None):
"""
Creates new account, appends it to the :class:`Wallet`'s account list and returns it.
:param label: account label as `str`
:rtype: :class:`Account`
"""
acc, addr = self._backend.new_account(label=label)
assert acc.index == l... | [
"Creates",
"new",
"account",
"appends",
"it",
"to",
"the",
":",
"class",
":",
"Wallet",
"s",
"account",
"list",
"and",
"returns",
"it",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L92-L102 | [
"def",
"new_account",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"acc",
",",
"addr",
"=",
"self",
".",
"_backend",
".",
"new_account",
"(",
"label",
"=",
"label",
")",
"assert",
"acc",
".",
"index",
"==",
"len",
"(",
"self",
".",
"accounts",
... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.confirmations | Returns the number of confirmations for given
:class:`Transaction <monero.transaction.Transaction>` or
:class:`Payment <monero.transaction.Payment>` object.
:rtype: int | monero/wallet.py | def confirmations(self, txn_or_pmt):
"""
Returns the number of confirmations for given
:class:`Transaction <monero.transaction.Transaction>` or
:class:`Payment <monero.transaction.Payment>` object.
:rtype: int
"""
if isinstance(txn_or_pmt, Payment):
t... | def confirmations(self, txn_or_pmt):
"""
Returns the number of confirmations for given
:class:`Transaction <monero.transaction.Transaction>` or
:class:`Payment <monero.transaction.Payment>` object.
:rtype: int
"""
if isinstance(txn_or_pmt, Payment):
t... | [
"Returns",
"the",
"number",
"of",
"confirmations",
"for",
"given",
":",
"class",
":",
"Transaction",
"<monero",
".",
"transaction",
".",
"Transaction",
">",
"or",
":",
"class",
":",
"Payment",
"<monero",
".",
"transaction",
".",
"Payment",
">",
"object",
"."... | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L104-L119 | [
"def",
"confirmations",
"(",
"self",
",",
"txn_or_pmt",
")",
":",
"if",
"isinstance",
"(",
"txn_or_pmt",
",",
"Payment",
")",
":",
"txn",
"=",
"txn_or_pmt",
".",
"transaction",
"else",
":",
"txn",
"=",
"txn_or_pmt",
"try",
":",
"return",
"max",
"(",
"0",... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.get_address | Calculates sub-address for account index (`major`) and address index within
the account (`minor`).
:rtype: :class:`BaseAddress <monero.address.BaseAddress>` | monero/wallet.py | def get_address(self, major, minor):
"""
Calculates sub-address for account index (`major`) and address index within
the account (`minor`).
:rtype: :class:`BaseAddress <monero.address.BaseAddress>`
"""
# ensure indexes are within uint32
if major < 0 or major >= 2... | def get_address(self, major, minor):
"""
Calculates sub-address for account index (`major`) and address index within
the account (`minor`).
:rtype: :class:`BaseAddress <monero.address.BaseAddress>`
"""
# ensure indexes are within uint32
if major < 0 or major >= 2... | [
"Calculates",
"sub",
"-",
"address",
"for",
"account",
"index",
"(",
"major",
")",
"and",
"address",
"index",
"within",
"the",
"account",
"(",
"minor",
")",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L198-L231 | [
"def",
"get_address",
"(",
"self",
",",
"major",
",",
"minor",
")",
":",
"# ensure indexes are within uint32",
"if",
"major",
"<",
"0",
"or",
"major",
">=",
"2",
"**",
"32",
":",
"raise",
"ValueError",
"(",
"'major index {} is outside uint32 range'",
".",
"forma... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.transfer | Sends a transfer from the default account. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtype
:param amount: amount to send
:param priority: transaction priority, implies fee. The priority can be a number
... | monero/wallet.py | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer from the default account. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtyp... | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer from the default account. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtyp... | [
"Sends",
"a",
"transfer",
"from",
"the",
"default",
"account",
".",
"Returns",
"a",
"list",
"of",
"resulting",
"transactions",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L233-L259 | [
"def",
"transfer",
"(",
"self",
",",
"address",
",",
"amount",
",",
"priority",
"=",
"prio",
".",
"NORMAL",
",",
"payment_id",
"=",
"None",
",",
"unlock_time",
"=",
"0",
",",
"relay",
"=",
"True",
")",
":",
"return",
"self",
".",
"accounts",
"[",
"0"... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wallet.transfer_multiple | Sends a batch of transfers from the default account. Returns a list of resulting
transactions.
:param destinations: a list of destination and amount pairs: [(address, amount), ...]
:param priority: transaction priority, implies fee. The priority can be a number
from 1 to 4 (... | monero/wallet.py | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers from the default account. Returns a list of resulting
transactions.
:param destinations: a list of destination and amount p... | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers from the default account. Returns a list of resulting
transactions.
:param destinations: a list of destination and amount p... | [
"Sends",
"a",
"batch",
"of",
"transfers",
"from",
"the",
"default",
"account",
".",
"Returns",
"a",
"list",
"of",
"resulting",
"transactions",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L261-L286 | [
"def",
"transfer_multiple",
"(",
"self",
",",
"destinations",
",",
"priority",
"=",
"prio",
".",
"NORMAL",
",",
"payment_id",
"=",
"None",
",",
"unlock_time",
"=",
"0",
",",
"relay",
"=",
"True",
")",
":",
"return",
"self",
".",
"accounts",
"[",
"0",
"... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Account.balance | Returns specified balance.
:param unlocked: if `True`, return the unlocked balance, otherwise return total balance
:rtype: Decimal | monero/account.py | def balance(self, unlocked=False):
"""
Returns specified balance.
:param unlocked: if `True`, return the unlocked balance, otherwise return total balance
:rtype: Decimal
"""
return self._backend.balances(account=self.index)[1 if unlocked else 0] | def balance(self, unlocked=False):
"""
Returns specified balance.
:param unlocked: if `True`, return the unlocked balance, otherwise return total balance
:rtype: Decimal
"""
return self._backend.balances(account=self.index)[1 if unlocked else 0] | [
"Returns",
"specified",
"balance",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/account.py#L37-L44 | [
"def",
"balance",
"(",
"self",
",",
"unlocked",
"=",
"False",
")",
":",
"return",
"self",
".",
"_backend",
".",
"balances",
"(",
"account",
"=",
"self",
".",
"index",
")",
"[",
"1",
"if",
"unlocked",
"else",
"0",
"]"
] | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Account.new_address | Creates a new address.
:param label: address label as `str`
:rtype: :class:`SubAddress <monero.address.SubAddress>` | monero/account.py | def new_address(self, label=None):
"""
Creates a new address.
:param label: address label as `str`
:rtype: :class:`SubAddress <monero.address.SubAddress>`
"""
return self._backend.new_address(account=self.index, label=label) | def new_address(self, label=None):
"""
Creates a new address.
:param label: address label as `str`
:rtype: :class:`SubAddress <monero.address.SubAddress>`
"""
return self._backend.new_address(account=self.index, label=label) | [
"Creates",
"a",
"new",
"address",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/account.py#L62-L69 | [
"def",
"new_address",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"return",
"self",
".",
"_backend",
".",
"new_address",
"(",
"account",
"=",
"self",
".",
"index",
",",
"label",
"=",
"label",
")"
] | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Account.transfer | Sends a transfer. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtype
:param amount: amount to send
:param priority: transaction priority, implies fee. The priority can be a number
from 1 to 4 (unimportan... | monero/account.py | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtype
:param amount: ... | def transfer(self, address, amount,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a transfer. Returns a list of resulting transactions.
:param address: destination :class:`Address <monero.address.Address>` or subtype
:param amount: ... | [
"Sends",
"a",
"transfer",
".",
"Returns",
"a",
"list",
"of",
"resulting",
"transactions",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/account.py#L71-L97 | [
"def",
"transfer",
"(",
"self",
",",
"address",
",",
"amount",
",",
"priority",
"=",
"prio",
".",
"NORMAL",
",",
"payment_id",
"=",
"None",
",",
"unlock_time",
"=",
"0",
",",
"relay",
"=",
"True",
")",
":",
"return",
"self",
".",
"_backend",
".",
"tr... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Account.transfer_multiple | Sends a batch of transfers. Returns a list of resulting transactions.
:param destinations: a list of destination and amount pairs:
[(:class:`Address <monero.address.Address>`, `Decimal`), ...]
:param priority: transaction priority, implies fee. The priority can be a number
... | monero/account.py | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers. Returns a list of resulting transactions.
:param destinations: a list of destination and amount pairs:
[(:clas... | def transfer_multiple(self, destinations,
priority=prio.NORMAL, payment_id=None, unlock_time=0,
relay=True):
"""
Sends a batch of transfers. Returns a list of resulting transactions.
:param destinations: a list of destination and amount pairs:
[(:clas... | [
"Sends",
"a",
"batch",
"of",
"transfers",
".",
"Returns",
"a",
"list",
"of",
"resulting",
"transactions",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/account.py#L99-L125 | [
"def",
"transfer_multiple",
"(",
"self",
",",
"destinations",
",",
"priority",
"=",
"prio",
".",
"NORMAL",
",",
"payment_id",
"=",
"None",
",",
"unlock_time",
"=",
"0",
",",
"relay",
"=",
"True",
")",
":",
"return",
"self",
".",
"_backend",
".",
"transfe... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | to_atomic | Convert Monero decimal to atomic integer of piconero. | monero/numbers.py | def to_atomic(amount):
"""Convert Monero decimal to atomic integer of piconero."""
if not isinstance(amount, (Decimal, float) + _integer_types):
raise ValueError("Amount '{}' doesn't have numeric type. Only Decimal, int, long and "
"float (not recommended) are accepted as amounts.")
... | def to_atomic(amount):
"""Convert Monero decimal to atomic integer of piconero."""
if not isinstance(amount, (Decimal, float) + _integer_types):
raise ValueError("Amount '{}' doesn't have numeric type. Only Decimal, int, long and "
"float (not recommended) are accepted as amounts.")
... | [
"Convert",
"Monero",
"decimal",
"to",
"atomic",
"integer",
"of",
"piconero",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/numbers.py#L15-L20 | [
"def",
"to_atomic",
"(",
"amount",
")",
":",
"if",
"not",
"isinstance",
"(",
"amount",
",",
"(",
"Decimal",
",",
"float",
")",
"+",
"_integer_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Amount '{}' doesn't have numeric type. Only Decimal, int, long and \"",
"\"... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Seed._validate_checksum | Given a mnemonic word string, confirm seed checksum (last word) matches the computed checksum.
:rtype: bool | monero/seed.py | def _validate_checksum(self):
"""Given a mnemonic word string, confirm seed checksum (last word) matches the computed checksum.
:rtype: bool
"""
phrase = self.phrase.split(" ")
if self.word_list.get_checksum(self.phrase) == phrase[-1]:
return True
raise Value... | def _validate_checksum(self):
"""Given a mnemonic word string, confirm seed checksum (last word) matches the computed checksum.
:rtype: bool
"""
phrase = self.phrase.split(" ")
if self.word_list.get_checksum(self.phrase) == phrase[-1]:
return True
raise Value... | [
"Given",
"a",
"mnemonic",
"word",
"string",
"confirm",
"seed",
"checksum",
"(",
"last",
"word",
")",
"matches",
"the",
"computed",
"checksum",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/seed.py#L109-L117 | [
"def",
"_validate_checksum",
"(",
"self",
")",
":",
"phrase",
"=",
"self",
".",
"phrase",
".",
"split",
"(",
"\" \"",
")",
"if",
"self",
".",
"word_list",
".",
"get_checksum",
"(",
"self",
".",
"phrase",
")",
"==",
"phrase",
"[",
"-",
"1",
"]",
":",
... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Seed.public_address | Returns the master :class:`Address <monero.address.Address>` represented by the seed.
:param net: the network, one of 'mainnet', 'testnet', 'stagenet'. Default is 'mainnet'.
:rtype: :class:`Address <monero.address.Address>` | monero/seed.py | def public_address(self, net='mainnet'):
"""Returns the master :class:`Address <monero.address.Address>` represented by the seed.
:param net: the network, one of 'mainnet', 'testnet', 'stagenet'. Default is 'mainnet'.
:rtype: :class:`Address <monero.address.Address>`
"""
if net... | def public_address(self, net='mainnet'):
"""Returns the master :class:`Address <monero.address.Address>` represented by the seed.
:param net: the network, one of 'mainnet', 'testnet', 'stagenet'. Default is 'mainnet'.
:rtype: :class:`Address <monero.address.Address>`
"""
if net... | [
"Returns",
"the",
"master",
":",
"class",
":",
"Address",
"<monero",
".",
"address",
".",
"Address",
">",
"represented",
"by",
"the",
"seed",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/seed.py#L154-L169 | [
"def",
"public_address",
"(",
"self",
",",
"net",
"=",
"'mainnet'",
")",
":",
"if",
"net",
"not",
"in",
"(",
"'mainnet'",
",",
"'testnet'",
",",
"'stagenet'",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid net argument. Must be one of ('mainnet', 'testnet', 'stage... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | address | Discover the proper class and return instance for a given Monero address.
:param addr: the address as a string-like object
:param label: a label for the address (defaults to `None`)
:rtype: :class:`Address`, :class:`SubAddress` or :class:`IntegratedAddress` | monero/address.py | def address(addr, label=None):
"""Discover the proper class and return instance for a given Monero address.
:param addr: the address as a string-like object
:param label: a label for the address (defaults to `None`)
:rtype: :class:`Address`, :class:`SubAddress` or :class:`IntegratedAddress`
"""
... | def address(addr, label=None):
"""Discover the proper class and return instance for a given Monero address.
:param addr: the address as a string-like object
:param label: a label for the address (defaults to `None`)
:rtype: :class:`Address`, :class:`SubAddress` or :class:`IntegratedAddress`
"""
... | [
"Discover",
"the",
"proper",
"class",
"and",
"return",
"instance",
"for",
"a",
"given",
"Monero",
"address",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/address.py#L178-L201 | [
"def",
"address",
"(",
"addr",
",",
"label",
"=",
"None",
")",
":",
"addr",
"=",
"str",
"(",
"addr",
")",
"if",
"_ADDR_REGEX",
".",
"match",
"(",
"addr",
")",
":",
"netbyte",
"=",
"bytearray",
"(",
"unhexlify",
"(",
"base58",
".",
"decode",
"(",
"a... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Address.with_payment_id | Integrates payment id into the address.
:param payment_id: int, hexadecimal string or :class:`PaymentID <monero.numbers.PaymentID>`
(max 64-bit long)
:rtype: `IntegratedAddress`
:raises: `TypeError` if the payment id is too long | monero/address.py | def with_payment_id(self, payment_id=0):
"""Integrates payment id into the address.
:param payment_id: int, hexadecimal string or :class:`PaymentID <monero.numbers.PaymentID>`
(max 64-bit long)
:rtype: `IntegratedAddress`
:raises: `TypeError` if the payment id is to... | def with_payment_id(self, payment_id=0):
"""Integrates payment id into the address.
:param payment_id: int, hexadecimal string or :class:`PaymentID <monero.numbers.PaymentID>`
(max 64-bit long)
:rtype: `IntegratedAddress`
:raises: `TypeError` if the payment id is to... | [
"Integrates",
"payment",
"id",
"into",
"the",
"address",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/address.py#L114-L129 | [
"def",
"with_payment_id",
"(",
"self",
",",
"payment_id",
"=",
"0",
")",
":",
"payment_id",
"=",
"numbers",
".",
"PaymentID",
"(",
"payment_id",
")",
"if",
"not",
"payment_id",
".",
"is_short",
"(",
")",
":",
"raise",
"TypeError",
"(",
"\"Payment ID {0} has ... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | IntegratedAddress.base_address | Returns the base address without payment id.
:rtype: :class:`Address` | monero/address.py | def base_address(self):
"""Returns the base address without payment id.
:rtype: :class:`Address`
"""
prefix = 53 if self.is_testnet() else 24 if self.is_stagenet() else 18
data = bytearray([prefix]) + self._decoded[1:65]
checksum = keccak_256(data).digest()[:4]
re... | def base_address(self):
"""Returns the base address without payment id.
:rtype: :class:`Address`
"""
prefix = 53 if self.is_testnet() else 24 if self.is_stagenet() else 18
data = bytearray([prefix]) + self._decoded[1:65]
checksum = keccak_256(data).digest()[:4]
re... | [
"Returns",
"the",
"base",
"address",
"without",
"payment",
"id",
".",
":",
"rtype",
":",
":",
"class",
":",
"Address"
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/address.py#L168-L175 | [
"def",
"base_address",
"(",
"self",
")",
":",
"prefix",
"=",
"53",
"if",
"self",
".",
"is_testnet",
"(",
")",
"else",
"24",
"if",
"self",
".",
"is_stagenet",
"(",
")",
"else",
"18",
"data",
"=",
"bytearray",
"(",
"[",
"prefix",
"]",
")",
"+",
"self... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | encode | Encode hexadecimal string as base58 (ex: encoding a Monero address). | monero/base58.py | def encode(hex):
'''Encode hexadecimal string as base58 (ex: encoding a Monero address).'''
data = _hexToBin(hex)
l_data = len(data)
if l_data == 0:
return ""
full_block_count = l_data // __fullBlockSize
last_block_size = l_data % __fullBlockSize
res_size = full_block_count * __ful... | def encode(hex):
'''Encode hexadecimal string as base58 (ex: encoding a Monero address).'''
data = _hexToBin(hex)
l_data = len(data)
if l_data == 0:
return ""
full_block_count = l_data // __fullBlockSize
last_block_size = l_data % __fullBlockSize
res_size = full_block_count * __ful... | [
"Encode",
"hexadecimal",
"string",
"as",
"base58",
"(",
"ex",
":",
"encoding",
"a",
"Monero",
"address",
")",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/base58.py#L71-L91 | [
"def",
"encode",
"(",
"hex",
")",
":",
"data",
"=",
"_hexToBin",
"(",
"hex",
")",
"l_data",
"=",
"len",
"(",
"data",
")",
"if",
"l_data",
"==",
"0",
":",
"return",
"\"\"",
"full_block_count",
"=",
"l_data",
"//",
"__fullBlockSize",
"last_block_size",
"="... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | decode | Decode a base58 string (ex: a Monero address) into hexidecimal form. | monero/base58.py | def decode(enc):
'''Decode a base58 string (ex: a Monero address) into hexidecimal form.'''
enc = bytearray(enc, encoding='ascii')
l_enc = len(enc)
if l_enc == 0:
return ""
full_block_count = l_enc // __fullEncodedBlockSize
last_block_size = l_enc % __fullEncodedBlockSize
try:
... | def decode(enc):
'''Decode a base58 string (ex: a Monero address) into hexidecimal form.'''
enc = bytearray(enc, encoding='ascii')
l_enc = len(enc)
if l_enc == 0:
return ""
full_block_count = l_enc // __fullEncodedBlockSize
last_block_size = l_enc % __fullEncodedBlockSize
try:
... | [
"Decode",
"a",
"base58",
"string",
"(",
"ex",
":",
"a",
"Monero",
"address",
")",
"into",
"hexidecimal",
"form",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/base58.py#L127-L151 | [
"def",
"decode",
"(",
"enc",
")",
":",
"enc",
"=",
"bytearray",
"(",
"enc",
",",
"encoding",
"=",
"'ascii'",
")",
"l_enc",
"=",
"len",
"(",
"enc",
")",
"if",
"l_enc",
"==",
"0",
":",
"return",
"\"\"",
"full_block_count",
"=",
"l_enc",
"//",
"__fullEn... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wordlist.encode | Convert hexadecimal string to mnemonic word representation with checksum. | monero/wordlists/wordlist.py | def encode(cls, hex):
"""Convert hexadecimal string to mnemonic word representation with checksum.
"""
out = []
for i in range(len(hex) // 8):
word = endian_swap(hex[8*i:8*i+8])
x = int(word, 16)
w1 = x % cls.n
w2 = (x // cls.n + w1) % cls.... | def encode(cls, hex):
"""Convert hexadecimal string to mnemonic word representation with checksum.
"""
out = []
for i in range(len(hex) // 8):
word = endian_swap(hex[8*i:8*i+8])
x = int(word, 16)
w1 = x % cls.n
w2 = (x // cls.n + w1) % cls.... | [
"Convert",
"hexadecimal",
"string",
"to",
"mnemonic",
"word",
"representation",
"with",
"checksum",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wordlists/wordlist.py#L43-L56 | [
"def",
"encode",
"(",
"cls",
",",
"hex",
")",
":",
"out",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"hex",
")",
"//",
"8",
")",
":",
"word",
"=",
"endian_swap",
"(",
"hex",
"[",
"8",
"*",
"i",
":",
"8",
"*",
"i",
"+",
"8"... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wordlist.decode | Calculate hexadecimal representation of the phrase. | monero/wordlists/wordlist.py | def decode(cls, phrase):
"""Calculate hexadecimal representation of the phrase.
"""
phrase = phrase.split(" ")
out = ""
for i in range(len(phrase) // 3):
word1, word2, word3 = phrase[3*i:3*i+3]
w1 = cls.word_list.index(word1)
w2 = cls.word_list... | def decode(cls, phrase):
"""Calculate hexadecimal representation of the phrase.
"""
phrase = phrase.split(" ")
out = ""
for i in range(len(phrase) // 3):
word1, word2, word3 = phrase[3*i:3*i+3]
w1 = cls.word_list.index(word1)
w2 = cls.word_list... | [
"Calculate",
"hexadecimal",
"representation",
"of",
"the",
"phrase",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wordlists/wordlist.py#L59-L71 | [
"def",
"decode",
"(",
"cls",
",",
"phrase",
")",
":",
"phrase",
"=",
"phrase",
".",
"split",
"(",
"\" \"",
")",
"out",
"=",
"\"\"",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"phrase",
")",
"//",
"3",
")",
":",
"word1",
",",
"word2",
",",
"wor... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Wordlist.get_checksum | Given a mnemonic word string, return a string of the computed checksum.
:rtype: str | monero/wordlists/wordlist.py | def get_checksum(cls, phrase):
"""Given a mnemonic word string, return a string of the computed checksum.
:rtype: str
"""
phrase_split = phrase.split(" ")
if len(phrase_split) < 12:
raise ValueError("Invalid mnemonic phrase")
if len(phrase_split) > 13:
... | def get_checksum(cls, phrase):
"""Given a mnemonic word string, return a string of the computed checksum.
:rtype: str
"""
phrase_split = phrase.split(" ")
if len(phrase_split) < 12:
raise ValueError("Invalid mnemonic phrase")
if len(phrase_split) > 13:
... | [
"Given",
"a",
"mnemonic",
"word",
"string",
"return",
"a",
"string",
"of",
"the",
"computed",
"checksum",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wordlists/wordlist.py#L74-L92 | [
"def",
"get_checksum",
"(",
"cls",
",",
"phrase",
")",
":",
"phrase_split",
"=",
"phrase",
".",
"split",
"(",
"\" \"",
")",
"if",
"len",
"(",
"phrase_split",
")",
"<",
"12",
":",
"raise",
"ValueError",
"(",
"\"Invalid mnemonic phrase\"",
")",
"if",
"len",
... | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | Daemon.send_transaction | Sends a transaction generated by a :class:`Wallet <monero.wallet.Wallet>`.
:param tx: :class:`Transaction <monero.transaction.Transaction>`
:param relay: whether to relay the transaction to peers. If `False`, the daemon will have
to mine the transaction itself in order to have it includ... | monero/daemon.py | def send_transaction(self, tx, relay=True):
"""
Sends a transaction generated by a :class:`Wallet <monero.wallet.Wallet>`.
:param tx: :class:`Transaction <monero.transaction.Transaction>`
:param relay: whether to relay the transaction to peers. If `False`, the daemon will have
... | def send_transaction(self, tx, relay=True):
"""
Sends a transaction generated by a :class:`Wallet <monero.wallet.Wallet>`.
:param tx: :class:`Transaction <monero.transaction.Transaction>`
:param relay: whether to relay the transaction to peers. If `False`, the daemon will have
... | [
"Sends",
"a",
"transaction",
"generated",
"by",
"a",
":",
"class",
":",
"Wallet",
"<monero",
".",
"wallet",
".",
"Wallet",
">",
"."
] | monero-ecosystem/monero-python | python | https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/daemon.py#L27-L35 | [
"def",
"send_transaction",
"(",
"self",
",",
"tx",
",",
"relay",
"=",
"True",
")",
":",
"return",
"self",
".",
"_backend",
".",
"send_transaction",
"(",
"tx",
".",
"blob",
",",
"relay",
"=",
"relay",
")"
] | 64149f6323af57a3924f45ed87997d64387c5ee0 |
valid | one | Instantiates a picker, registers custom handlers for going back,
and starts the picker. | questionnaire/prompters.py | def one(prompt, *args, **kwargs):
"""Instantiates a picker, registers custom handlers for going back,
and starts the picker.
"""
indicator = '‣'
if sys.version_info < (3, 0):
indicator = '>'
def go_back(picker):
return None, -1
options, verbose_options = prepare_options(arg... | def one(prompt, *args, **kwargs):
"""Instantiates a picker, registers custom handlers for going back,
and starts the picker.
"""
indicator = '‣'
if sys.version_info < (3, 0):
indicator = '>'
def go_back(picker):
return None, -1
options, verbose_options = prepare_options(arg... | [
"Instantiates",
"a",
"picker",
"registers",
"custom",
"handlers",
"for",
"going",
"back",
"and",
"starts",
"the",
"picker",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/prompters.py#L46-L70 | [
"def",
"one",
"(",
"prompt",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"indicator",
"=",
"'‣'",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"indicator",
"=",
"'>'",
"def",
"go_back",
"(",
"picker",
")",
":",
... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | many | Calls `pick` in a while loop to allow user to pick many
options. Returns a list of chosen options. | questionnaire/prompters.py | def many(prompt, *args, **kwargs):
"""Calls `pick` in a while loop to allow user to pick many
options. Returns a list of chosen options.
"""
def get_options(options, chosen):
return [options[i] for i, c in enumerate(chosen) if c]
def get_verbose_options(verbose_options, chosen):
no,... | def many(prompt, *args, **kwargs):
"""Calls `pick` in a while loop to allow user to pick many
options. Returns a list of chosen options.
"""
def get_options(options, chosen):
return [options[i] for i, c in enumerate(chosen) if c]
def get_verbose_options(verbose_options, chosen):
no,... | [
"Calls",
"pick",
"in",
"a",
"while",
"loop",
"to",
"allow",
"user",
"to",
"pick",
"many",
"options",
".",
"Returns",
"a",
"list",
"of",
"chosen",
"options",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/prompters.py#L74-L109 | [
"def",
"many",
"(",
"prompt",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"get_options",
"(",
"options",
",",
"chosen",
")",
":",
"return",
"[",
"options",
"[",
"i",
"]",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"chosen",
")"... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | prepare_options | Create options and verbose options from strings and non-string iterables in
`options` array. | questionnaire/prompters.py | def prepare_options(options):
"""Create options and verbose options from strings and non-string iterables in
`options` array.
"""
options_, verbose_options = [], []
for option in options:
if is_string(option):
options_.append(option)
verbose_options.append(option)
... | def prepare_options(options):
"""Create options and verbose options from strings and non-string iterables in
`options` array.
"""
options_, verbose_options = [], []
for option in options:
if is_string(option):
options_.append(option)
verbose_options.append(option)
... | [
"Create",
"options",
"and",
"verbose",
"options",
"from",
"strings",
"and",
"non",
"-",
"string",
"iterables",
"in",
"options",
"array",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/prompters.py#L112-L124 | [
"def",
"prepare_options",
"(",
"options",
")",
":",
"options_",
",",
"verbose_options",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"option",
"in",
"options",
":",
"if",
"is_string",
"(",
"option",
")",
":",
"options_",
".",
"append",
"(",
"option",
")",
"ver... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | raw | Calls input to allow user to input an arbitrary string. User can go
back by entering the `go_back` string. Works in both Python 2 and 3. | questionnaire/prompters.py | def raw(prompt, *args, **kwargs):
"""Calls input to allow user to input an arbitrary string. User can go
back by entering the `go_back` string. Works in both Python 2 and 3.
"""
go_back = kwargs.get('go_back', '<')
type_ = kwargs.get('type', str)
default = kwargs.get('default', '')
with stdo... | def raw(prompt, *args, **kwargs):
"""Calls input to allow user to input an arbitrary string. User can go
back by entering the `go_back` string. Works in both Python 2 and 3.
"""
go_back = kwargs.get('go_back', '<')
type_ = kwargs.get('type', str)
default = kwargs.get('default', '')
with stdo... | [
"Calls",
"input",
"to",
"allow",
"user",
"to",
"input",
"an",
"arbitrary",
"string",
".",
"User",
"can",
"go",
"back",
"by",
"entering",
"the",
"go_back",
"string",
".",
"Works",
"in",
"both",
"Python",
"2",
"and",
"3",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/prompters.py#L128-L152 | [
"def",
"raw",
"(",
"prompt",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"go_back",
"=",
"kwargs",
".",
"get",
"(",
"'go_back'",
",",
"'<'",
")",
"type_",
"=",
"kwargs",
".",
"get",
"(",
"'type'",
",",
"str",
")",
"default",
"=",
"kwargs... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | stdout_redirected | Lifted from: https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
This is the only way I've found to redirect stdout with curses. This way the
output from questionnaire can be piped to another program, without piping
what's written to the terminal by the prompters. | questionnaire/prompters.py | def stdout_redirected(to):
"""Lifted from: https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
This is the only way I've found to redirect stdout with curses. This way the
output from questionnaire can be piped to another program, without piping
what's written to the termina... | def stdout_redirected(to):
"""Lifted from: https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
This is the only way I've found to redirect stdout with curses. This way the
output from questionnaire can be piped to another program, without piping
what's written to the termina... | [
"Lifted",
"from",
":",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"4675728",
"/",
"redirect",
"-",
"stdout",
"-",
"to",
"-",
"a",
"-",
"file",
"-",
"in",
"-",
"python"
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/prompters.py#L156-L179 | [
"def",
"stdout_redirected",
"(",
"to",
")",
":",
"stdout",
"=",
"sys",
".",
"stdout",
"stdout_fd",
"=",
"fileno",
"(",
"stdout",
")",
"# copy stdout_fd before it is overwritten",
"with",
"os",
".",
"fdopen",
"(",
"os",
".",
"dup",
"(",
"stdout_fd",
")",
",",... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | exit_on_keyboard_interrupt | Decorator that allows user to exit script by sending a keyboard interrupt
(ctrl + c) without raising an exception. | questionnaire/__init__.py | def exit_on_keyboard_interrupt(f):
"""Decorator that allows user to exit script by sending a keyboard interrupt
(ctrl + c) without raising an exception.
"""
@wraps(f)
def wrapper(*args, **kwargs):
raise_exception = kwargs.pop('raise_exception', False)
try:
return f(*args,... | def exit_on_keyboard_interrupt(f):
"""Decorator that allows user to exit script by sending a keyboard interrupt
(ctrl + c) without raising an exception.
"""
@wraps(f)
def wrapper(*args, **kwargs):
raise_exception = kwargs.pop('raise_exception', False)
try:
return f(*args,... | [
"Decorator",
"that",
"allows",
"user",
"to",
"exit",
"script",
"by",
"sending",
"a",
"keyboard",
"interrupt",
"(",
"ctrl",
"+",
"c",
")",
"without",
"raising",
"an",
"exception",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L16-L29 | [
"def",
"exit_on_keyboard_interrupt",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise_exception",
"=",
"kwargs",
".",
"pop",
"(",
"'raise_exception'",
",",
"False",
")",
"try... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Condition.get_operator | Assigns function to the operators property of the instance. | questionnaire/__init__.py | def get_operator(self, op):
"""Assigns function to the operators property of the instance.
"""
if op in self.OPERATORS:
return self.OPERATORS.get(op)
try:
n_args = len(inspect.getargspec(op)[0])
if n_args != 2:
raise TypeError
e... | def get_operator(self, op):
"""Assigns function to the operators property of the instance.
"""
if op in self.OPERATORS:
return self.OPERATORS.get(op)
try:
n_args = len(inspect.getargspec(op)[0])
if n_args != 2:
raise TypeError
e... | [
"Assigns",
"function",
"to",
"the",
"operators",
"property",
"of",
"the",
"instance",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L52-L65 | [
"def",
"get_operator",
"(",
"self",
",",
"op",
")",
":",
"if",
"op",
"in",
"self",
".",
"OPERATORS",
":",
"return",
"self",
".",
"OPERATORS",
".",
"get",
"(",
"op",
")",
"try",
":",
"n_args",
"=",
"len",
"(",
"inspect",
".",
"getargspec",
"(",
"op"... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Question.assign_prompter | If you want to change the core prompters registry, you can
override this method in a Question subclass. | questionnaire/__init__.py | def assign_prompter(self, prompter):
"""If you want to change the core prompters registry, you can
override this method in a Question subclass.
"""
if is_string(prompter):
if prompter not in prompters:
eprint("Error: '{}' is not a core prompter".format(prompte... | def assign_prompter(self, prompter):
"""If you want to change the core prompters registry, you can
override this method in a Question subclass.
"""
if is_string(prompter):
if prompter not in prompters:
eprint("Error: '{}' is not a core prompter".format(prompte... | [
"If",
"you",
"want",
"to",
"change",
"the",
"core",
"prompters",
"registry",
"you",
"can",
"override",
"this",
"method",
"in",
"a",
"Question",
"subclass",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L83-L93 | [
"def",
"assign_prompter",
"(",
"self",
",",
"prompter",
")",
":",
"if",
"is_string",
"(",
"prompter",
")",
":",
"if",
"prompter",
"not",
"in",
"prompters",
":",
"eprint",
"(",
"\"Error: '{}' is not a core prompter\"",
".",
"format",
"(",
"prompter",
")",
")",
... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.add | Add a Question instance to the questions dict. Each key points
to a list of Question instances with that key. Use the `question`
kwarg to pass a Question instance if you want, or pass in the same
args you would pass to instantiate a question. | questionnaire/__init__.py | def add(self, *args, **kwargs):
"""Add a Question instance to the questions dict. Each key points
to a list of Question instances with that key. Use the `question`
kwarg to pass a Question instance if you want, or pass in the same
args you would pass to instantiate a question.
""... | def add(self, *args, **kwargs):
"""Add a Question instance to the questions dict. Each key points
to a list of Question instances with that key. Use the `question`
kwarg to pass a Question instance if you want, or pass in the same
args you would pass to instantiate a question.
""... | [
"Add",
"a",
"Question",
"instance",
"to",
"the",
"questions",
"dict",
".",
"Each",
"key",
"points",
"to",
"a",
"list",
"of",
"Question",
"instances",
"with",
"that",
"key",
".",
"Use",
"the",
"question",
"kwarg",
"to",
"pass",
"a",
"Question",
"instance",
... | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L124-L135 | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'question'",
"in",
"kwargs",
"and",
"isinstance",
"(",
"kwargs",
"[",
"'question'",
"]",
",",
"Question",
")",
":",
"question",
"=",
"kwargs",
"[",
"'question'",
"... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.ask | Asks the next question in the questionnaire and returns the answer,
unless user goes back. | questionnaire/__init__.py | def ask(self, error=None):
"""Asks the next question in the questionnaire and returns the answer,
unless user goes back.
"""
q = self.next_question
if q is None:
return
try:
answer = q.prompter(self.get_prompt(q, error), *q.prompter_args, **q.prom... | def ask(self, error=None):
"""Asks the next question in the questionnaire and returns the answer,
unless user goes back.
"""
q = self.next_question
if q is None:
return
try:
answer = q.prompter(self.get_prompt(q, error), *q.prompter_args, **q.prom... | [
"Asks",
"the",
"next",
"question",
"in",
"the",
"questionnaire",
"and",
"returns",
"the",
"answer",
"unless",
"user",
"goes",
"back",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L163-L188 | [
"def",
"ask",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"q",
"=",
"self",
".",
"next_question",
"if",
"q",
"is",
"None",
":",
"return",
"try",
":",
"answer",
"=",
"q",
".",
"prompter",
"(",
"self",
".",
"get_prompt",
"(",
"q",
",",
"error... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.next_question | Returns the next `Question` in the questionnaire, or `None` if there
are no questions left. Returns first question for whose key there is no
answer and for which condition is satisfied, or for which there is no
condition. | questionnaire/__init__.py | def next_question(self):
"""Returns the next `Question` in the questionnaire, or `None` if there
are no questions left. Returns first question for whose key there is no
answer and for which condition is satisfied, or for which there is no
condition.
"""
for key, questions... | def next_question(self):
"""Returns the next `Question` in the questionnaire, or `None` if there
are no questions left. Returns first question for whose key there is no
answer and for which condition is satisfied, or for which there is no
condition.
"""
for key, questions... | [
"Returns",
"the",
"next",
"Question",
"in",
"the",
"questionnaire",
"or",
"None",
"if",
"there",
"are",
"no",
"questions",
"left",
".",
"Returns",
"first",
"question",
"for",
"whose",
"key",
"there",
"is",
"no",
"answer",
"and",
"for",
"which",
"condition",
... | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L200-L212 | [
"def",
"next_question",
"(",
"self",
")",
":",
"for",
"key",
",",
"questions",
"in",
"self",
".",
"questions",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"answers",
":",
"continue",
"for",
"question",
"in",
"questions",
":",
"if",
"... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.check_condition | Helper that returns True if condition is satisfied/doesn't exist. | questionnaire/__init__.py | def check_condition(self, condition):
"""Helper that returns True if condition is satisfied/doesn't exist.
"""
if not condition:
return True
for c in condition.conditions:
key, value, operator = c
if not operator(self.answers[key], value):
... | def check_condition(self, condition):
"""Helper that returns True if condition is satisfied/doesn't exist.
"""
if not condition:
return True
for c in condition.conditions:
key, value, operator = c
if not operator(self.answers[key], value):
... | [
"Helper",
"that",
"returns",
"True",
"if",
"condition",
"is",
"satisfied",
"/",
"doesn",
"t",
"exist",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L214-L223 | [
"def",
"check_condition",
"(",
"self",
",",
"condition",
")",
":",
"if",
"not",
"condition",
":",
"return",
"True",
"for",
"c",
"in",
"condition",
".",
"conditions",
":",
"key",
",",
"value",
",",
"operator",
"=",
"c",
"if",
"not",
"operator",
"(",
"se... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.go_back | Move `n` questions back in the questionnaire by removing the last `n`
answers. | questionnaire/__init__.py | def go_back(self, n=1):
"""Move `n` questions back in the questionnaire by removing the last `n`
answers.
"""
if not self.can_go_back:
return
N = max(len(self.answers)-abs(n), 0)
self.answers = OrderedDict(islice(self.answers.items(), N)) | def go_back(self, n=1):
"""Move `n` questions back in the questionnaire by removing the last `n`
answers.
"""
if not self.can_go_back:
return
N = max(len(self.answers)-abs(n), 0)
self.answers = OrderedDict(islice(self.answers.items(), N)) | [
"Move",
"n",
"questions",
"back",
"in",
"the",
"questionnaire",
"by",
"removing",
"the",
"last",
"n",
"answers",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L225-L232 | [
"def",
"go_back",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"if",
"not",
"self",
".",
"can_go_back",
":",
"return",
"N",
"=",
"max",
"(",
"len",
"(",
"self",
".",
"answers",
")",
"-",
"abs",
"(",
"n",
")",
",",
"0",
")",
"self",
".",
"answer... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.format_answers | Formats answers depending on `fmt`. | questionnaire/__init__.py | def format_answers(self, fmt='obj'):
"""Formats answers depending on `fmt`.
"""
fmts = ('obj', 'array', 'plain')
if fmt not in fmts:
eprint("Error: '{}' not in {}".format(fmt, fmts))
return
def stringify(val):
if type(val) in (list, tuple):
... | def format_answers(self, fmt='obj'):
"""Formats answers depending on `fmt`.
"""
fmts = ('obj', 'array', 'plain')
if fmt not in fmts:
eprint("Error: '{}' not in {}".format(fmt, fmts))
return
def stringify(val):
if type(val) in (list, tuple):
... | [
"Formats",
"answers",
"depending",
"on",
"fmt",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L241-L261 | [
"def",
"format_answers",
"(",
"self",
",",
"fmt",
"=",
"'obj'",
")",
":",
"fmts",
"=",
"(",
"'obj'",
",",
"'array'",
",",
"'plain'",
")",
"if",
"fmt",
"not",
"in",
"fmts",
":",
"eprint",
"(",
"\"Error: '{}' not in {}\"",
".",
"format",
"(",
"fmt",
",",... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | Questionnaire.answer_display | Helper method for displaying the answers so far. | questionnaire/__init__.py | def answer_display(self, s=''):
"""Helper method for displaying the answers so far.
"""
padding = len(max(self.questions.keys(), key=len)) + 5
for key in list(self.answers.keys()):
s += '{:>{}} : {}\n'.format(key, padding, self.answers[key])
return s | def answer_display(self, s=''):
"""Helper method for displaying the answers so far.
"""
padding = len(max(self.questions.keys(), key=len)) + 5
for key in list(self.answers.keys()):
s += '{:>{}} : {}\n'.format(key, padding, self.answers[key])
return s | [
"Helper",
"method",
"for",
"displaying",
"the",
"answers",
"so",
"far",
"."
] | kylebebak/questionnaire | python | https://github.com/kylebebak/questionnaire/blob/ed92642e8a2a0198da198acbcde2707f1d528585/questionnaire/__init__.py#L263-L269 | [
"def",
"answer_display",
"(",
"self",
",",
"s",
"=",
"''",
")",
":",
"padding",
"=",
"len",
"(",
"max",
"(",
"self",
".",
"questions",
".",
"keys",
"(",
")",
",",
"key",
"=",
"len",
")",
")",
"+",
"5",
"for",
"key",
"in",
"list",
"(",
"self",
... | ed92642e8a2a0198da198acbcde2707f1d528585 |
valid | IntentContainer.add_intent | Creates a new intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
lines (list<str>): All the sentences that should activate the intent
reload_cache: Whether to ignore cached intent if exists | padatious/intent_container.py | def add_intent(self, name, lines, reload_cache=False):
"""
Creates a new intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
lines (list<str>): All the sentences that should activate the intent
reload_cache: Whether... | def add_intent(self, name, lines, reload_cache=False):
"""
Creates a new intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
lines (list<str>): All the sentences that should activate the intent
reload_cache: Whether... | [
"Creates",
"a",
"new",
"intent",
"optionally",
"checking",
"the",
"cache",
"first"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L72-L83 | [
"def",
"add_intent",
"(",
"self",
",",
"name",
",",
"lines",
",",
"reload_cache",
"=",
"False",
")",
":",
"self",
".",
"intents",
".",
"add",
"(",
"name",
",",
"lines",
",",
"reload_cache",
")",
"self",
".",
"padaos",
".",
"add_intent",
"(",
"name",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.add_entity | Adds an entity that matches the given lines.
Example:
self.add_intent('weather', ['will it rain on {weekday}?'])
self.add_entity('{weekday}', ['monday', 'tuesday', 'wednesday']) # ...
Args:
name (str): The name of the entity
lines (list<str>): Lines of ... | padatious/intent_container.py | def add_entity(self, name, lines, reload_cache=False):
"""
Adds an entity that matches the given lines.
Example:
self.add_intent('weather', ['will it rain on {weekday}?'])
self.add_entity('{weekday}', ['monday', 'tuesday', 'wednesday']) # ...
Args:
... | def add_entity(self, name, lines, reload_cache=False):
"""
Adds an entity that matches the given lines.
Example:
self.add_intent('weather', ['will it rain on {weekday}?'])
self.add_entity('{weekday}', ['monday', 'tuesday', 'wednesday']) # ...
Args:
... | [
"Adds",
"an",
"entity",
"that",
"matches",
"the",
"given",
"lines",
"."
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L86-L102 | [
"def",
"add_entity",
"(",
"self",
",",
"name",
",",
"lines",
",",
"reload_cache",
"=",
"False",
")",
":",
"Entity",
".",
"verify_name",
"(",
"name",
")",
"self",
".",
"entities",
".",
"add",
"(",
"Entity",
".",
"wrap_name",
"(",
"name",
")",
",",
"li... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.load_entity | Loads an entity, optionally checking the cache first
Args:
name (str): The associated name of the entity
file_name (str): The location of the entity file
reload_cache (bool): Whether to refresh all of cache | padatious/intent_container.py | def load_entity(self, name, file_name, reload_cache=False):
"""
Loads an entity, optionally checking the cache first
Args:
name (str): The associated name of the entity
file_name (str): The location of the entity file
reload_cache (bool): Whether to refresh all of... | def load_entity(self, name, file_name, reload_cache=False):
"""
Loads an entity, optionally checking the cache first
Args:
name (str): The associated name of the entity
file_name (str): The location of the entity file
reload_cache (bool): Whether to refresh all of... | [
"Loads",
"an",
"entity",
"optionally",
"checking",
"the",
"cache",
"first"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L105-L118 | [
"def",
"load_entity",
"(",
"self",
",",
"name",
",",
"file_name",
",",
"reload_cache",
"=",
"False",
")",
":",
"Entity",
".",
"verify_name",
"(",
"name",
")",
"self",
".",
"entities",
".",
"load",
"(",
"Entity",
".",
"wrap_name",
"(",
"name",
")",
",",... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.load_intent | Loads an intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
file_name (str): The location of the intent file
reload_cache (bool): Whether to refresh all of cache | padatious/intent_container.py | def load_intent(self, name, file_name, reload_cache=False):
"""
Loads an intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
file_name (str): The location of the intent file
reload_cache (bool): Whether to refresh a... | def load_intent(self, name, file_name, reload_cache=False):
"""
Loads an intent, optionally checking the cache first
Args:
name (str): The associated name of the intent
file_name (str): The location of the intent file
reload_cache (bool): Whether to refresh a... | [
"Loads",
"an",
"intent",
"optionally",
"checking",
"the",
"cache",
"first"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L126-L138 | [
"def",
"load_intent",
"(",
"self",
",",
"name",
",",
"file_name",
",",
"reload_cache",
"=",
"False",
")",
":",
"self",
".",
"intents",
".",
"load",
"(",
"name",
",",
"file_name",
",",
"reload_cache",
")",
"with",
"open",
"(",
"file_name",
")",
"as",
"f... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.remove_intent | Unload an intent | padatious/intent_container.py | def remove_intent(self, name):
"""Unload an intent"""
self.intents.remove(name)
self.padaos.remove_intent(name)
self.must_train = True | def remove_intent(self, name):
"""Unload an intent"""
self.intents.remove(name)
self.padaos.remove_intent(name)
self.must_train = True | [
"Unload",
"an",
"intent"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L141-L145 | [
"def",
"remove_intent",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"intents",
".",
"remove",
"(",
"name",
")",
"self",
".",
"padaos",
".",
"remove_intent",
"(",
"name",
")",
"self",
".",
"must_train",
"=",
"True"
] | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.remove_entity | Unload an entity | padatious/intent_container.py | def remove_entity(self, name):
"""Unload an entity"""
self.entities.remove(name)
self.padaos.remove_entity(name) | def remove_entity(self, name):
"""Unload an entity"""
self.entities.remove(name)
self.padaos.remove_entity(name) | [
"Unload",
"an",
"entity"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L148-L151 | [
"def",
"remove_entity",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"entities",
".",
"remove",
"(",
"name",
")",
"self",
".",
"padaos",
".",
"remove_entity",
"(",
"name",
")"
] | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.train | Trains all the loaded intents that need to be updated
If a cache file exists with the same hash as the intent file,
the intent will not be trained and just loaded from file
Args:
debug (bool): Whether to print a message to stdout each time a new intent is trained
force (... | padatious/intent_container.py | def train(self, debug=True, force=False, single_thread=False, timeout=20):
"""
Trains all the loaded intents that need to be updated
If a cache file exists with the same hash as the intent file,
the intent will not be trained and just loaded from file
Args:
debug (bo... | def train(self, debug=True, force=False, single_thread=False, timeout=20):
"""
Trains all the loaded intents that need to be updated
If a cache file exists with the same hash as the intent file,
the intent will not be trained and just loaded from file
Args:
debug (bo... | [
"Trains",
"all",
"the",
"loaded",
"intents",
"that",
"need",
"to",
"be",
"updated",
"If",
"a",
"cache",
"file",
"exists",
"with",
"the",
"same",
"hash",
"as",
"the",
"intent",
"file",
"the",
"intent",
"will",
"not",
"be",
"trained",
"and",
"just",
"loade... | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L162-L188 | [
"def",
"train",
"(",
"self",
",",
"debug",
"=",
"True",
",",
"force",
"=",
"False",
",",
"single_thread",
"=",
"False",
",",
"timeout",
"=",
"20",
")",
":",
"if",
"not",
"self",
".",
"must_train",
"and",
"not",
"force",
":",
"return",
"self",
".",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.train_subprocess | Trains in a subprocess which provides a timeout guarantees everything shuts down properly
Args:
See <train>
Returns:
bool: True for success, False if timed out | padatious/intent_container.py | def train_subprocess(self, *args, **kwargs):
"""
Trains in a subprocess which provides a timeout guarantees everything shuts down properly
Args:
See <train>
Returns:
bool: True for success, False if timed out
"""
ret = call([
sys.execu... | def train_subprocess(self, *args, **kwargs):
"""
Trains in a subprocess which provides a timeout guarantees everything shuts down properly
Args:
See <train>
Returns:
bool: True for success, False if timed out
"""
ret = call([
sys.execu... | [
"Trains",
"in",
"a",
"subprocess",
"which",
"provides",
"a",
"timeout",
"guarantees",
"everything",
"shuts",
"down",
"properly"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L190-L217 | [
"def",
"train_subprocess",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"call",
"(",
"[",
"sys",
".",
"executable",
",",
"'-m'",
",",
"'padatious'",
",",
"'train'",
",",
"self",
".",
"cache_dir",
",",
"'-d'",
",",
"... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.calc_intents | Tests all the intents against the query and returns
data on how well each one matched against the query
Args:
query (str): Input sentence to test against intents
Returns:
list<MatchData>: List of intent matches
See calc_intent() for a description of the returned ... | padatious/intent_container.py | def calc_intents(self, query):
"""
Tests all the intents against the query and returns
data on how well each one matched against the query
Args:
query (str): Input sentence to test against intents
Returns:
list<MatchData>: List of intent matches
S... | def calc_intents(self, query):
"""
Tests all the intents against the query and returns
data on how well each one matched against the query
Args:
query (str): Input sentence to test against intents
Returns:
list<MatchData>: List of intent matches
S... | [
"Tests",
"all",
"the",
"intents",
"against",
"the",
"query",
"and",
"returns",
"data",
"on",
"how",
"well",
"each",
"one",
"matched",
"against",
"the",
"query"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L219-L239 | [
"def",
"calc_intents",
"(",
"self",
",",
"query",
")",
":",
"if",
"self",
".",
"must_train",
":",
"self",
".",
"train",
"(",
")",
"intents",
"=",
"{",
"}",
"if",
"self",
".",
"train_thread",
"and",
"self",
".",
"train_thread",
".",
"is_alive",
"(",
"... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | IntentContainer.calc_intent | Tests all the intents against the query and returns
match data of the best intent
Args:
query (str): Input sentence to test against intents
Returns:
MatchData: Best intent match | padatious/intent_container.py | def calc_intent(self, query):
"""
Tests all the intents against the query and returns
match data of the best intent
Args:
query (str): Input sentence to test against intents
Returns:
MatchData: Best intent match
"""
matches = self.calc_int... | def calc_intent(self, query):
"""
Tests all the intents against the query and returns
match data of the best intent
Args:
query (str): Input sentence to test against intents
Returns:
MatchData: Best intent match
"""
matches = self.calc_int... | [
"Tests",
"all",
"the",
"intents",
"against",
"the",
"query",
"and",
"returns",
"match",
"data",
"of",
"the",
"best",
"intent"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/intent_container.py#L241-L256 | [
"def",
"calc_intent",
"(",
"self",
",",
"query",
")",
":",
"matches",
"=",
"self",
".",
"calc_intents",
"(",
"query",
")",
"if",
"len",
"(",
"matches",
")",
"==",
"0",
":",
"return",
"MatchData",
"(",
"''",
",",
"''",
")",
"best_match",
"=",
"max",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | Sentence.expand | Creates a combination of all sub-sentences.
Returns:
List<List<str>>: A list with all subsentence expansions combined in
every possible way | padatious/bracket_expansion.py | def expand(self):
"""
Creates a combination of all sub-sentences.
Returns:
List<List<str>>: A list with all subsentence expansions combined in
every possible way
"""
old_expanded = [[]]
for sub in self._tree:
... | def expand(self):
"""
Creates a combination of all sub-sentences.
Returns:
List<List<str>>: A list with all subsentence expansions combined in
every possible way
"""
old_expanded = [[]]
for sub in self._tree:
... | [
"Creates",
"a",
"combination",
"of",
"all",
"sub",
"-",
"sentences",
".",
"Returns",
":",
"List<List<str",
">>",
":",
"A",
"list",
"with",
"all",
"subsentence",
"expansions",
"combined",
"in",
"every",
"possible",
"way"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/bracket_expansion.py#L75-L92 | [
"def",
"expand",
"(",
"self",
")",
":",
"old_expanded",
"=",
"[",
"[",
"]",
"]",
"for",
"sub",
"in",
"self",
".",
"_tree",
":",
"sub_expanded",
"=",
"sub",
".",
"expand",
"(",
")",
"new_expanded",
"=",
"[",
"]",
"while",
"len",
"(",
"old_expanded",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | Options.expand | Returns all of its options as seperated sub-sentences.
Returns:
List<List<str>>: A list containing the sentences created by all
expansions of its sub-sentences | padatious/bracket_expansion.py | def expand(self):
"""
Returns all of its options as seperated sub-sentences.
Returns:
List<List<str>>: A list containing the sentences created by all
expansions of its sub-sentences
"""
options = []
for option in self.... | def expand(self):
"""
Returns all of its options as seperated sub-sentences.
Returns:
List<List<str>>: A list containing the sentences created by all
expansions of its sub-sentences
"""
options = []
for option in self.... | [
"Returns",
"all",
"of",
"its",
"options",
"as",
"seperated",
"sub",
"-",
"sentences",
".",
"Returns",
":",
"List<List<str",
">>",
":",
"A",
"list",
"containing",
"the",
"sentences",
"created",
"by",
"all",
"expansions",
"of",
"its",
"sub",
"-",
"sentences"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/bracket_expansion.py#L102-L113 | [
"def",
"expand",
"(",
"self",
")",
":",
"options",
"=",
"[",
"]",
"for",
"option",
"in",
"self",
".",
"_tree",
":",
"options",
".",
"extend",
"(",
"option",
".",
"expand",
"(",
")",
")",
"return",
"options"
] | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | SentenceTreeParser._parse_expr | Generate sentence token trees from the current position to
the next closing parentheses / end of the list and return it
['1', '(', '2', '|', '3, ')'] -> ['1', [['2'], ['3']]]
['2', '|', '3'] -> [['2'], ['3']] | padatious/bracket_expansion.py | def _parse_expr(self):
"""
Generate sentence token trees from the current position to
the next closing parentheses / end of the list and return it
['1', '(', '2', '|', '3, ')'] -> ['1', [['2'], ['3']]]
['2', '|', '3'] -> [['2'], ['3']]
"""
# List of all gen... | def _parse_expr(self):
"""
Generate sentence token trees from the current position to
the next closing parentheses / end of the list and return it
['1', '(', '2', '|', '3, ')'] -> ['1', [['2'], ['3']]]
['2', '|', '3'] -> [['2'], ['3']]
"""
# List of all gen... | [
"Generate",
"sentence",
"token",
"trees",
"from",
"the",
"current",
"position",
"to",
"the",
"next",
"closing",
"parentheses",
"/",
"end",
"of",
"the",
"list",
"and",
"return",
"it",
"[",
"1",
"(",
"2",
"|",
"3",
")",
"]",
"-",
">",
"[",
"1",
"[[",
... | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/bracket_expansion.py#L133-L172 | [
"def",
"_parse_expr",
"(",
"self",
")",
":",
"# List of all generated sentences\r",
"sentence_list",
"=",
"[",
"]",
"# Currently active sentence\r",
"cur_sentence",
"=",
"[",
"]",
"sentence_list",
".",
"append",
"(",
"Sentence",
"(",
"cur_sentence",
")",
")",
"# Det... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | _train_and_save | Internal pickleable function used to train objects in another process | padatious/training_manager.py | def _train_and_save(obj, cache, data, print_updates):
"""Internal pickleable function used to train objects in another process"""
obj.train(data)
if print_updates:
print('Regenerated ' + obj.name + '.')
obj.save(cache) | def _train_and_save(obj, cache, data, print_updates):
"""Internal pickleable function used to train objects in another process"""
obj.train(data)
if print_updates:
print('Regenerated ' + obj.name + '.')
obj.save(cache) | [
"Internal",
"pickleable",
"function",
"used",
"to",
"train",
"objects",
"in",
"another",
"process"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/training_manager.py#L24-L29 | [
"def",
"_train_and_save",
"(",
"obj",
",",
"cache",
",",
"data",
",",
"print_updates",
")",
":",
"obj",
".",
"train",
"(",
"data",
")",
"if",
"print_updates",
":",
"print",
"(",
"'Regenerated '",
"+",
"obj",
".",
"name",
"+",
"'.'",
")",
"obj",
".",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | Entity.wrap_name | Wraps SkillName:entity into SkillName:{entity} | padatious/entity.py | def wrap_name(name):
"""Wraps SkillName:entity into SkillName:{entity}"""
if ':' in name:
parts = name.split(':')
intent_name, ent_name = parts[0], parts[1:]
return intent_name + ':{' + ':'.join(ent_name) + '}'
else:
return '{' + name + '}' | def wrap_name(name):
"""Wraps SkillName:entity into SkillName:{entity}"""
if ':' in name:
parts = name.split(':')
intent_name, ent_name = parts[0], parts[1:]
return intent_name + ':{' + ':'.join(ent_name) + '}'
else:
return '{' + name + '}' | [
"Wraps",
"SkillName",
":",
"entity",
"into",
"SkillName",
":",
"{",
"entity",
"}"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/entity.py#L32-L39 | [
"def",
"wrap_name",
"(",
"name",
")",
":",
"if",
"':'",
"in",
"name",
":",
"parts",
"=",
"name",
".",
"split",
"(",
"':'",
")",
"intent_name",
",",
"ent_name",
"=",
"parts",
"[",
"0",
"]",
",",
"parts",
"[",
"1",
":",
"]",
"return",
"intent_name",
... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | lines_hash | Creates a unique binary id for the given lines
Args:
lines (list<str>): List of strings that should be collectively hashed
Returns:
bytearray: Binary hash | padatious/util.py | def lines_hash(lines):
"""
Creates a unique binary id for the given lines
Args:
lines (list<str>): List of strings that should be collectively hashed
Returns:
bytearray: Binary hash
"""
x = xxh32()
for i in lines:
x.update(i.encode())
return x.digest() | def lines_hash(lines):
"""
Creates a unique binary id for the given lines
Args:
lines (list<str>): List of strings that should be collectively hashed
Returns:
bytearray: Binary hash
"""
x = xxh32()
for i in lines:
x.update(i.encode())
return x.digest() | [
"Creates",
"a",
"unique",
"binary",
"id",
"for",
"the",
"given",
"lines",
"Args",
":",
"lines",
"(",
"list<str",
">",
")",
":",
"List",
"of",
"strings",
"that",
"should",
"be",
"collectively",
"hashed",
"Returns",
":",
"bytearray",
":",
"Binary",
"hash"
] | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/util.py#L19-L30 | [
"def",
"lines_hash",
"(",
"lines",
")",
":",
"x",
"=",
"xxh32",
"(",
")",
"for",
"i",
"in",
"lines",
":",
"x",
".",
"update",
"(",
"i",
".",
"encode",
"(",
")",
")",
"return",
"x",
".",
"digest",
"(",
")"
] | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | tokenize | Converts a single sentence into a list of individual significant units
Args:
sentence (str): Input string ie. 'This is a sentence.'
Returns:
list<str>: List of tokens ie. ['this', 'is', 'a', 'sentence'] | padatious/util.py | def tokenize(sentence):
"""
Converts a single sentence into a list of individual significant units
Args:
sentence (str): Input string ie. 'This is a sentence.'
Returns:
list<str>: List of tokens ie. ['this', 'is', 'a', 'sentence']
"""
tokens = []
class Vars:
start_po... | def tokenize(sentence):
"""
Converts a single sentence into a list of individual significant units
Args:
sentence (str): Input string ie. 'This is a sentence.'
Returns:
list<str>: List of tokens ie. ['this', 'is', 'a', 'sentence']
"""
tokens = []
class Vars:
start_po... | [
"Converts",
"a",
"single",
"sentence",
"into",
"a",
"list",
"of",
"individual",
"significant",
"units",
"Args",
":",
"sentence",
"(",
"str",
")",
":",
"Input",
"string",
"ie",
".",
"This",
"is",
"a",
"sentence",
".",
"Returns",
":",
"list<str",
">",
":",... | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/util.py#L33-L68 | [
"def",
"tokenize",
"(",
"sentence",
")",
":",
"tokens",
"=",
"[",
"]",
"class",
"Vars",
":",
"start_pos",
"=",
"-",
"1",
"last_type",
"=",
"'o'",
"def",
"update",
"(",
"c",
",",
"i",
")",
":",
"if",
"c",
".",
"isalpha",
"(",
")",
"or",
"c",
"in... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | resolve_conflicts | Checks for duplicate inputs and if there are any,
remove one and set the output to the max of the two outputs
Args:
inputs (list<list<float>>): Array of input vectors
outputs (list<list<float>>): Array of output vectors
Returns:
tuple<inputs, outputs>: The modified inputs and outputs | padatious/util.py | def resolve_conflicts(inputs, outputs):
"""
Checks for duplicate inputs and if there are any,
remove one and set the output to the max of the two outputs
Args:
inputs (list<list<float>>): Array of input vectors
outputs (list<list<float>>): Array of output vectors
Returns:
tup... | def resolve_conflicts(inputs, outputs):
"""
Checks for duplicate inputs and if there are any,
remove one and set the output to the max of the two outputs
Args:
inputs (list<list<float>>): Array of input vectors
outputs (list<list<float>>): Array of output vectors
Returns:
tup... | [
"Checks",
"for",
"duplicate",
"inputs",
"and",
"if",
"there",
"are",
"any",
"remove",
"one",
"and",
"set",
"the",
"output",
"to",
"the",
"max",
"of",
"the",
"two",
"outputs",
"Args",
":",
"inputs",
"(",
"list<list<float",
">>",
")",
":",
"Array",
"of",
... | MycroftAI/padatious | python | https://github.com/MycroftAI/padatious/blob/794a2530d6079bdd06e193edd0d30b2cc793e631/padatious/util.py#L99-L124 | [
"def",
"resolve_conflicts",
"(",
"inputs",
",",
"outputs",
")",
":",
"data",
"=",
"{",
"}",
"for",
"inp",
",",
"out",
"in",
"zip",
"(",
"inputs",
",",
"outputs",
")",
":",
"tup",
"=",
"tuple",
"(",
"inp",
")",
"if",
"tup",
"in",
"data",
":",
"dat... | 794a2530d6079bdd06e193edd0d30b2cc793e631 |
valid | main | Re-apply type annotations from .pyi stubs to your codebase. | retype.py | def main(src, pyi_dir, target_dir, incremental, quiet, replace_any, hg, traceback):
"""Re-apply type annotations from .pyi stubs to your codebase."""
Config.incremental = incremental
Config.replace_any = replace_any
returncode = 0
for src_entry in src:
for file, error, exc_type, tb in retype... | def main(src, pyi_dir, target_dir, incremental, quiet, replace_any, hg, traceback):
"""Re-apply type annotations from .pyi stubs to your codebase."""
Config.incremental = incremental
Config.replace_any = replace_any
returncode = 0
for src_entry in src:
for file, error, exc_type, tb in retype... | [
"Re",
"-",
"apply",
"type",
"annotations",
"from",
".",
"pyi",
"stubs",
"to",
"your",
"codebase",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L87-L113 | [
"def",
"main",
"(",
"src",
",",
"pyi_dir",
",",
"target_dir",
",",
"incremental",
",",
"quiet",
",",
"replace_any",
",",
"hg",
",",
"traceback",
")",
":",
"Config",
".",
"incremental",
"=",
"incremental",
"Config",
".",
"replace_any",
"=",
"replace_any",
"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | retype_path | Recursively retype files or directories given. Generate errors. | retype.py | def retype_path(
src, pyi_dir, targets, *, src_explicitly_given=False, quiet=False, hg=False
):
"""Recursively retype files or directories given. Generate errors."""
if src.is_dir():
for child in src.iterdir():
if child == pyi_dir or child == targets:
continue
... | def retype_path(
src, pyi_dir, targets, *, src_explicitly_given=False, quiet=False, hg=False
):
"""Recursively retype files or directories given. Generate errors."""
if src.is_dir():
for child in src.iterdir():
if child == pyi_dir or child == targets:
continue
... | [
"Recursively",
"retype",
"files",
"or",
"directories",
"given",
".",
"Generate",
"errors",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L116-L136 | [
"def",
"retype_path",
"(",
"src",
",",
"pyi_dir",
",",
"targets",
",",
"*",
",",
"src_explicitly_given",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"hg",
"=",
"False",
")",
":",
"if",
"src",
".",
"is_dir",
"(",
")",
":",
"for",
"child",
"in",
"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | retype_file | Retype `src`, finding types in `pyi_dir`. Save in `targets`.
The file should remain formatted exactly as it was before, save for:
- annotations
- additional imports needed to satisfy annotations
- additional module-level names needed to satisfy annotations
Type comments in sources are normalized t... | retype.py | def retype_file(src, pyi_dir, targets, *, quiet=False, hg=False):
"""Retype `src`, finding types in `pyi_dir`. Save in `targets`.
The file should remain formatted exactly as it was before, save for:
- annotations
- additional imports needed to satisfy annotations
- additional module-level names nee... | def retype_file(src, pyi_dir, targets, *, quiet=False, hg=False):
"""Retype `src`, finding types in `pyi_dir`. Save in `targets`.
The file should remain formatted exactly as it was before, save for:
- annotations
- additional imports needed to satisfy annotations
- additional module-level names nee... | [
"Retype",
"src",
"finding",
"types",
"in",
"pyi_dir",
".",
"Save",
"in",
"targets",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L139-L169 | [
"def",
"retype_file",
"(",
"src",
",",
"pyi_dir",
",",
"targets",
",",
"*",
",",
"quiet",
"=",
"False",
",",
"hg",
"=",
"False",
")",
":",
"with",
"tokenize",
".",
"open",
"(",
"src",
")",
"as",
"src_buffer",
":",
"src_encoding",
"=",
"src_buffer",
"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | lib2to3_parse | Given a string with source, return the lib2to3 Node. | retype.py | def lib2to3_parse(src_txt):
"""Given a string with source, return the lib2to3 Node."""
grammar = pygram.python_grammar_no_print_statement
drv = driver.Driver(grammar, pytree.convert)
if src_txt[-1] != '\n':
nl = '\r\n' if '\r\n' in src_txt[:1024] else '\n'
src_txt += nl
try:
... | def lib2to3_parse(src_txt):
"""Given a string with source, return the lib2to3 Node."""
grammar = pygram.python_grammar_no_print_statement
drv = driver.Driver(grammar, pytree.convert)
if src_txt[-1] != '\n':
nl = '\r\n' if '\r\n' in src_txt[:1024] else '\n'
src_txt += nl
try:
... | [
"Given",
"a",
"string",
"with",
"source",
"return",
"the",
"lib2to3",
"Node",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L172-L193 | [
"def",
"lib2to3_parse",
"(",
"src_txt",
")",
":",
"grammar",
"=",
"pygram",
".",
"python_grammar_no_print_statement",
"drv",
"=",
"driver",
".",
"Driver",
"(",
"grammar",
",",
"pytree",
".",
"convert",
")",
"if",
"src_txt",
"[",
"-",
"1",
"]",
"!=",
"'\\n'... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | lib2to3_unparse | Given a lib2to3 node, return its string representation. | retype.py | def lib2to3_unparse(node, *, hg=False):
"""Given a lib2to3 node, return its string representation."""
code = str(node)
if hg:
from retype_hgext import apply_job_security
code = apply_job_security(code)
return code | def lib2to3_unparse(node, *, hg=False):
"""Given a lib2to3 node, return its string representation."""
code = str(node)
if hg:
from retype_hgext import apply_job_security
code = apply_job_security(code)
return code | [
"Given",
"a",
"lib2to3",
"node",
"return",
"its",
"string",
"representation",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L196-L202 | [
"def",
"lib2to3_unparse",
"(",
"node",
",",
"*",
",",
"hg",
"=",
"False",
")",
":",
"code",
"=",
"str",
"(",
"node",
")",
"if",
"hg",
":",
"from",
"retype_hgext",
"import",
"apply_job_security",
"code",
"=",
"apply_job_security",
"(",
"code",
")",
"retur... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | reapply_all | Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another. | retype.py | def reapply_all(ast_node, lib2to3_node):
"""Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another.
"""
late_processing = reapply(ast_node, lib2to3_node)
for lazy_func in reve... | def reapply_all(ast_node, lib2to3_node):
"""Reapplies the typed_ast node into the lib2to3 tree.
Also does post-processing. This is done in reverse order to enable placing
TypeVars and aliases that depend on one another.
"""
late_processing = reapply(ast_node, lib2to3_node)
for lazy_func in reve... | [
"Reapplies",
"the",
"typed_ast",
"node",
"into",
"the",
"lib2to3",
"tree",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L205-L213 | [
"def",
"reapply_all",
"(",
"ast_node",
",",
"lib2to3_node",
")",
":",
"late_processing",
"=",
"reapply",
"(",
"ast_node",
",",
"lib2to3_node",
")",
"for",
"lazy_func",
"in",
"reversed",
"(",
"late_processing",
")",
":",
"lazy_func",
"(",
")"
] | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | fix_remaining_type_comments | Converts type comments in `node` to proper annotated assignments. | retype.py | def fix_remaining_type_comments(node):
"""Converts type comments in `node` to proper annotated assignments."""
assert node.type == syms.file_input
last_n = None
for n in node.post_order():
if last_n is not None:
if n.type == token.NEWLINE and is_assignment(last_n):
f... | def fix_remaining_type_comments(node):
"""Converts type comments in `node` to proper annotated assignments."""
assert node.type == syms.file_input
last_n = None
for n in node.post_order():
if last_n is not None:
if n.type == token.NEWLINE and is_assignment(last_n):
f... | [
"Converts",
"type",
"comments",
"in",
"node",
"to",
"proper",
"annotated",
"assignments",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L784-L797 | [
"def",
"fix_remaining_type_comments",
"(",
"node",
")",
":",
"assert",
"node",
".",
"type",
"==",
"syms",
".",
"file_input",
"last_n",
"=",
"None",
"for",
"n",
"in",
"node",
".",
"post_order",
"(",
")",
":",
"if",
"last_n",
"is",
"not",
"None",
":",
"i... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | get_function_signature | Returns (args, returns).
`args` is ast3.arguments, `returns` is the return type AST node. The kicker
about this function is that it pushes type comments into proper annotation
fields, standardizing type handling. | retype.py | def get_function_signature(fun, *, is_method=False):
"""Returns (args, returns).
`args` is ast3.arguments, `returns` is the return type AST node. The kicker
about this function is that it pushes type comments into proper annotation
fields, standardizing type handling.
"""
args = fun.args
re... | def get_function_signature(fun, *, is_method=False):
"""Returns (args, returns).
`args` is ast3.arguments, `returns` is the return type AST node. The kicker
about this function is that it pushes type comments into proper annotation
fields, standardizing type handling.
"""
args = fun.args
re... | [
"Returns",
"(",
"args",
"returns",
")",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1050-L1075 | [
"def",
"get_function_signature",
"(",
"fun",
",",
"*",
",",
"is_method",
"=",
"False",
")",
":",
"args",
"=",
"fun",
".",
"args",
"returns",
"=",
"fun",
".",
"returns",
"if",
"fun",
".",
"type_comment",
":",
"try",
":",
"args_tc",
",",
"returns_tc",
"=... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | parse_signature_type_comment | Parse the fugly signature type comment into AST nodes.
Caveats: ASTifying **kwargs is impossible with the current grammar so we
hack it into unary subtraction (to differentiate from Starred in vararg).
For example from:
"(str, int, *int, **Any) -> 'SomeReturnType'"
To:
([ast3.Name, ast.Name, ... | retype.py | def parse_signature_type_comment(type_comment):
"""Parse the fugly signature type comment into AST nodes.
Caveats: ASTifying **kwargs is impossible with the current grammar so we
hack it into unary subtraction (to differentiate from Starred in vararg).
For example from:
"(str, int, *int, **Any) ->... | def parse_signature_type_comment(type_comment):
"""Parse the fugly signature type comment into AST nodes.
Caveats: ASTifying **kwargs is impossible with the current grammar so we
hack it into unary subtraction (to differentiate from Starred in vararg).
For example from:
"(str, int, *int, **Any) ->... | [
"Parse",
"the",
"fugly",
"signature",
"type",
"comment",
"into",
"AST",
"nodes",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1078-L1100 | [
"def",
"parse_signature_type_comment",
"(",
"type_comment",
")",
":",
"try",
":",
"result",
"=",
"ast3",
".",
"parse",
"(",
"type_comment",
",",
"'<func_type>'",
",",
"'func_type'",
")",
"except",
"SyntaxError",
":",
"raise",
"ValueError",
"(",
"f\"invalid functio... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | parse_type_comment | Parse a type comment string into AST nodes. | retype.py | def parse_type_comment(type_comment):
"""Parse a type comment string into AST nodes."""
try:
result = ast3.parse(type_comment, '<type_comment>', 'eval')
except SyntaxError:
raise ValueError(f"invalid type comment: {type_comment!r}") from None
assert isinstance(result, ast3.Expression)
... | def parse_type_comment(type_comment):
"""Parse a type comment string into AST nodes."""
try:
result = ast3.parse(type_comment, '<type_comment>', 'eval')
except SyntaxError:
raise ValueError(f"invalid type comment: {type_comment!r}") from None
assert isinstance(result, ast3.Expression)
... | [
"Parse",
"a",
"type",
"comment",
"string",
"into",
"AST",
"nodes",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1103-L1111 | [
"def",
"parse_type_comment",
"(",
"type_comment",
")",
":",
"try",
":",
"result",
"=",
"ast3",
".",
"parse",
"(",
"type_comment",
",",
"'<type_comment>'",
",",
"'eval'",
")",
"except",
"SyntaxError",
":",
"raise",
"ValueError",
"(",
"f\"invalid type comment: {type... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | parse_arguments | parse_arguments('(a, b, *, c=False, **d)') -> ast3.arguments
Parse a string with function arguments into an AST node. | retype.py | def parse_arguments(arguments):
"""parse_arguments('(a, b, *, c=False, **d)') -> ast3.arguments
Parse a string with function arguments into an AST node.
"""
arguments = f"def f{arguments}: ..."
try:
result = ast3.parse(arguments, '<arguments>', 'exec')
except SyntaxError:
raise ... | def parse_arguments(arguments):
"""parse_arguments('(a, b, *, c=False, **d)') -> ast3.arguments
Parse a string with function arguments into an AST node.
"""
arguments = f"def f{arguments}: ..."
try:
result = ast3.parse(arguments, '<arguments>', 'exec')
except SyntaxError:
raise ... | [
"parse_arguments",
"(",
"(",
"a",
"b",
"*",
"c",
"=",
"False",
"**",
"d",
")",
")",
"-",
">",
"ast3",
".",
"arguments"
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1114-L1130 | [
"def",
"parse_arguments",
"(",
"arguments",
")",
":",
"arguments",
"=",
"f\"def f{arguments}: ...\"",
"try",
":",
"result",
"=",
"ast3",
".",
"parse",
"(",
"arguments",
",",
"'<arguments>'",
",",
"'exec'",
")",
"except",
"SyntaxError",
":",
"raise",
"ValueError"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | copy_arguments_to_annotations | Copies AST nodes from `type_comment` into the ast3.arguments in `args`.
Does validaation of argument count (allowing for untyped self/cls)
and type (vararg and kwarg). | retype.py | def copy_arguments_to_annotations(args, type_comment, *, is_method=False):
"""Copies AST nodes from `type_comment` into the ast3.arguments in `args`.
Does validaation of argument count (allowing for untyped self/cls)
and type (vararg and kwarg).
"""
if isinstance(type_comment, ast3.Ellipsis):
... | def copy_arguments_to_annotations(args, type_comment, *, is_method=False):
"""Copies AST nodes from `type_comment` into the ast3.arguments in `args`.
Does validaation of argument count (allowing for untyped self/cls)
and type (vararg and kwarg).
"""
if isinstance(type_comment, ast3.Ellipsis):
... | [
"Copies",
"AST",
"nodes",
"from",
"type_comment",
"into",
"the",
"ast3",
".",
"arguments",
"in",
"args",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1133-L1183 | [
"def",
"copy_arguments_to_annotations",
"(",
"args",
",",
"type_comment",
",",
"*",
",",
"is_method",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"type_comment",
",",
"ast3",
".",
"Ellipsis",
")",
":",
"return",
"expected",
"=",
"len",
"(",
"args",
".... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | copy_type_comments_to_annotations | Copies argument type comments from the legacy long form to annotations
in the entire function signature. | retype.py | def copy_type_comments_to_annotations(args):
"""Copies argument type comments from the legacy long form to annotations
in the entire function signature.
"""
for arg in args.args:
copy_type_comment_to_annotation(arg)
if args.vararg:
copy_type_comment_to_annotation(args.vararg)
f... | def copy_type_comments_to_annotations(args):
"""Copies argument type comments from the legacy long form to annotations
in the entire function signature.
"""
for arg in args.args:
copy_type_comment_to_annotation(arg)
if args.vararg:
copy_type_comment_to_annotation(args.vararg)
f... | [
"Copies",
"argument",
"type",
"comments",
"from",
"the",
"legacy",
"long",
"form",
"to",
"annotations",
"in",
"the",
"entire",
"function",
"signature",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1186-L1200 | [
"def",
"copy_type_comments_to_annotations",
"(",
"args",
")",
":",
"for",
"arg",
"in",
"args",
".",
"args",
":",
"copy_type_comment_to_annotation",
"(",
"arg",
")",
"if",
"args",
".",
"vararg",
":",
"copy_type_comment_to_annotation",
"(",
"args",
".",
"vararg",
... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | maybe_replace_any_if_equal | Return the type given in `expected`.
Raise ValueError if `expected` isn't equal to `actual`. If --replace-any is
used, the Any type in `actual` is considered equal.
The implementation is naively checking if the string representation of
`actual` is one of "Any", "typing.Any", or "t.Any". This is done... | retype.py | def maybe_replace_any_if_equal(name, expected, actual):
"""Return the type given in `expected`.
Raise ValueError if `expected` isn't equal to `actual`. If --replace-any is
used, the Any type in `actual` is considered equal.
The implementation is naively checking if the string representation of
`a... | def maybe_replace_any_if_equal(name, expected, actual):
"""Return the type given in `expected`.
Raise ValueError if `expected` isn't equal to `actual`. If --replace-any is
used, the Any type in `actual` is considered equal.
The implementation is naively checking if the string representation of
`a... | [
"Return",
"the",
"type",
"given",
"in",
"expected",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1212-L1241 | [
"def",
"maybe_replace_any_if_equal",
"(",
"name",
",",
"expected",
",",
"actual",
")",
":",
"is_equal",
"=",
"expected",
"==",
"actual",
"if",
"not",
"is_equal",
"and",
"Config",
".",
"replace_any",
":",
"actual_str",
"=",
"minimize_whitespace",
"(",
"str",
"(... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | remove_function_signature_type_comment | Removes the legacy signature type comment, leaving other comments if any. | retype.py | def remove_function_signature_type_comment(body):
"""Removes the legacy signature type comment, leaving other comments if any."""
for node in body.children:
if node.type == token.INDENT:
prefix = node.prefix.lstrip()
if prefix.startswith('# type: '):
node.prefix =... | def remove_function_signature_type_comment(body):
"""Removes the legacy signature type comment, leaving other comments if any."""
for node in body.children:
if node.type == token.INDENT:
prefix = node.prefix.lstrip()
if prefix.startswith('# type: '):
node.prefix =... | [
"Removes",
"the",
"legacy",
"signature",
"type",
"comment",
"leaving",
"other",
"comments",
"if",
"any",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1259-L1266 | [
"def",
"remove_function_signature_type_comment",
"(",
"body",
")",
":",
"for",
"node",
"in",
"body",
".",
"children",
":",
"if",
"node",
".",
"type",
"==",
"token",
".",
"INDENT",
":",
"prefix",
"=",
"node",
".",
"prefix",
".",
"lstrip",
"(",
")",
"if",
... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | flatten_some | Generates nodes or leaves, unpacking bodies of try:except:finally: statements. | retype.py | def flatten_some(children):
"""Generates nodes or leaves, unpacking bodies of try:except:finally: statements."""
for node in children:
if node.type in (syms.try_stmt, syms.suite):
yield from flatten_some(node.children)
else:
yield node | def flatten_some(children):
"""Generates nodes or leaves, unpacking bodies of try:except:finally: statements."""
for node in children:
if node.type in (syms.try_stmt, syms.suite):
yield from flatten_some(node.children)
else:
yield node | [
"Generates",
"nodes",
"or",
"leaves",
"unpacking",
"bodies",
"of",
"try",
":",
"except",
":",
"finally",
":",
"statements",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1283-L1289 | [
"def",
"flatten_some",
"(",
"children",
")",
":",
"for",
"node",
"in",
"children",
":",
"if",
"node",
".",
"type",
"in",
"(",
"syms",
".",
"try_stmt",
",",
"syms",
".",
"suite",
")",
":",
"yield",
"from",
"flatten_some",
"(",
"node",
".",
"children",
... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | pop_param | Pops the parameter and the "remainder" (comma, default value).
Returns a tuple of ('name', default) or (_star, 'name') or (_dstar, 'name'). | retype.py | def pop_param(params):
"""Pops the parameter and the "remainder" (comma, default value).
Returns a tuple of ('name', default) or (_star, 'name') or (_dstar, 'name').
"""
default = None
name = params.pop(0)
if name in (_star, _dstar):
default = params.pop(0)
if default == _comma... | def pop_param(params):
"""Pops the parameter and the "remainder" (comma, default value).
Returns a tuple of ('name', default) or (_star, 'name') or (_dstar, 'name').
"""
default = None
name = params.pop(0)
if name in (_star, _dstar):
default = params.pop(0)
if default == _comma... | [
"Pops",
"the",
"parameter",
"and",
"the",
"remainder",
"(",
"comma",
"default",
"value",
")",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1292-L1315 | [
"def",
"pop_param",
"(",
"params",
")",
":",
"default",
"=",
"None",
"name",
"=",
"params",
".",
"pop",
"(",
"0",
")",
"if",
"name",
"in",
"(",
"_star",
",",
"_dstar",
")",
":",
"default",
"=",
"params",
".",
"pop",
"(",
"0",
")",
"if",
"default"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | get_offset_and_prefix | Returns the offset after which a statement can be inserted to the `body`.
This offset is calculated to come after all imports, and maybe existing
(possibly annotated) assignments if `skip_assignments` is True.
Also returns the indentation prefix that should be applied to the inserted
node. | retype.py | def get_offset_and_prefix(body, skip_assignments=False):
"""Returns the offset after which a statement can be inserted to the `body`.
This offset is calculated to come after all imports, and maybe existing
(possibly annotated) assignments if `skip_assignments` is True.
Also returns the indentation pre... | def get_offset_and_prefix(body, skip_assignments=False):
"""Returns the offset after which a statement can be inserted to the `body`.
This offset is calculated to come after all imports, and maybe existing
(possibly annotated) assignments if `skip_assignments` is True.
Also returns the indentation pre... | [
"Returns",
"the",
"offset",
"after",
"which",
"a",
"statement",
"can",
"be",
"inserted",
"to",
"the",
"body",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1396-L1435 | [
"def",
"get_offset_and_prefix",
"(",
"body",
",",
"skip_assignments",
"=",
"False",
")",
":",
"assert",
"body",
".",
"type",
"in",
"(",
"syms",
".",
"file_input",
",",
"syms",
".",
"suite",
")",
"_offset",
"=",
"0",
"prefix",
"=",
"''",
"for",
"_offset",... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | fix_line_numbers | r"""Recomputes all line numbers based on the number of \n characters. | retype.py | def fix_line_numbers(body):
r"""Recomputes all line numbers based on the number of \n characters."""
maxline = 0
for node in body.pre_order():
maxline += node.prefix.count('\n')
if isinstance(node, Leaf):
node.lineno = maxline
maxline += str(node.value).count('\n') | def fix_line_numbers(body):
r"""Recomputes all line numbers based on the number of \n characters."""
maxline = 0
for node in body.pre_order():
maxline += node.prefix.count('\n')
if isinstance(node, Leaf):
node.lineno = maxline
maxline += str(node.value).count('\n') | [
"r",
"Recomputes",
"all",
"line",
"numbers",
"based",
"on",
"the",
"number",
"of",
"\\",
"n",
"characters",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1457-L1464 | [
"def",
"fix_line_numbers",
"(",
"body",
")",
":",
"maxline",
"=",
"0",
"for",
"node",
"in",
"body",
".",
"pre_order",
"(",
")",
":",
"maxline",
"+=",
"node",
".",
"prefix",
".",
"count",
"(",
"'\\n'",
")",
"if",
"isinstance",
"(",
"node",
",",
"Leaf"... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | new | lib2to3's AST requires unique objects as children. | retype.py | def new(n, prefix=None):
"""lib2to3's AST requires unique objects as children."""
if isinstance(n, Leaf):
return Leaf(n.type, n.value, prefix=n.prefix if prefix is None else prefix)
# this is hacky, we assume complex nodes are just being reused once from the
# original AST.
n.parent = None... | def new(n, prefix=None):
"""lib2to3's AST requires unique objects as children."""
if isinstance(n, Leaf):
return Leaf(n.type, n.value, prefix=n.prefix if prefix is None else prefix)
# this is hacky, we assume complex nodes are just being reused once from the
# original AST.
n.parent = None... | [
"lib2to3",
"s",
"AST",
"requires",
"unique",
"objects",
"as",
"children",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype.py#L1467-L1478 | [
"def",
"new",
"(",
"n",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"n",
",",
"Leaf",
")",
":",
"return",
"Leaf",
"(",
"n",
".",
"type",
",",
"n",
".",
"value",
",",
"prefix",
"=",
"n",
".",
"prefix",
"if",
"prefix",
"is",
... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | apply_job_security | Treat input `code` like Python 2 (implicit strings are byte literals).
The implementation is horribly inefficient but the goal is to be compatible
with what Mercurial does at runtime. | retype_hgext.py | def apply_job_security(code):
"""Treat input `code` like Python 2 (implicit strings are byte literals).
The implementation is horribly inefficient but the goal is to be compatible
with what Mercurial does at runtime.
"""
buf = io.BytesIO(code.encode('utf8'))
tokens = tokenize.tokenize(buf.readl... | def apply_job_security(code):
"""Treat input `code` like Python 2 (implicit strings are byte literals).
The implementation is horribly inefficient but the goal is to be compatible
with what Mercurial does at runtime.
"""
buf = io.BytesIO(code.encode('utf8'))
tokens = tokenize.tokenize(buf.readl... | [
"Treat",
"input",
"code",
"like",
"Python",
"2",
"(",
"implicit",
"strings",
"are",
"byte",
"literals",
")",
"."
] | ambv/retype | python | https://github.com/ambv/retype/blob/03137abd4d9c9845f3cced1006190b5cca64d879/retype_hgext.py#L157-L168 | [
"def",
"apply_job_security",
"(",
"code",
")",
":",
"buf",
"=",
"io",
".",
"BytesIO",
"(",
"code",
".",
"encode",
"(",
"'utf8'",
")",
")",
"tokens",
"=",
"tokenize",
".",
"tokenize",
"(",
"buf",
".",
"readline",
")",
"# NOTE: by setting the fullname to `merc... | 03137abd4d9c9845f3cced1006190b5cca64d879 |
valid | S3._load_info | Get user info for GBDX S3, put into instance vars for convenience.
Args:
None.
Returns:
Dictionary with S3 access key, S3 secret key, S3 session token,
user bucket and user prefix (dict). | gbdxtools/s3.py | def _load_info(self):
'''Get user info for GBDX S3, put into instance vars for convenience.
Args:
None.
Returns:
Dictionary with S3 access key, S3 secret key, S3 session token,
user bucket and user prefix (dict).
'''
url = '%s/prefix?duratio... | def _load_info(self):
'''Get user info for GBDX S3, put into instance vars for convenience.
Args:
None.
Returns:
Dictionary with S3 access key, S3 secret key, S3 session token,
user bucket and user prefix (dict).
'''
url = '%s/prefix?duratio... | [
"Get",
"user",
"info",
"for",
"GBDX",
"S3",
"put",
"into",
"instance",
"vars",
"for",
"convenience",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/s3.py#L51-L65 | [
"def",
"_load_info",
"(",
"self",
")",
":",
"url",
"=",
"'%s/prefix?duration=36000'",
"%",
"self",
".",
"base_url",
"r",
"=",
"self",
".",
"gbdx_connection",
".",
"get",
"(",
"url",
")",
"r",
".",
"raise_for_status",
"(",
")",
"return",
"r",
".",
"json",... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | S3.download | Download content from bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are
downloaded. If it is a file, then that file is downloaded.
Args:
location (str)... | gbdxtools/s3.py | def download(self, location, local_dir='.'):
'''Download content from bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are
downloaded. If it is a file, then that file is dow... | def download(self, location, local_dir='.'):
'''Download content from bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are
downloaded. If it is a file, then that file is dow... | [
"Download",
"content",
"from",
"bucket",
"/",
"prefix",
"/",
"location",
".",
"Location",
"can",
"be",
"a",
"directory",
"or",
"a",
"file",
"(",
"e",
".",
"g",
".",
"my_dir",
"or",
"my_dir",
"/",
"my_image",
".",
"tif",
")",
"If",
"location",
"is",
"... | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/s3.py#L67-L116 | [
"def",
"download",
"(",
"self",
",",
"location",
",",
"local_dir",
"=",
"'.'",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Getting S3 info'",
")",
"bucket",
"=",
"self",
".",
"info",
"[",
"'bucket'",
"]",
"prefix",
"=",
"self",
".",
"info",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | S3.delete | Delete content in bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are deleted.
If it is a file, then that file is deleted.
Args:
location (str): S3 locat... | gbdxtools/s3.py | def delete(self, location):
'''Delete content in bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are deleted.
If it is a file, then that file is deleted.
Args:
... | def delete(self, location):
'''Delete content in bucket/prefix/location.
Location can be a directory or a file (e.g., my_dir or my_dir/my_image.tif)
If location is a directory, all files in the directory are deleted.
If it is a file, then that file is deleted.
Args:
... | [
"Delete",
"content",
"in",
"bucket",
"/",
"prefix",
"/",
"location",
".",
"Location",
"can",
"be",
"a",
"directory",
"or",
"a",
"file",
"(",
"e",
".",
"g",
".",
"my_dir",
"or",
"my_dir",
"/",
"my_image",
".",
"tif",
")",
"If",
"location",
"is",
"a",
... | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/s3.py#L118-L145 | [
"def",
"delete",
"(",
"self",
",",
"location",
")",
":",
"bucket",
"=",
"self",
".",
"info",
"[",
"'bucket'",
"]",
"prefix",
"=",
"self",
".",
"info",
"[",
"'prefix'",
"]",
"self",
".",
"logger",
".",
"debug",
"(",
"'Connecting to S3'",
")",
"s3conn",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | S3.upload | Upload files to your DG S3 bucket/prefix.
Args:
local_file (str): a path to a local file to upload, directory structures are not mirrored
s3_path: a key (location) on s3 to upload the file to
Returns:
str: s3 path file was saved to
Examples:
>>>... | gbdxtools/s3.py | def upload(self, local_file, s3_path=None):
'''
Upload files to your DG S3 bucket/prefix.
Args:
local_file (str): a path to a local file to upload, directory structures are not mirrored
s3_path: a key (location) on s3 to upload the file to
Returns:
s... | def upload(self, local_file, s3_path=None):
'''
Upload files to your DG S3 bucket/prefix.
Args:
local_file (str): a path to a local file to upload, directory structures are not mirrored
s3_path: a key (location) on s3 to upload the file to
Returns:
s... | [
"Upload",
"files",
"to",
"your",
"DG",
"S3",
"bucket",
"/",
"prefix",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/s3.py#L147-L182 | [
"def",
"upload",
"(",
"self",
",",
"local_file",
",",
"s3_path",
"=",
"None",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"local_file",
")",
":",
"raise",
"Exception",
"(",
"local_file",
"+",
"\" does not exist.\"",
")",
"if",
"s3_path"... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.rgb | Convert the image to a 3 band RGB for plotting
This method shares the same arguments as plot(). It will perform visual adjustment on the
image and prepare the data for plotting in MatplotLib. Values are converted to an
appropriate precision and the axis order is changed to put the band ... | gbdxtools/images/mixins/geo.py | def rgb(self, **kwargs):
''' Convert the image to a 3 band RGB for plotting
This method shares the same arguments as plot(). It will perform visual adjustment on the
image and prepare the data for plotting in MatplotLib. Values are converted to an
appropriate precision and the a... | def rgb(self, **kwargs):
''' Convert the image to a 3 band RGB for plotting
This method shares the same arguments as plot(). It will perform visual adjustment on the
image and prepare the data for plotting in MatplotLib. Values are converted to an
appropriate precision and the a... | [
"Convert",
"the",
"image",
"to",
"a",
"3",
"band",
"RGB",
"for",
"plotting",
"This",
"method",
"shares",
"the",
"same",
"arguments",
"as",
"plot",
"()",
".",
"It",
"will",
"perform",
"visual",
"adjustment",
"on",
"the",
"image",
"and",
"prepare",
"the",
... | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L23-L56 | [
"def",
"rgb",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"bands\"",
"in",
"kwargs",
":",
"use_bands",
"=",
"kwargs",
"[",
"\"bands\"",
"]",
"assert",
"len",
"(",
"use_bands",
")",
"==",
"3",
",",
"'Plot method only supports single or 3-band outp... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.histogram_equalize | Equalize and the histogram and normalize value range
Equalization is on all three bands, not per-band | gbdxtools/images/mixins/geo.py | def histogram_equalize(self, use_bands, **kwargs):
''' Equalize and the histogram and normalize value range
Equalization is on all three bands, not per-band'''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
flattened = data.... | def histogram_equalize(self, use_bands, **kwargs):
''' Equalize and the histogram and normalize value range
Equalization is on all three bands, not per-band'''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
flattened = data.... | [
"Equalize",
"and",
"the",
"histogram",
"and",
"normalize",
"value",
"range",
"Equalization",
"is",
"on",
"all",
"three",
"bands",
"not",
"per",
"-",
"band"
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L61-L79 | [
"def",
"histogram_equalize",
"(",
"self",
",",
"use_bands",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
"use_bands",
",",
"...",
"]",
",",
"*",
"*",
"kwargs",
")",
"data",
"=",
"np",
".",
"rollaxis",
"(",... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.histogram_match | Match the histogram to existing imagery | gbdxtools/images/mixins/geo.py | def histogram_match(self, use_bands, blm_source=None, **kwargs):
''' Match the histogram to existing imagery '''
assert has_rio, "To match image histograms please install rio_hist"
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
... | def histogram_match(self, use_bands, blm_source=None, **kwargs):
''' Match the histogram to existing imagery '''
assert has_rio, "To match image histograms please install rio_hist"
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
... | [
"Match",
"the",
"histogram",
"to",
"existing",
"imagery"
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L81-L101 | [
"def",
"histogram_match",
"(",
"self",
",",
"use_bands",
",",
"blm_source",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"has_rio",
",",
"\"To match image histograms please install rio_hist\"",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.histogram_stretch | entry point for contrast stretching | gbdxtools/images/mixins/geo.py | def histogram_stretch(self, use_bands, **kwargs):
''' entry point for contrast stretching '''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
return self._histogram_stretch(data, **kwargs) | def histogram_stretch(self, use_bands, **kwargs):
''' entry point for contrast stretching '''
data = self._read(self[use_bands,...], **kwargs)
data = np.rollaxis(data.astype(np.float32), 0, 3)
return self._histogram_stretch(data, **kwargs) | [
"entry",
"point",
"for",
"contrast",
"stretching"
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L103-L107 | [
"def",
"histogram_stretch",
"(",
"self",
",",
"use_bands",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
"use_bands",
",",
"...",
"]",
",",
"*",
"*",
"kwargs",
")",
"data",
"=",
"np",
".",
"rollaxis",
"(",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin._histogram_stretch | perform a contrast stretch and/or gamma adjustment | gbdxtools/images/mixins/geo.py | def _histogram_stretch(self, data, **kwargs):
''' perform a contrast stretch and/or gamma adjustment '''
limits = {}
# get the image min-max statistics
for x in range(3):
band = data[:,:,x]
try:
limits[x] = np.percentile(band, kwargs.get("stretch",... | def _histogram_stretch(self, data, **kwargs):
''' perform a contrast stretch and/or gamma adjustment '''
limits = {}
# get the image min-max statistics
for x in range(3):
band = data[:,:,x]
try:
limits[x] = np.percentile(band, kwargs.get("stretch",... | [
"perform",
"a",
"contrast",
"stretch",
"and",
"/",
"or",
"gamma",
"adjustment"
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L109-L136 | [
"def",
"_histogram_stretch",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"limits",
"=",
"{",
"}",
"# get the image min-max statistics",
"for",
"x",
"in",
"range",
"(",
"3",
")",
":",
"band",
"=",
"data",
"[",
":",
",",
":",
",",
"x",... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.ndvi | Calculates Normalized Difference Vegetation Index using NIR and Red of an image.
Returns: numpy array with ndvi values | gbdxtools/images/mixins/geo.py | def ndvi(self, **kwargs):
"""
Calculates Normalized Difference Vegetation Index using NIR and Red of an image.
Returns: numpy array with ndvi values
"""
data = self._read(self[self._ndvi_bands,...]).astype(np.float32)
return (data[0,:,:] - data[1,:,:]) / (data[0,:,:] + d... | def ndvi(self, **kwargs):
"""
Calculates Normalized Difference Vegetation Index using NIR and Red of an image.
Returns: numpy array with ndvi values
"""
data = self._read(self[self._ndvi_bands,...]).astype(np.float32)
return (data[0,:,:] - data[1,:,:]) / (data[0,:,:] + d... | [
"Calculates",
"Normalized",
"Difference",
"Vegetation",
"Index",
"using",
"NIR",
"and",
"Red",
"of",
"an",
"image",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L138-L145 | [
"def",
"ndvi",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
"self",
".",
"_ndvi_bands",
",",
"...",
"]",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"return",
"(",
"data",
"[",
"0"... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.ndwi | Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values | gbdxtools/images/mixins/geo.py | def ndwi(self):
"""
Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values
"""
data = self._read(self[self._ndwi_bands,...]).astype(... | def ndwi(self):
"""
Calculates Normalized Difference Water Index using Coastal and NIR2 bands for WV02, WV03.
For Landsat8 and sentinel2 calculated by using Green and NIR bands.
Returns: numpy array of ndwi values
"""
data = self._read(self[self._ndwi_bands,...]).astype(... | [
"Calculates",
"Normalized",
"Difference",
"Water",
"Index",
"using",
"Coastal",
"and",
"NIR2",
"bands",
"for",
"WV02",
"WV03",
".",
"For",
"Landsat8",
"and",
"sentinel2",
"calculated",
"by",
"using",
"Green",
"and",
"NIR",
"bands",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L147-L155 | [
"def",
"ndwi",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"_read",
"(",
"self",
"[",
"self",
".",
"_ndwi_bands",
",",
"...",
"]",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"return",
"(",
"data",
"[",
"1",
",",
":",
",",
":",
"... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | PlotMixin.plot | Plot the image with MatplotLib
Plot sizing includes default borders and spacing. If the image is shown in Jupyter the outside whitespace will be automatically cropped to save size, resulting in a smaller sized image than expected.
Histogram options:
* 'equalize': performs histogram equaliz... | gbdxtools/images/mixins/geo.py | def plot(self, spec="rgb", **kwargs):
''' Plot the image with MatplotLib
Plot sizing includes default borders and spacing. If the image is shown in Jupyter the outside whitespace will be automatically cropped to save size, resulting in a smaller sized image than expected.
Histogram options:
... | def plot(self, spec="rgb", **kwargs):
''' Plot the image with MatplotLib
Plot sizing includes default borders and spacing. If the image is shown in Jupyter the outside whitespace will be automatically cropped to save size, resulting in a smaller sized image than expected.
Histogram options:
... | [
"Plot",
"the",
"image",
"with",
"MatplotLib"
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/images/mixins/geo.py#L157-L195 | [
"def",
"plot",
"(",
"self",
",",
"spec",
"=",
"\"rgb\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"shape",
"[",
"0",
"]",
"==",
"1",
"or",
"(",
"\"bands\"",
"in",
"kwargs",
"and",
"len",
"(",
"kwargs",
"[",
"\"bands\"",
"]",
")",
"... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.get_images_by_catid_and_aoi | Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
aoi_wkt (str): The well known text of the area of interest.
Returns:
results (json): The full catalog-search response for IDAHO images
... | gbdxtools/idaho.py | def get_images_by_catid_and_aoi(self, catid, aoi_wkt):
""" Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
aoi_wkt (str): The well known text of the area of interest.
Returns:
... | def get_images_by_catid_and_aoi(self, catid, aoi_wkt):
""" Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
aoi_wkt (str): The well known text of the area of interest.
Returns:
... | [
"Retrieves",
"the",
"IDAHO",
"image",
"records",
"associated",
"with",
"a",
"given",
"catid",
".",
"Args",
":",
"catid",
"(",
"str",
")",
":",
"The",
"source",
"catalog",
"ID",
"from",
"the",
"platform",
"catalog",
".",
"aoi_wkt",
"(",
"str",
")",
":",
... | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L34-L62 | [
"def",
"get_images_by_catid_and_aoi",
"(",
"self",
",",
"catid",
",",
"aoi_wkt",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Retrieving IDAHO metadata'",
")",
"# use the footprint to get the IDAHO id",
"url",
"=",
"'%s/search'",
"%",
"self",
".",
"base_url... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.get_images_by_catid | Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
Returns:
results (json): The full catalog-search response for IDAHO images
within the catID. | gbdxtools/idaho.py | def get_images_by_catid(self, catid):
""" Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
Returns:
results (json): The full catalog-search response for IDAHO images
... | def get_images_by_catid(self, catid):
""" Retrieves the IDAHO image records associated with a given catid.
Args:
catid (str): The source catalog ID from the platform catalog.
Returns:
results (json): The full catalog-search response for IDAHO images
... | [
"Retrieves",
"the",
"IDAHO",
"image",
"records",
"associated",
"with",
"a",
"given",
"catid",
".",
"Args",
":",
"catid",
"(",
"str",
")",
":",
"The",
"source",
"catalog",
"ID",
"from",
"the",
"platform",
"catalog",
".",
"Returns",
":",
"results",
"(",
"j... | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L64-L90 | [
"def",
"get_images_by_catid",
"(",
"self",
",",
"catid",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'Retrieving IDAHO metadata'",
")",
"# get the footprint of the catid's strip",
"footprint",
"=",
"self",
".",
"catalog",
".",
"get_strip_footprint_wkt",
"(",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.describe_images | Describe the result set of a catalog search for IDAHO images.
Args:
idaho_image_results (dict): Result set of catalog search.
Returns:
results (json): The full catalog-search response for IDAHO images
corresponding to the given catID. | gbdxtools/idaho.py | def describe_images(self, idaho_image_results):
"""Describe the result set of a catalog search for IDAHO images.
Args:
idaho_image_results (dict): Result set of catalog search.
Returns:
results (json): The full catalog-search response for IDAHO images
... | def describe_images(self, idaho_image_results):
"""Describe the result set of a catalog search for IDAHO images.
Args:
idaho_image_results (dict): Result set of catalog search.
Returns:
results (json): The full catalog-search response for IDAHO images
... | [
"Describe",
"the",
"result",
"set",
"of",
"a",
"catalog",
"search",
"for",
"IDAHO",
"images",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L92-L136 | [
"def",
"describe_images",
"(",
"self",
",",
"idaho_image_results",
")",
":",
"results",
"=",
"idaho_image_results",
"[",
"'results'",
"]",
"# filter only idaho images:",
"results",
"=",
"[",
"r",
"for",
"r",
"in",
"results",
"if",
"'IDAHOImage'",
"in",
"r",
"[",... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.get_chip | Downloads a native resolution, orthorectified chip in tif format
from a user-specified catalog id.
Args:
coordinates (list): Rectangle coordinates in order West, South, East, North.
West and East are longitudes, North and South are latitudes.
... | gbdxtools/idaho.py | def get_chip(self, coordinates, catid, chip_type='PAN', chip_format='TIF', filename='chip.tif'):
"""Downloads a native resolution, orthorectified chip in tif format
from a user-specified catalog id.
Args:
coordinates (list): Rectangle coordinates in order West, South, East, North.
... | def get_chip(self, coordinates, catid, chip_type='PAN', chip_format='TIF', filename='chip.tif'):
"""Downloads a native resolution, orthorectified chip in tif format
from a user-specified catalog id.
Args:
coordinates (list): Rectangle coordinates in order West, South, East, North.
... | [
"Downloads",
"a",
"native",
"resolution",
"orthorectified",
"chip",
"in",
"tif",
"format",
"from",
"a",
"user",
"-",
"specified",
"catalog",
"id",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L138-L217 | [
"def",
"get_chip",
"(",
"self",
",",
"coordinates",
",",
"catid",
",",
"chip_type",
"=",
"'PAN'",
",",
"chip_format",
"=",
"'TIF'",
",",
"filename",
"=",
"'chip.tif'",
")",
":",
"def",
"t2s1",
"(",
"t",
")",
":",
"# Tuple to string 1",
"return",
"str",
"... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.get_tms_layers | Get list of urls and bounding boxes corrsponding to idaho images for a given catalog id.
Args:
catid (str): Catalog id
bands (str): Bands to display, separated by commas (0-7).
gamma (float): gamma coefficient. This is for on-the-fly pansharpening.
highcutoff (float)... | gbdxtools/idaho.py | def get_tms_layers(self,
catid,
bands='4,2,1',
gamma=1.3,
highcutoff=0.98,
lowcutoff=0.02,
brightness=1.0,
contrast=1.0):
"""Get list of urls and bound... | def get_tms_layers(self,
catid,
bands='4,2,1',
gamma=1.3,
highcutoff=0.98,
lowcutoff=0.02,
brightness=1.0,
contrast=1.0):
"""Get list of urls and bound... | [
"Get",
"list",
"of",
"urls",
"and",
"bounding",
"boxes",
"corrsponding",
"to",
"idaho",
"images",
"for",
"a",
"given",
"catalog",
"id",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L219-L294 | [
"def",
"get_tms_layers",
"(",
"self",
",",
"catid",
",",
"bands",
"=",
"'4,2,1'",
",",
"gamma",
"=",
"1.3",
",",
"highcutoff",
"=",
"0.98",
",",
"lowcutoff",
"=",
"0.02",
",",
"brightness",
"=",
"1.0",
",",
"contrast",
"=",
"1.0",
")",
":",
"descriptio... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
valid | Idaho.create_leaflet_viewer | Create a leaflet viewer html file for viewing idaho images.
Args:
idaho_image_results (dict): IDAHO image result set as returned from
the catalog.
filename (str): Where to save output html file. | gbdxtools/idaho.py | def create_leaflet_viewer(self, idaho_image_results, filename):
"""Create a leaflet viewer html file for viewing idaho images.
Args:
idaho_image_results (dict): IDAHO image result set as returned from
the catalog.
filename (str): Where to ... | def create_leaflet_viewer(self, idaho_image_results, filename):
"""Create a leaflet viewer html file for viewing idaho images.
Args:
idaho_image_results (dict): IDAHO image result set as returned from
the catalog.
filename (str): Where to ... | [
"Create",
"a",
"leaflet",
"viewer",
"html",
"file",
"for",
"viewing",
"idaho",
"images",
"."
] | DigitalGlobe/gbdxtools | python | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/idaho.py#L296-L360 | [
"def",
"create_leaflet_viewer",
"(",
"self",
",",
"idaho_image_results",
",",
"filename",
")",
":",
"description",
"=",
"self",
".",
"describe_images",
"(",
"idaho_image_results",
")",
"if",
"len",
"(",
"description",
")",
">",
"0",
":",
"functionstring",
"=",
... | def62f8f2d77b168aa2bd115290aaa0f9a08a4bb |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.