本文整理匯總了Python中foundations.parsers.SectionsFileParser類的典型用法代碼示例。如果您正苦於以下問題:Python SectionsFileParser類的具體用法?Python SectionsFileParser怎麽用?Python SectionsFileParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SectionsFileParser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getIblSetImagesPaths
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
示例2: __view__valueChanged
def __view__valueChanged(self, *args):
"""
Defines the slot triggered by a View when value changed.
:param \*args: Arguments.
:type \*args: \*
"""
LOGGER.debug("> Initializing '{0}' Template settings file content.".format(self.__templateSettingsFile))
templateSettingsSectionsFileParser = SectionsFileParser(self.__templateSettingsFile)
templateSettingsSectionsFileParser.sections = OrderedDict()
for section, view in OrderedDict([(self.__templateCommonAttributesSection,
self.Common_Attributes_tableWidget),
(self.__templateAdditionalAttributesSection,
self.Additional_Attributes_tableWidget)]).iteritems():
templateSettingsSectionsFileParser.sections[section] = OrderedDict()
for row in range(view.rowCount()):
widget = view.cellWidget(row, 0)
if type(widget) is Variable_QPushButton:
value = widget.text() == "True" and "1" or "0"
elif type(widget) is QDoubleSpinBox:
value = foundations.strings.toString(widget.value())
elif type(widget) is QComboBox:
value = foundations.strings.toString(widget.currentText())
else:
value = foundations.strings.toString(widget.text())
templateSettingsSectionsFileParser.sections[
section][foundations.namespace.removeNamespace(widget.data.name)] = value
templateSettingsSectionsFileParser.write()
示例3: testRawSections
def testRawSections(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class raw sections consistencies.
"""
sectionsFileParser = SectionsFileParser(TEMPLATE_FILE)
sectionsFileParser.parse(rawSections=("Script",))
self.assertListEqual(sectionsFileParser.sections["Script"]["__raw__"][0:10], SCRIPT_RAW_SECTION)
示例4: test__len__
def test__len__(self):
"""
Tests :meth:`foundations.parsers.SectionsFileParser.__len__` method.
"""
for type, file in STANDARD_FILES.iteritems():
sectionsFileParser = SectionsFileParser(file)
sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
self.assertEqual(len(sectionsFileParser), len(STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type].keys()))
示例5: testDefaultsSection
def testDefaultsSection(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class default section consistency.
"""
sectionsFileParser = SectionsFileParser(DEFAULTS_FILE)
sectionsFileParser.parse()
for section in DEFAULTS_FILE_SECTIONS_AND_ATTRIBUTES:
self.assertIn(section, sectionsFileParser.sections)
示例6: testSectionExists
def testSectionExists(self):
"""
Tests :meth:`foundations.parsers.SectionsFileParser.sectionExists` method.
"""
for type, file in STANDARD_FILES.iteritems():
sectionsFileParser = SectionsFileParser(file)
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"))
示例7: testParsingErrors
def testParsingErrors(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class parsing errors consistencies.
"""
sectionsFileParser = SectionsFileParser(PARSING_ERRORS_FILE)
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])
示例8: test__contains__
def test__contains__(self):
"""
Tests :meth:`foundations.parsers.SectionsFileParser.__contains__` method.
"""
for type, file in STANDARD_FILES.iteritems():
sectionsFileParser = SectionsFileParser(file)
sectionsFileParser.parse(rawSections=STANDARD_FILES_RAW_SECTIONS[type])
for key in STANDARD_FILES_SECTIONS_AND_ATTRIBUTES[type].keys():
self.assertTrue(key in sectionsFileParser)
示例9: test__getitem__
def test__getitem__(self):
"""
Tests :meth:`foundations.parsers.SectionsFileParser.__getitem__` method.
"""
sectionsFileParser = SectionsFileParser(IBL_SET_FILE)
sectionsFileParser.parse()
self.assertListEqual(
sectionsFileParser["Header"].keys(),
STANDARD_FILES_SECTIONS_AND_ATTRIBUTES.get("iblSet").get("Header").get("namespaced"),
)
示例10: testNamespaces
def testNamespaces(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class namespaces consistencies.
"""
for type, file in STANDARD_FILES.iteritems():
sectionsFileParser = SectionsFileParser(file)
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"])
示例11: testStripWhitespaces
def testStripWhitespaces(self):
"""
This method tests :class:`foundations.parsers.SectionsFileParser` class whitespaces consistencies.
"""
sectionsFileParser = SectionsFileParser(STRIPPING_FILE)
sectionsFileParser.read() and sectionsFileParser.parse(stripWhitespaces=False)
for section in STRIPPING_FILE_SECTIONS_AND_ATTRIBUTES_NON_STRIPPED:
self.assertIn(section, sectionsFileParser.sections)
for attribute, value in STRIPPING_FILE_SECTIONS_AND_ATTRIBUTES_NON_STRIPPED[section].iteritems():
self.assertIn(attribute, sectionsFileParser.sections[section])
self.assertIn(value, sectionsFileParser.sections[section].itervalues())
示例12: __setActiveIblSetParser
def __setActiveIblSetParser(self):
"""
Sets the :mod:`sibl_gui.components.core.inspector.inspector` Component Ibl Set parser.
"""
if foundations.common.pathExists(self.__activeIblSet.path):
LOGGER.debug("> Parsing Inspector Ibl Set file: '{0}'.".format(self.__activeIblSet))
if not self.__sectionsFileParsersCache.getContent(self.__activeIblSet.path):
sectionsFileParser = SectionsFileParser(self.__activeIblSet.path)
sectionsFileParser.parse()
self.__sectionsFileParsersCache.addContent(**{self.__activeIblSet.path: sectionsFileParser})
示例13: testStripQuotationMarkers
def testStripQuotationMarkers(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class quotation markers consistencies.
"""
sectionsFileParser = SectionsFileParser(STRIPPING_FILE)
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())
示例14: testComments
def testComments(self):
"""
Tests :class:`foundations.parsers.SectionsFileParser` class comments consistencies.
"""
for type, file in STANDARD_FILES.iteritems():
sectionsFileParser = SectionsFileParser(file)
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"])
示例15: listTemplatesReleases
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))