예제 #1
0
	def buildWithLocalMapping(self):
		# TODO(jchaloup): read location of mappings from config file
		with open("%s/data/known_prefixes.json" % getScriptDir(__file__), "r") as f:
			regexs = json.load(f)

		with open("%s/data/native_packages.json" % getScriptDir(__file__), "r") as f:
			native = json.load(f)


		return ImportPathParser(regexs, native)
예제 #2
0
    def test(self):

        api1_path = "%s/testdata/api1.json" % getScriptDir(__file__)
        api2_path = "%s/testdata/api2.json" % getScriptDir(__file__)

        with open(api1_path, "r") as f:
            api1 = json.load(f)

        with open(api2_path, "r") as f:
            api2 = json.load(f)

        d = GoApiDiff(api1, api2).runDiff()

        # TODO(jchaloup): validate the api diff
        self.assertNotEqual(d.apiDiff(), {})
예제 #3
0
	def test(self):

		api1_path = "%s/testdata/api1.json" % getScriptDir(__file__)
		api2_path = "%s/testdata/api2.json" % getScriptDir(__file__)

		with open(api1_path, "r") as f:
			api1 = json.load(f)

		with open(api2_path, "r") as f:
			api2 = json.load(f)

		d = GoApiDiff(api1, api2).runDiff()

		# TODO(jchaloup): validate the api diff
		self.assertNotEqual(d.apiDiff(), {})
예제 #4
0
	def __init__(self):
		file_location = "%s/../fakedata/data.json" % getScriptDir(__file__)
		self._data = {}
		with open(file_location, "r") as f:
			data = json.load(f)

		for build in data["builds"]:
			self._data[ build["name"] ] = build
예제 #5
0
    def __init__(self):
        file_location = "%s/../fakedata/data.json" % getScriptDir(__file__)
        self._data = {}
        with open(file_location, "r") as f:
            data = json.load(f)

        for build in data["builds"]:
            self._data[build["name"]] = build
예제 #6
0
    def test(self):

        source_code_directory = "%s/testdata/example" % getScriptDir(__file__)

        e = GoSymbolsExtractor(source_code_directory).extract()

        # TODO(jchaloup): validate the schema
        self.assertNotEquals(e.packages(), {"main": [], "tests": [], "dependencies": [], "packages": []})
        self.assertNotEquals(e.exportedApi(), [])
예제 #7
0
	def buildUpstreamWithLocalMapping(self):
		mapping_file = os.path.join(getScriptDir(__file__), "data/ip2pp_mapping.json")

		with open(mapping_file, "r") as f:
			ip2pp = json.load(f)

		p = UpstreamProvider(ip2pp)

		return p
예제 #8
0
파일: logger.py 프로젝트: gofed/lib
	def set(verbose=False):
		if "GOFED_DEVEL" in os.environ:
			config_file = "%s/logging.yaml" % getScriptDir(__file__)
		else:
			config_file = LibConfig().loggingConfigFile()

		log_config = yaml.load(open(config_file, 'r'))
		if verbose:
			log_config["handlers"]["consoleHandler"]["level"] = "INFO"
		logging.config.dictConfig(log_config)
예제 #9
0
    def set(verbose=False):
        if LibConfig().loggingConfigFile() is not None:
            config_file = LibConfig().loggingConfigFile()
        else:
            config_file = "%s/logging.yaml" % getScriptDir(__file__)

        log_config = yaml.load(open(config_file, 'r'))
        if verbose:
            log_config["handlers"]["consoleHandler"]["level"] = "INFO"
        logging.config.dictConfig(log_config)
예제 #10
0
    def buildUpstreamWithLocalMapping(self):
        mapping_file = os.path.join(getScriptDir(__file__),
                                    "data/ip2pp_mapping.json")

        with open(mapping_file, "r") as f:
            ip2pp = json.load(f)

        p = UpstreamProvider(ip2pp)

        return p
