コード例 #1
0
ファイル: test_coreprops.py プロジェクト: scanny/python-pptx
 def date_prop_set_fixture(self, request):
     prop_name, tagname, value, str_val, attrs = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CorePropertiesPart.load(None, None, None,
                                               coreProperties)
     expected_xml = self.coreProperties(tagname, str_val, attrs)
     return core_properties, prop_name, value, expected_xml
コード例 #2
0
 def core_properties(self):
     xml = (
         b'<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\'?>'
         b'\n<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.o'
         b'rg/package/2006/metadata/core-properties" xmlns:dc="http://pur'
         b'l.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcm'
         b'itype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="h'
         b'ttp://www.w3.org/2001/XMLSchema-instance">\n'
         b'  <cp:contentStatus>DRAFT</cp:contentStatus>\n'
         b'  <dc:creator>python-pptx</dc:creator>\n'
         b'  <dcterms:created xsi:type="dcterms:W3CDTF">2012-11-17T11:07:'
         b'40-05:30</dcterms:created>\n'
         b'  <dc:description/>\n'
         b'  <dc:identifier>GXS 10.2.1ab</dc:identifier>\n'
         b'  <dc:language>US-EN</dc:language>\n'
         b'  <cp:lastPrinted>2014-06-04T04:28:00Z</cp:lastPrinted>\n'
         b'  <cp:keywords>foo bar baz</cp:keywords>\n'
         b'  <cp:lastModifiedBy>Steve Canny</cp:lastModifiedBy>\n'
         b'  <cp:revision>4</cp:revision>\n'
         b'  <dc:subject>Spam</dc:subject>\n'
         b'  <dc:title>Presentation</dc:title>\n'
         b'  <cp:version>1.2.88</cp:version>\n'
         b'</cp:coreProperties>\n'
     )
     return CorePropertiesPart.load(None, None, xml, None)
コード例 #3
0
ファイル: test_coreprops.py プロジェクト: scanny/python-pptx
 def revision_set_fixture(self, request):
     value, str_val = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CorePropertiesPart.load(None, None, None,
                                               coreProperties)
     expected_xml = self.coreProperties("cp:revision", str_val)
     return core_properties, value, expected_xml
コード例 #4
0
ファイル: test_coreprops.py プロジェクト: scanny/python-pptx
 def revision_get_fixture(self, request):
     str_val, expected_revision = request.param
     tagname = "" if str_val is None else "cp:revision"
     coreProperties = self.coreProperties(tagname, str_val)
     core_properties = CorePropertiesPart.load(None, None, None,
                                               coreProperties)
     return core_properties, expected_revision
コード例 #5
0
 def date_prop_set_fixture(self, request):
     prop_name, tagname, value, str_val, attrs = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CorePropertiesPart.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties(tagname, str_val, attrs)
     return core_properties, prop_name, value, expected_xml
コード例 #6
0
 def revision_set_fixture(self, request):
     value, str_val = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CorePropertiesPart.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties('cp:revision', str_val)
     return core_properties, value, expected_xml
コード例 #7
0
 def revision_get_fixture(self, request):
     str_val, expected_revision = request.param
     tagname = '' if str_val is None else 'cp:revision'
     coreProperties = self.coreProperties(tagname, str_val)
     core_properties = CorePropertiesPart.load(
         None, None, coreProperties, None
     )
     return core_properties, expected_revision
コード例 #8
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
コード例 #9
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