How to use the pyroma.projectdata function in pyroma

To help you get started, we’ve selected a few pyroma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github regebro / pyroma / pyroma / tests.py View on Github external
def _get_file_rating(self, dirname):
        directory = resource_filename(__name__, os.path.join("testdata", dirname))
        data = projectdata.get_data(directory)
        return rate(data)
github jayclassless / tidypy / src / tidypy / tools / pyroma.py View on Github external
def execute(self, finder):
        issues = []

        for filepath in finder.files(self.config['filters']):
            dirname, _ = os.path.split(filepath)

            with warnings.catch_warnings():
                warnings.simplefilter('ignore')
                with SysOutCapture() as capture:
                    try:
                        data = projectdata.get_data(dirname)
                    except RuntimeError:
                        err = capture.get_stderr()
                        if err:
                            issues.append(PyromaIssue(
                                TIDYPY_ISSUES['SCRIPT_FAIL'][0],
                                TIDYPY_ISSUES['SCRIPT_FAIL'][1] % (err,),
                                filepath,
                            ))
                        else:
                            issues.append(PyromaIssue(
                                TIDYPY_ISSUES['NOT_CALLED'][0],
                                TIDYPY_ISSUES['NOT_CALLED'][1],
                                filepath,
                            ))
                        continue
github PyCQA / prospector / prospector / tools / pyroma / __init__.py View on Github external
def run(self, found_files):
        messages = []
        for module in found_files.iter_module_paths(include_ignored=True):
            dirname, filename = os.path.split(module)
            if filename != 'setup.py':
                continue

            data = projectdata.get_data(dirname)

            all_tests = [m() for m in PYROMA_TEST_CLASSES]
            for test in all_tests:
                code = PYROMA_CODES[test.__class__]

                if code in self.ignore_codes:
                    continue

                passed = test.test(data)
                if passed is False:  # passed can be True, False or None...
                    loc = Location(module, 'setup', None, -1, -1)
                    msg = Message('pyroma', code, loc, test.message())
                    messages.append(msg)

        return messages
github regebro / pyroma / pyroma / distributiondata.py View on Github external
basename, ignored = os.path.splitext(basename)

    try:
        tempdir = tempfile.mkdtemp()

        if ext in (".bz2", ".tbz", "tb2", ".gz", ".tgz", ".tar"):
            tarfile.open(name=path, mode="r:*").extractall(tempdir)

        elif ext in (".zip", ".egg"):
            zipfile.ZipFile(path, mode="r").extractall(tempdir)

        else:
            raise ValueError("Unknown file type: " + ext)

        projectpath = os.path.join(tempdir, basename)
        data = projectdata.get_data(projectpath)

    finally:
        shutil.rmtree(tempdir)

    return data
github regebro / pyroma / pyroma / __init__.py View on Github external
def run(mode, argument):

    logging.info("-" * 30)
    logging.info("Checking " + argument)

    if mode == "directory":
        data = projectdata.get_data(os.path.abspath(argument))
        logging.info("Found " + data.get("name", "nothing"))
    elif mode == "file":
        data = distributiondata.get_data(os.path.abspath(argument))
        logging.info("Found " + data.get("name", "nothing"))
    else:
        # It's probably a package name
        data = pypidata.get_data(argument)
        logging.info("Found " + data.get("name", "nothing"))

    rating = ratings.rate(data)

    logging.info("-" * 30)
    for problem in rating[1]:
        # XXX It would be nice with a * pointlist instead, but that requires
        # that we know how wide the terminal is and nice word-breaks, so that's
        # for later.