2121# https://www.nipreps.org/community/licensing/
2222#
2323"""The TemplateFlow Python Client command-line interface (CLI)."""
24+
2425from __future__ import annotations
2526
2627import json
3132
3233from templateflow import __package__ , api
3334from templateflow ._loader import Loader as _Loader
34- from templateflow .conf import TF_HOME , TF_USE_DATALAD , TF_AUTOUPDATE
35+ from templateflow .conf import TF_AUTOUPDATE , TF_HOME , TF_USE_DATALAD
3536
3637load_data = _Loader (__package__ )
3738
3839ENTITY_SHORTHANDS = {
3940 # 'template': ('--tpl', '-t'),
40- 'resolution' : ('--res' , ),
41- 'density' : ('--den' , ),
42- 'atlas' : ('-a' , ),
43- 'suffix' : ('-s' , ),
41+ 'resolution' : ('--res' ,),
42+ 'density' : ('--den' ,),
43+ 'atlas' : ('-a' ,),
44+ 'suffix' : ('-s' ,),
4445 'desc' : ('-d' , '--description' ),
4546 'extension' : ('--ext' , '-x' ),
46- 'label' : ('-l' , ),
47- 'segmentation' : ('--seg' , ),
47+ 'label' : ('-l' ,),
48+ 'segmentation' : ('--seg' ,),
4849}
4950ENTITY_EXCLUDE = {'template' , 'description' }
5051TEMPLATE_LIST = api .get_templates ()
@@ -57,16 +58,12 @@ def _nulls(s):
5758def entity_opts ():
5859 """Attaches all entities as options to the command."""
5960
60- entities = json .loads (
61- Path (load_data ('conf/config.json' )).read_text ()
62- )['entities' ]
61+ entities = json .loads (Path (load_data ('conf/config.json' )).read_text ())['entities' ]
6362
6463 args = [
65- (
66- f"--{ e ['name' ]} " ,
67- * ENTITY_SHORTHANDS .get (e ['name' ], ())
68- )
69- for e in entities if e ['name' ] not in ENTITY_EXCLUDE
64+ (f"--{ e ['name' ]} " , * ENTITY_SHORTHANDS .get (e ['name' ], ()))
65+ for e in entities
66+ if e ['name' ] not in ENTITY_EXCLUDE
7067 ]
7168
7269 def decorator (f : FC ) -> FC :
@@ -135,9 +132,7 @@ def update(local, overwrite):
135132def ls (template , ** kwargs ):
136133 """List the assets corresponding to template and optional filters."""
137134 entities = {k : _nulls (v ) for k , v in kwargs .items () if v != '' }
138- click .echo (
139- '\n ' .join (f'{ match } ' for match in api .ls (template , ** entities ))
140- )
135+ click .echo ('\n ' .join (f'{ match } ' for match in api .ls (template , ** entities )))
141136
142137
143138@main .command ()
@@ -146,9 +141,7 @@ def ls(template, **kwargs):
146141def get (template , ** kwargs ):
147142 """Fetch the assets corresponding to template and optional filters."""
148143 entities = {k : _nulls (v ) for k , v in kwargs .items () if v != '' }
149- click .echo (
150- '\n ' .join (f'{ match } ' for match in api .get (template , ** entities ))
151- )
144+ click .echo ('\n ' .join (f'{ match } ' for match in api .get (template , ** entities )))
152145
153146
154147if __name__ == '__main__' :
0 commit comments