def __init__(self, input_mods, config): '''Sets up a TopicContinuum for use.''' tracer.info("called") UsableFlag.__init__(self) self.__input_mods = input_mods self._config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats() tracer.debug("Finished.")
class TopicContinuumSet(UsableFlag): '''Class holding all the available TopicSetCollections of the past and possible the current.''' def __init__(self, input_mods, config): '''Sets up a TopicContinuum for use.''' tracer.info("called") UsableFlag.__init__(self) self.__input_mods = input_mods self._config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # Store objects with IDs also in the cache - so that they # can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats() tracer.debug("Finished.") def __init_continuum_set(self): '''Initialize the continuum: Check the configuration for the appropriate interval parameters and read in the TopicContinuum.''' tracer.debug("Called.") # Step through all the available topic sets. for ts_name, ts_config in iteritems(self._config.get_value("topics")): topic_cont = TopicContinuum(ts_name, self._config, ts_config, self.__object_cache, self.__input_mods) self.__continuum[ts_name] = topic_cont self._adapt_usablility(topic_cont) tracer.debug("Finished; count [%d]", len(self.__continuum)) def execute(self, executor, func_prefix): '''Execute the parts which are needed for TopicsContinuumSet.''' tracer.debug("Calling pre.") FuncCall.pcall(executor, func_prefix + 'topic_continuum_set_pre', self) tracer.debug("Calling sub.") for continuum in executor.topic_continuum_set_sort( self.__continuum.values()): continuum.execute(executor, func_prefix) tracer.debug("Calling Post") FuncCall.pcall(executor, func_prefix + 'topic_continuum_set_post', self) tracer.debug("Finished.") def get_continuum_dict(self): '''Returns the continuum.''' return self.__continuum
class TopicContinuumSet(UsableFlag): """Class holding all the available TopicSetCollections of the past and possible the current.""" def __init__(self, input_mods, config): """Sets up a TopicContinuum for use.""" tracer.info("called") UsableFlag.__init__(self) self.__input_mods = input_mods self._config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats() tracer.debug("Finished.") def __init_continuum_set(self): """Initialize the continuum: Check the configuration for the appropriate interval parameters and read in the TopicContinuum.""" tracer.debug("Called.") # Step through all the available topic sets. for ts_name, ts_config in self._config.get_value("topics").get_dict().iteritems(): topic_cont = TopicContinuum(ts_name, self._config, ts_config, self.__object_cache, self.__input_mods) self.__continuum[ts_name] = topic_cont self._adapt_usablility(topic_cont) tracer.debug("Finished; count [%d]" % len(self.__continuum)) def execute(self, executor, func_prefix): """Execute the parts which are needed for TopicsContinuumSet.""" tracer.debug("Calling pre.") FuncCall.pcall(executor, func_prefix + "topic_continuum_set_pre", self) tracer.debug("Calling sub.") for continuum in executor.topic_continuum_set_sort(self.__continuum.values()): continuum.execute(executor, func_prefix) tracer.debug("Calling Post") FuncCall.pcall(executor, func_prefix + "topic_continuum_set_post", self) tracer.debug("Finished.") def get_continuum_dict(self): """Returns the continuum.""" return self.__continuum
def get_vcs_id_with_type(self, commit, dir_type): '''Return the vcs id from the base directories of the given dir_type.''' tracer.debug("called: commit [%s] directory type [%s]" % (commit, dir_type)) result = [] for directory in self.__dirs[dir_type]: dir_split = directory.split("/") ltree = self.__get_tree(commit.tree, dir_split) result.append(ltree.hexsha) return ObjectCache.create_hashable(result)
def rmttest_positive_02(self): "TopicSet - valid" cfg = Cfg() cfg.set_value('hahaha.directory', 'tests/unit-test/topic-tests/testdata/topicset01') cfg.set_value('hahaha.name', 't01') cfg.set_value('topics.test-name01.output', {}) cfg.set_value('topic_root_node', 'RootNode') tvcs = TestVCS(cfg) tobjcache = ObjectCache() tinmod = TestInputModules() TopicSet(cfg, tvcs, "test-name01", tobjcache, tinmod)
def test_positive_03(self): "TopicSet - valid with empty requirement set" tioconfig = TxtIOConfig() cfg = Cfg() cfg.set_value('huhuhu.directory', 'tests/unit-test/topic-tests/testdata/topicset01') cfg.set_value('huhuhu.name', 't01') cfg.set_value('topics.test-name02.output', {}) cfg.set_value('topic_root_node', 'RootNode') tvcs = TestVCS(cfg) tobjcache = ObjectCache() tinmod = TestInputModules() topicset = TopicSet(cfg, tvcs, "test-name02", tobjcache, tinmod)
def main_impl(args, mstdout, mstderr): tracer.debug("Called.") config, mods = MainHelper.main_setup(args, mstdout, mstderr) file_system_if = FileSystem(config) object_cache = ObjectCache() rs = RequirementSet(config) command_line_args = config.get_rvalue('general.command_line_arguments') rs.read_requirements(file_system_if, None, mods, object_cache) return rs.normalize_dependencies() \ and rs.write_to_filesystem(command_line_args[0])
def __init__(self, input_mods, config): """Sets up a TopicContinuum for use.""" tracer.info("called") UsableFlag.__init__(self) self.__input_mods = input_mods self._config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats() tracer.debug("Finished.")
def rmttest_positive_01(self): "TopicSet - constructor with only one element" try: cfg = Cfg() cfg.set_value('ahah.directory', 'tests/unit-test/topic-tests/testdata/topicset01') cfg.set_value('ahah.name', 't01') cfg.set_value('topics.bkdkd.output', {}) cfg.set_value('topic_root_node', 'RootNode') tvcs = TestVCS(cfg) tobjcache = ObjectCache() tinmod = TestInputModules() TopicSet(cfg, tvcs, "bkdkd", tobjcache, tinmod) self.assertTrue(False) except AssertionError: pass
def main_func(args, mstdout, mstderr): """The 'real' main function. Sets up everything, reads in the requirements and writes out everything. """ tracer.debug("Called.") config, mods = MainHelper.main_setup(args, mstdout, mstderr) file_system_if = FileSystem(config) object_cache = ObjectCache() req_set = RequirementSet(config) command_line_args = config.get_rvalue('general.command_line_arguments') req_set.read_requirements(file_system_if, None, mods, object_cache) return req_set.normalize_dependencies() \ and req_set.write_to_filesystem(command_line_args[0])
def __init__(self, input_mods, config): '''Sets up a TopicContinuum for use.''' tracer.info("called") MemLogStore.__init__(self) self.__input_mods = input_mods self.__config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # The VCS repository. # If this is None - there is no repository available. self.__deprecated_repo = None # Because the construction / evaluation should continue even in # error cases, a flag is available to check if the (possible only # partially) constructed element is usable. self.__is_usable = True # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats()
def get_vcs_id_with_type(self, commit, dir_type): '''Return the filename of the given dir_type.''' assert commit == None tracer.debug("called: directory type [%s]" % dir_type) return ObjectCache.create_hashable(self.__dirs[dir_type])
class TopicContinuumSet(MemLogStore): '''Class holding all the available TopicSetCollections of the past and possible the current.''' def __init__(self, input_mods, config): '''Sets up a TopicContinuum for use.''' tracer.info("called") MemLogStore.__init__(self) self.__input_mods = input_mods self.__config = config # This dictionary holds all the TopicSetCollections # available in the configured time period. self.__continuum = {} # The VCS repository. # If this is None - there is no repository available. self.__deprecated_repo = None # Because the construction / evaluation should continue even in # error cases, a flag is available to check if the (possible only # partially) constructed element is usable. self.__is_usable = True # Store objects with IDs also in the cache - so that they can be reused. self.__object_cache = ObjectCache() self.__init_continuum_set() self.__object_cache.log_stats() def __init_continuum_set(self): '''Initialize the continuum: Check the configuration for the appropriate interval parameters and read in the TopicSetCollections.''' tracer.debug("called") # Step through all the available topic sets. for ts_name, ts_config in \ self.__config.get_value("topics").get_dict().iteritems(): self.__continuum[ts_name] = \ TopicContinuum(ts_name, self.__config, ts_config, self.__object_cache, self.__input_mods) assert False sources = self.config() versint = self.internal_get_interval() self.internal_check_repo(versint) self.internal_read_continuum(versint) def is_usable(self): '''Returns True iff the object is really usable, i.e. if there was no problem during construction.''' return self.__is_usable # Everything below in DEPRECATED def deprecated_internal_get_interval(self): '''Returns the configured interval [start, end].''' return [self.config.get_value('requirements.input.commit_interval.begin'), self.config.get_value('requirements.input.commit_interval.end')] def deprecated_internal_create_repo(self): '''This method sets up the repository and splits out the repository directory from the requirements directory. Sets up the repository variable with the repository object when a repository is available. In this case 'true' is returned. If there is no repository available, 'false' is returned.''' directory = self.config.get_value("requirements.input.directory") # When the directory is not absolute, convert it to an # absolute path that it can be compared to the outcome of the # git.Repo. if not os.path.isabs(directory): directory = os.path.abspath(directory) try: self.repo = VersionControlSystem.create(directory) return True except VCSException: # There is no VCS repository here - therefore nothing to do. pass return False def deprecated_internal_repo_access_needed(self, versint): '''Checks if depending on the given versions interval a repository is needed.''' # Only if FILES:FILES is specified, there is no need to access # the repository. return versint[0] != 'FILES' or versint[1] != 'FILES' def deprecated_internal_check_repo(self, versint): '''Checks if a repository is needed. If so, it checks whether a repository exists. If (in this case) no repository exists, an exception is thrown.''' # Should the repository be accessed? if self.internal_repo_access_needed(versint): # Have a look, if there is a repository in the given directory. if not self.internal_create_repo(): raise RMTException(40, "Based on the configuration a " "repository is needed - but there is " "none") def deprecated_internal_create_continuum_from_file(self): '''Reads in a TopicSetCollection from the file system.''' topic_set_collection = TopicSetCollection(self.config) req_input_dir = self.config.get_value('requirements.input.directory') topic_set_collection.read_from_filesystem(req_input_dir) self.internal_continuum_add("FILES", topic_set_collection) def deprecated_internal_create_continuum_from_vcs(self, start_vers, end_repo): '''Read in the continuum from the VCS.''' tsc_list = self.repo.read_history(start_vers, end_repo) # Copy over the result into the local (current) for tsc in tsc_list: self.internal_continuum_add(tsc[0], tsc[1]) def deprecated_internal_read_continuum(self, versint): '''Read in the continuum from the VCS and / or file system.''' start_vers, end_vers = versint # Maybe add also the FILES: if end_vers == "FILES": self.internal_create_continuum_from_file() # Maybe add also some old versions if start_vers != "FILES": # When there is FILES given as last parameter - get # everything from start_vers upto HEAD end_repo = end_vers if end_vers == "FILES": end_repo = "HEAD" self.internal_create_continuum_from_vcs(start_vers, end_repo)