aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-01-02 17:36:15 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-01-02 17:36:15 +0100
commit6daa9e9dfa6a4d7357fe6edc167ef1fe4459810f (patch)
treed024dd782bb248f04b81929068d919728bbd41ae
parentcdbc9a82815e5c22b395e3ea06faf0d9c5c12986 (diff)
Read settings.py skeleton from package data
-rw-r--r--lesana/collection.py12
-rw-r--r--lesana/data/settings.yaml8
2 files changed, 15 insertions, 5 deletions
diff --git a/lesana/collection.py b/lesana/collection.py
index 05abcfb..cf6c505 100644
--- a/lesana/collection.py
+++ b/lesana/collection.py
@@ -5,6 +5,8 @@ import uuid
import ruamel.yaml
import xapian
+from pkg_resources import resource_string
+
try:
import git
git_available = True
@@ -267,14 +269,14 @@ class Collection(object):
repo.index.add(['.gitignore'])
# TODO: Add hook to index files as they are pulled
# If it doesn't exist, create a skeleton of settings.yaml file
- # and then open it for editing
+ # then open settings.yaml for editing
filepath = os.path.join(c_dir, 'settings.yaml')
if not os.path.exists(filepath):
- # TODO: write this in a file and just copy that
+ skel = resource_string(
+ 'lesana', 'data/settings.yaml'
+ ).decode('utf-8')
with open(filepath, 'w') as fp:
- fp.write('name: \n')
- fp.write('lang: english\n')
- fp.write('fields:\n')
+ fp.write(skel)
if edit_file:
edit_file(filepath)
if git_enabled and repo:
diff --git a/lesana/data/settings.yaml b/lesana/data/settings.yaml
new file mode 100644
index 0000000..ea83e8a
--- /dev/null
+++ b/lesana/data/settings.yaml
@@ -0,0 +1,8 @@
+name: 'My Collection'
+lang: english
+fields:
+ - name: name
+ type: string
+ prefix: S
+ index: free
+