当前位置: 首页>>代码示例>>Python>>正文


Python inspect.getabsfile方法代码示例

本文整理汇总了Python中inspect.getabsfile方法的典型用法代码示例。如果您正苦于以下问题:Python inspect.getabsfile方法的具体用法?Python inspect.getabsfile怎么用?Python inspect.getabsfile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inspect的用法示例。


在下文中一共展示了inspect.getabsfile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lines_without_stdlib

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def lines_without_stdlib(self):
        """Filters code from standard library from self.lines."""
        prev_line = None
        current_module_path = inspect.getabsfile(inspect.currentframe())
        for module_path, lineno, runtime in self.lines:
            module_abspath = os.path.abspath(module_path)
            if not prev_line:
                prev_line = [module_abspath, lineno, runtime]
            else:
                if (not check_standard_dir(module_path) and
                        module_abspath != current_module_path):
                    yield prev_line
                    prev_line = [module_abspath, lineno, runtime]
                else:
                    prev_line[2] += runtime
        yield prev_line 
开发者ID:nvdv,项目名称:vprof,代码行数:18,代码来源:code_heatmap.py

示例2: testRequest

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def testRequest(self):
        runner.run(
            self._func, 'p', ('foo', 'bar'), host=_HOST, port=_PORT)
        response = urllib.request.urlopen(
            'http://%s:%s/profile' % (_HOST, _PORT))
        response_data = gzip.decompress(response.read())
        stats = json.loads(response_data.decode('utf-8'))
        curr_filename = inspect.getabsfile(inspect.currentframe())
        self.assertEqual(stats['p']['objectName'],
                         '_func @ %s (function)' % curr_filename)
        self.assertTrue(len(stats['p']['callStats']) > 0)
        self.assertTrue(stats['p']['totalTime'] > 0)
        self.assertTrue(stats['p']['primitiveCalls'] > 0)
        self.assertTrue(stats['p']['totalCalls'] > 0)


# pylint: enable=missing-docstring, blacklisted-name 
开发者ID:nvdv,项目名称:vprof,代码行数:19,代码来源:profiler_e2e.py

示例3: testRequest

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def testRequest(self):
        runner.run(
            self._func, 'h', ('foo', 'bar'), host=_HOST, port=_PORT)
        response = urllib.request.urlopen(
            'http://%s:%s/profile' % (_HOST, _PORT))
        response_data = gzip.decompress(response.read())
        stats = json.loads(response_data.decode('utf-8'))
        self.assertTrue(stats['h']['runTime'] > 0)
        heatmaps = stats['h']['heatmaps']
        curr_filename = inspect.getabsfile(inspect.currentframe())
        self.assertEqual(stats['h']['objectName'],
                         '_func @ %s (function)' % curr_filename)
        self.assertEqual(len(heatmaps), 1)
        self.assertDictEqual(
            heatmaps[0]['executionCount'], {'101': 1, '102': 1})
        self.assertListEqual(
            heatmaps[0]['srcCode'],
            [['line', 100, u'        def _func(foo, bar):\n'],
             ['line', 101, u'            baz = foo + bar\n'],
             ['line', 102, u'            return baz\n']])

# pylint: enable=missing-docstring, blacklisted-name 
开发者ID:nvdv,项目名称:vprof,代码行数:24,代码来源:code_heatmap_e2e.py

示例4: testRequest

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def testRequest(self):
        runner.run(
            self._func, 'c', ('foo', 'bar'), host=_HOST, port=_PORT)
        response = urllib.request.urlopen(
            'http://%s:%s/profile' % (_HOST, _PORT))
        response_data = gzip.decompress(response.read())
        stats = json.loads(response_data.decode('utf-8'))
        curr_filename = inspect.getabsfile(inspect.currentframe())
        self.assertEqual(stats['c']['objectName'],
                         '_func @ %s (function)' % curr_filename)
        self.assertEqual(
            stats['c']['sampleInterval'], flame_graph._SAMPLE_INTERVAL)
        self.assertTrue(stats['c']['runTime'] > 0)
        self.assertTrue(len(stats['c']['callStats']) >= 0)
        self.assertTrue(stats['c']['totalSamples'] >= 0)

# pylint: enable=missing-docstring, blacklisted-name, protected-access 
开发者ID:nvdv,项目名称:vprof,代码行数:19,代码来源:flame_graph_e2e.py

示例5: testRequest

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def testRequest(self):
        runner.run(
            self._func, 'm', ('foo', 'bar'), host=_HOST, port=_PORT)
        response = urllib.request.urlopen(
            'http://%s:%s/profile' % (_HOST, _PORT))
        response_data = gzip.decompress(response.read())
        stats = json.loads(response_data.decode('utf-8'))
        curr_filename = inspect.getabsfile(inspect.currentframe())
        self.assertEqual(stats['m']['objectName'],
                         '_func @ %s (function)' % curr_filename)
        self.assertEqual(stats['m']['totalEvents'], 2)
        self.assertEqual(stats['m']['codeEvents'][0][0], 1)
        self.assertEqual(stats['m']['codeEvents'][0][1], 91)
        self.assertEqual(stats['m']['codeEvents'][0][3], '_func')
        self.assertEqual(stats['m']['codeEvents'][1][0], 2)
        self.assertEqual(stats['m']['codeEvents'][1][1], 92)
        self.assertEqual(stats['m']['codeEvents'][1][3], '_func')

# pylint: enable=missing-docstring, blacklisted-name 
开发者ID:nvdv,项目名称:vprof,代码行数:21,代码来源:memory_profiler_e2e.py

示例6: main

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def main():
    args = parse_args()

    plugins = parse_plugins(args.plugins)
    for p in plugins:
        dr.load_components(p, continue_on_error=False)

    results = defaultdict(list)
    for comp, delegate in dr.DELEGATES.items():
        if isinstance(delegate, rule):
            results[dr.get_base_module_name(comp)].append(comp)

    results = dict((key, comps) for key, comps in results.items() if len(comps) > 1)

    if results:
        print("Potential key conflicts:")
        print()
        for key in sorted(results):
            print("{key}:".format(key=key))
            for comp in sorted(results[key], key=dr.get_name):
                name = comp.__name__
                path = inspect.getabsfile(comp)
                print("    {name} in {path}".format(name=name, path=path))
            print() 
开发者ID:RedHatInsights,项目名称:insights-core,代码行数:26,代码来源:dupkeycheck.py

示例7: run

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def run(self):
        """Turn everything on."""
        self.roaster.auto_connect()
        self.window = mainwindow.MainWindow(
            self.recipes,
            self.roaster)
        self.window.show()
        sys.exit(self.app.exec_())


# def get_script_dir(follow_symlinks=True):
    # """Checks where the script is being executed from to verify the imports
    # will work properly."""
    # if getattr(sys, 'frozen', False):
        # path = os.path.abspath(sys.executable)
    # else:
        # path = inspect.getabsfile(get_script_dir)

    # if follow_symlinks:
        # path = os.path.realpath(path)

    # return os.path.dirname(path) 
开发者ID:Roastero,项目名称:Openroast,代码行数:24,代码来源:openroastapp.py

示例8: getdocloc

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def getdocloc(self, object):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS)

        basedir = os.path.join(sys.base_exec_prefix, "lib",
                               "python%d.%d" %  sys.version_info[:2])
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 '_thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith("http://"):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__)
            else:
                docloc = os.path.join(docloc, object.__name__ + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
开发者ID:war-and-code,项目名称:jawfish,代码行数:30,代码来源:pydoc.py

示例9: _get_script_dir

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def _get_script_dir(follow_symlinks: bool = True) -> Path:
    # Getting the path to the trust stores is tricky due to subtle differences on OS X, Linux and Windows
    if getattr(sys, "frozen", False):
        # py2exe, PyInstaller, cx_Freeze
        path = Path(sys.executable).absolute()
    else:
        path = Path(inspect.getabsfile(_get_script_dir))
    if follow_symlinks:
        path = Path(realpath(path))
    return path.parent 
开发者ID:nabla-c0d3,项目名称:sslyze,代码行数:12,代码来源:trust_store_repository.py

示例10: _get_position_of_obj

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def _get_position_of_obj(self, obj, quiet=False):
        if hasattr(inspect, "unwrap"):
            obj = inspect.unwrap(obj)
        if isinstance(obj, str):
            return obj, 1, None
        try:
            filename = inspect.getabsfile(obj)
            lines, lineno = inspect.getsourcelines(obj)
        except (IOError, TypeError) as e:
            if not quiet:
                print('** Error: %s **' % e, file=self.stdout)
            return None, None, None
        return filename, lineno, lines 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:15,代码来源:pdbpp.py

示例11: getdocloc

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def getdocloc(self, object):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS",
                                "http://docs.python.org/library")
        basedir = os.path.join(sys.exec_prefix, "lib",
                               "python"+sys.version[0:3])
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 'thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith("http://"):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__)
            else:
                docloc = os.path.join(docloc, object.__name__ + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
开发者ID:glmcdona,项目名称:meddle,代码行数:30,代码来源:pydoc.py

示例12: getdocloc

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def getdocloc(self, object,
                  basedir=os.path.join(sys.exec_prefix, "lib",
                                       "python"+sys.version[0:3])):
        """Return the location of module docs or None"""

        try:
            file = inspect.getabsfile(object)
        except TypeError:
            file = '(built-in)'

        docloc = os.environ.get("PYTHONDOCS",
                                "https://docs.python.org/library")
        basedir = os.path.normcase(basedir)
        if (isinstance(object, type(os)) and
            (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
                                 'marshal', 'posix', 'signal', 'sys',
                                 'thread', 'zipimport') or
             (file.startswith(basedir) and
              not file.startswith(os.path.join(basedir, 'site-packages')))) and
            object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
            if docloc.startswith(("http://", "https://")):
                docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__.lower())
            else:
                docloc = os.path.join(docloc, object.__name__.lower() + ".html")
        else:
            docloc = None
        return docloc

# -------------------------------------------- HTML documentation generator 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:31,代码来源:pydoc.py

示例13: test_html_doc

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def test_html_doc(self):
        result, doc_loc = get_pydoc_html(pydoc_mod)
        mod_file = inspect.getabsfile(pydoc_mod)
        if sys.platform == 'win32':
            import nturl2path
            mod_url = nturl2path.pathname2url(mod_file)
        else:
            mod_url = mod_file
        expected_html = expected_html_pattern % (
                        (mod_url, mod_file, doc_loc) +
                        expected_html_data_docstrings)
        if result != expected_html:
            print_diffs(expected_html, result)
            self.fail("outputs are not equal, see diff above") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_pydoc.py

示例14: test_text_doc

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def test_text_doc(self):
        result, doc_loc = get_pydoc_text(pydoc_mod)
        expected_text = expected_text_pattern % (
                        (inspect.getabsfile(pydoc_mod), doc_loc) +
                        expected_text_data_docstrings)
        if result != expected_text:
            print_diffs(expected_text, result)
            self.fail("outputs are not equal, see diff above") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_pydoc.py

示例15: sys_path

# 需要导入模块: import inspect [as 别名]
# 或者: from inspect import getabsfile [as 别名]
def sys_path():
    """Detect installation path of exopy.

    Automtically called, DOES NOT use directly. Use exopy_path to get the path
    to the exopy directory.

    """
    import exopy

    # Hiding current app_directory.ini to avoid losing user choice.
    path = os.path.dirname(getabsfile(exopy))
    pref_path = os.path.join(path, APP_PREFERENCES)
    app_dir = os.path.join(pref_path, APP_DIR_CONFIG)
    new = os.path.join(pref_path, '_' + APP_DIR_CONFIG)

    # If a hidden file exists already assume it is because previous test
    # failed and do nothing.
    if os.path.isfile(app_dir) and not os.path.isfile(new):
        os.rename(app_dir, new)

    global EXOPY
    EXOPY = path

    yield

    # Remove created app_directory.ini and put hold one back in place.
    app_dir = os.path.join(pref_path, APP_DIR_CONFIG)
    if os.path.isfile(app_dir):
        os.remove(app_dir)

    # Put user file back in place.
    protected = os.path.join(pref_path, '_' + APP_DIR_CONFIG)
    if os.path.isfile(protected):
        os.rename(protected, app_dir) 
开发者ID:Exopy,项目名称:exopy,代码行数:36,代码来源:fixtures.py


注:本文中的inspect.getabsfile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。