summaryrefslogtreecommitdiff
path: root/reconfigure/items/netatalk.py
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
committerAndrew Shadura <andrew@shadura.me>2015-08-20 15:58:26 +0200
commitff1408420159488a106492ccd11dd234967029b6 (patch)
tree473420cee1c5229a427ec4cafead1aa6c0a26800 /reconfigure/items/netatalk.py
Imported Upstream version 0.1.29
Diffstat (limited to 'reconfigure/items/netatalk.py')
-rw-r--r--reconfigure/items/netatalk.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/reconfigure/items/netatalk.py b/reconfigure/items/netatalk.py
new file mode 100644
index 0000000..e4957cf
--- /dev/null
+++ b/reconfigure/items/netatalk.py
@@ -0,0 +1,38 @@
+from reconfigure.nodes import Node, PropertyNode
+from reconfigure.items.bound import BoundData
+from util import yn_getter, yn_setter
+
+
+class NetatalkData (BoundData):
+ pass
+
+
+class GlobalData (BoundData):
+ pass
+
+
+class ShareData (BoundData):
+ fields = ['path', 'appledouble', 'valid users', 'cnid scheme', 'ea', 'password']
+ defaults = ['', 'ea', '', 'dbd', 'none', '']
+
+ def template(self):
+ return Node(
+ 'share',
+ *[PropertyNode(x, y) for x, y in zip(ShareData.fields, ShareData.defaults)]
+ )
+
+
+NetatalkData.bind_child('global', lambda x: x.get('Global'), item_class=GlobalData)
+NetatalkData.bind_collection('shares', selector=lambda x: x.name != 'Global', item_class=ShareData)
+
+
+GlobalData.bind_property('afp port', 'afp_port', default='548')
+GlobalData.bind_property('cnid listen', 'cnid_listen', default='localhost:4700')
+GlobalData.bind_property(
+ 'zeroconf', 'zeroconf', default=True,
+ getter=yn_getter, setter=yn_setter)
+
+ShareData.bind_name('name')
+ShareData.bind_attribute('comment', 'comment', path=lambda x: x.get('path'), default='')
+for f, d in zip(ShareData.fields, ShareData.defaults):
+ ShareData.bind_property(f, f.replace(' ', '_'), default=d)