summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-20 07:11:26 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-20 07:11:26 +0000
commit0c8f41f02553a420cf6f2824bb31573ef0f9ac1b (patch)
tree61f08caa0a09c5873ac7bf6caac57591f4fefb9b /kpov_judge
parent446224cb38afb299cfe53ac59c72b2f09b8f5170 (diff)
Added unknown_generator for default_generator
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@220 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rwxr-xr-xkpov_judge/kpov_random_helpers.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/kpov_judge/kpov_random_helpers.py b/kpov_judge/kpov_random_helpers.py
index 5646897..aadce0b 100755
--- a/kpov_judge/kpov_random_helpers.py
+++ b/kpov_judge/kpov_random_helpers.py
@@ -105,6 +105,9 @@ with open('random_data/slovenian_surnames.txt') as f:
def username_gen(r):
return r.choice(names) + r.choice(surnames) + "{0}".format(r.randint(1, 99))
+def unknown_generator(r):
+ return ''
+
default_generators = {
'IP': lambda r: IPv4_addr_gen(r, IPv4_net_gen(r))[0],
'localnet': lambda r: IPv4_net_gen(r, min_hosts = r.randint(16, 250), local=True, multicast=False),
@@ -115,15 +118,17 @@ default_generators = {
'short_text': lambda r: fortune(r, 40),
'hostname': lambda r: hostname_gen(r),
None: lambda r: alnum_gen(r, 8),
- '': '',
+ '': unknown_generator,
}
+
def default_gen(userID, param_meta):
r = random.Random(userID)
params = dict()
for name, meta in param_meta.iteritems():
if meta.get('generated', False):
- params[name] = default_generators[meta.get('type', None)](r)
+ params[name] = default_generators(
+ meta.get('type', None), unknown_generator)(r)
return params
if __name__ == '__main__':