No need to cache directory listing
This commit is contained in:
parent
87f205484f
commit
409b760be3
1 changed files with 0 additions and 7 deletions
|
@ -327,18 +327,11 @@ def customize_lexer_priority(file_name, accuracy, lexer):
|
||||||
return (accuracy, priority, lexer)
|
return (accuracy, priority, lexer)
|
||||||
|
|
||||||
|
|
||||||
EXTENSION_CACHE = {}
|
|
||||||
def extensions_in_same_folder(file_name):
|
def extensions_in_same_folder(file_name):
|
||||||
"""Returns a list of file extensions from the same folder as file_name."""
|
"""Returns a list of file extensions from the same folder as file_name."""
|
||||||
global EXTENSION_CACHE
|
|
||||||
|
|
||||||
if file_name in EXTENSION_CACHE:
|
|
||||||
return EXTENSION_CACHE[file_name]
|
|
||||||
|
|
||||||
directory = os.path.dirname(file_name)
|
directory = os.path.dirname(file_name)
|
||||||
files = os.listdir(directory)
|
files = os.listdir(directory)
|
||||||
extensions = list(zip(*map(os.path.splitext, files)))[1]
|
extensions = list(zip(*map(os.path.splitext, files)))[1]
|
||||||
extensions = set([ext.lower() for ext in extensions])
|
extensions = set([ext.lower() for ext in extensions])
|
||||||
|
|
||||||
EXTENSION_CACHE[file_name] = extensions
|
|
||||||
return extensions
|
return extensions
|
||||||
|
|
Loading…
Reference in a new issue