Extracts the driver version from the driver jar MANIFEST.MF file.
19074
private static String driverVersion()
    {
        // "Session" is arbitrary - the only thing that matters is that the class we use here is in the
        // 'org.neo4j.driver' package, because that is where the jar manifest specifies the version.
        // This is done as part of the build, adding a MANIFEST.MF file to the generated jarfile.
        Package pkg = Session.class.getPackage();
        if ( pkg != null && pkg.getImplementationVersion() != null )
        {
            return pkg.getImplementationVersion();
        }

        // If there is no version, we're not running from a jar file, but from raw compiled class files.
        // This should only happen during development, so call the version 'dev'.
        return "dev";
    }
58630
public static String getPomVersion() {
        String cmd = "mvn help:evaluate -Dexpression=project.version " +
                     "-q -DforceStdout";
        Process process = null;
        InputStreamReader isr = null;
        try {
            process = Runtime.getRuntime().exec(cmd);
            process.waitFor();

            isr = new InputStreamReader(process.getInputStream());
            BufferedReader br = new BufferedReader(isr);
            return br.readLine();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (isr != null) {
                try {
                    isr.close();
                } catch (Exception ignored) {}
            }

            // Destroy child process
            if (process != null) {
                process.destroy();
            }
        }
    }
995537
def get_version():
    
    version_file = os.path.join(PKG, 'lib/version.py')
    ver_str_line = open(version_file, "rt").read()
    version_regex = r'^__version__ = [\'"]([^\'"]*)[\'"]'
    mo = re.search(version_regex, ver_str_line, re.M)
    if mo:
        return mo.group(1)
    else:
        raise RuntimeError('Unable to find version string in %s.'
                           % (version_file,))
251649
static Map<String, String> getVersionAttributes(URL url) throws IOException {
        Map<String, String> ret = new LinkedHashMap<>();
        try (InputStream inputStream = url.openStream()) {
            Manifest manifest = new Manifest(inputStream);
            Attributes attributes = manifest.getMainAttributes();
            for (String key : VERSION_ATTRIBUTES) {
                final String value = attributes.getValue(key);
                ret.put(key, value == null ? UNKNOWN_VALUE : value);
            }
        }
        return ret;
    }
265560
public static ManifestVersion of(final URL url)
	{
		final ManifestVersion version = new ManifestVersion();
		if (url != null)
		{
			URLConnection urlConnection = null;
			try
			{
				urlConnection = url.openConnection();
				version.setLastModified(LocalDateTime.ofInstant(
					Instant.ofEpochMilli(urlConnection.getLastModified()), ZoneId.systemDefault()));
				version.setManifest(new Manifest(urlConnection.getInputStream()));
				version
					.setTitle(version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_TITLE));
				version.setVersion(
					version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_VERSION));
			}
			catch (final IOException e)
			{
				throw new RuntimeException("Error while try to load manifest file from " + url, e);
			}
		}
		return version;
	}
164431
def get_dialect(self):
        

        if "+" not in self.drivername:
            name = self.drivername
        else:
            name = self.drivername.replace("+", ".")
        cls = registry.load(name)
        # check for legacy dialects that
        # would return a module with 'dialect' as the
        # actual class
        if (
            hasattr(cls, "dialect")
            and isinstance(cls.dialect, type)
            and issubclass(cls.dialect, Dialect)
        ):
            return cls.dialect
        else:
            return cls
