lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Output a newline by default at the end of progress messages. (issue 5485


From: julien . rioux
Subject: Output a newline by default at the end of progress messages. (issue 5485077)
Date: Sun, 18 Dec 2011 00:50:50 +0000

Reviewers: ,

Message:
Note to self: before pushing, rebase on top of master and remove the
extra '\n' added in the progress message in
http://git.savannah.gnu.org/gitweb/?p=lilypond.git;a=blobdiff;f=python/lilylib.py;h=0f33ed4a2cde2bf5b7e147ae0366afa249bf275c;hp=7a36a8aaace6ab8cce1b09d8044dc61ced22b38a;hb=06aadb4af78fb061726d9f91ab7e2bb52eab59e8;hpb=e59c90a91ba93c55342dc9495e8c4c29076b9cea

Description:
Output a newline by default at the end of progress messages.

For lilypond-book, convert-ly and other python scripts.

Please review this at http://codereview.appspot.com/5485077/

Affected files:
  M python/lilylib.py
  M scripts/convert-ly.py
  M scripts/lilypond-book.py


Index: python/lilylib.py
diff --git a/python/lilylib.py b/python/lilylib.py
index 7a36a8aaace6ab8cce1b09d8044dc61ced22b38a..5d2d22492a8618fd6f92ab28669f28a87b9de7a7 100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -115,10 +115,12 @@ def is_verbose ():
 def stderr_write (s):
     encoded_write (sys.stderr, s)

-def print_logmessage (level, s, fullmessage = True):
+def print_logmessage (level, s, fullmessage = True, newline = True):
     if (is_loglevel (level)):
         if fullmessage:
             stderr_write (program_name + ": " + s + '\n')
+        elif newline:
+            stderr_write (s + '\n')
         else:
             stderr_write (s)

@@ -131,11 +133,11 @@ def warning (s):
 def basic_progress (s):
     print_logmessage ("BASIC", s);

-def progress (s, fullmessage = False):
-    print_logmessage ("PROGRESS", s, fullmessage);
+def progress (s, fullmessage = False, newline = True):
+    print_logmessage ("PROGRESS", s, fullmessage, newline);

-def debug_output (s, fullmessage = False):
-    print_logmessage ("DEBUG", s, fullmessage);
+def debug_output (s, fullmessage = False, newline = True):
+    print_logmessage ("DEBUG", s, fullmessage, newline);



Index: scripts/convert-ly.py
diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py
index 9f983540d6a2c4a1d3f7992d979bacd45dd36f68..383f2fb855a5437c8edd0b601e37a2e5b84e927b 100644
--- a/scripts/convert-ly.py
+++ b/scripts/convert-ly.py
@@ -181,16 +181,18 @@ tuple (LAST,STR), with the last successful conversion and the resulting
 string."""
     conv_list = get_conversions (from_version, to_version)

-    ly.progress (_ ("Applying conversion: "))
+    ly.progress (_ ("Applying conversion: "), newline = False)

     last_conversion = ()
     try:
         if not conv_list:
             last_conversion = to_version
         for x in conv_list:
-            ly.progress (tup_to_str (x[0]))
             if x != conv_list[-1]:
-                ly.progress (', ')
+                ly.progress (tup_to_str (x[0]), newline = False)
+                ly.progress (', ', newline = False)
+            else:
+                ly.progress (tup_to_str (x[0]))
             str = x[1] (str)
             last_conversion = x[0]

@@ -344,6 +346,5 @@ def main ():
                          "Valid version strings consist of three numbers, "
"separated by dots, e.g. `2.8.12'") % (f, v.version) )

-    ly.progress ('\n')

 main ()
Index: scripts/lilypond-book.py
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 69156d715e7f4c100f64dd628354a2bbb19adb49..80cfbfaa9b3d9b8f408504a937333fed76136e56 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -448,11 +448,9 @@ def do_process_cmd (chunks, input_name, options):
     progress (_ ("Writing snippets..."))
     for snippet in outdated:
         snippet.write_ly()
-    progress ('\n')

     if outdated:
         progress (_ ("Processing..."))
-        progress ('\n')
         process_snippets (options.process_cmd, outdated,
                           options.formatter, options.lily_output_dir)

@@ -466,8 +464,6 @@ def do_process_cmd (chunks, input_name, options):
                                            output_files,
                                            options.output_dir)

-    progress ('\n')
-

 ###
 # Format guessing data
@@ -488,7 +484,6 @@ def write_if_updated (file_name, lines):
         new_str = ''.join (lines)
         if oldstr == new_str:
             progress (_ ("%s is up to date.") % file_name)
-            progress ('\n')

             # this prevents make from always rerunning lilypond-book:
             # output file must be touched in order to be up to date
@@ -503,7 +498,6 @@ def write_if_updated (file_name, lines):

     progress (_ ("Writing `%s'...") % file_name)
     file (file_name, 'w').writelines (lines)
-    progress ('\n')


 def note_input_file (name, inputs=[]):
@@ -569,7 +563,6 @@ def do_file (input_filename, included=False):
     try:
         progress (_ ("Reading %s...") % input_fullname)
         source = in_handle.read ()
-        progress ('\n')

         if not included:
             global_options.formatter.init_default_snippet_options (source)
@@ -580,7 +573,6 @@ def do_file (input_filename, included=False):

         # Let the formatter modify the chunks before further processing
         chunks = global_options.formatter.process_chunks (chunks)
-        progress ('\n')

         if global_options.filter_cmd:
             write_if_updated (output_filename,
@@ -588,7 +580,6 @@ def do_file (input_filename, included=False):
         elif global_options.process_cmd:
             do_process_cmd (chunks, input_fullname, global_options)
             progress (_ ("Compiling %s...") % output_filename)
-            progress ('\n')
             write_if_updated (output_filename,
                      [s.replacement_text ()
                      for s in chunks])
@@ -597,7 +588,6 @@ def do_file (input_filename, included=False):
             os.chdir (original_dir)
             name = snippet.substring ('filename')
             progress (_ ("Processing include: %s") % name)
-            progress ('\n')
             return do_file (name, included=True)

         include_chunks = map (process_include,
@@ -609,7 +599,6 @@ def do_file (input_filename, included=False):
     except BookSnippet.CompileError:
         os.chdir (original_dir)
         progress (_ ("Removing `%s'") % output_filename)
-        progress ('\n')
         raise BookSnippet.CompileError

 def do_options ():



reply via email to

[Prev in Thread] Current Thread [Next in Thread]