# Path: source/helpers/interface_pandoc.py
# def get_pandoc_formats():
#     """
#     Dynamic preprocessor for Pandoc formats.
#     Return 2 lists. "from_formats" and "to_formats".
#     """
#     settings = QSettings('Pandoc', 'PanConvert')
#     path_pandoc = settings.value('path_pandoc','')
# 
#     if os.path.isfile(path_pandoc):
# 
#         version = get_pandoc_version()
# 
#         if version < 118:
# 
#                 p = subprocess.Popen(
#                     [path_pandoc, '-h'],
#                     stdin=subprocess.PIPE,
#                     stdout=subprocess.PIPE)
#                 help_text = p.communicate()[0].decode().splitlines(False)
#                 txt = ' '.join(help_text[1:help_text.index('Options:')])
# 
# 
#                 aux = txt.split('Output formats: ')
#                 in_ = aux[0].split('Input formats: ')[1].split(',')
#                 out = aux[1].split(',')
# 
#                 return [f.strip() for f in in_], [f.strip() for f in out]
# 
# 
#         else:
# 
#             p = subprocess.Popen(
#                 [path_pandoc, '--list-input-formats'],
#                 stdin=subprocess.PIPE,
#                 stdout=subprocess.PIPE)
#             inputformats = p.communicate()[0].decode().splitlines(False)
# 
# 
#             p = subprocess.Popen(
#                 [path_pandoc, '--list-output-formats'],
#                 stdin=subprocess.PIPE,
#                 stdout=subprocess.PIPE)
#             outputformats = p.communicate()[0].decode().splitlines(False)
# 
#             in_ = inputformats
#             out = outputformats
# 
#             return [f.strip() for f in in_], [f.strip() for f in out]
# 
# 
#     else:
#         path_pandoc = get_path_pandoc()
#         path_pandoc = settings.value('path_pandoc','')
#         if not os.path.isfile(path_pandoc):
#             message = error_converter_path()
#             return message
# 
# Path: source/gui/panconvert_diag_toformat.py
# class Ui_To_Format_Dialog(object):
#     def setupUi(self, To_Format_Dialog):
#         To_Format_Dialog.setObjectName("To_Format_Dialog")
#         To_Format_Dialog.setWindowModality(QtCore.Qt.NonModal)
#         To_Format_Dialog.setEnabled(True)
#         To_Format_Dialog.resize(334, 402)
#         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
#         sizePolicy.setHorizontalStretch(1)
#         sizePolicy.setVerticalStretch(1)
#         sizePolicy.setHeightForWidth(To_Format_Dialog.sizePolicy().hasHeightForWidth())
#         To_Format_Dialog.setSizePolicy(sizePolicy)
#         To_Format_Dialog.setMinimumSize(QtCore.QSize(224, 234))
#         To_Format_Dialog.setSizeGripEnabled(False)
#         To_Format_Dialog.setModal(False)
#         self.gridLayout = QtWidgets.QGridLayout(To_Format_Dialog)
#         self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
#         self.gridLayout.setObjectName("gridLayout")
#         self.verticalLayout = QtWidgets.QVBoxLayout()
#         self.verticalLayout.setObjectName("verticalLayout")
#         self.ButtonCancel = QtWidgets.QPushButton(To_Format_Dialog)
#         self.ButtonCancel.setObjectName("ButtonCancel")
#         self.verticalLayout.addWidget(self.ButtonCancel)
#         self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
#         self.textBrowser = QtWebEngineWidgets.QWebEngineView(To_Format_Dialog)
#         self.textBrowser.setMinimumSize(QtCore.QSize(200, 100))
#         self.textBrowser.setObjectName("textBrowser")
#         self.gridLayout.addWidget(self.textBrowser, 0, 0, 1, 1)
# 
#         self.retranslateUi(To_Format_Dialog)
#         QtCore.QMetaObject.connectSlotsByName(To_Format_Dialog)
# 
#     def retranslateUi(self, To_Format_Dialog):
#         _translate = QtCore.QCoreApplication.translate
#         To_Format_Dialog.setWindowTitle(_translate("To_Format_Dialog", "Pandoc To Formats"))
#         self.ButtonCancel.setText(_translate("To_Format_Dialog", "Cancel"))


from source.helpers.interface_pandoc import get_pandoc_formats
from source.gui.panconvert_diag_toformat import Ui_To_Format_Dialog
from source.language.messages import *
        settings = QSettings('Pandoc', 'PanConvert')
        path_pandoc = settings.value('path_pandoc','')

        self.resize(settings.value("ToFormat_size", QSize(270, 225)))
        self.move(settings.value("ToFormat_pos", QPoint(50, 50)))

        if os.path.isfile(path_pandoc):
            formats =  get_pandoc_formats()
            toformats = formats[1]
            data = '<br>'.join(toformats)
            self.ui.textBrowser.setHtml(data)
        else:
            message = error_converter_path()
            self.ui.textBrowser.setHtml(message)


     def closeEvent(self, event):

        settings = QSettings('Pandoc', 'PanConvert')
        Dialog_Size = settings.value('Dialog_Size')
        if Dialog_Size is True or Dialog_Size == 'true':
            settings.setValue("ToFormat_size", self.size())
            settings.setValue("ToFormat_pos", self.pos())


        settings.sync()
        settings.status()
        ToFormatDialog.close(self)

     def info(self):

