[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [oonib/master] Move policy related things into an appropriate object
commit c6c0496a93cec538aaf13e8972d0dda394801567
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Mon Aug 19 14:31:04 2013 +0200
Move policy related things into an appropriate object
---
oonib/policy/handlers.py | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/oonib/policy/handlers.py b/oonib/policy/handlers.py
index 788e578..93f9f82 100644
--- a/oonib/policy/handlers.py
+++ b/oonib/policy/handlers.py
@@ -5,20 +5,31 @@ import json
import os
import yaml
-class NetTestPolicyHandler(OONIBHandler):
+class Policy(object):
+ nettest = None
+ input = None
+
+ def __init__(self):
+ with open(config.main.policy_file) as f:
+ p = yaml.safe_load(f)
+ self.nettest = list(p['nettest'])
+ self.input = list(p['input'])
+
+class PolicyHandler(OONIBHandler):
+ def initialize(self):
+ self.policy = Policy()
+
+class NetTestPolicyHandler(PolicyHandler):
def get(self):
"""
returns a list of accepted NetTests
"""
- with open(config.main.policy_file) as f:
- p = yaml.safe_load(f)
- self.write(p['nettest'])
+ self.write(self.policy.nettest)
-class InputPolicyHandler(OONIBHandler):
+class InputPolicyHandler(PolicyHandler):
def get(self):
"""
return list of input ids
"""
- with open(config.main.policy_file) as f:
- p = yaml.safe_load(f)
- self.write(p['input'])
+ self.write(self.policy.input)
+
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits