programmatically determining programming languages based on file extensions in python

Solutions on MaxInterview for programmatically determining programming languages based on file extensions in python by the best coders in the world

showing results for - "programmatically determining programming languages based on file extensions in python"
Karl
06 Feb 2017
1# use: https://github.com/blakeembrey/language-map/blob/master/languages.json
2# Github Linguist map as dict for referance
3
4language_results = list(map(
5        lambda file_args: file_args[0] if file_extension in list(map(
6            lambda i: i, file_args[1].get("extensions", []))) else None, language_map.items()))
7language_results = list(filter(None, language_results))
8return language_results[0] if len(language_results) > 0 else None
9