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


Python pkg_resources.load_entry_point方法代码示例

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


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

示例1: test_bug_862

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_bug_862(self):
        if env.WINDOWS:
            self.skipTest("Windows can't make symlinks")
        # This simulates how pyenv and pyenv-virtualenv end up creating the
        # coverage executable.
        self.make_file("elsewhere/bin/fake-coverage", """\
            #!{executable}
            import sys, pkg_resources
            sys.exit(pkg_resources.load_entry_point('coverage', 'console_scripts', 'coverage')())
            """.format(executable=sys.executable))
        os.chmod("elsewhere/bin/fake-coverage", stat.S_IREAD | stat.S_IEXEC)
        os.symlink("elsewhere", "somewhere")
        self.make_file("foo.py", "print('inside foo')")
        self.make_file("bar.py", "import foo")
        out = self.run_command("somewhere/bin/fake-coverage run bar.py")
        self.assertEqual("inside foo\n", out) 
开发者ID:nedbat,项目名称:coveragepy,代码行数:18,代码来源:test_process.py

示例2: test_convert_from_problematic

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_convert_from_problematic(self):
        probl = pkg_resources.resource_filename("Mikado.tests", "Chrysemys_picta_bellii_problematic.gff3")
        for outp in ("gtf", "bed12"):
            with self.subTest(outp=outp):
                outfile = tempfile.NamedTemporaryFile(mode="wt")
                outfile.close()
                sys.argv = ["", "util", "convert", "-of", outp, probl, outfile.name]
                # with self.assertRaises(SystemExit):
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                self.assertGreater(os.stat(outfile.name).st_size, 0)
                lines = [_ for _ in open(outfile.name)]
                self.assertTrue(any(["rna-NC_023890.1:71..1039" in line for line in lines]))
                self.assertTrue(any(["rna-NC_023890.1:1040..1107" in line for line in lines]))
                self.assertTrue(any(["gene-LOC112059550" in line for line in lines]))
                self.assertTrue(any(["id-LOC112059311" in line for line in lines]))


# @mark.slow 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:20,代码来源:test_system_calls.py

示例3: test_serialise_external

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_serialise_external(self):

        base = pkg_resources.resource_filename("Mikado.tests", "test_external")
        external_conf = os.path.join(base, "mikado.configuration.testds.yaml")
        external_scores = os.path.join(base, "annotation_run1.metrics.testds.txt")
        fasta = os.path.join(base, "mikado_prepared.testds.fasta")

        for procs in (1, 3):
            with self.subTest(procs=procs):
                dir = tempfile.TemporaryDirectory(suffix="test_serialise_external")
                log = "serialise.log"
                sys.argv = [str(_) for _ in ["mikado", "serialise", "--json-conf", external_conf,
                                             "--transcripts", fasta, "-od", dir.name,
                                             "-l", log,
                                             "--external-scores", external_scores,
                                             "--seed", 10, "--procs", procs, "mikado.db"]]
                log = os.path.join(dir.name, log)
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                conn = sqlite3.connect(os.path.join(dir.name, "mikado.db"))
                total = conn.execute("SELECT count(*) FROM external").fetchone()[0]
                self.assertEqual(total, 190)
                tot_sources = conn.execute("SELECT count(*) FROM external_sources").fetchone()[0]
                self.assertEqual(tot_sources, 95) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:25,代码来源:test_system_calls.py

示例4: invoke_tool

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def invoke_tool(self, cmd_line):

        # capture io
        stdout_buffer = io.StringIO()
        stderr_buffer = io.StringIO()

        old_stdout = sys.stdout
        old_stderr = sys.stderr

        sys.stdout = stdout_buffer
        sys.stderr = stderr_buffer

        args = shlex.split(cmd_line)
        v = pkg_resources.load_entry_point('inkfish', 'console_scripts',
                                           args[0])(args)

        sys.stdout = old_stdout
        sys.stderr = old_stderr

        return v, stdout_buffer.getvalue(), stderr_buffer.getvalue() 
