Is the given string a valid package name?
352873
boolean isValidPackageName(String s) {
        int index;
        while ((index = s.indexOf('.')) != -1) {
            if (!isValidClassName(s.substring(0, index))) return false;
            s = s.substring(index+1);
        }
        return isValidClassName(s);
    }
115731
def is_installed(self, package):
        """"""
        if isinstance(package, tuple):
            package = '=='.join(package)
        if package.endswith('.git'):
            pkg_name = os.path.split(package)[1][:-4]
            return pkg_name in self.installed_package_names or \
                    pkg_name.replace('_', '-') in self.installed_package_names
        pkg_tuple = split_package_name(package)
        if pkg_tuple[1] is not None:
            return pkg_tuple in self.installed_packages
        else:
            return pkg_tuple[0].lower() in self.installed_package_names
1011491
def check_specifier(dist, attr, value):
    """"""
    try:
        packaging.specifiers.SpecifierSet(value)
    except packaging.specifiers.InvalidSpecifier as error:
        tmpl = (
            "{attr!r} must be a string "
            "containing valid version specifiers; {error}"
        )
        raise DistutilsSetupError(tmpl.format(attr=attr, error=error))
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);
    }
  }
323215
def get_random_name():
    """"""
    char_seq = []
    name_source = random.randint(1, 2**8-1)
    current_value = name_source
    while current_value > 0:
        char_offset = current_value % 26
        current_value = current_value - random.randint(1, 26)
        char_seq.append(chr(char_offset + ord('a')))
    name = ''.join(char_seq)
    assert re.match(VALID_PACKAGE_RE, name)
    return name
175287
def resolve_name(name, package):
    """"""
    if not name.startswith('.'):
        return name
    elif not package:
        raise ValueError('{!r} is not a relative name '
                         '(no leading dot)'.format(name))
    level = 0
    for character in name:
        if character != '.':
            break
        level += 1
    return _resolve_name(name[level:], package, level)
182147
def validate_package_name(pkg_name: str) -> None:
    
    if not bool(re.match(PACKAGE_NAME_REGEX, pkg_name)):
        raise ValidationError(f"{pkg_name} is not a valid package name.")
880732
def is_valid_field_name(value):
    """"""
    leftovers = re.sub(r"\w", "", value)
    leftovers = re.sub(r"-", "", leftovers)
    if leftovers != "" or value[0].isdigit() or value[0] in ["-", "_"] or " " in value:
        return False
    return True
635729
def _is_valid_string(self, inpt, metadata):
        """"""
        if not is_string(inpt):
            return False
        if metadata.get_minimum_string_length() and len(inpt) < metadata.get_minimum_string_length():
            return False
        elif metadata.get_maximum_string_length() and len(inpt) > metadata.get_maximum_string_length():
            return False
        if metadata.get_string_set() and inpt not in metadata.get_string_set():
            return False
        else:
            return True
21605
private static String calculatePackagePrefix() {
        String maybeShaded = Library.class.getName();
        // Use ! instead of . to avoid shading utilities from modifying the string
        String expected = "io!netty!internal!tcnative!Library".replace('!', '.');
        if (!maybeShaded.endsWith(expected)) {
            throw new UnsatisfiedLinkError(String.format(
                    "Could not find prefix added to %s to get %s. When shading, only adding a "
                            + "package prefix is supported", expected, maybeShaded));
        }
        return maybeShaded.substring(0, maybeShaded.length() - expected.length());
    }
1356969
function (packageName, context) {
        context = context || '';
        if (!packageName) {
            Aria.$logError(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
            return false;
        }
        if (Aria.isJsReservedWord(packageName)) {
            Aria.$logError(Aria.INVALID_PACKAGENAME_RESERVED, [packageName, context]);
            return false;
        }
        if (!packageName.match(/^[a-z]\w*$/)) {
            Aria.$logInfo(Aria.INVALID_PACKAGENAME_FORMAT, [packageName, context]);
        }
        return true;
    }
369766
function( packageFilename, options ) {
    if( typeof options === 'undefined' ) options = {};

    packageFilename = Path.resolve( packageFilename );
    if( false == FS.existsSync() ) 
        this.fatal( "Package file not found: \"" + packageFilename + "\"" );
    
    var prjDir = Path.dirname( packageFilename );
    this._prjDir = Path.resolve( prjDir );
    this._libDir = Path.resolve( Path.join(__dirname, "../ker") );
    this._tplDir = Path.resolve( Path.join(__dirname, "../tpl") );
    this._srcDir = mkdir.call( this, prjDir, "src" );
    this._docDir = mkdir.call( this, prjDir, "doc" );
    this._tmpDir = mkdir.call( this, prjDir, "tmp" );
    this._wwwDir = mkdir.call( this, prjDir, "www" );

}
1090885
static String getPackageName(Context context) {
        String packageName = "";
        if (context != null) {
            try {
                final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                packageName = packageInfo.packageName;
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining PackageName", e);
            }
        }
        return packageName;
    }
256769
public String parsePackageName(PackageElement p) {
        String pkgname = p.isUnnamed() ? "" : getPackageName(p);
        int index = -1;
        for (int j = 0; j < MAX_CONSTANT_VALUE_INDEX_LENGTH; j++) {
            index = pkgname.indexOf(".", index + 1);
        }
        if (index != -1) {
            pkgname = pkgname.substring(0, index);
        }
        return pkgname;
    }
831591
static String fromPackageName(String packageName) {
        List<String> tokens = tokenOf(packageName);
        return fromTokens(tokens);
    }
493920
def split_package_name(p):
    """"""
    s = p.split(six.u('=='))
    if len(s) == 1:
        return (to_text(s[0]), None)
    else:
        return (to_text(s[0]), to_text(s[1]))
1021980
def name_from_setup_py(self):  # type: () -> str
        
        source = self.setup_py_source()
        if not source:
            return ""
        for row in source.split("\n"):
            #
            if "packages=" in row:
                simplified_row = row.replace(" ", "").replace("'", '"').strip(" \t\n")
                if '"' in simplified_row:
                    return simplified_row.split('"')[1]

            if "name=" in row:
                simplified_row = row.replace(" ", "").replace("'", '"').strip(" \t\n")
                if '"' in simplified_row:
                    return simplified_row.split('"')[1]
        return ""