def parseFile(configPath): try: config_string = open(configPath + '.json') except: error.log('no file found at ' + configPath + '.json', 'WARNING') return False try: config_json = json.load(config_string) config_string.close() except: error.log('badly formed json in ' + configPath + '.json', 'WARNING') return False return config_json
def getAsset(assetType): currAsset = [] for asset in config_json[assetType]: assetPath = { 'local' : True, 'path' : False } if assetType == 'template': assetType = 'html' assetExt = assetType if type(asset) is unicode: if assetType == 'lang': assetName = asset + '/' + loc['lang'] assetExt = 'json' else: assetName = asset assetPath['path'] = buildPath['path'] + '/' + assetType + '/' + assetName + '.' + assetExt elif type(asset) is dict: if assetType == 'lang': assetName = asset[assetType] + '/' + loc['lang'] assetExt = 'json' elif assetType in asset: assetName = asset[assetType] if ('dir' in asset): assetPath['path'] = assetType + '/' + asset['dir'] + '/' + assetName + '.' + assetExt elif ('page' in asset) and ('view' in asset): assetPath['path'] = 'pages/' + asset['page'] + '/views/' + asset['view'] + '/' + assetType + '/' + assetName + '.' + assetExt elif('page' in asset): assetPath['path'] = 'pages/' + asset['page'] + '/' + assetType + '/' + assetName + '.' + assetExt elif('view' in asset): assetPath['path'] = 'views/' + asset['view'] + '/' + assetType + '/' + assetName + '.' + assetExt elif(assetType in asset): assetPath['path'] = assetType + '/' + assetName + '.' + assetExt elif('ext' in asset): assetPath['path'] = asset['ext'] assetPath['local'] = False if assetPath['path'] is False: error.log('badly formed ' + assetType + ' include in ' + buildPath['path'] + '/' + buildPath['profile']) if (assetType == 'html' or assetType == 'lang'): if type(asset) is unicode: assetPath['name'] = asset if 'page' in loc: assetPath['page'] = loc['page'] if 'view' in loc: assetPath['view'] = loc['view'] elif type(asset) is dict: if ('dir' in asset): assetPath['dir'] = asset['dir'] elif ('page' in asset) and ('view' in asset): assetPath['page'] = asset['page'] assetPath['view'] = asset['view'] elif('page' in asset): assetPath['page'] = asset['page'] elif('view' in asset): assetPath['view'] = asset['view'] if not 'ext' in asset: try: assetPath['source'] = open(assetPath['path']).read() except: error.log('no file found at ' + assetPath['path']) currAsset.append(assetPath) return currAsset