开发者ID:Chia-Network,项目名称:oldvdf-competition,代码行数:22,代码来源:test_cmds.py

示例5: SearchEngine

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def SearchEngine(engine='dummy', **config):
    entry = pkg_resources.load_entry_point(
        'kansha', 'search.engines', engine)
    return entry(**config) 
开发者ID:Net-ng,项目名称:kansha,代码行数:6,代码来源:__init__.py

示例6: get_command

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def get_command(self, ctx, name):
        params = [click.Argument(["command"], nargs=-1)]
        plugin = pkg_resources.load_entry_point(
            "pifpaf", "pifpaf.daemons", name)
        params.extend(map(lambda kw: click.Option(**kw), plugin.get_options()))

        def _run_cb(*args, **kwargs):
            return self._run(name, plugin, ctx, *args, **kwargs)

        return click.Command(name=name, callback=_run_cb, params=params) 
开发者ID:jd,项目名称:pifpaf,代码行数:12,代码来源:__main__.py

示例7: parse

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def parse(uri):
    resolve_uri = pkg_resources.load_entry_point(
        'newt.db', 'zodburi.resolvers', 'newt')
    factory, dbkw = resolve_uri(uri)
    with mock.patch("newt.db.storage") as storage:
        factory()
        (dsn,), options = storage.call_args
        return dsn, options, dbkw 
开发者ID:newtdb,项目名称:db,代码行数:10,代码来源:testzodburi.py

示例8: test_entry_point

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_entry_point(self):
        script = load_entry_point('qopen', 'console_scripts', 'qopen')
        with quiet():
            try:
                script(['-h'])
            except SystemExit:
                pass 
开发者ID:trichter,项目名称:qopen,代码行数:9,代码来源:test_xcore.py

示例9: test_script

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_script(self):
        self.script = load_entry_point('qopen', 'console_scripts', 'qopen-rt')
        with tempdir():
            with quiet():
                self.cmd('calc 1600 500 -t 5 -r 1000')
                self.cmd('calc 1600 500 -t 5 -r 1000 -a 5000')
                self.cmd('calc-direct 1600 500 -t 5')
                with warnings.catch_warnings():
                    warnings.simplefilter('ignore')
                    self.cmd('plot-t 1600 500 -r 1000')
                    self.cmd('plot-t 1600 500 -r 1000 --no-direct')
                    self.cmd('plot-r 1600 500 -t 0.5 --type rt2d') 
开发者ID:trichter,项目名称:qopen,代码行数:14,代码来源:test_rt.py

示例10: tests_run

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def tests_run(display, authfile=None):
    pid = os.fork()
    if pid != 0:
        return pid
    if authfile is None:
        authfile = os.devnull
    os.environ['DISPLAY'] = display
    os.environ['XAUTHORITY'] = authfile
    cmd = [
        sys.executable,
        '-c', textwrap.dedent(
            '''
            from pkg_resources import load_entry_point
            sys.exit(load_entry_point(
                'nose', 'console_scripts', 'nosetests',
            )())
            '''
        ).lstrip(),
        '--exe', '--with-xunit', '--verbosity=3',
    ]
    has_custom_tests = False
    for arg in sys.argv[1:]:
        if not arg.startswith('-'):
            has_custom_tests = True
        cmd.append(arg)
    if not has_custom_tests:
        cmd.extend(('test/', 'examples/run_examples.py'))
    print('running tests: `{0}`'.format(' '.join(cmd)))
    sys.argv = cmd
    try:
        load_entry_point('nose', 'console_scripts', 'nosetests')()
    except SystemExit as err:
        code = err.code
    else:
        code = 0
    os._exit(code) 
开发者ID:python-xlib,项目名称:python-xlib,代码行数:38,代码来源:runtests.py

示例11: test_convert_from_bam

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_convert_from_bam(self):

        bam_inp = pkg_resources.resource_filename("Mikado.tests", "test_mRNA.bam")
        for outp in ("gff3", "gtf", "bed12"):
            with self.subTest(outp=outp):
                outfile = tempfile.NamedTemporaryFile(mode="wt")
                outfile.close()
                sys.argv = ["", "util", "convert", "-of", outp, bam_inp, outfile.name]
                # with self.assertRaises(SystemExit):
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                self.assertGreater(os.stat(outfile.name).st_size, 0)
                lines = [_ for _ in open(outfile.name)]
                self.assertTrue(any(["TraesCS2B02G055500.1" in line for line in lines])) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:15,代码来源:test_system_calls.py

示例12: test_different_scoring

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_different_scoring(self):

        dir = tempfile.TemporaryDirectory()
        self.json_conf["pick"]["files"]["output_dir"] = os.path.abspath(dir.name)
        self.json_conf["pick"]["files"]["input"] = pkg_resources.resource_filename("Mikado.tests",
                                                                                   "mikado_prepared.gtf")

        self.json_conf["pick"]["files"]["loci_out"] = "mikado.test_diff.loci.gff3"
        self.json_conf["pick"]["files"]["subloci_out"] = "mikado.test_diff.subloci.gff3"
        self.json_conf["pick"]["files"]["monoloci_out"] = "mikado.test_diff.monoloci.gff3"
        self.json_conf["pick"]["files"]["log"] = "mikado.test_diff.log"
        self.json_conf["pick"]["alternative_splicing"]["pad"] = False
        self.json_conf["log_settings"]["log_level"] = "DEBUG"

        self.assertEqual(os.path.basename(self.json_conf["pick"]["scoring_file"]),
                         "plant.yaml")
        shutil.copy(pkg_resources.resource_filename("Mikado.tests", "mikado.db"),
                    os.path.join(self.json_conf["pick"]["files"]["output_dir"], "mikado.db"))
        self.json_conf["db_settings"]["db"] = os.path.join(self.json_conf["pick"]["files"]["output_dir"],
                                                           "mikado.db")
        json_file = os.path.join(self.json_conf["pick"]["files"]["output_dir"], "mikado.yaml")
        with open(json_file, "wt") as json_handle:
            sub_configure.print_config(yaml.dump(self.json_conf, default_flow_style=False), json_handle)
        sys.argv = ["mikado", "pick", "--json-conf", json_file, "--single", "--seed", "1078"]
        with self.assertRaises(SystemExit):
            pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()

        import csv
        with open(os.path.join(self.json_conf["pick"]["files"]["output_dir"], "mikado.test_diff.loci.scores.tsv")) as tsv:
            reader = csv.DictReader(tsv, delimiter="\t")
            score_names = [_ for _ in self.json_conf["scoring"]]
            score_header = [_ for _ in reader.fieldnames if _ not in
                            ("tid", "alias", "parent", "score", "source_score")]
            self.assertEqual(sorted(score_names), sorted(score_header))
        dir.cleanup() 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:37,代码来源:test_system_calls.py

示例13: test_grep

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_grep(self):
        files = [pkg_resources.resource_filename("Mikado.tests", fname) for fname in ["trinity.gtf", "trinity.gff3"]]
        with io.TextIOWrapper(pkg_resources.resource_stream("Mikado.tests", "trinity.ids")) as id_file:
            ids = [tuple(line.rstrip().split("\t")) for line in id_file]

        id_temp_file = tempfile.NamedTemporaryFile("wt", suffix=".txt")
        to_write = [ids[_] for _ in np.random.choice(len(ids), 10, replace=False)]
        [print(*idline, sep="\t", file=id_temp_file) for idline in to_write]
        id_temp_file.flush()

        for fname in files:
            with self.subTest(fname=fname):
                form = os.path.splitext(fname)[1]
                outfile = tempfile.NamedTemporaryFile("wt", suffix=form)
                outfile.close()
                self.assertFalse(os.path.exists(outfile.name))
                sys.argv = ["mikado", "util", "grep", id_temp_file.name, fname, outfile.name]
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                self.assertTrue(os.path.exists(outfile.name))
                found = set()
                with to_gff(outfile.name, input_format=form[1:]) as stream:
                    for record in stream:
                        if record.is_transcript:
                            found.add(record.transcript)
                self.assertEqual(len(found), 10)
                self.assertEqual(found, set(_[0] for _ in to_write)) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:28,代码来源:test_system_calls.py

示例14: test_v_grep

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_v_grep(self):
        files = [pkg_resources.resource_filename("Mikado.tests", fname) for fname in ["trinity.gtf", "trinity.gff3"]]
        with io.TextIOWrapper(pkg_resources.resource_stream("Mikado.tests", "trinity.ids")) as id_file:
            ids = [tuple(line.rstrip().split("\t")) for line in id_file]

        id_temp_file = tempfile.NamedTemporaryFile("wt", suffix=".txt")
        to_write = [ids[_] for _ in np.random.choice(len(ids), 10, replace=False)]
        others = [_ for _ in ids if _ not in to_write]
        [print(*idline, sep="\t", file=id_temp_file) for idline in to_write]
        id_temp_file.flush()

        for fname in files:
            with self.subTest(fname=fname):
                form = os.path.splitext(fname)[1]
                outfile = tempfile.NamedTemporaryFile("wt", suffix=form)
                outfile.close()
                self.assertFalse(os.path.exists(outfile.name))
                sys.argv = ["mikado", "util", "grep", "-v", id_temp_file.name, fname, outfile.name]
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                self.assertTrue(os.path.exists(outfile.name))
                found = set()
                with to_gff(outfile.name, input_format=form[1:]) as stream:
                    for record in stream:
                        if record.is_transcript:
                            found.add(record.transcript)
                self.assertEqual(len(found), len(others))
                self.assertEqual(found, set(_[0] for _ in others)) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:29,代码来源:test_system_calls.py

示例15: test_problem_grep

# 需要导入模块: import pkg_resources [as 别名]
# 或者: from pkg_resources import load_entry_point [as 别名]
def test_problem_grep(self):
        fname = pkg_resources.resource_filename("Mikado.tests", "Chrysemys_picta_bellii_problematic.gff3")
        flist = pkg_resources.resource_filename("Mikado.tests", "Chrysemys_picta_bellii_problematic.list.txt")

        for flag in ("", "-v"):
            with self.subTest(flag=flag):
                form = os.path.splitext(fname)[1]
                outfile = tempfile.NamedTemporaryFile("wt", suffix=form)
                outfile.close()
                self.assertFalse(os.path.exists(outfile.name))
                if flag:
                    sys.argv = ["mikado", "util", "grep", flag, flist, fname, outfile.name]
                else:
                    sys.argv = ["mikado", "util", "grep", flist, fname, outfile.name]
                print(*sys.argv)
                pkg_resources.load_entry_point("Mikado", "console_scripts", "mikado")()
                self.assertTrue(os.path.exists(outfile.name))
                found = set()

                others = ["NC_023890.1:1..16875"]
                if flag != "-v":
                    for line in pkg_resources.resource_stream("Mikado.tests",
                                                              "Chrysemys_picta_bellii_problematic.list.txt"):
                        rec = line.decode().rstrip().split()[0]
                        print(line, rec)
                        others.append(rec)

                with to_gff(outfile.name, input_format=form[1:]) as stream:
                    for record in stream:
                        if record.feature in ("exon", "CDS"):
                            continue
                        if record.is_transcript:
                            found.add(record.transcript)
                        elif record.feature in ("pseudogene", "region"):
                            found.add(record.id)

                self.assertEqual(len(found), len(others))
                self.assertEqual(found, set(others)) 
开发者ID:EI-CoreBioinformatics,项目名称:mikado,代码行数:40,代码来源:test_system_calls.py


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