mirror of
https://github.com/simonw/datasette.git
synced 2026-05-31 22:27:00 +02:00
Merge 4265e4b500 into 316daf9a43
This commit is contained in:
commit
9fb1cad036
3 changed files with 45 additions and 0 deletions
|
|
@ -958,6 +958,15 @@ class LoadExtension(click.ParamType):
|
|||
name = "path:entrypoint?"
|
||||
|
||||
def convert(self, value, param, ctx):
|
||||
#:\ indicates we're on a Windows machine study the argument a bit more
|
||||
if ":\\" in r"%r" % value:
|
||||
path_entry = value.split(":", 2)
|
||||
if len(path_entry) < 3:
|
||||
return value
|
||||
# argument contains a Windows/DOS path and an entry point
|
||||
path = path_entry[0] + ":" + path_entry[1]
|
||||
entrypoint = path_entry[-1]
|
||||
return path, entrypoint
|
||||
if ":" not in value:
|
||||
return value
|
||||
path, entrypoint = value.split(":", 1)
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ Depending on your distribution, you should be able to run Datasette something li
|
|||
|
||||
If you are unsure of the location of the module, try running ``locate mod_spatialite`` and see what comes back.
|
||||
|
||||
Installing SpatiaLite on Windows
|
||||
-----------------------------
|
||||
|
||||
For Windows, you may find binaries on the `Gaia-SINS <https://www.gaia-gis.it/gaia-sins/>`_ home page.
|
||||
|
||||
Spatial indexing latitude/longitude columns
|
||||
===========================================
|
||||
|
||||
|
|
|
|||
31
tests/test_loadextension.py
Normal file
31
tests/test_loadextension.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from datasette.utils import LoadExtension
|
||||
|
||||
|
||||
def test_dos_path():
|
||||
path_string = "C:\Windows\System32\mod_spatialite.dll"
|
||||
le = LoadExtension()
|
||||
path = le.convert(path_string, None, None)
|
||||
assert path == "C:\Windows\System32\mod_spatialite.dll"
|
||||
|
||||
|
||||
def test_dos_pathentry():
|
||||
path_entry = "C:\Windows\System32\mod_spatialite.dll:testentry"
|
||||
le = LoadExtension()
|
||||
pathen, entry = le.convert(path_entry, None, None)
|
||||
assert pathen == "C:\Windows\System32\mod_spatialite.dll"
|
||||
assert entry == "testentry"
|
||||
|
||||
|
||||
def test_linux_path():
|
||||
path_string = "/base/test/test2"
|
||||
le = LoadExtension()
|
||||
path = le.convert(path_string, None, None)
|
||||
assert path == path_string
|
||||
|
||||
|
||||
def test_linux_path_entry():
|
||||
path_string = "/base/test/test2:testentry"
|
||||
le = LoadExtension()
|
||||
path, entry = le.convert(path_string, None, None)
|
||||
assert path == "/base/test/test2"
|
||||
assert entry == "testentry"
|
||||
Loading…
Add table
Add a link
Reference in a new issue