[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: install-sh



  User: pcjc2   
  Date: 06/09/19 05:42:42

  Added:       .        install-sh missing msgfmt.py py-compile
                        pygettext.py
  Log:
  Initial commit of xgsch2pcb
  
  
  
  
  Revision  Changes    Path
  1.1                  eda/geda/xgsch2pcb/tools/install-sh
  
  Index: install-sh
  ===================================================================
  #!/bin/sh
  # install - install a program, script, or datafile
  
  scriptversion=2005-05-14.22
  
  # This originates from X11R5 (mit/util/scripts/install.sh), which was
  # later released in X11R6 (xc/config/util/install.sh) with the
  # following copyright and license.
  #
  # Copyright (C) 1994 X Consortium
  #
  # Permission is hereby granted, free of charge, to any person obtaining a copy
  # of this software and associated documentation files (the "Software"), to
  # deal in the Software without restriction, including without limitation the
  # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  # sell copies of the Software, and to permit persons to whom the Software is
  # furnished to do so, subject to the following conditions:
  #
  # The above copyright notice and this permission notice shall be included in
  # all copies or substantial portions of the Software.
  #
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
  # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  #
  # Except as contained in this notice, the name of the X Consortium shall not
  # be used in advertising or otherwise to promote the sale, use or other deal-
  # ings in this Software without prior written authorization from the X Consor-
  # tium.
  #
  #
  # FSF changes to this file are in the public domain.
  #
  # Calling this script install-sh is preferred over install.sh, to prevent
  # `make' implicit rules from creating a file called install from it
  # when there is no Makefile.
  #
  # This script is compatible with the BSD install script, but was written
  # from scratch.  It can only install one file at a time, a restriction
  # shared with many OS's install programs.
  
  # set DOITPROG to echo to test this script
  
  # Don't use :- since 4.3BSD and earlier shells don't like it.
  doit="${DOITPROG-}"
  
  # put in absolute paths if you don't have them in your path; or use env. vars.
  
  mvprog="${MVPROG-mv}"
  cpprog="${CPPROG-cp}"
  chmodprog="${CHMODPROG-chmod}"
  chownprog="${CHOWNPROG-chown}"
  chgrpprog="${CHGRPPROG-chgrp}"
  stripprog="${STRIPPROG-strip}"
  rmprog="${RMPROG-rm}"
  mkdirprog="${MKDIRPROG-mkdir}"
  
  chmodcmd="$chmodprog 0755"
  chowncmd=
  chgrpcmd=
  stripcmd=
  rmcmd="$rmprog -f"
  mvcmd="$mvprog"
  src=
  dst=
  dir_arg=
  dstarg=
  no_target_directory=
  
  usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
     or: $0 [OPTION]... SRCFILES... DIRECTORY
     or: $0 [OPTION]... -t DIRECTORY SRCFILES...
     or: $0 [OPTION]... -d DIRECTORIES...
  
  In the 1st form, copy SRCFILE to DSTFILE.
  In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
  In the 4th, create DIRECTORIES.
  
  Options:
  -c         (ignored)
  -d         create directories instead of installing files.
  -g GROUP   $chgrpprog installed files to GROUP.
  -m MODE    $chmodprog installed files to MODE.
  -o USER    $chownprog installed files to USER.
  -s         $stripprog installed files.
  -t DIRECTORY  install into DIRECTORY.
  -T         report an error if DSTFILE is a directory.
  --help     display this help and exit.
  --version  display version info and exit.
  
  Environment variables override the default commands:
    CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
  "
  
  while test -n "$1"; do
    case $1 in
      -c) shift
          continue;;
  
      -d) dir_arg=true
          shift
          continue;;
  
      -g) chgrpcmd="$chgrpprog $2"
          shift
          shift
          continue;;
  
      --help) echo "$usage"; exit $?;;
  
      -m) chmodcmd="$chmodprog $2"
          shift
          shift
          continue;;
  
      -o) chowncmd="$chownprog $2"
          shift
          shift
          continue;;
  
      -s) stripcmd=$stripprog
          shift
          continue;;
  
      -t) dstarg=$2
  	shift
  	shift
  	continue;;
  
      -T) no_target_directory=true
  	shift
  	continue;;
  
      --version) echo "$0 $scriptversion"; exit $?;;
  
      *)  # When -d is used, all remaining arguments are directories to create.
  	# When -t is used, the destination is already specified.
  	test -n "$dir_arg$dstarg" && break
          # Otherwise, the last argument is the destination.  Remove it from $@.
  	for arg
  	do
            if test -n "$dstarg"; then
  	    # $@ is not empty: it contains at least $arg.
  	    set fnord "$@" "$dstarg"
  	    shift # fnord
  	  fi
  	  shift # arg
  	  dstarg=$arg
  	done
  	break;;
    esac
  done
  
  if test -z "$1"; then
    if test -z "$dir_arg"; then
      echo "$0: no input file specified." >&2
      exit 1
    fi
    # It's OK to call `install-sh -d' without argument.
    # This can happen when creating conditional directories.
    exit 0
  fi
  
  for src
  do
    # Protect names starting with `-'.
    case $src in
      -*) src=./$src ;;
    esac
  
    if test -n "$dir_arg"; then
      dst=$src
      src=
  
      if test -d "$dst"; then
        mkdircmd=:
        chmodcmd=
      else
        mkdircmd=$mkdirprog
      fi
    else
      # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
      # might cause directories to be created, which would be especially bad
      # if $src (and thus $dsttmp) contains '*'.
      if test ! -f "$src" && test ! -d "$src"; then
        echo "$0: $src does not exist." >&2
        exit 1
      fi
  
      if test -z "$dstarg"; then
        echo "$0: no destination specified." >&2
        exit 1
      fi
  
      dst=$dstarg
      # Protect names starting with `-'.
      case $dst in
        -*) dst=./$dst ;;
      esac
  
      # If destination is a directory, append the input filename; won't work
      # if double slashes aren't ignored.
      if test -d "$dst"; then
        if test -n "$no_target_directory"; then
  	echo "$0: $dstarg: Is a directory" >&2
  	exit 1
        fi
        dst=$dst/`basename "$src"`
      fi
    fi
  
    # This sed command emulates the dirname command.
    dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
  
    # Make sure that the destination directory exists.
  
    # Skip lots of stat calls in the usual case.
    if test ! -d "$dstdir"; then
      defaultIFS='
  	 '
      IFS="${IFS-$defaultIFS}"
  
      oIFS=$IFS
      # Some sh's can't handle IFS=/ for some reason.
      IFS='%'
      set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
      shift
      IFS=$oIFS
  
      pathcomp=
  
      while test $# -ne 0 ; do
        pathcomp=$pathcomp$1
        shift
        if test ! -d "$pathcomp"; then
          $mkdirprog "$pathcomp"
  	# mkdir can fail with a `File exist' error in case several
  	# install-sh are creating the directory concurrently.  This
  	# is OK.
  	test -d "$pathcomp" || exit
        fi
        pathcomp=$pathcomp/
      done
    fi
  
    if test -n "$dir_arg"; then
      $doit $mkdircmd "$dst" \
        && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
        && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
        && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
        && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
  
    else
      dstfile=`basename "$dst"`
  
      # Make a couple of temp file names in the proper directory.
      dsttmp=$dstdir/_inst.$$_
      rmtmp=$dstdir/_rm.$$_
  
      # Trap to clean up those temp files at exit.
      trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
      trap '(exit $?); exit' 1 2 13 15
  
      # Copy the file name to the temp name.
      $doit $cpprog "$src" "$dsttmp" &&
  
      # and set any options; do chmod last to preserve setuid bits.
      #
      # If any of these fail, we abort the whole thing.  If we want to
      # ignore errors from any of these, just make sure not to ignore
      # errors from the above "$doit $cpprog $src $dsttmp" command.
      #
      { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
        && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
        && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
        && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
  
      # Now rename the file to the real destination.
      { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
        || {
  	   # The rename failed, perhaps because mv can't rename something else
  	   # to itself, or perhaps because mv is so ancient that it does not
  	   # support -f.
  
  	   # Now remove or move aside any old file at destination location.
  	   # We try this two ways since rm can't unlink itself on some
  	   # systems and the destination file might be busy for other
  	   # reasons.  In this case, the final cleanup might fail but the new
  	   # file should still install successfully.
  	   {
  	     if test -f "$dstdir/$dstfile"; then
  	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
  	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
  	       || {
  		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
  		 (exit 1); exit 1
  	       }
  	     else
  	       :
  	     fi
  	   } &&
  
  	   # Now rename the file to the real destination.
  	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
  	 }
      }
    fi || { (exit 1); exit 1; }
  done
  
  # The final little trick to "correctly" pass the exit status to the exit trap.
  {
    (exit 0); exit 0
  }
  
  # Local variables:
  # eval: (add-hook 'write-file-hooks 'time-stamp)
  # time-stamp-start: "scriptversion="
  # time-stamp-format: "%:y-%02m-%02d.%02H"
  # time-stamp-end: "$"
  # End:
  
  
  
  1.1                  eda/geda/xgsch2pcb/tools/missing
  
  Index: missing
  ===================================================================
  #! /bin/sh
  # Common stub for a few missing GNU programs while installing.
  
  scriptversion=2005-06-08.21
  
  # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
  #   Free Software Foundation, Inc.
  # Originally by Fran,cois Pinard <pinard@xxxxxxxxxxxxxxxx>, 1996.
  
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation; either version 2, or (at your option)
  # any later version.
  
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  # 02110-1301, USA.
  
  # As a special exception to the GNU General Public License, if you
  # distribute this file as part of a program that contains a
  # configuration script generated by Autoconf, you may include it under
  # the same distribution terms that you use for the rest of that program.
  
  if test $# -eq 0; then
    echo 1>&2 "Try \`$0 --help' for more information"
    exit 1
  fi
  
  run=:
  
  # In the cases where this matters, `missing' is being run in the
  # srcdir already.
  if test -f configure.ac; then
    configure_ac=configure.ac
  else
    configure_ac=configure.in
  fi
  
  msg="missing on your system"
  
  case "$1" in
  --run)
    # Try to run requested program, and just exit if it succeeds.
    run=
    shift
    "$@" && exit 0
    # Exit code 63 means version mismatch.  This often happens
    # when the user try to use an ancient version of a tool on
    # a file that requires a minimum version.  In this case we
    # we should proceed has if the program had been absent, or
    # if --run hadn't been passed.
    if test $? = 63; then
      run=:
      msg="probably too old"
    fi
    ;;
  
    -h|--h|--he|--hel|--help)
      echo "\
  $0 [OPTION]... PROGRAM [ARGUMENT]...
  
  Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
  error status if there is no known handling for PROGRAM.
  
  Options:
    -h, --help      display this help and exit
    -v, --version   output version information and exit
    --run           try to run the given command, and emulate it if it fails
  
  Supported PROGRAM values:
    aclocal      touch file \`aclocal.m4'
    autoconf     touch file \`configure'
    autoheader   touch file \`config.h.in'
    automake     touch all \`Makefile.in' files
    bison        create \`y.tab.[ch]', if possible, from existing .[ch]
    flex         create \`lex.yy.c', if possible, from existing .c
    help2man     touch the output file
    lex          create \`lex.yy.c', if possible, from existing .c
    makeinfo     touch the output file
    tar          try tar, gnutar, gtar, then tar without non-portable flags
    yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
  
  Send bug reports to <bug-automake@xxxxxxx>."
      exit $?
      ;;
  
    -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
      echo "missing $scriptversion (GNU Automake)"
      exit $?
      ;;
  
    -*)
      echo 1>&2 "$0: Unknown \`$1' option"
      echo 1>&2 "Try \`$0 --help' for more information"
      exit 1
      ;;
  
  esac
  
  # Now exit if we have it, but it failed.  Also exit now if we
  # don't have it and --version was passed (most likely to detect
  # the program).
  case "$1" in
    lex|yacc)
      # Not GNU programs, they don't have --version.
      ;;
  
    tar)
      if test -n "$run"; then
         echo 1>&2 "ERROR: \`tar' requires --run"
         exit 1
      elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
         exit 1
      fi
      ;;
  
    *)
      if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
         # We have it, but it failed.
         exit 1
      elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
         # Could not run --version or --help.  This is probably someone
         # running `$TOOL --version' or `$TOOL --help' to check whether
         # $TOOL exists and not knowing $TOOL uses missing.
         exit 1
      fi
      ;;
  esac
  
  # If it does not exist, or fails to run (possibly an outdated version),
  # try to emulate it.
  case "$1" in
    aclocal*)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
           to install the \`Automake' and \`Perl' packages.  Grab them from
           any GNU archive site."
      touch aclocal.m4
      ;;
  
    autoconf)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified \`${configure_ac}'.  You might want to install the
           \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
           archive site."
      touch configure
      ;;
  
    autoheader)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified \`acconfig.h' or \`${configure_ac}'.  You might want
           to install the \`Autoconf' and \`GNU m4' packages.  Grab them
           from any GNU archive site."
      files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
      test -z "$files" && files="config.h"
      touch_files=
      for f in $files; do
        case "$f" in
        *:*) touch_files="$touch_files "`echo "$f" |
  				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
        *) touch_files="$touch_files $f.in";;
        esac
      done
      touch $touch_files
      ;;
  
    automake*)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
           You might want to install the \`Automake' and \`Perl' packages.
           Grab them from any GNU archive site."
      find . -type f -name Makefile.am -print |
  	   sed 's/\.am$/.in/' |
  	   while read f; do touch "$f"; done
      ;;
  
    autom4te)
      echo 1>&2 "\
  WARNING: \`$1' is needed, but is $msg.
           You might have modified some files without having the
           proper tools for further handling them.
           You can get \`$1' as part of \`Autoconf' from any GNU
           archive site."
  
      file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
      test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
      if test -f "$file"; then
  	touch $file
      else
  	test -z "$file" || exec >$file
  	echo "#! /bin/sh"
  	echo "# Created by GNU Automake missing as a replacement of"
  	echo "#  $ $@"
  	echo "exit 0"
  	chmod +x $file
  	exit 1
      fi
      ;;
  
    bison|yacc)
      echo 1>&2 "\
  WARNING: \`$1' $msg.  You should only need it if
           you modified a \`.y' file.  You may need the \`Bison' package
           in order for those modifications to take effect.  You can get
           \`Bison' from any GNU archive site."
      rm -f y.tab.c y.tab.h
      if [ $# -ne 1 ]; then
          eval LASTARG="\${$#}"
  	case "$LASTARG" in
  	*.y)
  	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
  	    if [ -f "$SRCFILE" ]; then
  	         cp "$SRCFILE" y.tab.c
  	    fi
  	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
  	    if [ -f "$SRCFILE" ]; then
  	         cp "$SRCFILE" y.tab.h
  	    fi
  	  ;;
  	esac
      fi
      if [ ! -f y.tab.h ]; then
  	echo >y.tab.h
      fi
      if [ ! -f y.tab.c ]; then
  	echo 'main() { return 0; }' >y.tab.c
      fi
      ;;
  
    lex|flex)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified a \`.l' file.  You may need the \`Flex' package
           in order for those modifications to take effect.  You can get
           \`Flex' from any GNU archive site."
      rm -f lex.yy.c
      if [ $# -ne 1 ]; then
          eval LASTARG="\${$#}"
  	case "$LASTARG" in
  	*.l)
  	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
  	    if [ -f "$SRCFILE" ]; then
  	         cp "$SRCFILE" lex.yy.c
  	    fi
  	  ;;
  	esac
      fi
      if [ ! -f lex.yy.c ]; then
  	echo 'main() { return 0; }' >lex.yy.c
      fi
      ;;
  
    help2man)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
  	 you modified a dependency of a manual page.  You may need the
  	 \`Help2man' package in order for those modifications to take
  	 effect.  You can get \`Help2man' from any GNU archive site."
  
      file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
      if test -z "$file"; then
  	file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
      fi
      if [ -f "$file" ]; then
  	touch $file
      else
  	test -z "$file" || exec >$file
  	echo ".ab help2man is required to generate this page"
  	exit 1
      fi
      ;;
  
    makeinfo)
      echo 1>&2 "\
  WARNING: \`$1' is $msg.  You should only need it if
           you modified a \`.texi' or \`.texinfo' file, or any other file
           indirectly affecting the aspect of the manual.  The spurious
           call might also be the consequence of using a buggy \`make' (AIX,
           DU, IRIX).  You might want to install the \`Texinfo' package or
           the \`GNU make' package.  Grab either from any GNU archive site."
      # The file to touch is that specified with -o ...
      file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
      if test -z "$file"; then
        # ... or it is the one specified with @setfilename ...
        infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
        file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
        # ... or it is derived from the source name (dir/f.texi becomes f.info)
        test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
      fi
      # If the file does not exist, the user really needs makeinfo;
      # let's fail without touching anything.
      test -f $file || exit 1
      touch $file
      ;;
  
    tar)
      shift
  
      # We have already tried tar in the generic part.
      # Look for gnutar/gtar before invocation to avoid ugly error
      # messages.
      if (gnutar --version > /dev/null 2>&1); then
         gnutar "$@" && exit 0
      fi
      if (gtar --version > /dev/null 2>&1); then
         gtar "$@" && exit 0
      fi
      firstarg="$1"
      if shift; then
  	case "$firstarg" in
  	*o*)
  	    firstarg=`echo "$firstarg" | sed s/o//`
  	    tar "$firstarg" "$@" && exit 0
  	    ;;
  	esac
  	case "$firstarg" in
  	*h*)
  	    firstarg=`echo "$firstarg" | sed s/h//`
  	    tar "$firstarg" "$@" && exit 0
  	    ;;
  	esac
      fi
  
      echo 1>&2 "\
  WARNING: I can't seem to be able to run \`tar' with the given arguments.
           You may want to install GNU tar or Free paxutils, or check the
           command line arguments."
      exit 1
      ;;
  
    *)
      echo 1>&2 "\
  WARNING: \`$1' is needed, and is $msg.
           You might have modified some files without having the
           proper tools for further handling them.  Check the \`README' file,
           it often tells you about the needed prerequisites for installing
           this package.  You may also peek at any GNU archive site, in case
           some other package would contain this missing \`$1' program."
      exit 1
      ;;
  esac
  
  exit 0
  
  # Local variables:
  # eval: (add-hook 'write-file-hooks 'time-stamp)
  # time-stamp-start: "scriptversion="
  # time-stamp-format: "%:y-%02m-%02d.%02H"
  # time-stamp-end: "$"
  # End:
  
  
  
  1.1                  eda/geda/xgsch2pcb/tools/msgfmt.py
  
  Index: msgfmt.py
  ===================================================================
  #! /usr/bin/env python
  # -*- coding: iso-8859-1 -*-
  # Written by Martin v. Löwis <loewis@xxxxxxxxxxxxxxxxxxxxxxx>
  
  """Generate binary message catalog from textual translation description.
  
  This program converts a textual Uniforum-style message catalog (.po file) into
  a binary GNU catalog (.mo file).  This is essentially the same function as the
  GNU msgfmt program, however, it is a simpler implementation.
  
  Usage: msgfmt.py [OPTIONS] filename.po
  
  Options:
      -o file
      --output-file=file
          Specify the output file to write to.  If omitted, output will go to a
          file named filename.mo (based off the input file name).
  
      -h
      --help
          Print this message and exit.
  
      -V
      --version
          Display version information and exit.
  """
  
  import sys
  import os
  import getopt
  import struct
  import array
  
  __version__ = "1.1"
  
  MESSAGES = {}
  
  
  
  def usage(code, msg=''):
      print >> sys.stderr, __doc__
      if msg:
          print >> sys.stderr, msg
      sys.exit(code)
  
  
  
  def add(id, str, fuzzy):
      "Add a non-fuzzy translation to the dictionary."
      global MESSAGES
      if not fuzzy and str:
          MESSAGES[id] = str
  
  
  
  def generate():
      "Return the generated output."
      global MESSAGES
      keys = MESSAGES.keys()
      # the keys are sorted in the .mo file
      keys.sort()
      offsets = []
      ids = strs = ''
      for id in keys:
          # For each string, we need size and file offset.  Each string is NUL
          # terminated; the NUL does not count into the size.
          offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id])))
          ids += id + '\0'
          strs += MESSAGES[id] + '\0'
      output = ''
      # The header is 7 32-bit unsigned integers.  We don't use hash tables, so
      # the keys start right after the index tables.
      # translated string.
      keystart = 7*4+16*len(keys)
      # and the values start after the keys
      valuestart = keystart + len(ids)
      koffsets = []
      voffsets = []
      # The string table first has the list of keys, then the list of values.
      # Each entry has first the size of the string, then the file offset.
      for o1, l1, o2, l2 in offsets:
          koffsets += [l1, o1+keystart]
          voffsets += [l2, o2+valuestart]
      offsets = koffsets + voffsets
      output = struct.pack("Iiiiiii",
                           0x950412deL,       # Magic
                           0,                 # Version
                           len(keys),         # # of entries
                           7*4,               # start of key index
                           7*4+len(keys)*8,   # start of value index
                           0, 0)              # size and offset of hash table
      output += array.array("i", offsets).tostring()
      output += ids
      output += strs
      return output
  
  
  
  def make(filename, outfile):
      ID = 1
      STR = 2
  
      # Compute .mo name from .po name and arguments
      if filename.endswith('.po'):
          infile = filename
      else:
          infile = filename + '.po'
      if outfile is None:
          outfile = os.path.splitext(infile)[0] + '.mo'
  
      try:
          lines = open(infile).readlines()
      except IOError, msg:
          print >> sys.stderr, msg
          sys.exit(1)
  
      section = None
      fuzzy = 0
  
      # Parse the catalog
      lno = 0
      for l in lines:
          lno += 1
          # If we get a comment line after a msgstr, this is a new entry
          if l[0] == '#' and section == STR:
              add(msgid, msgstr, fuzzy)
              section = None
              fuzzy = 0
          # Record a fuzzy mark
          if l[:2] == '#,' and l.find('fuzzy'):
              fuzzy = 1
          # Skip comments
          if l[0] == '#':
              continue
          # Now we are in a msgid section, output previous section
          if l.startswith('msgid'):
              if section == STR:
                  add(msgid, msgstr, fuzzy)
              section = ID
              l = l[5:]
              msgid = msgstr = ''
          # Now we are in a msgstr section
          elif l.startswith('msgstr'):
              section = STR
              l = l[6:]
          # Skip empty lines
          l = l.strip()
          if not l:
              continue
          # XXX: Does this always follow Python escape semantics?
          l = eval(l)
          if section == ID:
              msgid += l
          elif section == STR:
              msgstr += l
          else:
              print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \
                    'before:'
              print >> sys.stderr, l
              sys.exit(1)
      # Add last entry
      if section == STR:
          add(msgid, msgstr, fuzzy)
  
      # Compute output
      output = generate()
  
      try:
          open(outfile,"wb").write(output)
      except IOError,msg:
          print >> sys.stderr, msg
  
  
  
  def main():
      try:
          opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
                                     ['help', 'version', 'output-file='])
      except getopt.error, msg:
          usage(1, msg)
  
      outfile = None
      # parse options
      for opt, arg in opts:
          if opt in ('-h', '--help'):
              usage(0)
          elif opt in ('-V', '--version'):
              print >> sys.stderr, "msgfmt.py", __version__
              sys.exit(0)
          elif opt in ('-o', '--output-file'):
              outfile = arg
      # do it
      if not args:
          print >> sys.stderr, 'No input file given'
          print >> sys.stderr, "Try `msgfmt --help' for more information."
          return
  
      for filename in args:
          make(filename, outfile)
  
  
  if __name__ == '__main__':
      main()
  
  
  
  1.1                  eda/geda/xgsch2pcb/tools/py-compile
  
  Index: py-compile
  ===================================================================
  #!/bin/sh
  # py-compile - Compile a Python program
  
  scriptversion=2005-05-14.22
  
  # Copyright (C) 2000, 2001, 2003, 2004, 2005  Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation; either version 2, or (at your option)
  # any later version.
  
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  # 02110-1301, USA.
  
  # As a special exception to the GNU General Public License, if you
  # distribute this file as part of a program that contains a
  # configuration script generated by Autoconf, you may include it under
  # the same distribution terms that you use for the rest of that program.
  
  # This file is maintained in Automake, please report
  # bugs to <bug-automake@xxxxxxx> or send patches to
  # <automake-patches@xxxxxxx>.
  
  if [ -z "$PYTHON" ]; then
    PYTHON=python
  fi
  
  basedir=
  destdir=
  files=
  while test $# -ne 0; do
    case "$1" in
      --basedir)
        basedir=$2
        if test -z "$basedir"; then
          echo "$0: Missing argument to --basedir." 1>&2
          exit 1
        fi
        shift
        ;;
      --destdir)
        destdir=$2
        if test -z "$destdir"; then
          echo "$0: Missing argument to --destdir." 1>&2
          exit 1
        fi
        shift
        ;;
      -h|--h*)
        cat <<\EOF
  Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
  
  Byte compile some python scripts FILES.  Use --destdir to specify any
  leading directory path to the FILES that you don't want to include in the
  byte compiled file.  Specify --basedir for any additional path information you
  do want to be shown in the byte compiled file.
  
  Example:
    py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
  
  Report bugs to <bug-automake@xxxxxxx>.
  EOF
        exit $?
        ;;
      -v|--v*)
        echo "py-compile $scriptversion"
        exit $?
        ;;
      *)
        files="$files $1"
        ;;
    esac
    shift
  done
  
  if test -z "$files"; then
      echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
      exit 1
  fi
  
  # if basedir was given, then it should be prepended to filenames before
  # byte compilation.
  if [ -z "$basedir" ]; then
      pathtrans="path = file"
  else
      pathtrans="path = os.path.join('$basedir', file)"
  fi
  
  # if destdir was given, then it needs to be prepended to the filename to
  # byte compile but not go into the compiled file.
  if [ -z "$destdir" ]; then
      filetrans="filepath = path"
  else
      filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
  fi
  
  $PYTHON -c "
  import sys, os, string, py_compile
  
  files = '''$files'''
  
  print 'Byte-compiling python modules...'
  for file in string.split(files):
      $pathtrans
      $filetrans
      if not os.path.exists(filepath) or not (len(filepath) >= 3
                                              and filepath[-3:] == '.py'):
  	continue
      print file,
      sys.stdout.flush()
      py_compile.compile(filepath, filepath + 'c', path)
  print" || exit $?
  
  # this will fail for python < 1.5, but that doesn't matter ...
  $PYTHON -O -c "
  import sys, os, string, py_compile
  
  files = '''$files'''
  print 'Byte-compiling python modules (optimized versions) ...'
  for file in string.split(files):
      $pathtrans
      $filetrans
      if not os.path.exists(filepath) or not (len(filepath) >= 3
                                              and filepath[-3:] == '.py'):
  	continue
      print file,
      sys.stdout.flush()
      py_compile.compile(filepath, filepath + 'o', path)
  print" 2>/dev/null || :
  
  # Local Variables:
  # mode: shell-script
  # sh-indentation: 2
  # eval: (add-hook 'write-file-hooks 'time-stamp)
  # time-stamp-start: "scriptversion="
  # time-stamp-format: "%:y-%02m-%02d.%02H"
  # time-stamp-end: "$"
  # End:
  
  
  
  1.1                  eda/geda/xgsch2pcb/tools/pygettext.py
  
  Index: pygettext.py
  ===================================================================
  #! /usr/bin/env python
  # -*- coding: iso-8859-1 -*-
  # Originally written by Barry Warsaw <barry@xxxxxxxx>
  #
  # Minimally patched to make it even more xgettext compatible
  # by Peter Funk <pf@xxxxxxxxxxxxxx>
  #
  # 2002-11-22 Jürgen Hermann <jh@xxxxxx>
  # Added checks that _() only contains string literals, and
  # command line args are resolved to module lists, i.e. you
  # can now pass a filename, a module or package name, or a
  # directory (including globbing chars, important for Win32).
  # Made docstring fit in 80 chars wide displays using pydoc.
  #
  
  # for selftesting
  try:
      import fintl
      _ = fintl.gettext
  except ImportError:
      _ = lambda s: s
  
  __doc__ = _("""pygettext -- Python equivalent of xgettext(1)
  
  Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the
  internationalization of C programs. Most of these tools are independent of
  the programming language and can be used from within Python programs.
  Martin von Loewis' work[1] helps considerably in this regard.
  
  There's one problem though; xgettext is the program that scans source code
  looking for message strings, but it groks only C (or C++). Python
  introduces a few wrinkles, such as dual quoting characters, triple quoted
  strings, and raw strings. xgettext understands none of this.
  
  Enter pygettext, which uses Python's standard tokenize module to scan
  Python source code, generating .pot files identical to what GNU xgettext[2]
  generates for C and C++ code. From there, the standard GNU tools can be
  used.
  
  A word about marking Python strings as candidates for translation. GNU
  xgettext recognizes the following keywords: gettext, dgettext, dcgettext,
  and gettext_noop. But those can be a lot of text to include all over your
  code. C and C++ have a trick: they use the C preprocessor. Most
  internationalized C source includes a #define for gettext() to _() so that
  what has to be written in the source is much less. Thus these are both
  translatable strings:
  
      gettext("Translatable String")
      _("Translatable String")
  
  Python of course has no preprocessor so this doesn't work so well.  Thus,
  pygettext searches only for _() by default, but see the -k/--keyword flag
  below for how to augment this.
  
   [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html
   [2] http://www.gnu.org/software/gettext/gettext.html
  
  NOTE: pygettext attempts to be option and feature compatible with GNU
  xgettext where ever possible. However some options are still missing or are
  not fully implemented. Also, xgettext's use of command line switches with
  option arguments is broken, and in these cases, pygettext just defines
  additional switches.
  
  Usage: pygettext [options] inputfile ...
  
  Options:
  
      -a
      --extract-all
          Extract all strings.
  
      -d name
      --default-domain=name
          Rename the default output file from messages.pot to name.pot.
  
      -E
      --escape
          Replace non-ASCII characters with octal escape sequences.
  
      -D
      --docstrings
          Extract module, class, method, and function docstrings.  These do
          not need to be wrapped in _() markers, and in fact cannot be for
          Python to consider them docstrings. (See also the -X option).
  
      -h
      --help
          Print this help message and exit.
  
      -k word
      --keyword=word
          Keywords to look for in addition to the default set, which are:
          %(DEFAULTKEYWORDS)s
  
          You can have multiple -k flags on the command line.
  
      -K
      --no-default-keywords
          Disable the default set of keywords (see above).  Any keywords
          explicitly added with the -k/--keyword option are still recognized.
  
      --no-location
          Do not write filename/lineno location comments.
  
      -n
      --add-location
          Write filename/lineno location comments indicating where each
          extracted string is found in the source.  These lines appear before
          each msgid.  The style of comments is controlled by the -S/--style
          option.  This is the default.
  
      -o filename
      --output=filename
          Rename the default output file from messages.pot to filename.  If
          filename is `-' then the output is sent to standard out.
  
      -p dir
      --output-dir=dir
          Output files will be placed in directory dir.
  
      -S stylename
      --style stylename
          Specify which style to use for location comments.  Two styles are
          supported:
  
          Solaris  # File: filename, line: line-number
          GNU      #: filename:line
  
          The style name is case insensitive.  GNU style is the default.
  
      -v
      --verbose
          Print the names of the files being processed.
  
      -V
      --version
          Print the version of pygettext and exit.
  
      -w columns
      --width=columns
          Set width of output to columns.
  
      -x filename
      --exclude-file=filename
          Specify a file that contains a list of strings that are not be
          extracted from the input files.  Each string to be excluded must
          appear on a line by itself in the file.
  
      -X filename
      --no-docstrings=filename
          Specify a file that contains a list of files (one per line) that
          should not have their docstrings extracted.  This is only useful in
          conjunction with the -D option above.
  
  If `inputfile' is -, standard input is read.
  """)
  
  import os
  import imp
  import sys
  import glob
  import time
  import getopt
  import token
  import tokenize
  import operator
  
  __version__ = '1.5'
  
  default_keywords = ['_']
  DEFAULTKEYWORDS = ', '.join(default_keywords)
  
  EMPTYSTRING = ''
  
  
  
  # The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
  # there.
  pot_header = _('''\
  # SOME DESCRIPTIVE TITLE.
  # Copyright (C) YEAR ORGANIZATION
  # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
  #
  msgid ""
  msgstr ""
  "Project-Id-Version: PACKAGE VERSION\\n"
  "POT-Creation-Date: %(time)s\\n"
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
  "Language-Team: LANGUAGE <LL@xxxxxx>\\n"
  "MIME-Version: 1.0\\n"
  "Content-Type: text/plain; charset=CHARSET\\n"
  "Content-Transfer-Encoding: ENCODING\\n"
  "Generated-By: pygettext.py %(version)s\\n"
  
  ''')
  
  
  def usage(code, msg=''):
      print >> sys.stderr, __doc__ % globals()
      if msg:
          print >> sys.stderr, msg
      sys.exit(code)
  
  
  
  escapes = []
  
  def make_escapes(pass_iso8859):
      global escapes
      if pass_iso8859:
          # Allow iso-8859 characters to pass through so that e.g. 'msgid
          # "Höhe"' would result not result in 'msgid "H\366he"'.  Otherwise we
          # escape any character outside the 32..126 range.
          mod = 128
      else:
          mod = 256
      for i in range(256):
          if 32 <= (i % mod) <= 126:
              escapes.append(chr(i))
          else:
              escapes.append("\\%03o" % i)
      escapes[ord('\\')] = '\\\\'
      escapes[ord('\t')] = '\\t'
      escapes[ord('\r')] = '\\r'
      escapes[ord('\n')] = '\\n'
      escapes[ord('\"')] = '\\"'
  
  
  def escape(s):
      global escapes
      s = list(s)
      for i in range(len(s)):
          s[i] = escapes[ord(s[i])]
      return EMPTYSTRING.join(s)
  
  
  def safe_eval(s):
      # unwrap quotes, safely
      return eval(s, {'__builtins__':{}}, {})
  
  
  def normalize(s):
      # This converts the various Python string types into a format that is
      # appropriate for .po files, namely much closer to C style.
      lines = s.split('\n')
      if len(lines) == 1:
          s = '"' + escape(s) + '"'
      else:
          if not lines[-1]:
              del lines[-1]
              lines[-1] = lines[-1] + '\n'
          for i in range(len(lines)):
              lines[i] = escape(lines[i])
          lineterm = '\\n"\n"'
          s = '""\n"' + lineterm.join(lines) + '"'
      return s
  
  
  def containsAny(str, set):
      """Check whether 'str' contains ANY of the chars in 'set'"""
      return 1 in [c in str for c in set]
  
  
  def _visit_pyfiles(list, dirname, names):
      """Helper for getFilesForName()."""
      # get extension for python source files
      if not globals().has_key('_py_ext'):
          global _py_ext
          _py_ext = [triple[0] for triple in imp.get_suffixes()
                     if triple[2] == imp.PY_SOURCE][0]
  
      # don't recurse into CVS directories
      if 'CVS' in names:
          names.remove('CVS')
  
      # add all *.py files to list
      list.extend(
          [os.path.join(dirname, file) for file in names
           if os.path.splitext(file)[1] == _py_ext]
          )
  
  
  def _get_modpkg_path(dotted_name, pathlist=None):
      """Get the filesystem path for a module or a package.
  
      Return the file system path to a file for a module, and to a directory for
      a package. Return None if the name is not found, or is a builtin or
      extension module.
      """
      # split off top-most name
      parts = dotted_name.split('.', 1)
  
      if len(parts) > 1:
          # we have a dotted path, import top-level package
          try:
              file, pathname, description = imp.find_module(parts[0], pathlist)
              if file: file.close()
          except ImportError:
              return None
  
          # check if it's indeed a package
          if description[2] == imp.PKG_DIRECTORY:
              # recursively handle the remaining name parts
              pathname = _get_modpkg_path(parts[1], [pathname])
          else:
              pathname = None
      else:
          # plain name
          try:
              file, pathname, description = imp.find_module(
                  dotted_name, pathlist)
              if file:
                  file.close()
              if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
                  pathname = None
          except ImportError:
              pathname = None
  
      return pathname
  
  
  def getFilesForName(name):
      """Get a list of module files for a filename, a module or package name,
      or a directory.
      """
      if not os.path.exists(name):
          # check for glob chars
          if containsAny(name, "*?[]"):
              files = glob.glob(name)
              list = []
              for file in files:
                  list.extend(getFilesForName(file))
              return list
  
          # try to find module or package
          name = _get_modpkg_path(name)
          if not name:
              return []
  
      if os.path.isdir(name):
          # find all python files in directory
          list = []
          os.path.walk(name, _visit_pyfiles, list)
          return list
      elif os.path.exists(name):
          # a single file
          return [name]
  
      return []
  
  
  class TokenEater:
      def __init__(self, options):
          self.__options = options
          self.__messages = {}
          self.__state = self.__waiting
          self.__data = []
          self.__lineno = -1
          self.__freshmodule = 1
          self.__curfile = None
  
      def __call__(self, ttype, tstring, stup, etup, line):
          # dispatch
  ##        import token
  ##        print >> sys.stderr, 'ttype:', token.tok_name[ttype], \
  ##              'tstring:', tstring
          self.__state(ttype, tstring, stup[0])
  
      def __waiting(self, ttype, tstring, lineno):
          opts = self.__options
          # Do docstring extractions, if enabled
          if opts.docstrings and not opts.nodocstrings.get(self.__curfile):
              # module docstring?
              if self.__freshmodule:
                  if ttype == tokenize.STRING:
                      self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
                      self.__freshmodule = 0
                  elif ttype not in (tokenize.COMMENT, tokenize.NL):
                      self.__freshmodule = 0
                  return
              # class docstring?
              if ttype == tokenize.NAME and tstring in ('class', 'def'):
                  self.__state = self.__suiteseen
                  return
          if ttype == tokenize.NAME and tstring in opts.keywords:
              self.__state = self.__keywordseen
  
      def __suiteseen(self, ttype, tstring, lineno):
          # ignore anything until we see the colon
          if ttype == tokenize.OP and tstring == ':':
              self.__state = self.__suitedocstring
  
      def __suitedocstring(self, ttype, tstring, lineno):
          # ignore any intervening noise
          if ttype == tokenize.STRING:
              self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
              self.__state = self.__waiting
          elif ttype not in (tokenize.NEWLINE, tokenize.INDENT,
                             tokenize.COMMENT):
              # there was no class docstring
              self.__state = self.__waiting
  
      def __keywordseen(self, ttype, tstring, lineno):
          if ttype == tokenize.OP and tstring == '(':
              self.__data = []
              self.__lineno = lineno
              self.__state = self.__openseen
          else:
              self.__state = self.__waiting
  
      def __openseen(self, ttype, tstring, lineno):
          if ttype == tokenize.OP and tstring == ')':
              # We've seen the last of the translatable strings.  Record the
              # line number of the first line of the strings and update the list
              # of messages seen.  Reset state for the next batch.  If there
              # were no strings inside _(), then just ignore this entry.
              if self.__data:
                  self.__addentry(EMPTYSTRING.join(self.__data))
              self.__state = self.__waiting
          elif ttype == tokenize.STRING:
              self.__data.append(safe_eval(tstring))
          elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
                             token.NEWLINE, tokenize.NL]:
              # warn if we see anything else than STRING or whitespace
              print >> sys.stderr, _(
                  '*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
                  ) % {
                  'token': tstring,
                  'file': self.__curfile,
                  'lineno': self.__lineno
                  }
              self.__state = self.__waiting
  
      def __addentry(self, msg, lineno=None, isdocstring=0):
          if lineno is None:
              lineno = self.__lineno
          if not msg in self.__options.toexclude:
              entry = (self.__curfile, lineno)
              self.__messages.setdefault(msg, {})[entry] = isdocstring
  
      def set_filename(self, filename):
          self.__curfile = filename
          self.__freshmodule = 1
  
      def write(self, fp):
          options = self.__options
          timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
          # The time stamp in the header doesn't have the same format as that
          # generated by xgettext...
          print >> fp, pot_header % {'time': timestamp, 'version': __version__}
          # Sort the entries.  First sort each particular entry's keys, then
          # sort all the entries by their first item.
          reverse = {}
          for k, v in self.__messages.items():
              keys = v.keys()
              keys.sort()
              reverse.setdefault(tuple(keys), []).append((k, v))
          rkeys = reverse.keys()
          rkeys.sort()
          for rkey in rkeys:
              rentries = reverse[rkey]
              rentries.sort()
              for k, v in rentries:
                  isdocstring = 0
                  # If the entry was gleaned out of a docstring, then add a
                  # comment stating so.  This is to aid translators who may wish
                  # to skip translating some unimportant docstrings.
                  if reduce(operator.__add__, v.values()):
                      isdocstring = 1
                  # k is the message string, v is a dictionary-set of (filename,
                  # lineno) tuples.  We want to sort the entries in v first by
                  # file name and then by line number.
                  v = v.keys()
                  v.sort()
                  if not options.writelocations:
                      pass
                  # location comments are different b/w Solaris and GNU:
                  elif options.locationstyle == options.SOLARIS:
                      for filename, lineno in v:
                          d = {'filename': filename, 'lineno': lineno}
                          print >>fp, _(
                              '# File: %(filename)s, line: %(lineno)d') % d
                  elif options.locationstyle == options.GNU:
                      # fit as many locations on one line, as long as the
                      # resulting line length doesn't exceeds 'options.width'
                      locline = '#:'
                      for filename, lineno in v:
                          d = {'filename': filename, 'lineno': lineno}
                          s = _(' %(filename)s:%(lineno)d') % d
                          if len(locline) + len(s) <= options.width:
                              locline = locline + s
                          else:
                              print >> fp, locline
                              locline = "#:" + s
                      if len(locline) > 2:
                          print >> fp, locline
                  if isdocstring:
                      print >> fp, '#, docstring'
                  print >> fp, 'msgid', normalize(k)
                  print >> fp, 'msgstr ""\n'
  
  
  
  def main():
      global default_keywords
      try:
          opts, args = getopt.getopt(
              sys.argv[1:],
              'ad:DEhk:Kno:p:S:Vvw:x:X:',
              ['extract-all', 'default-domain=', 'escape', 'help',
               'keyword=', 'no-default-keywords',
               'add-location', 'no-location', 'output=', 'output-dir=',
               'style=', 'verbose', 'version', 'width=', 'exclude-file=',
               'docstrings', 'no-docstrings',
               ])
      except getopt.error, msg:
          usage(1, msg)
  
      # for holding option values
      class Options:
          # constants
          GNU = 1
          SOLARIS = 2
          # defaults
          extractall = 0 # FIXME: currently this option has no effect at all.
          escape = 0
          keywords = []
          outpath = ''
          outfile = 'messages.pot'
          writelocations = 1
          locationstyle = GNU
          verbose = 0
          width = 78
          excludefilename = ''
          docstrings = 0
          nodocstrings = {}
  
      options = Options()
      locations = {'gnu' : options.GNU,
                   'solaris' : options.SOLARIS,
                   }
  
      # parse options
      for opt, arg in opts:
          if opt in ('-h', '--help'):
              usage(0)
          elif opt in ('-a', '--extract-all'):
              options.extractall = 1
          elif opt in ('-d', '--default-domain'):
              options.outfile = arg + '.pot'
          elif opt in ('-E', '--escape'):
              options.escape = 1
          elif opt in ('-D', '--docstrings'):
              options.docstrings = 1
          elif opt in ('-k', '--keyword'):
              options.keywords.append(arg)
          elif opt in ('-K', '--no-default-keywords'):
              default_keywords = []
          elif opt in ('-n', '--add-location'):
              options.writelocations = 1
          elif opt in ('--no-location',):
              options.writelocations = 0
          elif opt in ('-S', '--style'):
              options.locationstyle = locations.get(arg.lower())
              if options.locationstyle is None:
                  usage(1, _('Invalid value for --style: %s') % arg)
          elif opt in ('-o', '--output'):
              options.outfile = arg
          elif opt in ('-p', '--output-dir'):
              options.outpath = arg
          elif opt in ('-v', '--verbose'):
              options.verbose = 1
          elif opt in ('-V', '--version'):
              print _('pygettext.py (xgettext for Python) %s') % __version__
              sys.exit(0)
          elif opt in ('-w', '--width'):
              try:
                  options.width = int(arg)
              except ValueError:
                  usage(1, _('--width argument must be an integer: %s') % arg)
          elif opt in ('-x', '--exclude-file'):
              options.excludefilename = arg
          elif opt in ('-X', '--no-docstrings'):
              fp = open(arg)
              try:
                  while 1:
                      line = fp.readline()
                      if not line:
                          break
                      options.nodocstrings[line[:-1]] = 1
              finally:
                  fp.close()
  
      # calculate escapes
      make_escapes(options.escape)
  
      # calculate all keywords
      options.keywords.extend(default_keywords)
  
      # initialize list of strings to exclude
      if options.excludefilename:
          try:
              fp = open(options.excludefilename)
              options.toexclude = fp.readlines()
              fp.close()
          except IOError:
              print >> sys.stderr, _(
                  "Can't read --exclude-file: %s") % options.excludefilename
              sys.exit(1)
      else:
          options.toexclude = []
  
      # resolve args to module lists
      expanded = []
      for arg in args:
          if arg == '-':
              expanded.append(arg)
          else:
              expanded.extend(getFilesForName(arg))
      args = expanded
  
      # slurp through all the files
      eater = TokenEater(options)
      for filename in args:
          if filename == '-':
              if options.verbose:
                  print _('Reading standard input')
              fp = sys.stdin
              closep = 0
          else:
              if options.verbose:
                  print _('Working on %s') % filename
              fp = open(filename)
              closep = 1
          try:
              eater.set_filename(filename)
              try:
                  tokenize.tokenize(fp.readline, eater)
              except tokenize.TokenError, e:
                  print >> sys.stderr, '%s: %s, line %d, column %d' % (
                      e[0], filename, e[1][0], e[1][1])
          finally:
              if closep:
                  fp.close()
  
      # write the output
      if options.outfile == '-':
          fp = sys.stdout
          closep = 0
      else:
          if options.outpath:
              options.outfile = os.path.join(options.outpath, options.outfile)
          fp = open(options.outfile, 'w')
          closep = 1
      try:
          eater.write(fp)
      finally:
          if closep:
              fp.close()
  
  
  if __name__ == '__main__':
      main()
      # some more test strings
      _(u'a unicode string')
      # this one creates a warning
      _('*** Seen unexpected token "%(token)s"') % {'token': 'test'}
      _('more' 'than' 'one' 'string')
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs