changeset 6:82aad57c7d1d

add regex mapping
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 10 Jul 2012 14:04:34 -0700
parents 2d883dd59a1a
children 68d2384b0a52
files setup.py talosnames/api.py
diffstat 2 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Tue Jul 10 10:48:09 2012 -0700
+++ b/setup.py	Tue Jul 10 14:04:34 2012 -0700
@@ -5,7 +5,7 @@
 import os
 
 version = "0.0"
-dependencies = ['MakeItSo', 'webob']
+dependencies = ['webob', 'CommandParser']
 
 # allow use of setuptools/distribute or distutils
 kw = {}
--- a/talosnames/api.py	Tue Jul 10 10:48:09 2012 -0700
+++ b/talosnames/api.py	Tue Jul 10 14:04:34 2012 -0700
@@ -1,3 +1,4 @@
+import re
 import sqlite3
 import urllib2
 
@@ -7,7 +8,7 @@
 
     # mapping file from builbot-configs name to tbpl codes:
     # http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/file/tip/js/Config.js
-    tbpl_mapping = 'http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/raw-file/tip/js/Data.js'
+    tbpl_map = 'http://hg.mozilla.org/users/mstange_themasta.com/tinderboxpushlog/raw-file/tip/js/Data.js'
 
     tables = {'os_list': '(id, name text)',
               'branches': '(id, name text)',
@@ -20,7 +21,7 @@
         self.setup_database()
         self.tbpl_mapping()
 
-    def setup_database():
+    def setup_database(self):
         self.db = sqlite3.connect(':memory:')
         sql_lines = urllib2.urlopen(self.graphserver_sql).readlines()
 
@@ -48,7 +49,17 @@
         cursor.close()
 
     def tbpl_mapping(self):
-        pass
+        self.tbpl_regexs = {}
+        lines = [line.strip()
+                 for line in urllib2.urlopen(self.tbpl_map).readlines()]
+        lines = [line for line in lines
+                 if line.startswith('/talos.*')]
+        regex = re.compile('\/talos\.\*(.*)\/.*\?.*\"([^"].*)\".*')
+        for line in lines:
+            match = regex.match(line)
+            assert match
+            _regex, name = match.groups()
+            self.tbpl_regexs[name] = _regex
 
     def __call__(self, name=None):
         retval = []