mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
parent
f12c6e0946
commit
72bdf7aa7e
6 changed files with 41 additions and 41 deletions
|
@ -60,18 +60,18 @@ class BaseInventoryPlugin(object):
|
|||
def verify_file(self, path):
|
||||
''' Verify if file is usable by this plugin, base does minimal accessability check '''
|
||||
|
||||
b_path = to_bytes(path)
|
||||
b_path = to_bytes(path, errors='surrogate_or_strict')
|
||||
return (os.path.exists(b_path) and os.access(b_path, os.R_OK))
|
||||
|
||||
def get_cache_prefix(self, path):
|
||||
''' create predictable unique prefix for plugin/inventory '''
|
||||
|
||||
m = hashlib.sha1()
|
||||
m.update(to_bytes(self.NAME))
|
||||
m.update(to_bytes(self.NAME, errors='surrogate_or_strict'))
|
||||
d1 = m.hexdigest()
|
||||
|
||||
n = hashlib.sha1()
|
||||
n.update(to_bytes(path))
|
||||
n.update(to_bytes(path, errors='surrogate_or_strict'))
|
||||
d2 = n.hexdigest()
|
||||
|
||||
return 's_'.join([d1[:5], d2[:5]])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue