def make_fout(fout='./tmp', fmt='pcap'):
        """Make root path for output.

        Positional arguments:
            * fout -- str, root path for output
            * fmt -- str, output format

        Returns:
            * output -- dumper of specified format

        """
        if fmt == 'pcap':       # output PCAP file
            from pcapkit.dumpkit import PCAP as output
        elif fmt == 'plist':    # output PLIST file
            from dictdumper import PLIST as output
        elif fmt == 'json':     # output JSON file
            from dictdumper import JSON as output
        elif fmt == 'tree':     # output treeview text file
            from dictdumper import Tree as output
            fmt = 'txt'
        elif fmt == 'html':     # output JavaScript file
            from dictdumper import JavaScript as output
            fmt = 'js'
        elif fmt == 'xml':      # output XML file
            from dictdumper import XML as output
        else:                   # no output file
            from pcapkit.dumpkit import NotImplementedIO as output
            if fmt is not None:
                warnings.warn(f'Unsupported output format: {fmt}; disabled file output feature',
                              FormatWarning, stacklevel=stacklevel())
            return output, ''

        try:
            pathlib.Path(fout).mkdir(parents=True, exist_ok=True)
        except FileExistsError as error:
            if fmt is None:
                warnings.warn(error.strerror, FileWarning, stacklevel=stacklevel())
            else:
                raise FileExists(*error.args) from None

        return output, fmt
def make_fout ( fout = './tmp' , fmt = 'pcap' ) : if fmt == 'pcap' : from pcapkit . dumpkit import PCAP as output elif fmt == 'plist' : from dictdumper import PLIST as output elif fmt == 'json' : from dictdumper import JSON as output elif fmt == 'tree' : from dictdumper import Tree as output fmt = 'txt' elif fmt == 'html' : from dictdumper import JavaScript as output fmt = 'js' elif fmt == 'xml' : from dictdumper import XML as output else : from pcapkit . dumpkit import NotImplementedIO as output if fmt is not None : warnings . warn ( f'Unsupported output format: {fmt}; disabled file output feature' , FormatWarning , stacklevel = stacklevel ( ) ) return output , '' try : pathlib . Path ( fout ) . mkdir ( parents = True , exist_ok = True ) except FileExistsError as error : if fmt is None : warnings . warn ( error . strerror , FileWarning , stacklevel = stacklevel ( ) ) else : raise FileExists ( * error . args ) from None return output , fmt
Make root path for output.

        Positional arguments:
            * fout -- str, root path for output
            * fmt -- str, output format

        Returns:
            * output -- dumper of specified format