diff options
Diffstat (limited to 'extras')
| -rwxr-xr-x | extras/csrf_migration_helper.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/extras/csrf_migration_helper.py b/extras/csrf_migration_helper.py index ffa8b0b924..818c1263b7 100755 --- a/extras/csrf_migration_helper.py +++ b/extras/csrf_migration_helper.py @@ -137,6 +137,7 @@ _POST_FORM_RE = \ _FORM_CLOSE_RE = re.compile(r'</form\s*>') _TOKEN_RE = re.compile('\{% csrf_token') + def get_template_dirs(): """ Returns a set of all directories that contain project templates. @@ -153,6 +154,7 @@ def get_template_dirs(): dirs.update(app_template_dirs) return dirs + def make_template_info(filename, root_dirs): """ Creates a Template object for a filename, calculating the possible @@ -241,6 +243,7 @@ class Template(object): def __hash__(self): return hash(self.absolute_filename) + def get_templates(dirs): """ Returns all files in dirs that have template extensions, as Template @@ -257,6 +260,7 @@ def get_templates(dirs): templates.add(t) return templates + def get_python_code(paths): """ Returns all Python code, as a list of tuples, each one being: @@ -275,6 +279,7 @@ def get_python_code(paths): retval.append((fn, content)) return retval + def search_python_list(python_code, template_names): """ Searches python code for a list of template names. @@ -286,6 +291,7 @@ def search_python_list(python_code, template_names): retval.update(search_python(python_code, tn)) return sorted(retval) + def search_python(python_code, template_name): """ Searches Python code for a template name. @@ -300,6 +306,7 @@ def search_python(python_code, template_name): retval.append((fn, ln + 1)) return retval + def main(pythonpaths): template_dirs = get_template_dirs() templates = get_templates(template_dirs) |