예제 #11
0
파일: extractor.py 프로젝트: gofed/lib
	def _getGoSymbols(self, path, imports_only=False):
		script_dir = getScriptDir(__file__) + "/."
		options = ""
		if imports_only:
			options = "-imports"

		so, se, rc = runCommand("%s/parseGo %s '%s'" % (script_dir, options, path))
		if rc != 0:
			return (1, se)

		return (0, so)
예제 #12
0
    def _getGoSymbols(self, path, imports_only=False):
        script_dir = getScriptDir(__file__) + "/."
        options = ""
        if imports_only:
            options = "-imports"

        so, se, rc = runCommand("%s/parseGo %s '%s'" %
                                (script_dir, options, path))
        if rc != 0:
            return (1, se)

        return (0, so)
예제 #13
0
    def test(self):

        source_code_directory = "%s/testdata/example" % getScriptDir(__file__)

        e = GoSymbolsExtractor(source_code_directory).extract()

        # TODO(jchaloup): validate the schema
        self.assertNotEquals(e.packages(), {
            'main': [],
            'tests': [],
            'dependencies': [],
            'packages': []
        })
        self.assertNotEquals(e.exportedApi(), [])
예제 #14
0
	def getPackages(self, distribution = "rawhide"):
		"""
		:param distribution: package distribution
		:type  distribution: string
		:returns: [string]
		:raises KeyError: if distribution not found
		"""
		if self._packages == {}:
			file_location = "%s/data/distribution_packages.json" % getScriptDir(__file__)
			with open(file_location, "r") as f:
				packages = json.load(f)
			for pkg in packages:
				for distro in pkg["distributions"]:
					try:
						self._packages[distro].append(pkg["package"])
					except KeyError:
						self._packages[distro] = [pkg["package"]]

		return self._packages[distribution]
예제 #15
0
    def getPackages(self, distribution="rawhide"):
        """
		:param distribution: package distribution
		:type  distribution: string
		:returns: [string]
		:raises KeyError: if distribution not found
		"""
        if self._packages == {}:
            file_location = "%s/data/distribution_packages.json" % getScriptDir(
                __file__)
            with open(file_location, "r") as f:
                packages = json.load(f)
            for pkg in packages:
                for distro in pkg["distributions"]:
                    try:
                        self._packages[distro].append(pkg["package"])
                    except KeyError:
                        self._packages[distro] = [pkg["package"]]

        return self._packages[distribution]
예제 #16
0
	def test(self):

		paths = [{
			"path": "github.com/coreos/etcd/pkg/netutil",
			"prefix": "github.com/coreos/etcd",
			"package": "pkg/netutil",
			"native": False
		},{
			"path": "github.com/coreos/etcd/pkg/types",
			"prefix": "github.com/coreos/etcd",
			"package": "pkg/types",
			"native": False
		},{
			"path": "github.com/coreos/go-systemd/daemon",
			"prefix": "github.com/coreos/go-systemd",
			"package": "daemon",
			"native": False
		},{
			"path": "github.com/xiang90/probing",
			"prefix": "github.com/xiang90/probing",
			"package": "",
			"native": False
		},{
			"path": "golang.org/x/crypto/bcrypt",
			"prefix": "golang.org/x/crypto",
			"package": "bcrypt",
			"native": False
		},{
			"path": "golang.org/x/net/context",
			"prefix": "golang.org/x/net",
			"package": "context",
			"native": False
		},{
			"path": "google.golang.org/grpc",
			"prefix": "google.golang.org/grpc",
			"package": "",
			"native": False
		},{
			"path": "google.golang.org/grpc/credentials",
			"prefix": "google.golang.org/grpc",
			"package": "credentials",
			"native": False
		},{
			"path": "code.google.com/p/goauth2/compute/serviceaccount",
			"prefix": "code.google.com/p/goauth2",
			"package": "compute/serviceaccount",
			"native": False
		},{
			"path": "code.google.com/p/google-api-go-client/googleapi",
			"prefix": "code.google.com/p/google-api-go-client",
			"package": "googleapi",
			"native": False
		},{
			"path": "bitbucket.org/kardianos/osext",
			"prefix": "bitbucket.org/kardianos/osext",
			"package": "",
			"native": False
		},{
			"path": "gopkg.in/gcfg.v1/scanner",
			"prefix": "gopkg.in/gcfg.v1",
			"package": "scanner",
			"native": False
		},{
			"path": "gopkg.in/v1/gcfg/scanner",
			"prefix": "gopkg.in/v1/gcfg",
			"package": "scanner",
			"native": False
		},{
			"path": "gopkg.in/fsnotify.v0",
			"prefix": "gopkg.in/fsnotify.v0",
			"package": "",
			"native": False
		},{
			"path": "bazil.org/fuse/aaa",
			"prefix": "bazil.org/fuse",
			"package": "aaa",
			"native": False
		},{
			"path": "camlistore.org/aaa",
			"prefix": "camlistore.org",
			"package": "aaa",
			"native": False
		},{
			"path": "collectd.org/aaa",
			"prefix": "collectd.org",
			"package": "aaa",
			"native": False
		},{
			"path": "gopkg.in/fatih/pool.v2/aaa",
			"prefix": "gopkg.in/fatih/pool.v2",
			"package": "aaa",
			"native": False
		},{
			"path": "gopkg.in/olivere/elastic.v2/aaa",
			"prefix": "gopkg.in/olivere/elastic.v2",
			"package": "aaa",
			"native": False
		},{
			"path": "k8s.io/heapster/aaa",
			"prefix": "k8s.io/heapster",
			"package": "aaa",
			"native": False
		},{
			"path": "k8s.io/kubernetes/aaa",
			"prefix": "k8s.io/kubernetes",
			"package": "aaa",
			"native": False
		},{
			"path": "gopkg.in/natefinch/lumberjack.v1/aaa",
			"prefix": "gopkg.in/natefinch/lumberjack.v1",
			"package": "aaa",
			"native": False
		},{
			"path": "launchpad.net/gocheck/check",
			"prefix": "launchpad.net/gocheck",
			"package": "check",
			"native": False
		},{
			"path": "speter.net/go/exp/math/dec/inf/aaa",
			"prefix": "speter.net/go/exp/math/dec/inf",
			"package": "aaa",
			"native": False
		}]

		script_dir = getScriptDir(__file__)
		prefixes_file = os.path.join(script_dir, "data/known_prefixes.json")
		packages_file = os.path.join(script_dir, "data/native_packages.json")

		with open(prefixes_file, "r") as f:
			regexs = json.load(f)

		with open(packages_file, "r") as f:
			native = json.load(f)

		p = ImportPathParser(regexs, native)

		for path in paths:
			p.parse(path["path"])
			self.assertEqual(path["native"], p.isNative())
			if not path["native"]:
				self.assertEqual(path["prefix"], p.prefix())
				self.assertEqual(path["package"], p.package())
예제 #17
0
	def __init__(self):
		fakedata = "%s/../fakedata/data.json" % getScriptDir(__file__)
		with open(fakedata, "r") as f:
			self._data = json.load(f)
