"Fossies" - the Fresh Open Source Software Archive

Member "roundup-2.0.0/roundup/dist/command/build.py" (26 Aug 2019, 2028 Bytes) of package /linux/www/roundup-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "build.py": 1.6.1_vs_2.0.0.

    1 #
    2 # Copyright (C) 2009 Stefan Seefeld
    3 # All rights reserved.
    4 # For license terms see the file COPYING.txt.
    5 #
    6 from __future__ import print_function
    7 from roundup import msgfmt
    8 from distutils.command.build import build as base
    9 import os
   10 from glob import glob
   11 
   12 def list_message_files(suffix=".po"):
   13     """Return list of all found message files and their intallation paths"""
   14     _files = glob("locale/*" + suffix)
   15     _list = []
   16     for _file in _files:
   17         # basename (without extension) is a locale name
   18         _locale = os.path.splitext(os.path.basename(_file))[0]
   19         _list.append((_file, os.path.join(
   20             "share", "locale", _locale, "LC_MESSAGES", "roundup.mo")))
   21     return _list
   22 
   23 def check_manifest():
   24     """Check that the files listed in the MANIFEST are present when the
   25     source is unpacked.
   26     """
   27     try:
   28         f = open('MANIFEST')
   29     except:
   30         print('\n*** SOURCE WARNING: The MANIFEST file is missing!')
   31         return
   32     try:
   33         manifest = [l.strip() for l in f.readlines()]
   34     finally:
   35         f.close()
   36     err = set([line for line in manifest if not os.path.exists(line)])
   37     # ignore auto-generated files
   38     err = err - set(['roundup-admin', 'roundup-demo', 'roundup-gettext',
   39         'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server'])
   40     if err:
   41         n = len(manifest)
   42         print('\n*** SOURCE WARNING: There are files missing (%d/%d found)!'%(
   43             n-len(err), n))
   44         print('Missing:', '\nMissing: '.join(err))
   45 
   46 def build_message_files(command):
   47     """For each locale/*.po, build .mo file in target locale directory"""
   48     for (_src, _dst) in list_message_files():
   49         _build_dst = os.path.join("build", _dst)
   50         command.mkpath(os.path.dirname(_build_dst))
   51         command.announce("Compiling %s -> %s" % (_src, _build_dst))
   52         mo = msgfmt.Msgfmt(_src).get()
   53         open(_build_dst, 'wb').write(mo)
   54 
   55 
   56 class build(base):
   57 
   58     def run(self):
   59         check_manifest()
   60         build_message_files(self)
   61         base.run(self)
   62