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 "" )
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)))
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)), )
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()
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)
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)))
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()
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 ''
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 '')
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 ''
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)
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
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
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 )
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)
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)
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)
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
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
def compiler_path(self): default = self.default_compiler_path() path = self._settings.value('compilerPath', default) return system.normpath(path)
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))
def esqloc(self): return system.normpath(self._settings.value('esqloc', ''))
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)
def _add_lib_path(self): path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select a library directory") if path: self.listWidgetLibPaths.addItem(system.normpath(path))
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)
def cob_include_path(self): default = self.default_include_dir() value = self._settings.value('environment/COB_INCLUDE_PATH', default) return system.normpath(value)
def _add_lib_path(self): path = QtWidgets.QFileDialog.getExistingDirectory( self, 'Select a library directory') if path: self.listWidgetLibPaths.addItem(system.normpath(path))
def cob_lib_path(self): default = self.default_lib_path() value = self._settings.value('environment/COB_LIB_PATH', default) return system.normpath(value)
def _select_cobmysqlapi(self): path, _ = QtWidgets.QFileDialog.getOpenFileName( self, "Select cobmysqlapi object file", self.lineEditCobmysqlapi.text() ) if path: self.lineEditCobmysqlapi.setText(system.normpath(path))
def compiler_path(self): default = 'cobc.exe' if system.windows else 'cobc' path = self._settings.value('compilerPath', default) return system.normpath(path)
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)
def vcvarsall(self): return system.normpath(self._settings.value('vcvarsall', ''))
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))
def _select_esqloc(self): path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select esqlOC folder", self.lineEditESQLOC.text()) if path: self.lineEditESQLOC.setText(system.normpath(path))
def cob_copy_dir(self): default = self.default_copy_dir() value = self._settings.value('environment/COB_COPY_DIR', default) return system.normpath(value)
def _select_esqloc(self): path = QtWidgets.QFileDialog.getExistingDirectory( self, 'Select esqlOC folder', self.lineEditESQLOC.text()) if path: self.lineEditESQLOC.setText(system.normpath(path))
def _select_cobmysqlapi(self): path, _ = QtWidgets.QFileDialog.getOpenFileName( self, 'Select cobmysqlapi object file', self.lineEditCobmysqlapi.text()) if path: self.lineEditCobmysqlapi.setText(system.normpath(path))
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))
def _add_copy_path(self): path = QtWidgets.QFileDialog.getExistingDirectory(self, "Select a copybook path") if path: self.listWidgetCopyPaths.addItem(system.normpath(path))
def _add_copy_path(self): path = QtWidgets.QFileDialog.getExistingDirectory( self, 'Select a copybook path') if path: self.listWidgetCopyPaths.addItem(system.normpath(path))
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))