1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
  
     | 
    
      #!/usr/bin/env python
# encoding: utf-8
# Import necessary python modules
import os
# Import canonical version from isoquery
from isoquery import __version__
APPNAME = 'isoquery'
VERSION = __version__
top = '.'
out = 'build'
from waflib import Scripting
Scripting.excludes.append('.eric4project')
Scripting.excludes.append('.ropeproject')
Scripting.excludes.append('debian')
Scripting.excludes.append('isoquery.e4p')
def options(opt):
    # Options for disabling pyc or pyo compilation
    opt.tool_options('python')
    # Support usual directory variables like MANDIR, DATADIR, etc.
    opt.tool_options('gnu_dirs')
def configure(conf):
    # Check that required programs are available
    conf.find_program('msgfmt', var='MSGFMT')
    conf.find_program(['rst2man','rst2man.py'], var='RST2MAN')
    conf.find_program('gzip', var='GZIP')
    conf.find_program('po4a-translate', var='PO4A_TRANSLATE')
    conf.check_tool('python')
    conf.check_python_version((2,4))
    conf.check_tool('gnu_dirs')
def build(bld):
    # Compile python files
    bld(
        features = 'py',
        source = bld.path.ant_glob('isoquery/*.py'),
        install_path = '${PYTHONDIR}/isoquery',
    )
    # Register installation paths
    bld.install_files('${BINDIR}', 'bin/isoquery', chmod=0755)
    bld.install_files('${DOCDIR}', ['ChangeLog', 'README', 'TODO', 'AUTHORS'])
    # Manpages
    # Generate man page from rst source files
    bld(
        source = 'man/isoquery.rst',
        target = 'man/isoquery.1',
        rule = '${RST2MAN} ${SRC} ${TGT}',
    )
    bld(
        source = 'man/de.add man/de.po man/isoquery.rst',
        target = 'man/de/isoquery.rst',
        rule = '${PO4A_TRANSLATE} ' + \
               '--format text ' + \
               '--option markdown ' + \
               '--addendum ${SRC[0].bldpath()} ' + \
               '--po ${SRC[1].bldpath()} ' + \
               '--master ${SRC[2].bldpath()} ' + \
               '--master-charset UTF-8 ' + \
               '--localized ${TGT}',
    )
    bld(
        source = 'man/pt.add man/pt.po man/isoquery.rst',
        target = 'man/pt/isoquery.rst',
        rule = '${PO4A_TRANSLATE} ' + \
               '--format text ' + \
               '--option markdown ' + \
               '--addendum ${SRC[0].bldpath()} ' + \
               '--po ${SRC[1].bldpath()} ' + \
               '--master ${SRC[2].bldpath()} ' + \
               '--master-charset UTF-8 ' + \
               '--localized ${TGT}',
    )
    bld(
        source = 'man/de/isoquery.rst',
        target = 'man/de/isoquery.1',
        rule = '${RST2MAN} ${SRC} ${TGT}',
    )
    bld(
        source = 'man/pt/isoquery.rst',
        target = 'man/pt/isoquery.1',
        rule = '${RST2MAN} ${SRC} ${TGT}',
    )
    # Compress and install man pages
    bld(
        source = 'man/isoquery.1',
        target = 'man/isoquery.1.gz',
        rule = '${GZIP} --best --stdout ${SRC} > ${TGT}',
    )
    bld.install_files('${MANDIR}/man1', 'man/isoquery.1.gz')
    bld(
        source = 'man/de/isoquery.1',
        target = 'man/de/isoquery.1.gz',
        rule = '${GZIP} --best --stdout ${SRC} > ${TGT}',
    )
    bld.install_files('${MANDIR}/de/man1', 'man/de/isoquery.1.gz')
    bld(
        source = 'man/pt/isoquery.1',
        target = 'man/pt/isoquery.1.gz',
        rule = '${GZIP} --best --stdout ${SRC} > ${TGT}',
    )
    bld.install_files('${MANDIR}/pt/man1', 'man/pt/isoquery.1.gz')
    # Generate .mo files
    for translation in bld.path.ant_glob('po/*.po'):
        # Get locale from basename of the file, without extension (.po)
        locale = os.path.basename(translation.path_from(bld.path))[:-3]
        # Create a task for each translation file
        mo_file = bld(
            source = translation,
            target = translation.change_ext('.mo'),
            rule = '${MSGFMT} --check --output ${TGT} ${SRC}',
        )
        # The file needs a new name for installation
        bld.install_as(
            '${LOCALEDIR}/%s/LC_MESSAGES/isoquery.mo' % locale,
            mo_file.target
        )
 
     |