Programmatically determining programming languages based on file extensions in python code example

Example: Programmatically determining programming languages based on file extensions in python

# use: https://github.com/blakeembrey/language-map/blob/master/languages.json
# Github Linguist map as dict for referance

language_results = list(map(
        lambda file_args: file_args[0] if file_extension in list(map(
            lambda i: i, file_args[1].get("extensions", []))) else None, language_map.items()))
language_results = list(filter(None, language_results))
return language_results[0] if len(language_results) > 0 else None

Tags:

Misc Example