File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 2626
2727from cluecode import copyrights_hint
2828
29+ from cluecode .normalizer import normalize_copyright_symbols
30+
31+ def detect_copyrights (file_path ):
32+ # Read the content of the file
33+ with open (file_path , 'r' , encoding = 'utf-8' ) as file :
34+ text = file .read ()
35+
36+ # Normalize the text before processing it
37+ normalized_text = normalize_copyright_symbols (text )
38+
39+ # Save the normalized content back to the file (optional)
40+ with open (file_path , 'w' , encoding = 'utf-8' ) as file :
41+ file .write (normalized_text )
42+
43+ return normalized_text
44+
45+ # Specify the path to your document directly here
46+ file_path = "./copyright.py"
47+
48+ # Call the function and print the result
49+ normalized_content = detect_copyrights (file_path )
50+ print (normalized_content )
51+
2952# Tracing flags
3053TRACE = False or os .environ .get ('SCANCODE_DEBUG_COPYRIGHT' , False )
3154
Original file line number Diff line number Diff line change 1414# A regex to match a string that may contain a copyright year.
1515# This is a year between 1960 and today prefixed and suffixed with
1616# either a white-space or some punctuation.
17+ from cluecode .normalizer import normalize_copyright_symbols
18+
19+ def detect_copyrights (file_path ):
20+ # Read the content of the file
21+ with open (file_path , 'r' , encoding = 'utf-8' ) as file :
22+ text = file .read ()
23+
24+ # Normalize the text before processing it
25+ normalized_text = normalize_copyright_symbols (text )
26+
27+ # Save the normalized content back to the file (optional)
28+ with open (file_path , 'w' , encoding = 'utf-8' ) as file :
29+ file .write (normalized_text )
30+
31+ return normalized_text
32+
33+ # Specify the path to your document directly here
34+ file_path = "./copyright.py"
35+
36+ # Call the function and print the result
37+ normalized_content = detect_copyrights (file_path )
38+ print (normalized_content )
39+
1740
1841all_years = tuple (str (year ) for year in range (1960 , datetime .today ().year ))
1942years = r'[\(\.,\-\)\s]+(' + '|' .join (all_years ) + r')([\(\.,\-\)\s]+|$)'
You can’t perform that action at this time.
0 commit comments