Beispiel #1
0
 def _select_dbpre(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Select dbpre executable", self.lineEditDbpre.text())
     if path:
         self.lineEditDbpre.setText(system.normpath(path))
         self.labelDbpreVersion.setText(
             compilers.DbpreCompiler(path).get_version() if Settings().dbpre != "" else ""
         )
Beispiel #2
0
    def _select_dbpre_framework(self):
        def bool_to_string(value):
            if value:
                return 'Found'
            else:
                return 'Missing'

        path = QtWidgets.QFileDialog.getExistingDirectory(
            self, 'Select dbpre framework directory',
            self.lineEditDbpreFramework.text())
        if path:
            path = system.normpath(path)
            pgctbbat = os.path.exists(os.path.join(path, 'PGCTBBAT'))
            pgctbparam = os.path.exists(os.path.join(path, 'PGCTBPARAM'))
            pgctbsub = os.path.exists(os.path.join(path, 'PGCTBSUB'))
            pgctbsubws = os.path.exists(os.path.join(path, 'PGCTBSUBWS'))
            sqlca = os.path.exists(os.path.join(path, 'SQLCA'))
            if pgctbparam and pgctbsub and sqlca and pgctbsubws and pgctbbat:
                self.lineEditDbpreFramework.setText(path)
            else:
                QtWidgets.QMessageBox.warning(
                    self, 'Invalid dpre framework directory',
                    'Missing one of the following files: \n'
                    'PGCTBBAT: %s\n'
                    'PGCTBPARAM: %s\n'
                    'PGCTBSUB: %s\n'
                    'PGCTBSUBWS: %s\n'
                    'SQLCA: %s\n' %
                    (bool_to_string(pgctbbat), bool_to_string(pgctbparam),
                     bool_to_string(pgctbsub), bool_to_string(pgctbsubws),
                     bool_to_string(sqlca)))
Beispiel #3
0
    def _select_dbpre_framework(self):
        def bool_to_string(value):
            if value:
                return "Found"
            else:
                return "Missing"

        path = QtWidgets.QFileDialog.getExistingDirectory(
            self, "Select dbpre framework directory", self.lineEditDbpreFramework.text()
        )
        if path:
            path = system.normpath(path)
            pgctbbat = os.path.exists(os.path.join(path, "PGCTBBAT"))
            pgctbbatws = os.path.exists(os.path.join(path, "PGCTBBATWS"))
            sqlca = os.path.exists(os.path.join(path, "SQLCA"))
            if pgctbbat and pgctbbatws and sqlca:
                self.lineEditDbpreFramework.setText(path)
            else:
                QtWidgets.QMessageBox.warning(
                    self,
                    "Invalid dpre framework directory",
                    "Missing one of the following files: \n"
                    "PGCTBBAT: %s\n"
                    "PGCTBBATWS: %s\n"
                    "SQLCA: %s\n" % (bool_to_string(pgctbbat), bool_to_string(pgctbbatws), bool_to_string(sqlca)),
                )
Beispiel #4
0
 def _select_custom_compiler_path(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Select path to a GnuCOBOL compiler executable',
         self.lineEditCompilerPath.text())
     if path:
         self.lineEditCompilerPath.setText(system.normpath(path))
         self._check_compiler()
Beispiel #5
0
 def full_compiler_path(self):
     compiler = self.compiler_path
     if compiler and not os.path.exists(compiler):
         result = system.which(compiler)
         if result is not None:
             compiler = result
     return system.normpath(compiler)
Beispiel #6
0
    def _select_dbpre_framework(self):
        def bool_to_string(value):
            if value:
                return 'Found'
            else:
                return 'Missing'

        path = QtWidgets.QFileDialog.getExistingDirectory(
            self, 'Select dbpre framework directory',
            self.lineEditDbpreFramework.text())
        if path:
            path = system.normpath(path)
            pgctbbat = os.path.exists(os.path.join(path, 'PGCTBBAT'))
            pgctbparam = os.path.exists(os.path.join(path, 'PGCTBPARAM'))
            pgctbsub = os.path.exists(os.path.join(path, 'PGCTBSUB'))
            pgctbsubws = os.path.exists(os.path.join(path, 'PGCTBSUBWS'))
            sqlca = os.path.exists(os.path.join(path, 'SQLCA'))
            if pgctbparam and pgctbsub and sqlca and pgctbsubws and pgctbbat:
                self.lineEditDbpreFramework.setText(path)
            else:
                QtWidgets.QMessageBox.warning(
                    self, 'Invalid dpre framework directory',
                    'Missing one of the following files: \n'
                    'PGCTBBAT: %s\n'
                    'PGCTBPARAM: %s\n'
                    'PGCTBSUB: %s\n'
                    'PGCTBSUBWS: %s\n'
                    'SQLCA: %s\n' % (
                        bool_to_string(pgctbbat), bool_to_string(pgctbparam),
                        bool_to_string(pgctbsub), bool_to_string(pgctbsubws),
                        bool_to_string(sqlca)))
Beispiel #7
0
 def full_compiler_path(self):
     compiler = self.compiler_path
     if compiler and not os.path.exists(compiler):
         result = system.which(compiler)
         if result is not None:
             compiler = result
     return system.normpath(compiler)
Beispiel #8
0
 def _select_custom_compiler_path(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, "Select path to a GnuCOBOL compiler executable", self.lineEditCompilerPath.text()
     )
     if path:
         self.lineEditCompilerPath.setText(system.normpath(path))
         self._check_compiler()
Beispiel #9
0
 def default_copy_dir(self):
     compiler_path = self.compiler_path
     if compiler_path:
         root = os.path.abspath(os.path.join(
             os.path.dirname(self.compiler_path), '..'))
         default = os.path.join(root, 'copy')
         return system.normpath(default)
     return ''
Beispiel #10
0
 def _select_dbpre(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Select dbpre executable', self.lineEditDbpre.text())
     if path:
         self.lineEditDbpre.setText(system.normpath(path))
         self.labelDbpreVersion.setText(
             compilers.DbpreCompiler(path).get_version(
             ) if Settings().dbpre != '' else '')
Beispiel #11
0
 def default_copy_dir(self):
     compiler_path = self.default_compiler_path()
     if compiler_path and system.windows:
         root = os.path.abspath(
             os.path.join(os.path.dirname(compiler_path), '..'))
         default = os.path.join(root, 'copy')
         return system.normpath(default)
     return ''
Beispiel #12
0
 def compiler_path(self):
     default = self.default_compiler_path()
     path = self._settings.value('compilerPath', default)
     if not path or \
             (not os.path.exists(path) and system.which(path) is None):
         path = default
         self.compiler_path = path
     return system.normpath(path)
Beispiel #13
0
 def compiler_path(self):
     default = self.default_compiler_path()
     path = self._settings.value('compilerPath', default)
     if not path or \
             (not os.path.exists(path) and system.which(path) is None):
         path = default
         self.compiler_path = path
     return system.normpath(path)
Beispiel #14
0
 def path(self):
     pth = self._settings.value('environment/PATH', self.default_path())
     paths = []
     for p in pth.split(os.pathsep):
         p = system.normpath(p)
         if p not in paths:
             paths.append(p)
     retval = os.pathsep.join(paths)
     return retval
Beispiel #15
0
 def path(self):
     pth = self._settings.value('environment/PATH', self.default_path())
     paths = []
     for p in pth.split(os.pathsep):
         if os.path.exists(p):
             paths.append(system.normpath(p))
     paths = list(set(paths))
     retval = os.pathsep.join(paths)
     return retval
Beispiel #16
0
 def path(self):
     pth = self._settings.value('environment/PATH', self.default_path())
     paths = []
     for p in pth.split(os.pathsep):
         if os.path.exists(p):
             paths.append(system.normpath(p))
     paths = list(set(paths))
     retval = os.pathsep.join(paths)
     return retval
Beispiel #17
0
 def path(self):
     pth = self._settings.value('environment/PATH', self.default_path())
     paths = []
     for p in pth.split(os.pathsep):
         p = system.normpath(p)
         if p not in paths:
             paths.append(p)
     retval = os.pathsep.join(paths)
     return retval
Beispiel #18
0
 def _select_vcvarsall(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(self, "Select vcvarsall.bat", self.lineEditVCVARS.text())
     if path:
         path = system.normpath(path)
         if os.path.isfile(path) and path.lower().endswith("vcvarsall.bat"):
             self.lineEditVCVARS.setText(path)
         else:
             QtWidgets.QMessageBox.warning(
                 self, "Invalid vcvarsall batch path", "%r is not a valid vcvarsall batch file" % path
             )
Beispiel #19
0
 def _select_vcvarsall(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Select vcvarsall.bat', self.lineEditVCVARS.text())
     if path:
         path = system.normpath(path)
         if os.path.isfile(path) and path.lower().endswith('vcvarsall.bat'):
             self.lineEditVCVARS.setText(path)
         else:
             QtWidgets.QMessageBox.warning(
                 self, "Invalid vcvarsall batch path",
                 "%r is not a valid vcvarsall batch file" % path)
Beispiel #20
0
 def default_compiler_path():
     if system.windows:
         # get the bundled compiler path as default
         # compiler on windows
         if getattr(sys, 'frozen', False):
             # The application is frozen
             cwd = os.path.dirname(sys.executable)
             default = os.path.join(cwd, 'GnuCOBOL', 'bin', 'cobc.exe')
         else:
             cwd = os.getcwd()
             default = os.path.join(cwd, 'GnuCOBOL-Win32-MinGW', 'bin',
                                    'cobc.exe')
     else:
         default = system.which('cobc', include_settings_path=False)
     return system.normpath(default)
Beispiel #21
0
 def default_compiler_path():
     if system.windows:
         # get the bundled compiler path as default
         # compiler on windows
         if getattr(sys, 'frozen', False):
             # The application is frozen
             cwd = os.path.dirname(sys.executable)
             default = os.path.join(cwd, 'GnuCOBOL', 'bin', 'cobc.exe')
         else:
             cwd = os.getcwd()
             default = os.path.join(cwd, 'GnuCOBOL-Win32-MinGW', 'bin',
                                    'cobc.exe')
     else:
         default = system.which('cobc')
     return system.normpath(default)
Beispiel #22
0
    def get_dependencies(cls, filename, recursive=True):
        """
        Gets the dependencies of a COBOL program/module.

        :param filename: path of the file to analyse.
        :param recursive: True to perform recursive analysis (analyses
            dependencies of dependencies recursively).
        :return: The set of dependencies that needs to be compiled to compile
            and use the requested program/module.
        """
        encoding = _get_encoding(filename)
        directory = os.path.dirname(filename)
        dependencies = []
        prog = re.compile(r'(^(\s|\d|\w)*CALL[\s\n]*.*".*")',
                          re.MULTILINE | re.IGNORECASE)
        with open(filename, 'r', encoding=encoding) as f:
            content = f.read()
            if not Settings().free_format:
                content = '\n'.join(
                    [' ' * 6 + l[6:] for l in content.splitlines()])
            for m in prog.findall(content):
                for m in m:
                    try:
                        module_base_name = re.findall('"(.*)"', m)[0]
                    except IndexError:
                        continue
                    # try to see if the module can be found in the current
                    # directory
                    for ext in Settings().all_extensions:
                        pth = os.path.join(directory, module_base_name + ext)
                        if os.path.exists(pth) and \
                                pth.lower() not in dependencies:
                            if filename != pth:
                                dependencies.append(system.normpath(pth))
                                if recursive:
                                    dependencies += cls.get_dependencies(pth)

        dependencies = list(set(dependencies))
        _logger().debug('dependencies of %s: %r', filename, dependencies)
        return dependencies
Beispiel #23
0
    def get_dependencies(cls, filename, recursive=True):
        """
        Gets the dependencies of a COBOL program/module.

        :param filename: path of the file to analyse.
        :param recursive: True to perform recursive analysis (analyses
            dependencies of dependencies recursively).
        :return: The set of dependencies that needs to be compiled to compile
            and use the requested program/module.
        """
        encoding = _get_encoding(filename)
        directory = os.path.dirname(filename)
        dependencies = []
        prog = re.compile(r'(^(\s|\d|\w)*CALL[\s\n]*.*".*")',
                          re.MULTILINE | re.IGNORECASE)
        with open(filename, 'r', encoding=encoding) as f:
            content = f.read()
            if not Settings().free_format:
                content = '\n'.join([' ' * 6 + l[6:] for l in content.splitlines()])
            for m in prog.findall(content):
                for m in m:
                    try:
                        module_base_name = re.findall('"(.*)"', m)[0]
                    except IndexError:
                        continue
                    # try to see if the module can be found in the current
                    # directory
                    for ext in Settings().all_extensions:
                        pth = os.path.join(directory, module_base_name + ext)
                        if os.path.exists(pth) and \
                                pth.lower() not in dependencies:
                            if filename != pth:
                                dependencies.append(system.normpath(pth))
                                if recursive:
                                    dependencies += cls.get_dependencies(pth)

        dependencies = list(set(dependencies))
        _logger().debug('dependencies of %s: %r', filename, dependencies)
        return dependencies
Beispiel #24
0
 def compiler_path(self):
     default = self.default_compiler_path()
     path = self._settings.value('compilerPath', default)
     return system.normpath(path)
Beispiel #25
0
 def _add_rel_copy_path(self):
     path, status = QtWidgets.QInputDialog.getText(self, "Add relative copybook path", "Path:")
     if status:
         self.listWidgetCopyPaths.addItem(system.normpath(path))
Beispiel #26
0
 def esqloc(self):
     return system.normpath(self._settings.value('esqloc', ''))
Beispiel #27
0
 def cob_copy_dir(self):
     default = self.default_copy_dir()
     value = self._settings.value('environment/COB_COPY_DIR', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #28
0
 def _add_lib_path(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select a library directory")
     if path:
         self.listWidgetLibPaths.addItem(system.normpath(path))
Beispiel #29
0
 def esqloc(self):
     return system.normpath(self._settings.value('esqloc', ''))
Beispiel #30
0
 def cob_include_path(self):
     default = self.default_include_dir()
     value = self._settings.value('environment/COB_INCLUDE_PATH', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #31
0
 def cob_include_path(self):
     default = self.default_include_dir()
     value = self._settings.value('environment/COB_INCLUDE_PATH', default)
     return system.normpath(value)
Beispiel #32
0
 def _add_lib_path(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(
         self, 'Select a library directory')
     if path:
         self.listWidgetLibPaths.addItem(system.normpath(path))
Beispiel #33
0
 def cob_lib_path(self):
     default = self.default_lib_path()
     value = self._settings.value('environment/COB_LIB_PATH', default)
     return system.normpath(value)
Beispiel #34
0
 def _select_cobmysqlapi(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, "Select cobmysqlapi object file", self.lineEditCobmysqlapi.text()
     )
     if path:
         self.lineEditCobmysqlapi.setText(system.normpath(path))
Beispiel #35
0
 def compiler_path(self):
     default = 'cobc.exe' if system.windows else 'cobc'
     path = self._settings.value('compilerPath', default)
     return system.normpath(path)
Beispiel #36
0
 def cob_lib_path(self):
     default = self.default_lib_path()
     value = self._settings.value('environment/COB_LIB_PATH', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #37
0
 def vcvarsall(self):
     return system.normpath(self._settings.value('vcvarsall', ''))
Beispiel #38
0
 def _add_rel_lib_path(self):
     path, status = QtWidgets.QInputDialog.getText(self, "Add relative library path", "Path:")
     if status:
         self.listWidgetLibPaths.addItem(system.normpath(path))
Beispiel #39
0
 def cob_include_path(self):
     default = self.default_include_dir()
     value = self._settings.value('environment/COB_INCLUDE_PATH', default)
     return system.normpath(value)
Beispiel #40
0
 def _select_esqloc(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select esqlOC folder", self.lineEditESQLOC.text())
     if path:
         self.lineEditESQLOC.setText(system.normpath(path))
Beispiel #41
0
 def cob_copy_dir(self):
     default = self.default_copy_dir()
     value = self._settings.value('environment/COB_COPY_DIR', default)
     return system.normpath(value)
Beispiel #42
0
 def cob_copy_dir(self):
     default = self.default_copy_dir()
     value = self._settings.value('environment/COB_COPY_DIR', default)
     return system.normpath(value)
Beispiel #43
0
 def cob_lib_path(self):
     default = self.default_lib_path()
     value = self._settings.value('environment/COB_LIB_PATH', default)
     return system.normpath(value)
Beispiel #44
0
 def _select_esqloc(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(
         self, 'Select esqlOC folder', self.lineEditESQLOC.text())
     if path:
         self.lineEditESQLOC.setText(system.normpath(path))
Beispiel #45
0
 def cob_include_path(self):
     default = self.default_include_dir()
     value = self._settings.value('environment/COB_INCLUDE_PATH', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #46
0
 def compiler_path(self):
     default = 'cobc.exe' if system.windows else 'cobc'
     path = self._settings.value('compilerPath', default)
     return system.normpath(path)
Beispiel #47
0
 def vcvarsall(self):
     return system.normpath(self._settings.value('vcvarsall', ''))
Beispiel #48
0
 def _select_cobmysqlapi(self):
     path, _ = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Select cobmysqlapi object file',
         self.lineEditCobmysqlapi.text())
     if path:
         self.lineEditCobmysqlapi.setText(system.normpath(path))
Beispiel #49
0
 def _add_rel_lib_path(self):
     path, status = QtWidgets.QInputDialog.getText(
         self, 'Add relative library path', 'Path:')
     if status:
         self.listWidgetLibPaths.addItem(system.normpath(path))
Beispiel #50
0
 def _add_copy_path(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select a copybook path")
     if path:
         self.listWidgetCopyPaths.addItem(system.normpath(path))
Beispiel #51
0
 def cob_copy_dir(self):
     default = self.default_copy_dir()
     value = self._settings.value('environment/COB_COPY_DIR', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #52
0
 def _add_copy_path(self):
     path = QtWidgets.QFileDialog.getExistingDirectory(
         self, 'Select a copybook path')
     if path:
         self.listWidgetCopyPaths.addItem(system.normpath(path))
Beispiel #53
0
 def cob_lib_path(self):
     default = self.default_lib_path()
     value = self._settings.value('environment/COB_LIB_PATH', default)
     if value and not os.path.exists(value):
         value = default
     return system.normpath(value)
Beispiel #54
0
 def _add_rel_copy_path(self):
     path, status = QtWidgets.QInputDialog.getText(
         self, 'Add relative copybook path', 'Path:')
     if status:
         self.listWidgetCopyPaths.addItem(system.normpath(path))