Skip to content

Commit

Permalink
- added geomet support as a requirement
Browse files Browse the repository at this point in the history
- added some type hints.
  • Loading branch information
achapkowski committed Aug 21, 2021
1 parent 0d4b6b2 commit 08da2cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions src/geopackage/_geopackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import sys
import json
import sqlite3

from typing import Generator
from typing import Union, Any, Dict
import tempfile
from io import BytesIO, StringIO
from sqlite3 import Binary as sBinary
Expand Down Expand Up @@ -105,7 +106,7 @@ def __len__(self):
return 0

# ----------------------------------------------------------------------
def __enter__(self):
def __enter__(self) -> "GeoPackage":
if self._con is None:
self._con = sqlite3.connect(self._path)
return self
Expand All @@ -116,7 +117,7 @@ def __exit__(self, type, value, traceback):
self._con.close()

# ----------------------------------------------------------------------
def exists(self, name):
def exists(self, name: str) -> bool:
"""
Returns boolean if the table exists
Expand All @@ -131,7 +132,7 @@ def exists(self, name):
return False

# ----------------------------------------------------------------------
def get(self, name):
def get(self, name: str) -> Union["Table", "SpatialTable"]:
"""
Returns a table if it exists in the geopackage.
Expand All @@ -155,7 +156,7 @@ def get(self, name):

# ----------------------------------------------------------------------
@property
def tables(self):
def tables(self) -> Generator["Table", "SpatialTable"]:
"""
Gets a list of registered table names with the geopackage
Expand All @@ -171,7 +172,7 @@ def tables(self):
yield SpatialTable(tbl[0], self._con)

# ----------------------------------------------------------------------
def enable(self):
def enable(self) -> bool:
"""
enables the sqlite database to be a geopackage
Expand All @@ -185,7 +186,14 @@ def enable(self):
return True

# ----------------------------------------------------------------------
def create(self, name, fields=None, wkid=None, geometry_type=None, overwrite=True):
def create(
self,
name: str,
fields: Dict[str, str] = None,
wkid: int = None,
geometry_type: str = None,
overwrite: bool = True,
) -> Union["Table", "SpatialTable"]:
"""
The `create` method generates a new table or feature class in the
geopackage.
Expand Down
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def read_file(file):
],
include_package_data=True,
zip_safe=False,
install_requires=["pandas"],
install_requires=["pandas", "geomet"],
extras_require={},
package_data={"geopackage": ["prj.json"]},
)

0 comments on commit 08da2cf

Please sign in to comment.