@@ -93,9 +93,7 @@ async def run_migration(dsn: Optional[str] = None) -> str:
9393 logging .debug (f"Target database already at version: { version } " )
9494 return version
9595 if oldversion is None :
96- logging .debug (
97- f"No pgstac version set, installing { version } from scratch"
98- )
96+ logging .debug (f"No pgstac version set, installing { version } from scratch" )
9997 migration_file = os .path .join (migrations_dir , f"pgstac.{ version } .sql" )
10098 else :
10199 logging .debug (f"Migrating from { oldversion } to { version } ." )
@@ -134,7 +132,7 @@ async def run_migration(dsn: Optional[str] = None) -> str:
134132def migrate (dsn : Optional [str ] = None ) -> None :
135133 """Migrate a pgstac database"""
136134 version = asyncio .run (run_migration (dsn ))
137- typer .echo (f' pgstac version { version } ' )
135+ typer .echo (f" pgstac version { version } " )
138136
139137
140138class loadopt (str , Enum ):
@@ -147,8 +145,9 @@ class tables(str, Enum):
147145 items = "items"
148146 collections = "collections"
149147
148+
150149# Types of iterable that load_iterator can support
151- T = TypeVar ('T' , Iterable [bytes ], Iterable [Dict [str , Any ]], Iterable [str ])
150+ T = TypeVar ("T" , Iterable [bytes ], Iterable [Dict [str , Any ]], Iterable [str ])
152151
153152
154153async def aiter (list : T ) -> AsyncGenerator [bytes , None ]:
@@ -161,15 +160,12 @@ async def aiter(list: T) -> AsyncGenerator[bytes, None]:
161160 elif isinstance (item , str ):
162161 item_str = item
163162 else :
164- raise ValueError (f"Cannot load iterator with values of type { type (item )} (value { item } )" )
165-
163+ raise ValueError (
164+ f"Cannot load iterator with values of type { type (item )} (value { item } )"
165+ )
166166
167167 line = "\n " .join (
168- [
169- item_str .rstrip ()
170- .replace (r"\n" , r"\\n" )
171- .replace (r"\t" , r"\\t" )
172- ]
168+ [item_str .rstrip ().replace (r"\n" , r"\\n" ).replace (r"\t" , r"\\t" )]
173169 ).encode ("utf-8" )
174170 yield line
175171
@@ -306,20 +302,16 @@ def load(
306302 table : tables ,
307303 file : str ,
308304 dsn : str = None ,
309- method : loadopt = typer .Option (
310- "insert" , prompt = "How to deal conflicting ids"
311- ),
305+ method : loadopt = typer .Option ("insert" , prompt = "How to deal conflicting ids" ),
312306) -> None :
313307 "Load STAC data into a pgstac database."
314- typer .echo (
315- asyncio .run (
316- load_ndjson (file = file , table = table , dsn = dsn , method = method )
317- )
318- )
308+ typer .echo (asyncio .run (load_ndjson (file = file , table = table , dsn = dsn , method = method )))
309+
319310
320311@app .command ()
321312def pgready (dsn : Optional [str ] = None ) -> None :
322313 """Wait for a pgstac database to accept connections"""
314+
323315 async def wait_on_connection () -> bool :
324316 cnt = 0
325317
@@ -338,7 +330,6 @@ async def wait_on_connection() -> bool:
338330 time .sleep (0.1 )
339331 cnt += 1
340332
341-
342333 asyncio .run (wait_on_connection ())
343334
344335
0 commit comments