def run(self, args) -> bool:
        '''
		Callback for running the command.
		:param args: the arguments.
		:return: True if the process could continue. False if an error occurred and the process should stop.
		'''
        # Run the building behavior
        if not super().run(args):
            return False

        maker = AutoLaTeXMaker.create(self.configuration)

        for root_file in maker.rootFiles:
            root_dir = os.path.dirname(root_file)
            # Output
            output_dir = genutils.abspath(args.out, root_dir)

            logging.debug(
                _T("Generating flat version into: %s") % (output_dir))

            # Delete the output directory
            try:
                if os.path.isdir(output_dir):
                    shutil.rmtree(output_dir)
            except:
                pass

            # Create the flattening tool
            flattener = Flattener(filename=root_file,
                                  outputDirectory=output_dir)
            flattener.use_biblio = args.externalbiblio
            if not flattener.run():
                return False
        return True
Beispiel #2
0
    def _internal_create_maker(self, args) -> AutoLaTeXMaker:
        '''
		Create the maker.
		:param args: the arguments.
		:return: the maker
		:rtype: AutoLaTeXMaker
		'''
        return AutoLaTeXMaker.create(self.configuration)
Beispiel #3
0
    def _internal_run_images(self, maker: AutoLaTeXMaker, args):
        '''
		Run the internal behavior of the 'images' command.
		:param maker: the AutoLaTeX maker.
		:param args: the arguments.
		:return: the dict of images
		:rtype: dict
		'''
        return maker.run_translators(forceGeneration=args.force)
	def _internal_run_build(self,  maker : AutoLaTeXMaker,  args) -> bool:
		'''
		Run the internal behavior of the 'images' command.
		:param maker: the AutoLaTeX maker.
		:param args: the arguments.
		:return: True to continue process. False to stop the process.
		'''
		ddir = self.configuration.documentDirectory
		if ddir and not args.nochdir:
			os.chdir(ddir)
		return maker.build()
Beispiel #5
0
    def run_clean_command(self, args) -> bool:
        '''
		Run the command 'clean'.
		:param args: the arguments.
		:return: True if the process could continue. False if an error occurred and the process should stop.
		'''
        ddir = self.configuration.documentDirectory
        if ddir and not args.nochdir:
            os.chdir(ddir)
        maker = AutoLaTeXMaker.create(self.configuration)
        # Prepare used-defined list of deletable files
        clean_files = self.configuration.clean.cleanFiles
        abs_clean_files = list()
        bn_clean_files = list()
        for file in clean_files:
            if os.sep in file:
                abs_clean_files.append(file)
            else:
                bn_clean_files.append(file)
        for root_file in maker.rootFiles:
            root_dir = os.path.dirname(root_file)
            if args.norecursive:
                root = os.path.dirname(root_file)
                for filename in os.listdir(root):
                    abs_filename = os.path.join(root, filename)
                    if self._is_deletable_in_root_folder_only(
                            root, root_file, abs_filename):
                        self._delete_file(abs_filename, args.simulate)
                    elif self._is_deletable(root, root_file, abs_filename):
                        self._delete_file(abs_filename, args.simulate)
                    elif self._is_deletable_shell(root, root_file,
                                                  abs_filename, filename,
                                                  abs_clean_files,
                                                  bn_clean_files):
                        self._delete_file(abs_filename, args.simulate)
            else:
                for root, dirs, files in os.walk(os.path.dirname(root_file)):
                    for filename in files:
                        abs_filename = os.path.join(root, filename)
                        if root == root_dir and self._is_deletable_in_root_folder_only(
                                root, root_file, abs_filename):
                            self._delete_file(abs_filename, args.simulate)
                        elif self._is_deletable(root, root_file, abs_filename):
                            self._delete_file(abs_filename, args.simulate)
                        elif self._is_deletable_shell(root, root_file,
                                                      abs_filename, filename,
                                                      abs_clean_files,
                                                      bn_clean_files):
                            self._delete_file(abs_filename, args.simulate)
        return True
    def run(self, args) -> bool:
        '''
		Callback for running the command.
		:param args: the arguments.
		:return: True if the process could continue. False if an error occurred and the process should stop.
		'''
        ddir = self.configuration.documentDirectory
        if ddir and not args.nochdir:
            os.chdir(ddir)
        maker = AutoLaTeXMaker.create(self.configuration)
        for root_file in maker.rootFiles:
            if not maker.run_makeglossaries(root_file):
                logging.error(_T("Error when running the glossary tool"))
                return False
        return True
Beispiel #7
0
	def run(self,  args) -> bool:
		'''
		Callback for running the command.
		:param args: the arguments.
		:return: True if the process could continue. False if an error occurred and the process should stop.
		'''
		ddir = self.configuration.documentDirectory
		if ddir and not args.nochdir:
			os.chdir(ddir)
		maker = AutoLaTeXMaker.create(self.configuration)
		for root_file in maker.rootFiles:
			error = maker.run_bibtex(root_file) 
			if error:
				extlogging.multiline_error(error['message'])
				return False
		return True
Beispiel #8
0
    def run(self, args) -> bool:
        '''
		Callback for running the command.
		:param args: the arguments.
		:return: True if the process could continue. False if an error occurred and the process should stop.
		'''
        ddir = self.configuration.documentDirectory
        if ddir and not args.nochdir:
            os.chdir(ddir)
        maker = AutoLaTeXMaker.create(self.configuration)
        idxExt = texutils.getIndexFileExtensions()[0]
        for root_file in maker.rootFiles:
            idxFile = genutils.basename2(
                root_file, texutils.getTeXFileExtensions()) + idxExt
            if not maker.run_makeindex(idxFile):
                logging.error(_T("Error when running the indexing tool"))
                return False
        return True
Beispiel #9
0
    def run(self, args) -> bool:
        '''
		Callback for running the command.
		:param args: the arguments.
		:return: True to continue process. False to stop the process.
		'''
        # Explore the auto-generated images
        auto_images = self._get_auto_images()

        # Explore the folders
        manual_images = self._get_manually_given_images(auto_images)

        # Parse the TeX
        maker = AutoLaTeXMaker.create(self.configuration)

        included_images = set()
        for root_file in maker.rootFiles:
            parser = ImageInclusions(filename=root_file)
            if not parser.run():
                return False
            images = parser.get_included_figures()
            included_images.update(images)

        # Compute the not-included figures
        not_included_images = manual_images.difference(included_images)

        # Do the action
        ddir = self.configuration.documentDirectory
        for image_file in not_included_images:
            relpath = os.path.relpath(image_file, ddir)
            abspath = genutils.abspath(image_file, ddir)
            eprint(relpath)
            if args.delete:
                #eprint("> " + abspath)
                genutils.unlink(abspath)

        return True