mirror of
https://github.com/kevinveenbirkenbach/directory-content-scanner.git
synced 2024-11-22 04:51:03 +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."""
|
"""Remove comments based on file type."""
|
||||||
comment_patterns = {
|
comment_patterns = {
|
||||||
CodeProcessor.PYTHON: [
|
CodeProcessor.PYTHON: [
|
||||||
(r'^\s*#.*\n?', ''),
|
(r'\s*#.*', '',0),
|
||||||
(r'\"\"\"(.*?)\"\"\"', ''),
|
(r'\"\"\"(.*?)\"\"\"', '', re.DOTALL),
|
||||||
(r"\'\'\'(.*?)\'\'\'", '')
|
(r"\'\'\'(.*?)\'\'\'", '', re.DOTALL)
|
||||||
],
|
],
|
||||||
CodeProcessor.JS: [
|
CodeProcessor.JS: [
|
||||||
(r'\s*//.*', ''),
|
(r'\s*//.*', '',0),
|
||||||
(r'/\*.*?\*/', '')
|
(r'/\*.*?\*/', '',0)
|
||||||
],
|
],
|
||||||
CodeProcessor.C: [
|
CodeProcessor.C: [
|
||||||
(r'\s*//.*', ''),
|
(r'\s*//.*', '',0),
|
||||||
(r'/\*.*?\*/', '')
|
(r'/\*.*?\*/', '',0)
|
||||||
],
|
],
|
||||||
CodeProcessor.CPP: [
|
CodeProcessor.CPP: [
|
||||||
(r'\s*//.*', ''),
|
(r'\s*//.*', '',0),
|
||||||
(r'/\*.*?\*/', '')
|
(r'/\*.*?\*/', '',0)
|
||||||
],
|
],
|
||||||
CodeProcessor.H: [
|
CodeProcessor.H: [
|
||||||
(r'\s*//.*', ''),
|
(r'\s*//.*', '',0),
|
||||||
(r'/\*.*?\*/', '')
|
(r'/\*.*?\*/', '',0)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
patterns = comment_patterns.get(file_type, [])
|
patterns = comment_patterns.get(file_type, [])
|
||||||
for pattern, repl in patterns:
|
for pattern, repl, flags in patterns:
|
||||||
content = re.sub(pattern, repl, content, flags=re.DOTALL)
|
content = re.sub(pattern, repl, content, flags=flags)
|
||||||
return content.strip()
|
return content.strip()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user