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_documentation_string stringlengths 1 47.2k | 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... | 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... | 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>},
... | 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>}
... | 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... | Serializes `x' to a string of length `outlen' in format `fmt' | 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... | Deserializes a number from a string `s' in format `fmt' | 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 | Returns whether `a' is a square modulo p | 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 >> ... | Return a root of `a' modulo p | 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) | Encrypts `s' for public key `pk' | 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) | Decrypts `s' with passphrase `passphrase' | 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... | Encrypts `in_file' to `out_file' for pubkey `pk' | 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:
... | Decrypts `in_file' to `out_file' with passphrase `passphrase' | 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... | Verifies that `sig' is a signature of pubkey `pk' for the
message `s'. | 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... | Signs `s' with passphrase `passphrase' | 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... | Convenience function to generate a random
new keypair (passphrase, pubkey). | 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) | Verifies that `sig' is a signature for a message with
SHA-512 hash `h'. | 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() | Returns a file like object `ef'. Anything written to `ef'
will be encrypted for this pubkey and written to `f'. | 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... | Encrypt `s' for this pubkey. | 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() | Decrypts a message from f. | 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... | Signs the message with SHA-512 hash `h' with this private key. | 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_... | Converts a 32 byte hash to an exponent | 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... | Defines how to parse CLI arguments for the DomainTools API | 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')
... | Defines how to start the CLI for the DomainTools API | 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_... | Decorator for views that checks whether a user has a particular permission
enabled, redirecting to the log-in page if necessary. | 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) | Decorator that wraps the permission_required decorator and returns a
permission denied (403) page instead of redirecting to the login URL. | 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... | 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... | 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 %}
... | 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... | 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... | 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 ... | 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... | 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... | 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... | 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. | 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... | 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. | 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... | 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. | 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) | Resolves a variable out of context if it's not in quotes | 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... | Get objects that have Group perm permission on | 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
... | Remove granular permission perm from user on an object instance | 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] = ' ... | Returns a flattened version of the parsed whois data | 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... | Default 403 handler.
Templates: `403.html`
Context:
request_path
The path of the requested URL (e.g., '/app/pages/bad_page/') | 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() | Approve granular permission request setting a Permission entry as
approved=True for a specific action from an user on an object instance. | 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__... | Goes and imports the permissions submodule of every app in INSTALLED_APPS
to make sure the permission set classes are registered correctly. | 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(... | Set up both the user and group caches. | 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[(
... | Set group cache. | 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... | Prime both the user and group caches and put them on the ``self.user``.
In addition add a cache filled flag on ``self.user``. | 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... | Prime the group cache and put them on the ``self.group``.
In addition add a cache filled flag on ``self.group``. | 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'... | cached_permissions will generate the cache in a lazy fashion. | 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... | cached_permissions will generate the cache in a lazy fashion. | 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... | cached_permissions will generate the cache in a lazy fashion. | 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... | 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. | 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... | Check if group has the permission for the given object | 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... | Check if user has the permission for the given object | 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) | Check if user requested a permission for the given object | 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... | 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. | 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 | Returns a character delimited version of the provided list as a Python string | 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']))} | Pulls in and enforces the latest rate limits for the specified user | 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((... | Returns _results for the specified API path with the specified **kwargs parameters | 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),
... | Pass in one or more terms as a list or separated by the pipe character ( | ) | 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.
... | Each term in the query string must be at least three characters long.
Pass in a list or use spaces to separate multiple terms. | 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... | Passed in name must be at least two characters long. Use a list or spaces to separate multiple terms. | 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) | Returns the hosting history from the given domain name | 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) | Pass in the IP Address you wish to query ( i.e. 199.30.228.112 ). | 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... | Query based on free text query terms | 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_... | Pass in the hostname of the Name Server you wish to query ( i.e. dynect.net ). | 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) | Pass in a domain name | 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... | One or more terms as a Python list or separated by the pipe character ( | ). | 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) | Pass in a domain name to see its reputation score | 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) | Pass in a domain name. | 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) | Pass in an IP address. | 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... | Pass in an IP address or a list of free text query terms. | 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) | Pass in a domain name or a name server. | 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... | List of one or more terms to search for in the Whois record,
as a Python list or separated with the pipe character ( | ). | 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) | Pass in a domain name. | 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 ... | 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... | 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.... | 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. | 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... | Performs a search for the provided search terms ANDed together,
returning the pivot engine row data for the resulting domains. | 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) | Returns back the risk score for a given domain | 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) | Returns back the detailed risk evidence associated with a given domain | 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... | 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... | 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:
... | 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... | 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>[^... | Returns a tuple pair of cookie and crumb used in the request | 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... | Returns a list of historical data from Yahoo Finance | 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... | Finds which mount methods are suitable for the specified disk type. Returns a list of all suitable mount
methods. | 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)
... | Mounts the AVFS filesystem. | 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... | 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... | 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... | Returns the raw path to the mounted disk image, i.e. the raw :file:`.dd`, :file:`.raw` or :file:`ewf1`
file.
:rtype: str | 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 :... | 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`.
... | 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... | 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 ... | 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... | 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_... | 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 | Gets a list of all volumes in this disk, including volumes that are contained in other volumes. | 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 ... | 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. | 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:])
... | Makes a new argument parser. | 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... | Overridden to reset the argument parser after every completion (argcomplete fails :() | 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... | Overriding default to get access to any argparse commands we have specified. | 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... | Accessing the argcompleter if available. | 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)) | Patched to also return argparse commands | 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 | Patched to show help for arparse commands | 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) | Patched to show all argparse commands as being documented | 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... | if the parser is not already set, loads the parser. | 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) | Do not crash the entire program when a single command fails. | 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 | Returns all indexes available in the parser | 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 | Returns a volume,disk tuple for the specified index | 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 | Quits the program. | 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... | 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. | 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() | Calls all unmount methods in the correct order. | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L78-L86 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.