當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。