# HG changeset patch # User Jeff Hammel # Date 1341954274 25200 # Node ID 82aad57c7d1d92dc47276e36157bb741d5c88db9 # Parent 2d883dd59a1a03990e5781669db9e9307f1b0ed8 add regex mapping diff -r 2d883dd59a1a -r 82aad57c7d1d setup.py --- 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 = {} diff -r 2d883dd59a1a -r 82aad57c7d1d talosnames/api.py --- 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 = []