clean up some style
This commit is contained in:
parent
1f1cd4c394
commit
18ac819707
1 changed files with 43 additions and 21 deletions
|
@ -327,7 +327,7 @@ class NextcloudHandler:
|
||||||
)[0].firstChild.data
|
)[0].firstChild.data
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
# I guess it's folder, because it has no content_type
|
# (markuman) I guess it's folder, because it has no content_type
|
||||||
return {
|
return {
|
||||||
'last_modified': dom.getElementsByTagName(
|
'last_modified': dom.getElementsByTagName(
|
||||||
'd:getlastmodified'
|
'd:getlastmodified'
|
||||||
|
@ -471,6 +471,7 @@ class NextcloudHandler:
|
||||||
"error": error
|
"error": error
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def request_passwords_session(self):
|
def request_passwords_session(self):
|
||||||
'''Request a Passwords API session'''
|
'''Request a Passwords API session'''
|
||||||
|
@ -500,6 +501,7 @@ class NextcloudHandler:
|
||||||
"password_hash": password_hash
|
"password_hash": password_hash
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def close_passwords_session(self):
|
def close_passwords_session(self):
|
||||||
'''Close Passwords API session'''
|
'''Close Passwords API session'''
|
||||||
|
@ -550,7 +552,6 @@ class NextcloudHandler:
|
||||||
)
|
)
|
||||||
if r.status_code == 201:
|
if r.status_code == 201:
|
||||||
return r.json()
|
return r.json()
|
||||||
else:
|
|
||||||
self.error(
|
self.error(
|
||||||
{
|
{
|
||||||
"action": "delete_passwords_folder",
|
"action": "delete_passwords_folder",
|
||||||
|
@ -566,6 +567,7 @@ class NextcloudHandler:
|
||||||
"folder_name": name
|
"folder_name": name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def exists_passwords_folder(self, name):
|
def exists_passwords_folder(self, name):
|
||||||
'''Test if a passwords folder exists'''
|
'''Test if a passwords folder exists'''
|
||||||
|
@ -592,7 +594,6 @@ class NextcloudHandler:
|
||||||
|
|
||||||
if r.status_code == 201:
|
if r.status_code == 201:
|
||||||
return r.json()
|
return r.json()
|
||||||
else:
|
|
||||||
self.error(
|
self.error(
|
||||||
{
|
{
|
||||||
"action": "create_passwords_folder",
|
"action": "create_passwords_folder",
|
||||||
|
@ -608,6 +609,7 @@ class NextcloudHandler:
|
||||||
"folder_name": name
|
"folder_name": name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def get_passwords_folder(self, name):
|
def get_passwords_folder(self, name):
|
||||||
'''Get Passwords folder'''
|
'''Get Passwords folder'''
|
||||||
|
@ -717,6 +719,7 @@ class NextcloudHandler:
|
||||||
"label": post_obj['label']
|
"label": post_obj['label']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def delete_password(self, post_obj):
|
def delete_password(self, post_obj):
|
||||||
'''Delete a password'''
|
'''Delete a password'''
|
||||||
|
@ -745,6 +748,7 @@ class NextcloudHandler:
|
||||||
"error": error,
|
"error": error,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def update_password(self, post_obj):
|
def update_password(self, post_obj):
|
||||||
|
@ -776,6 +780,7 @@ class NextcloudHandler:
|
||||||
"error": error,
|
"error": error,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def is_same_key(self, key, dict1, dict2):
|
def is_same_key(self, key, dict1, dict2):
|
||||||
'''Test if two dictionaries have the same key with the same value'''
|
'''Test if two dictionaries have the same key with the same value'''
|
||||||
|
@ -790,12 +795,24 @@ class NextcloudHandler:
|
||||||
safer_obj2 = dict(obj2, **{ 'password': '***' })
|
safer_obj2 = dict(obj2, **{ 'password': '***' })
|
||||||
if obj1 == obj2:
|
if obj1 == obj2:
|
||||||
self.debug(
|
self.debug(
|
||||||
{"action": "notify_exact_match", "object": { "obj1": safer_obj1, "obj2": safer_obj2 } }
|
{
|
||||||
|
"action": "notify_exact_match",
|
||||||
|
"object": {
|
||||||
|
"obj1": safer_obj1,
|
||||||
|
"obj2": safer_obj2
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
if obj1['label'] == obj2['label']:
|
if obj1['label'] == obj2['label']:
|
||||||
self.debug(
|
self.debug(
|
||||||
{ "action": "notify_name_match", "object": { "obj1": safer_obj1, "obj2": safer_obj2 } }
|
{
|
||||||
|
"action": "notify_name_match",
|
||||||
|
"object": {
|
||||||
|
"obj1": safer_obj1,
|
||||||
|
"obj2": safer_obj2
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
self.is_same_key('username', obj1, obj2) and
|
self.is_same_key('username', obj1, obj2) and
|
||||||
|
@ -917,6 +934,7 @@ class NcPasswordClient:
|
||||||
"object": name
|
"object": name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def create_passwords_folder(self, name):
|
def create_passwords_folder(self, name):
|
||||||
'''Create a passwords folder'''
|
'''Create a passwords folder'''
|
||||||
|
@ -968,7 +986,10 @@ class NcPasswordClient:
|
||||||
)
|
)
|
||||||
if answer != "Y":
|
if answer != "Y":
|
||||||
self.info(
|
self.info(
|
||||||
{ "action": "delete_all_passwords", "message": "Aborting after answering something different from 'Y'" }
|
{
|
||||||
|
"action": "delete_all_passwords",
|
||||||
|
"message": "Aborting after answering something different from 'Y'"
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
for item in self.nc.list_passwords():
|
for item in self.nc.list_passwords():
|
||||||
|
@ -981,6 +1002,7 @@ class NcPasswordClient:
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.nc.delete_password(item)
|
self.nc.delete_password(item)
|
||||||
|
return True
|
||||||
|
|
||||||
def remove_duplicates(self):
|
def remove_duplicates(self):
|
||||||
'''Remove duplicate passwords'''
|
'''Remove duplicate passwords'''
|
||||||
|
|
Loading…
Reference in a new issue