repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
bitshares/uptick | uptick/witness.py | disapprovewitness | def disapprovewitness(ctx, witnesses, account):
""" Disapprove witness(es)
"""
print_tx(ctx.bitshares.disapprovewitness(witnesses, account=account)) | python | def disapprovewitness(ctx, witnesses, account):
""" Disapprove witness(es)
"""
print_tx(ctx.bitshares.disapprovewitness(witnesses, account=account)) | [
"def",
"disapprovewitness",
"(",
"ctx",
",",
"witnesses",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"disapprovewitness",
"(",
"witnesses",
",",
"account",
"=",
"account",
")",
")"
] | Disapprove witness(es) | [
"Disapprove",
"witness",
"(",
"es",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/witness.py#L37-L40 |
bitshares/uptick | uptick/witness.py | witnesses | def witnesses(ctx):
""" List witnesses and relevant information
"""
t = [
[
"weight",
"account",
"signing_key",
"vote_id",
"url",
"total_missed",
"last_confirmed_block_num",
]
]
for witness in sorted(... | python | def witnesses(ctx):
""" List witnesses and relevant information
"""
t = [
[
"weight",
"account",
"signing_key",
"vote_id",
"url",
"total_missed",
"last_confirmed_block_num",
]
]
for witness in sorted(... | [
"def",
"witnesses",
"(",
"ctx",
")",
":",
"t",
"=",
"[",
"[",
"\"weight\"",
",",
"\"account\"",
",",
"\"signing_key\"",
",",
"\"vote_id\"",
",",
"\"url\"",
",",
"\"total_missed\"",
",",
"\"last_confirmed_block_num\"",
",",
"]",
"]",
"for",
"witness",
"in",
"... | List witnesses and relevant information | [
"List",
"witnesses",
"and",
"relevant",
"information"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/witness.py#L46-L73 |
bitshares/uptick | uptick/vesting.py | vesting | def vesting(ctx, account):
""" List accounts vesting balances
"""
account = Account(account, full=True)
t = [["vesting_id", "claimable"]]
for vest in account["vesting_balances"]:
vesting = Vesting(vest)
t.append([vesting["id"], str(vesting.claimable)])
print_table(t) | python | def vesting(ctx, account):
""" List accounts vesting balances
"""
account = Account(account, full=True)
t = [["vesting_id", "claimable"]]
for vest in account["vesting_balances"]:
vesting = Vesting(vest)
t.append([vesting["id"], str(vesting.claimable)])
print_table(t) | [
"def",
"vesting",
"(",
"ctx",
",",
"account",
")",
":",
"account",
"=",
"Account",
"(",
"account",
",",
"full",
"=",
"True",
")",
"t",
"=",
"[",
"[",
"\"vesting_id\"",
",",
"\"claimable\"",
"]",
"]",
"for",
"vest",
"in",
"account",
"[",
"\"vesting_bala... | List accounts vesting balances | [
"List",
"accounts",
"vesting",
"balances"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/vesting.py#L16-L24 |
bitshares/uptick | uptick/vesting.py | claim | def claim(ctx, vestingid, account, amount):
""" Claim funds from the vesting balance
"""
vesting = Vesting(vestingid)
if amount:
amount = Amount(float(amount), "BTS")
else:
amount = vesting.claimable
print_tx(
ctx.bitshares.vesting_balance_withdraw(
vesting["i... | python | def claim(ctx, vestingid, account, amount):
""" Claim funds from the vesting balance
"""
vesting = Vesting(vestingid)
if amount:
amount = Amount(float(amount), "BTS")
else:
amount = vesting.claimable
print_tx(
ctx.bitshares.vesting_balance_withdraw(
vesting["i... | [
"def",
"claim",
"(",
"ctx",
",",
"vestingid",
",",
"account",
",",
"amount",
")",
":",
"vesting",
"=",
"Vesting",
"(",
"vestingid",
")",
"if",
"amount",
":",
"amount",
"=",
"Amount",
"(",
"float",
"(",
"amount",
")",
",",
"\"BTS\"",
")",
"else",
":",... | Claim funds from the vesting balance | [
"Claim",
"funds",
"from",
"the",
"vesting",
"balance"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/vesting.py#L34-L46 |
bitshares/uptick | uptick/vesting.py | reserve | def reserve(ctx, amount, symbol, account):
""" Reserve/Burn tokens
"""
print_tx(
ctx.bitshares.reserve(
Amount(amount, symbol, bitshares_instance=ctx.bitshares), account=account
)
) | python | def reserve(ctx, amount, symbol, account):
""" Reserve/Burn tokens
"""
print_tx(
ctx.bitshares.reserve(
Amount(amount, symbol, bitshares_instance=ctx.bitshares), account=account
)
) | [
"def",
"reserve",
"(",
"ctx",
",",
"amount",
",",
"symbol",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"reserve",
"(",
"Amount",
"(",
"amount",
",",
"symbol",
",",
"bitshares_instance",
"=",
"ctx",
".",
"bitshares",
")",
"... | Reserve/Burn tokens | [
"Reserve",
"/",
"Burn",
"tokens"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/vesting.py#L56-L63 |
bitshares/uptick | uptick/apis/poloniex.py | run | def run(context, port):
""" Run the Webserver/SocketIO and app
"""
global ctx
ctx = context
app.run(port=port) | python | def run(context, port):
""" Run the Webserver/SocketIO and app
"""
global ctx
ctx = context
app.run(port=port) | [
"def",
"run",
"(",
"context",
",",
"port",
")",
":",
"global",
"ctx",
"ctx",
"=",
"context",
"app",
".",
"run",
"(",
"port",
"=",
"port",
")"
] | Run the Webserver/SocketIO and app | [
"Run",
"the",
"Webserver",
"/",
"SocketIO",
"and",
"app"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/apis/poloniex.py#L109-L114 |
bitshares/uptick | uptick/decorators.py | offline | def offline(f):
""" This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares with ``offline=True``.
"""
@click.pass_context
@verbose
def new_func(ctx, *args, **kwargs):
ctx.obj["offline"] = True
ctx.bitshares = BitShares(**ctx.obj)
ctx.... | python | def offline(f):
""" This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares with ``offline=True``.
"""
@click.pass_context
@verbose
def new_func(ctx, *args, **kwargs):
ctx.obj["offline"] = True
ctx.bitshares = BitShares(**ctx.obj)
ctx.... | [
"def",
"offline",
"(",
"f",
")",
":",
"@",
"click",
".",
"pass_context",
"@",
"verbose",
"def",
"new_func",
"(",
"ctx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ctx",
".",
"obj",
"[",
"\"offline\"",
"]",
"=",
"True",
"ctx",
".",
"bit... | This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares with ``offline=True``. | [
"This",
"decorator",
"allows",
"you",
"to",
"access",
"ctx",
".",
"bitshares",
"which",
"is",
"an",
"instance",
"of",
"BitShares",
"with",
"offline",
"=",
"True",
"."
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/decorators.py#L55-L69 |
bitshares/uptick | uptick/decorators.py | customchain | def customchain(**kwargsChain):
""" This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares. But in contrast to @chain, this is a
decorator that expects parameters that are directed right to
``BitShares()``.
... code-block::python
@ma... | python | def customchain(**kwargsChain):
""" This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares. But in contrast to @chain, this is a
decorator that expects parameters that are directed right to
``BitShares()``.
... code-block::python
@ma... | [
"def",
"customchain",
"(",
"*",
"*",
"kwargsChain",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"@",
"click",
".",
"pass_context",
"@",
"verbose",
"def",
"new_func",
"(",
"ctx",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"newoptions",
"=... | This decorator allows you to access ``ctx.bitshares`` which is
an instance of BitShares. But in contrast to @chain, this is a
decorator that expects parameters that are directed right to
``BitShares()``.
... code-block::python
@main.command()
@click.opti... | [
"This",
"decorator",
"allows",
"you",
"to",
"access",
"ctx",
".",
"bitshares",
"which",
"is",
"an",
"instance",
"of",
"BitShares",
".",
"But",
"in",
"contrast",
"to",
"@chain",
"this",
"is",
"a",
"decorator",
"that",
"expects",
"parameters",
"that",
"are",
... | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/decorators.py#L72-L103 |
bitshares/uptick | uptick/proposal.py | disapproveproposal | def disapproveproposal(ctx, proposal, account):
""" Disapprove a proposal
"""
print_tx(ctx.bitshares.disapproveproposal(proposal, account=account)) | python | def disapproveproposal(ctx, proposal, account):
""" Disapprove a proposal
"""
print_tx(ctx.bitshares.disapproveproposal(proposal, account=account)) | [
"def",
"disapproveproposal",
"(",
"ctx",
",",
"proposal",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"disapproveproposal",
"(",
"proposal",
",",
"account",
"=",
"account",
")",
")"
] | Disapprove a proposal | [
"Disapprove",
"a",
"proposal"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/proposal.py#L21-L24 |
bitshares/uptick | uptick/proposal.py | approveproposal | def approveproposal(ctx, proposal, account):
""" Approve a proposal
"""
print_tx(ctx.bitshares.approveproposal(proposal, account=account)) | python | def approveproposal(ctx, proposal, account):
""" Approve a proposal
"""
print_tx(ctx.bitshares.approveproposal(proposal, account=account)) | [
"def",
"approveproposal",
"(",
"ctx",
",",
"proposal",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"approveproposal",
"(",
"proposal",
",",
"account",
"=",
"account",
")",
")"
] | Approve a proposal | [
"Approve",
"a",
"proposal"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/proposal.py#L38-L41 |
bitshares/uptick | uptick/proposal.py | proposals | def proposals(ctx, account):
""" List proposals
"""
proposals = Proposals(account)
t = [
[
"id",
"expiration",
"proposer",
"required approvals",
"available approvals",
"review period time",
"proposal",
]
... | python | def proposals(ctx, account):
""" List proposals
"""
proposals = Proposals(account)
t = [
[
"id",
"expiration",
"proposer",
"required approvals",
"available approvals",
"review period time",
"proposal",
]
... | [
"def",
"proposals",
"(",
"ctx",
",",
"account",
")",
":",
"proposals",
"=",
"Proposals",
"(",
"account",
")",
"t",
"=",
"[",
"[",
"\"id\"",
",",
"\"expiration\"",
",",
"\"proposer\"",
",",
"\"required approvals\"",
",",
"\"available approvals\"",
",",
"\"revie... | List proposals | [
"List",
"proposals"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/proposal.py#L48-L87 |
bitshares/uptick | uptick/message.py | sign | def sign(ctx, file, account):
""" Sign a message with an account
"""
if not file:
print_message("Prompting for message. Terminate with CTRL-D", "info")
file = click.get_text_stream("stdin")
m = Message(file.read(), bitshares_instance=ctx.bitshares)
print_message(m.sign(account), "inf... | python | def sign(ctx, file, account):
""" Sign a message with an account
"""
if not file:
print_message("Prompting for message. Terminate with CTRL-D", "info")
file = click.get_text_stream("stdin")
m = Message(file.read(), bitshares_instance=ctx.bitshares)
print_message(m.sign(account), "inf... | [
"def",
"sign",
"(",
"ctx",
",",
"file",
",",
"account",
")",
":",
"if",
"not",
"file",
":",
"print_message",
"(",
"\"Prompting for message. Terminate with CTRL-D\"",
",",
"\"info\"",
")",
"file",
"=",
"click",
".",
"get_text_stream",
"(",
"\"stdin\"",
")",
"m"... | Sign a message with an account | [
"Sign",
"a",
"message",
"with",
"an",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/message.py#L24-L31 |
bitshares/uptick | uptick/message.py | verify | def verify(ctx, file, account):
""" Verify a signed message
"""
if not file:
print_message("Prompting for message. Terminate with CTRL-D", "info")
file = click.get_text_stream("stdin")
m = Message(file.read(), bitshares_instance=ctx.bitshares)
try:
if m.verify():
... | python | def verify(ctx, file, account):
""" Verify a signed message
"""
if not file:
print_message("Prompting for message. Terminate with CTRL-D", "info")
file = click.get_text_stream("stdin")
m = Message(file.read(), bitshares_instance=ctx.bitshares)
try:
if m.verify():
... | [
"def",
"verify",
"(",
"ctx",
",",
"file",
",",
"account",
")",
":",
"if",
"not",
"file",
":",
"print_message",
"(",
"\"Prompting for message. Terminate with CTRL-D\"",
",",
"\"info\"",
")",
"file",
"=",
"click",
".",
"get_text_stream",
"(",
"\"stdin\"",
")",
"... | Verify a signed message | [
"Verify",
"a",
"signed",
"message"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/message.py#L41-L54 |
bitshares/uptick | uptick/account.py | allow | def allow(ctx, foreign_account, permission, weight, threshold, account):
""" Add a key/account to an account's permission
"""
if not foreign_account:
from bitsharesbase.account import PasswordKey
pwd = click.prompt(
"Password for Key Derivation", hide_input=True, confirmation_pr... | python | def allow(ctx, foreign_account, permission, weight, threshold, account):
""" Add a key/account to an account's permission
"""
if not foreign_account:
from bitsharesbase.account import PasswordKey
pwd = click.prompt(
"Password for Key Derivation", hide_input=True, confirmation_pr... | [
"def",
"allow",
"(",
"ctx",
",",
"foreign_account",
",",
"permission",
",",
"weight",
",",
"threshold",
",",
"account",
")",
":",
"if",
"not",
"foreign_account",
":",
"from",
"bitsharesbase",
".",
"account",
"import",
"PasswordKey",
"pwd",
"=",
"click",
".",... | Add a key/account to an account's permission | [
"Add",
"a",
"key",
"/",
"account",
"to",
"an",
"account",
"s",
"permission"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L28-L48 |
bitshares/uptick | uptick/account.py | disallow | def disallow(ctx, foreign_account, permission, threshold, account):
""" Remove a key/account from an account's permission
"""
print_tx(
ctx.bitshares.disallow(
foreign_account, account=account, permission=permission, threshold=threshold
)
) | python | def disallow(ctx, foreign_account, permission, threshold, account):
""" Remove a key/account from an account's permission
"""
print_tx(
ctx.bitshares.disallow(
foreign_account, account=account, permission=permission, threshold=threshold
)
) | [
"def",
"disallow",
"(",
"ctx",
",",
"foreign_account",
",",
"permission",
",",
"threshold",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"disallow",
"(",
"foreign_account",
",",
"account",
"=",
"account",
",",
"permission",
"=",
... | Remove a key/account from an account's permission | [
"Remove",
"a",
"key",
"/",
"account",
"from",
"an",
"account",
"s",
"permission"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L66-L73 |
bitshares/uptick | uptick/account.py | history | def history(ctx, account, limit, type, csv, exclude, raw):
""" Show history of an account
"""
from bitsharesbase.operations import getOperationNameForId
t = [["#", "time (block)", "operation", "details"]]
for a in account:
account = Account(a, bitshares_instance=ctx.bitshares)
for ... | python | def history(ctx, account, limit, type, csv, exclude, raw):
""" Show history of an account
"""
from bitsharesbase.operations import getOperationNameForId
t = [["#", "time (block)", "operation", "details"]]
for a in account:
account = Account(a, bitshares_instance=ctx.bitshares)
for ... | [
"def",
"history",
"(",
"ctx",
",",
"account",
",",
"limit",
",",
"type",
",",
"csv",
",",
"exclude",
",",
"raw",
")",
":",
"from",
"bitsharesbase",
".",
"operations",
"import",
"getOperationNameForId",
"t",
"=",
"[",
"[",
"\"#\"",
",",
"\"time (block)\"",
... | Show history of an account | [
"Show",
"history",
"of",
"an",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L87-L105 |
bitshares/uptick | uptick/account.py | transfer | def transfer(ctx, to, amount, asset, memo, account):
""" Transfer assets
"""
print_tx(ctx.bitshares.transfer(to, amount, asset, memo=memo, account=account)) | python | def transfer(ctx, to, amount, asset, memo, account):
""" Transfer assets
"""
print_tx(ctx.bitshares.transfer(to, amount, asset, memo=memo, account=account)) | [
"def",
"transfer",
"(",
"ctx",
",",
"to",
",",
"amount",
",",
"asset",
",",
"memo",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"transfer",
"(",
"to",
",",
"amount",
",",
"asset",
",",
"memo",
"=",
"memo",
",",
"account... | Transfer assets | [
"Transfer",
"assets"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L119-L122 |
bitshares/uptick | uptick/account.py | balance | def balance(ctx, accounts):
""" Show Account balances
"""
t = [["Account", "Amount"]]
for a in accounts:
account = Account(a, bitshares_instance=ctx.bitshares)
for b in account.balances:
t.append([str(a), str(b)])
print_table(t) | python | def balance(ctx, accounts):
""" Show Account balances
"""
t = [["Account", "Amount"]]
for a in accounts:
account = Account(a, bitshares_instance=ctx.bitshares)
for b in account.balances:
t.append([str(a), str(b)])
print_table(t) | [
"def",
"balance",
"(",
"ctx",
",",
"accounts",
")",
":",
"t",
"=",
"[",
"[",
"\"Account\"",
",",
"\"Amount\"",
"]",
"]",
"for",
"a",
"in",
"accounts",
":",
"account",
"=",
"Account",
"(",
"a",
",",
"bitshares_instance",
"=",
"ctx",
".",
"bitshares",
... | Show Account balances | [
"Show",
"Account",
"balances"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L129-L137 |
bitshares/uptick | uptick/account.py | newaccount | def newaccount(ctx, accountname, account, password):
""" Create a new account
"""
print_tx(
ctx.bitshares.create_account(accountname, registrar=account, password=password)
) | python | def newaccount(ctx, accountname, account, password):
""" Create a new account
"""
print_tx(
ctx.bitshares.create_account(accountname, registrar=account, password=password)
) | [
"def",
"newaccount",
"(",
"ctx",
",",
"accountname",
",",
"account",
",",
"password",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"create_account",
"(",
"accountname",
",",
"registrar",
"=",
"account",
",",
"password",
"=",
"password",
")",
")... | Create a new account | [
"Create",
"a",
"new",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L167-L172 |
bitshares/uptick | uptick/account.py | cloneaccount | def cloneaccount(ctx, account_name, account):
""" Clone an account
This copies the owner and active permissions as well as the
options (e.g. votes, memo key)
"""
from bitsharesbase import transactions, operations
account = Account(account)
op = {
"fee": {"amount": 0, "asset... | python | def cloneaccount(ctx, account_name, account):
""" Clone an account
This copies the owner and active permissions as well as the
options (e.g. votes, memo key)
"""
from bitsharesbase import transactions, operations
account = Account(account)
op = {
"fee": {"amount": 0, "asset... | [
"def",
"cloneaccount",
"(",
"ctx",
",",
"account_name",
",",
"account",
")",
":",
"from",
"bitsharesbase",
"import",
"transactions",
",",
"operations",
"account",
"=",
"Account",
"(",
"account",
")",
"op",
"=",
"{",
"\"fee\"",
":",
"{",
"\"amount\"",
":",
... | Clone an account
This copies the owner and active permissions as well as the
options (e.g. votes, memo key) | [
"Clone",
"an",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L198-L220 |
bitshares/uptick | uptick/account.py | changememokey | def changememokey(ctx, key, account):
""" Change the memo key of an account
"""
print_tx(ctx.bitshares.update_memo_key(key, account=account)) | python | def changememokey(ctx, key, account):
""" Change the memo key of an account
"""
print_tx(ctx.bitshares.update_memo_key(key, account=account)) | [
"def",
"changememokey",
"(",
"ctx",
",",
"key",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"update_memo_key",
"(",
"key",
",",
"account",
"=",
"account",
")",
")"
] | Change the memo key of an account | [
"Change",
"the",
"memo",
"key",
"of",
"an",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L234-L237 |
bitshares/uptick | uptick/account.py | whitelist | def whitelist(ctx, whitelist_account, account):
""" Add an account to a whitelist
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.whitelist(whitelist_account)) | python | def whitelist(ctx, whitelist_account, account):
""" Add an account to a whitelist
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.whitelist(whitelist_account)) | [
"def",
"whitelist",
"(",
"ctx",
",",
"whitelist_account",
",",
"account",
")",
":",
"account",
"=",
"Account",
"(",
"account",
",",
"blockchain_instance",
"=",
"ctx",
".",
"blockchain",
")",
"print_tx",
"(",
"account",
".",
"whitelist",
"(",
"whitelist_account... | Add an account to a whitelist | [
"Add",
"an",
"account",
"to",
"a",
"whitelist"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L251-L255 |
bitshares/uptick | uptick/account.py | blacklist | def blacklist(ctx, blacklist_account, account):
""" Add an account to a blacklist
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.blacklist(blacklist_account)) | python | def blacklist(ctx, blacklist_account, account):
""" Add an account to a blacklist
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.blacklist(blacklist_account)) | [
"def",
"blacklist",
"(",
"ctx",
",",
"blacklist_account",
",",
"account",
")",
":",
"account",
"=",
"Account",
"(",
"account",
",",
"blockchain_instance",
"=",
"ctx",
".",
"blockchain",
")",
"print_tx",
"(",
"account",
".",
"blacklist",
"(",
"blacklist_account... | Add an account to a blacklist | [
"Add",
"an",
"account",
"to",
"a",
"blacklist"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L269-L273 |
bitshares/uptick | uptick/account.py | unlist | def unlist(ctx, unlist_account, account):
""" Remove an account from any list
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.nolist(unlist_account)) | python | def unlist(ctx, unlist_account, account):
""" Remove an account from any list
"""
account = Account(account, blockchain_instance=ctx.blockchain)
print_tx(account.nolist(unlist_account)) | [
"def",
"unlist",
"(",
"ctx",
",",
"unlist_account",
",",
"account",
")",
":",
"account",
"=",
"Account",
"(",
"account",
",",
"blockchain_instance",
"=",
"ctx",
".",
"blockchain",
")",
"print_tx",
"(",
"account",
".",
"nolist",
"(",
"unlist_account",
")",
... | Remove an account from any list | [
"Remove",
"an",
"account",
"from",
"any",
"list"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L287-L291 |
bitshares/uptick | uptick/account.py | setproxy | def setproxy(ctx, proxy_account, account):
""" Set the proxy account for an account
"""
print_tx(ctx.bitshares.set_proxy(proxy_account, account=account)) | python | def setproxy(ctx, proxy_account, account):
""" Set the proxy account for an account
"""
print_tx(ctx.bitshares.set_proxy(proxy_account, account=account)) | [
"def",
"setproxy",
"(",
"ctx",
",",
"proxy_account",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"set_proxy",
"(",
"proxy_account",
",",
"account",
"=",
"account",
")",
")"
] | Set the proxy account for an account | [
"Set",
"the",
"proxy",
"account",
"for",
"an",
"account"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/account.py#L305-L308 |
bitshares/uptick | uptick/callorders.py | calls | def calls(ctx, obj, limit):
""" List call/short positions of an account or an asset
"""
if obj.upper() == obj:
# Asset
from bitshares.asset import Asset
asset = Asset(obj, full=True)
calls = asset.get_call_orders(limit)
t = [["acount", "debt", "collateral", "call pri... | python | def calls(ctx, obj, limit):
""" List call/short positions of an account or an asset
"""
if obj.upper() == obj:
# Asset
from bitshares.asset import Asset
asset = Asset(obj, full=True)
calls = asset.get_call_orders(limit)
t = [["acount", "debt", "collateral", "call pri... | [
"def",
"calls",
"(",
"ctx",
",",
"obj",
",",
"limit",
")",
":",
"if",
"obj",
".",
"upper",
"(",
")",
"==",
"obj",
":",
"# Asset",
"from",
"bitshares",
".",
"asset",
"import",
"Asset",
"asset",
"=",
"Asset",
"(",
"obj",
",",
"full",
"=",
"True",
"... | List call/short positions of an account or an asset | [
"List",
"call",
"/",
"short",
"positions",
"of",
"an",
"account",
"or",
"an",
"asset"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/callorders.py#L20-L57 |
bitshares/uptick | uptick/callorders.py | settlements | def settlements(ctx, asset, limit):
""" Show pending settlement orders of a bitasset
"""
from bitshares.asset import Asset
asset = Asset(asset, full=True)
if not asset.is_bitasset:
print_message("{} is not a bitasset.".format(asset["symbol"]), "warning")
sys.exit(1)
calls = asse... | python | def settlements(ctx, asset, limit):
""" Show pending settlement orders of a bitasset
"""
from bitshares.asset import Asset
asset = Asset(asset, full=True)
if not asset.is_bitasset:
print_message("{} is not a bitasset.".format(asset["symbol"]), "warning")
sys.exit(1)
calls = asse... | [
"def",
"settlements",
"(",
"ctx",
",",
"asset",
",",
"limit",
")",
":",
"from",
"bitshares",
".",
"asset",
"import",
"Asset",
"asset",
"=",
"Asset",
"(",
"asset",
",",
"full",
"=",
"True",
")",
"if",
"not",
"asset",
".",
"is_bitasset",
":",
"print_mess... | Show pending settlement orders of a bitasset | [
"Show",
"pending",
"settlement",
"orders",
"of",
"a",
"bitasset"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/callorders.py#L65-L78 |
bitshares/uptick | uptick/workers.py | approveworker | def approveworker(ctx, workers, account):
""" Approve worker(es)
"""
print_tx(ctx.bitshares.approveworker(workers, account=account)) | python | def approveworker(ctx, workers, account):
""" Approve worker(es)
"""
print_tx(ctx.bitshares.approveworker(workers, account=account)) | [
"def",
"approveworker",
"(",
"ctx",
",",
"workers",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"approveworker",
"(",
"workers",
",",
"account",
"=",
"account",
")",
")"
] | Approve worker(es) | [
"Approve",
"worker",
"(",
"es",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/workers.py#L23-L26 |
bitshares/uptick | uptick/workers.py | disapproveworker | def disapproveworker(ctx, workers, account):
""" Disapprove worker(es)
"""
print_tx(ctx.bitshares.disapproveworker(workers, account=account)) | python | def disapproveworker(ctx, workers, account):
""" Disapprove worker(es)
"""
print_tx(ctx.bitshares.disapproveworker(workers, account=account)) | [
"def",
"disapproveworker",
"(",
"ctx",
",",
"workers",
",",
"account",
")",
":",
"print_tx",
"(",
"ctx",
".",
"bitshares",
".",
"disapproveworker",
"(",
"workers",
",",
"account",
"=",
"account",
")",
")"
] | Disapprove worker(es) | [
"Disapprove",
"worker",
"(",
"es",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/workers.py#L40-L43 |
bitshares/uptick | uptick/workers.py | workers | def workers(ctx, account, top):
""" List all workers (of an account)
"""
workers = Workers(account)
t = [["id", "name/url", "daily_pay", "votes", "time", "account"]]
workers_sorted = sorted(
workers, key=lambda x: int(x["total_votes_for"]), reverse=True
)
if top:
workers_sort... | python | def workers(ctx, account, top):
""" List all workers (of an account)
"""
workers = Workers(account)
t = [["id", "name/url", "daily_pay", "votes", "time", "account"]]
workers_sorted = sorted(
workers, key=lambda x: int(x["total_votes_for"]), reverse=True
)
if top:
workers_sort... | [
"def",
"workers",
"(",
"ctx",
",",
"account",
",",
"top",
")",
":",
"workers",
"=",
"Workers",
"(",
"account",
")",
"t",
"=",
"[",
"[",
"\"id\"",
",",
"\"name/url\"",
",",
"\"daily_pay\"",
",",
"\"votes\"",
",",
"\"time\"",
",",
"\"account\"",
"]",
"]"... | List all workers (of an account) | [
"List",
"all",
"workers",
"(",
"of",
"an",
"account",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/workers.py#L51-L78 |
bitshares/uptick | uptick/wallet.py | addkey | def addkey(ctx, key):
""" Add a private key to the wallet
"""
if not key:
while True:
key = click.prompt(
"Private Key (wif) [Enter to quit]",
hide_input=True,
show_default=False,
default="exit",
)
if... | python | def addkey(ctx, key):
""" Add a private key to the wallet
"""
if not key:
while True:
key = click.prompt(
"Private Key (wif) [Enter to quit]",
hide_input=True,
show_default=False,
default="exit",
)
if... | [
"def",
"addkey",
"(",
"ctx",
",",
"key",
")",
":",
"if",
"not",
"key",
":",
"while",
"True",
":",
"key",
"=",
"click",
".",
"prompt",
"(",
"\"Private Key (wif) [Enter to quit]\"",
",",
"hide_input",
"=",
"True",
",",
"show_default",
"=",
"False",
",",
"d... | Add a private key to the wallet | [
"Add",
"a",
"private",
"key",
"to",
"the",
"wallet"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L47-L83 |
bitshares/uptick | uptick/wallet.py | delkey | def delkey(ctx, pubkeys):
""" Delete a private key from the wallet
"""
if not pubkeys:
pubkeys = click.prompt("Public Keys").split(" ")
if click.confirm(
"Are you sure you want to delete keys from your wallet?\n"
"This step is IRREVERSIBLE! If you don't have a backup, "
"... | python | def delkey(ctx, pubkeys):
""" Delete a private key from the wallet
"""
if not pubkeys:
pubkeys = click.prompt("Public Keys").split(" ")
if click.confirm(
"Are you sure you want to delete keys from your wallet?\n"
"This step is IRREVERSIBLE! If you don't have a backup, "
"... | [
"def",
"delkey",
"(",
"ctx",
",",
"pubkeys",
")",
":",
"if",
"not",
"pubkeys",
":",
"pubkeys",
"=",
"click",
".",
"prompt",
"(",
"\"Public Keys\"",
")",
".",
"split",
"(",
"\" \"",
")",
"if",
"click",
".",
"confirm",
"(",
"\"Are you sure you want to delete... | Delete a private key from the wallet | [
"Delete",
"a",
"private",
"key",
"from",
"the",
"wallet"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L90-L101 |
bitshares/uptick | uptick/wallet.py | getkey | def getkey(ctx, pubkey):
""" Obtain private key in WIF format
"""
click.echo(ctx.bitshares.wallet.getPrivateKeyForPublicKey(pubkey)) | python | def getkey(ctx, pubkey):
""" Obtain private key in WIF format
"""
click.echo(ctx.bitshares.wallet.getPrivateKeyForPublicKey(pubkey)) | [
"def",
"getkey",
"(",
"ctx",
",",
"pubkey",
")",
":",
"click",
".",
"echo",
"(",
"ctx",
".",
"bitshares",
".",
"wallet",
".",
"getPrivateKeyForPublicKey",
"(",
"pubkey",
")",
")"
] | Obtain private key in WIF format | [
"Obtain",
"private",
"key",
"in",
"WIF",
"format"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L109-L112 |
bitshares/uptick | uptick/wallet.py | listkeys | def listkeys(ctx):
""" List all keys (for all networks)
"""
t = [["Available Key"]]
for key in ctx.bitshares.wallet.getPublicKeys():
t.append([key])
print_table(t) | python | def listkeys(ctx):
""" List all keys (for all networks)
"""
t = [["Available Key"]]
for key in ctx.bitshares.wallet.getPublicKeys():
t.append([key])
print_table(t) | [
"def",
"listkeys",
"(",
"ctx",
")",
":",
"t",
"=",
"[",
"[",
"\"Available Key\"",
"]",
"]",
"for",
"key",
"in",
"ctx",
".",
"bitshares",
".",
"wallet",
".",
"getPublicKeys",
"(",
")",
":",
"t",
".",
"append",
"(",
"[",
"key",
"]",
")",
"print_table... | List all keys (for all networks) | [
"List",
"all",
"keys",
"(",
"for",
"all",
"networks",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L118-L124 |
bitshares/uptick | uptick/wallet.py | listaccounts | def listaccounts(ctx):
""" List accounts (for the connected network)
"""
t = [["Name", "Key", "Owner", "Active", "Memo"]]
for key in tqdm(ctx.bitshares.wallet.getPublicKeys(True)):
for account in ctx.bitshares.wallet.getAccountsFromPublicKey(key):
account = Account(account)
... | python | def listaccounts(ctx):
""" List accounts (for the connected network)
"""
t = [["Name", "Key", "Owner", "Active", "Memo"]]
for key in tqdm(ctx.bitshares.wallet.getPublicKeys(True)):
for account in ctx.bitshares.wallet.getAccountsFromPublicKey(key):
account = Account(account)
... | [
"def",
"listaccounts",
"(",
"ctx",
")",
":",
"t",
"=",
"[",
"[",
"\"Name\"",
",",
"\"Key\"",
",",
"\"Owner\"",
",",
"\"Active\"",
",",
"\"Memo\"",
"]",
"]",
"for",
"key",
"in",
"tqdm",
"(",
"ctx",
".",
"bitshares",
".",
"wallet",
".",
"getPublicKeys",
... | List accounts (for the connected network) | [
"List",
"accounts",
"(",
"for",
"the",
"connected",
"network",
")"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L130-L147 |
bitshares/uptick | uptick/wallet.py | importaccount | def importaccount(ctx, account, role):
""" Import an account using an account password
"""
from bitsharesbase.account import PasswordKey
password = click.prompt("Account Passphrase", hide_input=True)
account = Account(account, bitshares_instance=ctx.bitshares)
imported = False
if role == "... | python | def importaccount(ctx, account, role):
""" Import an account using an account password
"""
from bitsharesbase.account import PasswordKey
password = click.prompt("Account Passphrase", hide_input=True)
account = Account(account, bitshares_instance=ctx.bitshares)
imported = False
if role == "... | [
"def",
"importaccount",
"(",
"ctx",
",",
"account",
",",
"role",
")",
":",
"from",
"bitsharesbase",
".",
"account",
"import",
"PasswordKey",
"password",
"=",
"click",
".",
"prompt",
"(",
"\"Account Passphrase\"",
",",
"hide_input",
"=",
"True",
")",
"account",... | Import an account using an account password | [
"Import",
"an",
"account",
"using",
"an",
"account",
"password"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/wallet.py#L158-L201 |
bitshares/uptick | uptick/api.py | create | def create(ctx):
""" Create default config file
"""
import shutil
this_dir, this_filename = os.path.split(__file__)
default_config_file = os.path.join(this_dir, "apis/example-config.yaml")
config_file = ctx.obj["configfile"]
shutil.copyfile(default_config_file, config_file)
print_messag... | python | def create(ctx):
""" Create default config file
"""
import shutil
this_dir, this_filename = os.path.split(__file__)
default_config_file = os.path.join(this_dir, "apis/example-config.yaml")
config_file = ctx.obj["configfile"]
shutil.copyfile(default_config_file, config_file)
print_messag... | [
"def",
"create",
"(",
"ctx",
")",
":",
"import",
"shutil",
"this_dir",
",",
"this_filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"__file__",
")",
"default_config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"this_dir",
",",
"\"apis/example-confi... | Create default config file | [
"Create",
"default",
"config",
"file"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/api.py#L28-L37 |
bitshares/uptick | uptick/api.py | start | def start(ctx):
""" Start the API according to the config file
"""
module = ctx.config.get("api", "poloniex")
# unlockWallet
if module == "poloniex":
from .apis import poloniex
poloniex.run(ctx, port=5000)
else:
print_message("Unkown 'api'!", "error") | python | def start(ctx):
""" Start the API according to the config file
"""
module = ctx.config.get("api", "poloniex")
# unlockWallet
if module == "poloniex":
from .apis import poloniex
poloniex.run(ctx, port=5000)
else:
print_message("Unkown 'api'!", "error") | [
"def",
"start",
"(",
"ctx",
")",
":",
"module",
"=",
"ctx",
".",
"config",
".",
"get",
"(",
"\"api\"",
",",
"\"poloniex\"",
")",
"# unlockWallet",
"if",
"module",
"==",
"\"poloniex\"",
":",
"from",
".",
"apis",
"import",
"poloniex",
"poloniex",
".",
"run... | Start the API according to the config file | [
"Start",
"the",
"API",
"according",
"to",
"the",
"config",
"file"
] | train | https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/api.py#L43-L53 |
rmax/scrapydo | scrapydo/api.py | fetch | def fetch(url, **kwargs):
"""Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to crawl.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler instance.
capture_items : bool (default: True)
If enabled, ... | python | def fetch(url, **kwargs):
"""Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to crawl.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler instance.
capture_items : bool (default: True)
If enabled, ... | [
"def",
"fetch",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"DEFAULT_TIMEOUT",
")",
"kwargs",
"[",
"'return_crawler'",
"]",
"=",
"True",
"crawler",
"=",
"wait_for",
"(",
"timeout",
",",
"_... | Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to crawl.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler instance.
capture_items : bool (default: True)
If enabled, the scraped items are captured an... | [
"Fetches",
"an",
"URL",
"and",
"returns",
"the",
"response",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L25-L59 |
rmax/scrapydo | scrapydo/api.py | crawl | def crawl(url, callback, **kwargs):
"""Crawls an URL with given callback.
Parameters
----------
url : str
An URL to crawl.
callback : callable
A function to be used as spider callback for the given URL.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class t... | python | def crawl(url, callback, **kwargs):
"""Crawls an URL with given callback.
Parameters
----------
url : str
An URL to crawl.
callback : callable
A function to be used as spider callback for the given URL.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class t... | [
"def",
"crawl",
"(",
"url",
",",
"callback",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"DEFAULT_TIMEOUT",
")",
"return",
"wait_for",
"(",
"timeout",
",",
"_crawl_in_reactor",
",",
"url",
",",
"callbac... | Crawls an URL with given callback.
Parameters
----------
url : str
An URL to crawl.
callback : callable
A function to be used as spider callback for the given URL.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler instance.
capt... | [
"Crawls",
"an",
"URL",
"with",
"given",
"callback",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L62-L95 |
rmax/scrapydo | scrapydo/api.py | run_spider | def run_spider(spider_cls, **kwargs):
"""Runs a spider and returns the scraped items (by default).
Parameters
----------
spider_cls : scrapy.Spider
A spider class to run.
capture_items : bool (default: True)
If enabled, the scraped items are captured and returned.
return_crawler... | python | def run_spider(spider_cls, **kwargs):
"""Runs a spider and returns the scraped items (by default).
Parameters
----------
spider_cls : scrapy.Spider
A spider class to run.
capture_items : bool (default: True)
If enabled, the scraped items are captured and returned.
return_crawler... | [
"def",
"run_spider",
"(",
"spider_cls",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"DEFAULT_TIMEOUT",
")",
"return",
"wait_for",
"(",
"timeout",
",",
"_run_spider_in_reactor",
",",
"spider_cls",
",",
"*",
... | Runs a spider and returns the scraped items (by default).
Parameters
----------
spider_cls : scrapy.Spider
A spider class to run.
capture_items : bool (default: True)
If enabled, the scraped items are captured and returned.
return_crawler : bool (default: False)
If enabled, ... | [
"Runs",
"a",
"spider",
"and",
"returns",
"the",
"scraped",
"items",
"(",
"by",
"default",
")",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L98-L127 |
rmax/scrapydo | scrapydo/api.py | _fetch_in_reactor | def _fetch_in_reactor(url, spider_cls=DefaultSpider, **kwargs):
"""Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to fetch.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler.
kwargs : dict, optional
... | python | def _fetch_in_reactor(url, spider_cls=DefaultSpider, **kwargs):
"""Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to fetch.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler.
kwargs : dict, optional
... | [
"def",
"_fetch_in_reactor",
"(",
"url",
",",
"spider_cls",
"=",
"DefaultSpider",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"parse",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"response",
"=",
"response",
"req",
"=",
"Request",
"(",
"url",
")"... | Fetches an URL and returns the response.
Parameters
----------
url : str
An URL to fetch.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler.
kwargs : dict, optional
Additional arguments to be passed to ``_run_spider_in_reactor``.
... | [
"Fetches",
"an",
"URL",
"and",
"returns",
"the",
"response",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L130-L153 |
rmax/scrapydo | scrapydo/api.py | _crawl_in_reactor | def _crawl_in_reactor(url, callback, spider_cls=DefaultSpider, **kwargs):
"""Crawls given URL with given callback.
Parameters
----------
url : str
The URL to crawl.
callback : callable
Function to be used as callback for the request.
spider_cls : scrapy.Spider (default: DefaultS... | python | def _crawl_in_reactor(url, callback, spider_cls=DefaultSpider, **kwargs):
"""Crawls given URL with given callback.
Parameters
----------
url : str
The URL to crawl.
callback : callable
Function to be used as callback for the request.
spider_cls : scrapy.Spider (default: DefaultS... | [
"def",
"_crawl_in_reactor",
"(",
"url",
",",
"callback",
",",
"spider_cls",
"=",
"DefaultSpider",
",",
"*",
"*",
"kwargs",
")",
":",
"spider_cls",
"=",
"override_start_requests",
"(",
"spider_cls",
",",
"[",
"url",
"]",
",",
"callback",
")",
"return",
"_run_... | Crawls given URL with given callback.
Parameters
----------
url : str
The URL to crawl.
callback : callable
Function to be used as callback for the request.
spider_cls : scrapy.Spider (default: DefaultSpider)
A spider class to be used in the crawler instance.
kwargs : di... | [
"Crawls",
"given",
"URL",
"with",
"given",
"callback",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L156-L176 |
rmax/scrapydo | scrapydo/api.py | _run_spider_in_reactor | def _run_spider_in_reactor(spider_cls, capture_items=True, return_crawler=False,
settings=None, **kwargs):
"""Runs given spider inside the twisted reactdor.
Parameters
----------
spider_cls : scrapy.Spider
Spider to run.
capture_items : bool (default: True)
... | python | def _run_spider_in_reactor(spider_cls, capture_items=True, return_crawler=False,
settings=None, **kwargs):
"""Runs given spider inside the twisted reactdor.
Parameters
----------
spider_cls : scrapy.Spider
Spider to run.
capture_items : bool (default: True)
... | [
"def",
"_run_spider_in_reactor",
"(",
"spider_cls",
",",
"capture_items",
"=",
"True",
",",
"return_crawler",
"=",
"False",
",",
"settings",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"settings",
"=",
"settings",
"or",
"{",
"}",
"crawler_settings",
"=",... | Runs given spider inside the twisted reactdor.
Parameters
----------
spider_cls : scrapy.Spider
Spider to run.
capture_items : bool (default: True)
If enabled, the scraped items are captured and returned.
return_crawler : bool (default: False)
If enabled, the crawler instanc... | [
"Runs",
"given",
"spider",
"inside",
"the",
"twisted",
"reactdor",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L180-L216 |
rmax/scrapydo | scrapydo/api.py | override_start_requests | def override_start_requests(spider_cls, start_urls, callback=None, **attrs):
"""Returns a new spider class overriding the ``start_requests``.
This function is useful to replace the start requests of an existing spider
class on runtime.
Parameters
----------
spider_cls : scrapy.Spider
S... | python | def override_start_requests(spider_cls, start_urls, callback=None, **attrs):
"""Returns a new spider class overriding the ``start_requests``.
This function is useful to replace the start requests of an existing spider
class on runtime.
Parameters
----------
spider_cls : scrapy.Spider
S... | [
"def",
"override_start_requests",
"(",
"spider_cls",
",",
"start_urls",
",",
"callback",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"def",
"start_requests",
"(",
")",
":",
"for",
"url",
"in",
"start_urls",
":",
"req",
"=",
"Request",
"(",
"url",
",",... | Returns a new spider class overriding the ``start_requests``.
This function is useful to replace the start requests of an existing spider
class on runtime.
Parameters
----------
spider_cls : scrapy.Spider
Spider class to be used as base class.
start_urls : iterable
Iterable of ... | [
"Returns",
"a",
"new",
"spider",
"class",
"overriding",
"the",
"start_requests",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L225-L255 |
rmax/scrapydo | scrapydo/api.py | wait_for | def wait_for(timeout, func, *args, **kwargs):
"""Waits for a eventual result.
Parameters
----------
timeout : int
How much time to wait, in seconds.
func : callable
A function that returns ``crochet.EventualResult``.
args : tuple, optional
Arguments for ``func``.
kwa... | python | def wait_for(timeout, func, *args, **kwargs):
"""Waits for a eventual result.
Parameters
----------
timeout : int
How much time to wait, in seconds.
func : callable
A function that returns ``crochet.EventualResult``.
args : tuple, optional
Arguments for ``func``.
kwa... | [
"def",
"wait_for",
"(",
"timeout",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"return",
"result",
".",
"wait",
"(",
"timeout",
")",
"except"... | Waits for a eventual result.
Parameters
----------
timeout : int
How much time to wait, in seconds.
func : callable
A function that returns ``crochet.EventualResult``.
args : tuple, optional
Arguments for ``func``.
kwargs : dict, optional
Keyword arguments for ``... | [
"Waits",
"for",
"a",
"eventual",
"result",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/api.py#L258-L287 |
rmax/scrapydo | scrapydo/utils.py | highlight | def highlight(code, lexer='html', formatter='html', output_wrapper=None):
"""Highlights given code using pygments."""
if not pygments:
raise TypeError("pygments module required")
if not isinstance(code, six.string_types):
code = pprint.pformat(code)
if isinstance(lexer, six.string_types)... | python | def highlight(code, lexer='html', formatter='html', output_wrapper=None):
"""Highlights given code using pygments."""
if not pygments:
raise TypeError("pygments module required")
if not isinstance(code, six.string_types):
code = pprint.pformat(code)
if isinstance(lexer, six.string_types)... | [
"def",
"highlight",
"(",
"code",
",",
"lexer",
"=",
"'html'",
",",
"formatter",
"=",
"'html'",
",",
"output_wrapper",
"=",
"None",
")",
":",
"if",
"not",
"pygments",
":",
"raise",
"TypeError",
"(",
"\"pygments module required\"",
")",
"if",
"not",
"isinstanc... | Highlights given code using pygments. | [
"Highlights",
"given",
"code",
"using",
"pygments",
"."
] | train | https://github.com/rmax/scrapydo/blob/b0f9e6d50a5ea9d2ba8335bffa877003109c3af5/scrapydo/utils.py#L16-L31 |
williballenthin/ida-netnode | netnode/netnode.py | Netnode._get_next_slot | def _get_next_slot(self, tag):
'''
get the first unused supval table key, or 0 if the
table is empty.
useful for filling the supval table sequentially.
'''
slot = self._n.suplast(tag)
if slot is None or slot == idaapi.BADNODE:
return 0
else:
... | python | def _get_next_slot(self, tag):
'''
get the first unused supval table key, or 0 if the
table is empty.
useful for filling the supval table sequentially.
'''
slot = self._n.suplast(tag)
if slot is None or slot == idaapi.BADNODE:
return 0
else:
... | [
"def",
"_get_next_slot",
"(",
"self",
",",
"tag",
")",
":",
"slot",
"=",
"self",
".",
"_n",
".",
"suplast",
"(",
"tag",
")",
"if",
"slot",
"is",
"None",
"or",
"slot",
"==",
"idaapi",
".",
"BADNODE",
":",
"return",
"0",
"else",
":",
"return",
"slot"... | get the first unused supval table key, or 0 if the
table is empty.
useful for filling the supval table sequentially. | [
"get",
"the",
"first",
"unused",
"supval",
"table",
"key",
"or",
"0",
"if",
"the",
"table",
"is",
"empty",
".",
"useful",
"for",
"filling",
"the",
"supval",
"table",
"sequentially",
"."
] | train | https://github.com/williballenthin/ida-netnode/blob/6ca60ceddaa2e3283207217b832accfcf8dd01dc/netnode/netnode.py#L104-L114 |
mattboyer/sqbrite | version.py | GitRunner.run_git | def run_git(self, args, git_env=None):
'''
Runs the git executable with the arguments given and returns a list of
lines produced on its standard output.
'''
popen_kwargs = {
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE,
}
if git_e... | python | def run_git(self, args, git_env=None):
'''
Runs the git executable with the arguments given and returns a list of
lines produced on its standard output.
'''
popen_kwargs = {
'stdout': subprocess.PIPE,
'stderr': subprocess.PIPE,
}
if git_e... | [
"def",
"run_git",
"(",
"self",
",",
"args",
",",
"git_env",
"=",
"None",
")",
":",
"popen_kwargs",
"=",
"{",
"'stdout'",
":",
"subprocess",
".",
"PIPE",
",",
"'stderr'",
":",
"subprocess",
".",
"PIPE",
",",
"}",
"if",
"git_env",
":",
"popen_kwargs",
"[... | Runs the git executable with the arguments given and returns a list of
lines produced on its standard output. | [
"Runs",
"the",
"git",
"executable",
"with",
"the",
"arguments",
"given",
"and",
"returns",
"a",
"list",
"of",
"lines",
"produced",
"on",
"its",
"standard",
"output",
"."
] | train | https://github.com/mattboyer/sqbrite/blob/22d8049f8c03e52ed5232726f883517813fe7e8c/version.py#L131-L175 |
mozilla/build-mar | src/mardor/writer.py | add_signature_block | def add_signature_block(src_fileobj, dest_fileobj, signing_algorithm, signature=None):
"""Add a signature block to marfile, a MarReader object.
Productversion and channel are preserved, but any existing signatures are overwritten.
Args:
src_fileobj (file object): The input MAR file to add a signat... | python | def add_signature_block(src_fileobj, dest_fileobj, signing_algorithm, signature=None):
"""Add a signature block to marfile, a MarReader object.
Productversion and channel are preserved, but any existing signatures are overwritten.
Args:
src_fileobj (file object): The input MAR file to add a signat... | [
"def",
"add_signature_block",
"(",
"src_fileobj",
",",
"dest_fileobj",
",",
"signing_algorithm",
",",
"signature",
"=",
"None",
")",
":",
"algo_id",
"=",
"{",
"'sha1'",
":",
"1",
",",
"'sha384'",
":",
"2",
"}",
"[",
"signing_algorithm",
"]",
"if",
"not",
"... | Add a signature block to marfile, a MarReader object.
Productversion and channel are preserved, but any existing signatures are overwritten.
Args:
src_fileobj (file object): The input MAR file to add a signature to
dest_fileobj (file object): File object to write new MAR file to. Must be open ... | [
"Add",
"a",
"signature",
"block",
"to",
"marfile",
"a",
"MarReader",
"object",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L328-L399 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.add | def add(self, path, compress=None):
"""Add `path` to the MAR file.
If `path` is a file, it will be added directly.
If `path` is a directory, it will be traversed recursively and all
files inside will be added.
Args:
path (str): path to file or directory on disk to a... | python | def add(self, path, compress=None):
"""Add `path` to the MAR file.
If `path` is a file, it will be added directly.
If `path` is a directory, it will be traversed recursively and all
files inside will be added.
Args:
path (str): path to file or directory on disk to a... | [
"def",
"add",
"(",
"self",
",",
"path",
",",
"compress",
"=",
"None",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"self",
".",
"add_dir",
"(",
"path",
",",
"compress",
")",
"else",
":",
"self",
".",
"add_file",
"(",
... | Add `path` to the MAR file.
If `path` is a file, it will be added directly.
If `path` is a directory, it will be traversed recursively and all
files inside will be added.
Args:
path (str): path to file or directory on disk to add to this MAR
file
... | [
"Add",
"path",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L117-L132 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.add_dir | def add_dir(self, path, compress):
"""Add all files under directory `path` to the MAR file.
Args:
path (str): path to directory to add to this MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
"""
if not os.path.isdir(path):
rais... | python | def add_dir(self, path, compress):
"""Add all files under directory `path` to the MAR file.
Args:
path (str): path to directory to add to this MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
"""
if not os.path.isdir(path):
rais... | [
"def",
"add_dir",
"(",
"self",
",",
"path",
",",
"compress",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"'{} is not a directory'",
".",
"format",
"(",
"path",
")",
")",
"for",
"root",
",... | Add all files under directory `path` to the MAR file.
Args:
path (str): path to directory to add to this MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None. | [
"Add",
"all",
"files",
"under",
"directory",
"path",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L134-L145 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.add_fileobj | def add_fileobj(self, fileobj, path, compress, flags=None):
"""Add the contents of a file object to the MAR file.
Args:
fileobj (file-like object): open file object
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to... | python | def add_fileobj(self, fileobj, path, compress, flags=None):
"""Add the contents of a file object to the MAR file.
Args:
fileobj (file-like object): open file object
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to... | [
"def",
"add_fileobj",
"(",
"self",
",",
"fileobj",
",",
"path",
",",
"compress",
",",
"flags",
"=",
"None",
")",
":",
"f",
"=",
"file_iter",
"(",
"fileobj",
")",
"flags",
"=",
"flags",
"or",
"os",
".",
"stat",
"(",
"path",
")",
"&",
"0o777",
"retur... | Add the contents of a file object to the MAR file.
Args:
fileobj (file-like object): open file object
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
flags (int): permission of this file in the MAR file... | [
"Add",
"the",
"contents",
"of",
"a",
"file",
"object",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L147-L158 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.add_stream | def add_stream(self, stream, path, compress, flags):
"""Add the contents of an iterable to the MAR file.
Args:
stream (iterable): yields blocks of data
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
... | python | def add_stream(self, stream, path, compress, flags):
"""Add the contents of an iterable to the MAR file.
Args:
stream (iterable): yields blocks of data
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
... | [
"def",
"add_stream",
"(",
"self",
",",
"stream",
",",
"path",
",",
"compress",
",",
"flags",
")",
":",
"self",
".",
"data_fileobj",
".",
"seek",
"(",
"self",
".",
"last_offset",
")",
"if",
"compress",
"==",
"'bz2'",
":",
"stream",
"=",
"bz2_compress_stre... | Add the contents of an iterable to the MAR file.
Args:
stream (iterable): yields blocks of data
path (str): name of this file in the MAR file
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
flags (int): permission of this file in the MAR file | [
"Add",
"the",
"contents",
"of",
"an",
"iterable",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L160-L194 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.add_file | def add_file(self, path, compress):
"""Add a single file to the MAR file.
Args:
path (str): path to a file to add to this MAR file.
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
"""
if not os.path.isfile(path):
raise ValueError('{} is... | python | def add_file(self, path, compress):
"""Add a single file to the MAR file.
Args:
path (str): path to a file to add to this MAR file.
compress (str): One of 'xz', 'bz2', or None. Defaults to None.
"""
if not os.path.isfile(path):
raise ValueError('{} is... | [
"def",
"add_file",
"(",
"self",
",",
"path",
",",
"compress",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"'{} is not a file'",
".",
"format",
"(",
"path",
")",
")",
"self",
".",
"fileob... | Add a single file to the MAR file.
Args:
path (str): path to a file to add to this MAR file.
compress (str): One of 'xz', 'bz2', or None. Defaults to None. | [
"Add",
"a",
"single",
"file",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L196-L209 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.write_header | def write_header(self):
"""Write the MAR header to the file.
The MAR header includes the MAR magic bytes as well as the offset to
where the index data can be found.
"""
self.fileobj.seek(0)
header = mar_header.build(dict(index_offset=self.last_offset))
self.fileo... | python | def write_header(self):
"""Write the MAR header to the file.
The MAR header includes the MAR magic bytes as well as the offset to
where the index data can be found.
"""
self.fileobj.seek(0)
header = mar_header.build(dict(index_offset=self.last_offset))
self.fileo... | [
"def",
"write_header",
"(",
"self",
")",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"0",
")",
"header",
"=",
"mar_header",
".",
"build",
"(",
"dict",
"(",
"index_offset",
"=",
"self",
".",
"last_offset",
")",
")",
"self",
".",
"fileobj",
".",
"wr... | Write the MAR header to the file.
The MAR header includes the MAR magic bytes as well as the offset to
where the index data can be found. | [
"Write",
"the",
"MAR",
"header",
"to",
"the",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L211-L219 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.dummy_signatures | def dummy_signatures(self):
"""Create a dummy signature.
This is used when initially writing the MAR header and we don't know
what the final signature data will be.
Returns:
Fake signature data suitable for writing to the header with
.write_signatures()
... | python | def dummy_signatures(self):
"""Create a dummy signature.
This is used when initially writing the MAR header and we don't know
what the final signature data will be.
Returns:
Fake signature data suitable for writing to the header with
.write_signatures()
... | [
"def",
"dummy_signatures",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"signing_algorithm",
":",
"return",
"[",
"]",
"algo_id",
"=",
"{",
"'sha1'",
":",
"1",
",",
"'sha384'",
":",
"2",
"}",
"[",
"self",
".",
"signing_algorithm",
"]",
"signature",
... | Create a dummy signature.
This is used when initially writing the MAR header and we don't know
what the final signature data will be.
Returns:
Fake signature data suitable for writing to the header with
.write_signatures() | [
"Create",
"a",
"dummy",
"signature",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L221-L236 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.calculate_signatures | def calculate_signatures(self):
"""Calculate the signatures for this MAR file.
Returns:
A list of signature tuples: [(algorithm_id, signature_data), ...]
"""
if not self.signing_algorithm:
return []
algo_id = {'sha1': 1, 'sha384': 2}[self.signing_algori... | python | def calculate_signatures(self):
"""Calculate the signatures for this MAR file.
Returns:
A list of signature tuples: [(algorithm_id, signature_data), ...]
"""
if not self.signing_algorithm:
return []
algo_id = {'sha1': 1, 'sha384': 2}[self.signing_algori... | [
"def",
"calculate_signatures",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"signing_algorithm",
":",
"return",
"[",
"]",
"algo_id",
"=",
"{",
"'sha1'",
":",
"1",
",",
"'sha384'",
":",
"2",
"}",
"[",
"self",
".",
"signing_algorithm",
"]",
"hashers",
... | Calculate the signatures for this MAR file.
Returns:
A list of signature tuples: [(algorithm_id, signature_data), ...] | [
"Calculate",
"the",
"signatures",
"for",
"this",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L238-L254 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.write_signatures | def write_signatures(self, signatures):
"""Write signature data to the MAR file.
Args:
signatures (list): list of signature tuples of the form
(algorithm_id, signature_data)
"""
self.fileobj.seek(self.signature_offset)
sig_entries = [dict(algorithm_i... | python | def write_signatures(self, signatures):
"""Write signature data to the MAR file.
Args:
signatures (list): list of signature tuples of the form
(algorithm_id, signature_data)
"""
self.fileobj.seek(self.signature_offset)
sig_entries = [dict(algorithm_i... | [
"def",
"write_signatures",
"(",
"self",
",",
"signatures",
")",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"self",
".",
"signature_offset",
")",
"sig_entries",
"=",
"[",
"dict",
"(",
"algorithm_id",
"=",
"id_",
",",
"size",
"=",
"len",
"(",
"sig",
... | Write signature data to the MAR file.
Args:
signatures (list): list of signature tuples of the form
(algorithm_id, signature_data) | [
"Write",
"signature",
"data",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L256-L280 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.write_additional | def write_additional(self, productversion, channel):
"""Write the additional information to the MAR header.
Args:
productversion (str): product and version string
channel (str): channel string
"""
self.fileobj.seek(self.additional_offset)
extras = extras... | python | def write_additional(self, productversion, channel):
"""Write the additional information to the MAR header.
Args:
productversion (str): product and version string
channel (str): channel string
"""
self.fileobj.seek(self.additional_offset)
extras = extras... | [
"def",
"write_additional",
"(",
"self",
",",
"productversion",
",",
"channel",
")",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"self",
".",
"additional_offset",
")",
"extras",
"=",
"extras_header",
".",
"build",
"(",
"dict",
"(",
"count",
"=",
"1",
"... | Write the additional information to the MAR header.
Args:
productversion (str): product and version string
channel (str): channel string | [
"Write",
"the",
"additional",
"information",
"to",
"the",
"MAR",
"header",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L282-L302 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.write_index | def write_index(self):
"""Write the index of all our files to the MAR file."""
self.fileobj.seek(self.last_offset)
index = index_header.build(dict(entries=self.entries))
self.fileobj.write(index)
self.filesize = self.fileobj.tell() | python | def write_index(self):
"""Write the index of all our files to the MAR file."""
self.fileobj.seek(self.last_offset)
index = index_header.build(dict(entries=self.entries))
self.fileobj.write(index)
self.filesize = self.fileobj.tell() | [
"def",
"write_index",
"(",
"self",
")",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"self",
".",
"last_offset",
")",
"index",
"=",
"index_header",
".",
"build",
"(",
"dict",
"(",
"entries",
"=",
"self",
".",
"entries",
")",
")",
"self",
".",
"file... | Write the index of all our files to the MAR file. | [
"Write",
"the",
"index",
"of",
"all",
"our",
"files",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L304-L309 |
mozilla/build-mar | src/mardor/writer.py | MarWriter.finish | def finish(self):
"""Finalize the MAR file.
The MAR header, index and signatures need to be updated once we've
finished adding all the files.
"""
# Update the last_offset in the mar header
self.write_header()
# Write out the index of contents
self.write_i... | python | def finish(self):
"""Finalize the MAR file.
The MAR header, index and signatures need to be updated once we've
finished adding all the files.
"""
# Update the last_offset in the mar header
self.write_header()
# Write out the index of contents
self.write_i... | [
"def",
"finish",
"(",
"self",
")",
":",
"# Update the last_offset in the mar header",
"self",
".",
"write_header",
"(",
")",
"# Write out the index of contents",
"self",
".",
"write_index",
"(",
")",
"if",
"not",
"self",
".",
"use_old_format",
":",
"# Refresh the sign... | Finalize the MAR file.
The MAR header, index and signatures need to be updated once we've
finished adding all the files. | [
"Finalize",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/writer.py#L311-L325 |
mozilla/build-mar | src/mardor/cli.py | build_argparser | def build_argparser():
"""Build argument parser for the CLI."""
parser = ArgumentParser('Utility for managing MAR files')
create_group = parser.add_argument_group("Create a MAR file")
create_group.add_argument("-c", "--create", metavar="MARFILE", help="create MAR")
create_group.add_argument("-V", "-... | python | def build_argparser():
"""Build argument parser for the CLI."""
parser = ArgumentParser('Utility for managing MAR files')
create_group = parser.add_argument_group("Create a MAR file")
create_group.add_argument("-c", "--create", metavar="MARFILE", help="create MAR")
create_group.add_argument("-V", "-... | [
"def",
"build_argparser",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"'Utility for managing MAR files'",
")",
"create_group",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"Create a MAR file\"",
")",
"create_group",
".",
"add_argument",
"(",
"\"-c\"",
","... | Build argument parser for the CLI. | [
"Build",
"argument",
"parser",
"for",
"the",
"CLI",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L23-L73 |
mozilla/build-mar | src/mardor/cli.py | do_extract | def do_extract(marfile, destdir, decompress):
"""Extract the MAR file to the destdir."""
with open(marfile, 'rb') as f:
with MarReader(f) as m:
m.extract(str(destdir), decompress=decompress) | python | def do_extract(marfile, destdir, decompress):
"""Extract the MAR file to the destdir."""
with open(marfile, 'rb') as f:
with MarReader(f) as m:
m.extract(str(destdir), decompress=decompress) | [
"def",
"do_extract",
"(",
"marfile",
",",
"destdir",
",",
"decompress",
")",
":",
"with",
"open",
"(",
"marfile",
",",
"'rb'",
")",
"as",
"f",
":",
"with",
"MarReader",
"(",
"f",
")",
"as",
"m",
":",
"m",
".",
"extract",
"(",
"str",
"(",
"destdir",... | Extract the MAR file to the destdir. | [
"Extract",
"the",
"MAR",
"file",
"to",
"the",
"destdir",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L76-L80 |
mozilla/build-mar | src/mardor/cli.py | get_keys | def get_keys(keyfiles, signature_type):
"""Get public keys for the given keyfiles.
Args:
keyfiles: List of filenames with public keys, or :mozilla- prefixed key
names
signature_type: one of 'sha1' or 'sha384'
Returns:
List of public keys as strings
"""
bu... | python | def get_keys(keyfiles, signature_type):
"""Get public keys for the given keyfiles.
Args:
keyfiles: List of filenames with public keys, or :mozilla- prefixed key
names
signature_type: one of 'sha1' or 'sha384'
Returns:
List of public keys as strings
"""
bu... | [
"def",
"get_keys",
"(",
"keyfiles",
",",
"signature_type",
")",
":",
"builtin_keys",
"=",
"{",
"(",
"'release'",
",",
"'sha1'",
")",
":",
"[",
"mardor",
".",
"mozilla",
".",
"release1_sha1",
",",
"mardor",
".",
"mozilla",
".",
"release2_sha1",
"]",
",",
... | Get public keys for the given keyfiles.
Args:
keyfiles: List of filenames with public keys, or :mozilla- prefixed key
names
signature_type: one of 'sha1' or 'sha384'
Returns:
List of public keys as strings | [
"Get",
"public",
"keys",
"for",
"the",
"given",
"keyfiles",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L83-L116 |
mozilla/build-mar | src/mardor/cli.py | do_verify | def do_verify(marfile, keyfiles=None):
"""Verify the MAR file."""
try:
with open(marfile, 'rb') as f:
with MarReader(f) as m:
# Check various parts of the mar file
# e.g. signature algorithms and additional block sections
errors = m.get_errors(... | python | def do_verify(marfile, keyfiles=None):
"""Verify the MAR file."""
try:
with open(marfile, 'rb') as f:
with MarReader(f) as m:
# Check various parts of the mar file
# e.g. signature algorithms and additional block sections
errors = m.get_errors(... | [
"def",
"do_verify",
"(",
"marfile",
",",
"keyfiles",
"=",
"None",
")",
":",
"try",
":",
"with",
"open",
"(",
"marfile",
",",
"'rb'",
")",
"as",
"f",
":",
"with",
"MarReader",
"(",
"f",
")",
"as",
"m",
":",
"# Check various parts of the mar file",
"# e.g.... | Verify the MAR file. | [
"Verify",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L119-L150 |
mozilla/build-mar | src/mardor/cli.py | do_list | def do_list(marfile, detailed=False):
"""
List the MAR file.
Yields lines of text to output
"""
with open(marfile, 'rb') as f:
with MarReader(f) as m:
if detailed:
if m.compression_type:
yield "Compression type: {}".format(m.compression_type)
... | python | def do_list(marfile, detailed=False):
"""
List the MAR file.
Yields lines of text to output
"""
with open(marfile, 'rb') as f:
with MarReader(f) as m:
if detailed:
if m.compression_type:
yield "Compression type: {}".format(m.compression_type)
... | [
"def",
"do_list",
"(",
"marfile",
",",
"detailed",
"=",
"False",
")",
":",
"with",
"open",
"(",
"marfile",
",",
"'rb'",
")",
"as",
"f",
":",
"with",
"MarReader",
"(",
"f",
")",
"as",
"m",
":",
"if",
"detailed",
":",
"if",
"m",
".",
"compression_typ... | List the MAR file.
Yields lines of text to output | [
"List",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L153-L184 |
mozilla/build-mar | src/mardor/cli.py | do_create | def do_create(marfile, files, compress, productversion=None, channel=None,
signing_key=None, signing_algorithm=None):
"""Create a new MAR file."""
with open(marfile, 'w+b') as f:
with MarWriter(f, productversion=productversion, channel=channel,
signing_key=signing_ke... | python | def do_create(marfile, files, compress, productversion=None, channel=None,
signing_key=None, signing_algorithm=None):
"""Create a new MAR file."""
with open(marfile, 'w+b') as f:
with MarWriter(f, productversion=productversion, channel=channel,
signing_key=signing_ke... | [
"def",
"do_create",
"(",
"marfile",
",",
"files",
",",
"compress",
",",
"productversion",
"=",
"None",
",",
"channel",
"=",
"None",
",",
"signing_key",
"=",
"None",
",",
"signing_algorithm",
"=",
"None",
")",
":",
"with",
"open",
"(",
"marfile",
",",
"'w... | Create a new MAR file. | [
"Create",
"a",
"new",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L187-L196 |
mozilla/build-mar | src/mardor/cli.py | do_hash | def do_hash(hash_algo, marfile, asn1=False):
"""Output the hash for this MAR file."""
# Add a dummy signature into a temporary file
dst = tempfile.TemporaryFile()
with open(marfile, 'rb') as f:
add_signature_block(f, dst, hash_algo)
dst.seek(0)
with MarReader(dst) as m:
hashes ... | python | def do_hash(hash_algo, marfile, asn1=False):
"""Output the hash for this MAR file."""
# Add a dummy signature into a temporary file
dst = tempfile.TemporaryFile()
with open(marfile, 'rb') as f:
add_signature_block(f, dst, hash_algo)
dst.seek(0)
with MarReader(dst) as m:
hashes ... | [
"def",
"do_hash",
"(",
"hash_algo",
",",
"marfile",
",",
"asn1",
"=",
"False",
")",
":",
"# Add a dummy signature into a temporary file",
"dst",
"=",
"tempfile",
".",
"TemporaryFile",
"(",
")",
"with",
"open",
"(",
"marfile",
",",
"'rb'",
")",
"as",
"f",
":"... | Output the hash for this MAR file. | [
"Output",
"the",
"hash",
"for",
"this",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L199-L214 |
mozilla/build-mar | src/mardor/cli.py | do_add_signature | def do_add_signature(input_file, output_file, signature_file):
"""Add a signature to the MAR file."""
signature = open(signature_file, 'rb').read()
if len(signature) == 256:
hash_algo = 'sha1'
elif len(signature) == 512:
hash_algo = 'sha384'
else:
raise ValueError()
with... | python | def do_add_signature(input_file, output_file, signature_file):
"""Add a signature to the MAR file."""
signature = open(signature_file, 'rb').read()
if len(signature) == 256:
hash_algo = 'sha1'
elif len(signature) == 512:
hash_algo = 'sha384'
else:
raise ValueError()
with... | [
"def",
"do_add_signature",
"(",
"input_file",
",",
"output_file",
",",
"signature_file",
")",
":",
"signature",
"=",
"open",
"(",
"signature_file",
",",
"'rb'",
")",
".",
"read",
"(",
")",
"if",
"len",
"(",
"signature",
")",
"==",
"256",
":",
"hash_algo",
... | Add a signature to the MAR file. | [
"Add",
"a",
"signature",
"to",
"the",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L217-L229 |
mozilla/build-mar | src/mardor/cli.py | check_args | def check_args(parser, args):
"""Validate commandline arguments."""
# Make sure only one action has been specified
if len([a for a in [args.create, args.extract, args.verify, args.list,
args.list_detailed, args.hash, args.add_signature] if a
is not None]) != 1:
pa... | python | def check_args(parser, args):
"""Validate commandline arguments."""
# Make sure only one action has been specified
if len([a for a in [args.create, args.extract, args.verify, args.list,
args.list_detailed, args.hash, args.add_signature] if a
is not None]) != 1:
pa... | [
"def",
"check_args",
"(",
"parser",
",",
"args",
")",
":",
"# Make sure only one action has been specified",
"if",
"len",
"(",
"[",
"a",
"for",
"a",
"in",
"[",
"args",
".",
"create",
",",
"args",
".",
"extract",
",",
"args",
".",
"verify",
",",
"args",
"... | Validate commandline arguments. | [
"Validate",
"commandline",
"arguments",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L232-L250 |
mozilla/build-mar | src/mardor/cli.py | get_key_from_cmdline | def get_key_from_cmdline(parser, args):
"""Return the signing key and signing algoritm from the commandline."""
if args.keyfiles:
signing_key = open(args.keyfiles[0], 'rb').read()
bits = get_keysize(signing_key)
if bits == 2048:
signing_algorithm = 'sha1'
elif bits ==... | python | def get_key_from_cmdline(parser, args):
"""Return the signing key and signing algoritm from the commandline."""
if args.keyfiles:
signing_key = open(args.keyfiles[0], 'rb').read()
bits = get_keysize(signing_key)
if bits == 2048:
signing_algorithm = 'sha1'
elif bits ==... | [
"def",
"get_key_from_cmdline",
"(",
"parser",
",",
"args",
")",
":",
"if",
"args",
".",
"keyfiles",
":",
"signing_key",
"=",
"open",
"(",
"args",
".",
"keyfiles",
"[",
"0",
"]",
",",
"'rb'",
")",
".",
"read",
"(",
")",
"bits",
"=",
"get_keysize",
"("... | Return the signing key and signing algoritm from the commandline. | [
"Return",
"the",
"signing",
"key",
"and",
"signing",
"algoritm",
"from",
"the",
"commandline",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L253-L270 |
mozilla/build-mar | src/mardor/cli.py | main | def main(argv=None):
"""Run the main CLI entry point."""
parser = build_argparser()
args = parser.parse_args(argv)
logging.basicConfig(level=args.loglevel, format="%(message)s")
check_args(parser, args)
if args.extract:
marfile = os.path.abspath(args.extract)
if args.chdir:
... | python | def main(argv=None):
"""Run the main CLI entry point."""
parser = build_argparser()
args = parser.parse_args(argv)
logging.basicConfig(level=args.loglevel, format="%(message)s")
check_args(parser, args)
if args.extract:
marfile = os.path.abspath(args.extract)
if args.chdir:
... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"build_argparser",
"(",
")",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"argv",
")",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"args",
".",
"loglevel",
",",
"format",
"=",
... | Run the main CLI entry point. | [
"Run",
"the",
"main",
"CLI",
"entry",
"point",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/cli.py#L273-L316 |
mozilla/build-mar | src/mardor/reader.py | MarReader.compression_type | def compression_type(self):
"""Return the latest compresion type used in this MAR.
Returns:
One of None, 'bz2', or 'xz'
"""
best_compression = None
for e in self.mardata.index.entries:
self.fileobj.seek(e.offset)
magic = self.fileobj.read(10)... | python | def compression_type(self):
"""Return the latest compresion type used in this MAR.
Returns:
One of None, 'bz2', or 'xz'
"""
best_compression = None
for e in self.mardata.index.entries:
self.fileobj.seek(e.offset)
magic = self.fileobj.read(10)... | [
"def",
"compression_type",
"(",
"self",
")",
":",
"best_compression",
"=",
"None",
"for",
"e",
"in",
"self",
".",
"mardata",
".",
"index",
".",
"entries",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"e",
".",
"offset",
")",
"magic",
"=",
"self",
"... | Return the latest compresion type used in this MAR.
Returns:
One of None, 'bz2', or 'xz' | [
"Return",
"the",
"latest",
"compresion",
"type",
"used",
"in",
"this",
"MAR",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L59-L76 |
mozilla/build-mar | src/mardor/reader.py | MarReader.signature_type | def signature_type(self):
"""Return the signature type used in this MAR.
Returns:
One of None, 'unknown', 'sha1', or 'sha384'
"""
if not self.mardata.signatures:
return None
for sig in self.mardata.signatures.sigs:
if sig.algorithm_id == 1:
... | python | def signature_type(self):
"""Return the signature type used in this MAR.
Returns:
One of None, 'unknown', 'sha1', or 'sha384'
"""
if not self.mardata.signatures:
return None
for sig in self.mardata.signatures.sigs:
if sig.algorithm_id == 1:
... | [
"def",
"signature_type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"mardata",
".",
"signatures",
":",
"return",
"None",
"for",
"sig",
"in",
"self",
".",
"mardata",
".",
"signatures",
".",
"sigs",
":",
"if",
"sig",
".",
"algorithm_id",
"==",
"1",... | Return the signature type used in this MAR.
Returns:
One of None, 'unknown', 'sha1', or 'sha384' | [
"Return",
"the",
"signature",
"type",
"used",
"in",
"this",
"MAR",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L79-L95 |
mozilla/build-mar | src/mardor/reader.py | MarReader.extract_entry | def extract_entry(self, e, decompress='auto'):
"""Yield blocks of data for this entry from this MAR file.
Args:
e (:obj:`mardor.format.index_entry`): An index_entry object that
refers to this file's size and offset inside the MAR file.
path (str): Where on disk t... | python | def extract_entry(self, e, decompress='auto'):
"""Yield blocks of data for this entry from this MAR file.
Args:
e (:obj:`mardor.format.index_entry`): An index_entry object that
refers to this file's size and offset inside the MAR file.
path (str): Where on disk t... | [
"def",
"extract_entry",
"(",
"self",
",",
"e",
",",
"decompress",
"=",
"'auto'",
")",
":",
"self",
".",
"fileobj",
".",
"seek",
"(",
"e",
".",
"offset",
")",
"stream",
"=",
"file_iter",
"(",
"self",
".",
"fileobj",
")",
"stream",
"=",
"takeexactly",
... | Yield blocks of data for this entry from this MAR file.
Args:
e (:obj:`mardor.format.index_entry`): An index_entry object that
refers to this file's size and offset inside the MAR file.
path (str): Where on disk to extract this file to.
decompress (str, optio... | [
"Yield",
"blocks",
"of",
"data",
"for",
"this",
"entry",
"from",
"this",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L97-L127 |
mozilla/build-mar | src/mardor/reader.py | MarReader.extract | def extract(self, destdir, decompress='auto'):
"""Extract the entire MAR file into a directory.
Args:
destdir (str): A local directory on disk into which the contents of
this MAR file will be extracted. Required parent directories
will be created as necessary... | python | def extract(self, destdir, decompress='auto'):
"""Extract the entire MAR file into a directory.
Args:
destdir (str): A local directory on disk into which the contents of
this MAR file will be extracted. Required parent directories
will be created as necessary... | [
"def",
"extract",
"(",
"self",
",",
"destdir",
",",
"decompress",
"=",
"'auto'",
")",
":",
"for",
"e",
"in",
"self",
".",
"mardata",
".",
"index",
".",
"entries",
":",
"name",
"=",
"e",
".",
"name",
"entry_path",
"=",
"safejoin",
"(",
"destdir",
",",... | Extract the entire MAR file into a directory.
Args:
destdir (str): A local directory on disk into which the contents of
this MAR file will be extracted. Required parent directories
will be created as necessary.
decompress (obj, optional): Controls whether... | [
"Extract",
"the",
"entire",
"MAR",
"file",
"into",
"a",
"directory",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L129-L147 |
mozilla/build-mar | src/mardor/reader.py | MarReader.get_errors | def get_errors(self):
"""Verify that this MAR file is well formed.
Returns:
A list of strings describing errors in the MAR file
None if this MAR file appears well formed.
"""
errors = []
errors.extend(self._get_signature_errors())
errors.extend(s... | python | def get_errors(self):
"""Verify that this MAR file is well formed.
Returns:
A list of strings describing errors in the MAR file
None if this MAR file appears well formed.
"""
errors = []
errors.extend(self._get_signature_errors())
errors.extend(s... | [
"def",
"get_errors",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"errors",
".",
"extend",
"(",
"self",
".",
"_get_signature_errors",
"(",
")",
")",
"errors",
".",
"extend",
"(",
"self",
".",
"_get_additional_errors",
"(",
")",
")",
"errors",
".",
"... | Verify that this MAR file is well formed.
Returns:
A list of strings describing errors in the MAR file
None if this MAR file appears well formed. | [
"Verify",
"that",
"this",
"MAR",
"file",
"is",
"well",
"formed",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L181-L194 |
mozilla/build-mar | src/mardor/reader.py | MarReader.verify | def verify(self, verify_key):
"""Verify that this MAR file has a valid signature.
Args:
verify_key (str): PEM formatted public key
Returns:
True if the MAR file's signature matches its contents
False otherwise; this includes cases where there is no signature... | python | def verify(self, verify_key):
"""Verify that this MAR file has a valid signature.
Args:
verify_key (str): PEM formatted public key
Returns:
True if the MAR file's signature matches its contents
False otherwise; this includes cases where there is no signature... | [
"def",
"verify",
"(",
"self",
",",
"verify_key",
")",
":",
"if",
"not",
"self",
".",
"mardata",
".",
"signatures",
"or",
"not",
"self",
".",
"mardata",
".",
"signatures",
".",
"sigs",
":",
"# This MAR file can't be verified since it has no signatures",
"return",
... | Verify that this MAR file has a valid signature.
Args:
verify_key (str): PEM formatted public key
Returns:
True if the MAR file's signature matches its contents
False otherwise; this includes cases where there is no signature. | [
"Verify",
"that",
"this",
"MAR",
"file",
"has",
"a",
"valid",
"signature",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L196-L225 |
mozilla/build-mar | src/mardor/reader.py | MarReader.productinfo | def productinfo(self):
"""Return the productversion and channel of this MAR if present."""
if not self.mardata.additional:
return None
for s in self.mardata.additional.sections:
if s.id == 1:
return str(s.productversion), str(s.channel)
return No... | python | def productinfo(self):
"""Return the productversion and channel of this MAR if present."""
if not self.mardata.additional:
return None
for s in self.mardata.additional.sections:
if s.id == 1:
return str(s.productversion), str(s.channel)
return No... | [
"def",
"productinfo",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"mardata",
".",
"additional",
":",
"return",
"None",
"for",
"s",
"in",
"self",
".",
"mardata",
".",
"additional",
".",
"sections",
":",
"if",
"s",
".",
"id",
"==",
"1",
":",
"re... | Return the productversion and channel of this MAR if present. | [
"Return",
"the",
"productversion",
"and",
"channel",
"of",
"this",
"MAR",
"if",
"present",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L228-L237 |
mozilla/build-mar | src/mardor/reader.py | MarReader.calculate_hashes | def calculate_hashes(self):
"""Return hashes of the contents of this MAR file.
The hashes depend on the algorithms defined in the MAR file's signature block.
Returns:
A list of (algorithm_id, hash) tuples
"""
hashers = []
if not self.mardata.signatures:
... | python | def calculate_hashes(self):
"""Return hashes of the contents of this MAR file.
The hashes depend on the algorithms defined in the MAR file's signature block.
Returns:
A list of (algorithm_id, hash) tuples
"""
hashers = []
if not self.mardata.signatures:
... | [
"def",
"calculate_hashes",
"(",
"self",
")",
":",
"hashers",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"mardata",
".",
"signatures",
":",
"return",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"mardata",
".",
"signatures",
".",
"sigs",
":",
"h",
"=",
"m... | Return hashes of the contents of this MAR file.
The hashes depend on the algorithms defined in the MAR file's signature block.
Returns:
A list of (algorithm_id, hash) tuples | [
"Return",
"hashes",
"of",
"the",
"contents",
"of",
"this",
"MAR",
"file",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/reader.py#L239-L259 |
mozilla/build-mar | src/mardor/format.py | _has_extras | def _has_extras(ctx):
"""Determine if a MAR file has an additional section block or not.
It does this by looking at where file data starts in the file. If this
starts immediately after the signature data, then no additional sections are present.
Args:
ctx (context): construct parsing context
... | python | def _has_extras(ctx):
"""Determine if a MAR file has an additional section block or not.
It does this by looking at where file data starts in the file. If this
starts immediately after the signature data, then no additional sections are present.
Args:
ctx (context): construct parsing context
... | [
"def",
"_has_extras",
"(",
"ctx",
")",
":",
"if",
"not",
"ctx",
".",
"index",
".",
"entries",
":",
"return",
"False",
"return",
"ctx",
".",
"data_offset",
">",
"8",
"and",
"ctx",
".",
"data_offset",
">",
"(",
"ctx",
".",
"signatures",
".",
"offset_end"... | Determine if a MAR file has an additional section block or not.
It does this by looking at where file data starts in the file. If this
starts immediately after the signature data, then no additional sections are present.
Args:
ctx (context): construct parsing context
Returns:
True if ... | [
"Determine",
"if",
"a",
"MAR",
"file",
"has",
"an",
"additional",
"section",
"block",
"or",
"not",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/format.py#L108-L125 |
mozilla/build-mar | src/mardor/signing.py | get_publickey | def get_publickey(keydata):
"""Load the public key from a PEM encoded string."""
try:
key = serialization.load_pem_public_key(
keydata,
backend=default_backend(),
)
return key
except ValueError:
key = serialization.load_pem_private_key(
key... | python | def get_publickey(keydata):
"""Load the public key from a PEM encoded string."""
try:
key = serialization.load_pem_public_key(
keydata,
backend=default_backend(),
)
return key
except ValueError:
key = serialization.load_pem_private_key(
key... | [
"def",
"get_publickey",
"(",
"keydata",
")",
":",
"try",
":",
"key",
"=",
"serialization",
".",
"load_pem_public_key",
"(",
"keydata",
",",
"backend",
"=",
"default_backend",
"(",
")",
",",
")",
"return",
"key",
"except",
"ValueError",
":",
"key",
"=",
"se... | Load the public key from a PEM encoded string. | [
"Load",
"the",
"public",
"key",
"from",
"a",
"PEM",
"encoded",
"string",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L25-L40 |
mozilla/build-mar | src/mardor/signing.py | get_privatekey | def get_privatekey(keydata):
"""Load the private key from a PEM encoded string."""
key = serialization.load_pem_private_key(
keydata,
password=None,
backend=default_backend(),
)
return key | python | def get_privatekey(keydata):
"""Load the private key from a PEM encoded string."""
key = serialization.load_pem_private_key(
keydata,
password=None,
backend=default_backend(),
)
return key | [
"def",
"get_privatekey",
"(",
"keydata",
")",
":",
"key",
"=",
"serialization",
".",
"load_pem_private_key",
"(",
"keydata",
",",
"password",
"=",
"None",
",",
"backend",
"=",
"default_backend",
"(",
")",
",",
")",
"return",
"key"
] | Load the private key from a PEM encoded string. | [
"Load",
"the",
"private",
"key",
"from",
"a",
"PEM",
"encoded",
"string",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L43-L50 |
mozilla/build-mar | src/mardor/signing.py | get_signature_data | def get_signature_data(fileobj, filesize):
"""Read data from MAR file that is required for MAR signatures.
Args:
fileboj (file-like object): file-like object to read the MAR data from
filesize (int): the total size of the file
Yields:
blocks of bytes representing the data required ... | python | def get_signature_data(fileobj, filesize):
"""Read data from MAR file that is required for MAR signatures.
Args:
fileboj (file-like object): file-like object to read the MAR data from
filesize (int): the total size of the file
Yields:
blocks of bytes representing the data required ... | [
"def",
"get_signature_data",
"(",
"fileobj",
",",
"filesize",
")",
":",
"# Read everything except the signature entries",
"# The first 8 bytes are covered, as is everything from the beginning",
"# of the additional section to the end of the file. The signature",
"# algorithm id and size fields... | Read data from MAR file that is required for MAR signatures.
Args:
fileboj (file-like object): file-like object to read the MAR data from
filesize (int): the total size of the file
Yields:
blocks of bytes representing the data required to generate or validate
signatures. | [
"Read",
"data",
"from",
"MAR",
"file",
"that",
"is",
"required",
"for",
"MAR",
"signatures",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L59-L101 |
mozilla/build-mar | src/mardor/signing.py | make_hasher | def make_hasher(algorithm_id):
"""Create a hashing object for the given signing algorithm."""
if algorithm_id == 1:
return hashes.Hash(hashes.SHA1(), default_backend())
elif algorithm_id == 2:
return hashes.Hash(hashes.SHA384(), default_backend())
else:
raise ValueError("Unsuppor... | python | def make_hasher(algorithm_id):
"""Create a hashing object for the given signing algorithm."""
if algorithm_id == 1:
return hashes.Hash(hashes.SHA1(), default_backend())
elif algorithm_id == 2:
return hashes.Hash(hashes.SHA384(), default_backend())
else:
raise ValueError("Unsuppor... | [
"def",
"make_hasher",
"(",
"algorithm_id",
")",
":",
"if",
"algorithm_id",
"==",
"1",
":",
"return",
"hashes",
".",
"Hash",
"(",
"hashes",
".",
"SHA1",
"(",
")",
",",
"default_backend",
"(",
")",
")",
"elif",
"algorithm_id",
"==",
"2",
":",
"return",
"... | Create a hashing object for the given signing algorithm. | [
"Create",
"a",
"hashing",
"object",
"for",
"the",
"given",
"signing",
"algorithm",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L104-L111 |
mozilla/build-mar | src/mardor/signing.py | sign_hash | def sign_hash(private_key, hash, hash_algo):
"""Sign the given hash with the given private key.
Args:
private_key (str): PEM enoded private key
hash (byte str): hash to sign
hash_algo (str): name of hash algorithm used
Returns:
byte string representing the signature
""... | python | def sign_hash(private_key, hash, hash_algo):
"""Sign the given hash with the given private key.
Args:
private_key (str): PEM enoded private key
hash (byte str): hash to sign
hash_algo (str): name of hash algorithm used
Returns:
byte string representing the signature
""... | [
"def",
"sign_hash",
"(",
"private_key",
",",
"hash",
",",
"hash_algo",
")",
":",
"hash_algo",
"=",
"_hash_algorithms",
"[",
"hash_algo",
"]",
"return",
"get_privatekey",
"(",
"private_key",
")",
".",
"sign",
"(",
"hash",
",",
"padding",
".",
"PKCS1v15",
"(",... | Sign the given hash with the given private key.
Args:
private_key (str): PEM enoded private key
hash (byte str): hash to sign
hash_algo (str): name of hash algorithm used
Returns:
byte string representing the signature | [
"Sign",
"the",
"given",
"hash",
"with",
"the",
"given",
"private",
"key",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L114-L131 |
mozilla/build-mar | src/mardor/signing.py | verify_signature | def verify_signature(public_key, signature, hash, hash_algo):
"""Verify the given signature is correct for the given hash and public key.
Args:
public_key (str): PEM encoded public key
signature (bytes): signature to verify
hash (bytes): hash of data
hash_algo (str): hash algori... | python | def verify_signature(public_key, signature, hash, hash_algo):
"""Verify the given signature is correct for the given hash and public key.
Args:
public_key (str): PEM encoded public key
signature (bytes): signature to verify
hash (bytes): hash of data
hash_algo (str): hash algori... | [
"def",
"verify_signature",
"(",
"public_key",
",",
"signature",
",",
"hash",
",",
"hash_algo",
")",
":",
"hash_algo",
"=",
"_hash_algorithms",
"[",
"hash_algo",
"]",
"try",
":",
"return",
"get_publickey",
"(",
"public_key",
")",
".",
"verify",
"(",
"signature"... | Verify the given signature is correct for the given hash and public key.
Args:
public_key (str): PEM encoded public key
signature (bytes): signature to verify
hash (bytes): hash of data
hash_algo (str): hash algorithm used
Returns:
True if the signature is valid, False ... | [
"Verify",
"the",
"given",
"signature",
"is",
"correct",
"for",
"the",
"given",
"hash",
"and",
"public",
"key",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L134-L156 |
mozilla/build-mar | src/mardor/signing.py | make_rsa_keypair | def make_rsa_keypair(bits):
"""Generate an RSA keypair.
Args:
bits (int): number of bits to use for the key.
Returns:
(private_key, public_key) - both as PEM encoded strings
"""
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=bits,
b... | python | def make_rsa_keypair(bits):
"""Generate an RSA keypair.
Args:
bits (int): number of bits to use for the key.
Returns:
(private_key, public_key) - both as PEM encoded strings
"""
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=bits,
b... | [
"def",
"make_rsa_keypair",
"(",
"bits",
")",
":",
"private_key",
"=",
"rsa",
".",
"generate_private_key",
"(",
"public_exponent",
"=",
"65537",
",",
"key_size",
"=",
"bits",
",",
"backend",
"=",
"default_backend",
"(",
")",
",",
")",
"private_pem",
"=",
"pri... | Generate an RSA keypair.
Args:
bits (int): number of bits to use for the key.
Returns:
(private_key, public_key) - both as PEM encoded strings | [
"Generate",
"an",
"RSA",
"keypair",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/signing.py#L159-L183 |
mozilla/build-mar | src/mardor/utils.py | mkdir | def mkdir(path):
"""Make a directory and its parents.
Args:
path (str): path to create
Returns:
None
Raises:
OSError if the directory cannot be created.
"""
try:
os.makedirs(path)
# sanity check
if not os.path.isdir(path): # pragma: no cover
... | python | def mkdir(path):
"""Make a directory and its parents.
Args:
path (str): path to create
Returns:
None
Raises:
OSError if the directory cannot be created.
"""
try:
os.makedirs(path)
# sanity check
if not os.path.isdir(path): # pragma: no cover
... | [
"def",
"mkdir",
"(",
"path",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"# sanity check",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"# pragma: no cover",
"raise",
"IOError",
"(",
"'path is not a directory'",
... | Make a directory and its parents.
Args:
path (str): path to create
Returns:
None
Raises:
OSError if the directory cannot be created. | [
"Make",
"a",
"directory",
"and",
"its",
"parents",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L18-L40 |
mozilla/build-mar | src/mardor/utils.py | takeexactly | def takeexactly(iterable, size):
"""Yield blocks from `iterable` until exactly len(size) have been returned.
Args:
iterable (iterable): Any iterable that yields sliceable objects that
have length.
size (int): How much data to consume
Yields:
blocks from... | python | def takeexactly(iterable, size):
"""Yield blocks from `iterable` until exactly len(size) have been returned.
Args:
iterable (iterable): Any iterable that yields sliceable objects that
have length.
size (int): How much data to consume
Yields:
blocks from... | [
"def",
"takeexactly",
"(",
"iterable",
",",
"size",
")",
":",
"total",
"=",
"0",
"for",
"block",
"in",
"iterable",
":",
"n",
"=",
"min",
"(",
"len",
"(",
"block",
")",
",",
"size",
"-",
"total",
")",
"block",
"=",
"block",
"[",
":",
"n",
"]",
"... | Yield blocks from `iterable` until exactly len(size) have been returned.
Args:
iterable (iterable): Any iterable that yields sliceable objects that
have length.
size (int): How much data to consume
Yields:
blocks from `iterable` such that
sum(len(bl... | [
"Yield",
"blocks",
"from",
"iterable",
"until",
"exactly",
"len",
"(",
"size",
")",
"have",
"been",
"returned",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L57-L87 |
mozilla/build-mar | src/mardor/utils.py | write_to_file | def write_to_file(src, dst):
"""Write data from `src` into `dst`.
Args:
src (iterable): iterable that yields blocks of data to write
dst (file-like object): file-like object that must support
.write(block)
Returns:
number of bytes written to `dst`
"""
n = 0
... | python | def write_to_file(src, dst):
"""Write data from `src` into `dst`.
Args:
src (iterable): iterable that yields blocks of data to write
dst (file-like object): file-like object that must support
.write(block)
Returns:
number of bytes written to `dst`
"""
n = 0
... | [
"def",
"write_to_file",
"(",
"src",
",",
"dst",
")",
":",
"n",
"=",
"0",
"for",
"block",
"in",
"src",
":",
"dst",
".",
"write",
"(",
"block",
")",
"n",
"+=",
"len",
"(",
"block",
")",
"return",
"n"
] | Write data from `src` into `dst`.
Args:
src (iterable): iterable that yields blocks of data to write
dst (file-like object): file-like object that must support
.write(block)
Returns:
number of bytes written to `dst` | [
"Write",
"data",
"from",
"src",
"into",
"dst",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L90-L106 |
mozilla/build-mar | src/mardor/utils.py | bz2_compress_stream | def bz2_compress_stream(src, level=9):
"""Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
level (int): compression level (1-9) default is 9
Yields:
blocks of compressed data
"""
compressor = bz2.BZ2Compressor(level)
for b... | python | def bz2_compress_stream(src, level=9):
"""Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
level (int): compression level (1-9) default is 9
Yields:
blocks of compressed data
"""
compressor = bz2.BZ2Compressor(level)
for b... | [
"def",
"bz2_compress_stream",
"(",
"src",
",",
"level",
"=",
"9",
")",
":",
"compressor",
"=",
"bz2",
".",
"BZ2Compressor",
"(",
"level",
")",
"for",
"block",
"in",
"src",
":",
"encoded",
"=",
"compressor",
".",
"compress",
"(",
"block",
")",
"if",
"en... | Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
level (int): compression level (1-9) default is 9
Yields:
blocks of compressed data | [
"Compress",
"data",
"from",
"src",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L109-L125 |
mozilla/build-mar | src/mardor/utils.py | bz2_decompress_stream | def bz2_decompress_stream(src):
"""Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data
"""
dec = bz2.BZ2Decompressor()
for block in src:
decoded = dec.decompress(block)
if decoded:... | python | def bz2_decompress_stream(src):
"""Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data
"""
dec = bz2.BZ2Decompressor()
for block in src:
decoded = dec.decompress(block)
if decoded:... | [
"def",
"bz2_decompress_stream",
"(",
"src",
")",
":",
"dec",
"=",
"bz2",
".",
"BZ2Decompressor",
"(",
")",
"for",
"block",
"in",
"src",
":",
"decoded",
"=",
"dec",
".",
"decompress",
"(",
"block",
")",
"if",
"decoded",
":",
"yield",
"decoded"
] | Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data | [
"Decompress",
"data",
"from",
"src",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L128-L142 |
mozilla/build-mar | src/mardor/utils.py | xz_compress_stream | def xz_compress_stream(src):
"""Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
Yields:
blocks of compressed data
"""
compressor = lzma.LZMACompressor(
check=lzma.CHECK_CRC64,
filters=[
{"id": lzma.FILTER_... | python | def xz_compress_stream(src):
"""Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
Yields:
blocks of compressed data
"""
compressor = lzma.LZMACompressor(
check=lzma.CHECK_CRC64,
filters=[
{"id": lzma.FILTER_... | [
"def",
"xz_compress_stream",
"(",
"src",
")",
":",
"compressor",
"=",
"lzma",
".",
"LZMACompressor",
"(",
"check",
"=",
"lzma",
".",
"CHECK_CRC64",
",",
"filters",
"=",
"[",
"{",
"\"id\"",
":",
"lzma",
".",
"FILTER_X86",
"}",
",",
"{",
"\"id\"",
":",
"... | Compress data from `src`.
Args:
src (iterable): iterable that yields blocks of data to compress
Yields:
blocks of compressed data | [
"Compress",
"data",
"from",
"src",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L145-L166 |
mozilla/build-mar | src/mardor/utils.py | xz_decompress_stream | def xz_decompress_stream(src):
"""Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data
"""
dec = lzma.LZMADecompressor()
for block in src:
decoded = dec.decompress(block)
if decoded... | python | def xz_decompress_stream(src):
"""Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data
"""
dec = lzma.LZMADecompressor()
for block in src:
decoded = dec.decompress(block)
if decoded... | [
"def",
"xz_decompress_stream",
"(",
"src",
")",
":",
"dec",
"=",
"lzma",
".",
"LZMADecompressor",
"(",
")",
"for",
"block",
"in",
"src",
":",
"decoded",
"=",
"dec",
".",
"decompress",
"(",
"block",
")",
"if",
"decoded",
":",
"yield",
"decoded",
"if",
"... | Decompress data from `src`.
Args:
src (iterable): iterable that yields blocks of compressed data
Yields:
blocks of uncompressed data | [
"Decompress",
"data",
"from",
"src",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L169-L186 |
mozilla/build-mar | src/mardor/utils.py | auto_decompress_stream | def auto_decompress_stream(src):
"""Decompress data from `src` if required.
If the first block of `src` appears to be compressed, then the entire
stream will be uncompressed. Otherwise the stream will be passed along
as-is.
Args:
src (iterable): iterable that yields blocks of data
Yie... | python | def auto_decompress_stream(src):
"""Decompress data from `src` if required.
If the first block of `src` appears to be compressed, then the entire
stream will be uncompressed. Otherwise the stream will be passed along
as-is.
Args:
src (iterable): iterable that yields blocks of data
Yie... | [
"def",
"auto_decompress_stream",
"(",
"src",
")",
":",
"block",
"=",
"next",
"(",
"src",
")",
"compression",
"=",
"guess_compression",
"(",
"block",
")",
"if",
"compression",
"==",
"'bz2'",
":",
"src",
"=",
"bz2_decompress_stream",
"(",
"chain",
"(",
"[",
... | Decompress data from `src` if required.
If the first block of `src` appears to be compressed, then the entire
stream will be uncompressed. Otherwise the stream will be passed along
as-is.
Args:
src (iterable): iterable that yields blocks of data
Yields:
blocks of uncompressed data | [
"Decompress",
"data",
"from",
"src",
"if",
"required",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L206-L230 |
mozilla/build-mar | src/mardor/utils.py | path_is_inside | def path_is_inside(path, dirname):
"""Return True if path is under dirname."""
path = os.path.abspath(path)
dirname = os.path.abspath(dirname)
while len(path) >= len(dirname):
if path == dirname:
return True
newpath = os.path.dirname(path)
if newpath == path:
... | python | def path_is_inside(path, dirname):
"""Return True if path is under dirname."""
path = os.path.abspath(path)
dirname = os.path.abspath(dirname)
while len(path) >= len(dirname):
if path == dirname:
return True
newpath = os.path.dirname(path)
if newpath == path:
... | [
"def",
"path_is_inside",
"(",
"path",
",",
"dirname",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"dirname",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"dirname",
")",
"while",
"len",
"(",
"path",
")",
">=",
"len",... | Return True if path is under dirname. | [
"Return",
"True",
"if",
"path",
"is",
"under",
"dirname",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L233-L244 |
mozilla/build-mar | src/mardor/utils.py | safejoin | def safejoin(base, *elements):
"""Safely joins paths together.
The result will always be a subdirectory under `base`, otherwise ValueError
is raised.
Args:
base (str): base path
elements (list of strings): path elements to join to base
Returns:
elements joined to base
... | python | def safejoin(base, *elements):
"""Safely joins paths together.
The result will always be a subdirectory under `base`, otherwise ValueError
is raised.
Args:
base (str): base path
elements (list of strings): path elements to join to base
Returns:
elements joined to base
... | [
"def",
"safejoin",
"(",
"base",
",",
"*",
"elements",
")",
":",
"# TODO: do we really want to be absolute here?",
"base",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"base",
")",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
",",
"*",
"eleme... | Safely joins paths together.
The result will always be a subdirectory under `base`, otherwise ValueError
is raised.
Args:
base (str): base path
elements (list of strings): path elements to join to base
Returns:
elements joined to base | [
"Safely",
"joins",
"paths",
"together",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L247-L267 |
mozilla/build-mar | src/mardor/utils.py | filesize | def filesize(fileobj):
"""Return the number of bytes in the fileobj.
This function seeks to the end of the file, and then back to the original position.
"""
current = fileobj.tell()
fileobj.seek(0, 2)
end = fileobj.tell()
fileobj.seek(current)
return end | python | def filesize(fileobj):
"""Return the number of bytes in the fileobj.
This function seeks to the end of the file, and then back to the original position.
"""
current = fileobj.tell()
fileobj.seek(0, 2)
end = fileobj.tell()
fileobj.seek(current)
return end | [
"def",
"filesize",
"(",
"fileobj",
")",
":",
"current",
"=",
"fileobj",
".",
"tell",
"(",
")",
"fileobj",
".",
"seek",
"(",
"0",
",",
"2",
")",
"end",
"=",
"fileobj",
".",
"tell",
"(",
")",
"fileobj",
".",
"seek",
"(",
"current",
")",
"return",
"... | Return the number of bytes in the fileobj.
This function seeks to the end of the file, and then back to the original position. | [
"Return",
"the",
"number",
"of",
"bytes",
"in",
"the",
"fileobj",
"."
] | train | https://github.com/mozilla/build-mar/blob/d8c3b3469e55654d31f430cb343fd89392196c4e/src/mardor/utils.py#L270-L280 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.