def have_prefix_files(files): for f in files: if f.endswith(('.pyc', '.pyo', '.a')): continue path = join(prefix, f) if isdir(path): continue if sys.platform != 'darwin' and islink(path): # OSX does not allow hard-linking symbolic links, so we cannot # skip symbolic links (as we can on Linux) continue if is_obj(path): continue try: with open(path) as fi: data = fi.read() except UnicodeDecodeError: continue if prefix not in data: continue st = os.stat(path) data = data.replace(prefix, prefix_placeholder) with open(path, 'w') as fo: fo.write(data) os.chmod(path, stat.S_IMODE(st.st_mode) | stat.S_IWUSR) # chmod u+w yield f
def have_prefix_files(files): for f in files: if f.endswith(('.pyc', '.pyo', '.a')): continue path = join(prefix, f) if isdir(path): continue if sys.platform != 'darwin' and islink(path): # OSX does not allow hard-linking symbolic links, so we cannot # skip symbolic links (as we can on Linux) continue if is_obj(path): continue if islink(path): continue try: with open(path) as fi: data = fi.read() except UnicodeDecodeError: continue if prefix not in data: continue st = os.stat(path) data = data.replace(prefix, prefix_placeholder) with open(path, 'w') as fo: fo.write(data) os.chmod(path, stat.S_IMODE(st.st_mode) | stat.S_IWUSR) # chmod u+w yield f
def have_prefix_files(files): for f in files: if f.endswith(('.pyc', '.pyo', '.a')): continue path = join(prefix, f) if isdir(path): continue if sys.platform != 'darwin' and islink(path): # OSX does not allow hard-linking symbolic links, so we cannot # skip symbolic links (as we can on Linux) continue if is_obj(path): continue try: with open(path) as fi: data = fi.read() except UnicodeDecodeError: continue if prefix_placeholder in data: yield f