def generate_vanilla_profile(self, source, target): egg = egg_source(source) if not is_generator_egg(egg): return tgv = TaggedValues(source) profilename = tgv.direct('name', 'generator:profile', source.name) basepath = os.path.dirname(agx.generator.generator.__file__) profilepath = os.path.join(basepath, 'resources', 'vanilla_profile') # read the model files model_di = open(os.path.join(profilepath, 'model.profile.di')).read() model_uml = open(os.path.join(profilepath, 'model.profile.uml')).read() model_notation = open(os.path.join(profilepath, 'model.profile.notation')).read() eggdir = read_target_node(egg_source(source), target.target) # create profiles dir if 'profiles' not in eggdir.keys(): profiles = Directory() profiles.__name__ = 'profiles' eggdir['profiles'] = profiles profiles = eggdir['profiles'] # add the model files with correct name and change the references if profilename + '.profile.di' not in profiles.keys(): ff = File() ff._data = model_di.replace('model.profile.notation', profilename + '.profile.notation') profiles[profilename + '.profile.di'] = ff if profilename + '.profile.uml' not in profiles.keys(): ff = File() ff._data = model_uml.replace('profilename_changeme', profilename) profiles[profilename + '.profile.uml'] = ff if profilename + '.profile.notation' not in profiles.keys(): ff = File() ff._data = model_notation.replace('model.profile.uml', profilename + '.profile.uml') profiles[profilename + '.profile.notation'] = ff
def typeicon(self, source, target): egg = egg_source(source) package = read_target_node(egg, target.target) resources = package['resources'] icon = '%s_icon.png' % source.name.lower() klass = read_target_node(source, target.target) folderish = token(str(klass.uuid), True, folderish=False).folderish if not icon in resources: default = package['profiles']['default'] type_name = type_id(source, target.target) name = '%s.xml' % type_name fti = default['types'][name] if folderish: path = templatepath('folder_icon.png') else: path = templatepath('document_icon.png') file = resources[icon] = File() file.mode = MODE_BINARY with open(path) as template: file.data = template.read()