Returns a dictionary mapping {check-package-name --> pinned_version} from the
    given file contents. We can assume lines are in the form:

        datadog-active-directory==1.1.1; sys_platform == 'win32'
541004
def parse_agent_req_file(contents):
    
    catalog = OrderedDict()
    for line in contents.splitlines():
        toks = line.split('==', 1)
        if len(toks) != 2 or not toks[0] or not toks[1]:
            # if we get here, the requirements file is garbled but let's stay
            # resilient
            continue

        name, other = toks
        version = other.split(';')
        catalog[name] = version[0]

    return catalog
1274432
def package_version(filename, varname):
    """"""
    _locals = {}
    with open(filename) as fp:
        exec(fp.read(), None, _locals)
    return _locals[varname]
877258
def get_agent_requirement_line(check, version):
    
    package_name = get_package_name(check)

    # no manifest
    if check in ('datadog_checks_base', 'datadog_checks_downloader'):
        return '{}=={}'.format(package_name, version)

    m = load_manifest(check)
    platforms = sorted(m.get('supported_os', []))

    # all platforms
    if platforms == ALL_PLATFORMS:
        return '{}=={}'.format(package_name, version)
    # one specific platform
    elif len(platforms) == 1:
        return "{}=={}; sys_platform == '{}'".format(package_name, version, PLATFORMS_TO_PY.get(platforms[0]))
    elif platforms:
        if 'windows' not in platforms:
            return "{}=={}; sys_platform != 'win32'".format(package_name, version)
        elif 'mac_os' not in platforms:
            return "{}=={}; sys_platform != 'darwin'".format(package_name, version)
        elif 'linux' not in platforms:
            return "{}=={}; sys_platform != 'linux2'".format(package_name, version)

    raise ManifestError("Can't parse the `supported_os` list for the check {}: {}".format(check, platforms))
357895
def _version_string():
    
    platform_system = platform.system()
    if platform_system == 'Linux':
        os_name, os_version, _ = platform.dist()
    else:
        os_name = platform_system
        os_version = platform.version()
    python_version = platform.python_version()
    return 'trytravis %s (%s %s, python %s)' % (__version__,
                                                os_name.lower(),
                                                os_version,
                                                python_version)
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)
1084591
public static String getDoradusVersion() {       
        String version = null;
        try {
            //first read from the local git repository
        	Git git = Git.open(new File("../.git"));
            String url = git.getRepository().getConfig().getString("remote", "origin", "url");
            instance().m_logger.info("Remote.origin.url: {}", url);
            if (!Utils.isEmpty(url) && url.contains("dell-oss/Doradus.git")) {
            	DescribeCommand cmd = git.describe();
            	version = cmd.call();
            	instance().m_logger.info("Doradus version found from git repo: {}", version);
            	writeVersionToVerFile(version);
            }
        } catch (Throwable e) {
        	instance().m_logger.info("failed to read version from git repo");
        }
        //if not found, reading from local file
        if (Utils.isEmpty(version)) {
	        try {
	            version = getVersionFromVerFile();
	            instance().m_logger.info("Doradus version found from doradus.ver file {}", version);
	        } catch (IOException e1) {
	            version = null;
	        }
        }
        return version;
    }
562393
def __get_cfg_pkgs_dpkg(self):
        '''
        
        '''
        # Get list of all available packages
        data = dict()

        for pkg_name in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None,
                                                        '-Wf', "${binary:Package}\\n")[0]).split(os.linesep):
            pkg_name = pkg_name.strip()
            if not pkg_name:
                continue
            data[pkg_name] = list()
            for pkg_cfg_item in salt.utils.stringutils.to_str(self._syscall('dpkg-query', None, None, '-Wf', "${Conffiles}\\n",
                                                                pkg_name)[0]).split(os.linesep):
                pkg_cfg_item = pkg_cfg_item.strip()
                if not pkg_cfg_item:
                    continue
                pkg_cfg_file, pkg_cfg_sum = pkg_cfg_item.strip().split(" ", 1)
                data[pkg_name].append(pkg_cfg_file)

            # Dpkg meta data is unreliable. Check every package
            # and remove which actually does not have config files.
            if not data[pkg_name]:
                data.pop(pkg_name)

        return data
