def copy_file(self, src, dst, preserve_mode=True, **kw): # Preserve mode of files under libexec if "libexec" in dst: return build_py.copy_file(self, src, dst, preserve_mode=True, **kw) else: return build_py.copy_file(self, src, dst, preserve_mode=preserve_mode, **kw)
def copy_file(self, infile, outfile, **kwargs): du_build_py.copy_file(self, infile, outfile, **kwargs) # Ripped out of install_scripts, might as well be consistent. if os.name == 'posix' and infile in package_scripts: if self.dry_run: log.info("changing mode of %s", outfile) else: mode = ((os.stat(outfile)[stat.ST_MODE]) | 0555) & 07777 log.info("changing mode of %s to %o", outfile, mode) os.chmod(outfile, mode)
def copy_file(self, source, target, preserve_mode=True): if source.endswith('.py') and not 'backport' in source: with open(source, 'rt') as input: nval = self.rtool.refactor_string(input.read(), source) with open(target, 'wt') as output: output.write( 'from __future__ import print_function, absolute_import\n') output.write('from contextlib import nested\n') output.write(str(nval)) else: _build_py.copy_file(self, source, target, preserve_mode=preserve_mode)
def copy_file(self, source, target, preserve_mode=True): if match_patterns(source, build_py27_unmodified): _build_py.copy_file(self, source, target, preserve_mode) elif match_patterns(source, build_py27_excluded): print("excluding: %s" % source) elif source.endswith('.py'): try: print("3to2 converting: %s => %s" % (source, target)) with open(source, 'rt') as input: # ensure file contents have trailing newline source_content = input.read() + "\n" nval = self.rtool.refactor_string(source_content, source) if nval is not None: with open(target, 'wt') as output: output.write('from __future__ import print_function\n') output.write(str(nval)) else: raise(Exception("Failed to parse: %s" % source)) except Exception as e: print("3to2 error (%s => %s): %s" % (source,target,e))
def copy_file(self, source, target, preserve_mode=True): if match_patterns(source, build_py27_unmodified): _build_py.copy_file(self, source, target, preserve_mode) elif match_patterns(source, build_py27_excluded): print("excluding: %s" % source) elif source.endswith('.py'): try: print("3to2 converting: %s => %s" % (source, target)) with open(source, 'rt') as input: # ensure file contents have trailing newline source_content = input.read() + "\n" nval = self.rtool.refactor_string(source_content, source) if nval is not None: with open(target, 'wt') as output: output.write('from __future__ import print_function\n') output.write(str(nval)) else: raise (Exception("Failed to parse: %s" % source)) except Exception as e: print("3to2 error (%s => %s): %s" % (source, target, e))
def copy_file(self, *args, **kwargs): dst, copied = build_py.copy_file(self, *args, **kwargs) if copied and dst.endswith('__init__.py'): if self.distribution.pure: modulepolicy = 'py' else: modulepolicy = 'c' content = open(dst, 'rb').read() content = content.replace(b'@MODULELOADPOLICY@', modulepolicy.encode(libdir_escape)) with open(dst, 'wb') as fh: fh.write(content) return dst, copied