oplus/epm/epm.py
def to_idf(self, buffer_or_path=None, dump_external_files=True):
        """
        Parameters
        ----------
        buffer_or_path: buffer or path, default None
            output to write into. If None, will return a json string.
        dump_external_files: boolean, default True
            if True, external files will be dumped in external files directory

        Returns
        -------
        None, or an idf string (if buffer_or_path is None).
        """
        # prepare comment
        comment = get_multi_line_copyright_message()
        if self._comment != "":
            comment += textwrap.indent(self._comment, "! ", lambda line: True)
        comment += "\n\n"

        # prepare external files dir path if file path
        if isinstance(buffer_or_path, str):
            dir_path, file_name = os.path.split(buffer_or_path)
            model_name, _ = os.path.splitext(file_name)
        else:
            model_name, dir_path = None, os.path.curdir

        # dump files if asked
        if dump_external_files:
            self.dump_external_files(
                target_dir_path=os.path.join(dir_path, get_external_files_dir_name(model_name=model_name))
            )

        # prepare body
        formatted_records = []
        for table_ref, table in self._tables.items():  # self._tables is already sorted
            formatted_records.extend([r.to_idf(model_name=model_name) for r in sorted(table)])
        body = "\n\n".join(formatted_records)

        # return
        content = comment + body
        return multi_mode_write(
            lambda f: f.write(content),
            lambda: content,
            buffer_or_path
        )
def to_idf(self, buffer_or_path=None, dump_external_files=True):
        """
        Parameters
        ----------
        buffer_or_path: buffer or path, default None
            output to write into. If None, will return a json string.
        dump_external_files: boolean, default True
            if True, external files will be dumped in external files directory

        Returns
        -------
        None, or an idf string (if buffer_or_path is None).
        """
        # prepare comment
        comment = get_multi_line_copyright_message()
        if self._comment != "":
            comment += textwrap.indent(self._comment, "! ", lambda line: True)
        comment += "\n\n"

        # prepare external files dir path if file path
        if isinstance(buffer_or_path, str):
            dir_path, file_name = os.path.split(buffer_or_path)
            model_name, _ = os.path.splitext(file_name)
        else:
            model_name, dir_path = None, os.path.curdir

        # dump files if asked
        if dump_external_files:
            self.dump_external_files(
                target_dir_path=os.path.join(dir_path, get_external_files_dir_name(model_name=model_name))
            )

        # prepare body
        formatted_records = []
        for table_ref, table in self._tables.items():  # self._tables is already sorted
            formatted_records.extend([r.to_idf(model_name=model_name) for r in sorted(table)])
        body = "\n\n".join(formatted_records)

        # return
        content = comment + body
        return multi_mode_write(
            lambda f: f.write(content),
            lambda: content,
            buffer_or_path
        )
Parameters
        ----------
        buffer_or_path: buffer or path, default None
            output to write into. If None, will return a json string.
        dump_external_files: boolean, default True
            if True, external files will be dumped in external files directory

        Returns
        -------
        None, or an idf string (if buffer_or_path is None).