wesnoth/utils/wescamp_import
Nils Kneuper 168e01c6b4 fixed a bug with the wescamp_import script...
...that led to not including the campaign.cfg file in the pot-updates
2007-05-12 00:08:44 +00:00

144 lines
4.5 KiB
Python
Executable File

#!/usr/bin/env python
#
# wescamp_import -- generate a shellscript to import a campaign from WesCamp
#
# Pipe the output of this comman to sh to actually perform the opetation
#
import sys, os, getopt, shutil
if __name__ == "__main__":
def help():
sys.stderr.write("""\
Usage: wescamp_import {-h | wescamp-path campaign-name textdomain}
Options may be any of these:
-h, --help Emit this help message and quit
Requires as first argument a path to a WesCamp checkout
Requires as second argument a campaign name.
Call from the top level directory of mainline.
""")
# Process options
(options, arguments) = getopt.getopt(sys.argv[1:], "h", ['help',])
for (switch, val) in options:
if switch in ('-h', '--help'):
help()
sys.exit(0)
if len(arguments) == 0:
sys.stderr.write("wescamp_import: a path to a local WesCamp checkout is required.\n")
sys.exit(1)
else:
wescamp_path = arguments[0]
if len(arguments) == 1:
sys.stderr.write("wescamp_import: a campaign name is required.\n")
sys.exit(1)
else:
campaign = arguments[1]
if len(arguments) == 2:
sys.stderr.write("wescamp_import: a text domain name is required.\n")
sys.exit(1)
else:
textdomain = arguments[2]
print """\
# Generated script to do an import of %(textdomain)s from a WesCamp checkout
#
mkdir po/%(textdomain)s
cp %(wescamp_path)s/%(campaign)s-po/po/*.po* po/%(textdomain)s
cp po/wesnoth/LINGUAS po/%(textdomain)s/
cat > po/%(textdomain)s/FINDCFG <<'EOF'
find data/campaigns/%(campaign)s -name '*.cfg' -print
echo data/campaigns/%(campaign)s.cfg
EOF
cat > po/%(textdomain)s/remove-potcdate.sin <<'EOF'
#Sed script that remove the POT-Creation-Date line in the header entry
# from a POT file.
#
# The distinction between the first and the following occurrences of the
# pattern is achieved by looking at the hold space.
/^"POT-Creation-Date: .*"$/{
x
# Test if the hold space is empty.
s/P/P/
ta
# Yes it was empty. First occurrence. Remove the line.
g
d
bb
:a
# The hold space was nonempty. Following occurrences. Do nothing.
x
:b
}
EOF
cat > po/%(textdomain)s/Makevars <<'EOF'
# Makefile variables for PO directory in any package using GNU gettext.
# Usually the message domain is the same as the package name.
DOMAIN = %(textdomain)s
# These two variables depend on the location of this directory.
subdir = po/$(DOMAIN)
top_builddir = ../..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --from-code=UTF-8 --sort-by-file --keyword=sgettext --keyword=vgettext --keyword=_n:1,2 --keyword=sngettext:1,2 --keyword=vngettext:1,2
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = Wesnoth development team
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
# in the GNU gettext documentation, section 'Preparing Strings'.
# - Strings which use unclear terms or require additional context to be
# understood.
# - Strings which make invalid assumptions about notation of date, time or
# money.
# - Pluralisation problems.
# - Incorrect English spelling.
# - Incorrect formatting.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS =http://bugs.wesnoth.org/
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
EOF
touch po/%(textdomain)s/POTFILES.in
ed po/Makefile.am <<'EOF'
/^SUBDIRS/s/$/ %(textdomain)s/
wq
EOF
# Warning: this depends on m4/Makefile being in the list of generated files
ed configure.ac <<'EOF'
/m4\/Makefile/-1a
po/%(textdomain)s/Makefile.in
.
wq
EOF
svn add po/%(textdomain)s
# To be able to review the commit before actually doing it
# recommended commit-msg: Wescamp import
svn commit configure.ac po/Makefile.am po/%(textdomain)s
""" % locals()