コード例 #1
0
ファイル: package.py プロジェクト: scanny/python-pptx
    def core_properties(self):
        """Instance of |CoreProperties| holding read/write Dublin Core doc properties.

        Creates a default core properties part if one is not present (not common).
        """
        try:
            return self.part_related_by(RT.CORE_PROPERTIES)
        except KeyError:
            core_props = CorePropertiesPart.default(self)
            self.relate_to(core_props, RT.CORE_PROPERTIES)
            return core_props
コード例 #2
0
 def it_can_construct_a_default_core_props(self):
     core_props = CorePropertiesPart.default()
     # verify -----------------------
     assert isinstance(core_props, CorePropertiesPart)
     assert core_props.content_type is CT.OPC_CORE_PROPERTIES
     assert core_props.partname == '/docProps/core.xml'
     assert isinstance(core_props._element, CT_CoreProperties)
     assert core_props.title == 'PowerPoint Presentation'
     assert core_props.last_modified_by == 'python-pptx'
     assert core_props.revision == 1
     # core_props.modified only stores time with seconds resolution, so
     # comparison needs to be a little loose (within two seconds)
     modified_timedelta = datetime.utcnow() - core_props.modified
     max_expected_timedelta = timedelta(seconds=2)
     assert modified_timedelta < max_expected_timedelta