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


Python SectionsFileParser.read方法代碼示例

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


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

示例1: __templatesOutliner_view_selectionModel__selectionChanged

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def __templatesOutliner_view_selectionModel__selectionChanged(self, selectedItems, deselectedItems):
		"""
		This method is triggered when **templatesOutliner.view** Model selection has changed.

		:param selectedItems: Selected items. ( QItemSelection )
		:param deselectedItems: Deselected items. ( QItemSelection )
		"""

		selectedTemplates = self.__templatesOutliner.getSelectedTemplates()
		template = foundations.common.getFirstItem(selectedTemplates)
		if not (template and foundations.common.pathExists(template.path)):
			return

		LOGGER.debug("> Parsing '{0}' Template for '{1}' section.".format(template.name,
																	self.__templateRemoteConnectionSection))
		templateSectionsFileParser = SectionsFileParser(template.path)
		templateSectionsFileParser.read() and templateSectionsFileParser.parse(
		rawSections=(self.__templateScriptSection))

		if not self.__templateRemoteConnectionSection in templateSectionsFileParser.sections:
			return

		LOGGER.debug("> {0}' section found.".format(self.__templateRemoteConnectionSection))
		connectionType = foundations.parsers.getAttributeCompound("ConnectionType",
		templateSectionsFileParser.getValue("ConnectionType", self.__templateRemoteConnectionSection))
		if connectionType.value == "Socket":
			LOGGER.debug("> Remote connection type: 'Socket'.")
			self.__tcpClientUi.address = foundations.parsers.getAttributeCompound("DefaultAddress",
			templateSectionsFileParser.getValue("DefaultAddress",
												self.__templateRemoteConnectionSection)).value
			self.__tcpClientUi.port = int(foundations.parsers.getAttributeCompound("DefaultPort",
			templateSectionsFileParser.getValue("DefaultPort",
												self.__templateRemoteConnectionSection)).value)
		elif connectionType.value == "Win32":
			LOGGER.debug("> Remote connection: 'Win32'.")
開發者ID:JulioCesarCampos,項目名稱:sIBL_GUI,代碼行數:37,代碼來源:loaderScript.py

示例2: getIblSetImagesPaths

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def getIblSetImagesPaths(self, iblSet, imageType):
		"""
		This method gets Ibl Set images paths.

		:param iblSet: Ibl Set. ( IblSet )
		:param imageType: Image type. ( String )
		:return: Images paths. ( List )
		"""

		imagePaths = []
		if imageType == "Background":
			path = iblSet.backgroundImage
			path and imagePaths.append(path)
		elif imageType == "Lighting":
			path = iblSet.lightingImage
			path and imagePaths.append(path)
		elif imageType == "Reflection":
			path = iblSet.reflectionImage
			path and imagePaths.append(path)
		elif imageType == "Plate":
			if foundations.common.pathExists(iblSet.path):
				LOGGER.debug("> Parsing Inspector Ibl Set file: '{0}'.".format(iblSet))
				sectionsFileParser = SectionsFileParser(iblSet.path)
				sectionsFileParser.read() and sectionsFileParser.parse()
				for section in sectionsFileParser.sections:
					if re.search(r"Plate\d+", section):
						imagePaths.append(os.path.normpath(os.path.join(os.path.dirname(iblSet.path),
																	sectionsFileParser.getValue("PLATEfile", section))))

		for path in imagePaths[:]:
			if not foundations.common.pathExists(path):
				imagePaths.remove(path) and LOGGER.warning(
				"!> {0} | '{1}' image file doesn't exists and will be skipped!".format(self.__class__.__name__, path))
		return imagePaths
開發者ID:JulioCesarCampos,項目名稱:sIBL_GUI,代碼行數:36,代碼來源:preview.py

