def get_tree(self):
     """Returns the full xml tree.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.tree
 def close_database(self):
     """*DEPRECATED in KeePassLibrary 0.3.0*, Use `Close Keepass Database` instead.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         self.database = None
 def save(self, filename=None, transformed_key=None):
     """*DEPRECATED in KeePassLibrary 0.3.0*, Use `Save Keepass Database` instead.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         self.database.save(filename, transformed_key)
Beispiel #4
0
    def get_entries_by_string(self,
                              string,
                              regex=False,
                              flags=None,
                              group=None,
                              history=False,
                              first=False):
        """Return a list of entries in the open KeePass database matching the given ``string``.\n

           See `Get Entries` for more details about optional arguments.
           
           Example:
           | &{string}= | Create Dictionary | UserName=foobar_user | Title=group_entry |  
           
           Valid dictonary keys:
           | Title |
           | UserName |
           | Password |
           | URL |
           | Notes |
           | IconID |
           | Tags |
           | History |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            return self.database.find_entries_by_string(
                string, regex, flags, group, history, first)
 def close_keepass_database(self):
     """Closes the currently open KeePass database.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         self.database = None
 def get_root_group(self):
     """Returns the root group.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.root_group
 def get_kdf_algorithm(self):
     """Returns the key transformation algorithm used. 
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.kdf_algorithm
 def get_transformed_key(self):
     """Returns the transformed key.
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.transformed_key
 def get_encryption_algorithm(self):
     """Returns the encryption algorithm used. 
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.encryption_algorithm
    def get_groups(self, recursive=True, path=None, group=None, **kwargs):
        """Return a list of groups in the open KeePass database matching the given arguments

           The ``recursive`` argument can be set ``True`` this enables recursive searching, default value is False.\n
           The ``path`` argument sets the path which the groups should match, default value is None.\n 
           The ``group`` argument has to match an existing Group is supplied only entries which are a direct child will be searched, default value is None. See ``Get Groups`` for information about selecting a group \n 
           See the `Entries and Groups` section for more information about Entries and Groups.\n        

           *Additional arguments:*
           - The ``history`` argument can be set to ``True`` to include history groups in the search, default value is False.
           - The ``first`` argument can be set ``True`` this has the effect that only the first match will be returned, default value is False.
           - The ``regex`` argument can be set to ``True`` this enables regular expression searching, default value is False.
           - The ``flags`` argument can be set to modify the regular expression search, default value is None. See the `Regular expression` section for more information about about the ``regex`` and ``flags`` syntax.
           - The ``name`` argument can be given to search matching names, default value is None.
           - The ``notes`` argument sets the notes which the groups should match, default value is None.
           - The ``uuid`` argument sets the uuid which the groups should match, default value is None.
 
           Example:
           | @{groups}= | `Get Groups` | name=.*group | notes=^.{0}$ | regex=True |
           | ${groups}= | `Get Groups` | name=.*group | notes=^.{0}$ | regex=True | first=True |

           | ${group}=   | `Get Groups By Name` | subgroup  | first=True     |   
           | @{groups}= |  `Get Groups`         | subgroup2 | group=${group} |             
        """ 
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            if 'regex' in kwargs:
                kwargs['regex'] = is_truthy(kwargs['regex'])
            if 'first' in kwargs:
                kwargs['first'] = is_truthy(kwargs['first'])    
            return self.database.find_groups(recursive, path, group, **kwargs)
 def get_version(self):
     """Returns the version of the KeePass database loaded with `Load Database`
     | =Return=   | =Description= |
     | ``(3, 1)`` | KDBX v3       |
     | ``(4, 0)`` | KDBX v4       |
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.version
    def dump_xml(self, outfile):
        """Dump the content of the database to a xml file.
           NOTE: The resulting file is unencrypted!

        | =Parameter= | =Description=                        |
        | ``outfile`` | specifies the path of the dumped xml |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            self.database.dump_xml(outfile)
    def save_keepass_database(self, filename=None, transformed_key=None):
        """Save the content of the currently open KeePass database.

        | =Parameter=        | =Description=                              |
        | ``filename``       | specifies the path of the KeePass database |
        | ``tranformed_key`` | specifies the location of the keyfile      |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            self.database.save(filename, transformed_key)
