# 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
# 
# def get_path_pandoc():
# 
#     settings = QSettings('Pandoc', 'PanConvert')
#     path_pandoc_tmp = settings.value('path_pandoc','')
#     path_pandoc = str(path_pandoc_tmp)
# 
#     if not os.path.isfile(path_pandoc):
# 
#         if platform.system() == 'Darwin' or os.name == 'posix':
#             path_pandoc = which("pandoc")
#             settings.setValue('path_pandoc', path_pandoc)
#             settings.sync()
#         else:
#             path_pandoc = where("pandoc.exe")
#             settings.setValue('path_pandoc', path_pandoc)
#             settings.sync()
# 
# Path: source/gui/panconvert_diag_fromformat.py
# class Ui_From_Format_Dialog(object):
#     def setupUi(self, From_Format_Dialog):
#         From_Format_Dialog.setObjectName("From_Format_Dialog")
#         From_Format_Dialog.resize(224, 234)
#         self.gridLayout = QtWidgets.QGridLayout(From_Format_Dialog)
#         self.gridLayout.setObjectName("gridLayout")
#         self.verticalLayout = QtWidgets.QVBoxLayout()
#         self.verticalLayout.setObjectName("verticalLayout")
#         self.ButtonCancel = QtWidgets.QPushButton(From_Format_Dialog)
#         self.ButtonCancel.setObjectName("ButtonCancel")
#         self.verticalLayout.addWidget(self.ButtonCancel)
#         self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
#         self.textBrowser = QtWebEngineWidgets.QWebEngineView(From_Format_Dialog)
#         self.textBrowser.setMinimumSize(QtCore.QSize(200, 100))
#         self.textBrowser.setObjectName("textBrowser")
#         self.gridLayout.addWidget(self.textBrowser, 0, 0, 1, 1)
# 
#         self.retranslateUi(From_Format_Dialog)
#         QtCore.QMetaObject.connectSlotsByName(From_Format_Dialog)
# 
#     def retranslateUi(self, From_Format_Dialog):
#         _translate = QtCore.QCoreApplication.translate
#         From_Format_Dialog.setWindowTitle(_translate("From_Format_Dialog", "Pandoc From Formats"))
#         self.ButtonCancel.setText(_translate("From_Format_Dialog", "Cancel"))


from source.helpers.interface_pandoc import get_pandoc_formats, get_path_pandoc
from source.gui.panconvert_diag_fromformat import Ui_From_Format_Dialog
from source.language.messages import *
        self.resize(settings.value("FromFormat_size", QSize(270, 225)))
        self.move(settings.value("FromFormat_pos", QPoint(50, 50)))

        if not os.path.isfile(path_pandoc):
            path_pandoc = get_path_pandoc()
            path_pandoc = settings.value('path_pandoc')

        if os.path.isfile(path_pandoc):
            formats =  get_pandoc_formats()
            fromformats = formats[0]
            data = '<br>'.join(fromformats)
            self.ui.textBrowser.setHtml(data)
        else:
                message = error_converter_path()
                return 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("FromFormat_size", self.size())
            settings.setValue("FromFormat_pos", self.pos())


        settings.sync()
        settings.status()
        FromFormatDialog.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
# 
# def get_path_pandoc():
# 
#     settings = QSettings('Pandoc', 'PanConvert')
#     path_pandoc_tmp = settings.value('path_pandoc','')
#     path_pandoc = str(path_pandoc_tmp)
# 
#     if not os.path.isfile(path_pandoc):
# 
#         if platform.system() == 'Darwin' or os.name == 'posix':
#             path_pandoc = which("pandoc")
#             settings.setValue('path_pandoc', path_pandoc)
#             settings.sync()
#         else:
#             path_pandoc = where("pandoc.exe")
#             settings.setValue('path_pandoc', path_pandoc)
#             settings.sync()
# 
# Path: source/gui/panconvert_diag_fromformat.py
# class Ui_From_Format_Dialog(object):
#     def setupUi(self, From_Format_Dialog):
#         From_Format_Dialog.setObjectName("From_Format_Dialog")
#         From_Format_Dialog.resize(224, 234)
#         self.gridLayout = QtWidgets.QGridLayout(From_Format_Dialog)
#         self.gridLayout.setObjectName("gridLayout")
#         self.verticalLayout = QtWidgets.QVBoxLayout()
#         self.verticalLayout.setObjectName("verticalLayout")
#         self.ButtonCancel = QtWidgets.QPushButton(From_Format_Dialog)
#         self.ButtonCancel.setObjectName("ButtonCancel")
#         self.verticalLayout.addWidget(self.ButtonCancel)
#         self.gridLayout.addLayout(self.verticalLayout, 1, 0, 1, 1)
#         self.textBrowser = QtWebEngineWidgets.QWebEngineView(From_Format_Dialog)
#         self.textBrowser.setMinimumSize(QtCore.QSize(200, 100))
#         self.textBrowser.setObjectName("textBrowser")
#         self.gridLayout.addWidget(self.textBrowser, 0, 0, 1, 1)
# 
#         self.retranslateUi(From_Format_Dialog)
#         QtCore.QMetaObject.connectSlotsByName(From_Format_Dialog)
# 
#     def retranslateUi(self, From_Format_Dialog):
#         _translate = QtCore.QCoreApplication.translate
#         From_Format_Dialog.setWindowTitle(_translate("From_Format_Dialog", "Pandoc From Formats"))
#         self.ButtonCancel.setText(_translate("From_Format_Dialog", "Cancel"))


# Path: source/dialogs/dialog_fromformat.py
from source.helpers.interface_pandoc import get_pandoc_formats, get_path_pandoc
from source.gui.panconvert_diag_fromformat import Ui_From_Format_Dialog
from source.language.messages import *

        self.resize(settings.value("FromFormat_size", QSize(270, 225)))
        self.move(settings.value("FromFormat_pos", QPoint(50, 50)))

        if not os.path.isfile(path_pandoc):
            path_pandoc = get_path_pandoc()
            path_pandoc = settings.value('path_pandoc')

        if os.path.isfile(path_pandoc):
            formats =  get_pandoc_formats()
            fromformats = formats[0]
            data = '<br>'.join(fromformats)
            self.ui.textBrowser.setHtml(data)
        else:
                message = error_converter_path()
                return 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("FromFormat_size", self.size())
            settings.setValue("FromFormat_pos", self.pos())


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

     def info(self):

        formats =  get_pandoc_formats()