예제 #1
0
파일: ggi.py 프로젝트: nullr0ute/gofed
			if options.all and element == "Native":
				# does not make sense to check Native class in PkgDB
				if options.pkgdb:
					continue
				print "Class: %s" % element
				if not options.short:
					for gimport in gimports:
						if options.showoccurrence:
							print "\t%s (%s)" % (gimport, ", ".join(package_imports_occurence[gimport]))
						else:
							print "\t%s" % gimport
				continue

			# Translate non-native class into package name (if -d option)
			if options.pkgdb:
				ip_obj = ImportPath(element)
				if not ip_obj.parse():
					fmt_obj.printWarning("Unable to translate %s to package name" % element)
					continue

				pkg_name = ip_obj.getPackageName()
				if pkg_name == "":
					fmt_obj.printWarning(ip_obj.getError())

				pkg_in_pkgdb = packageInPkgdb(pkg_name)
				if pkg_in_pkgdb:
					if options.verbose:
						print (GREEN + "Class: %s (%s) PkgDB=%s" + ENDC) % (element, pkg_name, pkg_in_pkgdb)
				else:
					print (RED + "Class: %s (%s) PkgDB=%s" + ENDC ) % (element, pkg_name, pkg_in_pkgdb)
				continue
예제 #2
0
                        if options.showoccurrence:
                            if options.showmain:
                                main_occ = show_main(
                                    package_imports_occurence[gimport])
                                if main_occ != "":
                                    print "\t%s %s" % (gimport, main_occ)
                            else:
                                print "\t%s (%s)" % (gimport, ", ".join(
                                    package_imports_occurence[gimport]))
                        else:
                            print "\t%s" % gimport
                continue

            # Translate non-native class into package name (if -d option)
            if options.pkgdb:
                ip_obj = ImportPath(element)
                if not ip_obj.parse():
                    fmt_obj.printWarning(
                        "Unable to translate %s to package name" % element)
                    continue

                pkg_name = ip_obj.getPackageName()
                if pkg_name == "":
                    fmt_obj.printWarning(ip_obj.getError())

                pkg_in_pkgdb = packageInPkgdb(pkg_name)
                if pkg_in_pkgdb:
                    if options.verbose:
                        print(GREEN + "Class: %s (%s) PkgDB=%s" +
                              ENDC) % (element, pkg_name, pkg_in_pkgdb)
                else:
예제 #3
0
	classes = ipd.getClasses()
	sorted_classes = sorted(classes.keys())

	for element in sorted_classes:
		if element == "Native":
			continue

		if element == "Unknown":
			fmt_obj.printWarning("Some import paths were not detected. Please run gofed ggi -c on extracted tarball manually")
			continue

		if element.startswith(url):
			continue

		ip_obj = ImportPath(element)
		if not ip_obj.parse():
			fmt_obj.printWarning("Unable to translate %s to package name" % element)
			continue

		pkg_name = ip_obj.getPackageName()
		pkg_in_pkgdb = False

		if pkg_name != "":
			pkg_in_pkgdb = packageInPkgdb(pkg_name)
			if pkg_in_pkgdb:
				print (GREEN + "Class: %s (%s) PkgDB=%s" + ENDC) % (element, pkg_name, pkg_in_pkgdb)
			else:
				print (RED + "Class: %s (%s) PkgDB=%s" + ENDC ) % (element, pkg_name, pkg_in_pkgdb)

예제 #4
0
			# does it occur only in main package?
			# remove it from classes[element]
			if len(package_imports_occurence[gimport]) == 1 and package_imports_occurence[gimport][0].endswith(":main"):
				continue

			one_class.append(gimport)

		if one_class == []:
			continue

		classes[element] = sorted(one_class)

		if element.startswith(url):
			continue

		ip_obj = ImportPath(element)
		if not ip_obj.parse():
			fmt_obj.printWarning("Unable to translate %s to package name" % element)
			continue

		pkg_name = ip_obj.getPackageName()
		pkg_in_pkgdb = False

		if pkg_name != "":
			pkg_in_pkgdb = packageInPkgdb(pkg_name)
			if pkg_in_pkgdb:
				print (GREEN + "Class: %s (%s) PkgDB=%s" + ENDC) % (element, pkg_name, pkg_in_pkgdb)
			else:
				print (RED + "Class: %s (%s) PkgDB=%s" + ENDC ) % (element, pkg_name, pkg_in_pkgdb)