def compile_all(): from solar.core.resource import compiler destination_path = utils.read_config()['resources-compiled-file'] if os.path.exists(destination_path): os.remove(destination_path) for path in utils.find_by_mask(utils.read_config()['resources-files-mask']): meta = utils.yaml_load(path) meta['base_path'] = os.path.dirname(path) compiler.compile(meta)
def compile_all(): from solar.core.resource import compiler destination_path = utils.read_config()['resources-compiled-file'] if os.path.exists(destination_path): os.remove(destination_path) for path in utils.find_by_mask( utils.read_config()['resources-files-mask']): meta = utils.yaml_load(path) meta['base_path'] = os.path.dirname(path) compiler.compile(meta)
def __init__(self, url, path='.', base_path=None): self.url = url self.path = path self.base_path = base_path or utils.read_config()['resources-directory'] if path != '.': self.repo_directory = os.path.join(self.base_path, path) else: self.repo_directory = self.base_path self.directory = os.path.join(self.repo_directory, self.url.rsplit('/', 1)[-1])
def _get_resources_list(): result = [] for path in utils.find_by_mask(utils.read_config()['resources-files-mask']): resource = utils.yaml_load(path) resource['path'] = path resource['dir_path'] = os.path.dirname(path) result.append(resource) return result
def profile(id, tags, create): if not id: id = utils.generate_uuid() if create: params = {'tags': tags, 'id': id} profile_template_path = os.path.join( utils.read_config()['template-dir'], 'profile.yml') data = yaml.load(utils.render_template(profile_template_path, params)) db.store('profiles', data) else: pprint.pprint(db.get_list('profiles'))
def compile(meta): destination_file = utils.read_config()['resources-compiled-file'] resource.prepare_meta(meta) meta['class_name'] = '{}Resource'.format( inflection.camelize(meta['base_name']) ) meta['meta_actions'] = pprint.pformat(meta['actions']) meta['meta_input'] = pprint.pformat(meta['input']) print meta['base_name'], meta['class_name'] if not os.path.exists(destination_file): with open(destination_file, 'w') as f: f.write(RESOURCE_HEADER_TEMPLATE.format(**meta)) with open(destination_file, 'a') as f: input_properties = '\n'.join( RESOURCE_INPUT_PROPERTY_TEMPLATE.format(name=name) for name in meta['input'] ) f.write(RESOURCE_CLASS_TEMPLATE.format( input_properties=input_properties, **meta) )
def __init__(self, base_path=None): if base_path is None: self.base_path = utils.read_config()['resources-directory'] else: self.base_path = base_path
import glob import os from solar.core.profile import Profile from solar.extensions.base import BaseExtension from solar import utils # Import all modules from the directory in order # to make subclasses for extensions work modules = glob.glob( os.path.join(utils.read_config()['extensions-dir'], 'modules', '*.py') ) [__import__('%s.%s' % ('modules', os.path.basename(f)[:-3]), locals(), globals()) for f in modules] def get_all_extensions(): return BaseExtension.__subclasses__() def find_extension(id_, version): extensions = filter( lambda e: e.ID == id_ and e.VERSION == version, get_all_extensions()) if not extensions: return None return extensions[0] def find_by_provider_from_profile(profile, provider): profile_ = Profile(profile)