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 _read_generation_prefix(self,  content : object,  filename : str, config : Config):
		'''
		Read the path definition in the configuration section [generation].
		:param content: the configuration file content.
		:type content: dict
		:param filename: the name of the configuration file.
		:type filename: str
		:param config: the configuration object to fill up.
		:type config: Config
		'''
		main_name = self._ensureAscendentCompatibility(content.get('main file'))
		if main_name:
			main_name = genutils.abspath(main_name,  self._base_dir)
			config.documentDirectory = os.path.dirname(main_name)
			config.documentFilename = os.path.basename(main_name)
Beispiel #3
0
 def __call__(actionself,
              parser,
              namespace,
              value,
              option_string=None):
     self.configuration.generation.is_index_enable = True
     if value:
         path = genutils.abspath(
             value, self.configuration.documentDirectory)
         if os.path.isfile(path):
             self.configuration.generation.makeindexStyleFilename = path
         else:
             logging.error(_T("File not found: %s") % (value))
             self.__exiter.exitOnFailure()
             return
Beispiel #4
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
	def run(self,  args) -> bool:
		'''
		Callback for running the command.
		:param args: the arguments.
		:return: True to continue process. False to stop the process.
		'''
		# Create the translator repository
		repository = TranslatorRepository(self.configuration)
		# Create the runner of translators
		runner = TranslatorRunner(repository)
		# Detect the images
		runner.sync()
		images = runner.getSourceImages()
		# Show detect images
		ddir = self.configuration.documentDirectory
		image_list = dict()
		if ddir:
			for image in images:
				relpath = os.path.relpath(image,  ddir)
				abspath = genutils.abspath(image,  ddir)
				image_list[abspath] = relpath
		else:
			for image in images:
				relpath = os.path.relpath(image)
				abspath = os.path.abspath(image)
				image_list[abspath] = relpath
		
		if args.showvalidimages:
			self._show_valid_images(image_list,  runner)
		elif args.showchangedimages:
			self._show_changed_images(image_list,  runner)
		elif args.showimagetranslators:
			self._show_image_translators(image_list,  runner)
		else:
			self._show_all_images(image_list,  runner)
		return True
Beispiel #6
0
	def to_path(self,  value : str) -> str:
		if value:
			return genutils.abspath(value,  self._base_dir)
		return value