diff options
author | Fernando Farfan <ffarfan@gmail.com> | 2015-08-06 11:24:15 -0600 |
---|---|---|
committer | Fernando Farfan <ffarfan@gmail.com> | 2015-08-10 15:41:10 -0600 |
commit | b5e7930a91e5ad9fa045a8ecba71187cb0f1f3b9 (patch) | |
tree | 5c883ce50d172b971f6ea813e8641cccfd298f1c /licenses | |
parent | acff3ca1094609e01e994fc867d75970ef046940 (diff) |
Added a Utility file for license processing
We create license_utils, a utility library to include common methods to handle
license files.
The script that handles the cleanup of CreativeCommons files now uses the
methods that have been extracted into the license_utils lib.
[endlessm/eos-sdk#3471]
Diffstat (limited to 'licenses')
-rwxr-xr-x | licenses/03-cleanup-cc-html-files.py | 8 | ||||
-rw-r--r-- | licenses/license_utils.py | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/licenses/03-cleanup-cc-html-files.py b/licenses/03-cleanup-cc-html-files.py index 80f93cd..c81ca7d 100755 --- a/licenses/03-cleanup-cc-html-files.py +++ b/licenses/03-cleanup-cc-html-files.py @@ -5,6 +5,8 @@ import os import re import sys +from license_utils import rewrite_attr + def main(argv): langs = ['C', 'ar', 'es', 'fr', 'pt_BR'] @@ -118,12 +120,6 @@ def cleanup_deed_file(src_dir, license, lang): f.write(html) f.close() -def rewrite_attr(html, elem, attr, source, target): - for element in html.findAll(elem): - if element.has_key(attr): - attr_val = re.sub(source, target, element[attr]) - element[attr] = attr_val - def cleanup_conditional_comments(html): comments = html.findAll(text=lambda text:isinstance(text, Comment) and '[if' in text) for comment in comments: diff --git a/licenses/license_utils.py b/licenses/license_utils.py new file mode 100644 index 0000000..bb4479d --- /dev/null +++ b/licenses/license_utils.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +import re + +def rewrite_attr(html, elem, attr, source, target): + for element in html.findAll(elem): + if element.has_key(attr): + attr_val = re.sub(source, target, element[attr]) + element[attr] = attr_val + |