38
38
]
39
39
EXCLUDE_COMPILED = re .compile ('|' .join ([fnmatch .translate (m ) for m in EXCLUDE ]))
40
40
41
- INCLUDE = ['*.h' , '*.cpp' , '*.cc' , '*.c' , '*.py' ]
41
+ INCLUDE = ['*.h' , '*.hpp' , '*. cpp' , '*.cc' , '*.c' , '*.py' , 'Makefile.*' , 'configure.ac ' ]
42
42
INCLUDE_COMPILED = re .compile ('|' .join ([fnmatch .translate (m ) for m in INCLUDE ]))
43
43
44
44
def applies_to_file (filename ):
@@ -69,6 +69,8 @@ def get_filenames_to_examine():
69
69
COPYRIGHT_WITHOUT_C = 'Copyright'
70
70
ANY_COPYRIGHT_STYLE = '(%s|%s)' % (COPYRIGHT_WITH_C , COPYRIGHT_WITHOUT_C )
71
71
72
+ MIN_INSERT_YEAR = '2017'
73
+ LAST_INSERT_YEAR = datetime .date .today ().year
72
74
YEAR = "20[0-9][0-9]"
73
75
YEAR_RANGE = '(%s)(-%s)?' % (YEAR , YEAR )
74
76
YEAR_LIST = '(%s)(, %s)+' % (YEAR , YEAR )
@@ -82,6 +84,7 @@ def compile_copyright_regex(copyright_style, year_style, name):
82
84
return re .compile ('%s %s %s' % (copyright_style , year_style , name ))
83
85
84
86
EXPECTED_HOLDER_NAMES = [
87
+ "The Energi Core developers\n " ,
85
88
"Satoshi Nakamoto\n " ,
86
89
"The Bitcoin Core developers\n " ,
87
90
"The Bitcoin Core developers \n " ,
@@ -340,7 +343,7 @@ def write_file_lines(filename, file_lines):
340
343
COPYRIGHT = 'Copyright \(c\)'
341
344
YEAR = "20[0-9][0-9]"
342
345
YEAR_RANGE = '(%s)(-%s)?' % (YEAR , YEAR )
343
- HOLDER = 'The Bitcoin Core developers'
346
+ HOLDER = 'The Energi Core developers'
344
347
UPDATEABLE_LINE_COMPILED = re .compile (' ' .join ([COPYRIGHT , YEAR_RANGE , HOLDER ]))
345
348
346
349
def get_updatable_copyright_line (file_lines ):
@@ -408,24 +411,24 @@ def exec_update_header_year(base_directory):
408
411
################################################################################
409
412
410
413
UPDATE_USAGE = """
411
- Updates all the copyright headers of "The Bitcoin Core developers" which were
414
+ Updates all the copyright headers of "The Energi Core developers" which were
412
415
changed in a year more recent than is listed. For example:
413
416
414
- // Copyright (c) <firstYear>-<lastYear> The Bitcoin Core developers
417
+ // Copyright (c) <firstYear>-<lastYear> The Energi Core developers
415
418
416
419
will be updated to:
417
420
418
- // Copyright (c) <firstYear>-<lastModifiedYear> The Bitcoin Core developers
421
+ // Copyright (c) <firstYear>-<lastModifiedYear> The Energi Core developers
419
422
420
423
where <lastModifiedYear> is obtained from the 'git log' history.
421
424
422
425
This subcommand also handles copyright headers that have only a single year. In those cases:
423
426
424
- // Copyright (c) <year> The Bitcoin Core developers
427
+ // Copyright (c) <year> The Energi Core developers
425
428
426
429
will be updated to:
427
430
428
- // Copyright (c) <year>-<lastModifiedYear> The Bitcoin Core developers
431
+ // Copyright (c) <year>-<lastModifiedYear> The Energi Core developers
429
432
430
433
where the update is appropriate.
431
434
@@ -458,7 +461,7 @@ def get_header_lines(header, start_year, end_year):
458
461
return [line + '\n ' for line in lines ]
459
462
460
463
CPP_HEADER = '''
461
- // Copyright (c) %s The Bitcoin Core developers
464
+ // Copyright (c) %s The Energi Core developers
462
465
// Distributed under the MIT software license, see the accompanying
463
466
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
464
467
'''
@@ -467,7 +470,7 @@ def get_cpp_header_lines_to_insert(start_year, end_year):
467
470
return reversed (get_header_lines (CPP_HEADER , start_year , end_year ))
468
471
469
472
PYTHON_HEADER = '''
470
- # Copyright (c) %s The Bitcoin Core developers
473
+ # Copyright (c) %s The Energi Core developers
471
474
# Distributed under the MIT software license, see the accompanying
472
475
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
473
476
'''
@@ -509,21 +512,31 @@ def insert_python_header(filename, file_lines, start_year, end_year):
509
512
insert_idx = 0
510
513
header_lines = get_python_header_lines_to_insert (start_year , end_year )
511
514
for line in header_lines :
515
+ if line in file_lines [:30 ]:
516
+ continue
512
517
file_lines .insert (insert_idx , line )
513
518
write_file_lines (filename , file_lines )
514
519
515
520
def insert_cpp_header (filename , file_lines , start_year , end_year ):
516
521
header_lines = get_cpp_header_lines_to_insert (start_year , end_year )
517
522
for line in header_lines :
523
+ if line in file_lines [:30 ]:
524
+ continue
518
525
file_lines .insert (0 , line )
519
526
write_file_lines (filename , file_lines )
520
527
521
528
def exec_insert_header (filename , style ):
522
529
file_lines = read_file_lines (filename )
523
530
if file_already_has_core_copyright (file_lines ):
524
- sys .exit ('*** %s already has a copyright by The Bitcoin Core developers'
531
+ sys .exit ('*** %s already has a copyright by The Energi Core developers'
525
532
% (filename ))
526
533
start_year , end_year = get_git_change_year_range (filename )
534
+
535
+ if start_year < MIN_INSERT_YEAR :
536
+ start_year = MIN_INSERT_YEAR
537
+
538
+ end_year = LAST_INSERT_YEAR
539
+
527
540
if style == 'python' :
528
541
insert_python_header (filename , file_lines , start_year , end_year )
529
542
else :
@@ -534,7 +547,7 @@ def exec_insert_header(filename, style):
534
547
################################################################################
535
548
536
549
INSERT_USAGE = """
537
- Inserts a copyright header for "The Bitcoin Core developers" at the top of the
550
+ Inserts a copyright header for "The Energi Core developers" at the top of the
538
551
file in either Python or C++ style as determined by the file extension. If the
539
552
file is a Python file and it has a '#!' starting the first line, the header is
540
553
inserted in the line below it.
@@ -548,7 +561,7 @@ def exec_insert_header(filename, style):
548
561
549
562
"<current_year>"
550
563
551
- If the file already has a copyright for "The Bitcoin Core developers", the
564
+ If the file already has a copyright for "The Energi Core developers", the
552
565
script will exit.
553
566
554
567
Usage:
0 commit comments