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


Python path.append方法代码示例

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


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

示例1: addSig

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def addSig(self,sig,main=True):
        """新增信号图"""
        if main:
            if sig in self.sigPlots:
                self.pwKL.removeItem(self.sigPlots[sig])
            self.sigPlots[sig] = self.pwKL.plot()
            self.sigColor[sig] = self.allColor[0]
            self.allColor.append(self.allColor.popleft())
        else:
            if sig in self.subSigPlots:
                self.pwOI.removeItem(self.subSigPlots[sig])
            self.subSigPlots[sig] = self.pwOI.plot()
            self.subSigColor[sig] = self.allSubColor[0]
            self.allSubColor.append(self.allSubColor.popleft())

    #---------------------------------------------------------------------- 
开发者ID:rjj510,项目名称:uiKLine,代码行数:18,代码来源:uiKLine.py

示例2: set_start_and_end_pos

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def set_start_and_end_pos(self,datas):
        """根据开始与结束日期设置pos"""
        
        datas['time_int'] = np.array(range(len(datas.index)))
        #print (datas[(datas.index=="20201111")]['time_int'])
        #print (datas[(datas.index=="20190402")]['time_int'])
        if len(datas[(datas.index==self.start_date[0])]['time_int']) > 0:
            self.start_date.append(datas[(datas.index==self.start_date[0])]['time_int'][0])            
        else:
            self.start_date.append(0)
            
        if len(datas[(datas.index==self.end_date[0])]['time_int']) > 0:
            self.end_date.append(datas[(datas.index==self.end_date[0])]['time_int'][0])
        else:
            self.end_date.append(len(datas.index)-1)
        
                  
        
    #---------------------------------------------------------------------- 
开发者ID:rjj510,项目名称:uiKLine,代码行数:21,代码来源:uiKLine.py

示例3: log_broken

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def log_broken(name, e):
    global BROKEN_LIST
    
    if VERBOSE:
        print name, "FAILED"
    print >> LOG_FILE_BUSTED, "----------------------------------------------------------------"
    print >> LOG_FILE_BUSTED, "--", name
    if hasattr(e, "clsException"):
        print >> LOG_FILE_BUSTED, e.clsException
    else:
        print >> LOG_FILE_BUSTED, e
    
    temp_name = name.replace(".", "\\")
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name + ".py"):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + ".py")
    except:
        pass
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/"))
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + "/__init__.py")
    except:
        pass 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:26,代码来源:stdmodules.py

示例4: _save_result

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def _save_result(self, result: Dict[str, str]) -> None:
        try:
            self.results.append(result)
            if 'NS' in result.keys():
                self.base.print_success('Domain: ', result['Domain'], ' NS: ', result['NS'])
            else:
                with open(RawDnsResolver.temporary_results_filename, 'a') as temporary_file:
                    temporary_file.write('Domain: ' + result['Domain'] +
                                         ' IPv4 address: ' + result['IPv4 address'] +
                                         ' IPv6 address: ' + result['IPv6 address'] + '\n')
                if result['IPv6 address'] == '-':
                    print(self.base.cSUCCESS + '[' + str(len(self.uniq_hosts)) + '] ' + self.base.cEND +
                          result['Domain'] + ' - ' + result['IPv4 address'])
                else:
                    print(self.base.cSUCCESS + '[' + str(len(self.uniq_hosts)) + '] ' + self.base.cEND +
                          result['Domain'] + ' - ' + result['IPv6 address'])
        except AttributeError:
            pass

        except KeyError:
            pass
    # endregion

    # region Parse DNS packet function 
开发者ID:raw-packet,项目名称:raw-packet,代码行数:26,代码来源:dns_resolver.py

示例5: get_ipv6_nameservers_apple_device_over_ssh

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def get_ipv6_nameservers_apple_device_over_ssh(self, host: Union[None, str] = None) -> List[str]:
        nameservers: List[str] = list()
        if host is None:
            host = ScriptDhcpv6RogueServerTest.Variables.apple_device_ipv4_address
        target_command = run(['ssh ' + ScriptDhcpv6RogueServerTest.Variables.apple_device_username + '@' + host +
                              ' "cat /etc/resolv.conf | grep nameserver"'],
                             shell=True, stdout=PIPE, stderr=STDOUT)
        target_nameservers: str = target_command.stdout.decode('utf-8')
        target_nameservers: str = sub(r' +', ' ', target_nameservers)
        target_nameservers: List[str] = target_nameservers.splitlines()
        for target_nameserver in target_nameservers:
            nameserver_address: str = target_nameserver.split(' ')[1]
            if self.base.ip_address_validation(nameserver_address):
                nameservers.append(nameserver_address)
            if self.base.ipv6_address_validation(nameserver_address):
                nameservers.append(nameserver_address)
        return nameservers 
开发者ID:raw-packet,项目名称:raw-packet,代码行数:19,代码来源:test_dhcpv6_rogue_server.py

示例6: _unserialize_contents

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def _unserialize_contents(self, data : BytesIO):
        
        self.symbol_table = []
        
        for num_symbol in range(self.section_header.sh_size // self.section_header.sh_entsize):
            
            data.seek(self.section_header.sh_offset + num_symbol * self.section_header.sh_entsize)
            
            symbol_class = {
                (False, False): Elf32LittleEndianSymbolTableEntry,
                (True, False): Elf32BigEndianSymbolTableEntry,
                (False, True): Elf64LittleEndianSymbolTableEntry,
                (True, True): Elf64BigEndianSymbolTableEntry,
            }[(self.is_big_endian, self.is_64_bits)]
            
            symbol = symbol_class(self.is_big_endian, self.is_64_bits)
            
            symbol.unserialize(data)
            
            self.symbol_table.append(symbol) 
开发者ID:marin-m,项目名称:vmlinux-to-elf,代码行数:22,代码来源:elf.py

示例7: unserialize

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def unserialize(self, data : BytesIO):
        
        super().unserialize(data)
        
        data.seek(self.section_header.sh_offset)
        
        self.relocation_table = []
        
        for num_symbol in range(self.section_header.sh_size // self.section_header.sh_entsize):

            relocation_class = {
                (False, False): Elf32LittleEndianRelocationWithAddendTableEntry,
                (True, False): Elf32BigEndianRelocationWithAddendTableEntry,
                (False, True): Elf64LittleEndianRelocationWithAddendTableEntry,
                (True, True): Elf64BigEndianRelocationWithAddendTableEntry,
            }[(self.is_big_endian, self.is_64_bits)]
            
            relocation = relocation_class(self.is_big_endian, self.is_64_bits)
            
            relocation.unserialize(data)
            
            self.relocation_table.append(relocation) 
开发者ID:marin-m,项目名称:vmlinux-to-elf,代码行数:24,代码来源:elf.py

示例8: log_broken

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def log_broken(name, e):
    global BROKEN_LIST
    
    if VERBOSE:
        print(name, "FAILED")
    print("----------------------------------------------------------------", file=LOG_FILE_BUSTED)
    print("--", name, file=LOG_FILE_BUSTED)
    if hasattr(e, "clsException"):
        print(e.clsException, file=LOG_FILE_BUSTED)
    else:
        print(e, file=LOG_FILE_BUSTED)
    
    temp_name = name.replace(".", "\\")
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name + ".py"):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + ".py")
    except:
        pass
    try:
        if nt.stat(CPY_LIB_DIR + "\\" + temp_name):
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/"))
            BROKEN_LIST.append("/Lib/" + temp_name.replace("\\", "/") + "/__init__.py")
    except:
        pass 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:26,代码来源:stdmodules.py

示例9: start

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def start(self):
		for self.path in self.paths:
			self.path = self.path.rstrip()

			if self.path not in self.scanned:
				if self.ext != False:
					if "." in self.path:
						if self.ext in self.path:
							self.ItsTime()
						else:
							pass						
					else:
						self.ItsTime()
				else:
					self.ItsTime()
				self.scanned.append(self.path)
			else:
				pass 
开发者ID:fnk0c,项目名称:cangibrina,代码行数:20,代码来源:cangibrina.py

示例10: __init__

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def __init__(self):
        self.settings = settings
        self.rbac = rbac
        self.properties = properties
        self.database = database
        self.logging = logging
        self.load_custom_properties()
        self.path = Path.cwd()
        self.init_encryption()
        self.use_vault = settings["vault"]["use_vault"]
        if self.use_vault:
            self.init_vault_client()
        if settings["syslog"]["active"]:
            self.init_syslog_server()
        if settings["paths"]["custom_code"]:
            sys_path.append(settings["paths"]["custom_code"])
        self.fetch_version()
        self.init_logs()
        self.init_redis()
        self.init_scheduler()
        self.init_connection_pools() 
开发者ID:eNMS-automation,项目名称:eNMS,代码行数:23,代码来源:base.py

示例11: init_services

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def init_services(self):
        path_services = [self.path / "eNMS" / "services"]
        if self.settings["paths"]["custom_services"]:
            path_services.append(Path(self.settings["paths"]["custom_services"]))
        for path in path_services:
            for file in path.glob("**/*.py"):
                if "init" in str(file):
                    continue
                if not self.settings["app"]["create_examples"] and "examples" in str(
                    file
                ):
                    continue
                info(f"Loading service: {file}")
                spec = spec_from_file_location(str(file).split("/")[-1][:-3], str(file))
                try:
                    spec.loader.exec_module(module_from_spec(spec))
                except InvalidRequestError as exc:
                    error(f"Error loading custom service '{file}' ({str(exc)})") 
开发者ID:eNMS-automation,项目名称:eNMS,代码行数:20,代码来源:base.py

示例12: log_queue

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def log_queue(self, runtime, service, log=None, mode="add"):
        if self.redis_queue:
            key = f"{runtime}/{service}/logs"
            self.run_logs[runtime][int(service)] = None
            if mode == "add":
                log = self.redis("lpush", key, log)
            else:
                log = self.redis("lrange", key, 0, -1)
                if log:
                    log = log[::-1]
        else:
            if mode == "add":
                return self.run_logs[runtime][int(service)].append(log)
            else:
                log = getattr(self.run_logs[runtime], mode)(int(service), [])
        return log 
开发者ID:eNMS-automation,项目名称:eNMS,代码行数:18,代码来源:base.py

示例13: __init__

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def __init__(self, problem, population):
        ea.MoeaAlgorithm.__init__(self, problem, population) # 先调用父类构造方法
        if population.ChromNum == 1:
            raise RuntimeError('传入的种群对象必须是多染色体的种群类型。')
        self.name = 'psy-awGA'
        self.selFunc = 'tour' # 选择方式,采用锦标赛选择
        # 由于有多个染色体,因此需要用多个重组和变异算子
        self.recOpers = []
        self.mutOpers = []
        for i in range(population.ChromNum):
            if population.Encodings[i] == 'P':
                recOper = ea.Xovpmx(XOVR = 1) # 生成部分匹配交叉算子对象
                mutOper = ea.Mutinv(Pm = 1) # 生成逆转变异算子对象
            elif population.Encodings[i] == 'BG':
                recOper = ea.Xovud(XOVR = 1) # 生成部均匀交叉算子对象
                mutOper = ea.Mutbin(Pm = None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值
            elif population.Encodings[i] == 'RI':
                recOper = ea.Xovud(XOVR = 1) # 生成部均匀交叉算子对象
                mutOper = ea.Mutuni(Pm = 1/self.problem.Dim, Alpha = False, Middle = False) # 生成均匀变异算子对象
            else:
                raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.')
            self.recOpers.append(recOper)
            self.mutOpers.append(mutOper)
        self.extraMutOper = ea.Mutgau(Pm = 1/self.problem.Dim, Sigma3 = False, Middle = False) # 额外生成一个高斯变异算子对象,对标准差放大3倍
        self.MAXSIZE = population.sizes # 非支配解集大小限制 
开发者ID:geatpy-dev,项目名称:geatpy,代码行数:27,代码来源:moea_psy_awGA_templet.py

示例14: __init__

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def __init__(self, problem, population):
        ea.SoeaAlgorithm.__init__(self, problem, population) # 先调用父类构造方法
        if population.ChromNum == 1:
            raise RuntimeError('传入的种群对象必须是多染色体的种群类型。')
        self.name = 'psy-EGA'
        self.selFunc = 'tour' # 锦标赛选择算子
        # 由于有多个染色体,因此需要用多个重组和变异算子
        self.recOpers = []
        self.mutOpers = []
        for i in range(population.ChromNum):
            if population.Encodings[i] == 'P':
                recOper = ea.Xovpmx(XOVR = 0.7) # 生成部分匹配交叉算子对象
                mutOper = ea.Mutinv(Pm = 0.5) # 生成逆转变异算子对象
            else:
                recOper = ea.Xovdp(XOVR = 0.7) # 生成两点交叉算子对象
                if population.Encodings[i] == 'BG':
                    mutOper = ea.Mutbin(Pm = None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值
                elif population.Encodings[i] == 'RI':
                    mutOper = ea.Mutbga(Pm = 1/self.problem.Dim, MutShrink = 0.5, Gradient = 20) # 生成breeder GA变异算子对象
                else:
                    raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.')
            self.recOpers.append(recOper)
            self.mutOpers.append(mutOper) 
开发者ID:geatpy-dev,项目名称:geatpy,代码行数:25,代码来源:soea_psy_EGA_templet.py

示例15: __init__

# 需要导入模块: from sys import path [as 别名]
# 或者: from sys.path import append [as 别名]
def __init__(self, problem, population):
        ea.SoeaAlgorithm.__init__(self, problem, population) # 先调用父类构造方法
        if population.ChromNum == 1:
            raise RuntimeError('传入的种群对象必须是多染色体的种群类型。')
        self.name = 'psy-steadyGA'
        self.selFunc = 'etour' # 锦标赛选择算子
        # 由于有多个染色体,因此需要用多个重组和变异算子
        self.recOpers = []
        self.mutOpers = []
        for i in range(population.ChromNum):
            if population.Encodings[i] == 'P':
                recOper = ea.Xovpmx(XOVR = 1) # 生成部分匹配交叉算子对象
                mutOper = ea.Mutinv(Pm = 0.5) # 生成逆转变异算子对象
            else:
                recOper = ea.Xovdp(XOVR = 1) # 生成两点交叉算子对象
                if population.Encodings[i] == 'BG':
                    mutOper = ea.Mutbin(Pm = None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值
                elif population.Encodings[i] == 'RI':
                    mutOper = ea.Mutbga(Pm = 1/self.problem.Dim, MutShrink = 0.5, Gradient = 20) # 生成breeder GA变异算子对象
                else:
                    raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.')
            self.recOpers.append(recOper)
            self.mutOpers.append(mutOper) 
开发者ID:geatpy-dev,项目名称:geatpy,代码行数:25,代码来源:soea_psy_steadyGA_templet.py


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