mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-07 15:38:11 +08:00
Sort os.listdir in filecrawler.py
This commit is contained in:
committed by
Alokito
parent
84db11077a
commit
eb4693f1fa
@@ -8,7 +8,7 @@ def recurse_dir(path):
|
|||||||
"The given path does not exist.", status.HTTP_400_BAD_REQUEST
|
"The given path does not exist.", status.HTTP_400_BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
all_entries = os.listdir(path)
|
all_entries = sorted(os.listdir(path))
|
||||||
def is_h5ad(el):
|
def is_h5ad(el):
|
||||||
return el.endswith('.h5ad') and os.path.isfile(os.path.join(path, el))
|
return el.endswith('.h5ad') and os.path.isfile(os.path.join(path, el))
|
||||||
h5ad_entries = [x for x in all_entries if is_h5ad(x)]
|
h5ad_entries = [x for x in all_entries if is_h5ad(x)]
|
||||||
@@ -22,7 +22,7 @@ def recurse_dir(path):
|
|||||||
"name": x[:-13] if (len(x) > 13 and x[-13] in ['-','_']) else (
|
"name": x[:-13] if (len(x) > 13 and x[-13] in ['-','_']) else (
|
||||||
x[:-4] if x.endswith('.csv') else x),
|
x[:-4] if x.endswith('.csv') else x),
|
||||||
"path": os.path.join(full_path, x).replace(env.cellxgene_data, ""),
|
"path": os.path.join(full_path, x).replace(env.cellxgene_data, ""),
|
||||||
} for x in os.listdir(full_path) if x.endswith('.csv') and os.path.isfile(os.path.join(full_path, x))]
|
} for x in sorted(os.listdir(full_path)) if x.endswith('.csv') and os.path.isfile(os.path.join(full_path, x))]
|
||||||
return [{"name":'new', "class":'new', "path":full_path.replace(env.cellxgene_data, "")}] + entries
|
return [{"name":'new', "class":'new', "path":full_path.replace(env.cellxgene_data, "")}] + entries
|
||||||
|
|
||||||
def make_entry(el):
|
def make_entry(el):
|
||||||
@@ -48,7 +48,7 @@ def recurse_dir(path):
|
|||||||
"type": "neither",
|
"type": "neither",
|
||||||
}
|
}
|
||||||
|
|
||||||
return [make_entry(x) for x in os.listdir(path)]
|
return [make_entry(x) for x in sorted(os.listdir(path))]
|
||||||
|
|
||||||
|
|
||||||
def render_entries(entries):
|
def render_entries(entries):
|
||||||
|
|||||||
Reference in New Issue
Block a user