diff -r 0765d19355bd -r 22214389caed confml/implml/hbtheme.implml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/confml/implml/hbtheme.implml Fri Jun 11 14:07:21 2010 +0300 @@ -0,0 +1,84 @@ + + + + + + + + + + ${HbTheme.UIThemeFile} configures ${HbTheme.HbDefaultTheme} = {% get_themename_from_thx( ${HbTheme.UIThemeFile}, 'themes' ) %} + + + ${HbTheme.PriorityThemeFile} configures ${HbTheme.HbPriorityThemeName} = {% get_themename_from_thx( ${HbTheme.PriorityThemeFile}, 'prioritytheme' ) %} + + + +import sys, zipfile, os, os.path +import tempfile +import shutil + +def get_themename_from_thx(file, themesfolder): + ret = None + + outdir = get_output_folder() + outdir = os.path.join(outdir, 'resource') + if not os.path.exists(outdir): + os.mkdir(outdir) + outdir = os.path.join(outdir, 'hb') + if not os.path.exists(outdir): + os.mkdir(outdir) + outdir = os.path.join(outdir, themesfolder) + if not os.path.exists(outdir): + os.mkdir(outdir) + unzip_file_into_dir(file, outdir) + + # Get filesnames in outdir + files_in_dir = os.listdir(outdir) + + # Search for themeindex file + for fn in files_in_dir: + if os.path.splitext(fn)[1] == '.themeindex': + ret = os.path.splitext(fn)[0] + + return ret + +def unzip_file_into_dir(file, dir): + """ + Unzips file into given folder. + """ + + zfobj = zipfile.ZipFile(file,'r') + for name in zfobj.namelist(): + if name.endswith('/'): + os.mkdir(os.path.join(dir, name)) + else: + outfile = open(os.path.join(dir, name), 'wb') + outfile.write(zfobj.read(name)) + outfile.close() + +def get_output_folder(): + output = ruleml.context.output + output = os.path.join(output, 'content') + if not os.path.exists(output): + os.mkdir(output) + + return output + + + + + + + + + + + + + + + + + +