Parses user input for a package name
    :return:
427814
def main():
    
    parser = argparse.ArgumentParser('Determines the health of a package')

    parser.add_argument(
        'package_name',
        help='Name of package listed on pypi.python.org',
    )

    parser.add_argument(
        'package_version', nargs='?',
        help='Version of package to check',
    )

    parser.add_argument(
        '-v', '--verbose', required=False,
        help='Show verbose output - the reasons for the package health score',
        action='store_true'
    )

    parser.add_argument(
        '-n', '--no_output', required=False,
        help='Show no output - no output will be generated',
        action='store_true'
    )

    args = parser.parse_args()

    return calculate_health(args.package_name, args.package_version, args.verbose, args.no_output)
196304
def get_name_variants(pkg):
    # type: (STRING_TYPE) -> Set[STRING_TYPE]
    

    if not isinstance(pkg, six.string_types):
        raise TypeError("must provide a string to derive package names")
    from pkg_resources import safe_name
    from packaging.utils import canonicalize_name

    pkg = pkg.lower()
    names = {safe_name(pkg), canonicalize_name(pkg), pkg.replace("-", "_")}
    return names
921002
@VisibleForTesting
  static String packageName(String source) {
    try (StringReader r = new StringReader(source)) {
      StreamTokenizer tokenizer = new StreamTokenizer(r);
      tokenizer.slashSlashComments(true);
      tokenizer.slashStarComments(true);
      StringBuilder sb = new StringBuilder();
      boolean inName = false;
      while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
        if (inName) {
          switch (tokenizer.ttype) {
            case ';':
              return sb.length() > 0 ? sb.toString() : null;
            case '.':
              sb.append('.');
              break;
            case StreamTokenizer.TT_WORD:
              sb.append(tokenizer.sval);
              break;
            default:
              inName = false; // Invalid package statement pattern.
              break;
          }
        } else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("package")) {
          inName = true;
        }
      }
      return null; // Package statement not found.
    } catch (IOException e) {
      throw new AssertionError("Exception reading string: " + e);
    }
  }
730592
def get_package_id(self, name):
        
        json_scheme = self.gen_def_json_scheme('GetPreConfiguredPackages', dict(HypervisorType=4))
        json_obj = self.call_method_post(method='GetPreConfiguredPackages ', json_scheme=json_scheme)
        for package in json_obj['Value']:
            packageId  = package['PackageID']
            for description in package['Descriptions']:
                languageID = description['LanguageID']
                packageName = description['Text']
                if languageID == 2 and packageName.lower() == name.lower():
                    return packageId
1206815
def parse_package_for_version(name):
    
    from utool import util_regex
    init_fpath = join(name, '__init__.py')
    version_errmsg = textwrap.dedent(
        '''
        You must include a __version__ variable
        in %s\'s __init__.py file.
        Try something like:
        __version__ = '1.0.0.dev1' ''' % (name,))
    if not exists(init_fpath):
        raise AssertionError(version_errmsg)
    val_regex = util_regex.named_field('version', '[0-9a-zA-Z.]+')
    regexstr = '__version__ *= *[\'"]' + val_regex
    def parse_version(line):
        # Helper
        line = line.replace(' ', '').replace('\t', '')
        match_dict = util_regex.regex_parse(regexstr, line)
        if match_dict is not None:
            return match_dict['version']
    # Find the version  in the text of the source
    #version = 'UNKNOWN_VERSION'
    with open(init_fpath, 'r') as file_:
        for line in file_.readlines():
            if line.startswith('__version__'):
                version = parse_version(line)
                if version is not None:
                    return version
    raise AssertionError(version_errmsg)
1367259
def get_pkg_config(pkg_config_args, *packages):
    
    if not isinstance(pkg_config_args, (tuple, list)):
        pkg_config_args = [pkg_config_args]
    # Maybe we have multiple pkg-config, and maybe some of them finds it.
    for pp in find_exec_in_path("pkg-config"):
        try:
            cmd = [pp] + list(pkg_config_args) + list(packages)
            #print(" ".join(cmd))
            out = check_output(cmd, stderr=open(os.devnull, "wb"))
            return out.strip().decode("utf8").split()
        except CalledProcessError:
            pass
    return None
743479
def list_(env=None, user=None):
    
    cmd = _create_conda_cmd('list', args=['--json'], env=env, user=user)
    ret = _execcmd(cmd, user=user)
    if ret['retcode'] == 0:
        pkg_list = json.loads(ret['stdout'])
        packages = {}
        for pkg in pkg_list:
            pkg_info = pkg.split('-')
            name, version, build = '-'.join(pkg_info[:-2]), pkg_info[-2], pkg_info[-1]
            packages[name] = {'version': version, 'build': build}
        return packages
    else:
        return ret