# Path: source/helpers/interface_pandoc.py
# def get_pandoc_formats():
#     """
#     Dynamic preprocessor for Pandoc formats.
#     Return 2 lists. "from_formats" and "to_formats".
#     """
#     settings = QSettings('Pandoc', 'PanConvert')
#     path_pandoc = settings.value('path_pandoc','')
# 
#     if os.path.isfile(path_pandoc):
# 
#         version = get_pandoc_version()
# 
#         if version < 118:
# 
#                 p = subprocess.Popen(
#                     [path_pandoc, '-h'],
#                     stdin=subprocess.PIPE,
#                     stdout=subprocess.PIPE)
#                 help_text = p.communicate()[0].decode().splitlines(False)
#                 txt = ' '.join(help_text[1:help_text.index('Options:')])
# 
# 
#                 aux = txt.split('Output formats: ')
#                 in_ = aux[0].split('Input formats: ')[1].split(',')
#                 out = aux[1].split(',')
# 
#                 return [f.strip() for f in in_], [f.strip() for f in out]
# 
# 
#         else:
# 
#             p = subprocess.Popen(
#                 [path_pandoc, '--list-input-formats'],
#                 stdin=subprocess.PIPE,
#                 stdout=subprocess.PIPE)
#             inputformats = p.communicate()[0].decode().splitlines(False)
# 
# 
#             p = subprocess.Popen(
#                 [path_pandoc, '--list-output-formats'],
#                 stdin=subprocess.PIPE,
#                 stdout=subprocess.PIPE)
#             outputformats = p.communicate()[0].decode().splitlines(False)
# 
#             in_ = inputformats
#             out = outputformats
# 
#             return [f.strip() for f in in_], [f.strip() for f in out]
# 
# 
#     else:
#         path_pandoc = get_path_pandoc()
#         path_pandoc = settings.value('path_pandoc','')
#         if not os.path.isfile(path_pandoc):
#             message = error_converter_path()
#             return message
# 
# Path: source/gui/panconvert_diag_toformat.py
# class Ui_To_Format_Dialog(object):
#     def setupUi(self, To_Format_Dialog):
#         To_Format_Dialog.setObjectName("To_Format_Dialog")
#         To_Format_Dialog.setWindowModality(QtCore.Qt.NonModal)
#         To_Format_Dialog.setEnabled(True)
#         To_Format_Dialog.resize(334, 402)
#         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
#         sizePolicy.setHorizontalStretch(1)
#         sizePolicy.setVerticalStretch(1)
#         sizePolicy.setHeightForWidth(To_Format_Dialog.sizePolicy().hasHeightForWidth())
#         To_Format_Dialog.setSizePolicy(sizePolicy)
#         To_Format_Dialog.setMinimumSize(QtCore.QSize(224, 234))
#         To_Format_Dialog.setSizeGripEnabled(False)
#         To_Format_Dialog.setModal(False)
#         self.gridLayout = QtWidgets.QGridLayout(To_Format_Dialog)
#         self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetNoConstraint)
#         self.gridLayout.setObjectName("gridLayout")
#         self.verticalLayout = QtWidgets.QVBoxLayout()
#         self.verticalLayout.setObjectName("verticalLayout")
#         self.ButtonCancel = QtWidgets.QPushButton(To_Format_Dialog)
#         self.ButtonCancel.setObjectName("ButtonCancel")
#         self.verticalLayout.addWidget(self.ButtonCancel)
#         self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
#         self.textBrowser = QtWebEngineWidgets.QWebEngineView(To_Format_Dialog)
#         self.textBrowser.setMinimumSize(QtCore.QSize(200, 100))
#         self.textBrowser.setObjectName("textBrowser")
#         self.gridLayout.addWidget(self.textBrowser, 0, 0, 1, 1)
# 
#         self.retranslateUi(To_Format_Dialog)
#         QtCore.QMetaObject.connectSlotsByName(To_Format_Dialog)
# 
#     def retranslateUi(self, To_Format_Dialog):
#         _translate = QtCore.QCoreApplication.translate
#         To_Format_Dialog.setWindowTitle(_translate("To_Format_Dialog", "Pandoc To Formats"))
#         self.ButtonCancel.setText(_translate("To_Format_Dialog", "Cancel"))


# Path: source/dialogs/dialog_toformat.py
from source.helpers.interface_pandoc import get_pandoc_formats
from source.gui.panconvert_diag_toformat import Ui_To_Format_Dialog
from source.language.messages import *

        settings = QSettings('Pandoc', 'PanConvert')
        path_pandoc = settings.value('path_pandoc','')

        self.resize(settings.value("ToFormat_size", QSize(270, 225)))
        self.move(settings.value("ToFormat_pos", QPoint(50, 50)))

        if os.path.isfile(path_pandoc):
            formats =  get_pandoc_formats()
            toformats = formats[1]
            data = '<br>'.join(toformats)
            self.ui.textBrowser.setHtml(data)
        else:
            message = error_converter_path()
            self.ui.textBrowser.setHtml(message)


     def closeEvent(self, event):

        settings = QSettings('Pandoc', 'PanConvert')
        Dialog_Size = settings.value('Dialog_Size')
        if Dialog_Size is True or Dialog_Size == 'true':
            settings.setValue("ToFormat_size", self.size())
            settings.setValue("ToFormat_pos", self.pos())


        settings.sync()
        settings.status()
        ToFormatDialog.close(self)

     def info(self):

        formats =  get_pandoc_formats()