Beispiel #14
0
 def get_entries_all(self):
     """Return a list of all entries in the open KeePass database.\n
        
        See the `Entries and Groups` section for more information about Entries and Groups.\n 
        
        Example:
        | ${entries} = | `Get Entries All` | 
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_entries_by_title('.*', regex=True)
 def get_groups_all(self):
     """Return a list of all groups in the open KeePass database.
     
        See the `Entries and Groups` section for more information about Entries and Groups.\n  
     
        Example:
        | ${groups} = | Get Groups All | 
     """ 
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_groups_by_name('.*', 
                                                  regex=True)
Beispiel #16
0
    def get_entries(self,
                    history=False,
                    first=False,
                    recursive=True,
                    path=None,
                    group=None,
                    **kwargs):
        """Return a list of entries in the open KeePass database matching the given arguments.\n
  
           The ``history`` argument can be set to ``True`` to include history entries in the search, default value is False.\n
           The ``first`` argument can be set ``True`` this has the effect that only the first match will be returned, default value is False.\n
           The ``recursive`` argument can be set ``True`` this enables recursive searching, default value is False.\n
           The ``path`` argument sets the path which the entries should match, default value is None.\n 
           The ``group`` argument has to match an existing Group is supplied only entries which are a direct child will be searched, default value is None. See ``Get Groups`` for information about selecting a group \n 
           See the `Entries and Groups` section for more information about Entries and Groups.\n        

           *Additional arguments:*
           - The ``regex`` argument can be set to ``True`` this enables regular expression searching, default value is False.
           - The ``flags`` argument can be set to modify the regular expression search, default value is None. See the `Regular expression` section for more information about about the ``regex`` and ``flags`` syntax.
           - The ``title`` argument can be given to search matching titles, default value is None.
           - The ``username`` argument sets the username which the entries should match, default value is None.
           - The ``password`` argument sets the password which the entries should match, default value is None.
           - The ``url`` argument sets the url which the entries should match, default value is None.
           - The ``notes`` argument sets the notes which the entries should match, default value is None.
           - The ``uuid`` argument sets the uuid which the entries should match, default value is None.
  
           Examples:
           | @{entries}= | `Get Entries` | title=.*entry | regex=True |
           | ${entry}=   | `Get Entries` | title=.*entry | regex=True | first=True |
           | @{entries}= | `Get Entries` | title=.*entry | username=.*user     | regex=True |
           | @{entries}= | `Get Entries` | title=.*entry | notes=.*entry notes | regex=True |
           
           | ${group}=   | Get Groups By Name      | subgroup | first=True |   
           | ${entries}= | Get Entries By Username | foobar   | group=${group} | first=True |     
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            if 'regex' in kwargs:
                kwargs['regex'] = is_truthy(kwargs['regex'])
            return self.database.find_entries(recursive=recursive,
                                              path=path,
                                              group=group,
                                              history=history,
                                              first=first,
                                              **kwargs)
 def get_groups_by_path(self, group_path_str=None, regex=False, flags=None,
                         group=None, first=False):
     """Return a list of groups in the open KeePass database
        matching the given path
        
        See `Get Groups` for more details about optional arguments.
        
        Example:
        | ${groups} = | Get Groups By Path | foobar_group/subgroup |
     """  
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_groups_by_path(group_path_str=group_path_str,
                                                  regex=regex,
                                                  flags=flags,
                                                  group=group,
                                                  first=first)
 def get_groups_by_name(self, group_name, regex=False, flags=None,
                         group=None, first=False):
     """Return a list of groups in the open KeePass database
        matching the given string
        
        See `Get Groups` for more details about optional arguments.
        
        Examples:
        | ${groups} = | Get Groups By Name | subgroup |
        | ${groups} = | Get Groups By Name | .* | regex=True |
     """  
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_groups_by_name(group_name=group_name,
                                                  regex=regex,
                                                  flags=flags,
                                                  group=group,
                                                  first=first)
Beispiel #19
0
    def get_entries_by_username(self,
                                username,
                                regex=False,
                                flags=None,
                                group=None,
                                history=False,
                                first=False):
        """Return a list of entries in the open KeePass database matching the given ``username``.\n
           
           See `Get Entries` for more details about optional arguments.

           Example:
           | @{entries} = | `Get Entries By Username` | foobar_user |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            return self.database.find_entries_by_username(
                username, regex, flags, group, history, first)
 def get_groups_by_notes(self, notes, regex=False, flags=None,
                           group=None, history=False, first=False):
     """Return a list of groups in the open KeePass database
        matching the given notes
 
        See `Get Groups` for more details about optional arguments.
 
        Example:
        | ${groups} = | Get Groups By Notes | group notes |
     """ 
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_groups_by_notes(notes=notes,
                                                   regex=regex,
                                                   flags=flags,
                                                   group=group,
                                                   history=history,
                                                   first=first)
Beispiel #21
0
    def get_entries_by_uuid(self,
                            uuid,
                            regex=False,
                            flags=None,
                            group=None,
                            history=False,
                            first=False):
        """Return a list of entries in the open KeePass database matching the given ``uuid``.\n

           See `Get Entries` for more details about optional arguments.

           Example:
           | ${entries} = | Get Entries By Uuid | 12345678-1234-5678-1234-567812345678 |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            uuid = UUID('urn:uuid:' + uuid)
            return self.database.find_entries_by_uuid(uuid, regex, flags,
                                                      group, history, first)
Beispiel #22
0
    def get_entries_by_path(self,
                            path,
                            regex=False,
                            flags=None,
                            group=None,
                            history=False,
                            first=False):
        """Return a list of entries in the open KeePass database matching the given ``path``.\n

           See `Get Entries` for more details about optional arguments.
           
           Note, only 1 entry can be selected by path
             
           Example:
           | ${entry} = | Get Entries By Path | foobar_group/group_entry |
        """
        if self.database is None:
            raise DatabaseNotLoaded('No KeePass Database loaded.')
        else:
            return self.database.find_entries_by_path(path, regex, flags,
                                                      group, history, first)
Beispiel #23
0
 def get_entries_by_title(self,
                          title,
                          regex=False,
                          flags=None,
                          group=None,
                          history=False,
                          first=False):
     """Return a list of entries in the open KeePass database matching the given ``title``.\n
     
        See `Get Entries` for more details about optional arguments.         
     
        Example:
        | @{entries} = | `Get Entries By Title` | root_entry |
        => all entries with title: root_entry
     
        | ${entry} =   | `Get Entries By Title` | root_entry | first=True |
        => first entry with title: root_entry
     """
     if self.database is None:
         raise DatabaseNotLoaded('No KeePass Database loaded.')
     else:
         return self.database.find_entries_by_title(title, regex, flags,
                                                    group, history, first)