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