| 292 | |
| 293 | # Load the JS defaults into python. |
| 294 | def read_js_settings(filename, attrs): |
| 295 | settings = utils.read_file(filename) |
| 296 | # Use a bunch of regexs to convert the file from JS to python |
| 297 | # TODO(sbc): This is kind hacky and we should probably convert |
| 298 | # this file in format that python can read directly (since we |
| 299 | # no longer read this file from JS at all). |
| 300 | settings = settings.replace('//', '#') |
| 301 | settings = re.sub(r'var ([\w\d]+)', r'attrs["\1"]', settings) |
| 302 | settings = re.sub(r'=\s+false\s*;', '= False', settings) |
| 303 | settings = re.sub(r'=\s+true\s*;', '= True', settings) |
| 304 | exec(settings, {'attrs': attrs}) |
| 305 | |
| 306 | internal_attrs = {} |
| 307 | read_js_settings(path_from_root('src/settings.js'), self.attrs) |