@@ -71,7 +71,7 @@ if len(sys.argv) < 1:
7171 sys .exit (1 )
7272
7373try :
74- opts , files = getopt .gnu_getopt (sys .argv [1 :], "hpvV " , ["help" , "patch" , "version" , "verbose" ,])
74+ opts , files = getopt .gnu_getopt (sys .argv [1 :], "hC:pvV " , ["help" , "copyright= " , "patch" , "version" , "verbose" ,])
7575except Exception as e :
7676 print ( "%s: %s" % (program , e ))
7777 sys .exit (1 )
@@ -82,6 +82,7 @@ except Exception as e:
8282# set default values, if any
8383opt_verbose = 0
8484opt_patch = False
85+ opt_copyright = "Copyright The IETF Trust {years}, All Rights Reserved"
8586
8687# handle individual options
8788for opt , value in opts :
@@ -90,6 +91,8 @@ for opt, value in opts:
9091 sys .exit (1 )
9192 elif opt in ["-p" , "--patch" ]: # Generate patch output rather than error messages
9293 opt_patch = True
94+ elif opt in ["-C" , "--copyright" ]: # Copyright line pattern using {years} for years
95+ opt_copyright = value
9396 elif opt in ["-V" , "--version" ]: # Output version information, then exit
9497 print ( program , version )
9598 sys .exit (0 )
@@ -197,8 +200,8 @@ for path in files:
197200 date = initinfo [path ]['date' ]
198201 init = date [:4 ]
199202
200- copyright_re = r "(?i)Copyright The IETF Trust ( \d+-)?\d+, All Rights Reserved"
201- copyright_year_re = r "(?i)Copyright The IETF Trust (%s-)?%s, All Rights Reserved" % ( init , year )
203+ copyright_re = "(?i)" + opt_copyright . format ( years = r"( \d+-)?\d+" )
204+ copyright_year_re = "(?i)" + opt_copyright . format ( years = r"({ init})?{ year}" )
202205 with open (path ) as file :
203206 try :
204207 chunk = file .read (4000 )
@@ -209,9 +212,9 @@ for path in files:
209212 continue
210213 if not re .search (copyright_year_re , chunk ):
211214 if year == init :
212- copyright = f"Copyright The IETF Trust { year } , All Rights Reserved"
215+ copyright = opt_copyright . format ( years = year )
213216 else :
214- copyright = f"Copyright The IETF Trust { init } -{ year } , All Rights Reserved"
217+ copyright = opt_copyright . format ( years = f" { init } -{ year } " )
215218 if opt_patch :
216219 print (f"--- { file .name } \t (original)" )
217220 print (f"+++ { file .name } \t (modified)" )
0 commit comments