1106178
def search(name, versions_as_list=False, **kwargs):
    '''
    
    '''

    ret = {}
    cmd = ['/bin/pkg', 'list', '-aHv', name]
    out = __salt__['cmd.run_all'](cmd, ignore_retcode=True)
    if out['retcode'] != 0:
        # error = nothing found
        return {}
    # no error, processing pkg listing
    # column 1 is full FMRI name in form pkg://publisher/pkg/name@version
    for line in out['stdout'].splitlines():
        name = _ips_get_pkgname(line)
        version = _ips_get_pkgversion(line)
        __salt__['pkg_resource.add_pkg'](ret, name, version)

    if not versions_as_list:
        __salt__['pkg_resource.stringify'](ret)
    return ret
1041288
def _get_ignored_version():
    
    if os.path.exists(filepath):
        with open(filepath) as data_file:
            data = json.load(data_file)
            version = data.get('version')
    else:
        version = None
    return version
1298887
private Version getProductVersion(File wlpInstallationDirectory) throws VersionParsingException {
        // First get the properties
        Map<String, ProductInfo> productProperties = VersionUtils.getAllProductInfo(wlpInstallationDirectory);

        // Get the properties for WAS
        ProductInfo wasProperties = productProperties.get("com.ibm.websphere.appserver");
        if (wasProperties == null) {
            throw new VersionParsingException(getMessage("compare.no.was.properties.found"));
        }

        Version version = convertVersion(wasProperties);

        return version;
    }
658535
def _get_version():
    """"""
    with open(os.path.join(os.path.dirname(__file__), PACKAGE_NAME, 'VERSION'), 'rb') as f:
        version = f.read().decode('ascii').strip()
    return version
1208916
def fix_pin(self, line):
        
        dep = Dependency(line)
        if dep.valid:
            if dep.package in self.ignore:
                ignored_version = self.ignore[dep.package]
                if ignored_version is not None:
                    # ignored_version can be None to disable conflict detection
                    if dep.version and dep.version != ignored_version:
                        logger.error(
                            "Package %s was resolved to different "
                            "versions in different environments: %s and %s",
                            dep.package, dep.version, ignored_version,
                        )
                        raise RuntimeError(
                            "Please add constraints for the package "
                            "version listed above"
                        )
                return None
            self.packages[dep.package] = dep.version
            if self.forbid_post or dep.is_compatible:
                # Always drop post for internal packages
                dep.drop_post()
            return dep.serialize()
        return line.strip()
181335
def get_versions(default={"version": "unknown", "full": ""}, verbose=False):
    """"""

    # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
    # __file__, we can work backwards from there to the root. Some
    # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
    # case we can only use expanded keywords.

    keywords = { "refnames": git_refnames,
                 "full_revisionid": git_full_revisionid,
                 "short_revisionid": git_short_revisionid }
    ver = git_versions_from_keywords(keywords, tag_prefix, verbose)
    if ver:
        return ver

    try:
        root = os.path.abspath(__file__)
        # versionfile_source is the relative path from the top of the source
        # tree (where the .git directory might live) to this file. Invert
        # this to find the root from __file__.
# TODO(dustin): Shouldn't this always loop until it fails?
        for i in range(len(versionfile_source.split(os.sep))):
            root = os.path.dirname(root)
    except NameError:
        return default

    return (git_versions_from_vcs(tag_prefix, root, verbose)
            or versions_from_parentdir(parentdir_prefix, root, verbose)
            or default)
80009
def get_pypi_version(self):
        
        if self.args.disable_check_update:
            return

        # If the cached file exist, read-it
        cached_data = self._load_cache()

        if cached_data == {}:
            # Update needed
            # Update and save the cache
            thread = threading.Thread(target=self._update_pypi_version)
            thread.start()
        else:
            # Update not needed
            self.data['latest_version'] = cached_data['latest_version']
            logger.debug("Get Glances version from cache file")
127536
def get_version(*args):
    """"""
    contents = get_contents(*args)
    metadata = dict(re.findall('__([a-z]+)__ = [\'"]([^\'"]+)', contents))
    return metadata['version']
269711
def Version():
  """"""

  version_ini = VersionPath()

  config = configparser.SafeConfigParser()
  config.read(version_ini)
  return dict(
      packageversion=config.get("Version", "packageversion"),
      major=config.getint("Version", "major"),
      minor=config.getint("Version", "minor"),
      revision=config.getint("Version", "revision"),
      release=config.getint("Version", "release"))
1290970
def get_version():
    """"""
    try:
        # Try with the package manager, if present
        from pkg_resources import resource_string
        return resource_string(__name__, "VERSION.txt").decode('utf8').strip()
    except Exception:
        # If the package manager is not present, try reading the file
        version = os.path.join(os.path.dirname(__file__), "VERSION.txt")
        with open(version, "r") as f:
            return f.readlines()[0].strip()