示例3: testRawSections

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testRawSections(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class raw sections consistencies.
		"""

		sectionsFileParser = SectionsFileParser(TEMPLATE_FILE)
		sectionsFileParser.read() and sectionsFileParser.parse(rawSections=("Script",))
		self.assertListEqual(sectionsFileParser.sections["Script"]["_rawSectionContent"][0:10], SCRIPT_RAW_SECTION)
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:10,代碼來源:testsParsers.py

示例4: sendLoaderScriptToSoftware

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def sendLoaderScriptToSoftware(self, template, loaderScriptPath):
		"""
		This method sends the Loader Script to associated 3d package.

		:param template: Template. ( Template )
		:param loaderScriptPath: Loader Script path. ( String )
		:return: Method success. ( Boolean )
		"""

		LOGGER.info("{0} | Starting remote connection!".format(self.__class__.__name__))
		templateSectionsFileParser = SectionsFileParser(template.path)
		templateSectionsFileParser.read() and templateSectionsFileParser.parse(
		rawSections=(self.__templateScriptSection))
		connectionType = foundations.parsers.getAttributeCompound("ConnectionType",
		templateSectionsFileParser.getValue("ConnectionType", self.__templateRemoteConnectionSection))

		if connectionType.value == "Socket":
			try:
				connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
				connection.settimeout(2.5)
				connection.connect((foundations.strings.toString(self.__tcpClientUi.address), 	self.__tcpClientUi.port))
				socketCommand = foundations.parsers.getAttributeCompound("ExecutionCommand",
								templateSectionsFileParser.getValue("ExecutionCommand",
								self.__templateRemoteConnectionSection)).value.replace("$loaderScriptPath",
																						loaderScriptPath)
				LOGGER.debug("> Current socket command: '%s'.", socketCommand)
				connection.send(socketCommand)
				self.__engine.notificationsManager.notify(
				"{0} | Socket connection command dispatched!".format(self.__class__.__name__))
				dataBack = connection.recv(4096)
				LOGGER.debug("> Received from connection: '{0}'.".format(dataBack))
				connection.close()
				LOGGER.info("{0} | Closing remote connection!".format(self.__class__.__name__))
			except socket.timeout as error:
				LOGGER.info("{0} | Closing remote connection on timeout!".format(self.__class__.__name__))
			except Exception as error:
				raise sibl_gui.exceptions.SocketConnectionError(
				"{0} | Socket connection error: '{1}'!".format(self.__class__.__name__, error))
		elif connectionType.value == "Win32":
			if platform.system() == "Windows" or platform.system() == "Microsoft":
				try:
					import win32com.client
					connection = win32com.client.Dispatch(foundations.parsers.getAttributeCompound("TargetApplication",
								templateSectionsFileParser.getValue("TargetApplication",
																	self.__templateRemoteConnectionSection)).value)
					connection._FlagAsMethod(self.__win32ExecutionMethod)
					connectionCommand = foundations.parsers.getAttributeCompound("ExecutionCommand",
										templateSectionsFileParser.getValue("ExecutionCommand",
										self.__templateRemoteConnectionSection)).value.replace("$loaderScriptPath",
																								loaderScriptPath)
					LOGGER.debug("> Current connection command: '%s'.", connectionCommand)
					getattr(connection, self.__win32ExecutionMethod)(connectionCommand)
					self.__engine.notificationsManager.notify(
					"{0} | Win32 connection command dispatched!".format(self.__class__.__name__))
				except Exception as error:
					raise sibl_gui.exceptions.Win32OLEServerConnectionError(
					"{0} | Win32 OLE server connection error: '{1}'!".format(self.__class__.__name__, error))
		return True
開發者ID:JulioCesarCampos,項目名稱:sIBL_GUI,代碼行數:60,代碼來源:loaderScript.py

示例5: __views_setUi

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def __views_setUi(self):
		"""
		This method sets the Views.
		"""

		selectedTemplates = self.__templatesOutliner.getSelectedTemplates()
		template = foundations.common.getFirstItem(selectedTemplates)
		if not (template and foundations.common.pathExists(template.path)):
			for view in self.__views:
				self.__view_clearUi(view)
			return

		LOGGER.debug("> Attempting to read '{0}' Template settings file.".format(template.name))
		commonAttributesOverrides = {}
		additionalAttributesOverrides = {}
		templateSettingsDirectory = os.path.join(self.__templatesSettingsDirectory, template.software, template.name)
		currentTemplateSettingsDirectory = os.path.join(templateSettingsDirectory, template.release)
		self.__templateSettingsFile = os.path.join(templateSettingsDirectory,
										template.release,
										os.path.basename(template.path))

		not foundations.common.pathExists(currentTemplateSettingsDirectory) and \
		foundations.io.setDirectory(currentTemplateSettingsDirectory)

		templateSettingsFile = None
		if foundations.common.pathExists(self.__templateSettingsFile):
			templateSettingsFile = self.__templateSettingsFile
		else:
			for version in sorted((
							path for path in os.listdir(templateSettingsDirectory)
							if re.search(r"\d\.\d\.\d", path)), reverse=True, key=lambda x:(foundations.strings.getVersionRank(x))):
				path = os.path.join(templateSettingsDirectory, version, os.path.basename(template.path))
				if foundations.common.pathExists(path):
					templateSettingsFile = path
					break

		if templateSettingsFile:
			LOGGER.debug("> Accessing '{0}' Template settings file: '{1}'.".format(template.name, templateSettingsFile))
			templateSettingsSectionsFileParser = SectionsFileParser(templateSettingsFile)
			templateSettingsSectionsFileParser.read() and templateSettingsSectionsFileParser.parse()
			commonAttributesOverrides.update(
			templateSettingsSectionsFileParser.sections[self.__templateCommonAttributesSection])
			additionalAttributesOverrides.update(
			templateSettingsSectionsFileParser.sections[self.__templateAdditionalAttributesSection])
		else:
			LOGGER.debug("> No Template settings file found for : '{0}'.".format(template.name))

		LOGGER.debug("> Parsing '{0}' Template for '{1}' and '{2}' section.".format(
		template.name, self.__templateCommonAttributesSection, self.__templateAdditionalAttributesSection))
		templateSectionsFileParser = SectionsFileParser(template.path)
		templateSectionsFileParser.read() and templateSectionsFileParser.parse(
		rawSections=(self.__templateScriptSection))

		self.__view_setUi(templateSectionsFileParser.sections.get(self.__templateCommonAttributesSection, {}),
								self.__commonView, commonAttributesOverrides)
		self.__view_setUi(templateSectionsFileParser.sections.get(self.__templateAdditionalAttributesSection, {}),
								self.__additionalView, additionalAttributesOverrides)
開發者ID:JulioCesarCampos,項目名稱:sIBL_GUI,代碼行數:59,代碼來源:loaderScriptOptions.py

示例6: testDefaultsSection

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testDefaultsSection(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class default section consistency.
		"""

		sectionsFileParser = SectionsFileParser(DEFAULTS_FILE)
		sectionsFileParser.read() and sectionsFileParser.parse()
		for section in DEFAULTS_FILE_SECTIONS_AND_ATTRIBUTES:
			self.assertIn(section, sectionsFileParser.sections)
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:11,代碼來源:testsParsers.py

示例7: testSectionExists

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testSectionExists(self):
		"""
		This method tests :meth:`foundations.parsers.SectionsFileParser.sectionExists` method.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			self.assertTrue(sectionsFileParser.sectionExists(STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type].keys()[0]))
			self.assertFalse(sectionsFileParser.sectionExists("Unknown"))
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:12,代碼來源:testsParsers.py

示例8: testParsingErrors

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testParsingErrors(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class parsing errors consistencies.
		"""

		sectionsFileParser = SectionsFileParser(PARSING_ERRORS_FILE)
		sectionsFileParser.read() and sectionsFileParser.parse(raiseParsingErrors=False)
		for exception in sectionsFileParser.parsingErrors:
			self.assertIn(exception.line, PARSING_ERRORS_LINES_AND_VALUES)
			self.assertEqual(exception.value, PARSING_ERRORS_LINES_AND_VALUES[exception.line])
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:12,代碼來源:testsParsers.py

示例9: testStripQuotationMarkers

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testStripQuotationMarkers(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class quotation markers consistencies.
		"""

		sectionsFileParser = SectionsFileParser(STRIPPING_FILE)
		sectionsFileParser.read() and sectionsFileParser.parse(stripQuotationMarkers=False)
		for section in STRIPPING_FILE_SECTIONS_AND_ATTRIBUTES_STRIPPED:
			self.assertIn(section, sectionsFileParser.sections)
			for attribute, value in STRIPPING_FILE_SECTIONS_AND_ATTRIBUTES_STRIPPED[section].iteritems():
				self.assertIn(attribute, sectionsFileParser.sections[section])
				self.assertIn(value, sectionsFileParser.sections[section].itervalues())
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:14,代碼來源:testsParsers.py

示例10: testNamespaces

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testNamespaces(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class namespaces consistencies.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type],
																	namespaces=False)
			for section in STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type]:
				for attribute in sectionsFileParser.sections[section]:
					self.assertIn(attribute, STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type][section]["stripped"])
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:14,代碼來源:testsParsers.py

示例11: testSections

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testSections(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class sections consistencies.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			self.assertListEqual(sectionsFileParser.sections.keys(), STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type].keys())
			sectionsFileParser.parse(orderedDictionary=False, rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			for section in STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type]:
				self.assertIn(section, sectionsFileParser.sections)
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:14,代碼來源:testsParsers.py

示例12: testComments

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testComments(self):
		"""
		This method tests :class:`foundations.parsers.SectionsFileParser` class comments consistencies.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			self.assertEqual(sectionsFileParser.comments, OrderedDict())
			sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type], stripComments=False)
			for comment, value in RANDOM_COMMENTS[type].iteritems():
				self.assertIn(comment, sectionsFileParser.comments)
				self.assertEqual(value["id"], sectionsFileParser.comments[comment]["id"])
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:15,代碼來源:testsParsers.py

示例13: testAttributeExists

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testAttributeExists(self):
		"""
		This method tests :meth:`foundations.parsers.SectionsFileParser.attributeExists` method.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(False, rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			for attribute in RANDOM_ATTRIBUTES[type]:
				self.assertTrue(sectionsFileParser.attributeExists(attribute, namespace.getNamespace(attribute,
																									rootOnly=True)))
				self.assertFalse(sectionsFileParser.attributeExists("Unknown", namespace.getNamespace(attribute,
																									rootOnly=True)))
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:15,代碼來源:testsParsers.py

示例14: listTemplatesReleases

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
def listTemplatesReleases():
	"""
	This definition lists Templates releases.
	"""

	for template in sorted(list(foundations.walkers.filesWalker(os.path.normpath(TEMPLATES_PATH), (TEMPLATES_EXTENSION,), ("\._",)))):
		sectionsFileParser = SectionsFileParser(template)
		sectionsFileParser.read() and sectionsFileParser.parse(rawSections=("Script",))

		LOGGER.info("{0} | '{1}': '{2}'.".format(listTemplatesReleases.__name__,
												foundations.strings.getSplitextBasename(template),
												foundations.parsers.getAttributeCompound("Release",
												sectionsFileParser.getValue("Release", "Template")).value))
開發者ID:pupologic,項目名稱:sIBL_GUI_Templates,代碼行數:15,代碼來源:listTemplatesReleases.py

示例15: testGetAllAttributes

# 需要導入模塊: from foundations.parsers import SectionsFileParser [as 別名]
# 或者: from foundations.parsers.SectionsFileParser import read [as 別名]
	def testGetAllAttributes(self):
		"""
		This method tests :meth:`foundations.parsers.SectionsFileParser.getAllAttributes` method.
		"""

		for type, file in STANDARD_FILES.iteritems():
			sectionsFileParser = SectionsFileParser(file)
			sectionsFileParser.read() and sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
			attributes = sectionsFileParser.getAllAttributes()
			testsAttributes = []
			for section in STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type]:
				testsAttributes.extend(STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type][section]["namespaced"])
			self.assertListEqual(attributes.keys(), testsAttributes)
開發者ID:elanifegnirf,項目名稱:Foundations,代碼行數:15,代碼來源:testsParsers.py


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