mirror of
https://github.com/kevinveenbirkenbach/directory-content-scanner.git
synced 2024-11-21 20:41:04 +01:00
Solved commit bug
This commit is contained in:
parent
1fbf43bfeb
commit
632334f574
26
scan.py
26
scan.py
@ -15,31 +15,31 @@ class CodeProcessor:
|
||||
"""Remove comments based on file type."""
|
||||
comment_patterns = {
|
||||
CodeProcessor.PYTHON: [
|
||||
(r'^\s*#.*\n?', ''),
|
||||
(r'\"\"\"(.*?)\"\"\"', ''),
|
||||
(r"\'\'\'(.*?)\'\'\'", '')
|
||||
(r'\s*#.*', '',0),
|
||||
(r'\"\"\"(.*?)\"\"\"', '', re.DOTALL),
|
||||
(r"\'\'\'(.*?)\'\'\'", '', re.DOTALL)
|
||||
],
|
||||
CodeProcessor.JS: [
|
||||
(r'\s*//.*', ''),
|
||||
(r'/\*.*?\*/', '')
|
||||
(r'\s*//.*', '',0),
|
||||
(r'/\*.*?\*/', '',0)
|
||||
],
|
||||
CodeProcessor.C: [
|
||||
(r'\s*//.*', ''),
|
||||
(r'/\*.*?\*/', '')
|
||||
(r'\s*//.*', '',0),
|
||||
(r'/\*.*?\*/', '',0)
|
||||
],
|
||||
CodeProcessor.CPP: [
|
||||
(r'\s*//.*', ''),
|
||||
(r'/\*.*?\*/', '')
|
||||
(r'\s*//.*', '',0),
|
||||
(r'/\*.*?\*/', '',0)
|
||||
],
|
||||
CodeProcessor.H: [
|
||||
(r'\s*//.*', ''),
|
||||
(r'/\*.*?\*/', '')
|
||||
(r'\s*//.*', '',0),
|
||||
(r'/\*.*?\*/', '',0)
|
||||
]
|
||||
}
|
||||
|
||||
patterns = comment_patterns.get(file_type, [])
|
||||
for pattern, repl in patterns:
|
||||
content = re.sub(pattern, repl, content, flags=re.DOTALL)
|
||||
for pattern, repl, flags in patterns:
|
||||
content = re.sub(pattern, repl, content, flags=flags)
|
||||
return content.strip()
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user