-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hastagAB/HastagAB/Developement
feat(extractor): add language indentifier
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# VSCode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import argparse | ||
|
||
|
||
class CommentExtractor: | ||
def __init__(self): | ||
pass | ||
|
||
def langIdentifier(self, file): | ||
extension = os.path.splitext(file)[1] | ||
|
||
|
||
langMap = { | ||
'.py': 'python', | ||
'.c': 'c', | ||
'.cs': 'c#', | ||
'.cpp': 'c++', | ||
'.css': 'css', | ||
'.go': 'go', | ||
'.hs': 'haskell', | ||
'.html': 'html', | ||
'.java': 'java', | ||
'.js': 'javascript', | ||
'.kt': 'kotlin', | ||
'.kts': 'kotlin', | ||
'.ktm': 'kotlin', | ||
'.m': 'matlab', | ||
'.php': 'php', | ||
'.pl': 'perl', | ||
'.r': 'r', | ||
'.rbb': 'ruby', | ||
'.rs': 'rust', | ||
'.sh': 'shell', | ||
'.swift': 'swift', | ||
'.scala': 'scala', | ||
'.sc': 'scala', | ||
} | ||
|
||
return langMap[extension] | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("inputFile", help="Specify the input file path to scan") | ||
|
||
args = parser.parse_args() | ||
file = args.inputFile |