Permalink
Browse files

Bump copyright years (and add tool to do so)

  • Loading branch information...
cmpilato committed Jan 8, 2018
1 parent 11878f0 commit 7302888e630433f60a9da160524a8de67f431ece
Showing with 74 additions and 5 deletions.
  1. +1 −1 LICENSE
  2. +1 −1 lib/tk_data.py
  3. +1 −1 lib/tk_main.py
  4. +1 −1 thotkeeper
  5. +69 −0 tools/bump-copyright-years
  6. +1 −1 tools/make-release
View
@@ -1,4 +1,4 @@
Copyright (c) 2004-2008 C. Michael Pilato. All rights reserved.
Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
View
@@ -2,7 +2,7 @@
#
# ThotKeeper -- a personal daily journal application.
#
# Copyright (c) 2004-2008 C. Michael Pilato. All rights reserved.
# Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE file which can be found at the top level of the ThotKeeper
View
@@ -2,7 +2,7 @@
#
# ThotKeeper -- a personal daily journal application.
#
# Copyright (c) 2004-2008 C. Michael Pilato. All rights reserved.
# Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE file which can be found at the top level of the ThotKeeper
View
@@ -2,7 +2,7 @@
#
# ThotKeeper -- a personal daily journal application.
#
# Copyright (c) 2004-2006 C. Michael Pilato. All rights reserved.
# Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE file which can be found at the top level of the ThotKeeper
View
@@ -0,0 +1,69 @@
#!/usr/bin/env python
#
# Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html.
#
# For more information, visit http://viewvc.org/
#
# -----------------------------------------------------------------------
#
# bump-copyright-years: internal tool for bumping copyright years
#
# -----------------------------------------------------------------------
#
import sys
import os
import time
import re
_copyright_re = re.compile(r'Copyright (\(c\)|©) ([0-9]{4}-)?([0-9]{4}) C. Michael Pilato')
def replace_end_year(path, year):
updated = False
lines = open(path, 'r').readlines()
for i in range(len(lines)):
line = lines[i]
new_line = None
m = _copyright_re.search(line)
if not m:
continue
if m.group(2):
lines[i] = line[:m.start(3)] + year + line[m.end(3):]
open(path, 'w').write(''.join(lines))
break
elif m.group(3) != year:
lines[i] = line[:m.end(3)] + '-' + year + line[m.end(3):]
open(path, 'w').write(''.join(lines))
break
def bump_years_recursive(target_dir, year):
children = os.listdir(target_dir)
for child in children:
child_path = os.path.join(target_dir, child)
if os.path.isfile(child_path):
replace_end_year(child_path, year)
elif os.path.isdir(child_path):
bump_years_recursive(child_path, year)
def bump_years(target_dir):
year = time.strftime('%Y')
long_date = time.strftime('%B %d, %Y')
bump_years_recursive(target_dir, year)
sys.stdout.write("Copyright years bumped.\n\n")
if __name__ == "__main__":
try:
target_dir = sys.argv[1]
except:
sys.stderr.write("""\
Usage: bump-copyright-years DIRECTORY
Recursively update the copyright years associated with files carrying
the 'C. Michael Pilato' in and under DIRECTORY to include the current
year.
""")
sys.exit(1)
bump_years(target_dir)
View
@@ -2,7 +2,7 @@
#
# ThotKeeper -- a personal daily journal application.
#
# Copyright (c) 2004-2008 C. Michael Pilato. All rights reserved.
# Copyright (c) 2004-2018 C. Michael Pilato. All rights reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE file which can be found at the top level of the ThotKeeper

0 comments on commit 7302888

Please sign in to comment.