Exemplo n.º 1
0
 def _load_instance(self):
     # Use ConfigParser() to parser .ini files.
     try:
         self._INSTANCE = configparser.ConfigParser()
         self._INSTANCE.read(self.FILENAME)
     except:
         tty.warning(T_CONF_FILE_FAILURE)
Exemplo n.º 2
0
def build(filename, watch, pdf):
    """Builds document from source."""
    conf['build.filename'] = filename
    conf['build.watch'] = watch

    core = CoreController()
    core.mount(conf['build.filename'])

    def _output(cmd):
        """Returns output for the given shell command."""
        return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]

    PLATFORM = _output(['uname', '-mnprs']).strip()

    tty.echo("Path:     {0}".format(TEAX_WORK_PATH))
    tty.echo("Platform: {0}".format(PLATFORM))
    tty.echo("Engine:   {0} [{1}]".format(core.shelf['engine'], __version__))

    tty.section('BUILD')
    core.build(pdf=pdf)

    tty.section('RESULT')
    logfile = TEAX_WORK_PATH + '/.teax/' + os.path.splitext(filename)[0] + '.log'
    lf = LaTeXFilter()
    lf.feed(open(logfile, 'rt').read())
    for message in lf.get_messages():
        tty.warning(message.msg)
        block = []
        if message.filename:
            head, filename = os.path.split(message.filename)
            block.append('file ' + filename)
        if message.lineno:
            block.append('line ' + str(message.lineno))
        if len(block) > 0:
            tty.echo('    $[BG_WHITE]$[BLACK] {0} $[NORMAL]'.format('; '.join(block)))
Exemplo n.º 3
0
    def save(self, path):
        _document_name = slugify(path)
        _local_path = TEAX_WORK_PATH + '/' + _document_name

        if os.path.exists(_local_path):
            timestamp = str(int(time.time()))
            _local_path += '-' + timestamp
            tty.warning(T_DIRECTORY_EXISTS % timestamp)

        shutil.copytree(self.PATH, _local_path)

        tty.info(T_CREATING_TEMPLATE % _document_name)

        _conf_file = TEAX_WORK_PATH + '/' + _document_name + '/' + 'teax.ini'

        conf.save(_conf_file, [
            'general.title',
            'general.authors',
            'general.keywords'
        ])