repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
Autodesk/aomi
aomi/helpers.py
mount_for_path
def mount_for_path(path, client): """Returns the mountpoint for this path""" backend_data = client.list_secret_backends()['data'] backends = [mnt for mnt in backend_data.keys()] path_bits = path.split('/') if len(path_bits) == 1: vault_path = "%s/" % path if vault_path in backends: ...
python
def mount_for_path(path, client): """Returns the mountpoint for this path""" backend_data = client.list_secret_backends()['data'] backends = [mnt for mnt in backend_data.keys()] path_bits = path.split('/') if len(path_bits) == 1: vault_path = "%s/" % path if vault_path in backends: ...
[ "def", "mount_for_path", "(", "path", ",", "client", ")", ":", "backend_data", "=", "client", ".", "list_secret_backends", "(", ")", "[", "'data'", "]", "backends", "=", "[", "mnt", "for", "mnt", "in", "backend_data", ".", "keys", "(", ")", "]", "path_bi...
Returns the mountpoint for this path
[ "Returns", "the", "mountpoint", "for", "this", "path" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L140-L155
Autodesk/aomi
aomi/helpers.py
backend_type
def backend_type(path, client): """Returns the type of backend at the given mountpoint""" backends = client.list_secret_backends()['data'] vault_path = "%s/" % path return backends[vault_path]['type']
python
def backend_type(path, client): """Returns the type of backend at the given mountpoint""" backends = client.list_secret_backends()['data'] vault_path = "%s/" % path return backends[vault_path]['type']
[ "def", "backend_type", "(", "path", ",", "client", ")", ":", "backends", "=", "client", ".", "list_secret_backends", "(", ")", "[", "'data'", "]", "vault_path", "=", "\"%s/\"", "%", "path", "return", "backends", "[", "vault_path", "]", "[", "'type'", "]" ]
Returns the type of backend at the given mountpoint
[ "Returns", "the", "type", "of", "backend", "at", "the", "given", "mountpoint" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L158-L162
Autodesk/aomi
aomi/helpers.py
load_word_file
def load_word_file(filename): """Loads a words file as a list of lines""" words_file = resource_filename(__name__, "words/%s" % filename) handle = open(words_file, 'r') words = handle.readlines() handle.close() return words
python
def load_word_file(filename): """Loads a words file as a list of lines""" words_file = resource_filename(__name__, "words/%s" % filename) handle = open(words_file, 'r') words = handle.readlines() handle.close() return words
[ "def", "load_word_file", "(", "filename", ")", ":", "words_file", "=", "resource_filename", "(", "__name__", ",", "\"words/%s\"", "%", "filename", ")", "handle", "=", "open", "(", "words_file", ",", "'r'", ")", "words", "=", "handle", ".", "readlines", "(", ...
Loads a words file as a list of lines
[ "Loads", "a", "words", "file", "as", "a", "list", "of", "lines" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L165-L171
Autodesk/aomi
aomi/helpers.py
choose_one
def choose_one(things): """Returns a random entry from a list of things""" choice = SystemRandom().randint(0, len(things) - 1) return things[choice].strip()
python
def choose_one(things): """Returns a random entry from a list of things""" choice = SystemRandom().randint(0, len(things) - 1) return things[choice].strip()
[ "def", "choose_one", "(", "things", ")", ":", "choice", "=", "SystemRandom", "(", ")", ".", "randint", "(", "0", ",", "len", "(", "things", ")", "-", "1", ")", "return", "things", "[", "choice", "]", ".", "strip", "(", ")" ]
Returns a random entry from a list of things
[ "Returns", "a", "random", "entry", "from", "a", "list", "of", "things" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L174-L177
Autodesk/aomi
aomi/helpers.py
subdir_path
def subdir_path(directory, relative): """Returns a file path relative to another path.""" item_bits = directory.split(os.sep) relative_bits = relative.split(os.sep) for i, _item in enumerate(item_bits): if i == len(relative_bits) - 1: return os.sep.join(item_bits[i:]) else: ...
python
def subdir_path(directory, relative): """Returns a file path relative to another path.""" item_bits = directory.split(os.sep) relative_bits = relative.split(os.sep) for i, _item in enumerate(item_bits): if i == len(relative_bits) - 1: return os.sep.join(item_bits[i:]) else: ...
[ "def", "subdir_path", "(", "directory", ",", "relative", ")", ":", "item_bits", "=", "directory", ".", "split", "(", "os", ".", "sep", ")", "relative_bits", "=", "relative", ".", "split", "(", "os", ".", "sep", ")", "for", "i", ",", "_item", "in", "e...
Returns a file path relative to another path.
[ "Returns", "a", "file", "path", "relative", "to", "another", "path", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L187-L198
Autodesk/aomi
aomi/helpers.py
open_maybe_binary
def open_maybe_binary(filename): """Opens something that might be binary but also might be "plain text".""" if sys.version_info >= (3, 0): data = open(filename, 'rb').read() try: return data.decode('utf-8') except UnicodeDecodeError: return data return op...
python
def open_maybe_binary(filename): """Opens something that might be binary but also might be "plain text".""" if sys.version_info >= (3, 0): data = open(filename, 'rb').read() try: return data.decode('utf-8') except UnicodeDecodeError: return data return op...
[ "def", "open_maybe_binary", "(", "filename", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "data", "=", "open", "(", "filename", ",", "'rb'", ")", ".", "read", "(", ")", "try", ":", "return", "data", ".", "decode",...
Opens something that might be binary but also might be "plain text".
[ "Opens", "something", "that", "might", "be", "binary", "but", "also", "might", "be", "plain", "text", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L201-L211
Autodesk/aomi
aomi/helpers.py
ensure_dir
def ensure_dir(path): """Ensures a directory exists""" if not (os.path.exists(path) and os.path.isdir(path)): os.mkdir(path)
python
def ensure_dir(path): """Ensures a directory exists""" if not (os.path.exists(path) and os.path.isdir(path)): os.mkdir(path)
[ "def", "ensure_dir", "(", "path", ")", ":", "if", "not", "(", "os", ".", "path", ".", "exists", "(", "path", ")", "and", "os", ".", "path", ".", "isdir", "(", "path", ")", ")", ":", "os", ".", "mkdir", "(", "path", ")" ]
Ensures a directory exists
[ "Ensures", "a", "directory", "exists" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L214-L218
Autodesk/aomi
aomi/helpers.py
clean_tmpdir
def clean_tmpdir(path): """Invoked atexit, this removes our tmpdir""" if os.path.exists(path) and \ os.path.isdir(path): rmtree(path)
python
def clean_tmpdir(path): """Invoked atexit, this removes our tmpdir""" if os.path.exists(path) and \ os.path.isdir(path): rmtree(path)
[ "def", "clean_tmpdir", "(", "path", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", "and", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "rmtree", "(", "path", ")" ]
Invoked atexit, this removes our tmpdir
[ "Invoked", "atexit", "this", "removes", "our", "tmpdir" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L221-L225
Autodesk/aomi
aomi/helpers.py
dict_unicodeize
def dict_unicodeize(some_dict): """Ensure that every string in a dict is properly represented by unicode strings""" # some python 2/3 compat if isinstance(some_dict, ("".__class__, u"".__class__)): if sys.version_info >= (3, 0): return some_dict return some_dict.decode('utf...
python
def dict_unicodeize(some_dict): """Ensure that every string in a dict is properly represented by unicode strings""" # some python 2/3 compat if isinstance(some_dict, ("".__class__, u"".__class__)): if sys.version_info >= (3, 0): return some_dict return some_dict.decode('utf...
[ "def", "dict_unicodeize", "(", "some_dict", ")", ":", "# some python 2/3 compat", "if", "isinstance", "(", "some_dict", ",", "(", "\"\"", ".", "__class__", ",", "u\"\"", ".", "__class__", ")", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ","...
Ensure that every string in a dict is properly represented by unicode strings
[ "Ensure", "that", "every", "string", "in", "a", "dict", "is", "properly", "represented", "by", "unicode", "strings" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L235-L250
Autodesk/aomi
aomi/helpers.py
diff_dict
def diff_dict(dict1, dict2, ignore_missing=False): """Performs a base type comparison between two dicts""" unidict1 = dict_unicodeize(dict1) unidict2 = dict_unicodeize(dict2) if ((not ignore_missing) and (len(unidict1) != len(unidict2))) or \ (ignore_missing and (len(unidict1) >= len(unidict2))):...
python
def diff_dict(dict1, dict2, ignore_missing=False): """Performs a base type comparison between two dicts""" unidict1 = dict_unicodeize(dict1) unidict2 = dict_unicodeize(dict2) if ((not ignore_missing) and (len(unidict1) != len(unidict2))) or \ (ignore_missing and (len(unidict1) >= len(unidict2))):...
[ "def", "diff_dict", "(", "dict1", ",", "dict2", ",", "ignore_missing", "=", "False", ")", ":", "unidict1", "=", "dict_unicodeize", "(", "dict1", ")", "unidict2", "=", "dict_unicodeize", "(", "dict2", ")", "if", "(", "(", "not", "ignore_missing", ")", "and"...
Performs a base type comparison between two dicts
[ "Performs", "a", "base", "type", "comparison", "between", "two", "dicts" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L253-L268
Autodesk/aomi
aomi/helpers.py
map_val
def map_val(dest, src, key, default=None, src_key=None): """Will ensure a dict has values sourced from either another dict or based on the provided default""" if not src_key: src_key = key if src_key in src: dest[key] = src[src_key] else: if default is not None: ...
python
def map_val(dest, src, key, default=None, src_key=None): """Will ensure a dict has values sourced from either another dict or based on the provided default""" if not src_key: src_key = key if src_key in src: dest[key] = src[src_key] else: if default is not None: ...
[ "def", "map_val", "(", "dest", ",", "src", ",", "key", ",", "default", "=", "None", ",", "src_key", "=", "None", ")", ":", "if", "not", "src_key", ":", "src_key", "=", "key", "if", "src_key", "in", "src", ":", "dest", "[", "key", "]", "=", "src",...
Will ensure a dict has values sourced from either another dict or based on the provided default
[ "Will", "ensure", "a", "dict", "has", "values", "sourced", "from", "either", "another", "dict", "or", "based", "on", "the", "provided", "default" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/helpers.py#L278-L288
Autodesk/aomi
aomi/model/context.py
filtered_context
def filtered_context(context): """Filters a context This will return a new context with only the resources that are actually available for use. Uses tags and command line options to make determination.""" ctx = Context(context.opt) for resource in context.resources(): if resource.child:...
python
def filtered_context(context): """Filters a context This will return a new context with only the resources that are actually available for use. Uses tags and command line options to make determination.""" ctx = Context(context.opt) for resource in context.resources(): if resource.child:...
[ "def", "filtered_context", "(", "context", ")", ":", "ctx", "=", "Context", "(", "context", ".", "opt", ")", "for", "resource", "in", "context", ".", "resources", "(", ")", ":", "if", "resource", ".", "child", ":", "continue", "if", "resource", ".", "f...
Filters a context This will return a new context with only the resources that are actually available for use. Uses tags and command line options to make determination.
[ "Filters", "a", "context", "This", "will", "return", "a", "new", "context", "with", "only", "the", "resources", "that", "are", "actually", "available", "for", "use", ".", "Uses", "tags", "and", "command", "line", "options", "to", "make", "determination", "."...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L19-L33
Autodesk/aomi
aomi/model/context.py
ensure_backend
def ensure_backend(resource, backend, backends, opt, managed=True): """Ensure the backend for a resource is properly in context""" existing_mount = find_backend(resource.mount, backends) if not existing_mount: new_mount = backend(resource, opt, managed=managed) backends.append(new_mount) ...
python
def ensure_backend(resource, backend, backends, opt, managed=True): """Ensure the backend for a resource is properly in context""" existing_mount = find_backend(resource.mount, backends) if not existing_mount: new_mount = backend(resource, opt, managed=managed) backends.append(new_mount) ...
[ "def", "ensure_backend", "(", "resource", ",", "backend", ",", "backends", ",", "opt", ",", "managed", "=", "True", ")", ":", "existing_mount", "=", "find_backend", "(", "resource", ".", "mount", ",", "backends", ")", "if", "not", "existing_mount", ":", "n...
Ensure the backend for a resource is properly in context
[ "Ensure", "the", "backend", "for", "a", "resource", "is", "properly", "in", "context" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L59-L67
Autodesk/aomi
aomi/model/context.py
find_model
def find_model(config, obj, mods): """Given a list of mods (as returned by py_resources) attempts to determine if a given Python obj fits one of the models""" for mod in mods: if mod[0] != config: continue if len(mod) == 2: return mod[1] if len(mod) == 3 and...
python
def find_model(config, obj, mods): """Given a list of mods (as returned by py_resources) attempts to determine if a given Python obj fits one of the models""" for mod in mods: if mod[0] != config: continue if len(mod) == 2: return mod[1] if len(mod) == 3 and...
[ "def", "find_model", "(", "config", ",", "obj", ",", "mods", ")", ":", "for", "mod", "in", "mods", ":", "if", "mod", "[", "0", "]", "!=", "config", ":", "continue", "if", "len", "(", "mod", ")", "==", "2", ":", "return", "mod", "[", "1", "]", ...
Given a list of mods (as returned by py_resources) attempts to determine if a given Python obj fits one of the models
[ "Given", "a", "list", "of", "mods", "(", "as", "returned", "by", "py_resources", ")", "attempts", "to", "determine", "if", "a", "given", "Python", "obj", "fits", "one", "of", "the", "models" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L70-L83
Autodesk/aomi
aomi/model/context.py
py_resources
def py_resources(): """Discovers all aomi Vault resource models. This includes anything extending aomi.model.Mount or aomi.model.Resource.""" aomi_mods = [m for m, _v in iteritems(sys.modules) if m.startswith('aomi.model')] mod_list = [] mod_map = [] for amod in...
python
def py_resources(): """Discovers all aomi Vault resource models. This includes anything extending aomi.model.Mount or aomi.model.Resource.""" aomi_mods = [m for m, _v in iteritems(sys.modules) if m.startswith('aomi.model')] mod_list = [] mod_map = [] for amod in...
[ "def", "py_resources", "(", ")", ":", "aomi_mods", "=", "[", "m", "for", "m", ",", "_v", "in", "iteritems", "(", "sys", ".", "modules", ")", "if", "m", ".", "startswith", "(", "'aomi.model'", ")", "]", "mod_list", "=", "[", "]", "mod_map", "=", "["...
Discovers all aomi Vault resource models. This includes anything extending aomi.model.Mount or aomi.model.Resource.
[ "Discovers", "all", "aomi", "Vault", "resource", "models", ".", "This", "includes", "anything", "extending", "aomi", ".", "model", ".", "Mount", "or", "aomi", ".", "model", ".", "Resource", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L86-L113
Autodesk/aomi
aomi/model/context.py
Context.load
def load(config, opt): """Loads and returns a full context object based on the Secretfile""" ctx = Context(opt) seed_map = py_resources() seed_keys = sorted(set([m[0] for m in seed_map]), key=resource_sort) for config_key in seed_keys: if config_key not in config: ...
python
def load(config, opt): """Loads and returns a full context object based on the Secretfile""" ctx = Context(opt) seed_map = py_resources() seed_keys = sorted(set([m[0] for m in seed_map]), key=resource_sort) for config_key in seed_keys: if config_key not in config: ...
[ "def", "load", "(", "config", ",", "opt", ")", ":", "ctx", "=", "Context", "(", "opt", ")", "seed_map", "=", "py_resources", "(", ")", "seed_keys", "=", "sorted", "(", "set", "(", "[", "m", "[", "0", "]", "for", "m", "in", "seed_map", "]", ")", ...
Loads and returns a full context object based on the Secretfile
[ "Loads", "and", "returns", "a", "full", "context", "object", "based", "on", "the", "Secretfile" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L132-L153
Autodesk/aomi
aomi/model/context.py
Context.thaw
def thaw(self, tmp_dir): """Will thaw every secret into an appropriate temporary location""" for resource in self.resources(): if resource.present: resource.thaw(tmp_dir)
python
def thaw(self, tmp_dir): """Will thaw every secret into an appropriate temporary location""" for resource in self.resources(): if resource.present: resource.thaw(tmp_dir)
[ "def", "thaw", "(", "self", ",", "tmp_dir", ")", ":", "for", "resource", "in", "self", ".", "resources", "(", ")", ":", "if", "resource", ".", "present", ":", "resource", ".", "thaw", "(", "tmp_dir", ")" ]
Will thaw every secret into an appropriate temporary location
[ "Will", "thaw", "every", "secret", "into", "an", "appropriate", "temporary", "location" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L155-L159
Autodesk/aomi
aomi/model/context.py
Context.freeze
def freeze(self, dest_dir): """Freezes every resource within a context""" for resource in self.resources(): if resource.present: resource.freeze(dest_dir)
python
def freeze(self, dest_dir): """Freezes every resource within a context""" for resource in self.resources(): if resource.present: resource.freeze(dest_dir)
[ "def", "freeze", "(", "self", ",", "dest_dir", ")", ":", "for", "resource", "in", "self", ".", "resources", "(", ")", ":", "if", "resource", ".", "present", ":", "resource", ".", "freeze", "(", "dest_dir", ")" ]
Freezes every resource within a context
[ "Freezes", "every", "resource", "within", "a", "context" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L161-L165
Autodesk/aomi
aomi/model/context.py
Context.resources
def resources(self): """Vault resources within context""" res = [] for resource in self._resources: res = res + resource.resources() return res
python
def resources(self): """Vault resources within context""" res = [] for resource in self._resources: res = res + resource.resources() return res
[ "def", "resources", "(", "self", ")", ":", "res", "=", "[", "]", "for", "resource", "in", "self", ".", "_resources", ":", "res", "=", "res", "+", "resource", ".", "resources", "(", ")", "return", "res" ]
Vault resources within context
[ "Vault", "resources", "within", "context" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L186-L192
Autodesk/aomi
aomi/model/context.py
Context.add
def add(self, resource): """Add a resource to the context""" if isinstance(resource, Resource): if isinstance(resource, Secret) and \ resource.mount != 'cubbyhole': ensure_backend(resource, SecretBackend, ...
python
def add(self, resource): """Add a resource to the context""" if isinstance(resource, Resource): if isinstance(resource, Secret) and \ resource.mount != 'cubbyhole': ensure_backend(resource, SecretBackend, ...
[ "def", "add", "(", "self", ",", "resource", ")", ":", "if", "isinstance", "(", "resource", ",", "Resource", ")", ":", "if", "isinstance", "(", "resource", ",", "Secret", ")", "and", "resource", ".", "mount", "!=", "'cubbyhole'", ":", "ensure_backend", "(...
Add a resource to the context
[ "Add", "a", "resource", "to", "the", "context" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L194-L215
Autodesk/aomi
aomi/model/context.py
Context.remove
def remove(self, resource): """Removes a resource from the context""" if isinstance(resource, Resource): self._resources.remove(resource)
python
def remove(self, resource): """Removes a resource from the context""" if isinstance(resource, Resource): self._resources.remove(resource)
[ "def", "remove", "(", "self", ",", "resource", ")", ":", "if", "isinstance", "(", "resource", ",", "Resource", ")", ":", "self", ".", "_resources", ".", "remove", "(", "resource", ")" ]
Removes a resource from the context
[ "Removes", "a", "resource", "from", "the", "context" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L217-L220
Autodesk/aomi
aomi/model/context.py
Context.sync_policies
def sync_policies(self, vault_client): """Synchronizes policies only""" p_resources = [x for x in self.resources() if isinstance(x, Policy)] for resource in p_resources: resource.sync(vault_client) return [x for x in self.resources() if...
python
def sync_policies(self, vault_client): """Synchronizes policies only""" p_resources = [x for x in self.resources() if isinstance(x, Policy)] for resource in p_resources: resource.sync(vault_client) return [x for x in self.resources() if...
[ "def", "sync_policies", "(", "self", ",", "vault_client", ")", ":", "p_resources", "=", "[", "x", "for", "x", "in", "self", ".", "resources", "(", ")", "if", "isinstance", "(", "x", ",", "Policy", ")", "]", "for", "resource", "in", "p_resources", ":", ...
Synchronizes policies only
[ "Synchronizes", "policies", "only" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L222-L230
Autodesk/aomi
aomi/model/context.py
Context.sync_auth
def sync_auth(self, vault_client, resources): """Synchronizes auth mount wrappers. These happen early in the cycle, to ensure that user backends are proper. They may also be used to set mount tuning""" for auth in self.auths(): auth.sync(vault_client) auth_re...
python
def sync_auth(self, vault_client, resources): """Synchronizes auth mount wrappers. These happen early in the cycle, to ensure that user backends are proper. They may also be used to set mount tuning""" for auth in self.auths(): auth.sync(vault_client) auth_re...
[ "def", "sync_auth", "(", "self", ",", "vault_client", ",", "resources", ")", ":", "for", "auth", "in", "self", ".", "auths", "(", ")", ":", "auth", ".", "sync", "(", "vault_client", ")", "auth_resources", "=", "[", "x", "for", "x", "in", "resources", ...
Synchronizes auth mount wrappers. These happen early in the cycle, to ensure that user backends are proper. They may also be used to set mount tuning
[ "Synchronizes", "auth", "mount", "wrappers", ".", "These", "happen", "early", "in", "the", "cycle", "to", "ensure", "that", "user", "backends", "are", "proper", ".", "They", "may", "also", "be", "used", "to", "set", "mount", "tuning" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L232-L246
Autodesk/aomi
aomi/model/context.py
Context.actually_mount
def actually_mount(self, vault_client, resource, active_mounts): """Handle the actual (potential) mounting of a secret backend. This is called in multiple contexts, but the action will always be the same. If we were not aware of the mountpoint at the start and it has not already been mou...
python
def actually_mount(self, vault_client, resource, active_mounts): """Handle the actual (potential) mounting of a secret backend. This is called in multiple contexts, but the action will always be the same. If we were not aware of the mountpoint at the start and it has not already been mou...
[ "def", "actually_mount", "(", "self", ",", "vault_client", ",", "resource", ",", "active_mounts", ")", ":", "a_mounts", "=", "list", "(", "active_mounts", ")", "if", "isinstance", "(", "resource", ",", "Secret", ")", "and", "resource", ".", "mount", "==", ...
Handle the actual (potential) mounting of a secret backend. This is called in multiple contexts, but the action will always be the same. If we were not aware of the mountpoint at the start and it has not already been mounted, then mount it.
[ "Handle", "the", "actual", "(", "potential", ")", "mounting", "of", "a", "secret", "backend", ".", "This", "is", "called", "in", "multiple", "contexts", "but", "the", "action", "will", "always", "be", "the", "same", ".", "If", "we", "were", "not", "aware...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L248-L263
Autodesk/aomi
aomi/model/context.py
Context.sync_mounts
def sync_mounts(self, active_mounts, resources, vault_client): """Synchronizes mount points. Removes things before adding new.""" # Create a resource set that is only explicit mounts # and sort so removals are first mounts = [x for x in resources if isinstance(x...
python
def sync_mounts(self, active_mounts, resources, vault_client): """Synchronizes mount points. Removes things before adding new.""" # Create a resource set that is only explicit mounts # and sort so removals are first mounts = [x for x in resources if isinstance(x...
[ "def", "sync_mounts", "(", "self", ",", "active_mounts", ",", "resources", ",", "vault_client", ")", ":", "# Create a resource set that is only explicit mounts", "# and sort so removals are first", "mounts", "=", "[", "x", "for", "x", "in", "resources", "if", "isinstanc...
Synchronizes mount points. Removes things before adding new.
[ "Synchronizes", "mount", "points", ".", "Removes", "things", "before", "adding", "new", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L265-L295
Autodesk/aomi
aomi/model/context.py
Context.sync
def sync(self, vault_client, opt): """Synchronizes the context to the Vault server. This has the effect of updating every resource which is in the context and has changes pending.""" active_mounts = [] for audit_log in self.logs(): audit_log.sync(vault_client) ...
python
def sync(self, vault_client, opt): """Synchronizes the context to the Vault server. This has the effect of updating every resource which is in the context and has changes pending.""" active_mounts = [] for audit_log in self.logs(): audit_log.sync(vault_client) ...
[ "def", "sync", "(", "self", ",", "vault_client", ",", "opt", ")", ":", "active_mounts", "=", "[", "]", "for", "audit_log", "in", "self", ".", "logs", "(", ")", ":", "audit_log", ".", "sync", "(", "vault_client", ")", "# Handle policies only on the first pass...
Synchronizes the context to the Vault server. This has the effect of updating every resource which is in the context and has changes pending.
[ "Synchronizes", "the", "context", "to", "the", "Vault", "server", ".", "This", "has", "the", "effect", "of", "updating", "every", "resource", "which", "is", "in", "the", "context", "and", "has", "changes", "pending", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L297-L332
Autodesk/aomi
aomi/model/context.py
Context.prune
def prune(self, vault_client): """Will remove any mount point which is not actually defined in this context. """ existing = getattr(vault_client, SecretBackend.list_fun)()['data'].items() for mount_name, _values in existing: # ignore system paths an...
python
def prune(self, vault_client): """Will remove any mount point which is not actually defined in this context. """ existing = getattr(vault_client, SecretBackend.list_fun)()['data'].items() for mount_name, _values in existing: # ignore system paths an...
[ "def", "prune", "(", "self", ",", "vault_client", ")", ":", "existing", "=", "getattr", "(", "vault_client", ",", "SecretBackend", ".", "list_fun", ")", "(", ")", "[", "'data'", "]", ".", "items", "(", ")", "for", "mount_name", ",", "_values", "in", "e...
Will remove any mount point which is not actually defined in this context.
[ "Will", "remove", "any", "mount", "point", "which", "is", "not", "actually", "defined", "in", "this", "context", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L334-L351
Autodesk/aomi
aomi/model/context.py
Context.fetch
def fetch(self, vault_client): """Updates the context based on the contents of the Vault server. Note that some resources can not be read after they have been written to and it is up to those classes to handle that case properly.""" backends = [(self.mounts, SecretBackend), ...
python
def fetch(self, vault_client): """Updates the context based on the contents of the Vault server. Note that some resources can not be read after they have been written to and it is up to those classes to handle that case properly.""" backends = [(self.mounts, SecretBackend), ...
[ "def", "fetch", "(", "self", ",", "vault_client", ")", ":", "backends", "=", "[", "(", "self", ".", "mounts", ",", "SecretBackend", ")", ",", "(", "self", ".", "auths", ",", "AuthBackend", ")", ",", "(", "self", ".", "logs", ",", "LogBackend", ")", ...
Updates the context based on the contents of the Vault server. Note that some resources can not be read after they have been written to and it is up to those classes to handle that case properly.
[ "Updates", "the", "context", "based", "on", "the", "contents", "of", "the", "Vault", "server", ".", "Note", "that", "some", "resources", "can", "not", "be", "read", "after", "they", "have", "been", "written", "to", "and", "it", "is", "up", "to", "those",...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/context.py#L353-L383
Autodesk/aomi
aomi/model/auth.py
AppRole.presets
def presets(self, presets, opt): """Will create representational objects for any preset (push) based AppRole Secrets.""" for preset in presets: secret_obj = dict(preset) secret_obj['role_name'] = self.app_name self.secret_ids.append(AppRoleSecret(secret_obj, o...
python
def presets(self, presets, opt): """Will create representational objects for any preset (push) based AppRole Secrets.""" for preset in presets: secret_obj = dict(preset) secret_obj['role_name'] = self.app_name self.secret_ids.append(AppRoleSecret(secret_obj, o...
[ "def", "presets", "(", "self", ",", "presets", ",", "opt", ")", ":", "for", "preset", "in", "presets", ":", "secret_obj", "=", "dict", "(", "preset", ")", "secret_obj", "[", "'role_name'", "]", "=", "self", ".", "app_name", "self", ".", "secret_ids", "...
Will create representational objects for any preset (push) based AppRole Secrets.
[ "Will", "create", "representational", "objects", "for", "any", "preset", "(", "push", ")", "based", "AppRole", "Secrets", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/auth.py#L205-L211
Autodesk/aomi
aomi/render.py
secret_key_name
def secret_key_name(path, key, opt): """Renders a Secret key name appropriately""" value = key if opt.merge_path: norm_path = [x for x in path.split('/') if x] value = "%s_%s" % ('_'.join(norm_path), key) if opt.add_prefix: value = "%s%s" % (opt.add_prefix, value) if opt.ad...
python
def secret_key_name(path, key, opt): """Renders a Secret key name appropriately""" value = key if opt.merge_path: norm_path = [x for x in path.split('/') if x] value = "%s_%s" % ('_'.join(norm_path), key) if opt.add_prefix: value = "%s%s" % (opt.add_prefix, value) if opt.ad...
[ "def", "secret_key_name", "(", "path", ",", "key", ",", "opt", ")", ":", "value", "=", "key", "if", "opt", ".", "merge_path", ":", "norm_path", "=", "[", "x", "for", "x", "in", "path", ".", "split", "(", "'/'", ")", "if", "x", "]", "value", "=", ...
Renders a Secret key name appropriately
[ "Renders", "a", "Secret", "key", "name", "appropriately" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L18-L31
Autodesk/aomi
aomi/render.py
grok_template_file
def grok_template_file(src): """Determine the real deal template file""" if not src.startswith('builtin:'): return abspath(src) builtin = src.split(':')[1] builtin = "templates/%s.j2" % builtin return resource_filename(__name__, builtin)
python
def grok_template_file(src): """Determine the real deal template file""" if not src.startswith('builtin:'): return abspath(src) builtin = src.split(':')[1] builtin = "templates/%s.j2" % builtin return resource_filename(__name__, builtin)
[ "def", "grok_template_file", "(", "src", ")", ":", "if", "not", "src", ".", "startswith", "(", "'builtin:'", ")", ":", "return", "abspath", "(", "src", ")", "builtin", "=", "src", ".", "split", "(", "':'", ")", "[", "1", "]", "builtin", "=", "\"templ...
Determine the real deal template file
[ "Determine", "the", "real", "deal", "template", "file" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L34-L41
Autodesk/aomi
aomi/render.py
blend_vars
def blend_vars(secrets, opt): """Blends secret and static variables together""" base_obj = load_vars(opt) merged = merge_dicts(base_obj, secrets) template_obj = dict((k, v) for k, v in iteritems(merged) if v) # give templates something to iterate over template_obj['aomi_items'] = template_obj.co...
python
def blend_vars(secrets, opt): """Blends secret and static variables together""" base_obj = load_vars(opt) merged = merge_dicts(base_obj, secrets) template_obj = dict((k, v) for k, v in iteritems(merged) if v) # give templates something to iterate over template_obj['aomi_items'] = template_obj.co...
[ "def", "blend_vars", "(", "secrets", ",", "opt", ")", ":", "base_obj", "=", "load_vars", "(", "opt", ")", "merged", "=", "merge_dicts", "(", "base_obj", ",", "secrets", ")", "template_obj", "=", "dict", "(", "(", "k", ",", "v", ")", "for", "k", ",", ...
Blends secret and static variables together
[ "Blends", "secret", "and", "static", "variables", "together" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L44-L51
Autodesk/aomi
aomi/render.py
template
def template(client, src, dest, paths, opt): """Writes a template using variables from a vault path""" key_map = cli_hash(opt.key_map) obj = {} for path in paths: response = client.read(path) if not response: raise aomi.exceptions.VaultData("Unable to retrieve %s" % path) ...
python
def template(client, src, dest, paths, opt): """Writes a template using variables from a vault path""" key_map = cli_hash(opt.key_map) obj = {} for path in paths: response = client.read(path) if not response: raise aomi.exceptions.VaultData("Unable to retrieve %s" % path) ...
[ "def", "template", "(", "client", ",", "src", ",", "dest", ",", "paths", ",", "opt", ")", ":", "key_map", "=", "cli_hash", "(", "opt", ".", "key_map", ")", "obj", "=", "{", "}", "for", "path", "in", "paths", ":", "response", "=", "client", ".", "...
Writes a template using variables from a vault path
[ "Writes", "a", "template", "using", "variables", "from", "a", "vault", "path" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L54-L78
Autodesk/aomi
aomi/render.py
write_raw_file
def write_raw_file(secret, dest): """Writes an actual secret out to a file""" secret_file = None secret_filename = abspath(dest) if sys.version_info >= (3, 0): if not isinstance(secret, str): secret_file = open(secret_filename, 'wb') if not secret_file: secret_file = ope...
python
def write_raw_file(secret, dest): """Writes an actual secret out to a file""" secret_file = None secret_filename = abspath(dest) if sys.version_info >= (3, 0): if not isinstance(secret, str): secret_file = open(secret_filename, 'wb') if not secret_file: secret_file = ope...
[ "def", "write_raw_file", "(", "secret", ",", "dest", ")", ":", "secret_file", "=", "None", "secret_filename", "=", "abspath", "(", "dest", ")", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "if", "not", "isinstance", "(", "secre...
Writes an actual secret out to a file
[ "Writes", "an", "actual", "secret", "out", "to", "a", "file" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L81-L94
Autodesk/aomi
aomi/render.py
raw_file
def raw_file(client, src, dest, opt): """Write the contents of a vault path/key to a file. Is smart enough to attempt and handle binary files that are base64 encoded.""" path, key = path_pieces(src) resp = client.read(path) if not resp: client.revoke_self_token() raise aomi.excep...
python
def raw_file(client, src, dest, opt): """Write the contents of a vault path/key to a file. Is smart enough to attempt and handle binary files that are base64 encoded.""" path, key = path_pieces(src) resp = client.read(path) if not resp: client.revoke_self_token() raise aomi.excep...
[ "def", "raw_file", "(", "client", ",", "src", ",", "dest", ",", "opt", ")", ":", "path", ",", "key", "=", "path_pieces", "(", "src", ")", "resp", "=", "client", ".", "read", "(", "path", ")", "if", "not", "resp", ":", "client", ".", "revoke_self_to...
Write the contents of a vault path/key to a file. Is smart enough to attempt and handle binary files that are base64 encoded.
[ "Write", "the", "contents", "of", "a", "vault", "path", "/", "key", "to", "a", "file", ".", "Is", "smart", "enough", "to", "attempt", "and", "handle", "binary", "files", "that", "are", "base64", "encoded", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L97-L120
Autodesk/aomi
aomi/render.py
env
def env(client, paths, opt): """Renders a shell snippet based on paths in a Secretfile""" old_prefix = False old_prefix = opt.prefix and not (opt.add_prefix or opt.add_suffix or not opt.merge_path) if old_prefix: LOG.warni...
python
def env(client, paths, opt): """Renders a shell snippet based on paths in a Secretfile""" old_prefix = False old_prefix = opt.prefix and not (opt.add_prefix or opt.add_suffix or not opt.merge_path) if old_prefix: LOG.warni...
[ "def", "env", "(", "client", ",", "paths", ",", "opt", ")", ":", "old_prefix", "=", "False", "old_prefix", "=", "opt", ".", "prefix", "and", "not", "(", "opt", ".", "add_prefix", "or", "opt", ".", "add_suffix", "or", "not", "opt", ".", "merge_path", ...
Renders a shell snippet based on paths in a Secretfile
[ "Renders", "a", "shell", "snippet", "based", "on", "paths", "in", "a", "Secretfile" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L123-L158
Autodesk/aomi
aomi/render.py
aws
def aws(client, path, opt): """Renders a shell environment snippet with AWS information""" try: creds = client.read(path) except (hvac.exceptions.InternalServerError) as vault_exception: # this is how old vault behaves if vault_exception.errors[0].find('unsupported path') > 0: ...
python
def aws(client, path, opt): """Renders a shell environment snippet with AWS information""" try: creds = client.read(path) except (hvac.exceptions.InternalServerError) as vault_exception: # this is how old vault behaves if vault_exception.errors[0].find('unsupported path') > 0: ...
[ "def", "aws", "(", "client", ",", "path", ",", "opt", ")", ":", "try", ":", "creds", "=", "client", ".", "read", "(", "path", ")", "except", "(", "hvac", ".", "exceptions", ".", "InternalServerError", ")", "as", "vault_exception", ":", "# this is how old...
Renders a shell environment snippet with AWS information
[ "Renders", "a", "shell", "environment", "snippet", "with", "AWS", "information" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/render.py#L161-L200
Autodesk/aomi
aomi/model/generic.py
generated_key
def generated_key(key): """Create the proper generated key value""" key_name = key['name'] if key['method'] == 'uuid': LOG.debug("Setting %s to a uuid", key_name) return str(uuid4()) elif key['method'] == 'words': LOG.debug("Setting %s to random words", key_name) return r...
python
def generated_key(key): """Create the proper generated key value""" key_name = key['name'] if key['method'] == 'uuid': LOG.debug("Setting %s to a uuid", key_name) return str(uuid4()) elif key['method'] == 'words': LOG.debug("Setting %s to random words", key_name) return r...
[ "def", "generated_key", "(", "key", ")", ":", "key_name", "=", "key", "[", "'name'", "]", "if", "key", "[", "'method'", "]", "==", "'uuid'", ":", "LOG", ".", "debug", "(", "\"Setting %s to a uuid\"", ",", "key_name", ")", "return", "str", "(", "uuid4", ...
Create the proper generated key value
[ "Create", "the", "proper", "generated", "key", "value" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/generic.py#L101-L118
Autodesk/aomi
aomi/model/generic.py
Generated.generate_obj
def generate_obj(self): """Generates the secret object, respecting existing information and user specified options""" secret_obj = {} if self.existing: secret_obj = deepcopy(self.existing) for key in self.keys: key_name = key['name'] if self.e...
python
def generate_obj(self): """Generates the secret object, respecting existing information and user specified options""" secret_obj = {} if self.existing: secret_obj = deepcopy(self.existing) for key in self.keys: key_name = key['name'] if self.e...
[ "def", "generate_obj", "(", "self", ")", ":", "secret_obj", "=", "{", "}", "if", "self", ".", "existing", ":", "secret_obj", "=", "deepcopy", "(", "self", ".", "existing", ")", "for", "key", "in", "self", ".", "keys", ":", "key_name", "=", "key", "["...
Generates the secret object, respecting existing information and user specified options
[ "Generates", "the", "secret", "object", "respecting", "existing", "information", "and", "user", "specified", "options" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/generic.py#L133-L150
Autodesk/aomi
aomi/error.py
unhandled
def unhandled(exception, opt): """ Handle uncaught/unexpected errors and be polite about it""" exmod = type(exception).__module__ name = "%s.%s" % (exmod, type(exception).__name__) # this is a Vault error if exmod == 'aomi.exceptions' or exmod == 'cryptorito': # This may be set for Validatio...
python
def unhandled(exception, opt): """ Handle uncaught/unexpected errors and be polite about it""" exmod = type(exception).__module__ name = "%s.%s" % (exmod, type(exception).__name__) # this is a Vault error if exmod == 'aomi.exceptions' or exmod == 'cryptorito': # This may be set for Validatio...
[ "def", "unhandled", "(", "exception", ",", "opt", ")", ":", "exmod", "=", "type", "(", "exception", ")", ".", "__module__", "name", "=", "\"%s.%s\"", "%", "(", "exmod", ",", "type", "(", "exception", ")", ".", "__name__", ")", "# this is a Vault error", ...
Handle uncaught/unexpected errors and be polite about it
[ "Handle", "uncaught", "/", "unexpected", "errors", "and", "be", "polite", "about", "it" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/error.py#L7-L22
Autodesk/aomi
aomi/error.py
output
def output(message, opt, extra=None): """ Politely display an unexpected error""" print(message, file=sys.stderr) if opt.verbose: if extra: print(extra) traceback.print_exc(sys.stderr)
python
def output(message, opt, extra=None): """ Politely display an unexpected error""" print(message, file=sys.stderr) if opt.verbose: if extra: print(extra) traceback.print_exc(sys.stderr)
[ "def", "output", "(", "message", ",", "opt", ",", "extra", "=", "None", ")", ":", "print", "(", "message", ",", "file", "=", "sys", ".", "stderr", ")", "if", "opt", ".", "verbose", ":", "if", "extra", ":", "print", "(", "extra", ")", "traceback", ...
Politely display an unexpected error
[ "Politely", "display", "an", "unexpected", "error" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/error.py#L25-L32
Autodesk/aomi
aomi/vault.py
grok_seconds
def grok_seconds(lease): """Ensures that we are returning just seconds""" if lease.endswith('s'): return int(lease[0:-1]) elif lease.endswith('m'): return int(lease[0:-1]) * 60 elif lease.endswith('h'): return int(lease[0:-1]) * 3600 return None
python
def grok_seconds(lease): """Ensures that we are returning just seconds""" if lease.endswith('s'): return int(lease[0:-1]) elif lease.endswith('m'): return int(lease[0:-1]) * 60 elif lease.endswith('h'): return int(lease[0:-1]) * 3600 return None
[ "def", "grok_seconds", "(", "lease", ")", ":", "if", "lease", ".", "endswith", "(", "'s'", ")", ":", "return", "int", "(", "lease", "[", "0", ":", "-", "1", "]", ")", "elif", "lease", ".", "endswith", "(", "'m'", ")", ":", "return", "int", "(", ...
Ensures that we are returning just seconds
[ "Ensures", "that", "we", "are", "returning", "just", "seconds" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L25-L34
Autodesk/aomi
aomi/vault.py
renew_secret
def renew_secret(client, creds, opt): """Renews a secret. This will occur unless the user has specified on the command line that it is not neccesary""" if opt.reuse_token: return seconds = grok_seconds(opt.lease) if not seconds: raise aomi.exceptions.AomiCommand("invalid lease %s" %...
python
def renew_secret(client, creds, opt): """Renews a secret. This will occur unless the user has specified on the command line that it is not neccesary""" if opt.reuse_token: return seconds = grok_seconds(opt.lease) if not seconds: raise aomi.exceptions.AomiCommand("invalid lease %s" %...
[ "def", "renew_secret", "(", "client", ",", "creds", ",", "opt", ")", ":", "if", "opt", ".", "reuse_token", ":", "return", "seconds", "=", "grok_seconds", "(", "opt", ".", "lease", ")", "if", "not", "seconds", ":", "raise", "aomi", ".", "exceptions", "....
Renews a secret. This will occur unless the user has specified on the command line that it is not neccesary
[ "Renews", "a", "secret", ".", "This", "will", "occur", "unless", "the", "user", "has", "specified", "on", "the", "command", "line", "that", "it", "is", "not", "neccesary" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L37-L69
Autodesk/aomi
aomi/vault.py
approle_token
def approle_token(vault_client, role_id, secret_id): """Returns a vault token based on the role and seret id""" resp = vault_client.auth_approle(role_id, secret_id) if 'auth' in resp and 'client_token' in resp['auth']: return resp['auth']['client_token'] else: raise aomi.exceptions.AomiC...
python
def approle_token(vault_client, role_id, secret_id): """Returns a vault token based on the role and seret id""" resp = vault_client.auth_approle(role_id, secret_id) if 'auth' in resp and 'client_token' in resp['auth']: return resp['auth']['client_token'] else: raise aomi.exceptions.AomiC...
[ "def", "approle_token", "(", "vault_client", ",", "role_id", ",", "secret_id", ")", ":", "resp", "=", "vault_client", ".", "auth_approle", "(", "role_id", ",", "secret_id", ")", "if", "'auth'", "in", "resp", "and", "'client_token'", "in", "resp", "[", "'auth...
Returns a vault token based on the role and seret id
[ "Returns", "a", "vault", "token", "based", "on", "the", "role", "and", "seret", "id" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L72-L78
Autodesk/aomi
aomi/vault.py
app_token
def app_token(vault_client, app_id, user_id): """Returns a vault token based on the app and user id.""" resp = vault_client.auth_app_id(app_id, user_id) if 'auth' in resp and 'client_token' in resp['auth']: return resp['auth']['client_token'] else: raise aomi.exceptions.AomiCredentials('...
python
def app_token(vault_client, app_id, user_id): """Returns a vault token based on the app and user id.""" resp = vault_client.auth_app_id(app_id, user_id) if 'auth' in resp and 'client_token' in resp['auth']: return resp['auth']['client_token'] else: raise aomi.exceptions.AomiCredentials('...
[ "def", "app_token", "(", "vault_client", ",", "app_id", ",", "user_id", ")", ":", "resp", "=", "vault_client", ".", "auth_app_id", "(", "app_id", ",", "user_id", ")", "if", "'auth'", "in", "resp", "and", "'client_token'", "in", "resp", "[", "'auth'", "]", ...
Returns a vault token based on the app and user id.
[ "Returns", "a", "vault", "token", "based", "on", "the", "app", "and", "user", "id", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L81-L87
Autodesk/aomi
aomi/vault.py
token_meta
def token_meta(opt): """Generates metadata for a token""" meta = { 'via': 'aomi', 'operation': opt.operation, 'hostname': socket.gethostname() } if 'USER' in os.environ: meta['unix_user'] = os.environ['USER'] if opt.metadata: meta_bits = opt.metadata.split(',...
python
def token_meta(opt): """Generates metadata for a token""" meta = { 'via': 'aomi', 'operation': opt.operation, 'hostname': socket.gethostname() } if 'USER' in os.environ: meta['unix_user'] = os.environ['USER'] if opt.metadata: meta_bits = opt.metadata.split(',...
[ "def", "token_meta", "(", "opt", ")", ":", "meta", "=", "{", "'via'", ":", "'aomi'", ",", "'operation'", ":", "opt", ".", "operation", ",", "'hostname'", ":", "socket", ".", "gethostname", "(", ")", "}", "if", "'USER'", "in", "os", ".", "environ", ":...
Generates metadata for a token
[ "Generates", "metadata", "for", "a", "token" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L90-L111
Autodesk/aomi
aomi/vault.py
get_backend
def get_backend(backend, path, backends): """Returns mountpoint details for a backend""" m_norm = normalize_vault_path(path) for mount_name, values in backends.items(): b_norm = normalize_vault_path(mount_name) if (m_norm == b_norm) and values['type'] == backend: return values ...
python
def get_backend(backend, path, backends): """Returns mountpoint details for a backend""" m_norm = normalize_vault_path(path) for mount_name, values in backends.items(): b_norm = normalize_vault_path(mount_name) if (m_norm == b_norm) and values['type'] == backend: return values ...
[ "def", "get_backend", "(", "backend", ",", "path", ",", "backends", ")", ":", "m_norm", "=", "normalize_vault_path", "(", "path", ")", "for", "mount_name", ",", "values", "in", "backends", ".", "items", "(", ")", ":", "b_norm", "=", "normalize_vault_path", ...
Returns mountpoint details for a backend
[ "Returns", "mountpoint", "details", "for", "a", "backend" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L114-L122
Autodesk/aomi
aomi/vault.py
wrap_hvac
def wrap_hvac(msg): """Error catching Vault API wrapper This decorator wraps API interactions with Vault. It will catch and return appropriate error output on common problems. Do we even need this now that we extend the hvac class?""" # pylint: disable=missing-docstring def wrap_call(func): ...
python
def wrap_hvac(msg): """Error catching Vault API wrapper This decorator wraps API interactions with Vault. It will catch and return appropriate error output on common problems. Do we even need this now that we extend the hvac class?""" # pylint: disable=missing-docstring def wrap_call(func): ...
[ "def", "wrap_hvac", "(", "msg", ")", ":", "# pylint: disable=missing-docstring", "def", "wrap_call", "(", "func", ")", ":", "# pylint: disable=missing-docstring", "def", "func_wrapper", "(", "self", ",", "vault_client", ")", ":", "try", ":", "return", "func", "(",...
Error catching Vault API wrapper This decorator wraps API interactions with Vault. It will catch and return appropriate error output on common problems. Do we even need this now that we extend the hvac class?
[ "Error", "catching", "Vault", "API", "wrapper", "This", "decorator", "wraps", "API", "interactions", "with", "Vault", ".", "It", "will", "catch", "and", "return", "appropriate", "error", "output", "on", "common", "problems", ".", "Do", "we", "even", "need", ...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L130-L151
Autodesk/aomi
aomi/vault.py
Client.server_version
def server_version(self): """Attempts to determine the version of Vault that a server is running. Some actions will change on older Vault deployments.""" health_url = "%s/v1/sys/health" % self.vault_addr resp = self.session.request('get', health_url, **self._kwargs) if re...
python
def server_version(self): """Attempts to determine the version of Vault that a server is running. Some actions will change on older Vault deployments.""" health_url = "%s/v1/sys/health" % self.vault_addr resp = self.session.request('get', health_url, **self._kwargs) if re...
[ "def", "server_version", "(", "self", ")", ":", "health_url", "=", "\"%s/v1/sys/health\"", "%", "self", ".", "vault_addr", "resp", "=", "self", ".", "session", ".", "request", "(", "'get'", ",", "health_url", ",", "*", "*", "self", ".", "_kwargs", ")", "...
Attempts to determine the version of Vault that a server is running. Some actions will change on older Vault deployments.
[ "Attempts", "to", "determine", "the", "version", "of", "Vault", "that", "a", "server", "is", "running", ".", "Some", "actions", "will", "change", "on", "older", "Vault", "deployments", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L191-L204
Autodesk/aomi
aomi/vault.py
Client.connect
def connect(self, opt): """This sets up the tokens we expect to see in a way that hvac also expects.""" if not self._kwargs['verify']: LOG.warning('Skipping SSL Validation!') self.version = self.server_version() self.token = self.init_token() my_token = self....
python
def connect(self, opt): """This sets up the tokens we expect to see in a way that hvac also expects.""" if not self._kwargs['verify']: LOG.warning('Skipping SSL Validation!') self.version = self.server_version() self.token = self.init_token() my_token = self....
[ "def", "connect", "(", "self", ",", "opt", ")", ":", "if", "not", "self", ".", "_kwargs", "[", "'verify'", "]", ":", "LOG", ".", "warning", "(", "'Skipping SSL Validation!'", ")", "self", ".", "version", "=", "self", ".", "server_version", "(", ")", "s...
This sets up the tokens we expect to see in a way that hvac also expects.
[ "This", "sets", "up", "the", "tokens", "we", "expect", "to", "see", "in", "a", "way", "that", "hvac", "also", "expects", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L206-L243
Autodesk/aomi
aomi/vault.py
Client.init_token
def init_token(self): """Generate our first token based on workstation configuration""" app_filename = appid_file() token_filename = token_file() approle_filename = approle_file() token = None if 'VAULT_ROLE_ID' in os.environ and \ 'VAULT_SECRET_ID' in os.envi...
python
def init_token(self): """Generate our first token based on workstation configuration""" app_filename = appid_file() token_filename = token_file() approle_filename = approle_file() token = None if 'VAULT_ROLE_ID' in os.environ and \ 'VAULT_SECRET_ID' in os.envi...
[ "def", "init_token", "(", "self", ")", ":", "app_filename", "=", "appid_file", "(", ")", "token_filename", "=", "token_file", "(", ")", "approle_filename", "=", "approle_file", "(", ")", "token", "=", "None", "if", "'VAULT_ROLE_ID'", "in", "os", ".", "enviro...
Generate our first token based on workstation configuration
[ "Generate", "our", "first", "token", "based", "on", "workstation", "configuration" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L245-L295
Autodesk/aomi
aomi/vault.py
Client.op_token
def op_token(self, display_name, opt): """Return a properly annotated token for our use. This token will be revoked at the end of the session. The token will have some decent amounts of metadata tho.""" args = { 'lease': opt.lease, 'display_name': display_name, ...
python
def op_token(self, display_name, opt): """Return a properly annotated token for our use. This token will be revoked at the end of the session. The token will have some decent amounts of metadata tho.""" args = { 'lease': opt.lease, 'display_name': display_name, ...
[ "def", "op_token", "(", "self", ",", "display_name", ",", "opt", ")", ":", "args", "=", "{", "'lease'", ":", "opt", ".", "lease", ",", "'display_name'", ":", "display_name", ",", "'meta'", ":", "token_meta", "(", "opt", ")", "}", "try", ":", "token", ...
Return a properly annotated token for our use. This token will be revoked at the end of the session. The token will have some decent amounts of metadata tho.
[ "Return", "a", "properly", "annotated", "token", "for", "our", "use", ".", "This", "token", "will", "be", "revoked", "at", "the", "end", "of", "the", "session", ".", "The", "token", "will", "have", "some", "decent", "amounts", "of", "metadata", "tho", "....
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L297-L317
Autodesk/aomi
aomi/vault.py
Client.read
def read(self, path, wrap_ttl=None): """Wrap the hvac read call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, self).read(path, wrap_ttl) ...
python
def read(self, path, wrap_ttl=None): """Wrap the hvac read call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, self).read(path, wrap_ttl) ...
[ "def", "read", "(", "self", ",", "path", ",", "wrap_ttl", "=", "None", ")", ":", "path", "=", "sanitize_mount", "(", "path", ")", "if", "path", ".", "startswith", "(", "'cubbyhole'", ")", ":", "self", ".", "token", "=", "self", ".", "initial_token", ...
Wrap the hvac read call, using the right token for cubbyhole interactions.
[ "Wrap", "the", "hvac", "read", "call", "using", "the", "right", "token", "for", "cubbyhole", "interactions", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L319-L329
Autodesk/aomi
aomi/vault.py
Client.write
def write(self, path, wrap_ttl=None, **kwargs): """Wrap the hvac write call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) val = None if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, se...
python
def write(self, path, wrap_ttl=None, **kwargs): """Wrap the hvac write call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) val = None if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, se...
[ "def", "write", "(", "self", ",", "path", ",", "wrap_ttl", "=", "None", ",", "*", "*", "kwargs", ")", ":", "path", "=", "sanitize_mount", "(", "path", ")", "val", "=", "None", "if", "path", ".", "startswith", "(", "'cubbyhole'", ")", ":", "self", "...
Wrap the hvac write call, using the right token for cubbyhole interactions.
[ "Wrap", "the", "hvac", "write", "call", "using", "the", "right", "token", "for", "cubbyhole", "interactions", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L331-L343
Autodesk/aomi
aomi/vault.py
Client.delete
def delete(self, path): """Wrap the hvac delete call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) val = None if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, self).delete(path) ...
python
def delete(self, path): """Wrap the hvac delete call, using the right token for cubbyhole interactions.""" path = sanitize_mount(path) val = None if path.startswith('cubbyhole'): self.token = self.initial_token val = super(Client, self).delete(path) ...
[ "def", "delete", "(", "self", ",", "path", ")", ":", "path", "=", "sanitize_mount", "(", "path", ")", "val", "=", "None", "if", "path", ".", "startswith", "(", "'cubbyhole'", ")", ":", "self", ".", "token", "=", "self", ".", "initial_token", "val", "...
Wrap the hvac delete call, using the right token for cubbyhole interactions.
[ "Wrap", "the", "hvac", "delete", "call", "using", "the", "right", "token", "for", "cubbyhole", "interactions", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/vault.py#L345-L357
Autodesk/aomi
aomi/filez.py
from_keybase
def from_keybase(username): """Will attempt to retrieve a GPG public key from Keybase, importing if neccesary""" public_key = key_from_keybase(username) fingerprint = public_key['fingerprint'][-8:].upper().encode('ascii') key = public_key['bundle'].encode('ascii') if not has_gpg_key(fingerprint)...
python
def from_keybase(username): """Will attempt to retrieve a GPG public key from Keybase, importing if neccesary""" public_key = key_from_keybase(username) fingerprint = public_key['fingerprint'][-8:].upper().encode('ascii') key = public_key['bundle'].encode('ascii') if not has_gpg_key(fingerprint)...
[ "def", "from_keybase", "(", "username", ")", ":", "public_key", "=", "key_from_keybase", "(", "username", ")", "fingerprint", "=", "public_key", "[", "'fingerprint'", "]", "[", "-", "8", ":", "]", ".", "upper", "(", ")", ".", "encode", "(", "'ascii'", ")...
Will attempt to retrieve a GPG public key from Keybase, importing if neccesary
[ "Will", "attempt", "to", "retrieve", "a", "GPG", "public", "key", "from", "Keybase", "importing", "if", "neccesary" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L21-L32
Autodesk/aomi
aomi/filez.py
grok_keys
def grok_keys(config): """Will retrieve a GPG key from either Keybase or GPG directly""" key_ids = [] for key in config['pgp_keys']: if key.startswith('keybase:'): key_id = from_keybase(key[8:]) LOG.debug("Encrypting for keybase user %s", key[8:]) else: if...
python
def grok_keys(config): """Will retrieve a GPG key from either Keybase or GPG directly""" key_ids = [] for key in config['pgp_keys']: if key.startswith('keybase:'): key_id = from_keybase(key[8:]) LOG.debug("Encrypting for keybase user %s", key[8:]) else: if...
[ "def", "grok_keys", "(", "config", ")", ":", "key_ids", "=", "[", "]", "for", "key", "in", "config", "[", "'pgp_keys'", "]", ":", "if", "key", ".", "startswith", "(", "'keybase:'", ")", ":", "key_id", "=", "from_keybase", "(", "key", "[", "8", ":", ...
Will retrieve a GPG key from either Keybase or GPG directly
[ "Will", "retrieve", "a", "GPG", "key", "from", "either", "Keybase", "or", "GPG", "directly" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L35-L52
Autodesk/aomi
aomi/filez.py
freeze_archive
def freeze_archive(tmp_dir, dest_prefix): """Generates a ZIP file of secrets""" zip_filename = "%s/aomi-blah.zip" % tmp_dir archive = zipfile.ZipFile(zip_filename, 'w') for root, _dirnames, filenames in os.walk(dest_prefix): for filename in filenames: relative_path = subdir_path(root...
python
def freeze_archive(tmp_dir, dest_prefix): """Generates a ZIP file of secrets""" zip_filename = "%s/aomi-blah.zip" % tmp_dir archive = zipfile.ZipFile(zip_filename, 'w') for root, _dirnames, filenames in os.walk(dest_prefix): for filename in filenames: relative_path = subdir_path(root...
[ "def", "freeze_archive", "(", "tmp_dir", ",", "dest_prefix", ")", ":", "zip_filename", "=", "\"%s/aomi-blah.zip\"", "%", "tmp_dir", "archive", "=", "zipfile", ".", "ZipFile", "(", "zip_filename", ",", "'w'", ")", "for", "root", ",", "_dirnames", ",", "filename...
Generates a ZIP file of secrets
[ "Generates", "a", "ZIP", "file", "of", "secrets" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L55-L67
Autodesk/aomi
aomi/filez.py
freeze_encrypt
def freeze_encrypt(dest_dir, zip_filename, config, opt): """Encrypts the zip file""" pgp_keys = grok_keys(config) icefile_prefix = "aomi-%s" % \ os.path.basename(os.path.dirname(opt.secretfile)) if opt.icefile_prefix: icefile_prefix = opt.icefile_prefix timestamp = time...
python
def freeze_encrypt(dest_dir, zip_filename, config, opt): """Encrypts the zip file""" pgp_keys = grok_keys(config) icefile_prefix = "aomi-%s" % \ os.path.basename(os.path.dirname(opt.secretfile)) if opt.icefile_prefix: icefile_prefix = opt.icefile_prefix timestamp = time...
[ "def", "freeze_encrypt", "(", "dest_dir", ",", "zip_filename", ",", "config", ",", "opt", ")", ":", "pgp_keys", "=", "grok_keys", "(", "config", ")", "icefile_prefix", "=", "\"aomi-%s\"", "%", "os", ".", "path", ".", "basename", "(", "os", ".", "path", "...
Encrypts the zip file
[ "Encrypts", "the", "zip", "file" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L70-L84
Autodesk/aomi
aomi/filez.py
freeze
def freeze(dest_dir, opt): """Iterates over the Secretfile looking for secrets to freeze""" tmp_dir = ensure_tmpdir() dest_prefix = "%s/dest" % tmp_dir ensure_dir(dest_dir) ensure_dir(dest_prefix) config = get_secretfile(opt) Context.load(config, opt) \ .freeze(dest_prefix) zi...
python
def freeze(dest_dir, opt): """Iterates over the Secretfile looking for secrets to freeze""" tmp_dir = ensure_tmpdir() dest_prefix = "%s/dest" % tmp_dir ensure_dir(dest_dir) ensure_dir(dest_prefix) config = get_secretfile(opt) Context.load(config, opt) \ .freeze(dest_prefix) zi...
[ "def", "freeze", "(", "dest_dir", ",", "opt", ")", ":", "tmp_dir", "=", "ensure_tmpdir", "(", ")", "dest_prefix", "=", "\"%s/dest\"", "%", "tmp_dir", "ensure_dir", "(", "dest_dir", ")", "ensure_dir", "(", "dest_prefix", ")", "config", "=", "get_secretfile", ...
Iterates over the Secretfile looking for secrets to freeze
[ "Iterates", "over", "the", "Secretfile", "looking", "for", "secrets", "to", "freeze" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L87-L99
Autodesk/aomi
aomi/filez.py
thaw_decrypt
def thaw_decrypt(vault_client, src_file, tmp_dir, opt): """Decrypts the encrypted ice file""" if not os.path.isdir(opt.secrets): LOG.info("Creating secret directory %s", opt.secrets) os.mkdir(opt.secrets) zip_file = "%s/aomi.zip" % tmp_dir if opt.gpg_pass_path: gpg_path_bits =...
python
def thaw_decrypt(vault_client, src_file, tmp_dir, opt): """Decrypts the encrypted ice file""" if not os.path.isdir(opt.secrets): LOG.info("Creating secret directory %s", opt.secrets) os.mkdir(opt.secrets) zip_file = "%s/aomi.zip" % tmp_dir if opt.gpg_pass_path: gpg_path_bits =...
[ "def", "thaw_decrypt", "(", "vault_client", ",", "src_file", ",", "tmp_dir", ",", "opt", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "opt", ".", "secrets", ")", ":", "LOG", ".", "info", "(", "\"Creating secret directory %s\"", ",", "opt"...
Decrypts the encrypted ice file
[ "Decrypts", "the", "encrypted", "ice", "file" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L102-L132
Autodesk/aomi
aomi/filez.py
thaw
def thaw(vault_client, src_file, opt): """Given the combination of a Secretfile and the output of a freeze operation, will restore secrets to usable locations""" if not os.path.exists(src_file): raise aomi.exceptions.AomiFile("%s does not exist" % src_file) tmp_dir = ensure_tmpdir() zip_fil...
python
def thaw(vault_client, src_file, opt): """Given the combination of a Secretfile and the output of a freeze operation, will restore secrets to usable locations""" if not os.path.exists(src_file): raise aomi.exceptions.AomiFile("%s does not exist" % src_file) tmp_dir = ensure_tmpdir() zip_fil...
[ "def", "thaw", "(", "vault_client", ",", "src_file", ",", "opt", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "src_file", ")", ":", "raise", "aomi", ".", "exceptions", ".", "AomiFile", "(", "\"%s does not exist\"", "%", "src_file", ")", ...
Given the combination of a Secretfile and the output of a freeze operation, will restore secrets to usable locations
[ "Given", "the", "combination", "of", "a", "Secretfile", "and", "the", "output", "of", "a", "freeze", "operation", "will", "restore", "secrets", "to", "usable", "locations" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/filez.py#L135-L152
Autodesk/aomi
aomi/model/backend.py
VaultBackend.diff
def diff(self): """Determines if changes are needed for the Vault backend""" if not self.present: if self.existing: return DEL return NOOP is_diff = NOOP if self.present and self.existing: a_obj = self.config.copy() if se...
python
def diff(self): """Determines if changes are needed for the Vault backend""" if not self.present: if self.existing: return DEL return NOOP is_diff = NOOP if self.present and self.existing: a_obj = self.config.copy() if se...
[ "def", "diff", "(", "self", ")", ":", "if", "not", "self", ".", "present", ":", "if", "self", ".", "existing", ":", "return", "DEL", "return", "NOOP", "is_diff", "=", "NOOP", "if", "self", ".", "present", "and", "self", ".", "existing", ":", "a_obj",...
Determines if changes are needed for the Vault backend
[ "Determines", "if", "changes", "are", "needed", "for", "the", "Vault", "backend" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L62-L83
Autodesk/aomi
aomi/model/backend.py
VaultBackend.sync
def sync(self, vault_client): """Synchronizes the local and remote Vault resources. Has the net effect of adding backend if needed""" if self.present: if not self.existing: LOG.info("Mounting %s backend on %s", self.backend, self.path) ...
python
def sync(self, vault_client): """Synchronizes the local and remote Vault resources. Has the net effect of adding backend if needed""" if self.present: if not self.existing: LOG.info("Mounting %s backend on %s", self.backend, self.path) ...
[ "def", "sync", "(", "self", ",", "vault_client", ")", ":", "if", "self", ".", "present", ":", "if", "not", "self", ".", "existing", ":", "LOG", ".", "info", "(", "\"Mounting %s backend on %s\"", ",", "self", ".", "backend", ",", "self", ".", "path", ")...
Synchronizes the local and remote Vault resources. Has the net effect of adding backend if needed
[ "Synchronizes", "the", "local", "and", "remote", "Vault", "resources", ".", "Has", "the", "net", "effect", "of", "adding", "backend", "if", "needed" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L85-L106
Autodesk/aomi
aomi/model/backend.py
VaultBackend.sync_tunables
def sync_tunables(self, vault_client): """Synchtonizes any tunables we have set""" if not self.config: return a_prefix = self.tune_prefix if self.tune_prefix: a_prefix = "%s/" % self.tune_prefix v_path = "sys/mounts/%s%s/tune" % (a_prefix, self.path) ...
python
def sync_tunables(self, vault_client): """Synchtonizes any tunables we have set""" if not self.config: return a_prefix = self.tune_prefix if self.tune_prefix: a_prefix = "%s/" % self.tune_prefix v_path = "sys/mounts/%s%s/tune" % (a_prefix, self.path) ...
[ "def", "sync_tunables", "(", "self", ",", "vault_client", ")", ":", "if", "not", "self", ".", "config", ":", "return", "a_prefix", "=", "self", ".", "tune_prefix", "if", "self", ".", "tune_prefix", ":", "a_prefix", "=", "\"%s/\"", "%", "self", ".", "tune...
Synchtonizes any tunables we have set
[ "Synchtonizes", "any", "tunables", "we", "have", "set" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L108-L125
Autodesk/aomi
aomi/model/backend.py
VaultBackend.fetch
def fetch(self, vault_client, backends): """Updates local resource with context on whether this backend is actually mounted and available""" if not is_mounted(self.backend, self.path, backends) or \ self.tune_prefix is None: return backend_details = get_backend(se...
python
def fetch(self, vault_client, backends): """Updates local resource with context on whether this backend is actually mounted and available""" if not is_mounted(self.backend, self.path, backends) or \ self.tune_prefix is None: return backend_details = get_backend(se...
[ "def", "fetch", "(", "self", ",", "vault_client", ",", "backends", ")", ":", "if", "not", "is_mounted", "(", "self", ".", "backend", ",", "self", ".", "path", ",", "backends", ")", "or", "self", ".", "tune_prefix", "is", "None", ":", "return", "backend...
Updates local resource with context on whether this backend is actually mounted and available
[ "Updates", "local", "resource", "with", "context", "on", "whether", "this", "backend", "is", "actually", "mounted", "and", "available" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L127-L163
Autodesk/aomi
aomi/model/backend.py
VaultBackend.unmount
def unmount(self, client): """Unmounts a backend within Vault""" getattr(client, self.unmount_fun)(mount_point=self.path)
python
def unmount(self, client): """Unmounts a backend within Vault""" getattr(client, self.unmount_fun)(mount_point=self.path)
[ "def", "unmount", "(", "self", ",", "client", ")", ":", "getattr", "(", "client", ",", "self", ".", "unmount_fun", ")", "(", "mount_point", "=", "self", ".", "path", ")" ]
Unmounts a backend within Vault
[ "Unmounts", "a", "backend", "within", "Vault" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L165-L167
Autodesk/aomi
aomi/model/backend.py
VaultBackend.actually_mount
def actually_mount(self, client): """Actually mount something in Vault""" a_obj = self.config.copy() if 'description' in a_obj: del a_obj['description'] try: m_fun = getattr(client, self.mount_fun) if self.description and a_obj: m_fun(...
python
def actually_mount(self, client): """Actually mount something in Vault""" a_obj = self.config.copy() if 'description' in a_obj: del a_obj['description'] try: m_fun = getattr(client, self.mount_fun) if self.description and a_obj: m_fun(...
[ "def", "actually_mount", "(", "self", ",", "client", ")", ":", "a_obj", "=", "self", ".", "config", ".", "copy", "(", ")", "if", "'description'", "in", "a_obj", ":", "del", "a_obj", "[", "'description'", "]", "try", ":", "m_fun", "=", "getattr", "(", ...
Actually mount something in Vault
[ "Actually", "mount", "something", "in", "Vault" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/backend.py#L169-L200
Autodesk/aomi
aomi/model/resource.py
Resource.thaw
def thaw(self, tmp_dir): """Will perform some validation and copy a decrypted secret to it's final location""" for sfile in self.secrets(): src_file = "%s/%s" % (tmp_dir, sfile) err_msg = "%s secret missing from icefile" % (self) if not os.path.exists(src_file...
python
def thaw(self, tmp_dir): """Will perform some validation and copy a decrypted secret to it's final location""" for sfile in self.secrets(): src_file = "%s/%s" % (tmp_dir, sfile) err_msg = "%s secret missing from icefile" % (self) if not os.path.exists(src_file...
[ "def", "thaw", "(", "self", ",", "tmp_dir", ")", ":", "for", "sfile", "in", "self", ".", "secrets", "(", ")", ":", "src_file", "=", "\"%s/%s\"", "%", "(", "tmp_dir", ",", "sfile", ")", "err_msg", "=", "\"%s secret missing from icefile\"", "%", "(", "self...
Will perform some validation and copy a decrypted secret to it's final location
[ "Will", "perform", "some", "validation", "and", "copy", "a", "decrypted", "secret", "to", "it", "s", "final", "location" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L31-L51
Autodesk/aomi
aomi/model/resource.py
Resource.tunable
def tunable(self, obj): """A tunable resource maps against a backend...""" self.tune = dict() if 'tune' in obj: for tunable in MOUNT_TUNABLES: tunable_key = tunable[0] map_val(self.tune, obj['tune'], tunable_key) if tunable_key in self....
python
def tunable(self, obj): """A tunable resource maps against a backend...""" self.tune = dict() if 'tune' in obj: for tunable in MOUNT_TUNABLES: tunable_key = tunable[0] map_val(self.tune, obj['tune'], tunable_key) if tunable_key in self....
[ "def", "tunable", "(", "self", ",", "obj", ")", ":", "self", ".", "tune", "=", "dict", "(", ")", "if", "'tune'", "in", "obj", ":", "for", "tunable", "in", "MOUNT_TUNABLES", ":", "tunable_key", "=", "tunable", "[", "0", "]", "map_val", "(", "self", ...
A tunable resource maps against a backend...
[ "A", "tunable", "resource", "maps", "against", "a", "backend", "..." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L53-L66
Autodesk/aomi
aomi/model/resource.py
Resource.export_handle
def export_handle(self, directory): """Get a filehandle for exporting""" filename = getattr(self, 'filename') dest_file = "%s/%s" % (directory, filename) dest_dir = os.path.dirname(dest_file) if not os.path.isdir(dest_dir): os.mkdir(dest_dir, 0o700) return op...
python
def export_handle(self, directory): """Get a filehandle for exporting""" filename = getattr(self, 'filename') dest_file = "%s/%s" % (directory, filename) dest_dir = os.path.dirname(dest_file) if not os.path.isdir(dest_dir): os.mkdir(dest_dir, 0o700) return op...
[ "def", "export_handle", "(", "self", ",", "directory", ")", ":", "filename", "=", "getattr", "(", "self", ",", "'filename'", ")", "dest_file", "=", "\"%s/%s\"", "%", "(", "directory", ",", "filename", ")", "dest_dir", "=", "os", ".", "path", ".", "dirnam...
Get a filehandle for exporting
[ "Get", "a", "filehandle", "for", "exporting" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L68-L76
Autodesk/aomi
aomi/model/resource.py
Resource.export
def export(self, directory): """Export exportable resources decoding as needed""" if not self.existing or not hasattr(self, 'filename'): return secret_h = self.export_handle(directory) obj = self.existing if isinstance(obj, str): secret_h.write(obj) ...
python
def export(self, directory): """Export exportable resources decoding as needed""" if not self.existing or not hasattr(self, 'filename'): return secret_h = self.export_handle(directory) obj = self.existing if isinstance(obj, str): secret_h.write(obj) ...
[ "def", "export", "(", "self", ",", "directory", ")", ":", "if", "not", "self", ".", "existing", "or", "not", "hasattr", "(", "self", ",", "'filename'", ")", ":", "return", "secret_h", "=", "self", ".", "export_handle", "(", "directory", ")", "obj", "="...
Export exportable resources decoding as needed
[ "Export", "exportable", "resources", "decoding", "as", "needed" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L78-L88
Autodesk/aomi
aomi/model/resource.py
Resource.freeze
def freeze(self, tmp_dir): """Copies a secret into a particular location""" for sfile in self.secrets(): src_file = hard_path(sfile, self.opt.secrets) if not os.path.exists(src_file): raise aomi_excep.IceFile("%s secret not found at %s" % ...
python
def freeze(self, tmp_dir): """Copies a secret into a particular location""" for sfile in self.secrets(): src_file = hard_path(sfile, self.opt.secrets) if not os.path.exists(src_file): raise aomi_excep.IceFile("%s secret not found at %s" % ...
[ "def", "freeze", "(", "self", ",", "tmp_dir", ")", ":", "for", "sfile", "in", "self", ".", "secrets", "(", ")", ":", "src_file", "=", "hard_path", "(", "sfile", ",", "self", ".", "opt", ".", "secrets", ")", "if", "not", "os", ".", "path", ".", "e...
Copies a secret into a particular location
[ "Copies", "a", "secret", "into", "a", "particular", "location" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L90-L104
Autodesk/aomi
aomi/model/resource.py
Resource.grok_state
def grok_state(self, obj): """Determine the desired state of this resource based on data present""" if 'state' in obj: my_state = obj['state'].lower() if my_state != 'absent' and my_state != 'present': raise aomi_excep \ .Validation('st...
python
def grok_state(self, obj): """Determine the desired state of this resource based on data present""" if 'state' in obj: my_state = obj['state'].lower() if my_state != 'absent' and my_state != 'present': raise aomi_excep \ .Validation('st...
[ "def", "grok_state", "(", "self", ",", "obj", ")", ":", "if", "'state'", "in", "obj", ":", "my_state", "=", "obj", "[", "'state'", "]", ".", "lower", "(", ")", "if", "my_state", "!=", "'absent'", "and", "my_state", "!=", "'present'", ":", "raise", "a...
Determine the desired state of this resource based on data present
[ "Determine", "the", "desired", "state", "of", "this", "resource", "based", "on", "data", "present" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L110-L119
Autodesk/aomi
aomi/model/resource.py
Resource.validate
def validate(self, obj): """Base validation method. Will inspect class attributes to dermine just what should be present""" if 'tags' in obj and not isinstance(obj['tags'], list): raise aomi_excep.Validation('tags must be a list') if self.present: check_obj(self....
python
def validate(self, obj): """Base validation method. Will inspect class attributes to dermine just what should be present""" if 'tags' in obj and not isinstance(obj['tags'], list): raise aomi_excep.Validation('tags must be a list') if self.present: check_obj(self....
[ "def", "validate", "(", "self", ",", "obj", ")", ":", "if", "'tags'", "in", "obj", "and", "not", "isinstance", "(", "obj", "[", "'tags'", "]", ",", "list", ")", ":", "raise", "aomi_excep", ".", "Validation", "(", "'tags must be a list'", ")", "if", "se...
Base validation method. Will inspect class attributes to dermine just what should be present
[ "Base", "validation", "method", ".", "Will", "inspect", "class", "attributes", "to", "dermine", "just", "what", "should", "be", "present" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L121-L128
Autodesk/aomi
aomi/model/resource.py
Resource.diff
def diff(self, obj=None): """Determine if something has changed or not""" if self.no_resource: return NOOP if not self.present: if self.existing: return DEL return NOOP if not obj: obj = self.obj() is_diff = NOOP...
python
def diff(self, obj=None): """Determine if something has changed or not""" if self.no_resource: return NOOP if not self.present: if self.existing: return DEL return NOOP if not obj: obj = self.obj() is_diff = NOOP...
[ "def", "diff", "(", "self", ",", "obj", "=", "None", ")", ":", "if", "self", ".", "no_resource", ":", "return", "NOOP", "if", "not", "self", ".", "present", ":", "if", "self", ".", "existing", ":", "return", "DEL", "return", "NOOP", "if", "not", "o...
Determine if something has changed or not
[ "Determine", "if", "something", "has", "changed", "or", "not" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L158-L188
Autodesk/aomi
aomi/model/resource.py
Resource.fetch
def fetch(self, vault_client): """Populate internal representation of remote Vault resource contents""" result = self.read(vault_client) if result: if isinstance(result, dict) and 'data' in result: self.existing = result['data'] else: ...
python
def fetch(self, vault_client): """Populate internal representation of remote Vault resource contents""" result = self.read(vault_client) if result: if isinstance(result, dict) and 'data' in result: self.existing = result['data'] else: ...
[ "def", "fetch", "(", "self", ",", "vault_client", ")", ":", "result", "=", "self", ".", "read", "(", "vault_client", ")", "if", "result", ":", "if", "isinstance", "(", "result", ",", "dict", ")", "and", "'data'", "in", "result", ":", "self", ".", "ex...
Populate internal representation of remote Vault resource contents
[ "Populate", "internal", "representation", "of", "remote", "Vault", "resource", "contents" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L190-L200
Autodesk/aomi
aomi/model/resource.py
Resource.sync
def sync(self, vault_client): """Update remove Vault resource contents if needed""" if self.present and not self.existing: LOG.info("Writing new %s to %s", self.secret_format, self) self.write(vault_client) elif self.present and self.existing: ...
python
def sync(self, vault_client): """Update remove Vault resource contents if needed""" if self.present and not self.existing: LOG.info("Writing new %s to %s", self.secret_format, self) self.write(vault_client) elif self.present and self.existing: ...
[ "def", "sync", "(", "self", ",", "vault_client", ")", ":", "if", "self", ".", "present", "and", "not", "self", ".", "existing", ":", "LOG", ".", "info", "(", "\"Writing new %s to %s\"", ",", "self", ".", "secret_format", ",", "self", ")", "self", ".", ...
Update remove Vault resource contents if needed
[ "Update", "remove", "Vault", "resource", "contents", "if", "needed" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L202-L219
Autodesk/aomi
aomi/model/resource.py
Resource.filtered
def filtered(self): """Determines whether or not resource is filtered. Resources may be filtered if the tags do not match or the user has specified explict paths to include or exclude via command line options""" if not is_tagged(self.tags, self.opt.tags): LOG.info("Sk...
python
def filtered(self): """Determines whether or not resource is filtered. Resources may be filtered if the tags do not match or the user has specified explict paths to include or exclude via command line options""" if not is_tagged(self.tags, self.opt.tags): LOG.info("Sk...
[ "def", "filtered", "(", "self", ")", ":", "if", "not", "is_tagged", "(", "self", ".", "tags", ",", "self", ".", "opt", ".", "tags", ")", ":", "LOG", ".", "info", "(", "\"Skipping %s as it does not have requested tags\"", ",", "self", ".", "path", ")", "r...
Determines whether or not resource is filtered. Resources may be filtered if the tags do not match or the user has specified explict paths to include or exclude via command line options
[ "Determines", "whether", "or", "not", "resource", "is", "filtered", ".", "Resources", "may", "be", "filtered", "if", "the", "tags", "do", "not", "match", "or", "the", "user", "has", "specified", "explict", "paths", "to", "include", "or", "exclude", "via", ...
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L221-L236
Autodesk/aomi
aomi/model/resource.py
Resource.diff_write_only
def diff_write_only(resource): """A different implementation of diff that is used for those Vault resources that are write-only such as AWS root configs""" if resource.present and not resource.existing: return ADD elif not resource.present and resource.existing: ...
python
def diff_write_only(resource): """A different implementation of diff that is used for those Vault resources that are write-only such as AWS root configs""" if resource.present and not resource.existing: return ADD elif not resource.present and resource.existing: ...
[ "def", "diff_write_only", "(", "resource", ")", ":", "if", "resource", ".", "present", "and", "not", "resource", ".", "existing", ":", "return", "ADD", "elif", "not", "resource", ".", "present", "and", "resource", ".", "existing", ":", "return", "DEL", "el...
A different implementation of diff that is used for those Vault resources that are write-only such as AWS root configs
[ "A", "different", "implementation", "of", "diff", "that", "is", "used", "for", "those", "Vault", "resources", "that", "are", "write", "-", "only", "such", "as", "AWS", "root", "configs" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L239-L250
Autodesk/aomi
aomi/model/resource.py
Resource.read
def read(self, client): """Read from Vault while handling non surprising errors.""" val = None if self.no_resource: return val LOG.debug("Reading from %s", self) try: val = client.read(self.path) except hvac.exceptions.InvalidRequest as vault_exce...
python
def read(self, client): """Read from Vault while handling non surprising errors.""" val = None if self.no_resource: return val LOG.debug("Reading from %s", self) try: val = client.read(self.path) except hvac.exceptions.InvalidRequest as vault_exce...
[ "def", "read", "(", "self", ",", "client", ")", ":", "val", "=", "None", "if", "self", ".", "no_resource", ":", "return", "val", "LOG", ".", "debug", "(", "\"Reading from %s\"", ",", "self", ")", "try", ":", "val", "=", "client", ".", "read", "(", ...
Read from Vault while handling non surprising errors.
[ "Read", "from", "Vault", "while", "handling", "non", "surprising", "errors", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L253-L266
Autodesk/aomi
aomi/model/resource.py
Resource.write
def write(self, client): """Write to Vault while handling non-surprising errors.""" val = None if not self.no_resource: val = client.write(self.path, **self.obj()) return val
python
def write(self, client): """Write to Vault while handling non-surprising errors.""" val = None if not self.no_resource: val = client.write(self.path, **self.obj()) return val
[ "def", "write", "(", "self", ",", "client", ")", ":", "val", "=", "None", "if", "not", "self", ".", "no_resource", ":", "val", "=", "client", ".", "write", "(", "self", ".", "path", ",", "*", "*", "self", ".", "obj", "(", ")", ")", "return", "v...
Write to Vault while handling non-surprising errors.
[ "Write", "to", "Vault", "while", "handling", "non", "-", "surprising", "errors", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/model/resource.py#L269-L275
Autodesk/aomi
aomi/validation.py
find_file
def find_file(name, directory): """Searches up from a directory looking for a file""" path_bits = directory.split(os.sep) for i in range(0, len(path_bits) - 1): check_path = path_bits[0:len(path_bits) - i] check_file = "%s%s%s" % (os.sep.join(check_path), os.sep, name) if os.path.exi...
python
def find_file(name, directory): """Searches up from a directory looking for a file""" path_bits = directory.split(os.sep) for i in range(0, len(path_bits) - 1): check_path = path_bits[0:len(path_bits) - i] check_file = "%s%s%s" % (os.sep.join(check_path), os.sep, name) if os.path.exi...
[ "def", "find_file", "(", "name", ",", "directory", ")", ":", "path_bits", "=", "directory", ".", "split", "(", "os", ".", "sep", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "path_bits", ")", "-", "1", ")", ":", "check_path", "=", "...
Searches up from a directory looking for a file
[ "Searches", "up", "from", "a", "directory", "looking", "for", "a", "file" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L14-L23
Autodesk/aomi
aomi/validation.py
in_file
def in_file(string, search_file): """Looks in a file for a string.""" handle = open(search_file, 'r') for line in handle.readlines(): if string in line: return True return False
python
def in_file(string, search_file): """Looks in a file for a string.""" handle = open(search_file, 'r') for line in handle.readlines(): if string in line: return True return False
[ "def", "in_file", "(", "string", ",", "search_file", ")", ":", "handle", "=", "open", "(", "search_file", ",", "'r'", ")", "for", "line", "in", "handle", ".", "readlines", "(", ")", ":", "if", "string", "in", "line", ":", "return", "True", "return", ...
Looks in a file for a string.
[ "Looks", "in", "a", "file", "for", "a", "string", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L26-L33
Autodesk/aomi
aomi/validation.py
gitignore
def gitignore(opt): """Will check directories upwards from the Secretfile in order to ensure the gitignore file is set properly""" directory = os.path.dirname(abspath(opt.secretfile)) gitignore_file = find_file('.gitignore', directory) if gitignore_file: secrets_path = subdir_path(abspath(op...
python
def gitignore(opt): """Will check directories upwards from the Secretfile in order to ensure the gitignore file is set properly""" directory = os.path.dirname(abspath(opt.secretfile)) gitignore_file = find_file('.gitignore', directory) if gitignore_file: secrets_path = subdir_path(abspath(op...
[ "def", "gitignore", "(", "opt", ")", ":", "directory", "=", "os", ".", "path", ".", "dirname", "(", "abspath", "(", "opt", ".", "secretfile", ")", ")", "gitignore_file", "=", "find_file", "(", "'.gitignore'", ",", "directory", ")", "if", "gitignore_file", ...
Will check directories upwards from the Secretfile in order to ensure the gitignore file is set properly
[ "Will", "check", "directories", "upwards", "from", "the", "Secretfile", "in", "order", "to", "ensure", "the", "gitignore", "file", "is", "set", "properly" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L36-L52
Autodesk/aomi
aomi/validation.py
secret_file
def secret_file(filename): """Will check the permissions of things which really should be secret files""" filestat = os.stat(abspath(filename)) if stat.S_ISREG(filestat.st_mode) == 0 and \ stat.S_ISLNK(filestat.st_mode) == 0: e_msg = "Secret file %s must be a real file or symlink" % filen...
python
def secret_file(filename): """Will check the permissions of things which really should be secret files""" filestat = os.stat(abspath(filename)) if stat.S_ISREG(filestat.st_mode) == 0 and \ stat.S_ISLNK(filestat.st_mode) == 0: e_msg = "Secret file %s must be a real file or symlink" % filen...
[ "def", "secret_file", "(", "filename", ")", ":", "filestat", "=", "os", ".", "stat", "(", "abspath", "(", "filename", ")", ")", "if", "stat", ".", "S_ISREG", "(", "filestat", ".", "st_mode", ")", "==", "0", "and", "stat", ".", "S_ISLNK", "(", "filest...
Will check the permissions of things which really should be secret files
[ "Will", "check", "the", "permissions", "of", "things", "which", "really", "should", "be", "secret", "files" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L55-L69
Autodesk/aomi
aomi/validation.py
validate_obj
def validate_obj(keys, obj): """Super simple "object" validation.""" msg = '' for k in keys: if isinstance(k, str): if k not in obj or (not isinstance(obj[k], list) and not obj[k]): if msg: msg = "%s," % msg msg = "%s%s" % (msg, k) ...
python
def validate_obj(keys, obj): """Super simple "object" validation.""" msg = '' for k in keys: if isinstance(k, str): if k not in obj or (not isinstance(obj[k], list) and not obj[k]): if msg: msg = "%s," % msg msg = "%s%s" % (msg, k) ...
[ "def", "validate_obj", "(", "keys", ",", "obj", ")", ":", "msg", "=", "''", "for", "k", "in", "keys", ":", "if", "isinstance", "(", "k", ",", "str", ")", ":", "if", "k", "not", "in", "obj", "or", "(", "not", "isinstance", "(", "obj", "[", "k", ...
Super simple "object" validation.
[ "Super", "simple", "object", "validation", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L72-L97
Autodesk/aomi
aomi/validation.py
specific_path_check
def specific_path_check(path, opt): """Will make checks against include/exclude to determine if we actually care about the path in question.""" if opt.exclude: if path in opt.exclude: return False if opt.include: if path not in opt.include: return False retu...
python
def specific_path_check(path, opt): """Will make checks against include/exclude to determine if we actually care about the path in question.""" if opt.exclude: if path in opt.exclude: return False if opt.include: if path not in opt.include: return False retu...
[ "def", "specific_path_check", "(", "path", ",", "opt", ")", ":", "if", "opt", ".", "exclude", ":", "if", "path", "in", "opt", ".", "exclude", ":", "return", "False", "if", "opt", ".", "include", ":", "if", "path", "not", "in", "opt", ".", "include", ...
Will make checks against include/exclude to determine if we actually care about the path in question.
[ "Will", "make", "checks", "against", "include", "/", "exclude", "to", "determine", "if", "we", "actually", "care", "about", "the", "path", "in", "question", "." ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L100-L111
Autodesk/aomi
aomi/validation.py
check_obj
def check_obj(keys, name, obj): """Do basic validation on an object""" msg = validate_obj(keys, obj) if msg: raise aomi.exceptions.AomiData("object check : %s in %s" % (msg, name))
python
def check_obj(keys, name, obj): """Do basic validation on an object""" msg = validate_obj(keys, obj) if msg: raise aomi.exceptions.AomiData("object check : %s in %s" % (msg, name))
[ "def", "check_obj", "(", "keys", ",", "name", ",", "obj", ")", ":", "msg", "=", "validate_obj", "(", "keys", ",", "obj", ")", "if", "msg", ":", "raise", "aomi", ".", "exceptions", ".", "AomiData", "(", "\"object check : %s in %s\"", "%", "(", "msg", ",...
Do basic validation on an object
[ "Do", "basic", "validation", "on", "an", "object" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L114-L119
Autodesk/aomi
aomi/validation.py
sanitize_mount
def sanitize_mount(mount): """Returns a quote-unquote sanitized mount path""" sanitized_mount = mount if sanitized_mount.startswith('/'): sanitized_mount = sanitized_mount[1:] if sanitized_mount.endswith('/'): sanitized_mount = sanitized_mount[:-1] sanitized_mount = sanitized_mount...
python
def sanitize_mount(mount): """Returns a quote-unquote sanitized mount path""" sanitized_mount = mount if sanitized_mount.startswith('/'): sanitized_mount = sanitized_mount[1:] if sanitized_mount.endswith('/'): sanitized_mount = sanitized_mount[:-1] sanitized_mount = sanitized_mount...
[ "def", "sanitize_mount", "(", "mount", ")", ":", "sanitized_mount", "=", "mount", "if", "sanitized_mount", ".", "startswith", "(", "'/'", ")", ":", "sanitized_mount", "=", "sanitized_mount", "[", "1", ":", "]", "if", "sanitized_mount", ".", "endswith", "(", ...
Returns a quote-unquote sanitized mount path
[ "Returns", "a", "quote", "-", "unquote", "sanitized", "mount", "path" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L122-L132
Autodesk/aomi
aomi/validation.py
gpg_fingerprint
def gpg_fingerprint(key): """Validates a GPG key fingerprint This handles both pre and post GPG 2.1""" if (len(key) == 8 and re.match(r'^[0-9A-F]{8}$', key)) or \ (len(key) == 40 and re.match(r'^[0-9A-F]{40}$', key)): return raise aomi.exceptions.Validation('Invalid GPG Fingerprint')
python
def gpg_fingerprint(key): """Validates a GPG key fingerprint This handles both pre and post GPG 2.1""" if (len(key) == 8 and re.match(r'^[0-9A-F]{8}$', key)) or \ (len(key) == 40 and re.match(r'^[0-9A-F]{40}$', key)): return raise aomi.exceptions.Validation('Invalid GPG Fingerprint')
[ "def", "gpg_fingerprint", "(", "key", ")", ":", "if", "(", "len", "(", "key", ")", "==", "8", "and", "re", ".", "match", "(", "r'^[0-9A-F]{8}$'", ",", "key", ")", ")", "or", "(", "len", "(", "key", ")", "==", "40", "and", "re", ".", "match", "(...
Validates a GPG key fingerprint This handles both pre and post GPG 2.1
[ "Validates", "a", "GPG", "key", "fingerprint" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L135-L143
Autodesk/aomi
aomi/validation.py
is_unicode_string
def is_unicode_string(string): """Validates that we are some kinda unicode string""" try: if sys.version_info >= (3, 0): # isn't a python 3 str actually unicode if not isinstance(string, str): string.decode('utf-8') else: string.decode('utf-8'...
python
def is_unicode_string(string): """Validates that we are some kinda unicode string""" try: if sys.version_info >= (3, 0): # isn't a python 3 str actually unicode if not isinstance(string, str): string.decode('utf-8') else: string.decode('utf-8'...
[ "def", "is_unicode_string", "(", "string", ")", ":", "try", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "0", ")", ":", "# isn't a python 3 str actually unicode", "if", "not", "isinstance", "(", "string", ",", "str", ")", ":", "string", ".",...
Validates that we are some kinda unicode string
[ "Validates", "that", "we", "are", "some", "kinda", "unicode", "string" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L146-L157
Autodesk/aomi
aomi/validation.py
is_unicode
def is_unicode(string): """Validates that the object itself is some kinda string""" str_type = str(type(string)) if str_type.find('str') > 0 or str_type.find('unicode') > 0: return True return False
python
def is_unicode(string): """Validates that the object itself is some kinda string""" str_type = str(type(string)) if str_type.find('str') > 0 or str_type.find('unicode') > 0: return True return False
[ "def", "is_unicode", "(", "string", ")", ":", "str_type", "=", "str", "(", "type", "(", "string", ")", ")", "if", "str_type", ".", "find", "(", "'str'", ")", ">", "0", "or", "str_type", ".", "find", "(", "'unicode'", ")", ">", "0", ":", "return", ...
Validates that the object itself is some kinda string
[ "Validates", "that", "the", "object", "itself", "is", "some", "kinda", "string" ]
train
https://github.com/Autodesk/aomi/blob/84da2dfb0424837adf9c4ddc1aa352e942bb7a4a/aomi/validation.py#L160-L167
Chilipp/docrep
docrep/__init__.py
safe_modulo
def safe_modulo(s, meta, checked='', print_warning=True, stacklevel=2): """Safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checke...
python
def safe_modulo(s, meta, checked='', print_warning=True, stacklevel=2): """Safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checke...
[ "def", "safe_modulo", "(", "s", ",", "meta", ",", "checked", "=", "''", ",", "print_warning", "=", "True", ",", "stacklevel", "=", "2", ")", ":", "try", ":", "return", "s", "%", "meta", "except", "(", "ValueError", ",", "TypeError", ",", "KeyError", ...
Safe version of the modulo operation (%) of strings Parameters ---------- s: str string to apply the modulo operation with meta: dict or tuple meta informations to insert (usually via ``s % meta``) checked: {'KEY', 'VALUE'}, optional Security parameter for the recursive stru...
[ "Safe", "version", "of", "the", "modulo", "operation", "(", "%", ")", "of", "strings" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L45-L105
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_sections
def get_sections(self, s, base, sections=['Parameters', 'Other Parameters']): """ Method that extracts the specified sections out of the given string if (and only if) the docstring follows the numpy documentation guidelines [1]_. Note that the section either must app...
python
def get_sections(self, s, base, sections=['Parameters', 'Other Parameters']): """ Method that extracts the specified sections out of the given string if (and only if) the docstring follows the numpy documentation guidelines [1]_. Note that the section either must app...
[ "def", "get_sections", "(", "self", ",", "s", ",", "base", ",", "sections", "=", "[", "'Parameters'", ",", "'Other Parameters'", "]", ")", ":", "params", "=", "self", ".", "params", "# Remove the summary and dedent the rest", "s", "=", "self", ".", "_remove_su...
Method that extracts the specified sections out of the given string if (and only if) the docstring follows the numpy documentation guidelines [1]_. Note that the section either must appear in the :attr:`param_like_sections` or the :attr:`text_sections` attribute. Parameters ----...
[ "Method", "that", "extracts", "the", "specified", "sections", "out", "of", "the", "given", "string", "if", "(", "and", "only", "if", ")", "the", "docstring", "follows", "the", "numpy", "documentation", "guidelines", "[", "1", "]", "_", ".", "Note", "that",...
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L289-L330
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.get_sectionsf
def get_sectionsf(self, *args, **kwargs): """ Decorator method to extract sections from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_sections` method. Note, that the first argument will be the docstring of the s...
python
def get_sectionsf(self, *args, **kwargs): """ Decorator method to extract sections from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_sections` method. Note, that the first argument will be the docstring of the s...
[ "def", "get_sectionsf", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "func", "(", "f", ")", ":", "doc", "=", "f", ".", "__doc__", "self", ".", "get_sections", "(", "doc", "or", "''", ",", "*", "args", ",", "*", "*", ...
Decorator method to extract sections from a function docstring Parameters ---------- ``*args`` and ``**kwargs`` See the :meth:`get_sections` method. Note, that the first argument will be the docstring of the specified function Returns ------- fun...
[ "Decorator", "method", "to", "extract", "sections", "from", "a", "function", "docstring" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L350-L369
Chilipp/docrep
docrep/__init__.py
DocstringProcessor._set_object_doc
def _set_object_doc(self, obj, doc, stacklevel=3): """Convenience method to set the __doc__ attribute of a python object """ if isinstance(obj, types.MethodType) and six.PY2: obj = obj.im_func try: obj.__doc__ = doc except AttributeError: # probably pytho...
python
def _set_object_doc(self, obj, doc, stacklevel=3): """Convenience method to set the __doc__ attribute of a python object """ if isinstance(obj, types.MethodType) and six.PY2: obj = obj.im_func try: obj.__doc__ = doc except AttributeError: # probably pytho...
[ "def", "_set_object_doc", "(", "self", ",", "obj", ",", "doc", ",", "stacklevel", "=", "3", ")", ":", "if", "isinstance", "(", "obj", ",", "types", ".", "MethodType", ")", "and", "six", ".", "PY2", ":", "obj", "=", "obj", ".", "im_func", "try", ":"...
Convenience method to set the __doc__ attribute of a python object
[ "Convenience", "method", "to", "set", "the", "__doc__", "attribute", "of", "a", "python", "object" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L371-L386
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.dedent
def dedent(self, func): """ Dedent the docstring of a function and substitute with :attr:`params` Parameters ---------- func: function function with the documentation to dedent and whose sections shall be inserted from the :attr:`params` attribute""" ...
python
def dedent(self, func): """ Dedent the docstring of a function and substitute with :attr:`params` Parameters ---------- func: function function with the documentation to dedent and whose sections shall be inserted from the :attr:`params` attribute""" ...
[ "def", "dedent", "(", "self", ",", "func", ")", ":", "doc", "=", "func", ".", "__doc__", "and", "self", ".", "dedents", "(", "func", ".", "__doc__", ",", "stacklevel", "=", "4", ")", "return", "self", ".", "_set_object_doc", "(", "func", ",", "doc", ...
Dedent the docstring of a function and substitute with :attr:`params` Parameters ---------- func: function function with the documentation to dedent and whose sections shall be inserted from the :attr:`params` attribute
[ "Dedent", "the", "docstring", "of", "a", "function", "and", "substitute", "with", ":", "attr", ":", "params" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L388-L398
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.dedents
def dedents(self, s, stacklevel=3): """ Dedent a string and substitute with the :attr:`params` attribute Parameters ---------- s: str string to dedent and insert the sections of the :attr:`params` attribute stacklevel: int The stacklev...
python
def dedents(self, s, stacklevel=3): """ Dedent a string and substitute with the :attr:`params` attribute Parameters ---------- s: str string to dedent and insert the sections of the :attr:`params` attribute stacklevel: int The stacklev...
[ "def", "dedents", "(", "self", ",", "s", ",", "stacklevel", "=", "3", ")", ":", "s", "=", "dedents", "(", "s", ")", "return", "safe_modulo", "(", "s", ",", "self", ".", "params", ",", "stacklevel", "=", "stacklevel", ")" ]
Dedent a string and substitute with the :attr:`params` attribute Parameters ---------- s: str string to dedent and insert the sections of the :attr:`params` attribute stacklevel: int The stacklevel for the warning raised in :func:`safe_module` when ...
[ "Dedent", "a", "string", "and", "substitute", "with", "the", ":", "attr", ":", "params", "attribute" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L400-L413
Chilipp/docrep
docrep/__init__.py
DocstringProcessor.with_indent
def with_indent(self, indent=0): """ Substitute in the docstring of a function with indented :attr:`params` Parameters ---------- indent: int The number of spaces that the substitution should be indented Returns ------- function W...
python
def with_indent(self, indent=0): """ Substitute in the docstring of a function with indented :attr:`params` Parameters ---------- indent: int The number of spaces that the substitution should be indented Returns ------- function W...
[ "def", "with_indent", "(", "self", ",", "indent", "=", "0", ")", ":", "def", "replace", "(", "func", ")", ":", "doc", "=", "func", ".", "__doc__", "and", "self", ".", "with_indents", "(", "func", ".", "__doc__", ",", "indent", "=", "indent", ",", "...
Substitute in the docstring of a function with indented :attr:`params` Parameters ---------- indent: int The number of spaces that the substitution should be indented Returns ------- function Wrapper that takes a function as input and substitutes...
[ "Substitute", "in", "the", "docstring", "of", "a", "function", "with", "indented", ":", "attr", ":", "params" ]
train
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L415-L437