817925
public static String getMdwVersion() {
        if (mdwVersion != null)
            return mdwVersion;

        mdwVersion = "Unknown";
        try {
            String cpUtilLoc = ClasspathUtil.locate(ClasspathUtil.class.getName());
            int jarBangIdx = cpUtilLoc.indexOf(".jar!");
            if (jarBangIdx > 0) {
                String jarFilePath = cpUtilLoc.substring(0, jarBangIdx + 4);
                if (jarFilePath.startsWith("file:/"))
                    jarFilePath = jarFilePath.substring(6);
                if (!jarFilePath.startsWith("/"))
                    jarFilePath = "/" + jarFilePath;
                JarFile jarFile = new JarFile(new File(jarFilePath));
                String subpath = cpUtilLoc.substring(jarBangIdx + 5);
                int subjarBang = subpath.indexOf(".jar!");
                if (subjarBang > 0) {
                    // subjars in spring boot client apps
                    String subjarPath = subpath.substring(1, subjarBang + 4);
                    ZipEntry subjar = jarFile.getEntry(subjarPath);
                    File tempjar = Files.createTempFile("mdw", ".jar").toFile();
                    try (InputStream is = jarFile.getInputStream(subjar);
                            OutputStream os = new FileOutputStream(tempjar)) {
                        int bufSize = 16 * 1024;
                        int read = 0;
                        byte[] bytes = new byte[bufSize];
                        while((read = is.read(bytes)) != -1)
                            os.write(bytes, 0, read);
                    }
                    JarFile tempJarFile = new JarFile(tempjar);
                    Manifest manifest = tempJarFile.getManifest();
                    mdwVersion = manifest.getMainAttributes().getValue("MDW-Version");
                    mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build");
                    tempJarFile.close();
                    tempjar.delete();
                }
                else {
                    Manifest manifest = jarFile.getManifest();
                    mdwVersion = manifest.getMainAttributes().getValue("MDW-Version");
                    mdwBuildTimestamp = manifest.getMainAttributes().getValue("MDW-Build");
                }
                jarFile.close();
            }
            else {
                // try tomcat deploy structure
                String catalinaBase = System.getProperty("catalina.base");
                if (catalinaBase != null) {
                    File webInfLib = new File(catalinaBase + "/webapps/mdw/WEB-INF/lib");
                    if (webInfLib.exists()) {
                        for (File file : webInfLib.listFiles()) {
                            if (file.getName().startsWith("mdw-common")) {
                                mdwVersion = file.getName().substring(11, file.getName().length() - 4);
                                String mfPath = "jar:" + file.toURI() + "!/META-INF/MANIFEST.MF";
                                Manifest manifest = new Manifest(new URL(mfPath).openStream());
                                Attributes attrs = manifest.getMainAttributes();
                                mdwBuildTimestamp = attrs.getValue("MDW-Build");
                                break;
                            }
                        }
                    }
                }
            }

            if (mdwVersion != null && mdwVersion.endsWith(".SNAPSHOT")) {
                mdwVersion = mdwVersion.substring(0, mdwVersion.length() - 9) + "-SNAPSHOT";
            }
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(), ex);
        }

        return mdwVersion;
    }
34214
String scanForDriver(String url) {
    try {
      // already registered
      Driver driver;
      if ((driver = findRegisteredDriver(url)) != null) {
        return driver.getClass().getCanonicalName();
      }

      scanDrivers();

      if ((driver = findRegisteredDriver(url)) != null) {
        return driver.getClass().getCanonicalName();
      }

      return null;
    } catch (Exception e) {
      e.printStackTrace();
      debug(e.toString());
      return null;
    }
  }
483159
public static VersionMonitor getVersion(Class clazz) throws IOException {
        Manifest manifest = new Manifest();
        manifest.read(clazz.getResourceAsStream(MANIFEST_PATH));
        return getVersion(manifest);
    }
1196030
def getFileName(self, suffix=None, extension="jar"):
        

        assert (self._artifactId is not None)
        assert (self._version is not None)

        return "{0}-{1}{2}{3}".format(
            self._artifactId,
            self._version.getRawString(),
            "-" + suffix.lstrip("-") if suffix is not None else "",
            "." + extension.lstrip(".") if extension is not None else ""
        )
337258
def jarManifest(target, source, env, for_signature):
    """"""
    for src in source:
        contents = src.get_text_contents()
        if contents[:16] == "Manifest-Version":
            return src
    return ''
584113
def get_version(*file_paths):
    """"""
    filename = os.path.join(os.path.dirname(__file__), *file_paths)
    print("Looking for version in: {}".format(filename))
    version_file = open(filename).read()
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError('Unable to find version string.')
420419
public static String getJarVersionNumber() {
    Class clazz = SelendroidStandaloneDriver.class;
    String className = clazz.getSimpleName() + ".class";
    String classPath = clazz.getResource(className).toString();
    String version = "";

    if (!classPath.startsWith("jar")) {
      // Class not from JAR
      if(classPath.startsWith("file") && classPath.contains("target")) {
        try {
          version = getVersionFromPom(classPath.substring(5, classPath.lastIndexOf("target")));
        } catch (Exception e) {
          e.printStackTrace();
          return "";
        }
      } else return "dev";
    } else {
        try {
          version = getVersionFromManifest(classPath);
        } catch (IOException e){
          return "";
        }
    }
    return version;
  }
