diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-04 16:17:35 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-04 16:17:35 +0200 |
commit | 54a679161a9cd39570b566e9236d85774d7c6d8f (patch) | |
tree | ec9e66c58b342376bd76679f1a93314dabe1b5e4 /scripts | |
parent | 3f7538d784b24aa5305a228491efa4b68537a80f (diff) |
build_web_resources: copy top-level style.css
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build_web_resources.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/build_web_resources.py b/scripts/build_web_resources.py index 643920e..12a4ec5 100644 --- a/scripts/build_web_resources.py +++ b/scripts/build_web_resources.py @@ -45,6 +45,7 @@ import db problems_path = os.environ.get('CODEQ_PROBLEMS') or '/var/local/codeq-problems' # where to find problems, the same as server.problems._path_prefix output_path = os.environ.get('CODEQ_WEB_OUTPUT') or '/var/www/html/data' # the base directory where to create subdirectories and output the files for web +toplevel = {'style.css'} # files to copy from the toplevel directory (CODEQ_PROBLEMS) translations = {'sl', 'en'} # translations to seek (sl.py, en.py, ...) # default values (properties) for various types of items, also the list of properties to copy from modules @@ -130,7 +131,7 @@ def process_hint_type(hint_type): return result resource_tree = {} # a directory tree where branches are paths and leaves are filenames, it is rooted at the web data directory -def copy_web_resources(package, dst_dir_fragments): +def copy_web_resources(package, dst_dir_fragments, filter=None): src_path = os.path.join(problems_path, os.sep.join(package.split('.'))) dst_path = output_path node = resource_tree @@ -142,11 +143,14 @@ def copy_web_resources(package, dst_dir_fragments): node[fragment] = subnode node = subnode for filename in os.listdir(src_path): - if not filename.startswith('.') and not filename.endswith('.py'): - full_filename = os.path.join(src_path, filename) - if os.path.isfile(full_filename): - shutil.copy(full_filename, dst_path) - node[filename] = True + if filter and filename not in filter: + continue + if filename.startswith('.') or filename.endswith('.py'): + continue + full_filename = os.path.join(src_path, filename) + if os.path.isfile(full_filename): + shutil.copy(full_filename, dst_path) + node[filename] = True def dump_language_defs(data, output_path): # sort groups and problems @@ -180,6 +184,9 @@ def db_add(table, id, data): cur.execute(sql, vals + (id,)) try: + # copy top-level files (style etc.) + copy_web_resources('', [], filter=toplevel) + # get problem descriptors for lang_identifier in os.listdir(problems_path): lang_data = load_common_data(lang_identifier, language_common_props) |