From 5c027e47764f47a1b693ad04e76e94373fec8eb0 Mon Sep 17 00:00:00 2001 From: hanwen Date: Thu, 2 Mar 2006 15:33:35 +0000 Subject: [PATCH] (grob-cause): replace backslashes by / --- ChangeLog | 9 +++++++++ python/lilylib.py | 13 ------------- scm/output-ps.scm | 7 +++++-- scripts/lilypond-book.py | 37 ++++++++++++++++++------------------- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c94ad4b98..3352597293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-03-02 Han-Wen Nienhuys + + * scm/output-ps.scm (grob-cause): replace backslashes by / + 2006-03-02 Jan Nieuwenhuizen * cygwin/GNUmakefile: Install fixes. @@ -10,6 +14,11 @@ 2006-03-02 Han-Wen Nienhuys + * python/lilylib.py: pychecker cleanups. + + * scripts/lilypond-book.py + (Lilypond_snippet.output_print_filename): pychecker cleanups + * scripts/midi2ly.py (Key.dump): pychecker cleanups. * python/lilylib.py (underscore): remove identify() , warranty() diff --git a/python/lilylib.py b/python/lilylib.py index d4772286e5..8d51dd57ed 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -18,7 +18,6 @@ import re import shutil import string import sys -import tempfile import optparse ################################################################ @@ -94,18 +93,6 @@ def lilypond_version_check (binary, req): sys.exit (1) -def setup_temp (): - - ''' Create a temporary directory, and return its name. ''' - - if not __main__.keep_temp_dir_p: - __main__.temp_dir = tempfile.mktemp (__main__.program_name) - try: - os.mkdir (__main__.temp_dir, 0700) - except OSError: - pass - - return __main__.temp_dir def command_name (cmd): # Strip all stuf after command, diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 0e41c16944..efc5ad3ca3 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -181,8 +181,11 @@ (ly:number->string (+ (cdr offset) (cdr y-ext))) ;; TODO - ;; full escaping. - (string-regexp-substitute " " "%20" file) + ;;full escaping. + + ;; backslash is interpreted by GS. + (string-regexp-substitute "\\\\" "/" + (string-regexp-substitute " " "%20" file)) (cadr location) (caddr location) (cadddr location)) diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 2d2328672f..8e9bb407e3 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -28,13 +28,10 @@ TODO: ''' -import __main__ -import glob import stat import string import tempfile import commands -import optparse import os import sys import re @@ -68,9 +65,11 @@ sys.path.insert (0, os.path.join (datadir, 'python')) # dynamic relocation, for GUB binaries. bindir = os.path.split (sys.argv[0])[0] -for p in ['share', 'lib']: - datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) - sys.path.insert (0, os.path.join (datadir)) + + +for prefix_component in ['share', 'lib']: + datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component) + sys.path.insert (0, datadir) import lilylib as ly @@ -112,7 +111,7 @@ def warranty (): %s %s ''' ( _('Copyright (c) %s by') % '2001--2006', - authors + authors, _('Distributed under terms of the GNU General Public License.'), _('It comes with NO WARRANTY.'))) @@ -149,8 +148,9 @@ def get_option_parser (): p.add_option ('-V', '--verbose', help=_("be verbose"), action="store_true", dest="verbose") - p.add_option ('-w', '--warranty', help=_("show warranty and copyright"), - action='store_true'), + p.add_option ('-w', '--warranty', + help=_("show warranty and copyright"), + action='store_true') p.add_option_group ('bugs', @@ -973,7 +973,7 @@ class Lilypond_snippet (Snippet): # URGS if RELATIVE in override.keys () and override[RELATIVE]: - relative = string.atoi (override[RELATIVE]) + relative = int (override[RELATIVE]) relative_quotes = '' @@ -983,8 +983,6 @@ class Lilypond_snippet (Snippet): elif relative > 0: relative_quotes += "'" * relative - program_name = __main__.program_name - paper_string = string.join (compose_dict[PAPER], '\n ') % override layout_string = string.join (compose_dict[LAYOUT], @@ -1101,7 +1099,7 @@ class Lilypond_snippet (Snippet): str += self.output_print_filename (HTML) if VERBATIM in self.option_dict: verb = verbatim_html (self.substring ('code')) - str += write (output[HTML][VERBATIM] % vars ()) + str += output[HTML][VERBATIM] % vars () if QUOTE in self.option_dict: str = output[HTML][QUOTE] % vars () @@ -1387,30 +1385,30 @@ def get_latex_textwidth (source): m = re.search (r'''(?P\\begin\s*{document})''', source) preamble = source[:m.start (0)] latex_document = LATEX_INSPECTION_DOCUMENT % vars () - # Workaround problems with unusable $TMP on Cygwin: - tempfile.tempdir = '' - tmpfile = tempfile.mktemp('.tex') + + (handle, tmpfile) = tempfile.mkstemp('.tex') logfile = os.path.splitext (tmpfile)[0] + '.log' open (tmpfile,'w').write (latex_document) ly.system ('latex %s' % tmpfile) parameter_string = open (logfile).read() + os.unlink (tmpfile) os.unlink (logfile) columns = 0 m = re.search ('columns=([0-9.]*)', parameter_string) if m: - columns = string.atoi (m.group (1)) + columns = int (m.group (1)) columnsep = 0 m = re.search ('columnsep=([0-9.]*)pt', parameter_string) if m: - columnsep = string.atof (m.group (1)) + columnsep = float (m.group (1)) textwidth = 0 m = re.search ('textwidth=([0-9.]*)pt', parameter_string) if m: - textwidth = string.atof (m.group (1)) + textwidth = float (m.group (1)) if columns: textwidth = (textwidth - columnsep) / columns @@ -1528,6 +1526,7 @@ def write_if_updated (file_name, lines): ly.progress ('\n') def note_input_file (name, inputs=[]): + ## hack: inputs is mutable! inputs.append (name) return inputs -- 2.39.5