791846
def version_jar(self):
		
		cmd = config.get_command('java')
		cmd.append('-jar')
		cmd += self.cmd
		self.version(cmd=cmd, path=self.cmd[0])
282807
def get_version():
    
    here = os.path.abspath(os.path.dirname(__file__))
    jbxapi_file = os.path.join(here, "jbxapi.py")

    with open(jbxapi_file) as f:
        content = f.read()
        match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M)

    if not match:
        raise RuntimeError("Unable to find version string.")
    return match.group(1)
167247
private Properties getChecksumsForMF(File mf) throws IOException {
        Properties props = new Properties();

        InputStream is = null;
        try {
            is = new FileInputStream(mf);
            Manifest manifest = ManifestProcessor.parseManifest(is);

            String fileName = manifest.getMainAttributes().getValue("Subsystem-SymbolicName");
            NameValuePair pair = ManifestHeaderProcessor.parseBundleSymbolicName(fileName);
            props.put("file.name", pair.getName());

            String contents = manifest.getMainAttributes().getValue("Subsystem-Content");

            Map<String, Map<String, String>> data = ManifestHeaderProcessor.parseImportString(contents);

            for (Map.Entry<String, Map<String, String>> entry : data.entrySet()) {

                String name = entry.getKey();
                Map<String, String> attrs = entry.getValue();
                String type = attrs.get("type");
                // exclude the feature type and jar type
                if (type != null && (type.equals("osgi.subsystem.feature") || type.equals("checksum"))) {
                    continue;
                }

                // find the jar, we don't need care about the version,
                // because only one jar exists when build
                String location = attrs.get("location:");
                File jarFile = null;

                String version = attrs.get("version");
                VersionRange range = new VersionRange(version == null ? "0" : version);
                jarFile = cblbr.selectBundle(location, name, range);

                if (jarFile == null && location != null) {
                    jarFile = new File(installRoot, location);
                }

                if (jarFile == null && (type == null || "osgi.bundle".equals(type))) {
                    throw new BuildException("The OSGi Bundle with name: " + name + ", location: " + location + ", and version " + version
                                             + " does not exist (included in manifest "
                                             + mf.getName() + ")");
                }

                // If we have a null jar, throw a helpful exception rather than an NPE on the next line
                if (jarFile == null)
                {
                    throw new IllegalArgumentException("Could not find a jar file for the bundle " + name);
                }

                if (!jarFile.exists()) {
                    if ((type == null || "osgi.bundle".equals(type))) {
                        throw new BuildException("The OSGi Bundle with: " + name + ", location: " + location + ", and version " + version
                                                 + " does not exist (included in manifest "
                                                 + mf.getName() + ". The jar name was calculated as " + jarFile.getAbsolutePath() + " but this file does not exist.)");
                    }
                } else {
                    // If the bundle selection gave us a directory, and we're here, something is wrong
                    // We can't - and don't want to - try and calculate an MD5 hash for a directory
                    if (jarFile.isDirectory()) {
                        throw new BuildException("The entry with name " + name + ", location " + location + ", and version range " + version + " does not exist from "
                                                 + mf.getName());
                    }
                    if (shouldGenerateChecksum(jarFile)) {
                        // if it's not a directory, carry on and calculate the jar checksum
                        String[] checksumPair = getChecksumPair(jarFile);
                        props.setProperty(checksumPair[0], checksumPair[1]);
                    }
                }

            }
        } finally {
            FileUtils.tryToClose(is);
        }
        return props;

    }
212527
public static String getLicenseAgreement(final JarFile jar, final Map<String, String> manifestAttrs) {
        String licenseAgreement = null;

        if (manifestAttrs.isEmpty()) {
            return licenseAgreement;
        }

        String licenseAgreementPrefix = manifestAttrs.get(ArchiveUtils.LICENSE_AGREEMENT);

        LicenseProvider licenseProvider = (licenseAgreementPrefix != null) ? ZipLicenseProvider.createInstance(jar, licenseAgreementPrefix) : null;

        if (licenseProvider != null)
            licenseAgreement = new InstallLicenseImpl("", LicenseType.UNSPECIFIED, licenseProvider).getAgreement();

        return licenseAgreement;
    }