implement delete

update checks
password sha256 digest used from hashlib
This commit is contained in:
r4sas
2017-02-21 16:33:03 +03:00
parent cdf2544da7
commit 421e287679
5 changed files with 111 additions and 35 deletions

View File

@@ -1,20 +1,23 @@
"""Various code"""
import json
import os
class PBinCLIException(Exception):
pass
def check_readable(f):
"""Checks if path exists and readable"""
if not os.path.exists(f) or not os.access(f, os.R_OK):
raise PBinCLIException("Error accessing path: {}".format(f))
def check_writable(f):
"""Checks if path is writable"""
if not os.access(os.path.dirname(f) or ".", os.W_OK):
raise PBinCLIException("Path is not writable: {}".format(f))
"""http://stackoverflow.com/a/33571117"""
def json_load_byteified(file_handle):
return _byteify(
@@ -22,12 +25,14 @@ def json_load_byteified(file_handle):
ignore_dicts=True
)
def json_loads_byteified(json_text):
return _byteify(
json.loads(json_text, object_hook=_byteify),
ignore_dicts=True
)
def _byteify(data, ignore_dicts = False):
# if this is a unicode string, return its string representation
if isinstance(data, unicode):