mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-20 15:34:08 +02:00
Fix lint error
This commit is contained in:
parent
dc9947a5e1
commit
50a979b63d
1 changed files with 23 additions and 23 deletions
|
|
@ -8,33 +8,12 @@ import itertools
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from . import recipes
|
|
||||||
from typing import Dict, cast, BinaryIO, Iterable, Iterator, Optional, Tuple, Type
|
from typing import Dict, cast, BinaryIO, Iterable, Iterator, Optional, Tuple, Type
|
||||||
|
|
||||||
|
|
||||||
class _CloseableIterator(Iterator[dict]):
|
|
||||||
"""Iterator wrapper that closes a file when iteration is complete."""
|
|
||||||
|
|
||||||
def __init__(self, iterator: Iterator[dict], closeable: io.IOBase):
|
|
||||||
self._iterator = iterator
|
|
||||||
self._closeable = closeable
|
|
||||||
|
|
||||||
def __iter__(self) -> "_CloseableIterator":
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __next__(self) -> dict:
|
|
||||||
try:
|
|
||||||
return next(self._iterator)
|
|
||||||
except StopIteration:
|
|
||||||
self._closeable.close()
|
|
||||||
raise
|
|
||||||
|
|
||||||
def close(self) -> None:
|
|
||||||
self._closeable.close()
|
|
||||||
|
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
from . import recipes
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pysqlite3 as sqlite3 # noqa: F401
|
import pysqlite3 as sqlite3 # noqa: F401
|
||||||
from pysqlite3 import dbapi2 # noqa: F401
|
from pysqlite3 import dbapi2 # noqa: F401
|
||||||
|
|
@ -65,6 +44,27 @@ SPATIALITE_PATHS = (
|
||||||
ORIGINAL_CSV_FIELD_SIZE_LIMIT = csv.field_size_limit()
|
ORIGINAL_CSV_FIELD_SIZE_LIMIT = csv.field_size_limit()
|
||||||
|
|
||||||
|
|
||||||
|
class _CloseableIterator(Iterator[dict]):
|
||||||
|
"""Iterator wrapper that closes a file when iteration is complete."""
|
||||||
|
|
||||||
|
def __init__(self, iterator: Iterator[dict], closeable: io.IOBase):
|
||||||
|
self._iterator = iterator
|
||||||
|
self._closeable = closeable
|
||||||
|
|
||||||
|
def __iter__(self) -> "_CloseableIterator":
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self) -> dict:
|
||||||
|
try:
|
||||||
|
return next(self._iterator)
|
||||||
|
except StopIteration:
|
||||||
|
self._closeable.close()
|
||||||
|
raise
|
||||||
|
|
||||||
|
def close(self) -> None:
|
||||||
|
self._closeable.close()
|
||||||
|
|
||||||
|
|
||||||
def maximize_csv_field_size_limit():
|
def maximize_csv_field_size_limit():
|
||||||
"""
|
"""
|
||||||
Increase the CSV field size limit to the maximum possible.
|
Increase the CSV field size limit to the maximum possible.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue