How to use the yappi.yappi.YappiError function in yappi

To help you get started, we’ve selected a few yappi 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 sumerc / yappi / yappi / yappi.py View on Github external
def _validate_columns(name, list):
    name = name.lower()
    if name not in list:
        raise YappiError("Invalid Column name: '%s'" % (name))
github sumerc / yappi / yappi / yappi.py View on Github external
def _add_from_YSTAT(self, file):
        try:
            saved_stats, saved_clock_type = pickle.load(file)
        except:
            raise YappiError(
                "Unable to load the saved profile information from %s." %
                (file.name)
            )

        # check if we really have some stats to be merged?
        if not self.empty():
            if self._clock_type != saved_clock_type and self._clock_type is not None:
                raise YappiError("Clock type mismatch between current and saved profiler sessions.[%s,%s]" % \
                    (self._clock_type, saved_clock_type))

        self._clock_type = saved_clock_type

        # add 'not present' previous entries with unique indexes
        for saved_stat in saved_stats:
            if saved_stat not in self:
                self._idx_max += 1
github sumerc / yappi / yappi / yappi.py View on Github external
)

    if not len(modules):
        raise YappiError("Argument 'modules' cannot be empty.")

    if not isinstance(modules, list):
        raise YappiError(
            "Argument 'modules' is not a list object. (%s)" % (modules)
        )
    if stat.full_name not in _fn_descriptor_dict:
        return False

    modules = set(modules)
    for module in modules:
        if not isinstance(module, types.ModuleType):
            raise YappiError("Non-module item in 'modules'. (%s)" % (module))
    return inspect.getmodule(_fn_descriptor_dict[stat.full_name]) in modules
github sumerc / yappi / yappi / yappi.py View on Github external
def _validate_sorttype(sort_type, list):
    sort_type = sort_type.lower()
    if sort_type not in list:
        raise YappiError("Invalid SortType parameter: '%s'" % (sort_type))
    return sort_type
github sumerc / yappi / yappi / yappi.py View on Github external
def convert2pstats(stats):
    from collections import defaultdict
    """
    Converts the internal stat type of yappi(which is returned by a call to YFuncStats.get())
    as pstats object.
    """
    if not isinstance(stats, YFuncStats):
        raise YappiError("Source stats must be derived from YFuncStats.")

    import pstats

    class _PStatHolder:

        def __init__(self, d):
            self.stats = d

        def create_stats(self):
            pass

    def pstat_id(fs):
        return (fs.module, fs.lineno, fs.name)

    _pdict = {}
github sumerc / yappi / yappi / yappi.py View on Github external
def module_matches(stat, modules):

    if not isinstance(stat, YStat):
        raise YappiError(
            "Argument 'stat' shall be a YStat object. (%s)" % (stat)
        )

    if not len(modules):
        raise YappiError("Argument 'modules' cannot be empty.")

    if not isinstance(modules, list):
        raise YappiError(
            "Argument 'modules' is not a list object. (%s)" % (modules)
        )
    if stat.full_name not in _fn_descriptor_dict:
        return False

    modules = set(modules)
    for module in modules:
        if not isinstance(module, types.ModuleType):
            raise YappiError("Non-module item in 'modules'. (%s)" % (module))
    return inspect.getmodule(_fn_descriptor_dict[stat.full_name]) in modules