예제 #18
0
    def test(self):

        paths = [{
            "path": "github.com/coreos/etcd/pkg/netutil",
            "prefix": "github.com/coreos/etcd",
            "package": "pkg/netutil",
            "native": False
        }, {
            "path": "github.com/coreos/etcd/pkg/types",
            "prefix": "github.com/coreos/etcd",
            "package": "pkg/types",
            "native": False
        }, {
            "path": "github.com/coreos/go-systemd/daemon",
            "prefix": "github.com/coreos/go-systemd",
            "package": "daemon",
            "native": False
        }, {
            "path": "github.com/xiang90/probing",
            "prefix": "github.com/xiang90/probing",
            "package": "",
            "native": False
        }, {
            "path": "golang.org/x/crypto/bcrypt",
            "prefix": "golang.org/x/crypto",
            "package": "bcrypt",
            "native": False
        }, {
            "path": "golang.org/x/net/context",
            "prefix": "golang.org/x/net",
            "package": "context",
            "native": False
        }, {
            "path": "google.golang.org/grpc",
            "prefix": "google.golang.org/grpc",
            "package": "",
            "native": False
        }, {
            "path": "google.golang.org/grpc/credentials",
            "prefix": "google.golang.org/grpc",
            "package": "credentials",
            "native": False
        }, {
            "path": "code.google.com/p/goauth2/compute/serviceaccount",
            "prefix": "code.google.com/p/goauth2",
            "package": "compute/serviceaccount",
            "native": False
        }, {
            "path": "code.google.com/p/google-api-go-client/googleapi",
            "prefix": "code.google.com/p/google-api-go-client",
            "package": "googleapi",
            "native": False
        }, {
            "path": "bitbucket.org/kardianos/osext",
            "prefix": "bitbucket.org/kardianos/osext",
            "package": "",
            "native": False
        }, {
            "path": "gopkg.in/gcfg.v1/scanner",
            "prefix": "gopkg.in/gcfg.v1",
            "package": "scanner",
            "native": False
        }, {
            "path": "gopkg.in/v1/gcfg/scanner",
            "prefix": "gopkg.in/v1/gcfg",
            "package": "scanner",
            "native": False
        }, {
            "path": "gopkg.in/fsnotify.v0",
            "prefix": "gopkg.in/fsnotify.v0",
            "package": "",
            "native": False
        }, {
            "path": "bazil.org/fuse/aaa",
            "prefix": "bazil.org/fuse",
            "package": "aaa",
            "native": False
        }, {
            "path": "camlistore.org/aaa",
            "prefix": "camlistore.org",
            "package": "aaa",
            "native": False
        }, {
            "path": "collectd.org/aaa",
            "prefix": "collectd.org",
            "package": "aaa",
            "native": False
        }, {
            "path": "gopkg.in/fatih/pool.v2/aaa",
            "prefix": "gopkg.in/fatih/pool.v2",
            "package": "aaa",
            "native": False
        }, {
            "path": "gopkg.in/olivere/elastic.v2/aaa",
            "prefix": "gopkg.in/olivere/elastic.v2",
            "package": "aaa",
            "native": False
        }, {
            "path": "k8s.io/heapster/aaa",
            "prefix": "k8s.io/heapster",
            "package": "aaa",
            "native": False
        }, {
            "path": "k8s.io/kubernetes/aaa",
            "prefix": "k8s.io/kubernetes",
            "package": "aaa",
            "native": False
        }, {
            "path": "gopkg.in/natefinch/lumberjack.v1/aaa",
            "prefix": "gopkg.in/natefinch/lumberjack.v1",
            "package": "aaa",
            "native": False
        }, {
            "path": "launchpad.net/gocheck/check",
            "prefix": "launchpad.net/gocheck",
            "package": "check",
            "native": False
        }, {
            "path": "speter.net/go/exp/math/dec/inf/aaa",
            "prefix": "speter.net/go/exp/math/dec/inf",
            "package": "aaa",
            "native": False
        }]

        script_dir = getScriptDir(__file__)
        prefixes_file = os.path.join(script_dir, "data/known_prefixes.json")
        packages_file = os.path.join(script_dir, "data/native_packages.json")

        with open(prefixes_file, "r") as f:
            regexs = json.load(f)

        with open(packages_file, "r") as f:
            native = json.load(f)

        p = ImportPathParser(regexs, native)

        for path in paths:
            p.parse(path["path"])
            self.assertEqual(path["native"], p.isNative())
            if not path["native"]:
                self.assertEqual(path["prefix"], p.prefix())
                self.assertEqual(path["package"], p.package())
	def buildWithLocalMapping(self):

		with open("%s/data/ip2package_mapping.json" % getScriptDir(__file__), "r") as f:
			mapping = json.load(f)

		return PackageNameGenerator(mapping)
예제 #20
0
 def __init__(self):
     fakedata = "%s/../fakedata/data.json" % getScriptDir(__file__)
     with open(fakedata, "r") as f:
         self._data = json.load(f)