<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def restore(self):
 """use the self.directory to restore a db NOTE -- this will only restore a database dumped with one of the methods of this class """

        sql_files = []
        for root, dirs, files in os.walk(self.directory):
            for f in files:
                if f.endswith(".sql.gz"):
                    path = os.path.join(self.directory, f)
                    self._run_cmd(["gunzip", path])
                    sql_files.append(f.rstrip(".gz"))

                elif f.endswith('.sql'):
                    sql_files.append(f)

        sql_files.sort() # we want to go in the order the tables were dumped
        r = re.compile('\d{3,}_([^\.]+)')
        for f in sql_files:
            path = os.path.join(self.directory, f)
            m = r.match(f)
            if m:
                table = m.group(1)
                logger.info('------- restoring table {}'.format(table))

                #psql_args = self._get_args('psql', '-X', '--echo-queries', '-f {}'.format(path))
                psql_args = self._get_args('psql', '-X', '--quiet', '--file={}'.format(path))
                self._run_cmd(psql_args)

                logger.info('------- restored table {}'.format(table))

        return True