<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def merge_pot1_files(self, delete_source=True):
 """ This method is called when all the q-points have been computed. It runs `mrgdvdb` in sequential on the local machine to produce the final DVDB file in the outdir of the `Work`. Args: delete_source: True if POT1 files should be removed after (successful) merge. Returns: path to the output DVDB file. None if not DFPT POT file is found. """

        natom = len(self[0].input.structure)
        max_pertcase = 3 * natom

        pot1_files = []
        for task in self:
            if not isinstance(task, DfptTask): continue
            paths = task.outdir.list_filepaths(wildcard="*_POT*")
            for path in paths:
                # Include only atomic perturbations i.e. files whose ext <= 3 * natom
                i = path.rindex("_POT")
                pertcase = int(path[i+4:].replace(".nc", ""))
                if pertcase <= max_pertcase:
                    pot1_files.append(path)

        # prtpot = 0 disables the output of the DFPT POT files so an empty list is not fatal here.
        if not pot1_files: return None

        self.history.info("Will call mrgdvdb to merge %s files:" % len(pot1_files))

        # Final DDB file will be produced in the outdir of the work.
        out_dvdb = self.outdir.path_in("out_DVDB")

        if len(pot1_files) == 1:
            # Avoid the merge. Just move the DDB file to the outdir of the work
            shutil.copy(pot1_files[0], out_dvdb)
        else:
            # FIXME: The merge may require a non-negligible amount of memory if lots of qpts.
            # Besides there are machines such as lemaitre3 that are problematic when
            # running MPI applications on the front-end
            mrgdvdb = wrappers.Mrgdvdb(manager=self[0].manager, verbose=0)
            mrgdvdb.merge(self.outdir.path, pot1_files, out_dvdb, delete_source=delete_source)

        return out_dvdb