Logo Search packages:      
Sourcecode: mago version File versions  Download package

def mago::cmd::discovery::ApplicationData::discover (   cls,
  base_dirpaths 
)

Generator that discovers all applications under
a list of top directories

Definition at line 57 of file discovery.py.

00057                                     :
        """
        Generator that discovers all applications under
        a list of top directories
        """
        discovered_applications = []
        for base_dirpath in base_dirpaths:
            dirpaths = [os.path.join(base_dirpath, d)
                        for d in os.listdir(base_dirpath)
                        if os.path.isdir(os.path.join(base_dirpath, d))]

            for dirpath in dirpaths:
                try:
                    filenames = [f
                                 for f in os.listdir(dirpath)
                                 if os.path.isfile(os.path.join(dirpath, f))]
                except OSError:
                    continue # Permission denied.

                # Application directories are expected to honor
                # the specified name pattern
                app = cls(dirpath, filenames)
                if not app.name_matches():
                    logging.debug("Application name %s does not match pattern: %s"
                                  % (app.name, app.name_pattern))
                    continue

                # This check makes sure that the same application
                # isn't discovered twice. That is to say, when discovering
                # applications from multiple directories, the test cases 
                # from the application that is first found will be
                # executed while the others will be discarded
                if app in discovered_applications:
                    logging.debug("Application name %s has been already discovered"
                                  % app.name)
                    continue

                # Return application only if there is no whitelist
                # or if it matches any of the whitelist names
                if cls.whitelist and not app.name in cls.whitelist:
                    logging.debug("Application name %s has not been whitelisted"
                                  % app.name)
                    continue

                # At least one '.xml' file with a 'suite' root tag
                # should be contained in the directory to be a valid application directory
                if not any(app.suites()):
                    logging.debug("Application directory %s does't seem to contain a valid suite file"
                                  % app.path)
                    continue

                discovered_applications.append(app)
                yield app


class XmlData:


Generated by  Doxygen 1.6.0   Back to index