From c03515909737ca4bdcdf2681f0263e4cb0a5d581 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 12 Sep 2022 16:42:57 +0200 Subject: [PATCH] use default database path for location.Database() This is a naive sketch of the idea, since I've never written a Python module in C before. Basically, I propose that there is a constructor `location.Database()` which uses a built-in default path, e.g. _/var/lib/location/database.db_ e.g. the value of `@databasedir@`. --- src/python/database.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/python/database.c b/src/python/database.c index d6ee4d0..7b4018c 100644 --- a/src/python/database.c +++ b/src/python/database.c @@ -48,9 +48,12 @@ static int Database_init(DatabaseObject* self, PyObject* args, PyObject* kwargs) FILE* f = NULL; // Parse arguments - if (!PyArg_ParseTuple(args, "s", &path)) + if (!PyArg_ParseTuple(args, "|s", &path)) return -1; + if (!path) + path = strdup("@databasedir@/database.db"); + // Copy path self->path = strdup(path); if (!self->path)