Create assembly manifest.
506884
def create_manifest(filename, manifest, console):
    
    if not manifest:
        manifest = ManifestFromXMLFile(filename)
        # /path/NAME.exe.manifest - split extension twice to get NAME.
        name = os.path.basename(filename)
        manifest.name = os.path.splitext(os.path.splitext(name)[0])[0]
    elif isinstance(manifest, basestring) and "<" in manifest:
        # Assume XML string
        manifest = ManifestFromXML(manifest)
    elif not isinstance(manifest, Manifest):
        # Assume filename
        manifest = ManifestFromXMLFile(manifest)
    dep_names = set([dep.name for dep in manifest.dependentAssemblies])
    if manifest.filename != filename:
        # Update dependent assemblies
        depmanifest = ManifestFromXMLFile(filename)
        for assembly in depmanifest.dependentAssemblies:
            if not assembly.name in dep_names:
                manifest.dependentAssemblies.append(assembly)
                dep_names.add(assembly.name)
    if (not console and
        not "Microsoft.Windows.Common-Controls" in dep_names):
        # Add Microsoft.Windows.Common-Controls to dependent assemblies
        manifest.dependentAssemblies.append(
            Manifest(type_="win32",
                 name="Microsoft.Windows.Common-Controls",
                 language="*",
                 processorArchitecture=processor_architecture(),
                 version=(6, 0, 0, 0),
                 publicKeyToken="6595b64144ccf1df")
            )
    manifest.writeprettyxml(filename)
    return manifest
684933
def generate(env):
    """"""
    SCons.Tool.CreateJarBuilder(env)

    SCons.Tool.CreateJavaFileBuilder(env)
    SCons.Tool.CreateJavaClassFileBuilder(env)
    SCons.Tool.CreateJavaClassDirBuilder(env)

    env.AddMethod(Jar)

    env['JAR']        = 'jar'
    env['JARFLAGS']   = SCons.Util.CLVar('cf')
    env['_JARFLAGS']  = jarFlags
    env['_JARMANIFEST'] = jarManifest
    env['_JARSOURCES'] = jarSources
    env['_JARCOM']    = '$JAR $_JARFLAGS $TARGET $_JARMANIFEST $_JARSOURCES'
    env['JARCOM']     = "${TEMPFILE('$_JARCOM','$JARCOMSTR')}"
    env['JARSUFFIX']  = '.jar'
1320277
def create_module(clear_target, target):
    """"""

    if os.path.exists(target):
        if clear_target:
            shutil.rmtree(target)
        else:
            log("Target exists! Use --clear to delete it first.",
                emitter='MANAGE')
            sys.exit(2)

    done = False
    info = None

    while not done:
        info = _ask_questionnaire()
        pprint(info)
        done = _ask('Is the above correct', default='y', data_type='bool')

    augmented_info = _augment_info(info)

    log("Constructing module %(plugin_name)s" % info)
    _construct_module(augmented_info, target)
1216460
def put_manifest(self, manifest):
        """"""
        logger.debug("Putting manifest")
        text = json.dumps(manifest, indent=2, sort_keys=True)
        key = self.get_manifest_key()
        self.put_text(key, text)
435141
def create_program_action(parent, text, name, icon=None, nt_name=None):
    """"""
    if is_text_string(icon):
        icon = get_icon(icon)
    if os.name == 'nt' and nt_name is not None:
        name = nt_name
    path = programs.find_program(name)
    if path is not None:
        return create_action(parent, text, icon=icon,
                             triggered=lambda: programs.run_program(name))
545517
def generate(env):
    """"""
    M4Action = SCons.Action.Action('$M4COM', '$M4COMSTR')
    bld = SCons.Builder.Builder(action = M4Action, src_suffix = '.m4')

    env['BUILDERS']['M4'] = bld

    # .m4 files might include other files, and it would be pretty hard
    # to write a scanner for it, so let's just cd to the dir of the m4
    # file and run from there.
    # The src_suffix setup is like so: file.c.m4 -> file.c,
    # file.cpp.m4 -> file.cpp etc.
    env['M4']      = 'm4'
    env['M4FLAGS'] = SCons.Util.CLVar('-E')
    env['M4COM']   = 'cd ${SOURCE.rsrcdir} && $M4 $M4FLAGS < ${SOURCE.file} > ${TARGET.abspath}'
