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
ggaughan/pipe2py
pipe2py/modules/pipesubstr.py
asyncPipeSubstr
def asyncPipeSubstr(context=None, _INPUT=None, conf=None, **kwargs): """A string module that asynchronously returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : twisted Deferred iterable of items or strings conf : { 'from': {'type': 'number', va...
python
def asyncPipeSubstr(context=None, _INPUT=None, conf=None, **kwargs): """A string module that asynchronously returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : twisted Deferred iterable of items or strings conf : { 'from': {'type': 'number', va...
[ "def", "asyncPipeSubstr", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "conf", "[", "'start'", "]", "=", "conf", ".", "pop", "(", "'from'", ",", "dict", ".", "get", "(", "co...
A string module that asynchronously returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : twisted Deferred iterable of items or strings conf : { 'from': {'type': 'number', value': <starting position>}, 'length': {'type': 'number', 'value': <c...
[ "A", "string", "module", "that", "asynchronously", "returns", "a", "substring", ".", "Loopable", "." ]
train
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipesubstr.py#L31-L51
ggaughan/pipe2py
pipe2py/modules/pipesubstr.py
pipe_substr
def pipe_substr(context=None, _INPUT=None, conf=None, **kwargs): """A string module that returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : iterable of items or strings conf : { 'from': {'type': 'number', value': <starting position>}, ...
python
def pipe_substr(context=None, _INPUT=None, conf=None, **kwargs): """A string module that returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : iterable of items or strings conf : { 'from': {'type': 'number', value': <starting position>}, ...
[ "def", "pipe_substr", "(", "context", "=", "None", ",", "_INPUT", "=", "None", ",", "conf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "conf", "[", "'start'", "]", "=", "conf", ".", "pop", "(", "'from'", ",", "dict", ".", "get", "(", "conf",...
A string module that returns a substring. Loopable. Parameters ---------- context : pipe2py.Context object _INPUT : iterable of items or strings conf : { 'from': {'type': 'number', value': <starting position>}, 'length': {'type': 'number', 'value': <count of characters to return>} ...
[ "A", "string", "module", "that", "returns", "a", "substring", ".", "Loopable", "." ]
train
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/modules/pipesubstr.py#L55-L75
bwesterb/py-seccure
src/__init__.py
serialize_number
def serialize_number(x, fmt=SER_BINARY, outlen=None): """ Serializes `x' to a string of length `outlen' in format `fmt' """ ret = b'' if fmt == SER_BINARY: while x: x, r = divmod(x, 256) ret = six.int2byte(int(r)) + ret if outlen is not None: assert len(re...
python
def serialize_number(x, fmt=SER_BINARY, outlen=None): """ Serializes `x' to a string of length `outlen' in format `fmt' """ ret = b'' if fmt == SER_BINARY: while x: x, r = divmod(x, 256) ret = six.int2byte(int(r)) + ret if outlen is not None: assert len(re...
[ "def", "serialize_number", "(", "x", ",", "fmt", "=", "SER_BINARY", ",", "outlen", "=", "None", ")", ":", "ret", "=", "b''", "if", "fmt", "==", "SER_BINARY", ":", "while", "x", ":", "x", ",", "r", "=", "divmod", "(", "x", ",", "256", ")", "ret", ...
Serializes `x' to a string of length `outlen' in format `fmt'
[ "Serializes", "x", "to", "a", "string", "of", "length", "outlen", "in", "format", "fmt" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L57-L75
bwesterb/py-seccure
src/__init__.py
deserialize_number
def deserialize_number(s, fmt=SER_BINARY): """ Deserializes a number from a string `s' in format `fmt' """ ret = gmpy.mpz(0) if fmt == SER_BINARY: if isinstance(s, six.text_type): raise ValueError( "Encode `s` to a bytestring yourself to" + " prevent probl...
python
def deserialize_number(s, fmt=SER_BINARY): """ Deserializes a number from a string `s' in format `fmt' """ ret = gmpy.mpz(0) if fmt == SER_BINARY: if isinstance(s, six.text_type): raise ValueError( "Encode `s` to a bytestring yourself to" + " prevent probl...
[ "def", "deserialize_number", "(", "s", ",", "fmt", "=", "SER_BINARY", ")", ":", "ret", "=", "gmpy", ".", "mpz", "(", "0", ")", "if", "fmt", "==", "SER_BINARY", ":", "if", "isinstance", "(", "s", ",", "six", ".", "text_type", ")", ":", "raise", "Val...
Deserializes a number from a string `s' in format `fmt'
[ "Deserializes", "a", "number", "from", "a", "string", "s", "in", "format", "fmt" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L78-L96
bwesterb/py-seccure
src/__init__.py
mod_issquare
def mod_issquare(a, p): """ Returns whether `a' is a square modulo p """ if not a: return True p1 = p // 2 p2 = pow(a, p1, p) return p2 == 1
python
def mod_issquare(a, p): """ Returns whether `a' is a square modulo p """ if not a: return True p1 = p // 2 p2 = pow(a, p1, p) return p2 == 1
[ "def", "mod_issquare", "(", "a", ",", "p", ")", ":", "if", "not", "a", ":", "return", "True", "p1", "=", "p", "//", "2", "p2", "=", "pow", "(", "a", ",", "p1", ",", "p", ")", "return", "p2", "==", "1" ]
Returns whether `a' is a square modulo p
[ "Returns", "whether", "a", "is", "a", "square", "modulo", "p" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L113-L119
bwesterb/py-seccure
src/__init__.py
mod_root
def mod_root(a, p): """ Return a root of `a' modulo p """ if a == 0: return 0 if not mod_issquare(a, p): raise ValueError n = 2 while mod_issquare(n, p): n += 1 q = p - 1 r = 0 while not q.getbit(r): r += 1 q = q >> r y = pow(n, q, p) h = q >> ...
python
def mod_root(a, p): """ Return a root of `a' modulo p """ if a == 0: return 0 if not mod_issquare(a, p): raise ValueError n = 2 while mod_issquare(n, p): n += 1 q = p - 1 r = 0 while not q.getbit(r): r += 1 q = q >> r y = pow(n, q, p) h = q >> ...
[ "def", "mod_root", "(", "a", ",", "p", ")", ":", "if", "a", "==", "0", ":", "return", "0", "if", "not", "mod_issquare", "(", "a", ",", "p", ")", ":", "raise", "ValueError", "n", "=", "2", "while", "mod_issquare", "(", "n", ",", "p", ")", ":", ...
Return a root of `a' modulo p
[ "Return", "a", "root", "of", "a", "modulo", "p" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L122-L154
bwesterb/py-seccure
src/__init__.py
encrypt
def encrypt(s, pk, pk_format=SER_COMPACT, mac_bytes=10, curve=None): """ Encrypts `s' for public key `pk' """ curve = (Curve.by_pk_len(len(pk)) if curve is None else Curve.by_name(curve)) p = curve.pubkey_from_string(pk, pk_format) return p.encrypt(s, mac_bytes)
python
def encrypt(s, pk, pk_format=SER_COMPACT, mac_bytes=10, curve=None): """ Encrypts `s' for public key `pk' """ curve = (Curve.by_pk_len(len(pk)) if curve is None else Curve.by_name(curve)) p = curve.pubkey_from_string(pk, pk_format) return p.encrypt(s, mac_bytes)
[ "def", "encrypt", "(", "s", ",", "pk", ",", "pk_format", "=", "SER_COMPACT", ",", "mac_bytes", "=", "10", ",", "curve", "=", "None", ")", ":", "curve", "=", "(", "Curve", ".", "by_pk_len", "(", "len", "(", "pk", ")", ")", "if", "curve", "is", "No...
Encrypts `s' for public key `pk'
[ "Encrypts", "s", "for", "public", "key", "pk" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L903-L908
bwesterb/py-seccure
src/__init__.py
decrypt
def decrypt(s, passphrase, curve='secp160r1', mac_bytes=10): """ Decrypts `s' with passphrase `passphrase' """ curve = Curve.by_name(curve) privkey = curve.passphrase_to_privkey(passphrase) return privkey.decrypt(s, mac_bytes)
python
def decrypt(s, passphrase, curve='secp160r1', mac_bytes=10): """ Decrypts `s' with passphrase `passphrase' """ curve = Curve.by_name(curve) privkey = curve.passphrase_to_privkey(passphrase) return privkey.decrypt(s, mac_bytes)
[ "def", "decrypt", "(", "s", ",", "passphrase", ",", "curve", "=", "'secp160r1'", ",", "mac_bytes", "=", "10", ")", ":", "curve", "=", "Curve", ".", "by_name", "(", "curve", ")", "privkey", "=", "curve", ".", "passphrase_to_privkey", "(", "passphrase", ")...
Decrypts `s' with passphrase `passphrase'
[ "Decrypts", "s", "with", "passphrase", "passphrase" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L911-L915
bwesterb/py-seccure
src/__init__.py
encrypt_file
def encrypt_file(in_path_or_file, out_path_or_file, pk, pk_format=SER_COMPACT, mac_bytes=10, chunk_size=4096, curve=None): """ Encrypts `in_file' to `out_file' for pubkey `pk' """ close_in, close_out = False, False in_file, out_file = in_path_or_file, out_path_or_file try: if st...
python
def encrypt_file(in_path_or_file, out_path_or_file, pk, pk_format=SER_COMPACT, mac_bytes=10, chunk_size=4096, curve=None): """ Encrypts `in_file' to `out_file' for pubkey `pk' """ close_in, close_out = False, False in_file, out_file = in_path_or_file, out_path_or_file try: if st...
[ "def", "encrypt_file", "(", "in_path_or_file", ",", "out_path_or_file", ",", "pk", ",", "pk_format", "=", "SER_COMPACT", ",", "mac_bytes", "=", "10", ",", "chunk_size", "=", "4096", ",", "curve", "=", "None", ")", ":", "close_in", ",", "close_out", "=", "F...
Encrypts `in_file' to `out_file' for pubkey `pk'
[ "Encrypts", "in_file", "to", "out_file", "for", "pubkey", "pk" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L918-L936
bwesterb/py-seccure
src/__init__.py
decrypt_file
def decrypt_file(in_path_or_file, out_path_or_file, passphrase, curve='secp160r1', mac_bytes=10, chunk_size=4096): """ Decrypts `in_file' to `out_file' with passphrase `passphrase' """ close_in, close_out = False, False in_file, out_file = in_path_or_file, out_path_or_file try: ...
python
def decrypt_file(in_path_or_file, out_path_or_file, passphrase, curve='secp160r1', mac_bytes=10, chunk_size=4096): """ Decrypts `in_file' to `out_file' with passphrase `passphrase' """ close_in, close_out = False, False in_file, out_file = in_path_or_file, out_path_or_file try: ...
[ "def", "decrypt_file", "(", "in_path_or_file", ",", "out_path_or_file", ",", "passphrase", ",", "curve", "=", "'secp160r1'", ",", "mac_bytes", "=", "10", ",", "chunk_size", "=", "4096", ")", ":", "close_in", ",", "close_out", "=", "False", ",", "False", "in_...
Decrypts `in_file' to `out_file' with passphrase `passphrase'
[ "Decrypts", "in_file", "to", "out_file", "with", "passphrase", "passphrase" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L939-L957
bwesterb/py-seccure
src/__init__.py
verify
def verify(s, sig, pk, sig_format=SER_COMPACT, pk_format=SER_COMPACT, curve=None): """ Verifies that `sig' is a signature of pubkey `pk' for the message `s'. """ if isinstance(s, six.text_type): raise ValueError("Encode `s` to a bytestring yourself to" + " pre...
python
def verify(s, sig, pk, sig_format=SER_COMPACT, pk_format=SER_COMPACT, curve=None): """ Verifies that `sig' is a signature of pubkey `pk' for the message `s'. """ if isinstance(s, six.text_type): raise ValueError("Encode `s` to a bytestring yourself to" + " pre...
[ "def", "verify", "(", "s", ",", "sig", ",", "pk", ",", "sig_format", "=", "SER_COMPACT", ",", "pk_format", "=", "SER_COMPACT", ",", "curve", "=", "None", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "text_type", ")", ":", "raise", "ValueE...
Verifies that `sig' is a signature of pubkey `pk' for the message `s'.
[ "Verifies", "that", "sig", "is", "a", "signature", "of", "pubkey", "pk", "for", "the", "message", "s", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L985-L995
bwesterb/py-seccure
src/__init__.py
sign
def sign(s, passphrase, sig_format=SER_COMPACT, curve='secp160r1'): """ Signs `s' with passphrase `passphrase' """ if isinstance(s, six.text_type): raise ValueError("Encode `s` to a bytestring yourself to" + " prevent problems with different default encodings") curve = Curve...
python
def sign(s, passphrase, sig_format=SER_COMPACT, curve='secp160r1'): """ Signs `s' with passphrase `passphrase' """ if isinstance(s, six.text_type): raise ValueError("Encode `s` to a bytestring yourself to" + " prevent problems with different default encodings") curve = Curve...
[ "def", "sign", "(", "s", ",", "passphrase", ",", "sig_format", "=", "SER_COMPACT", ",", "curve", "=", "'secp160r1'", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "text_type", ")", ":", "raise", "ValueError", "(", "\"Encode `s` to a bytestring you...
Signs `s' with passphrase `passphrase'
[ "Signs", "s", "with", "passphrase", "passphrase" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L998-L1005
bwesterb/py-seccure
src/__init__.py
generate_keypair
def generate_keypair(curve='secp160r1', randfunc=None): """ Convenience function to generate a random new keypair (passphrase, pubkey). """ if randfunc is None: randfunc = Crypto.Random.new().read curve = Curve.by_name(curve) raw_privkey = randfunc(curve.order_len_bin) privkey = seri...
python
def generate_keypair(curve='secp160r1', randfunc=None): """ Convenience function to generate a random new keypair (passphrase, pubkey). """ if randfunc is None: randfunc = Crypto.Random.new().read curve = Curve.by_name(curve) raw_privkey = randfunc(curve.order_len_bin) privkey = seri...
[ "def", "generate_keypair", "(", "curve", "=", "'secp160r1'", ",", "randfunc", "=", "None", ")", ":", "if", "randfunc", "is", "None", ":", "randfunc", "=", "Crypto", ".", "Random", ".", "new", "(", ")", ".", "read", "curve", "=", "Curve", ".", "by_name"...
Convenience function to generate a random new keypair (passphrase, pubkey).
[ "Convenience", "function", "to", "generate", "a", "random", "new", "keypair", "(", "passphrase", "pubkey", ")", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L1013-L1022
bwesterb/py-seccure
src/__init__.py
PubKey.verify
def verify(self, h, sig, sig_fmt=SER_BINARY): """ Verifies that `sig' is a signature for a message with SHA-512 hash `h'. """ s = deserialize_number(sig, sig_fmt) return self.p._ECDSA_verify(h, s)
python
def verify(self, h, sig, sig_fmt=SER_BINARY): """ Verifies that `sig' is a signature for a message with SHA-512 hash `h'. """ s = deserialize_number(sig, sig_fmt) return self.p._ECDSA_verify(h, s)
[ "def", "verify", "(", "self", ",", "h", ",", "sig", ",", "sig_fmt", "=", "SER_BINARY", ")", ":", "s", "=", "deserialize_number", "(", "sig", ",", "sig_fmt", ")", "return", "self", ".", "p", ".", "_ECDSA_verify", "(", "h", ",", "s", ")" ]
Verifies that `sig' is a signature for a message with SHA-512 hash `h'.
[ "Verifies", "that", "sig", "is", "a", "signature", "for", "a", "message", "with", "SHA", "-", "512", "hash", "h", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L597-L601
bwesterb/py-seccure
src/__init__.py
PubKey.encrypt_to
def encrypt_to(self, f, mac_bytes=10): """ Returns a file like object `ef'. Anything written to `ef' will be encrypted for this pubkey and written to `f'. """ ctx = EncryptionContext(f, self.p, mac_bytes) yield ctx ctx.finish()
python
def encrypt_to(self, f, mac_bytes=10): """ Returns a file like object `ef'. Anything written to `ef' will be encrypted for this pubkey and written to `f'. """ ctx = EncryptionContext(f, self.p, mac_bytes) yield ctx ctx.finish()
[ "def", "encrypt_to", "(", "self", ",", "f", ",", "mac_bytes", "=", "10", ")", ":", "ctx", "=", "EncryptionContext", "(", "f", ",", "self", ".", "p", ",", "mac_bytes", ")", "yield", "ctx", "ctx", ".", "finish", "(", ")" ]
Returns a file like object `ef'. Anything written to `ef' will be encrypted for this pubkey and written to `f'.
[ "Returns", "a", "file", "like", "object", "ef", ".", "Anything", "written", "to", "ef", "will", "be", "encrypted", "for", "this", "pubkey", "and", "written", "to", "f", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L604-L609
bwesterb/py-seccure
src/__init__.py
PubKey.encrypt
def encrypt(self, s, mac_bytes=10): """ Encrypt `s' for this pubkey. """ if isinstance(s, six.text_type): raise ValueError( "Encode `s` to a bytestring yourself to" + " prevent problems with different default encodings") out = BytesIO() with se...
python
def encrypt(self, s, mac_bytes=10): """ Encrypt `s' for this pubkey. """ if isinstance(s, six.text_type): raise ValueError( "Encode `s` to a bytestring yourself to" + " prevent problems with different default encodings") out = BytesIO() with se...
[ "def", "encrypt", "(", "self", ",", "s", ",", "mac_bytes", "=", "10", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "text_type", ")", ":", "raise", "ValueError", "(", "\"Encode `s` to a bytestring yourself to\"", "+", "\" prevent problems with differe...
Encrypt `s' for this pubkey.
[ "Encrypt", "s", "for", "this", "pubkey", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L611-L620
bwesterb/py-seccure
src/__init__.py
PrivKey.decrypt_from
def decrypt_from(self, f, mac_bytes=10): """ Decrypts a message from f. """ ctx = DecryptionContext(self.curve, f, self, mac_bytes) yield ctx ctx.read()
python
def decrypt_from(self, f, mac_bytes=10): """ Decrypts a message from f. """ ctx = DecryptionContext(self.curve, f, self, mac_bytes) yield ctx ctx.read()
[ "def", "decrypt_from", "(", "self", ",", "f", ",", "mac_bytes", "=", "10", ")", ":", "ctx", "=", "DecryptionContext", "(", "self", ".", "curve", ",", "f", ",", "self", ",", "mac_bytes", ")", "yield", "ctx", "ctx", ".", "read", "(", ")" ]
Decrypts a message from f.
[ "Decrypts", "a", "message", "from", "f", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L643-L647
bwesterb/py-seccure
src/__init__.py
PrivKey.sign
def sign(self, h, sig_format=SER_BINARY): """ Signs the message with SHA-512 hash `h' with this private key. """ outlen = (self.curve.sig_len_compact if sig_format == SER_COMPACT else self.curve.sig_len_bin) sig = self._ECDSA_sign(h) return serialize_number(sig, sig_for...
python
def sign(self, h, sig_format=SER_BINARY): """ Signs the message with SHA-512 hash `h' with this private key. """ outlen = (self.curve.sig_len_compact if sig_format == SER_COMPACT else self.curve.sig_len_bin) sig = self._ECDSA_sign(h) return serialize_number(sig, sig_for...
[ "def", "sign", "(", "self", ",", "h", ",", "sig_format", "=", "SER_BINARY", ")", ":", "outlen", "=", "(", "self", ".", "curve", ".", "sig_len_compact", "if", "sig_format", "==", "SER_COMPACT", "else", "self", ".", "curve", ".", "sig_len_bin", ")", "sig",...
Signs the message with SHA-512 hash `h' with this private key.
[ "Signs", "the", "message", "with", "SHA", "-", "512", "hash", "h", "with", "this", "private", "key", "." ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L656-L661
bwesterb/py-seccure
src/__init__.py
Curve.hash_to_exponent
def hash_to_exponent(self, h): """ Converts a 32 byte hash to an exponent """ ctr = Crypto.Util.Counter.new(128, initial_value=0) cipher = Crypto.Cipher.AES.new(h, Crypto.Cipher.AES.MODE_CTR, counter=ctr) buf = cipher.encrypt(b'\0' * self.order_len_...
python
def hash_to_exponent(self, h): """ Converts a 32 byte hash to an exponent """ ctr = Crypto.Util.Counter.new(128, initial_value=0) cipher = Crypto.Cipher.AES.new(h, Crypto.Cipher.AES.MODE_CTR, counter=ctr) buf = cipher.encrypt(b'\0' * self.order_len_...
[ "def", "hash_to_exponent", "(", "self", ",", "h", ")", ":", "ctr", "=", "Crypto", ".", "Util", ".", "Counter", ".", "new", "(", "128", ",", "initial_value", "=", "0", ")", "cipher", "=", "Crypto", ".", "Cipher", ".", "AES", ".", "new", "(", "h", ...
Converts a 32 byte hash to an exponent
[ "Converts", "a", "32", "byte", "hash", "to", "an", "exponent" ]
train
https://github.com/bwesterb/py-seccure/blob/944760744686dd0ad015bd90ecb13a3ce0d7c9c9/src/__init__.py#L859-L865
DomainTools/python_api
domaintools/cli.py
parse
def parse(args=None): """Defines how to parse CLI arguments for the DomainTools API""" parser = argparse.ArgumentParser(description='The DomainTools CLI API Client') parser.add_argument('-u', '--username', dest='user', default='', help='API Username') parser.add_argument('-k', '--key', dest='key', defau...
python
def parse(args=None): """Defines how to parse CLI arguments for the DomainTools API""" parser = argparse.ArgumentParser(description='The DomainTools CLI API Client') parser.add_argument('-u', '--username', dest='user', default='', help='API Username') parser.add_argument('-k', '--key', dest='key', defau...
[ "def", "parse", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'The DomainTools CLI API Client'", ")", "parser", ".", "add_argument", "(", "'-u'", ",", "'--username'", ",", "dest", "=", "'user'",...
Defines how to parse CLI arguments for the DomainTools API
[ "Defines", "how", "to", "parse", "CLI", "arguments", "for", "the", "DomainTools", "API" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/cli.py#L19-L71
DomainTools/python_api
domaintools/cli.py
run
def run(): # pragma: no cover """Defines how to start the CLI for the DomainTools API""" out_file, out_format, arguments = parse() user, key = arguments.pop('user', None), arguments.pop('key', None) if not user or not key: sys.stderr.write('Credentials are required to perform API calls.\n') ...
python
def run(): # pragma: no cover """Defines how to start the CLI for the DomainTools API""" out_file, out_format, arguments = parse() user, key = arguments.pop('user', None), arguments.pop('key', None) if not user or not key: sys.stderr.write('Credentials are required to perform API calls.\n') ...
[ "def", "run", "(", ")", ":", "# pragma: no cover", "out_file", ",", "out_format", ",", "arguments", "=", "parse", "(", ")", "user", ",", "key", "=", "arguments", ".", "pop", "(", "'user'", ",", "None", ")", ",", "arguments", ".", "pop", "(", "'key'", ...
Defines how to start the CLI for the DomainTools API
[ "Defines", "how", "to", "start", "the", "CLI", "for", "the", "DomainTools", "API" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/cli.py#L74-L86
jazzband/django-authority
authority/decorators.py
permission_required
def permission_required(perm, *lookup_variables, **kwargs): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. """ login_url = kwargs.pop('login_url', settings.LOGIN_URL) redirect_field_name = kwargs.pop('redirect_...
python
def permission_required(perm, *lookup_variables, **kwargs): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary. """ login_url = kwargs.pop('login_url', settings.LOGIN_URL) redirect_field_name = kwargs.pop('redirect_...
[ "def", "permission_required", "(", "perm", ",", "*", "lookup_variables", ",", "*", "*", "kwargs", ")", ":", "login_url", "=", "kwargs", ".", "pop", "(", "'login_url'", ",", "settings", ".", "LOGIN_URL", ")", "redirect_field_name", "=", "kwargs", ".", "pop", ...
Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary.
[ "Decorator", "for", "views", "that", "checks", "whether", "a", "user", "has", "a", "particular", "permission", "enabled", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/decorators.py#L16-L65
jazzband/django-authority
authority/decorators.py
permission_required_or_403
def permission_required_or_403(perm, *args, **kwargs): """ Decorator that wraps the permission_required decorator and returns a permission denied (403) page instead of redirecting to the login URL. """ kwargs['redirect_to_login'] = False return permission_required(perm, *args, **kwargs)
python
def permission_required_or_403(perm, *args, **kwargs): """ Decorator that wraps the permission_required decorator and returns a permission denied (403) page instead of redirecting to the login URL. """ kwargs['redirect_to_login'] = False return permission_required(perm, *args, **kwargs)
[ "def", "permission_required_or_403", "(", "perm", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'redirect_to_login'", "]", "=", "False", "return", "permission_required", "(", "perm", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Decorator that wraps the permission_required decorator and returns a permission denied (403) page instead of redirecting to the login URL.
[ "Decorator", "that", "wraps", "the", "permission_required", "decorator", "and", "returns", "a", "permission", "denied", "(", "403", ")", "page", "instead", "of", "redirecting", "to", "the", "login", "URL", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/decorators.py#L68-L74
jazzband/django-authority
authority/templatetags/permissions.py
get_permissions
def get_permissions(parser, token): """ Retrieves all permissions associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permissions obj %} {% for perm in permissions %} {{ perm }} {% endfor %} {% get_permission...
python
def get_permissions(parser, token): """ Retrieves all permissions associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permissions obj %} {% for perm in permissions %} {{ perm }} {% endfor %} {% get_permission...
[ "def", "get_permissions", "(", "parser", ",", "token", ")", ":", "return", "PermissionsForObjectNode", ".", "handle_token", "(", "parser", ",", "token", ",", "approved", "=", "True", ",", "name", "=", "'\"permissions\"'", ")" ]
Retrieves all permissions associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permissions obj %} {% for perm in permissions %} {{ perm }} {% endfor %} {% get_permissions obj as "my_permissions" %} {% get_perm...
[ "Retrieves", "all", "permissions", "associated", "with", "the", "given", "obj", "and", "user", "and", "assigns", "the", "result", "to", "a", "context", "variable", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L263-L280
jazzband/django-authority
authority/templatetags/permissions.py
get_permission_requests
def get_permission_requests(parser, token): """ Retrieves all permissions requests associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permission_requests obj %} {% for perm in permissions %} {{ perm }} {% endfor %} ...
python
def get_permission_requests(parser, token): """ Retrieves all permissions requests associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permission_requests obj %} {% for perm in permissions %} {{ perm }} {% endfor %} ...
[ "def", "get_permission_requests", "(", "parser", ",", "token", ")", ":", "return", "PermissionsForObjectNode", ".", "handle_token", "(", "parser", ",", "token", ",", "approved", "=", "False", ",", "name", "=", "'\"permission_requests\"'", ")" ]
Retrieves all permissions requests associated with the given obj and user and assigns the result to a context variable. Syntax:: {% get_permission_requests obj %} {% for perm in permissions %} {{ perm }} {% endfor %} {% get_permission_requests obj as "my_permission...
[ "Retrieves", "all", "permissions", "requests", "associated", "with", "the", "given", "obj", "and", "user", "and", "assigns", "the", "result", "to", "a", "context", "variable", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L284-L302
jazzband/django-authority
authority/templatetags/permissions.py
get_permission
def get_permission(parser, token): """ Performs a permission check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permission "poll_permission.chan...
python
def get_permission(parser, token): """ Performs a permission check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permission "poll_permission.chan...
[ "def", "get_permission", "(", "parser", ",", "token", ")", ":", "return", "PermissionForObjectNode", ".", "handle_token", "(", "parser", ",", "token", ",", "approved", "=", "True", ",", "name", "=", "'\"permission\"'", ")" ]
Performs a permission check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permission "poll_permission.change_poll" for request.user and poll ...
[ "Performs", "a", "permission", "check", "with", "the", "given", "signature", "user", "and", "objects", "and", "assigns", "the", "result", "to", "a", "context", "variable", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L349-L372
jazzband/django-authority
authority/templatetags/permissions.py
get_permission_request
def get_permission_request(parser, token): """ Performs a permission request check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission_request PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permissi...
python
def get_permission_request(parser, token): """ Performs a permission request check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission_request PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permissi...
[ "def", "get_permission_request", "(", "parser", ",", "token", ")", ":", "return", "PermissionForObjectNode", ".", "handle_token", "(", "parser", ",", "token", ",", "approved", "=", "False", ",", "name", "=", "'\"permission_request\"'", ")" ]
Performs a permission request check with the given signature, user and objects and assigns the result to a context variable. Syntax:: {% get_permission_request PERMISSION_LABEL.CHECK_NAME for USER and *OBJS [as VARNAME] %} {% get_permission_request "poll_permission.change_poll" fo...
[ "Performs", "a", "permission", "request", "check", "with", "the", "given", "signature", "user", "and", "objects", "and", "assigns", "the", "result", "to", "a", "context", "variable", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L376-L398
jazzband/django-authority
authority/templatetags/permissions.py
permission_delete_link
def permission_delete_link(context, perm): """ Renders a html link to the delete view of the given permission. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): if (user.has_perm('aut...
python
def permission_delete_link(context, perm): """ Renders a html link to the delete view of the given permission. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): if (user.has_perm('aut...
[ "def", "permission_delete_link", "(", "context", ",", "perm", ")", ":", "user", "=", "context", "[", "'request'", "]", ".", "user", "if", "user", ".", "is_authenticated", "(", ")", ":", "if", "(", "user", ".", "has_perm", "(", "'authority.delete_foreign_perm...
Renders a html link to the delete view of the given permission. Returns no content if the request-user has no permission to delete foreign permissions.
[ "Renders", "a", "html", "link", "to", "the", "delete", "view", "of", "the", "given", "permission", ".", "Returns", "no", "content", "if", "the", "request", "-", "user", "has", "no", "permission", "to", "delete", "foreign", "permissions", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L409-L420
jazzband/django-authority
authority/templatetags/permissions.py
permission_request_delete_link
def permission_request_delete_link(context, perm): """ Renders a html link to the delete view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): link_k...
python
def permission_request_delete_link(context, perm): """ Renders a html link to the delete view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): link_k...
[ "def", "permission_request_delete_link", "(", "context", ",", "perm", ")", ":", "user", "=", "context", "[", "'request'", "]", ".", "user", "if", "user", ".", "is_authenticated", "(", ")", ":", "link_kwargs", "=", "base_link", "(", "context", ",", "perm", ...
Renders a html link to the delete view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions.
[ "Renders", "a", "html", "link", "to", "the", "delete", "view", "of", "the", "given", "permission", "request", ".", "Returns", "no", "content", "if", "the", "request", "-", "user", "has", "no", "permission", "to", "delete", "foreign", "permissions", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L424-L440
jazzband/django-authority
authority/templatetags/permissions.py
permission_request_approve_link
def permission_request_approve_link(context, perm): """ Renders a html link to the approve view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): if u...
python
def permission_request_approve_link(context, perm): """ Renders a html link to the approve view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions. """ user = context['request'].user if user.is_authenticated(): if u...
[ "def", "permission_request_approve_link", "(", "context", ",", "perm", ")", ":", "user", "=", "context", "[", "'request'", "]", ".", "user", "if", "user", ".", "is_authenticated", "(", ")", ":", "if", "user", ".", "has_perm", "(", "'authority.approve_permissio...
Renders a html link to the approve view of the given permission request. Returns no content if the request-user has no permission to delete foreign permissions.
[ "Renders", "a", "html", "link", "to", "the", "approve", "view", "of", "the", "given", "permission", "request", ".", "Returns", "no", "content", "if", "the", "request", "-", "user", "has", "no", "permission", "to", "delete", "foreign", "permissions", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L444-L454
jazzband/django-authority
authority/templatetags/permissions.py
ResolverNode.resolve
def resolve(self, var, context): """Resolves a variable out of context if it's not in quotes""" if var is None: return var if var[0] in ('"', "'") and var[-1] == var[0]: return var[1:-1] else: return template.Variable(var).resolve(context)
python
def resolve(self, var, context): """Resolves a variable out of context if it's not in quotes""" if var is None: return var if var[0] in ('"', "'") and var[-1] == var[0]: return var[1:-1] else: return template.Variable(var).resolve(context)
[ "def", "resolve", "(", "self", ",", "var", ",", "context", ")", ":", "if", "var", "is", "None", ":", "return", "var", "if", "var", "[", "0", "]", "in", "(", "'\"'", ",", "\"'\"", ")", "and", "var", "[", "-", "1", "]", "==", "var", "[", "0", ...
Resolves a variable out of context if it's not in quotes
[ "Resolves", "a", "variable", "out", "of", "context", "if", "it", "s", "not", "in", "quotes" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/templatetags/permissions.py#L40-L47
jazzband/django-authority
authority/managers.py
PermissionManager.group_permissions
def group_permissions(self, group, perm, obj, approved=True): """ Get objects that have Group perm permission on """ return self.get_for_model(obj).select_related( 'user', 'group', 'creator').filter(group=group, codename=perm, ap...
python
def group_permissions(self, group, perm, obj, approved=True): """ Get objects that have Group perm permission on """ return self.get_for_model(obj).select_related( 'user', 'group', 'creator').filter(group=group, codename=perm, ap...
[ "def", "group_permissions", "(", "self", ",", "group", ",", "perm", ",", "obj", ",", "approved", "=", "True", ")", ":", "return", "self", ".", "get_for_model", "(", "obj", ")", ".", "select_related", "(", "'user'", ",", "'group'", ",", "'creator'", ")", ...
Get objects that have Group perm permission on
[ "Get", "objects", "that", "have", "Group", "perm", "permission", "on" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/managers.py#L48-L54
jazzband/django-authority
authority/managers.py
PermissionManager.delete_user_permissions
def delete_user_permissions(self, user, perm, obj, check_groups=False): """ Remove granular permission perm from user on an object instance """ user_perms = self.user_permissions(user, perm, obj, check_groups=False) if not user_perms.filter(object_id=obj.id): return ...
python
def delete_user_permissions(self, user, perm, obj, check_groups=False): """ Remove granular permission perm from user on an object instance """ user_perms = self.user_permissions(user, perm, obj, check_groups=False) if not user_perms.filter(object_id=obj.id): return ...
[ "def", "delete_user_permissions", "(", "self", ",", "user", ",", "perm", ",", "obj", ",", "check_groups", "=", "False", ")", ":", "user_perms", "=", "self", ".", "user_permissions", "(", "user", ",", "perm", ",", "obj", ",", "check_groups", "=", "False", ...
Remove granular permission perm from user on an object instance
[ "Remove", "granular", "permission", "perm", "from", "user", "on", "an", "object", "instance" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/managers.py#L63-L71
DomainTools/python_api
domaintools/results.py
ParsedWhois.flattened
def flattened(self): """Returns a flattened version of the parsed whois data""" parsed = self['parsed_whois'] flat = OrderedDict() for key in ('domain', 'created_date', 'updated_date', 'expired_date', 'statuses', 'name_servers'): value = parsed[key] flat[key] = ' ...
python
def flattened(self): """Returns a flattened version of the parsed whois data""" parsed = self['parsed_whois'] flat = OrderedDict() for key in ('domain', 'created_date', 'updated_date', 'expired_date', 'statuses', 'name_servers'): value = parsed[key] flat[key] = ' ...
[ "def", "flattened", "(", "self", ")", ":", "parsed", "=", "self", "[", "'parsed_whois'", "]", "flat", "=", "OrderedDict", "(", ")", "for", "key", "in", "(", "'domain'", ",", "'created_date'", ",", "'updated_date'", ",", "'expired_date'", ",", "'statuses'", ...
Returns a flattened version of the parsed whois data
[ "Returns", "a", "flattened", "version", "of", "the", "parsed", "whois", "data" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/results.py#L50-L68
jazzband/django-authority
authority/views.py
permission_denied
def permission_denied(request, template_name=None, extra_context=None): """ Default 403 handler. Templates: `403.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ if template_name is None: template_name = ('403.html', 'autho...
python
def permission_denied(request, template_name=None, extra_context=None): """ Default 403 handler. Templates: `403.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ if template_name is None: template_name = ('403.html', 'autho...
[ "def", "permission_denied", "(", "request", ",", "template_name", "=", "None", ",", "extra_context", "=", "None", ")", ":", "if", "template_name", "is", "None", ":", "template_name", "=", "(", "'403.html'", ",", "'authority/403.html'", ")", "context", "=", "{"...
Default 403 handler. Templates: `403.html` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/')
[ "Default", "403", "handler", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/views.py#L96-L116
jazzband/django-authority
authority/models.py
Permission.approve
def approve(self, creator): """ Approve granular permission request setting a Permission entry as approved=True for a specific action from an user on an object instance. """ self.approved = True self.creator = creator self.save()
python
def approve(self, creator): """ Approve granular permission request setting a Permission entry as approved=True for a specific action from an user on an object instance. """ self.approved = True self.creator = creator self.save()
[ "def", "approve", "(", "self", ",", "creator", ")", ":", "self", ".", "approved", "=", "True", "self", ".", "creator", "=", "creator", "self", ".", "save", "(", ")" ]
Approve granular permission request setting a Permission entry as approved=True for a specific action from an user on an object instance.
[ "Approve", "granular", "permission", "request", "setting", "a", "Permission", "entry", "as", "approved", "=", "True", "for", "a", "specific", "action", "from", "an", "user", "on", "an", "object", "instance", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/models.py#L59-L66
jazzband/django-authority
authority/utils.py
autodiscover_modules
def autodiscover_modules(): """ Goes and imports the permissions submodule of every app in INSTALLED_APPS to make sure the permission set classes are registered correctly. """ import imp from django.conf import settings for app in settings.INSTALLED_APPS: try: __import__...
python
def autodiscover_modules(): """ Goes and imports the permissions submodule of every app in INSTALLED_APPS to make sure the permission set classes are registered correctly. """ import imp from django.conf import settings for app in settings.INSTALLED_APPS: try: __import__...
[ "def", "autodiscover_modules", "(", ")", ":", "import", "imp", "from", "django", ".", "conf", "import", "settings", "for", "app", "in", "settings", ".", "INSTALLED_APPS", ":", "try", ":", "__import__", "(", "app", ")", "app_path", "=", "sys", ".", "modules...
Goes and imports the permissions submodule of every app in INSTALLED_APPS to make sure the permission set classes are registered correctly.
[ "Goes", "and", "imports", "the", "permissions", "submodule", "of", "every", "app", "in", "INSTALLED_APPS", "to", "make", "sure", "the", "permission", "set", "classes", "are", "registered", "correctly", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/utils.py#L6-L26
jazzband/django-authority
authority/permissions.py
BasePermission._get_user_cached_perms
def _get_user_cached_perms(self): """ Set up both the user and group caches. """ if not self.user: return {}, {} group_pks = set(self.user.groups.values_list( 'pk', flat=True, )) perms = Permission.objects.filter( Q(...
python
def _get_user_cached_perms(self): """ Set up both the user and group caches. """ if not self.user: return {}, {} group_pks = set(self.user.groups.values_list( 'pk', flat=True, )) perms = Permission.objects.filter( Q(...
[ "def", "_get_user_cached_perms", "(", "self", ")", ":", "if", "not", "self", ".", "user", ":", "return", "{", "}", ",", "{", "}", "group_pks", "=", "set", "(", "self", ".", "user", ".", "groups", ".", "values_list", "(", "'pk'", ",", "flat", "=", "...
Set up both the user and group caches.
[ "Set", "up", "both", "the", "user", "and", "group", "caches", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L45-L78
jazzband/django-authority
authority/permissions.py
BasePermission._get_group_cached_perms
def _get_group_cached_perms(self): """ Set group cache. """ if not self.group: return {} perms = Permission.objects.filter( group=self.group, ) group_permissions = {} for perm in perms: group_permissions[( ...
python
def _get_group_cached_perms(self): """ Set group cache. """ if not self.group: return {} perms = Permission.objects.filter( group=self.group, ) group_permissions = {} for perm in perms: group_permissions[( ...
[ "def", "_get_group_cached_perms", "(", "self", ")", ":", "if", "not", "self", ".", "group", ":", "return", "{", "}", "perms", "=", "Permission", ".", "objects", ".", "filter", "(", "group", "=", "self", ".", "group", ",", ")", "group_permissions", "=", ...
Set group cache.
[ "Set", "group", "cache", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L80-L97
jazzband/django-authority
authority/permissions.py
BasePermission._prime_user_perm_caches
def _prime_user_perm_caches(self): """ Prime both the user and group caches and put them on the ``self.user``. In addition add a cache filled flag on ``self.user``. """ perm_cache, group_perm_cache = self._get_user_cached_perms() self.user._authority_perm_cache = perm_cac...
python
def _prime_user_perm_caches(self): """ Prime both the user and group caches and put them on the ``self.user``. In addition add a cache filled flag on ``self.user``. """ perm_cache, group_perm_cache = self._get_user_cached_perms() self.user._authority_perm_cache = perm_cac...
[ "def", "_prime_user_perm_caches", "(", "self", ")", ":", "perm_cache", ",", "group_perm_cache", "=", "self", ".", "_get_user_cached_perms", "(", ")", "self", ".", "user", ".", "_authority_perm_cache", "=", "perm_cache", "self", ".", "user", ".", "_authority_group_...
Prime both the user and group caches and put them on the ``self.user``. In addition add a cache filled flag on ``self.user``.
[ "Prime", "both", "the", "user", "and", "group", "caches", "and", "put", "them", "on", "the", "self", ".", "user", ".", "In", "addition", "add", "a", "cache", "filled", "flag", "on", "self", ".", "user", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L99-L107
jazzband/django-authority
authority/permissions.py
BasePermission._prime_group_perm_caches
def _prime_group_perm_caches(self): """ Prime the group cache and put them on the ``self.group``. In addition add a cache filled flag on ``self.group``. """ perm_cache = self._get_group_cached_perms() self.group._authority_perm_cache = perm_cache self.group._autho...
python
def _prime_group_perm_caches(self): """ Prime the group cache and put them on the ``self.group``. In addition add a cache filled flag on ``self.group``. """ perm_cache = self._get_group_cached_perms() self.group._authority_perm_cache = perm_cache self.group._autho...
[ "def", "_prime_group_perm_caches", "(", "self", ")", ":", "perm_cache", "=", "self", ".", "_get_group_cached_perms", "(", ")", "self", ".", "group", ".", "_authority_perm_cache", "=", "perm_cache", "self", ".", "group", ".", "_authority_perm_cache_filled", "=", "T...
Prime the group cache and put them on the ``self.group``. In addition add a cache filled flag on ``self.group``.
[ "Prime", "the", "group", "cache", "and", "put", "them", "on", "the", "self", ".", "group", ".", "In", "addition", "add", "a", "cache", "filled", "flag", "on", "self", ".", "group", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L109-L116
jazzband/django-authority
authority/permissions.py
BasePermission._user_perm_cache
def _user_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.user: return {} cache_filled = getattr( self.user, '_authority_perm_cache_filled'...
python
def _user_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.user: return {} cache_filled = getattr( self.user, '_authority_perm_cache_filled'...
[ "def", "_user_perm_cache", "(", "self", ")", ":", "# Check to see if the cache has been primed.", "if", "not", "self", ".", "user", ":", "return", "{", "}", "cache_filled", "=", "getattr", "(", "self", ".", "user", ",", "'_authority_perm_cache_filled'", ",", "Fals...
cached_permissions will generate the cache in a lazy fashion.
[ "cached_permissions", "will", "generate", "the", "cache", "in", "a", "lazy", "fashion", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L119-L138
jazzband/django-authority
authority/permissions.py
BasePermission._group_perm_cache
def _group_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.group: return {} cache_filled = getattr( self.group, '_authority_perm_cache_fill...
python
def _group_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.group: return {} cache_filled = getattr( self.group, '_authority_perm_cache_fill...
[ "def", "_group_perm_cache", "(", "self", ")", ":", "# Check to see if the cache has been primed.", "if", "not", "self", ".", "group", ":", "return", "{", "}", "cache_filled", "=", "getattr", "(", "self", ".", "group", ",", "'_authority_perm_cache_filled'", ",", "F...
cached_permissions will generate the cache in a lazy fashion.
[ "cached_permissions", "will", "generate", "the", "cache", "in", "a", "lazy", "fashion", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L141-L160
jazzband/django-authority
authority/permissions.py
BasePermission._user_group_perm_cache
def _user_group_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.user: return {} cache_filled = getattr( self.user, '_authority_perm_cache_f...
python
def _user_group_perm_cache(self): """ cached_permissions will generate the cache in a lazy fashion. """ # Check to see if the cache has been primed. if not self.user: return {} cache_filled = getattr( self.user, '_authority_perm_cache_f...
[ "def", "_user_group_perm_cache", "(", "self", ")", ":", "# Check to see if the cache has been primed.", "if", "not", "self", ".", "user", ":", "return", "{", "}", "cache_filled", "=", "getattr", "(", "self", ".", "user", ",", "'_authority_perm_cache_filled'", ",", ...
cached_permissions will generate the cache in a lazy fashion.
[ "cached_permissions", "will", "generate", "the", "cache", "in", "a", "lazy", "fashion", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L163-L180
jazzband/django-authority
authority/permissions.py
BasePermission.invalidate_permissions_cache
def invalidate_permissions_cache(self): """ In the event that the Permission table is changed during the use of a permission the Permission cache will need to be invalidated and regenerated. By calling this method the invalidation will occur, and the next time the cached_permissi...
python
def invalidate_permissions_cache(self): """ In the event that the Permission table is changed during the use of a permission the Permission cache will need to be invalidated and regenerated. By calling this method the invalidation will occur, and the next time the cached_permissi...
[ "def", "invalidate_permissions_cache", "(", "self", ")", ":", "if", "self", ".", "user", ":", "self", ".", "user", ".", "_authority_perm_cache_filled", "=", "False", "if", "self", ".", "group", ":", "self", ".", "group", ".", "_authority_perm_cache_filled", "=...
In the event that the Permission table is changed during the use of a permission the Permission cache will need to be invalidated and regenerated. By calling this method the invalidation will occur, and the next time the cached_permissions is used the cache will be re-primed.
[ "In", "the", "event", "that", "the", "Permission", "table", "is", "changed", "during", "the", "use", "of", "a", "permission", "the", "Permission", "cache", "will", "need", "to", "be", "invalidated", "and", "regenerated", ".", "By", "calling", "this", "method...
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L182-L193
jazzband/django-authority
authority/permissions.py
BasePermission.has_group_perms
def has_group_perms(self, perm, obj, approved): """ Check if group has the permission for the given object """ if not self.group: return False if self.use_smart_cache: content_type_pk = Permission.objects.get_content_type(obj).pk def _group_h...
python
def has_group_perms(self, perm, obj, approved): """ Check if group has the permission for the given object """ if not self.group: return False if self.use_smart_cache: content_type_pk = Permission.objects.get_content_type(obj).pk def _group_h...
[ "def", "has_group_perms", "(", "self", ",", "perm", ",", "obj", ",", "approved", ")", ":", "if", "not", "self", ".", "group", ":", "return", "False", "if", "self", ".", "use_smart_cache", ":", "content_type_pk", "=", "Permission", ".", "objects", ".", "g...
Check if group has the permission for the given object
[ "Check", "if", "group", "has", "the", "permission", "for", "the", "given", "object" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L240-L269
jazzband/django-authority
authority/permissions.py
BasePermission.has_perm
def has_perm(self, perm, obj, check_groups=True, approved=True): """ Check if user has the permission for the given object """ if self.user: if self.has_user_perms(perm, obj, approved, check_groups): return True if self.group: return self.h...
python
def has_perm(self, perm, obj, check_groups=True, approved=True): """ Check if user has the permission for the given object """ if self.user: if self.has_user_perms(perm, obj, approved, check_groups): return True if self.group: return self.h...
[ "def", "has_perm", "(", "self", ",", "perm", ",", "obj", ",", "check_groups", "=", "True", ",", "approved", "=", "True", ")", ":", "if", "self", ".", "user", ":", "if", "self", ".", "has_user_perms", "(", "perm", ",", "obj", ",", "approved", ",", "...
Check if user has the permission for the given object
[ "Check", "if", "user", "has", "the", "permission", "for", "the", "given", "object" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L271-L280
jazzband/django-authority
authority/permissions.py
BasePermission.requested_perm
def requested_perm(self, perm, obj, check_groups=True): """ Check if user requested a permission for the given object """ return self.has_perm(perm, obj, check_groups, False)
python
def requested_perm(self, perm, obj, check_groups=True): """ Check if user requested a permission for the given object """ return self.has_perm(perm, obj, check_groups, False)
[ "def", "requested_perm", "(", "self", ",", "perm", ",", "obj", ",", "check_groups", "=", "True", ")", ":", "return", "self", ".", "has_perm", "(", "perm", ",", "obj", ",", "check_groups", ",", "False", ")" ]
Check if user requested a permission for the given object
[ "Check", "if", "user", "requested", "a", "permission", "for", "the", "given", "object" ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L282-L286
jazzband/django-authority
authority/permissions.py
BasePermission.assign
def assign(self, check=None, content_object=None, generic=False): """ Assign a permission to a user. To assign permission for all checks: let check=None. To assign permission for all objects: let content_object=None. If generic is True then "check" will be suffixed with _modeln...
python
def assign(self, check=None, content_object=None, generic=False): """ Assign a permission to a user. To assign permission for all checks: let check=None. To assign permission for all objects: let content_object=None. If generic is True then "check" will be suffixed with _modeln...
[ "def", "assign", "(", "self", ",", "check", "=", "None", ",", "content_object", "=", "None", ",", "generic", "=", "False", ")", ":", "result", "=", "[", "]", "if", "not", "content_object", ":", "content_objects", "=", "(", "self", ".", "model", ",", ...
Assign a permission to a user. To assign permission for all checks: let check=None. To assign permission for all objects: let content_object=None. If generic is True then "check" will be suffixed with _modelname.
[ "Assign", "a", "permission", "to", "a", "user", "." ]
train
https://github.com/jazzband/django-authority/blob/58e08483cdd91a6a69e8019dd2a2edf68531ae97/authority/permissions.py#L329-L413
DomainTools/python_api
domaintools/api.py
delimited
def delimited(items, character='|'): """Returns a character delimited version of the provided list as a Python string""" return '|'.join(items) if type(items) in (list, tuple, set) else items
python
def delimited(items, character='|'): """Returns a character delimited version of the provided list as a Python string""" return '|'.join(items) if type(items) in (list, tuple, set) else items
[ "def", "delimited", "(", "items", ",", "character", "=", "'|'", ")", ":", "return", "'|'", ".", "join", "(", "items", ")", "if", "type", "(", "items", ")", "in", "(", "list", ",", "tuple", ",", "set", ")", "else", "items" ]
Returns a character delimited version of the provided list as a Python string
[ "Returns", "a", "character", "delimited", "version", "of", "the", "provided", "list", "as", "a", "Python", "string" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L10-L12
DomainTools/python_api
domaintools/api.py
API._rate_limit
def _rate_limit(self): """Pulls in and enforces the latest rate limits for the specified user""" self.limits_set = True for product in self.account_information(): self.limits[product['id']] = {'interval': timedelta(seconds=60 / float(product['per_minute_limit']))}
python
def _rate_limit(self): """Pulls in and enforces the latest rate limits for the specified user""" self.limits_set = True for product in self.account_information(): self.limits[product['id']] = {'interval': timedelta(seconds=60 / float(product['per_minute_limit']))}
[ "def", "_rate_limit", "(", "self", ")", ":", "self", ".", "limits_set", "=", "True", "for", "product", "in", "self", ".", "account_information", "(", ")", ":", "self", ".", "limits", "[", "product", "[", "'id'", "]", "]", "=", "{", "'interval'", ":", ...
Pulls in and enforces the latest rate limits for the specified user
[ "Pulls", "in", "and", "enforces", "the", "latest", "rate", "limits", "for", "the", "specified", "user" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L50-L54
DomainTools/python_api
domaintools/api.py
API._results
def _results(self, product, path, cls=Results, **kwargs): """Returns _results for the specified API path with the specified **kwargs parameters""" if product != 'account-information' and self.rate_limit and not self.limits_set and not self.limits: self._rate_limit() uri = '/'.join((...
python
def _results(self, product, path, cls=Results, **kwargs): """Returns _results for the specified API path with the specified **kwargs parameters""" if product != 'account-information' and self.rate_limit and not self.limits_set and not self.limits: self._rate_limit() uri = '/'.join((...
[ "def", "_results", "(", "self", ",", "product", ",", "path", ",", "cls", "=", "Results", ",", "*", "*", "kwargs", ")", ":", "if", "product", "!=", "'account-information'", "and", "self", ".", "rate_limit", "and", "not", "self", ".", "limits_set", "and", ...
Returns _results for the specified API path with the specified **kwargs parameters
[ "Returns", "_results", "for", "the", "specified", "API", "path", "with", "the", "specified", "**", "kwargs", "parameters" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L56-L73
DomainTools/python_api
domaintools/api.py
API.brand_monitor
def brand_monitor(self, query, exclude=[], domain_status=None, days_back=None, **kwargs): """Pass in one or more terms as a list or separated by the pipe character ( | )""" return self._results('mark-alert', '/v1/mark-alert', query=delimited(query), exclude=delimited(exclude), ...
python
def brand_monitor(self, query, exclude=[], domain_status=None, days_back=None, **kwargs): """Pass in one or more terms as a list or separated by the pipe character ( | )""" return self._results('mark-alert', '/v1/mark-alert', query=delimited(query), exclude=delimited(exclude), ...
[ "def", "brand_monitor", "(", "self", ",", "query", ",", "exclude", "=", "[", "]", ",", "domain_status", "=", "None", ",", "days_back", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'mark-alert'", ",", "'/v1/ma...
Pass in one or more terms as a list or separated by the pipe character ( | )
[ "Pass", "in", "one", "or", "more", "terms", "as", "a", "list", "or", "separated", "by", "the", "pipe", "character", "(", "|", ")" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L79-L82
DomainTools/python_api
domaintools/api.py
API.domain_search
def domain_search(self, query, exclude_query=[], max_length=25, min_length=2, has_hyphen=True, has_number=True, active_only=False, deleted_only=False, anchor_left=False, anchor_right=False, page=1, **kwargs): """Each term in the query string must be at least three characters long. ...
python
def domain_search(self, query, exclude_query=[], max_length=25, min_length=2, has_hyphen=True, has_number=True, active_only=False, deleted_only=False, anchor_left=False, anchor_right=False, page=1, **kwargs): """Each term in the query string must be at least three characters long. ...
[ "def", "domain_search", "(", "self", ",", "query", ",", "exclude_query", "=", "[", "]", ",", "max_length", "=", "25", ",", "min_length", "=", "2", ",", "has_hyphen", "=", "True", ",", "has_number", "=", "True", ",", "active_only", "=", "False", ",", "d...
Each term in the query string must be at least three characters long. Pass in a list or use spaces to separate multiple terms.
[ "Each", "term", "in", "the", "query", "string", "must", "be", "at", "least", "three", "characters", "long", ".", "Pass", "in", "a", "list", "or", "use", "spaces", "to", "separate", "multiple", "terms", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L88-L97
DomainTools/python_api
domaintools/api.py
API.domain_suggestions
def domain_suggestions(self, query, **kwargs): """Passed in name must be at least two characters long. Use a list or spaces to separate multiple terms.""" return self._results('domain-suggestions', '/v1/domain-suggestions', query=delimited(query, ' '), items_path=('suggestion...
python
def domain_suggestions(self, query, **kwargs): """Passed in name must be at least two characters long. Use a list or spaces to separate multiple terms.""" return self._results('domain-suggestions', '/v1/domain-suggestions', query=delimited(query, ' '), items_path=('suggestion...
[ "def", "domain_suggestions", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'domain-suggestions'", ",", "'/v1/domain-suggestions'", ",", "query", "=", "delimited", "(", "query", ",", "' '", ")", ",", ...
Passed in name must be at least two characters long. Use a list or spaces to separate multiple terms.
[ "Passed", "in", "name", "must", "be", "at", "least", "two", "characters", "long", ".", "Use", "a", "list", "or", "spaces", "to", "separate", "multiple", "terms", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L99-L102
DomainTools/python_api
domaintools/api.py
API.hosting_history
def hosting_history(self, query, **kwargs): """Returns the hosting history from the given domain name""" return self._results('hosting-history', '/v1/{0}/hosting-history'.format(query), cls=GroupedIterable, **kwargs)
python
def hosting_history(self, query, **kwargs): """Returns the hosting history from the given domain name""" return self._results('hosting-history', '/v1/{0}/hosting-history'.format(query), cls=GroupedIterable, **kwargs)
[ "def", "hosting_history", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'hosting-history'", ",", "'/v1/{0}/hosting-history'", ".", "format", "(", "query", ")", ",", "cls", "=", "GroupedIterable", ",", ...
Returns the hosting history from the given domain name
[ "Returns", "the", "hosting", "history", "from", "the", "given", "domain", "name" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L104-L106
DomainTools/python_api
domaintools/api.py
API.ip_monitor
def ip_monitor(self, query, days_back=0, page=1, **kwargs): """Pass in the IP Address you wish to query ( i.e. 199.30.228.112 ).""" return self._results('ip-monitor', '/v1/ip-monitor', query=query, days_back=days_back, page=page, items_path=('alerts', ), **kwargs)
python
def ip_monitor(self, query, days_back=0, page=1, **kwargs): """Pass in the IP Address you wish to query ( i.e. 199.30.228.112 ).""" return self._results('ip-monitor', '/v1/ip-monitor', query=query, days_back=days_back, page=page, items_path=('alerts', ), **kwargs)
[ "def", "ip_monitor", "(", "self", ",", "query", ",", "days_back", "=", "0", ",", "page", "=", "1", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'ip-monitor'", ",", "'/v1/ip-monitor'", ",", "query", "=", "query", ",", "d...
Pass in the IP Address you wish to query ( i.e. 199.30.228.112 ).
[ "Pass", "in", "the", "IP", "Address", "you", "wish", "to", "query", "(", "i", ".", "e", ".", "199", ".", "30", ".", "228", ".", "112", ")", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L108-L111
DomainTools/python_api
domaintools/api.py
API.ip_registrant_monitor
def ip_registrant_monitor(self, query, days_back=0, search_type="all", server=None, country=None, org=None, page=1, include_total_count=False, **kwargs): """Query based on free text query terms""" return self._results('ip-registrant-monitor', '/v1/ip-registrant-monitor', qu...
python
def ip_registrant_monitor(self, query, days_back=0, search_type="all", server=None, country=None, org=None, page=1, include_total_count=False, **kwargs): """Query based on free text query terms""" return self._results('ip-registrant-monitor', '/v1/ip-registrant-monitor', qu...
[ "def", "ip_registrant_monitor", "(", "self", ",", "query", ",", "days_back", "=", "0", ",", "search_type", "=", "\"all\"", ",", "server", "=", "None", ",", "country", "=", "None", ",", "org", "=", "None", ",", "page", "=", "1", ",", "include_total_count"...
Query based on free text query terms
[ "Query", "based", "on", "free", "text", "query", "terms" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L113-L118
DomainTools/python_api
domaintools/api.py
API.name_server_monitor
def name_server_monitor(self, query, days_back=0, page=1, **kwargs): """Pass in the hostname of the Name Server you wish to query ( i.e. dynect.net ).""" return self._results('name-server-monitor', '/v1/name-server-monitor', query=query, days_back=days_back, page=page, items_...
python
def name_server_monitor(self, query, days_back=0, page=1, **kwargs): """Pass in the hostname of the Name Server you wish to query ( i.e. dynect.net ).""" return self._results('name-server-monitor', '/v1/name-server-monitor', query=query, days_back=days_back, page=page, items_...
[ "def", "name_server_monitor", "(", "self", ",", "query", ",", "days_back", "=", "0", ",", "page", "=", "1", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'name-server-monitor'", ",", "'/v1/name-server-monitor'", ",", "query", ...
Pass in the hostname of the Name Server you wish to query ( i.e. dynect.net ).
[ "Pass", "in", "the", "hostname", "of", "the", "Name", "Server", "you", "wish", "to", "query", "(", "i", ".", "e", ".", "dynect", ".", "net", ")", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L120-L123
DomainTools/python_api
domaintools/api.py
API.parsed_whois
def parsed_whois(self, query, **kwargs): """Pass in a domain name""" return self._results('parsed-whois', '/v1/{0}/whois/parsed'.format(query), cls=ParsedWhois, **kwargs)
python
def parsed_whois(self, query, **kwargs): """Pass in a domain name""" return self._results('parsed-whois', '/v1/{0}/whois/parsed'.format(query), cls=ParsedWhois, **kwargs)
[ "def", "parsed_whois", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'parsed-whois'", ",", "'/v1/{0}/whois/parsed'", ".", "format", "(", "query", ")", ",", "cls", "=", "ParsedWhois", ",", "*", "*",...
Pass in a domain name
[ "Pass", "in", "a", "domain", "name" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L125-L127
DomainTools/python_api
domaintools/api.py
API.registrant_monitor
def registrant_monitor(self, query, exclude=[], days_back=0, limit=None, **kwargs): """One or more terms as a Python list or separated by the pipe character ( | ).""" return self._results('registrant-alert', '/v1/registrant-alert', query=delimited(query), exclude=delimited(ex...
python
def registrant_monitor(self, query, exclude=[], days_back=0, limit=None, **kwargs): """One or more terms as a Python list or separated by the pipe character ( | ).""" return self._results('registrant-alert', '/v1/registrant-alert', query=delimited(query), exclude=delimited(ex...
[ "def", "registrant_monitor", "(", "self", ",", "query", ",", "exclude", "=", "[", "]", ",", "days_back", "=", "0", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'registrant-alert'", ",", "'/v1/re...
One or more terms as a Python list or separated by the pipe character ( | ).
[ "One", "or", "more", "terms", "as", "a", "Python", "list", "or", "separated", "by", "the", "pipe", "character", "(", "|", ")", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L129-L133
DomainTools/python_api
domaintools/api.py
API.reputation
def reputation(self, query, include_reasons=False, **kwargs): """Pass in a domain name to see its reputation score""" return self._results('reputation', '/v1/reputation', domain=query, include_reasons=include_reasons, cls=Reputation, **kwargs)
python
def reputation(self, query, include_reasons=False, **kwargs): """Pass in a domain name to see its reputation score""" return self._results('reputation', '/v1/reputation', domain=query, include_reasons=include_reasons, cls=Reputation, **kwargs)
[ "def", "reputation", "(", "self", ",", "query", ",", "include_reasons", "=", "False", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'reputation'", ",", "'/v1/reputation'", ",", "domain", "=", "query", ",", "include_reasons", "...
Pass in a domain name to see its reputation score
[ "Pass", "in", "a", "domain", "name", "to", "see", "its", "reputation", "score" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L135-L138
DomainTools/python_api
domaintools/api.py
API.reverse_ip
def reverse_ip(self, domain=None, limit=None, **kwargs): """Pass in a domain name.""" return self._results('reverse-ip', '/v1/{0}/reverse-ip'.format(domain), limit=limit, **kwargs)
python
def reverse_ip(self, domain=None, limit=None, **kwargs): """Pass in a domain name.""" return self._results('reverse-ip', '/v1/{0}/reverse-ip'.format(domain), limit=limit, **kwargs)
[ "def", "reverse_ip", "(", "self", ",", "domain", "=", "None", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'reverse-ip'", ",", "'/v1/{0}/reverse-ip'", ".", "format", "(", "domain", ")", ",", "li...
Pass in a domain name.
[ "Pass", "in", "a", "domain", "name", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L140-L142
DomainTools/python_api
domaintools/api.py
API.host_domains
def host_domains(self, ip=None, limit=None, **kwargs): """Pass in an IP address.""" return self._results('reverse-ip', '/v1/{0}/host-domains'.format(ip), limit=limit, **kwargs)
python
def host_domains(self, ip=None, limit=None, **kwargs): """Pass in an IP address.""" return self._results('reverse-ip', '/v1/{0}/host-domains'.format(ip), limit=limit, **kwargs)
[ "def", "host_domains", "(", "self", ",", "ip", "=", "None", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'reverse-ip'", ",", "'/v1/{0}/host-domains'", ".", "format", "(", "ip", ")", ",", "limit"...
Pass in an IP address.
[ "Pass", "in", "an", "IP", "address", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L144-L146
DomainTools/python_api
domaintools/api.py
API.reverse_ip_whois
def reverse_ip_whois(self, query=None, ip=None, country=None, server=None, include_total_count=False, page=1, **kwargs): """Pass in an IP address or a list of free text query terms.""" if (ip and query) or not (ip or query): raise ValueError('Query or IP Address (but...
python
def reverse_ip_whois(self, query=None, ip=None, country=None, server=None, include_total_count=False, page=1, **kwargs): """Pass in an IP address or a list of free text query terms.""" if (ip and query) or not (ip or query): raise ValueError('Query or IP Address (but...
[ "def", "reverse_ip_whois", "(", "self", ",", "query", "=", "None", ",", "ip", "=", "None", ",", "country", "=", "None", ",", "server", "=", "None", ",", "include_total_count", "=", "False", ",", "page", "=", "1", ",", "*", "*", "kwargs", ")", ":", ...
Pass in an IP address or a list of free text query terms.
[ "Pass", "in", "an", "IP", "address", "or", "a", "list", "of", "free", "text", "query", "terms", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L148-L156
DomainTools/python_api
domaintools/api.py
API.reverse_name_server
def reverse_name_server(self, query, limit=None, **kwargs): """Pass in a domain name or a name server.""" return self._results('reverse-name-server', '/v1/{0}/name-server-domains'.format(query), items_path=('primary_domains', ), limit=limit, **kwargs)
python
def reverse_name_server(self, query, limit=None, **kwargs): """Pass in a domain name or a name server.""" return self._results('reverse-name-server', '/v1/{0}/name-server-domains'.format(query), items_path=('primary_domains', ), limit=limit, **kwargs)
[ "def", "reverse_name_server", "(", "self", ",", "query", ",", "limit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'reverse-name-server'", ",", "'/v1/{0}/name-server-domains'", ".", "format", "(", "query", ")", ",...
Pass in a domain name or a name server.
[ "Pass", "in", "a", "domain", "name", "or", "a", "name", "server", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L158-L161
DomainTools/python_api
domaintools/api.py
API.reverse_whois
def reverse_whois(self, query, exclude=[], scope='current', mode=None, **kwargs): """List of one or more terms to search for in the Whois record, as a Python list or separated with the pipe character ( | ). """ return self._results('reverse-whois', '/v1/reverse-whois', terms=delimited...
python
def reverse_whois(self, query, exclude=[], scope='current', mode=None, **kwargs): """List of one or more terms to search for in the Whois record, as a Python list or separated with the pipe character ( | ). """ return self._results('reverse-whois', '/v1/reverse-whois', terms=delimited...
[ "def", "reverse_whois", "(", "self", ",", "query", ",", "exclude", "=", "[", "]", ",", "scope", "=", "'current'", ",", "mode", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'reverse-whois'", ",", "'/v1/reverse...
List of one or more terms to search for in the Whois record, as a Python list or separated with the pipe character ( | ).
[ "List", "of", "one", "or", "more", "terms", "to", "search", "for", "in", "the", "Whois", "record", "as", "a", "Python", "list", "or", "separated", "with", "the", "pipe", "character", "(", "|", ")", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L163-L168
DomainTools/python_api
domaintools/api.py
API.whois_history
def whois_history(self, query, **kwargs): """Pass in a domain name.""" return self._results('whois-history', '/v1/{0}/whois/history'.format(query), items_path=('history', ), **kwargs)
python
def whois_history(self, query, **kwargs): """Pass in a domain name.""" return self._results('whois-history', '/v1/{0}/whois/history'.format(query), items_path=('history', ), **kwargs)
[ "def", "whois_history", "(", "self", ",", "query", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'whois-history'", ",", "'/v1/{0}/whois/history'", ".", "format", "(", "query", ")", ",", "items_path", "=", "(", "'history'", ","...
Pass in a domain name.
[ "Pass", "in", "a", "domain", "name", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L174-L176
DomainTools/python_api
domaintools/api.py
API.phisheye
def phisheye(self, query, days_back=None, **kwargs): """Returns domain results for the specified term for today or the specified number of days_back. Terms must be setup for monitoring via the web interface: https://research.domaintools.com/phisheye. NOTE: Properties of a domain are only ...
python
def phisheye(self, query, days_back=None, **kwargs): """Returns domain results for the specified term for today or the specified number of days_back. Terms must be setup for monitoring via the web interface: https://research.domaintools.com/phisheye. NOTE: Properties of a domain are only ...
[ "def", "phisheye", "(", "self", ",", "query", ",", "days_back", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'phisheye'", ",", "'/v1/phisheye'", ",", "query", "=", "query", ",", "days_back", "=", "days_back", ...
Returns domain results for the specified term for today or the specified number of days_back. Terms must be setup for monitoring via the web interface: https://research.domaintools.com/phisheye. NOTE: Properties of a domain are only provided if we have been able to obtain them. M...
[ "Returns", "domain", "results", "for", "the", "specified", "term", "for", "today", "or", "the", "specified", "number", "of", "days_back", ".", "Terms", "must", "be", "setup", "for", "monitoring", "via", "the", "web", "interface", ":", "https", ":", "//", "...
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L178-L187
DomainTools/python_api
domaintools/api.py
API.phisheye_term_list
def phisheye_term_list(self, include_inactive=False, **kwargs): """Provides a list of terms that are set up for this account. This call is not charged against your API usage limit. NOTE: The terms must be configured in the PhishEye web interface: https://research.domaintools.com/phisheye....
python
def phisheye_term_list(self, include_inactive=False, **kwargs): """Provides a list of terms that are set up for this account. This call is not charged against your API usage limit. NOTE: The terms must be configured in the PhishEye web interface: https://research.domaintools.com/phisheye....
[ "def", "phisheye_term_list", "(", "self", ",", "include_inactive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'phisheye_term_list'", ",", "'/v1/phisheye/term-list'", ",", "include_inactive", "=", "include_inactive", "...
Provides a list of terms that are set up for this account. This call is not charged against your API usage limit. NOTE: The terms must be configured in the PhishEye web interface: https://research.domaintools.com/phisheye. There is no API call to set up the terms.
[ "Provides", "a", "list", "of", "terms", "that", "are", "set", "up", "for", "this", "account", ".", "This", "call", "is", "not", "charged", "against", "your", "API", "usage", "limit", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L189-L197
DomainTools/python_api
domaintools/api.py
API.iris
def iris(self, domain=None, ip=None, email=None, nameserver=None, registrar=None, registrant=None, registrant_org=None, **kwargs): """Performs a search for the provided search terms ANDed together, returning the pivot engine row data for the resulting domains. """ if ((no...
python
def iris(self, domain=None, ip=None, email=None, nameserver=None, registrar=None, registrant=None, registrant_org=None, **kwargs): """Performs a search for the provided search terms ANDed together, returning the pivot engine row data for the resulting domains. """ if ((no...
[ "def", "iris", "(", "self", ",", "domain", "=", "None", ",", "ip", "=", "None", ",", "email", "=", "None", ",", "nameserver", "=", "None", ",", "registrar", "=", "None", ",", "registrant", "=", "None", ",", "registrant_org", "=", "None", ",", "*", ...
Performs a search for the provided search terms ANDed together, returning the pivot engine row data for the resulting domains.
[ "Performs", "a", "search", "for", "the", "provided", "search", "terms", "ANDed", "together", "returning", "the", "pivot", "engine", "row", "data", "for", "the", "resulting", "domains", "." ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L199-L210
DomainTools/python_api
domaintools/api.py
API.risk
def risk(self, domain, **kwargs): """Returns back the risk score for a given domain""" return self._results('risk', '/v1/risk', items_path=('components', ), domain=domain, cls=Reputation, **kwargs)
python
def risk(self, domain, **kwargs): """Returns back the risk score for a given domain""" return self._results('risk', '/v1/risk', items_path=('components', ), domain=domain, cls=Reputation, **kwargs)
[ "def", "risk", "(", "self", ",", "domain", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'risk'", ",", "'/v1/risk'", ",", "items_path", "=", "(", "'components'", ",", ")", ",", "domain", "=", "domain", ",", "cls", "=", ...
Returns back the risk score for a given domain
[ "Returns", "back", "the", "risk", "score", "for", "a", "given", "domain" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L212-L215
DomainTools/python_api
domaintools/api.py
API.risk_evidence
def risk_evidence(self, domain, **kwargs): """Returns back the detailed risk evidence associated with a given domain""" return self._results('risk-evidence', '/v1/risk/evidence/', items_path=('components', ), domain=domain, **kwargs)
python
def risk_evidence(self, domain, **kwargs): """Returns back the detailed risk evidence associated with a given domain""" return self._results('risk-evidence', '/v1/risk/evidence/', items_path=('components', ), domain=domain, **kwargs)
[ "def", "risk_evidence", "(", "self", ",", "domain", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_results", "(", "'risk-evidence'", ",", "'/v1/risk/evidence/'", ",", "items_path", "=", "(", "'components'", ",", ")", ",", "domain", "=", "domai...
Returns back the detailed risk evidence associated with a given domain
[ "Returns", "back", "the", "detailed", "risk", "evidence", "associated", "with", "a", "given", "domain" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L217-L220
DomainTools/python_api
domaintools/api.py
API.iris_enrich
def iris_enrich(self, *domains, **kwargs): """Returns back enriched data related to the specified domains using our Iris Enrich service each domain should be passed in as an un-named argument to the method: iris_enrich('domaintools.com', 'google.com') api.iris_enrich(*DOMAI...
python
def iris_enrich(self, *domains, **kwargs): """Returns back enriched data related to the specified domains using our Iris Enrich service each domain should be passed in as an un-named argument to the method: iris_enrich('domaintools.com', 'google.com') api.iris_enrich(*DOMAI...
[ "def", "iris_enrich", "(", "self", ",", "*", "domains", ",", "*", "*", "kwargs", ")", ":", "if", "not", "domains", ":", "raise", "ValueError", "(", "'One or more domains to enrich must be provided'", ")", "domains", "=", "','", ".", "join", "(", "domains", "...
Returns back enriched data related to the specified domains using our Iris Enrich service each domain should be passed in as an un-named argument to the method: iris_enrich('domaintools.com', 'google.com') api.iris_enrich(*DOMAIN_LIST)['results_count'] Returns the number of results...
[ "Returns", "back", "enriched", "data", "related", "to", "the", "specified", "domains", "using", "our", "Iris", "Enrich", "service", "each", "domain", "should", "be", "passed", "in", "as", "an", "un", "-", "named", "argument", "to", "the", "method", ":", "i...
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L222-L247
DomainTools/python_api
domaintools/api.py
API.iris_investigate
def iris_investigate(self, domains=None, data_updated_after=None, expiration_date=None, create_date=None, active=None, **kwargs): """Returns back a list of domains based on the provided filters. The following filters are available beyond what is parameterized as kwargs: ...
python
def iris_investigate(self, domains=None, data_updated_after=None, expiration_date=None, create_date=None, active=None, **kwargs): """Returns back a list of domains based on the provided filters. The following filters are available beyond what is parameterized as kwargs: ...
[ "def", "iris_investigate", "(", "self", ",", "domains", "=", "None", ",", "data_updated_after", "=", "None", ",", "expiration_date", "=", "None", ",", "create_date", "=", "None", ",", "active", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not",...
Returns back a list of domains based on the provided filters. The following filters are available beyond what is parameterized as kwargs: - ip: Search for domains having this IP. - email: Search for domains with this email in their data. - email_domain: Search for domains wh...
[ "Returns", "back", "a", "list", "of", "domains", "based", "on", "the", "provided", "filters", ".", "The", "following", "filters", "are", "available", "beyond", "what", "is", "parameterized", "as", "kwargs", ":" ]
train
https://github.com/DomainTools/python_api/blob/17be85fd4913fbe14d7660a4f4829242f1663e60/domaintools/api.py#L249-L305
AndrewRPorter/yahoo-historical
yahoo_historical/fetch.py
Fetcher.init
def init(self): """Returns a tuple pair of cookie and crumb used in the request""" url = 'https://finance.yahoo.com/quote/%s/history' % (self.ticker) r = requests.get(url) txt = r.content cookie = r.cookies['B'] pattern = re.compile('.*"CrumbStore":\{"crumb":"(?P<crumb>[^...
python
def init(self): """Returns a tuple pair of cookie and crumb used in the request""" url = 'https://finance.yahoo.com/quote/%s/history' % (self.ticker) r = requests.get(url) txt = r.content cookie = r.cookies['B'] pattern = re.compile('.*"CrumbStore":\{"crumb":"(?P<crumb>[^...
[ "def", "init", "(", "self", ")", ":", "url", "=", "'https://finance.yahoo.com/quote/%s/history'", "%", "(", "self", ".", "ticker", ")", "r", "=", "requests", ".", "get", "(", "url", ")", "txt", "=", "r", ".", "content", "cookie", "=", "r", ".", "cookie...
Returns a tuple pair of cookie and crumb used in the request
[ "Returns", "a", "tuple", "pair", "of", "cookie", "and", "crumb", "used", "in", "the", "request" ]
train
https://github.com/AndrewRPorter/yahoo-historical/blob/7a501af77fec6aa69551edb0485b665ea9bb2727/yahoo_historical/fetch.py#L26-L39
AndrewRPorter/yahoo-historical
yahoo_historical/fetch.py
Fetcher.getData
def getData(self, events): """Returns a list of historical data from Yahoo Finance""" if self.interval not in ["1d", "1wk", "1mo"]: raise ValueError("Incorrect interval: valid intervals are 1d, 1wk, 1mo") url = self.api_url % (self.ticker, self.start, self.end, self.interval, events...
python
def getData(self, events): """Returns a list of historical data from Yahoo Finance""" if self.interval not in ["1d", "1wk", "1mo"]: raise ValueError("Incorrect interval: valid intervals are 1d, 1wk, 1mo") url = self.api_url % (self.ticker, self.start, self.end, self.interval, events...
[ "def", "getData", "(", "self", ",", "events", ")", ":", "if", "self", ".", "interval", "not", "in", "[", "\"1d\"", ",", "\"1wk\"", ",", "\"1mo\"", "]", ":", "raise", "ValueError", "(", "\"Incorrect interval: valid intervals are 1d, 1wk, 1mo\"", ")", "url", "="...
Returns a list of historical data from Yahoo Finance
[ "Returns", "a", "list", "of", "historical", "data", "from", "Yahoo", "Finance" ]
train
https://github.com/AndrewRPorter/yahoo-historical/blob/7a501af77fec6aa69551edb0485b665ea9bb2727/yahoo_historical/fetch.py#L41-L50
ralphje/imagemounter
imagemounter/disk.py
Disk._get_mount_methods
def _get_mount_methods(self, disk_type): """Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount methods. """ if self.disk_mounter == 'auto': methods = [] def add_method_if_exists(method): if (me...
python
def _get_mount_methods(self, disk_type): """Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount methods. """ if self.disk_mounter == 'auto': methods = [] def add_method_if_exists(method): if (me...
[ "def", "_get_mount_methods", "(", "self", ",", "disk_type", ")", ":", "if", "self", ".", "disk_mounter", "==", "'auto'", ":", "methods", "=", "[", "]", "def", "add_method_if_exists", "(", "method", ")", ":", "if", "(", "method", "==", "'avfs'", "and", "_...
Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount methods.
[ "Finds", "which", "mount", "methods", "are", "suitable", "for", "the", "specified", "disk", "type", ".", "Returns", "a", "list", "of", "all", "suitable", "mount", "methods", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L89-L120
ralphje/imagemounter
imagemounter/disk.py
Disk._mount_avfs
def _mount_avfs(self): """Mounts the AVFS filesystem.""" self._paths['avfs'] = tempfile.mkdtemp(prefix='image_mounter_avfs_') # start by calling the mountavfs command to initialize avfs _util.check_call_(['avfsd', self._paths['avfs'], '-o', 'allow_other'], stdout=subprocess.PIPE) ...
python
def _mount_avfs(self): """Mounts the AVFS filesystem.""" self._paths['avfs'] = tempfile.mkdtemp(prefix='image_mounter_avfs_') # start by calling the mountavfs command to initialize avfs _util.check_call_(['avfsd', self._paths['avfs'], '-o', 'allow_other'], stdout=subprocess.PIPE) ...
[ "def", "_mount_avfs", "(", "self", ")", ":", "self", ".", "_paths", "[", "'avfs'", "]", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'image_mounter_avfs_'", ")", "# start by calling the mountavfs command to initialize avfs", "_util", ".", "check_call_", "("...
Mounts the AVFS filesystem.
[ "Mounts", "the", "AVFS", "filesystem", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L122-L139
ralphje/imagemounter
imagemounter/disk.py
Disk.mount
def mount(self): """Mounts the base image on a temporary location using the mount method stored in :attr:`method`. If mounting was successful, :attr:`mountpoint` is set to the temporary mountpoint. If :attr:`read_write` is enabled, a temporary read-write cache is also created and stored in :att...
python
def mount(self): """Mounts the base image on a temporary location using the mount method stored in :attr:`method`. If mounting was successful, :attr:`mountpoint` is set to the temporary mountpoint. If :attr:`read_write` is enabled, a temporary read-write cache is also created and stored in :att...
[ "def", "mount", "(", "self", ")", ":", "if", "self", ".", "parser", ".", "casename", ":", "self", ".", "mountpoint", "=", "tempfile", ".", "mkdtemp", "(", "prefix", "=", "'image_mounter_'", ",", "suffix", "=", "'_'", "+", "self", ".", "parser", ".", ...
Mounts the base image on a temporary location using the mount method stored in :attr:`method`. If mounting was successful, :attr:`mountpoint` is set to the temporary mountpoint. If :attr:`read_write` is enabled, a temporary read-write cache is also created and stored in :attr:`rwpath`. :return...
[ "Mounts", "the", "base", "image", "on", "a", "temporary", "location", "using", "the", "mount", "method", "stored", "in", ":", "attr", ":", "method", ".", "If", "mounting", "was", "successful", ":", "attr", ":", "mountpoint", "is", "set", "to", "the", "te...
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L141-L234
ralphje/imagemounter
imagemounter/disk.py
Disk.get_raw_path
def get_raw_path(self): """Returns the raw path to the mounted disk image, i.e. the raw :file:`.dd`, :file:`.raw` or :file:`ewf1` file. :rtype: str """ if self.disk_mounter == 'dummy': return self.paths[0] else: if self.disk_mounter == 'avfs' and...
python
def get_raw_path(self): """Returns the raw path to the mounted disk image, i.e. the raw :file:`.dd`, :file:`.raw` or :file:`ewf1` file. :rtype: str """ if self.disk_mounter == 'dummy': return self.paths[0] else: if self.disk_mounter == 'avfs' and...
[ "def", "get_raw_path", "(", "self", ")", ":", "if", "self", ".", "disk_mounter", "==", "'dummy'", ":", "return", "self", ".", "paths", "[", "0", "]", "else", ":", "if", "self", ".", "disk_mounter", "==", "'avfs'", "and", "os", ".", "path", ".", "isdi...
Returns the raw path to the mounted disk image, i.e. the raw :file:`.dd`, :file:`.raw` or :file:`ewf1` file. :rtype: str
[ "Returns", "the", "raw", "path", "to", "the", "mounted", "disk", "image", "i", ".", "e", ".", "the", "raw", ":", "file", ":", ".", "dd", ":", "file", ":", ".", "raw", "or", ":", "file", ":", "ewf1", "file", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L236-L266
ralphje/imagemounter
imagemounter/disk.py
Disk.detect_volumes
def detect_volumes(self, single=None): """Generator that detects the volumes from the Disk, using one of two methods: * Single volume: the entire Disk is a single volume * Multiple volumes: the Disk is a volume system :param single: If *single* is :const:`True`, this method will call :...
python
def detect_volumes(self, single=None): """Generator that detects the volumes from the Disk, using one of two methods: * Single volume: the entire Disk is a single volume * Multiple volumes: the Disk is a volume system :param single: If *single* is :const:`True`, this method will call :...
[ "def", "detect_volumes", "(", "self", ",", "single", "=", "None", ")", ":", "# prevent adding the same volumes twice", "if", "self", ".", "volumes", ".", "has_detected", ":", "for", "v", "in", "self", ".", "volumes", ":", "yield", "v", "elif", "single", ":",...
Generator that detects the volumes from the Disk, using one of two methods: * Single volume: the entire Disk is a single volume * Multiple volumes: the Disk is a volume system :param single: If *single* is :const:`True`, this method will call :Func:`init_single_volumes`. ...
[ "Generator", "that", "detects", "the", "volumes", "from", "the", "Disk", "using", "one", "of", "two", "methods", ":" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L280-L314
ralphje/imagemounter
imagemounter/disk.py
Disk.init
def init(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True): """Calls several methods required to perform a full initialisation: :func:`mount`, and :func:`mount_volumes` and yields all detected volumes. :param bool|None single: indicates whether the disk should be mou...
python
def init(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True): """Calls several methods required to perform a full initialisation: :func:`mount`, and :func:`mount_volumes` and yields all detected volumes. :param bool|None single: indicates whether the disk should be mou...
[ "def", "init", "(", "self", ",", "single", "=", "None", ",", "only_mount", "=", "None", ",", "skip_mount", "=", "None", ",", "swallow_exceptions", "=", "True", ")", ":", "self", ".", "mount", "(", ")", "self", ".", "volumes", ".", "preload_volume_data", ...
Calls several methods required to perform a full initialisation: :func:`mount`, and :func:`mount_volumes` and yields all detected volumes. :param bool|None single: indicates whether the disk should be mounted as a single disk, not as a single disk or whether it should try both (defaults to ...
[ "Calls", "several", "methods", "required", "to", "perform", "a", "full", "initialisation", ":", ":", "func", ":", "mount", "and", ":", "func", ":", "mount_volumes", "and", "yields", "all", "detected", "volumes", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L316-L333
ralphje/imagemounter
imagemounter/disk.py
Disk.init_volumes
def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True): """Generator that detects and mounts all volumes in the disk. :param single: If *single* is :const:`True`, this method will call :Func:`init_single_volumes`. If *single* is False, only...
python
def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True): """Generator that detects and mounts all volumes in the disk. :param single: If *single* is :const:`True`, this method will call :Func:`init_single_volumes`. If *single* is False, only...
[ "def", "init_volumes", "(", "self", ",", "single", "=", "None", ",", "only_mount", "=", "None", ",", "skip_mount", "=", "None", ",", "swallow_exceptions", "=", "True", ")", ":", "for", "volume", "in", "self", ".", "detect_volumes", "(", "single", "=", "s...
Generator that detects and mounts all volumes in the disk. :param single: If *single* is :const:`True`, this method will call :Func:`init_single_volumes`. If *single* is False, only :func:`init_multiple_volumes` is called. If *single* is None, :func:`init_multiple_...
[ "Generator", "that", "detects", "and", "mounts", "all", "volumes", "in", "the", "disk", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L335-L350
ralphje/imagemounter
imagemounter/disk.py
Disk.get_volumes
def get_volumes(self): """Gets a list of all volumes in this disk, including volumes that are contained in other volumes.""" volumes = [] for v in self.volumes: volumes.extend(v.get_volumes()) return volumes
python
def get_volumes(self): """Gets a list of all volumes in this disk, including volumes that are contained in other volumes.""" volumes = [] for v in self.volumes: volumes.extend(v.get_volumes()) return volumes
[ "def", "get_volumes", "(", "self", ")", ":", "volumes", "=", "[", "]", "for", "v", "in", "self", ".", "volumes", ":", "volumes", ".", "extend", "(", "v", ".", "get_volumes", "(", ")", ")", "return", "volumes" ]
Gets a list of all volumes in this disk, including volumes that are contained in other volumes.
[ "Gets", "a", "list", "of", "all", "volumes", "in", "this", "disk", "including", "volumes", "that", "are", "contained", "in", "other", "volumes", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L352-L358
ralphje/imagemounter
imagemounter/disk.py
Disk.unmount
def unmount(self, remove_rw=False, allow_lazy=False): """Removes all ties of this disk to the filesystem, so the image can be unmounted successfully. :raises SubsystemError: when one of the underlying commands fails. Some are swallowed. :raises CleanupError: when actual cleanup fails. Some are ...
python
def unmount(self, remove_rw=False, allow_lazy=False): """Removes all ties of this disk to the filesystem, so the image can be unmounted successfully. :raises SubsystemError: when one of the underlying commands fails. Some are swallowed. :raises CleanupError: when actual cleanup fails. Some are ...
[ "def", "unmount", "(", "self", ",", "remove_rw", "=", "False", ",", "allow_lazy", "=", "False", ")", ":", "for", "m", "in", "list", "(", "sorted", "(", "self", ".", "volumes", ",", "key", "=", "lambda", "v", ":", "v", ".", "mountpoint", "or", "\"\"...
Removes all ties of this disk to the filesystem, so the image can be unmounted successfully. :raises SubsystemError: when one of the underlying commands fails. Some are swallowed. :raises CleanupError: when actual cleanup fails. Some are swallowed.
[ "Removes", "all", "ties", "of", "this", "disk", "to", "the", "filesystem", "so", "the", "image", "can", "be", "unmounted", "successfully", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/disk.py#L365-L400
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell._make_argparser
def _make_argparser(self): """Makes a new argument parser.""" self.argparser = ShellArgumentParser(prog='') subparsers = self.argparser.add_subparsers() for name in self.get_names(): if name.startswith('parser_'): parser = subparsers.add_parser(name[7:]) ...
python
def _make_argparser(self): """Makes a new argument parser.""" self.argparser = ShellArgumentParser(prog='') subparsers = self.argparser.add_subparsers() for name in self.get_names(): if name.startswith('parser_'): parser = subparsers.add_parser(name[7:]) ...
[ "def", "_make_argparser", "(", "self", ")", ":", "self", ".", "argparser", "=", "ShellArgumentParser", "(", "prog", "=", "''", ")", "subparsers", "=", "self", ".", "argparser", ".", "add_subparsers", "(", ")", "for", "name", "in", "self", ".", "get_names",...
Makes a new argument parser.
[ "Makes", "a", "new", "argument", "parser", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L35-L54
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.complete
def complete(self, text, state): """Overridden to reset the argument parser after every completion (argcomplete fails :()""" result = cmd.Cmd.complete(self, text, state) if self.argparser_completer: self._make_argparser() # argparser screws up with internal states, this i...
python
def complete(self, text, state): """Overridden to reset the argument parser after every completion (argcomplete fails :()""" result = cmd.Cmd.complete(self, text, state) if self.argparser_completer: self._make_argparser() # argparser screws up with internal states, this i...
[ "def", "complete", "(", "self", ",", "text", ",", "state", ")", ":", "result", "=", "cmd", ".", "Cmd", ".", "complete", "(", "self", ",", "text", ",", "state", ")", "if", "self", ".", "argparser_completer", ":", "self", ".", "_make_argparser", "(", "...
Overridden to reset the argument parser after every completion (argcomplete fails :()
[ "Overridden", "to", "reset", "the", "argument", "parser", "after", "every", "completion", "(", "argcomplete", "fails", ":", "()" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L60-L66
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.default
def default(self, line): """Overriding default to get access to any argparse commands we have specified.""" if any((line.startswith(x) for x in self.argparse_names())): try: args = self.argparser.parse_args(shlex.split(line)) except Exception: # intentionally ca...
python
def default(self, line): """Overriding default to get access to any argparse commands we have specified.""" if any((line.startswith(x) for x in self.argparse_names())): try: args = self.argparser.parse_args(shlex.split(line)) except Exception: # intentionally ca...
[ "def", "default", "(", "self", ",", "line", ")", ":", "if", "any", "(", "(", "line", ".", "startswith", "(", "x", ")", "for", "x", "in", "self", ".", "argparse_names", "(", ")", ")", ")", ":", "try", ":", "args", "=", "self", ".", "argparser", ...
Overriding default to get access to any argparse commands we have specified.
[ "Overriding", "default", "to", "get", "access", "to", "any", "argparse", "commands", "we", "have", "specified", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L68-L79
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.completedefault
def completedefault(self, text, line, begidx, endidx): """Accessing the argcompleter if available.""" if self.argparser_completer and any((line.startswith(x) for x in self.argparse_names())): self.argparser_completer.rl_complete(line, 0) return [x[begidx:] for x in self.argparser...
python
def completedefault(self, text, line, begidx, endidx): """Accessing the argcompleter if available.""" if self.argparser_completer and any((line.startswith(x) for x in self.argparse_names())): self.argparser_completer.rl_complete(line, 0) return [x[begidx:] for x in self.argparser...
[ "def", "completedefault", "(", "self", ",", "text", ",", "line", ",", "begidx", ",", "endidx", ")", ":", "if", "self", ".", "argparser_completer", "and", "any", "(", "(", "line", ".", "startswith", "(", "x", ")", "for", "x", "in", "self", ".", "argpa...
Accessing the argcompleter if available.
[ "Accessing", "the", "argcompleter", "if", "available", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L81-L87
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.completenames
def completenames(self, text, *ignored): """Patched to also return argparse commands""" return sorted(cmd.Cmd.completenames(self, text, *ignored) + self.argparse_names(text))
python
def completenames(self, text, *ignored): """Patched to also return argparse commands""" return sorted(cmd.Cmd.completenames(self, text, *ignored) + self.argparse_names(text))
[ "def", "completenames", "(", "self", ",", "text", ",", "*", "ignored", ")", ":", "return", "sorted", "(", "cmd", ".", "Cmd", ".", "completenames", "(", "self", ",", "text", ",", "*", "ignored", ")", "+", "self", ".", "argparse_names", "(", "text", ")...
Patched to also return argparse commands
[ "Patched", "to", "also", "return", "argparse", "commands" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L92-L94
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.do_help
def do_help(self, arg): """Patched to show help for arparse commands""" if not arg or arg not in self.argparse_names(): cmd.Cmd.do_help(self, arg) else: try: self.argparser.parse_args([arg, '--help']) except Exception: pass
python
def do_help(self, arg): """Patched to show help for arparse commands""" if not arg or arg not in self.argparse_names(): cmd.Cmd.do_help(self, arg) else: try: self.argparser.parse_args([arg, '--help']) except Exception: pass
[ "def", "do_help", "(", "self", ",", "arg", ")", ":", "if", "not", "arg", "or", "arg", "not", "in", "self", ".", "argparse_names", "(", ")", ":", "cmd", ".", "Cmd", ".", "do_help", "(", "self", ",", "arg", ")", "else", ":", "try", ":", "self", "...
Patched to show help for arparse commands
[ "Patched", "to", "show", "help", "for", "arparse", "commands" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L96-L104
ralphje/imagemounter
imagemounter/cli/shell.py
ArgumentParsedShell.print_topics
def print_topics(self, header, cmds, cmdlen, maxcol): """Patched to show all argparse commands as being documented""" if header == self.doc_header: cmds.extend(self.argparse_names()) cmd.Cmd.print_topics(self, header, sorted(cmds), cmdlen, maxcol)
python
def print_topics(self, header, cmds, cmdlen, maxcol): """Patched to show all argparse commands as being documented""" if header == self.doc_header: cmds.extend(self.argparse_names()) cmd.Cmd.print_topics(self, header, sorted(cmds), cmdlen, maxcol)
[ "def", "print_topics", "(", "self", ",", "header", ",", "cmds", ",", "cmdlen", ",", "maxcol", ")", ":", "if", "header", "==", "self", ".", "doc_header", ":", "cmds", ".", "extend", "(", "self", ".", "argparse_names", "(", ")", ")", "cmd", ".", "Cmd",...
Patched to show all argparse commands as being documented
[ "Patched", "to", "show", "all", "argparse", "commands", "as", "being", "documented" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L106-L110
ralphje/imagemounter
imagemounter/cli/shell.py
ImageMounterShell.preloop
def preloop(self): """if the parser is not already set, loads the parser.""" if not self.parser: self.stdout.write("Welcome to imagemounter {version}".format(version=__version__)) self.stdout.write("\n") self.parser = ImageParser() for p in self.args.path...
python
def preloop(self): """if the parser is not already set, loads the parser.""" if not self.parser: self.stdout.write("Welcome to imagemounter {version}".format(version=__version__)) self.stdout.write("\n") self.parser = ImageParser() for p in self.args.path...
[ "def", "preloop", "(", "self", ")", ":", "if", "not", "self", ".", "parser", ":", "self", ".", "stdout", ".", "write", "(", "\"Welcome to imagemounter {version}\"", ".", "format", "(", "version", "=", "__version__", ")", ")", "self", ".", "stdout", ".", ...
if the parser is not already set, loads the parser.
[ "if", "the", "parser", "is", "not", "already", "set", "loads", "the", "parser", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L129-L137
ralphje/imagemounter
imagemounter/cli/shell.py
ImageMounterShell.onecmd
def onecmd(self, line): """Do not crash the entire program when a single command fails.""" try: return cmd.Cmd.onecmd(self, line) except Exception as e: print("Critical error.", e)
python
def onecmd(self, line): """Do not crash the entire program when a single command fails.""" try: return cmd.Cmd.onecmd(self, line) except Exception as e: print("Critical error.", e)
[ "def", "onecmd", "(", "self", ",", "line", ")", ":", "try", ":", "return", "cmd", ".", "Cmd", ".", "onecmd", "(", "self", ",", "line", ")", "except", "Exception", "as", "e", ":", "print", "(", "\"Critical error.\"", ",", "e", ")" ]
Do not crash the entire program when a single command fails.
[ "Do", "not", "crash", "the", "entire", "program", "when", "a", "single", "command", "fails", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L139-L144
ralphje/imagemounter
imagemounter/cli/shell.py
ImageMounterShell._get_all_indexes
def _get_all_indexes(self): """Returns all indexes available in the parser""" if self.parser: return [v.index for v in self.parser.get_volumes()] + [d.index for d in self.parser.disks] else: return None
python
def _get_all_indexes(self): """Returns all indexes available in the parser""" if self.parser: return [v.index for v in self.parser.get_volumes()] + [d.index for d in self.parser.disks] else: return None
[ "def", "_get_all_indexes", "(", "self", ")", ":", "if", "self", ".", "parser", ":", "return", "[", "v", ".", "index", "for", "v", "in", "self", ".", "parser", ".", "get_volumes", "(", ")", "]", "+", "[", "d", ".", "index", "for", "d", "in", "self...
Returns all indexes available in the parser
[ "Returns", "all", "indexes", "available", "in", "the", "parser" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L150-L155
ralphje/imagemounter
imagemounter/cli/shell.py
ImageMounterShell._get_by_index
def _get_by_index(self, index): """Returns a volume,disk tuple for the specified index""" volume_or_disk = self.parser.get_by_index(index) volume, disk = (volume_or_disk, None) if not isinstance(volume_or_disk, Disk) else (None, volume_or_disk) return volume, disk
python
def _get_by_index(self, index): """Returns a volume,disk tuple for the specified index""" volume_or_disk = self.parser.get_by_index(index) volume, disk = (volume_or_disk, None) if not isinstance(volume_or_disk, Disk) else (None, volume_or_disk) return volume, disk
[ "def", "_get_by_index", "(", "self", ",", "index", ")", ":", "volume_or_disk", "=", "self", ".", "parser", ".", "get_by_index", "(", "index", ")", "volume", ",", "disk", "=", "(", "volume_or_disk", ",", "None", ")", "if", "not", "isinstance", "(", "volum...
Returns a volume,disk tuple for the specified index
[ "Returns", "a", "volume", "disk", "tuple", "for", "the", "specified", "index" ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L157-L161
ralphje/imagemounter
imagemounter/cli/shell.py
ImageMounterShell.do_quit
def do_quit(self, arg): """Quits the program.""" if self.saved: self.save() else: self.parser.clean() return True
python
def do_quit(self, arg): """Quits the program.""" if self.saved: self.save() else: self.parser.clean() return True
[ "def", "do_quit", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "saved", ":", "self", ".", "save", "(", ")", "else", ":", "self", ".", "parser", ".", "clean", "(", ")", "return", "True" ]
Quits the program.
[ "Quits", "the", "program", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/cli/shell.py#L418-L424
ralphje/imagemounter
imagemounter/unmounter.py
Unmounter.preview_unmount
def preview_unmount(self): """Returns a list of all commands that would be executed if the :func:`unmount` method would be called. Note: any system changes between calling this method and calling :func:`unmount` aren't listed by this command. """ commands = [] for mountpoint in...
python
def preview_unmount(self): """Returns a list of all commands that would be executed if the :func:`unmount` method would be called. Note: any system changes between calling this method and calling :func:`unmount` aren't listed by this command. """ commands = [] for mountpoint in...
[ "def", "preview_unmount", "(", "self", ")", ":", "commands", "=", "[", "]", "for", "mountpoint", "in", "self", ".", "find_bindmounts", "(", ")", ":", "commands", ".", "append", "(", "'umount {0}'", ".", "format", "(", "mountpoint", ")", ")", "for", "moun...
Returns a list of all commands that would be executed if the :func:`unmount` method would be called. Note: any system changes between calling this method and calling :func:`unmount` aren't listed by this command.
[ "Returns", "a", "list", "of", "all", "commands", "that", "would", "be", "executed", "if", "the", ":", "func", ":", "unmount", "method", "would", "be", "called", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L52-L76
ralphje/imagemounter
imagemounter/unmounter.py
Unmounter.unmount
def unmount(self): """Calls all unmount methods in the correct order.""" self.unmount_bindmounts() self.unmount_mounts() self.unmount_volume_groups() self.unmount_loopbacks() self.unmount_base_images() self.clean_dirs()
python
def unmount(self): """Calls all unmount methods in the correct order.""" self.unmount_bindmounts() self.unmount_mounts() self.unmount_volume_groups() self.unmount_loopbacks() self.unmount_base_images() self.clean_dirs()
[ "def", "unmount", "(", "self", ")", ":", "self", ".", "unmount_bindmounts", "(", ")", "self", ".", "unmount_mounts", "(", ")", "self", ".", "unmount_volume_groups", "(", ")", "self", ".", "unmount_loopbacks", "(", ")", "self", ".", "unmount_base_images", "("...
Calls all unmount methods in the correct order.
[ "Calls", "all", "unmount", "methods", "in", "the", "correct", "order", "." ]
train
https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L78-L86