Reviewers: Reinhold,
Message:
Of course you know the code better, so please investigate. I did not
understand why we keep two points to the same file, but if it is needed,
support for windows will require copying the files. There are no hard
links that I am aware of.
http://codereview.appspot.com/5183042/diff/1/python/book_snippets.py
File python/book_snippets.py (right):
http://codereview.appspot.com/5183042/diff/1/python/book_snippets.py#newcode643
python/book_snippets.py:643: os.rename (src, dst)
On 2011/10/04 20:10:43, Reinhold wrote:
Doesn't this REMOVE the src?
os.link creates a link at dst, so the files at src and dst are
actually the same
file (i.e. both point to the same sectors on the hard drive, and thus
they are
always identical, even if you change one).
Yes it removes the src and moves it to dst. Why do you need the two
points? When I specify the output directory I expect the files to be
moved there.
http://codereview.appspot.com/5183042/diff/1/python/lilylib.py
File python/lilylib.py (right):
http://codereview.appspot.com/5183042/diff/1/python/lilylib.py#newcode154
python/lilylib.py:154: return x
On 2011/10/04 20:10:43, Reinhold wrote:
Ah, so in windows you can give a command line argument argument of the
form
my-cmd \$"`
and the command will actually receive a string containing
backslash-dollar-doublequote-backtick?
And none of these characters (dollar, double quotes, backtick,
backslash) need
to be escaped with a backslash? i.e. you don't need
my-cmd "\\\$\"\`"
?
The " might give trouble, but it cannot appear in a filename. Same goes
for \, which is the path separator. It's definitely wrong to use \ as
the escape character anyway. The other characters are plain characters.
Description:
Fix a few lilypond-book bugs on windows (Issue 1815).
- book_snippets.py: Replace os.link (purely unix) by os.rename.
- lilylib.py: Windows command-line arguments don't need escaping.
- lilypond-book.py: Use forward slashes within lilypond files.
Please review this at http://codereview.appspot.com/5183042/
Affected files:
M python/book_snippets.py
M python/lilylib.py
M scripts/lilypond-book.py
Index: python/book_snippets.py
diff --git a/python/book_snippets.py b/python/book_snippets.py
index
ab7c66e47a60d1a98866e6626aa9564000264458..d47f5ecd48f7a2f37d8566d0ba71f8b76e530f19
100644
--- a/python/book_snippets.py
+++ b/python/book_snippets.py
@@ -639,7 +639,11 @@ printing diff against existing file." % filename)
dst_path = os.path.split(dst)[0]
if not os.path.isdir (dst_path):
os.makedirs (dst_path)
- os.link (src, dst)
+ try:
+ os.rename (src, dst)
+ except OSError:
+ print '\nCould not overwrite file', dst
+ raise CompileError(self.basename())
def additional_files_to_consider (self, base, full):
return []
Index: python/lilylib.py
diff --git a/python/lilylib.py b/python/lilylib.py
index
e893aaa3a54482599374629d71ee514bd4eddfd5..7a36a8aaace6ab8cce1b09d8044dc61ced22b38a
100644
--- a/python/lilylib.py
+++ b/python/lilylib.py
@@ -150,6 +150,8 @@ please read 'Setup for MacOS X' in Application Usage.")
# Modified version of the commands.mkarg(x), which always uses
# double quotes (since Windows can't handle the single quotes:
def mkarg(x):
+ if os.name == 'nt':
+ return x
s = ' "'
for c in x:
if c in '\\$"`':
Index: scripts/lilypond-book.py
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index
4d2b000fbd80252d9a3776244f6ad7a26aebdf5f..69156d715e7f4c100f64dd628354a2bbb19adb49
100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -422,7 +422,7 @@ def write_file_map (lys, name):
#(define output-empty-score-list #f)
#(ly:add-file-name-alist '(%s
))\n
-""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename (), name)
+""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename ().replace('\\','/'),
name)
for ly in lys]))
def split_output_files(directory):
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel