當前位置: 首頁>>代碼示例>>Python>>正文


Python PyZipFile.namelist方法代碼示例

本文整理匯總了Python中zipfile.PyZipFile.namelist方法的典型用法代碼示例。如果您正苦於以下問題:Python PyZipFile.namelist方法的具體用法?Python PyZipFile.namelist怎麽用?Python PyZipFile.namelist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zipfile.PyZipFile的用法示例。


在下文中一共展示了PyZipFile.namelist方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: load_special_tools

# 需要導入模塊: from zipfile import PyZipFile [as 別名]
# 或者: from zipfile.PyZipFile import namelist [as 別名]
	def load_special_tools(self, var, ban=[]):
		"""
		Loads third-party extensions modules for certain programming languages
		by trying to list certain files in the extras/ directory. This method
		is typically called once for a programming language group, see for
		example :py:mod:`waflib.Tools.compiler_c`

		:param var: glob expression, for example 'cxx\_\*.py'
		:type var: string
		:param ban: list of exact file names to exclude
		:type ban: list of string
		"""
		if os.path.isdir(waf_dir):
			lst = self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var)
			for x in lst:
				if not x.name in ban:
					load_tool(x.name.replace('.py', ''))
		else:
			from zipfile import PyZipFile
			waflibs = PyZipFile(waf_dir)
			lst = waflibs.namelist()
			for x in lst:
				if not re.match('waflib/extras/%s' % var.replace('*', '.*'), var):
					continue
				f = os.path.basename(x)
				doban = False
				for b in ban:
					r = b.replace('*', '.*')
					if re.match(r, f):
						doban = True
				if not doban:
					f = f.replace('.py', '')
					load_tool(f)
開發者ID:fedepell,項目名稱:waf,代碼行數:35,代碼來源:Context.py

示例2: load_special_tools

# 需要導入模塊: from zipfile import PyZipFile [as 別名]
# 或者: from zipfile.PyZipFile import namelist [as 別名]
	def load_special_tools(self, var, ban=[]):
		global waf_dir
		if os.path.isdir(waf_dir):
			lst = self.root.find_node(waf_dir).find_node('waflib/extras').ant_glob(var)
			for x in lst:
				if not x.name in ban:
					load_tool(x.name.replace('.py', ''))
		else:
			from zipfile import PyZipFile
			waflibs = PyZipFile(waf_dir)
			lst = waflibs.namelist()
			for x in lst:
				if not re.match("waflib/extras/%s" % var.replace("*", ".*"), var):
					continue
				f = os.path.basename(x)
				doban = False
				for b in ban:
					r = b.replace("*", ".*")
					if re.match(b, f):
						doban = True
				if not doban:
					f = f.replace('.py', '')
					load_tool(f)
開發者ID:Jajcus,項目名稱:jack2,代碼行數:25,代碼來源:Context.py


注:本文中的zipfile.PyZipFile.namelist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。