示例#1
0
 def read_password_data_from_file(self, filename):
     """ Open a password file, load passwords and read metadata               """
     ##############################################################################
     try:
         with open(filename, 'r') as fname:
             password_data = yaml.safe_load(fname)
             password_entry = PasswordEntry()
             password_entry.metadata = password_data['metadata']
             password_entry.recipients = password_data['recipients']
             if 'escrow' in password_data:
                 password_entry.escrow = password_data['escrow']
         password_entry.validate()
         return password_entry
     except (OSError, IOError, TypeError):
         raise PasswordIOError(
             "Error reading '%s' perhaps a path error for the db, or malformed file"
             % filename)
示例#2
0
文件: passworddb.py 项目: olcf/pkpass
 def read_password_data_from_file(self, filename):
     ####################################################################
     """Open a password file, load passwords and read metadata"""
     ####################################################################
     try:
         with open(filename, "r", encoding="ASCII") as fname:
             password_data = safe_load(fname)
             password_entry = PasswordEntry()
             password_entry.metadata = password_data["metadata"]
             password_entry.recipients = password_data["recipients"]
             if "escrow" in password_data:
                 password_entry.escrow = password_data["escrow"]
         password_entry.validate()
         return password_entry
     except (OSError, IOError, TypeError) as err:
         raise PasswordIOError(
             f"Error reading '{filename}' perhaps a path error for the db, or malformed file"
         ) from err