summaryrefslogtreecommitdiffstats
path: root/tools/data_generators
diff options
context:
space:
mode:
authorAlanCoding <arominge@redhat.com>2017-01-03 14:53:45 +0100
committerAlanCoding <arominge@redhat.com>2017-01-03 14:53:45 +0100
commit8c05d7e968f2b61cff12ee68ba852e699248cf55 (patch)
tree2edc42db61bc9521dd431c346bf1fc62219cdd78 /tools/data_generators
parentlast job, more cleanup, and start work on preset data sets (diff)
downloadawx-8c05d7e968f2b61cff12ee68ba852e699248cf55.tar.xz
awx-8c05d7e968f2b61cff12ee68ba852e699248cf55.zip
clean up boilerplate for reading preset data
Diffstat (limited to 'tools/data_generators')
-rw-r--r--tools/data_generators/load_presets.py30
1 files changed, 11 insertions, 19 deletions
diff --git a/tools/data_generators/load_presets.py b/tools/data_generators/load_presets.py
index 34561e8fa6..7461dc067b 100644
--- a/tools/data_generators/load_presets.py
+++ b/tools/data_generators/load_presets.py
@@ -1,34 +1,26 @@
import os
+preset = 'medium'
+
presets_filename = os.path.abspath(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
'presets.tsv'))
with open(presets_filename) as f:
- r = f.read()
+ text = f.read()
-print r
+split_lines = [line.split('\t') for line in text.split('\n')]
+keys = split_lines[0][1:]
-lines = r.split('\n')
-keys = lines[0].split('\t')[1:]
-
-preset = 'medium'
-
-col = None
-for i, key in enumerate(keys):
- if key == preset:
- col = i
- break
-
-if col is None:
+try:
+ col = keys.index(preset)
+except ValueError:
raise Exception('Preset %s data set not found, options are %s' % (preset, keys))
+options = {cols[0]: cols[col+1] for cols in split_lines}
-options = {}
-
-for line in lines[1:]:
- cols = line.split('\t')
- options[cols[0]] = cols[i+1]
+print ' text '
+print text
print ' options '
print options