Return true if the given package name has been printed.  Also
return true if the root of this package has been printed.

@param pkgname the name of the package to check.
336528
private boolean hasPrintedPackageIndex(PackageElement pkg) {
        for (PackageElement printedPkg : printedPackageHeaders) {
            if (utils.getPackageName(pkg).startsWith(utils.parsePackageName(printedPkg))) {
                return true;
            }
        }
        return false;
    }
415264
protected final PrintWriter getPrintWriter( String packageName, String className ) {
        return context.tryCreate( logger, packageName, className );
    }
608002
public static boolean isAppInstalled(final Context context, final String packageName){
        try {
            context.getPackageManager().getPackageInfo(packageName, 0);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
548438
private boolean hasConstantField(PackageDoc pkg) {
        ClassDoc[] classes;
        if (pkg.name().length() > 0) {
            classes = pkg.allClasses();
        } else {
            classes = configuration.classDocCatalog.allClasses(
                DocletConstants.DEFAULT_PACKAGE_NAME);
        }
        boolean found = false;
        for (int j = 0; j < classes.length; j++){
            if (classes[j].isIncluded() && hasConstantField(classes[j])) {
                found = true;
            }
        }
        return found;
    }
152937
private static boolean hasAnnotation(String pkgInfo, String annotation) {
    if (!annotation.contains(".")) {
      ErrorUtil.warning(annotation + " is not a fully qualified name");
    }
    if (pkgInfo.contains("@" + annotation)) {
      return true;
    }
    int idx = annotation.lastIndexOf(".");
    String annotationPackageName = annotation.substring(0, idx);
    String annotationSimpleName = annotation.substring(idx + 1);
    if (pkgInfo.contains("@" + annotationSimpleName)) {
      String importRegex =
          "import\\s*" + annotationPackageName + "(\\.\\*|\\." + annotationSimpleName + ")";
      Pattern p = Pattern.compile(importRegex);
      Matcher m = p.matcher(pkgInfo);
      if (m.find()) {
        return true;
      }
    }
    return false;
  }
898793
public static boolean isPackageInstalled(Context context, String packageName) {
		try {
			context.getPackageManager().getApplicationInfo(packageName, 0);
			return true;
		} catch (Exception e) {
			return false;
		}
	}
181493
private boolean inSamePackage(Class<?> c1, Class<?> c2) {
        String nameC1 = c1.getName();
        String nameC2 = c2.getName();
        int indexDotC1 = nameC1.lastIndexOf('.');
        int indexDotC2 = nameC2.lastIndexOf('.');
        if (indexDotC1 != indexDotC2) {
            return false; // cannot be in the same package if indices are not the same
        }
        if (indexDotC1 == -1) {
            return true; // both of them are in default package
        }
        return nameC1.regionMatches(0, nameC2, 0, indexDotC1);
    }
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
14802
protected boolean isApplicationClass(String className) {
        for (String packageName : packagesToFilter) {
            if (className.startsWith(packageName)) return false;
        }
        return true;
    }
338888
public static String toValidPackageName(String pkg)
   {
      if (pkg == null)
      {
         throw new IllegalArgumentException("Package should not be null");
      }
      // Sanitizing package name
      StringBuilder sb = new StringBuilder(pkg.length());
      for (int i = 0; i < pkg.length(); i++)
      {
         char c = pkg.charAt(i);
         // remove dots from the beginning and the end of the package
         if (c == '.' && (i == 0 || i == pkg.length() - 1))
         {
            continue;
         }
         if (c == '.' || Character.isJavaIdentifierPart(c))
         {
            sb.append(c);
         }
      }
      String packageName = sb.toString();
      StringBuilder result = new StringBuilder();
      String[] tokens = packageName.split("[.]");
      for (String token : tokens)
      {
         if (result.length() > 0 && result.charAt(result.length() - 1) != '.')
         {
            result.append('.');
         }
         if (JLSValidator.isReservedWord(token))
         {
            result.append(token).append('_');
         }
         else if (isNumber(token))
         {
            // skip tokens as numbers and remove the appended '.' if exist
            if (result.length() > 0)
               result.deleteCharAt(result.length() - 1);
         }
         else
         {
            result.append(token);
         }
      }
      return result.toString();
   }
578132
def is_empty(self):
        
        for family in self.iter_package_families():
            for pkg in self.iter_packages(family):
                return False

        return True
320428
public boolean remove(String classname) {
    String		pkgname;
    HashSet<String>	names;

    classname = ClassPathTraversal.cleanUp(classname);
    pkgname   = ClassPathTraversal.extractPackage(classname);
    names     = m_NameCache.get(pkgname);
    if (names != null)
      return names.remove(classname);
    else
      return false;
  }
405575
public void mkPackage(String pkgName, File dir) {
        try {
            File metaDir = new File(dir + "/.mdw");
            if (!metaDir.exists() && !metaDir.mkdirs())
                throw new IOException("Cannot create directory: " + metaDir.getAbsolutePath());
            File pkgFile = new File(metaDir + "/package.yaml");
            if (!pkgFile.exists()) {
                JSONObject pkgJson = new JSONObject();
                pkgJson.put("name", pkgName);
                pkgJson.put("version", "1.0.01");
                pkgJson.put("schemaVersion", "6.1");
                Files.write(Paths.get(pkgFile.getPath()), pkgJson.toString(2).getBytes());
            }
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
680484
public static boolean packageResults() {
        String packageResults = getProgramProperty(PACKAGE_RESULTS);
        if (packageResults == null) {
            return false;
        }
        if ("".equals(packageResults)) {
            return true;
        }
        return "true".equalsIgnoreCase(packageResults);
    }
1070618
private String parsePackageName(String pkgname) {
        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;
    }
1292175
def is_installed(self, pkgname):
        

        return any(d for d in self.get_distributions() if d.project_name == pkgname)
854169
public static boolean isPackageInstaller(@NotNull final Context context, final String packageName) {
        final PackageManager packageManager = context.getPackageManager();
        final String installerPackageName = packageManager.getInstallerPackageName(context.getPackageName());
        boolean isPackageInstaller = TextUtils.equals(installerPackageName, packageName);
        Logger.d("isPackageInstaller() is ", isPackageInstaller, " for ", packageName);
        return isPackageInstaller;
    }