Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extractor): add language indentifier #1

Merged
merged 2 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# VSCode
.vscode
50 changes: 50 additions & 0 deletions extractor/extractor.py
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