Exemplo n.º 1
0
    def retrieve(self, directory, skip_errors=False):
        """
		Retrieve information about project from directory
		"""
        # directory exists?
        if not path.exists(directory):
            self.err = "Directory %s does not exist" % directory
            return False

        parser_config = ParserConfig()
        if skip_errors:
            parser_config.setSkipErrors()
        parser_config.setNoGodeps(self.noGodeps)
        parser_config.setParsePath(directory)

        gse_obj = GoSymbolsExtractor(parser_config)
        if not gse_obj.extract():
            self.err = gse_obj.getError()
            return False

        self.godeps_on = gse_obj.godepsDirectoryExists()
        ip_used = gse_obj.getImportedPackages()
        self.package_imports_occurence = gse_obj.getPackageImportsOccurences()
        packages = gse_obj.getSymbolsPosition()
        tests = gse_obj.getTestDirectories()

        ips_imported = []
        ips_provided = []

        # imported paths
        ipd = ImportPathsDecomposer(ip_used)
        if not ipd.decompose():
            self.err = ipd.getError()
            return False

        self.warn = ipd.getWarning()

        classes = ipd.getClasses()
        sorted_classes = sorted(classes.keys())

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

            for ip in classes[ip_class]:
                self.imported_packages.append(ip)

                # provided paths
        for pkg in packages:
            self.provided_packages.append(packages[pkg])

            # project documentation
        self.docs = self._getDocFiles(directory)

        self.imported_packages = sorted(self.imported_packages)
        self.provided_packages = sorted(self.provided_packages)
        self.test_directories = sorted(tests)

        return True
Exemplo n.º 2
0
    def retrieve(self, directory, skip_errors=False):
        """
		Retrieve information about project from directory
		"""
        # directory exists?
        if not path.exists(directory):
            self.err = "Directory %s does not exist" % directory
            return False

        gse_obj = GoSymbolsExtractor(directory,
                                     skip_errors=skip_errors,
                                     noGodeps=self.noGodeps)
        if not gse_obj.extract():
            self.err = gse_obj.getError()
            return False

        self.godeps_on = gse_obj.godepsDirectoryExists()
        ip_used = gse_obj.getImportedPackages()
        self.package_imports_occurence = gse_obj.getPackageImportsOccurences()
        packages = gse_obj.getSymbolsPosition()
        tests = gse_obj.getTestDirectories()

        ips_imported = []
        ips_provided = []

        # imported paths
        ipd = ImportPathsDecomposer(ip_used)
        if not ipd.decompose():
            self.err = ipd.getError()
            return False

        self.warn = ipd.getWarning()

        classes = ipd.getClasses()
        sorted_classes = sorted(classes.keys())

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

            for ip in classes[ip_class]:
                self.imported_packages.append(ip)

        # provided paths
        for pkg in packages:
            self.provided_packages.append(packages[pkg])

        # project documentation
        self.docs = self._getDocFiles(directory)

        self.imported_packages = sorted(self.imported_packages)
        self.provided_packages = sorted(self.provided_packages)
        self.test_directories = sorted(tests)

        return True
Exemplo n.º 3
0
		fmt_obj.printError(gse_obj.getError())
		exit(1)

	package_imports_occurence = gse_obj.getPackageImportsOccurences()

	ip_used = gse_obj.getImportedPackages()
	ipd = ImportPathsDecomposer(ip_used)
	if not ipd.decompose():
		fmt_obj.printError(ipd.getError())
		exit(1)

	warn = ipd.getWarning()
	if warn != "":
		fmt_obj.printWarning("Warning: %s" % warn)

	classes = ipd.getClasses()
	sorted_classes = sorted(classes.keys())

	# get max length of all imports
	max_len = 0
	for element in sorted_classes:
		if element == "Native":
			continue

		# class name starts with prefix => filter out
		if options.importpath != "" and element.startswith(options.importpath):
			continue

		gimports = []
		for gimport in classes[element]:
			if options.importpath != "" and gimport.startswith(options.importpath):
Exemplo n.º 4
0
	if prj_info == None:
		fmt_obj.printErr("Unable to bump spec file: %s" % se)
		exit(1)

	ip_used = prj_info.getImportedPackages()

	ipd = ImportPathsDecomposer(ip_used)
	if not ipd.decompose():
		fmt_obj.printErr(ipd.getError())
		exit(1)

	warn = ipd.getWarning()
	if warn != "":
		fmt_obj.printWarning(warn)

	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():