1005714
def _auto_install(self):
        
        template = Template(template=self.manifest)
        sections = template.sections()
        images = self.d_client.images.list(filters={'label': 'vent'})
        add_sections = []
        status = (True, None)
        for image in images:
            ignore = False
            if ('Labels' in image.attrs['Config'] and
                'vent.section' in image.attrs['Config']['Labels'] and
                    not image.attrs['Config']['Labels']['vent.section'] in sections[1]):
                section = image.attrs['Config']['Labels']['vent.section']
                section_str = image.attrs['Config']['Labels']['vent.section'].split(
                    ':')
                template.add_section(section)
                if 'vent.name' in image.attrs['Config']['Labels']:
                    template.set_option(section,
                                        'name',
                                        image.attrs['Config']['Labels']['vent.name'])
                if 'vent.repo' in image.attrs['Config']['Labels']:
                    template.set_option(section,
                                        'repo',
                                        image.attrs['Config']['Labels']['vent.repo'])
                    git_path = join(self.path_dirs.plugins_dir,
                                    '/'.join(section_str[:2]))
                    # TODO clone it down
                    template.set_option(section, 'path', join(
                        git_path, section_str[-3][1:]))
                    # get template settings
                    # TODO account for template files not named vent.template
                    v_template = Template(template=join(
                        git_path, section_str[-3][1:], 'vent.template'))
                    tool_sections = v_template.sections()
                    if tool_sections[0]:
                        for s in tool_sections[1]:
                            section_dict = {}
                            options = v_template.options(s)
                            if options[0]:
                                for option in options[1]:
                                    option_name = option
                                    if option == 'name':
                                        # get link name
                                        template.set_option(section,
                                                            'link_name',
                                                            v_template.option(s, option)[1])
                                        option_name = 'link_name'
                                    opt_val = v_template.option(s, option)[1]
                                    section_dict[option_name] = opt_val
                            if section_dict:
                                template.set_option(section, s,
                                                    json.dumps(section_dict))
                if ('vent.type' in image.attrs['Config']['Labels'] and
                        image.attrs['Config']['Labels']['vent.type'] == 'repository'):
                    template.set_option(
                        section, 'namespace', '/'.join(section_str[:2]))
                    template.set_option(section, 'branch', section_str[-2])
                    template.set_option(section, 'version', section_str[-1])
                    template.set_option(section, 'last_updated', str(
                        datetime.utcnow()) + ' UTC')
                    if image.attrs['RepoTags']:
                        template.set_option(
                            section, 'image_name', image.attrs['RepoTags'][0])
                    else:
                        # image with none tag is outdated, don't add it
                        ignore = True
                    template.set_option(section, 'type', 'repository')
                if 'vent.groups' in image.attrs['Config']['Labels']:
                    template.set_option(section,
                                        'groups',
                                        image.attrs['Config']['Labels']['vent.groups'])
                template.set_option(section, 'built', 'yes')
                template.set_option(section, 'image_id',
                                    image.attrs['Id'].split(':')[1][:12])
                template.set_option(section, 'running', 'no')
                # check if image is running as a container
                containers = self.d_client.containers.list(
                    filters={'label': 'vent'})
                for container in containers:
                    if container.attrs['Image'] == image.attrs['Id']:
                        template.set_option(section, 'running', 'yes')
                if not ignore:
                    add_sections.append(section)
                    template.write_config()
        # TODO this check will always be true, need to actually validate the above logic
        if status[0]:
            status = (True, add_sections)
        return status
