def _outfile_name(self, dirpath: str, infile: str, outfile_idx: int=<NUM_LIT:0>) -> Optional[str]:
if not self.opts.outfile and not self.opts.outdir:<EOL><INDENT>return None<EOL><DEDENT>if self.opts.outfile:<EOL><INDENT>outfile_element = self.opts.outfile[<NUM_LIT:0>] if len(self.opts.outfile) == <NUM_LIT:1> else self.opts.outfile[outfile_idx]<EOL><DEDENT>elif self.opts.infile:<EOL><INDENT>if '<STR_LIT>' in infile:<EOL><INDENT>outfile_element = "<STR_LIT>".format(outfile_idx + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>outfile_element = os.path.basename(infile).rsplit('<STR_LIT:.>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>relpath = dirpath[len(self.opts.indir) + <NUM_LIT:1>:] if not self.opts.flatten and self.opts.indir else '<STR_LIT>'<EOL>outfile_element = os.path.join(relpath, os.path.split(infile)[<NUM_LIT:1>][:-len(self.infile_suffix)])<EOL><DEDENT>return (os.path.join(self.opts.outdir, outfile_element) if self.opts.outdir else outfile_element) +(self.outfile_suffix if not self.opts.outfile and self.outfile_suffix else '<STR_LIT>')<EOL>
Construct the output file name from the input file.  If a single output file was named and there isn't a
        directory, return the output file.
        :param dirpath: Directory path to infile
        :param infile: Name of input file
        :param outfile_idx: Index into output file list (for multiple input/output files)
        :return: Full name of output file or None if output is not otherwise supplied