269737
static String[] parsePackages(String packages) {

    if (packages == null || packages.trim().length() == 0) {
      return new String[0];
    }
    String[] commaSplit = packages.split(",");
    String[] processPackages = new String[commaSplit.length];
    for (int i = 0; i < commaSplit.length; i++) {
      processPackages[i] = convert(commaSplit[i]);
    }
    return processPackages;
  }
795980
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken,
            knowledge_base):
    """"""
    _ = stderr, time_taken, args, knowledge_base  # Unused.
    self.CheckReturn(cmd, return_val)
    column_lengths = []
    i = 0
    for i, line in enumerate(stdout.decode("utf-8").splitlines()):
      if line.startswith("+++-"):
        # This is a special header line that determines column size.
        for col in line.split("-")[1:]:
          if not re.match("=*", col):
            raise parser.ParseError("Invalid header parsing for %s at line "
                                    "%s" % (cmd, i))
          column_lengths.append(len(col))
        break

    if not column_lengths:
      return

    packages = []

    remaining_lines = stdout.splitlines()[i + 1:]
    for i, line in enumerate(remaining_lines):
      cols = line.split(None, len(column_lengths))

      # The status column is ignored in column_lengths.
      if len(column_lengths) == 4:
        # Installed, Name, Version, Architecture, Description
        status, name, version, arch, desc = cols
      elif len(column_lengths) == 3:
        # Older versions of dpkg don't print Architecture
        status, name, version, desc = cols
        arch = None
      else:
        raise ValueError("Bad number of columns in dpkg --list output: %s" %
                         len(column_lengths))

      # Status is potentially 3 columns, but always at least two, desired and
      # actual state. We only care about actual state.
      if status[1] == "i":
        status = rdf_client.SoftwarePackage.InstallState.INSTALLED
      else:
        status = rdf_client.SoftwarePackage.InstallState.UNKNOWN
      packages.append(
          rdf_client.SoftwarePackage(
              name=name,
              description=desc,
              version=version,
              architecture=arch,
              install_state=status))

    if packages:
      yield rdf_client.SoftwarePackages(packages=packages)
549452
def qualified_name(self):
        
        idxstr = '' if self.index is None else str(self.index)
        return "%s[%s]" % (self.qualified_package_name, idxstr)
708346
def _parse_package(cls, package_string):
        
        pkg, arch = rsplit(package_string, cls._arch_sep(package_string))
        if arch not in KNOWN_ARCHITECTURES:
            pkg, arch = (package_string, None)
        pkg, release = rsplit(pkg, '-')
        name, version = rsplit(pkg, '-')
        epoch, version = version.split(':', 1) if ":" in version else ['0', version]
        # oracleasm packages have a dash in their version string, fix that
        if name.startswith('oracleasm') and name.endswith('.el5'):
            name, version2 = name.split('-', 1)
            version = version2 + '-' + version
        return {
            'name': name,
            'version': version,
            'release': release,
            'arch': arch,
            'epoch': epoch
        }
375881
private String parseOuterClassName() {
		StringBuilder sb = new StringBuilder();
		sb.append(parseJavaId());
		while (peekChar() == packageSeparator) { // '/' or '.'
			nextChar(packageSeparator);
			sb.append('.');
			sb.append(parseJavaId());
		}
		return sb.toString();
	}
987731
def package_install(name, **kwargs):
    '''
    
    '''
    cmd = 'pkg_install ' + name
    if kwargs.get('version', False):
        cmd += ' ' + kwargs['version']

    # Send the command to execute
    out, err = DETAILS['server'].sendline(cmd)

    # "scrape" the output and return the right fields as a dict
    return parse(out)
634740
def is_valid_package_name(name, raise_error=False):
    
    is_valid = PACKAGE_NAME_REGEX.match(name)
    if raise_error and not is_valid:
        raise PackageRequestError("Not a valid package name: %r" % name)
    return is_valid
1053957
function getPackageDefinition(packageName) {
  var def = PACKAGE_DEFINITIONS[packageName];
  if (!def) {
    warn('Cannot find package ' + packageName + '!');
    warn('Exiting...');
    process.exit();
  }
  return def;
}
467441
def get_version(package):
    
    init_py = readfile(os.path.join(package, '__init__.py'))
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
404554
def get_version(package_name, version_file='_version.py'):
    """"""
    filename = os.path.join(os.path.dirname(__file__), package_name, version_file)
    with open(filename, 'rb') as fp:
        return fp.read().decode('utf8').split('=')[1].strip(" \n'")