1117225
def create_catalog(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.create_bin
        return Catalog(
            self._provider_manager,
            self._get_provider_session('catalog_admin_session').create_catalog(*args, **kwargs),
            self._runtime,
            self._proxy)
967087
def BuildInstallerPkg(self, output_file):
    """"""
    self.CreateInstallDirs()
    self.InterpolateFiles()
    self.RenameGRRPyinstallerBinaries()
    self.SignGRRPyinstallerBinaries()
    self.WriteClientConfig()
    self.Set755Permissions()
    self.RunPkgBuild()
    self.RunProductBuild()
    self.RenamePkgToTemplate(output_file)
16999
def register_manifest(app, filename='manifest.json'):
    ''''''
    if current_app.config.get('TESTING'):
        return  # Do not spend time here when testing
    if not has_manifest(app, filename):
        msg = '{filename} not found for {app}'.format(**locals())
        raise ValueError(msg)
    manifest = _manifests.get(app, {})
    manifest.update(load_manifest(app, filename))
    _manifests[app] = manifest
659892
function Manifest(options) {
  this.options = options;
  this.destDir = options.destDir || process.cwd();
  this.content = {};
  this.filePath = path.join(this.destDir, MANIFEST_FILENAME);

  // get or create manifest content
  this.content = this.read();
}
704227
async function createManifest(libraryResource, libBundle, descriptorVersion, _include3rdParty) {
	// create a Library wrapper around the .library XML
	const library = await Library.from(libraryResource);

	// collect information from library.js file
	const libraryJSInfo = await analyzeLibraryJS(libBundle.findResource("library.js"));

	const manifestAppData = library.getAppData("manifest", XMLNS_MANIFEST);
	const sapFioriAppData = findChild(manifestAppData, "sap.fiori");

	function sectionVersion(candidateVersion) {
		// _version property for nested sections became optional with AppDescriptor V5
		if ( descriptorVersion.compare(APP_DESCRIPTOR_V5) < 0 ) {
			return candidateVersion;
		}
		// return undefined
	}

	function createSapApp() {
		function findComponentPaths() {
			const result = [];
			const prefix = libraryResource.getPath().slice(0, - ".library".length);
			const components = libBundle.getResources(/(?:[^/]+\/)*Component\.js$/);
			components.forEach((comp) => {
				const relativePath = comp.getPath().slice(prefix.length);
				if ( relativePath.lastIndexOf("/") >= 0 ) {
					result.push( relativePath.slice(0, relativePath.lastIndexOf("/")) );
				} else if ( prefix !== "/resources/sap/ui/core/" ) {
					log.error("Package %s contains both '*.library' and 'Component.js'. " +
						"This is not supported by manifests, therefore the component won't be " +
						"listed in the library's manifest.", comp.getPath());
				}
			});
			return result.sort();
		}

		function isValid(version) {
			return version && version !== "@version@" && version !== "${version}";
		}

		function getProjectVersion() {
			const project = libraryResource._project;
			if ( project ) {
				return project.version;
			}
		}

		function getLibraryTitle() {
			if ( library.getTitle() ) {
				return library.getTitle();
			}
			if ( library.getDocumentation() ) {
				let desc = library.getDocumentation();
				// remove all tags
				desc = desc.replace(/\\s+/g, " ").replace(/<\/?[a-zA-Z][a-zA-Z0-9_$.]*(\s[^>]*)>/g, "");
				// extract summary (first sentence)
				const m = /^([\w\W]+?[.;!?])[^a-zA-Z0-9_$]/.exec(desc);
				return m ? m[1] : desc;
			}
			return library.getName();
		}

		function getDefaultACH() {
			const ownership = library.getAppData("ownership", XMLNS_OWNERSHIP);
			for (const comp of findChildren(ownership, "component")) {
				if ( comp._ ) {
					return comp._;
				}
			}
		}

		function offline() {
			let result = sapFioriAppData == null ? true : false;
			const offlineElement = findChild(manifestAppData, "offline");
			if ( offlineElement ) {
				result = offlineElement._ === "true";
			}
			return result;
		}

		function sourceTemplate() {
			const sourceTemplateElement = findChild(manifestAppData, "sourceTemplate");
			if ( sourceTemplateElement ) {
				return {
					"id": getChildTextContent(sourceTemplateElement, "id"),
					"version": getChildTextContent(sourceTemplateElement, "version")
				};
			}
		}

		function openSourceComponents() {
			const embeddedOSComponents = new Set();
			const osComponents = [];
			for (const osCompElem of findChildren(manifestAppData, "openSourceComponent")) {
				const name = getAttribute(osCompElem, "name");
				const packagedWithMySelf = getBooleanAttribute(osCompElem, "packagedWithMySelf");
				osComponents.push({
					name: name,
					packagedWithMySelf,
					version: packagedWithMySelf ? getAttribute(osCompElem, "version") : undefined
				});
				if ( packagedWithMySelf ) {
					embeddedOSComponents.add(name);
				}
			}

			if ( _include3rdParty ) {
				// also merge all thirdparty libs, but only with the name - version info is not available
				// only merge in if no lib with the same name has been declared already
				const thirdpartyAppData = library.getAppData("thirdparty", XMLNS_THIRDPARTY);
				for (const thirdPartyElem of findChildren(thirdpartyAppData, "lib")) {
					const osCompName = getAttribute(thirdPartyElem, "name");
					if ( !embeddedOSComponents.has(osCompName) ) {
						embeddedOSComponents.add(osCompName);
						osComponents.push({
							name: osCompName,
							packagedWithMySelf: true,
							version: getAttribute(thirdPartyElem, "version") || "0.0.0"
						});
					}
				}
			}

			return osComponents.length > 0 ? osComponents : undefined;
		}

		const sapApp = {
			_version: sectionVersion(APP_DESCRIPTOR_V3_SECTION_SAP_APP),
			id: library.getName(),
			type: "library",
			embeds: findComponentPaths(),
			i18n: getChildTextContent(manifestAppData, "i18n"),
			applicationVersion: {
				version: isValid(library.getVersion()) ? library.getVersion() : getProjectVersion()
			},
			title: getLibraryTitle(),
			description: library.getDocumentation(),
			ach: getDefaultACH(), // optional, might be undefined
			resources: "resources.json",
			offline: offline(),
			sourceTemplate: sourceTemplate(),
			openSourceComponents: openSourceComponents()
		};

		log.verbose("  sap.app/id taken from .library: '%s'", sapApp.id);
		log.verbose("  sap.app/embeds determined from resources: '%s'", sapApp.embeds);
		log.verbose("  sap.app/i18n taken from .library appData: '%s'", sapApp.i18n);
		log.verbose("  sap.app/ach taken from .library appData/ownership: '%s'", sapApp.ach);

		return sapApp;
	}

	function createSapUi() {
		function deviceTypes() {
			const deviceTypesElement = findChild(manifestAppData, "deviceTypes");
			if ( deviceTypesElement ) {
				return {
					desktop: getBooleanAttribute(deviceTypesElement, "desktop"),
					tablet: getBooleanAttribute(deviceTypesElement, "tablet"),
					phone: getBooleanAttribute(deviceTypesElement, "phone"),
				};
			}
		}

		function collectThemes() {
			const themes = {};

			// find theme resources and determine theme names from their paths
			libBundle.getResources(/(?:[^/]+\/)*themes\//).forEach((res) => {
				const match = /\/themes\/([^/]+)\//.exec(res.getPath());
				if ( match ) {
					themes[match[1]] = true;
				}
			});

			// merge with supporteTheme info from .library file
			const elems = findChildren(manifestAppData, "supportedTheme");
			if ( elems ) {
				elems.forEach((elem) => {
					if ( elem._ ) {
						themes[elem._];
					}
				});
			}
			return Object.keys(themes).sort();
		}

		const sapUi = {
			_version: sectionVersion(APP_DESCRIPTOR_V3_OTHER_SECTIONS),
			technology: "UI5",
			deviceTypes: deviceTypes(),
			supportedThemes: collectThemes()
		};

		log.verbose("  sap.ui/supportedThemes determined from resources: '%s'", sapUi.supportedThemes);

		return sapUi;
	}

	function createSapUI5() {
		function getUI5Version() {
			let ui5Version;
			if ( ui5Version != null ) {
				return ui5Version;
			}

			const dummy = new Dependency({
				libraryName: [{
					_: "sap.ui.core"
				}]
			});
			return normalizeVersion(getVersion(dummy));
		}

		function dependencies() {
			const dependencies = {
				minUI5Version: getUI5Version(),
				libs: {
				}
			};
			if ( library.getDependencies() != null ) {
				for (const dep of library.getDependencies()) {
					dependencies.libs[dep.getLibraryName()] = {
						minVersion: getVersion(dep),
						lazy: dep.isLazy() || undefined // suppress default (false)
					};
				}
			}
			log.verbose("  sap.ui5/dependencies/libs determined from .library dependencies: '%s'", dependencies.libs);
			return dependencies;
		}

		function contentDensities() {
			const contentDensitiesElement = findChild(manifestAppData, "contentDensities");
			if ( contentDensitiesElement != null ) {
				const contentDensities = {
					cozy: getBooleanAttribute(contentDensitiesElement, "cozy"),
					compact: getBooleanAttribute(contentDensitiesElement, "compact")
				};
				log.verbose("  sap.ui5/contentDensities property taken from .library appData: '%s'", contentDensities);
				return contentDensities;
			}
		}

		function createLibraryMetadata() {
			if ( descriptorVersion.compare(APP_DESCRIPTOR_V10) < 0 ) {
				log.verbose("  target descriptor version %s: skipping sap.ui5/library information",
					descriptorVersion);
			}

			log.verbose("  target descriptor version %s: include sap.ui5/library information", descriptorVersion);

			const sapUi5AppData = findChild(manifestAppData, "sap.ui5");
			const libraryAppData = findChild(sapUi5AppData, "library");

			// i18n:
			// - from .library/appData/manifest/sap.ui5/library/i18n
			// - from library resources (if "messagebundle.properties" exists)
			function i18n() {
				const i18nElement = findChild(libraryAppData, "i18n");
				if ( i18nElement ) {
					const i18n = i18nElement._;
					if ( i18n === "false" ) {
						return false;
					} else if ( i18n === "true" ) {
						return "messagebundle.properties";
					} else {
						return i18n;
					}
					// log.verbose("  sap.ui5/library/i18n property taken from .library appData: '%s'", library.i18n);
				} else {
					if ( libBundle.findResource("messagebundle.properties") != null ) {
						// log.verbose("  sap.ui5/library/i18n property determined from resources: '%s'", library.i18n);
						return "messagebundle.properties";
					} else {
						return false;
					}
				}
			}

			// css:
			// - from .library/appData/manifest/sap.ui5/library/css
			// - from library.js/initLibrary/noLibraryCSS
			function css() {
				const cssElement = findChild(libraryAppData, "css");
				if ( cssElement != null ) {
					const css = cssElement._;
					if ( css === "false" ) {
						log.verbose("  sap.ui5/library/css property taken from .library appData: '%s'", false);
						return false;
					}
				} else if ( libraryJSInfo.noLibraryCSS ) {
					log.verbose("  sap.ui5/library/css property extracted from library.js: '%s'", false);
					return false;
				}
			}

			// content
			// - from library.js/initLibrary/ (types|elements|controls|interfaces)
			function content() {
				const libraryJS = libraryJSInfo;
				if ( libraryJS.controls || libraryJS.elements || libraryJS.interfaces || libraryJS.types ) {
					return {
						controls: libraryJS.controls,
						elements: libraryJS.elements,
						types: libraryJS.types,
						interfaces: libraryJS.interfaces
					};
				}
			}

			return {
				i18n: i18n(),
				css: css(),
				content: content()
			};
		}

		const sapUI5 = {
			_version: sectionVersion(APP_DESCRIPTOR_V3_OTHER_SECTIONS),
			dependencies: dependencies(),
			contentDensities: contentDensities(),
			library: createLibraryMetadata()
		};

		return sapUI5;
	}

	function createSapFiori() {
		// collect registrationIds if present
		function registrationIds() {
			const ids = [];
			for (const regid of findChildren(sapFioriAppData, "registrationId")) {
				ids.push(regid._);
			}
			return ids.length > 0 ? ids : undefined;
		}

		if ( sapFioriAppData != null ) {
			return {
				_version: sectionVersion(APP_DESCRIPTOR_V3_OTHER_SECTIONS),
				registrationIds: registrationIds(),
				archeType: getChildTextContent(sapFioriAppData, "archeType", "reuseComponent")
			};
		}
	}

	function createSapPlatformABAP() {
		const sapPlatformABAPElement = findChild(manifestAppData, "sap.platform.abap");
		if ( sapPlatformABAPElement ) {
			return {
				_version: sectionVersion(APP_DESCRIPTOR_V3_OTHER_SECTIONS),
				uri: getChildTextContent(sapPlatformABAPElement, "uri")
			};
		}
	}

	function createSapPlatformHCP() {
		const sapPlatformHCPElement = findChild(manifestAppData, "sap.platform.hcp");
		if ( sapPlatformHCPElement ) {
			return {
				_version: sectionVersion(APP_DESCRIPTOR_V3_OTHER_SECTIONS),
				uri: getChildTextContent(sapPlatformHCPElement, "uri")
			};
		}
	}

	function normalizeVersion(version) {
		if ( version == null ) {
			return version;
		}
		const v = new Version(version);
		return v.major + "." + v.minor;
	}

	function getVersion(dependency) {
		const version = dependency.getVersion();
		if ( version != null ) {
			return version;
		}

		function hasName(entity) {
			return entity.metadata && entity.metadata.name === dependency.getLibraryName();
		}

		const project = libraryResource._project;
		if ( project ) {
			if ( Array.isArray(project.dependencies) ) {
				const lib = project.dependencies.find(hasName);
				if ( lib ) {
					return lib.version;
				}
			}
			if ( hasName(project) ) {
				return project.version;
			}
		}

		throw new Error(
			`Couldn't find version for library '${dependency.getLibraryName()}', project dependency missing?`);
	}

	return {
		"_version": descriptorVersion.toString(),
		"sap.app": createSapApp(),
		"sap.ui": createSapUi(),
		"sap.ui5": createSapUI5(),
		"sap.fiori": createSapFiori(),
		"sap.platform.abap": createSapPlatformABAP(),
		"sap.platform.hcp": createSapPlatformHCP()
	};
}
60693
private Manifest createManifest( File jar, Map<String, String> manifestentries )
            throws MojoExecutionException
    {
        JarFile jarFile = null;
        try
        {
            jarFile = new JarFile( jar );

            // read manifest from jar
            Manifest manifest = jarFile.getManifest();

            if ( manifest == null || manifest.getMainAttributes().isEmpty() )
            {
                manifest = new Manifest();
                manifest.getMainAttributes().putValue( Attributes.Name.MANIFEST_VERSION.toString(), "1.0" );
            }

            // add or overwrite entries
            Set<Map.Entry<String, String>> entrySet = manifestentries.entrySet();
            for ( Map.Entry<String, String> entry : entrySet )
            {
                manifest.getMainAttributes().putValue( entry.getKey(), entry.getValue() );
            }

            return manifest;
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Error while reading manifest from " + jar.getAbsolutePath(), e );
        }
        finally
        {
            ioUtil.close( jarFile );
        }
    }
366487
def create(self):
        """"""
        self.logger.log(logging.DEBUG, 'os.mkdir %s', self.name)
        os.mkdir(self.name)
849736
def create_manifest(self):
        
        self.manifest = {}
        self.manifest['applications'] = [{'name': self.app_name}]
        self.manifest['services'] = []
        self.manifest['env'] = {
                'PREDIXPY_VERSION': str(predix.version),
                }

        self.write_manifest()
864232
def write_manifest(self):
        
        if os.path.exists(self.directory.manifest_path):
            self.main_manifest.write(open(self.directory.manifest_path, "w+"))
796841
def _create_project(config):
    """"""
    try:
        response = config.pbclient.create_project(config.project['name'],
                                                  config.project['short_name'],
                                                  config.project['description'])
        check_api_error(response)
        return ("Project: %s created!" % config.project['short_name'])
    except exceptions.ConnectionError:
        return("Connection Error! The server %s is not responding" % config.server)
    except (ProjectNotFound, TaskNotFound):
        raise