• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python path.extend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sys.path.extend函数的典型用法代码示例。如果您正苦于以下问题:Python extend函数的具体用法?Python extend怎么用?Python extend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _config_check

def _config_check():
    from message import Messager
    
    from sys import path
    from copy import deepcopy
    from os.path import dirname
    # Reset the path to force config.py to be in the root (could be hacked
    #       using __init__.py, but we can be monkey-patched anyway)
    orig_path = deepcopy(path)
    # Can't you empty in O(1) instead of O(N)?
    while path:
        path.pop()
    path.append(path_join(abspath(dirname(__file__)), '../..'))
    # Check if we have a config, otherwise whine
    try:
        import config
        del config
    except ImportError, e:
        path.extend(orig_path)
        # "Prettiest" way to check specific failure
        if e.message == 'No module named config':
            Messager.error(_miss_config_msg(), duration=-1)
        else:
            Messager.error(_get_stack_trace(), duration=-1)
        raise ConfigurationError
开发者ID:TsujiiLaboratory,项目名称:stav,代码行数:25,代码来源:server.py


示例2: CT_Init

def CT_Init():
    """creat a new calltips windows"""

    global helpBuffer
    vim.command('silent botright new Python_CallTips_Windows')
    vim.command('set buftype=nofile')
    vim.command('set nonumber')
    vim.command('resize 5')
    vim.command('set noswapfile')
    helpBuffer = vim.current.buffer
    vim.command('wincmd p')   #switch back window
    from sys import path
    path.extend(['.','..'])  #add current path and parent path
开发者ID:vim-scraper,项目名称:packages,代码行数:13,代码来源:2004-09-05+0.6+pyCallTips.py


示例3: CT_Init

def CT_Init():
    """creat a new calltips windows"""

    global helpBuffer
    vim.command('silent botright new Python_CallTips')
    vim.command('set buftype=nofile')
    vim.command('set nonumber')
    vim.command('resize 5')
    vim.command('set noswapfile')
    helpBuffer = vim.current.buffer
    vim.command('wincmd p')   #switch back window
    vim.command('autocmd CursorHold *.py python CT_ImportObject()')
    vim.command('set updatetime=5000')
    from sys import path
    path.extend(['.','..'])  #add current path and parent path
开发者ID:vim-scraper,项目名称:packages,代码行数:15,代码来源:2004-09-12+0.7+pyCallTips.py


示例4: _build_mod_list

def _build_mod_list(mod_path: list, suffix: str, blacklist: list) -> list:
    """ _build_mod_list(mod_path, suffix) -> Add all the paths in mod_path to
    sys.path and return a list of all modules in sys.path ending in suffix.

    """

    from sys import path as sys_path

    mod_path = [mod_path] if type(mod_path) is str else mod_path
    blacklist = [blacklist] if type(blacklist) is str else blacklist

    # Add suffix to all names in blacklist.
    blacklist.extend(["%s%s" % (name, suffix) for name in blacklist if not name.endswith(suffix)])

    # Add the path of this file to the search path.
    mod_path.append(os_abspath(os_dirname(__file__)))

    # Add the path(s) in mod_path to sys.path so we can import from
    # them.
    [sys_path.extend((path, os_dirname(path.rstrip("/")))) for path in mod_path if path not in sys_path]

    # Build the list of modules ending in suffix in the mod_path(s).
    mod_list = (
        (path, name)
        for path in sys_path
        if os_isdir(path)
        for name in os_listdir(path)
        if name.endswith(suffix) and name not in blacklist
    )

    return mod_list
开发者ID:zepto,项目名称:musio,代码行数:31,代码来源:io_util.py


示例5: _config_check

def _config_check():
    from message import Messager

    from sys import path
    from copy import deepcopy
    from os.path import dirname
    # Reset the path to force config.py to be in the root (could be hacked
    #       using __init__.py, but we can be monkey-patched anyway)
    orig_path = deepcopy(path)

    try:
        # Can't you empty in O(1) instead of O(N)?
        while path:
            path.pop()
        path.append(path_join(abspath(dirname(__file__)), '../..'))
        # Check if we have a config, otherwise whine
        try:
            import config
            del config
        except ImportError as e:
            path.extend(orig_path)
            # "Prettiest" way to check specific failure
            if e.message == 'No module named config':
                Messager.error(_miss_config_msg(), duration=-1)
            else:
                Messager.error(_get_stack_trace(), duration=-1)
            raise ConfigurationError
        # Try importing the config entries we need
        try:
            from config import DEBUG
        except ImportError:
            path.extend(orig_path)
            Messager.error(_miss_var_msg('DEBUG'), duration=-1)
            raise ConfigurationError
        try:
            from config import ADMIN_CONTACT_EMAIL
        except ImportError:
            path.extend(orig_path)
            Messager.error(_miss_var_msg('ADMIN_CONTACT_EMAIL'), duration=-1)
            raise ConfigurationError
    finally:
        # Remove our entry to the path
        while path:
            path.pop()
        # Then restore it
        path.extend(orig_path)
开发者ID:a-tsioh,项目名称:brat,代码行数:46,代码来源:server.py


示例6: all

  assert a.electropot.units == eV and all(abs(a.electropot - [-83.4534, -83.4534]*eV) < 1e-8)
  assert a.forces.units == eV/angstrom and all(abs(a.forces) < 1e-8)
  assert a.stresses.units == kB \
         and all(abs(a.stresses - [[[ 21.96,   0.  ,   0.  ],
                                    [  0.  ,  21.96,   0.  ],
                                    [  0.  ,   0.  ,  21.96]],
                                   [[-14.05,   0.  ,   0.  ],
                                    [  0.  , -14.05,   0.  ],
                                    [  0.  ,   0.  , -14.05]],
                                   [[  0.1 ,   0.  ,   0.  ],
                                    [  0.  ,   0.1 ,   0.  ],
                                    [  0.  ,   0.  ,   0.1 ]]] * kB) < 1e-3)
  assert a.stress.units == kB \
         and all(abs(a.stress - [[  0.1 ,   0.  ,   0.  ],
                                 [  0.  ,   0.1 ,   0.  ],
                                 [  0.  ,   0.  ,   0.1 ]] * kB) < 1e-3)
  assert hasattr(a.structure, 'stress')\
         and a.structure.stress.units == a.stress.units \
         and all(abs(a.structure.stress - a.stress) < 1e-8)
  assert all([hasattr(b, 'force') for b in a.structure])\
         and all([b.force.units == a.forces.units for b in a.structure])\
         and all(abs(a.forces.magnitude - array([b.force for b in a.structure])) < 1e-8)

if __name__ == "__main__":
  from sys import argv, path 
  from os.path import join
  if len(argv) > 2: path.extend(argv[2:])
  
  test(join(argv[1], 'COMMON'))

开发者ID:mdavezac,项目名称:LaDa,代码行数:29,代码来源:dft.py


示例7: points3d

    break
  points3d(x,y,z,s, scale_factor=0.004, colormap="autumn")
  x, y, z, s = [], [], [], []
  for i, box in enumerate(boxes):
    if i < N: continue
    x.extend([(atom.pos[0] + trans[0]) for atom, trans, inbox in box if not inbox])
    y.extend([(atom.pos[1] + trans[1]) for atom, trans, inbox in box if not inbox])
    z.extend([(atom.pos[2] + trans[2]) for atom, trans, inbox in box if not inbox])
    s.extend([float(i+2) + (0. if inbox else 0.4) for atom, trans, inbox in box if not inbox])
    break
  points3d(x,y,z,s, scale_factor=0.01, opacity=0.3)


if __name__ == "__main__":
  from sys import argv, path 
  if len(argv) > 0: path.extend(argv[1:])

  from random import randint
  from numpy import zeros
  from numpy.linalg import det
  from pylada.crystal.cppwrappers import supercell
  
  lattice = b5()
  check(lattice)

  for i in xrange(10): 
    cell = zeros((3,3))
    while det(cell) == 0:
      cell[:] = [[randint(-10, 11) for j in xrange(3)] for k in xrange(3)]
    if det(cell) < 0: cell[:, 0], cell[:, 1] = cell[:, 1].copy(), cell[:, 0].copy()
    structure = supercell(lattice, cell)
开发者ID:georgeyumnam,项目名称:pylada,代码行数:31,代码来源:periodic_dnc.py


示例8: Structure

        Structure(0.0, 0.5, 0.5, 0.5, 0.0, 0.5, 0.5, 0.5, 0.0, scale=2.0, m=True)
        .add_atom(0, 0, 0, "As")
        .add_atom(0.25, 0.25, 0.25, ["In", "Ga"], m=True)
    )
    assert is_primitive(lattice)
    for cell in itercells(10):
        structure = supercell(lattice, dot(lattice.cell, cell))
        assert not is_primitive(structure)


#   structure = primitive(structure, 1e-8)
#   assert is_primitive(structure)
#   assert abs(structure.volume - lattice.volume) < 1e-8
#   assert len(structure) == len(lattice)
#   assert is_integer(dot(structure.cell, inv(lattice.cell)))
#   assert is_integer(dot(lattice.cell, inv(structure.cell)))
#   invcell = inv(lattice.cell)
#   for atom in structure:
#     assert api(lattice[atom.site].pos, atom.pos, invcell) and \
#            atom.type == lattice[atom.site].type and \
#            getattr(lattice[atom.site], 'm', False) == getattr(atom, 'm', False) and \
#            (getattr(atom, 'm', False) or atom.site == 0)

if __name__ == "__main__":
    from sys import argv, path

    if len(argv) > 0:
        path.extend(argv[1:])

    test_primitive()
开发者ID:georgeyumnam,项目名称:pylada,代码行数:30,代码来源:primitive.py


示例9: abs

    assert abs(a.ediff - 2e-5) < 1e-8
    assert abs(a.ediffg - 2e-4) < 1e-8
    assert a.lorbit == 0
    assert abs(a.nupdown + 1.0) < 1e-8
    assert a.lmaxmix == 4
    assert abs(a.valence - 8.0) < 1e-8
    assert a.nonscf == False
    assert a.lwave == False
    assert a.lcharg
    assert a.lvtot == False
    assert a.nelm == 60
    assert a.nelmin == 2
    assert a.nelmdl == -5
    assert all(abs(a.kpoints - array([[0.25, 0.25, 0.25], [0.75, -0.25, -0.25]])) < 1e-8)
    assert all(abs(a.multiplicity - [96.0, 288.0]) < 1e-8)
    pylada.verbose_representation = True


# assert repr(a.functional) == "from pylada.vasp.functional import Vasp\nfrom pylada.vasp.specie import Specie\nfunctional = Vasp()\nfunctional.addgrid              = None\nfunctional.algo                 = 'Fast'\nfunctional.ediff                = 1e-05\nfunctional.ediffg               = None\nfunctional.encut                = 1\nfunctional.encutgw              = None\nfunctional.extraelectron        = 0\nfunctional.fftgrid              = None\nfunctional.ispin                = 1\nfunctional.istart               = None\nfunctional.isym                 = None\nfunctional.kpoints              = 'Automatic generation\\n0\\nMonkhorst\\n2 2 2\\n0 0 0'\nfunctional.lcharg               = True\nfunctional.lmaxfockae           = None\nfunctional.lmaxmix              = 4\nfunctional.loptics              = False\nfunctional.lorbit               = None\nfunctional.lpead                = False\nfunctional.lrpa                 = False\nfunctional.lvtot                = False\nfunctional.lwave                = False\nfunctional.magmom               = True\nfunctional.nbands               = None\nfunctional.nelm                 = None\nfunctional.nelmdl               = None\nfunctional.nelmin               = None\nfunctional.nomega               = None\nfunctional.nonscf               = False\nfunctional.npar                 = None\nfunctional.nupdown              = None\nfunctional.precfock             = None\nfunctional.precision            = 'Accurate'\nfunctional.relaxation           = 'volume'\nfunctional.restart              = None\nfunctional.restart_from_contcar = True\nfunctional.smearing             = None\nfunctional.symprec              = None\nfunctional.system               = True\nfunctional.U_verbosity          = 1\nfunctional.species['Si'] = Specie('~/usr/src/Pylada/revamped/vasp/tests/pseudos/Si')\n"
# pylada.verbose_representation = False
# assert repr(a.functional) == "from pylada.vasp.functional import Vasp\nfrom pylada.vasp.specie import Specie\nfunctional = Vasp()\nfunctional.ediff      = 1e-05\nfunctional.encut      = 1\nfunctional.kpoints    = 'Automatic generation\\n0\\nMonkhorst\\n2 2 2\\n0 0 0'\nfunctional.relaxation = 'volume'\nfunctional.species['Si'] = Specie('~/usr/src/Pylada/revamped/vasp/tests/pseudos/Si')\n"

if __name__ == "__main__":
    from sys import argv, path
    from os.path import join

    if len(argv) > 2:
        path.extend(argv[2:])

    test(join(argv[1], "COMMON"))
开发者ID:mdavezac,项目名称:LaDa,代码行数:30,代码来源:common.py


示例10: _convert_log_level

        except ImportError:
            path.extend(orig_path)
            Messager.error(_miss_var_msg('DEBUG'), duration=-1)
            raise ConfigurationError
        try:
            from config import ADMIN_CONTACT_EMAIL
        except ImportError:
            path.extend(orig_path)
            Messager.error(_miss_var_msg('ADMIN_CONTACT_EMAIL'), duration=-1)
            raise ConfigurationError
    finally:
        # Remove our entry to the path
        while path:
            path.pop()
        # Then restore it
        path.extend(orig_path)

# Convert internal log level to `logging` log level
def _convert_log_level(log_level):
    import config
    import logging
    if log_level == config.LL_DEBUG:
        return logging.DEBUG
    elif log_level == config.LL_INFO:
        return logging.INFO
    elif log_level == config.LL_WARNING:
        return logging.WARNING
    elif log_level == config.LL_ERROR:
        return logging.ERROR
    elif log_level == config.LL_CRITICAL:
        return logging.CRITICAL
开发者ID:s-case,项目名称:requirements-annotation-tool,代码行数:31,代码来源:server.py


示例11: CollideTest

# -*- coding: utf-8 -*-

"""Tests for collision"""

from sys import path
path.extend(['.', '..','../..'])

import unittest
from mosp import collide
from math import sqrt

__author__ = "F. Ludwig, P. Tute"
__maintainer__ = "B. Henne"
__contact__ = "[email protected]"
__copyright__ = "(c) 2010-2011, DCSec, Leibniz Universitaet Hannover, Germany"
__license__ = "GPLv3"


class CollideTest(unittest.TestCase):
    """Tests mosp.collide basic functions."""
    
    def test_Line_closest_to_point(self):
        """Test Line.closest_to_point with four Lines w/different angles."""
        h = collide.Line(2.0, 5.0, 8.0, 5.0)
        self.assertEqual(h.closest_to_point( 0.0, 0.0), (2,5))
        self.assertEqual(h.closest_to_point( 5.0, 0.0), (5,5))
        self.assertEqual(h.closest_to_point(10.0, 0.0), (8,5))
        self.assertEqual(h.closest_to_point(10.0, 5.0), (8,5))
        self.assertEqual(h.closest_to_point(10.0,10.0), (8,5))
        self.assertEqual(h.closest_to_point( 5.0,10.0), (5,5))
        self.assertEqual(h.closest_to_point( 0.0,10.0), (2,5))
开发者ID:bhenne,项目名称:MoSP,代码行数:31,代码来源:test_collide.py


示例12: custom

from sys import path
import os
from itertools import combinations_with_replacement, permutations

import numpy as np
from matplotlib import pyplot as plt
from scipy.optimize import leastsq

from toy import HamiltonianToy as H_ex
from toy import HamiltonianToyEffective as H_eff
from toy import get_a_exact as exact
from toy import custom_a_prescription as custom
from toy import get_n_i_fn as get_ni_fn

path.extend([b'../../tr-a_dependence_plots/src'])
# noinspection PyPep8,PyUnresolvedReferences
from plotting import save_plot_figure
# noinspection PyPep8,PyUnresolvedReferences
from plotting import save_plot_data_file
# noinspection PyPep8,PyUnresolvedReferences
from constants import LEGEND_SIZE

A_PRESCRIPTIONS = [
    exact,
    # custom(16, 17, 18),
    # custom(18, 18, 18),
    # custom(19.25066421,  19.11085927,  17.88211487),   # T2 = -1
    custom(4, 5, 6),
    custom(6, 6, 6),
    # custom(6.81052543, 7.16905406, 7.56813846),         # T2 = [-5,0]
开发者ID:dilynfullerton,项目名称:tr-vce_A_dependence_toy,代码行数:30,代码来源:main.py


示例13: Constants

TODO: SteeringBehavious.flocking is not automatically updated by pause, stop,
and resume methods. FIX THIS!

TODO: Future versions might provide a mechanism for importing only a subset
of the available behaviours, but this isn't really needed at this time.
"""

# for python3 compat
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import print_function
from __future__ import division

from sys import path
path.extend(['../vpoints'])
from point2d import Point2d

# Constants for steering behaviours
from steering_constants import *

# Math Constants (for readability)
INF = float('inf')
from math import sqrt
SQRT_HALF = sqrt(0.5)

# Random number generator
from random import Random
rand_gen = Random()
rand_gen.seed()
rand_uni = lambda x: rand_gen.uniform(-x, x)
开发者ID:PigSupreme,项目名称:clayton-rpi-tactical,代码行数:30,代码来源:steering.py


示例14: CallTips

    vim.command("wincmd p")   #switch back window
    #mapping "a-zA-Z." keys
    for letter in letters+'.':    
        vim.command("inoremap <buffer> %s %s<Esc>:python CallTips()<CR>" \
                    % (letter, letter))
    #mapping "Back Space" keys
    vim.command("inoremap <buffer> <BS> <BS><Esc>:python CallTips()<CR>")

    #mapping "F4" keys
    vim.command("inoremap <buffer> <F4> <Esc>:python ImportObject()<CR>")

    #mapping "Alt 1" key
    vim.command("inoremap <buffer> <M-1> <Esc>:python AutoComplete(1)<CR>")

    #mapping "Alt 2" key
    vim.command("inoremap <buffer> <M-2> <Esc>:python AutoComplete(2)<CR>")

    #mapping "Alt 3" key
    vim.command("inoremap <buffer> <M-3> <Esc>:python AutoComplete(3)<CR>")

    #mapping "Alt 4" key
    vim.command("inoremap <buffer> <M-4> <Esc>:python AutoComplete(4)<CR>")

    #mapping "Alt 5" key
    vim.command("inoremap <buffer> <M-5> <Esc>:python AutoComplete(5)<CR>")

    path.extend(['.','..'])  #add current path and parent path
    del path, letter

    ImportObject()
开发者ID:vim-scraper,项目名称:packages,代码行数:30,代码来源:2004-08-30+0.5+pyCallTips.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python path.insert函数代码示例发布时间:2022-05-27
下一篇:
Python path.append函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap