Skip to content

Commit

Permalink
[nggb] Activation script now removes comment header.
Browse files Browse the repository at this point in the history
git-svn-id: https://valelab.ucsf.edu/svn/micromanager2/trunk@13208 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd
  • Loading branch information
mark committed Apr 22, 2014
1 parent 0a7472e commit 0e3df24
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions buildscripts/nextgen-gnubuild/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import hashlib
import os, os.path
import re
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -85,7 +84,7 @@ def activate(initial=True):
os.stat(src).st_mtime > os.stat(dst).st_mtime):
masked_mode = mode & ~umask
print("copy", src, "->", dst, "(0{:03o})".format(masked_mode))
shutil.copyfile(src, dst)
copy_for_activation(src, dst)
os.chmod(dst, masked_mode)
else:
print("up to date: " + dst + " (from " + src + ")")
Expand Down Expand Up @@ -213,6 +212,36 @@ def process_nextgen(hdr, do_removal=True, check_removal=None):
return deletes, [(hdr.filename, new_path, hdr.file_mode)]


def copy_for_activation(srcfile, dstfile):
# Copy srcfile to dst file, but leave out any continuous block of comment
# lines that contain %nextgen_build_ directives.
block_comment_lines = None
with open(srcfile) as src:
with open(dstfile, "w") as dst:
for line in src:
if block_comment_lines is None:
if line.startswith("#") and not line.startswith("#!"):
block_comment_lines = [line]
block_comment_is_nextgen_header = line.startswith("# %nextgen_build_")
continue
dst.write(line)
else: # in block comment
if not line.startswith("#"): # ended
if not block_comment_is_nextgen_header:
for comment_line in block_comment_lines:
dst.write(comment_line)
block_comment_lines = None
dst.write(line)
continue
if line.startswith("# %nextgen_build_"):
block_comment_is_nextgen_header = True
block_comment_lines.append(line)
if block_comment_lines is not None:
if not block_comment_is_nextgen_header:
for comment_line in block_comment_lines:
dst.write(comment_line)


def get_md5(filename):
m = hashlib.md5()
with open(filename, "rb") as f:
Expand Down

0 comments on commit 0e3df24

Please sign in to comment.