Beispiel #1
0
    def makeglossaryFlags(self, flags):
        '''
		Set additional flags for the makeglossary compiler.
		:type flags: str or list
		'''
        if flags is None or isinstance(flags, list):
            self.__makeglossaryFlags = flags
        else:
            self.__makeglossaryFlags = genutils.parseCLI(flags)
Beispiel #2
0
    def dvipsFlags(self, flags):
        '''
		Set additional flags for the dvips compiler.
		:type flags: str or list
		'''
        if flags is None or isinstance(flags, list):
            self.__dvipsFlags = flags
        else:
            self.__dvipsFlags = genutils.parseCLI(flags)
Beispiel #3
0
	def viewerCLI(self, cli):
		'''
		Set the command-line for the viewer.
		:type cli: str or list
		'''
		if cli is None:
			self.__viewerCLI = list()
		elif isinstance(cli, list):
			self.__viewerCLI = cli
		else:
			self.__viewerCLI = genutils.parseCLI(cli)
Beispiel #4
0
    def texindyFlags(self, flags):
        '''
		Set additional flags for the texindy compiler.
		:type flags: str or list
		'''
        if flags is None:
            self.__texindyFlags = list()
        elif isinstance(flags, list):
            self.__texindyFlags = flags
        else:
            self.__texindyFlags = genutils.parseCLI(flags)
Beispiel #5
0
    def makeindexCLI(self, cli):
        '''
		Set the command-line for makeindex.
		:type cli: str or list
		'''
        if cli is None:
            self.__makeindexCLI = list()
        elif isinstance(cli, list):
            self.__makeindexCLI = cli
        else:
            self.__makeindexCLI = genutils.parseCLI(cli)
Beispiel #6
0
    def updateCLI(self, cli):
        '''
		Change the command-line for updating the current folder from the SCM system.
		:return: The CLI
		:rtype: list or str
		'''
        if cli is None:
            self.__updateCLI = list()
        elif isinstance(cli, list):
            self.__updateCLI = cli
        else:
            self.__updateCLI = genutils.parseCLI(cli)
Beispiel #7
0
    def commitCLI(self, cli):
        '''
		Change the command-line for commiting to the SCM system.
		:return: The CLI
		:rtype: list or str
		'''
        if cli is None:
            self.__commitCLI = list()
        elif isinstance(cli, list):
            self.__commitCLI = cli
        else:
            self.__commitCLI = genutils.parseCLI(cli)
Beispiel #8
0
	def test_parseCLI_noException(self):
		environment = { 'a': 'va', 'b': 'vb', 'c': 'vc' }
		self.assertListEqual([], genutils.parseCLI('', environment))
		self.assertListEqual([ 'abc', '--def', 'ghi' ], genutils.parseCLI('abc --def ghi', environment))
		self.assertListEqual([ 'abc', '--def', 'ghi' ], genutils.parseCLI('abc --def ${z} ghi', environment))
		self.assertListEqual([ 'abc', '--def', 'va', 'ghi' ], genutils.parseCLI('abc --def $a ghi', environment))
		self.assertListEqual([ 'abc', '--def', 'vbbc', 'ghi' ], genutils.parseCLI('abc --def ${b}bc ghi', environment))
		self.assertListEqual([ 'abc', os.path.expanduser('~') ], genutils.parseCLI('abc $HOME', environment))
Beispiel #9
0
    def readTranslatorFile(self, filename: str) -> dict:
        '''
		Read the translator file. The replied value is the set of keys read from the transdef file.
		:param filename: the name of the file to read.
		:type filename: str
		:rtype: dict
		'''
        content = dict()
        with open(filename) as f:
            lineno = 0
            eol = False
            curvar = None
            for line in f.readlines():
                lineno = lineno + 1
                if eol:
                    if line.startswith(eol):
                        eol = None
                        curvar = None
                    elif curvar:
                        # Append to current entry
                        content[curvar].value += line
                elif not re.match(r'^\s*[#;]', line):
                    m = re.match(
                        r'^\s*([azA-Z0-9_]+)(?:\s+with\s+(.*?))?(?:\s+for\s+((?:pdf)|(?:eps)))?\s*=\<\<([a-zA-Z0-9_]+)\s*(.*?)\s*$',
                        line, re.I)
                    if m:
                        curvar = m.group(1)
                        interpreter = m.group(2)
                        mode = m.group(3)
                        eol = m.group(4)
                        value = m.group(5)
                        if (not mode) or (
                                self.configuration.generator.pdfMode
                                and mode.lower() == 'pdf') or (
                                    not self.configuration.generator.pdfMode
                                    and mode.lower() == 'eps'):
                            curvar = curvar.upper()
                            content[curvar] = TransdefLine(
                                curvar, lineno, value,
                                (interpreter.lower() if interpreter else None))
                        else:
                            curvar = None
                    else:
                        m = re.match(
                            r'^\s*([azA-Z0-9_]+)(?:\s+with\s+(.*?))?(?:\s+for\s+((?:pdf)|(?:eps)))?\s*=\s*(.*?)\s*$',
                            line, re.I)
                        if m:
                            var = m.group(1)
                            interpreter = m.group(2)
                            mode = m.group(3)
                            value = m.group(4)
                            if (not mode) or (
                                    self.configuration.generation.pdfMode
                                    and mode.lower() == 'pdf'
                            ) or (not self.configuration.generation.pdfMode
                                  and mode.lower() == 'eps'):
                                curvar = None
                                eol = None
                                content[var.upper()] = TransdefLine(
                                    var.upper(), lineno, value,
                                    (interpreter.lower()
                                     if interpreter else None))
                        elif not re.match(r'^\s*$', line):
                            logging.error(
                                _T("Line outside a definition (%s:%d).") %
                                (filename, lineno))

        if eol:
            logging.error(
                _T("The block for the variable '%s' is not closed. Keyword '%s' was not found (%s:%s)."
                   ) % (curvar, eol, filename, lineno))

        # Translate the values into suitable Python objects
        if 'INPUT_EXTENSIONS' in content and content[
                'INPUT_EXTENSIONS'] and content['INPUT_EXTENSIONS'].value:
            exts = re.split(r'\s+', content['INPUT_EXTENSIONS'].value or '')
            content['INPUT_EXTENSIONS'].value_list = list()
            for e in exts:
                if not re.match(r'^\s*$', e):
                    if not re.match(r'^[\.+]', e):
                        e = "." + e
                    content['INPUT_EXTENSIONS'].value_list.append(e)

        if 'OUTPUT_EXTENSIONS' in content and content[
                'OUTPUT_EXTENSIONS'] and content['OUTPUT_EXTENSIONS'].value:
            exts = re.split(r'\s+', content['OUTPUT_EXTENSIONS'].value or '')
            content['OUTPUT_EXTENSIONS'].value_list = list()
            for e in exts:
                if not re.match(r'^\s*$', e):
                    if not re.match(r'^\.', e):
                        e = "." + e
                    content['OUTPUT_EXTENSIONS'].value_list.append(e)

        if 'TRANSLATOR_PERL_DEPENDENCIES' in content and content[
                'TRANSLATOR_PERL_DEPENDENCIES'] and content[
                    'TRANSLATOR_PERL_DEPENDENCIES'].value:
            logging.warning(
                _T("The key 'TRANSLATOR_PERL_DEPENDENCIES' is no more supported in the translator files. Please use 'TRANSLATOR_PYTHON_DEPENDENCIES'"
                   ))

        if 'TRANSLATOR_PYTHON_DEPENDENCIES' in content and content[
                'TRANSLATOR_PYTHON_DEPENDENCIES'] and content[
                    'TRANSLATOR_PYTHON_DEPENDENCIES'].value:
            content['TRANSLATOR_PYTHON_DEPENDENCIES'].value_list = re.split(
                r'\s+', content['TRANSLATOR_PYTHON_DEPENDENCIES']['value']
                or '')

        # Ensure that the command line is a list
        if 'COMMAND_LINE' in content and content['COMMAND_LINE'] and content[
                'COMMAND_LINE'].value:
            cli = genutils.parseCLI(commandLine=str(
                content['COMMAND_LINE'].value),
                                    all_protect=True)
            content['COMMAND_LINE'].value = None
            content['COMMAND_LINE'].value_list = cli

        if 'FILES_TO_CLEAN' in content and content[
                'FILES_TO_CLEAN'] and content['FILES_TO_CLEAN'].value:
            patterns = re.split(r'\s+', content['FILES_TO_CLEAN'].value or '')
            content['FILES_TO_CLEAN'].value_list = list()
            for p in patterns:
                if not re.match(r'^\s*$', p):
                    content['FILES_TO_CLEAN'].value_list.append(p)

        return content