nancy/src/nancy/store.py

21 lines
560 B
Python

"""Utilities for creating new stores and linking between them."""
import os
def find_store(path):
"""
Given a path, find a store dir containing nancy.db at any level above it.
"""
d = os.path.realpath(path) # dereference any symlinks in path
while True:
if os.path.exists(os.path.join(d, "nancy.db")):
return d
newd = os.path.dirname(path)
if newd == d: # indicates this is a filesystem root like C:\ or /
return None
def connect(path):
"""Given directory, connect to its store"""