From: Han-Wen Nienhuys Date: Sun, 12 Mar 2006 23:28:09 +0000 (+0000) Subject: (print_environment): move ps_page_count to lilypond-book.py X-Git-Tag: release/2.7.39~23 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2653452d1d96361a98118b231cc0aed489d27dab;p=lilypond.git (print_environment): move ps_page_count to lilypond-book.py --- diff --git a/ChangeLog b/ChangeLog index 915e305196..7086ace430 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-03-13 Han-Wen Nienhuys + + * python/lilylib.py (print_environment): move ps_page_count to lilypond-book.py + 2006-03-12 Han-Wen Nienhuys * Documentation/user/music-glossary.tely (G clef): fix clef alignments. diff --git a/python/lilylib.py b/python/lilylib.py index 9f5d07bba1..23d268f620 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -6,11 +6,6 @@ # (c) 1998--2006 Han-Wen Nienhuys # Jan Nieuwenhuizen -### subst:\(^\|[^._a-z]\)\(abspath\|identify\|warranty\|progress\|warning\|error\|exit\|getopt_args\|option_help_str\|options_help_str\|help\|setup_temp\|read_pipe\|system\|cleanup_temp\|strip_extension\|cp_to_dir\|mkdir_p\|init\) *( -### replace:\1ly.\2 ( - -### subst: \(help_summary\|keep_temp_dir_p\|option_definitions\|original_dir\|program_name\|pseudo_filter_p\|temp_dir\|verbose_p\) - import __main__ import glob import os @@ -21,6 +16,13 @@ import sys import optparse import subprocess +## windows mingw cross compile doesn't have selectmodule.so +have_select = True +try: + import select +except ImportError: + have_select = False + ################################################################ # Users of python modules should include this snippet # and customize variables below. @@ -94,6 +96,9 @@ def system (cmd, log = '' + if not have_select: + show_progress = True + if show_progress: retval = proc.wait() else: @@ -140,13 +145,6 @@ def print_environment (): sys.stderr.write ("%s=\"%s\"\n" % (k, v)) -def ps_page_count (ps_name): - header = open (ps_name).read (1024) - m = re.search ('\n%%Pages: ([0-9]+)', header) - if m: - return string.atoi (m.group (1)) - return 0 - class NonDentedHeadingFormatter (optparse.IndentedHelpFormatter): def format_heading(self, heading): if heading: diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 322ce9a39b..f2f48142cd 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -117,6 +117,13 @@ def warning (s): def error (s): sys.stderr.write (program_name + ": " + _ ("error: %s") % s + '\n') +def ps_page_count (ps_name): + header = open (ps_name).read (1024) + m = re.search ('\n%%Pages: ([0-9]+)', header) + if m: + return string.atoi (m.group (1)) + return 0 + def warranty (): identify () sys.stdout.write (''' @@ -1059,7 +1066,7 @@ class Lilypond_snippet (Snippet): page_count = 0 if ok: - page_count = ly.ps_page_count (base + '.eps') + page_count = ps_page_count (base + '.eps') if page_count == 1: ok = ok and os.path.exists (base + '.png') @@ -1102,7 +1109,7 @@ class Lilypond_snippet (Snippet): and (not os.path.exists (single) \ or (os.stat (multiple)[stat.ST_MTIME] \ > os.stat (single)[stat.ST_MTIME])): - count = ly.ps_page_count ('%(base)s.eps' % vars ()) + count = ps_page_count ('%(base)s.eps' % vars ()) images = ['%s-page%d.png' % (base, a) for a in range (1, count+1)] images = tuple (images) return images