Changeset View
Changeset View
Standalone View
Standalone View
contrib/devtools/copyright_header.py
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | def file_has_without_c_style_copyright_for_holder(contents, holder_name): | ||||
return match is not None | return match is not None | ||||
################################################################################ | ################################################################################ | ||||
# get file info | # get file info | ||||
################################################################################ | ################################################################################ | ||||
def read_file(filename): | def read_file(filename): | ||||
return open(os.path.abspath(filename), 'r').read() | return open(os.path.abspath(filename), 'r', encoding="utf8").read() | ||||
def gather_file_info(filename): | def gather_file_info(filename): | ||||
info = {} | info = {} | ||||
info['filename'] = filename | info['filename'] = filename | ||||
c = read_file(filename) | c = read_file(filename) | ||||
info['contents'] = c | info['contents'] = c | ||||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Lines | def get_most_recent_git_change_year(filename): | ||||
return max(get_git_change_years(filename)) | return max(get_git_change_years(filename)) | ||||
################################################################################ | ################################################################################ | ||||
# read and write to file | # read and write to file | ||||
################################################################################ | ################################################################################ | ||||
def read_file_lines(filename): | def read_file_lines(filename): | ||||
f = open(os.path.abspath(filename), 'r') | f = open(os.path.abspath(filename), 'r', encoding="utf8") | ||||
file_lines = f.readlines() | file_lines = f.readlines() | ||||
f.close() | f.close() | ||||
return file_lines | return file_lines | ||||
def write_file_lines(filename, file_lines): | def write_file_lines(filename, file_lines): | ||||
f = open(os.path.abspath(filename), 'w') | f = open(os.path.abspath(filename), 'w', encoding="utf8") | ||||
f.write(''.join(file_lines)) | f.write(''.join(file_lines)) | ||||
f.close() | f.close() | ||||
################################################################################ | ################################################################################ | ||||
# update header years execution | # update header years execution | ||||
################################################################################ | ################################################################################ | ||||
▲ Show 20 Lines • Show All 296 Lines • Show Last 20 Lines |