コード例 #1
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 CoreProperties.load(None, None, xml, None)
コード例 #2
0
ファイル: test_coreprops.py プロジェクト: pjbayes/python-pptx
 def core_properties(self):
     xml = (
         '<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\'?>\n'
         '<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/'
         'package/2006/metadata/core-properties" xmlns:dc="http://purl.or'
         'g/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype'
         '/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://'
         'www.w3.org/2001/XMLSchema-instance">\n'
         '  <cp:contentStatus>DRAFT</cp:contentStatus>\n'
         '  <dc:creator>python-pptx</dc:creator>\n'
         '  <dcterms:created xsi:type="dcterms:W3CDTF">2012-11-17T11:07:4'
         '0-05:30</dcterms:created>\n'
         '  <dc:description/>\n'
         '  <dc:identifier>GXS 10.2.1ab</dc:identifier>\n'
         '  <dc:language>US-EN</dc:language>\n'
         '  <cp:lastPrinted>2014-06-04T04:28:00Z</cp:lastPrinted>\n'
         '  <cp:keywords>foo bar baz</cp:keywords>\n'
         '  <cp:lastModifiedBy>Steve Canny</cp:lastModifiedBy>\n'
         '  <cp:revision>4</cp:revision>\n'
         '  <dc:subject>Spam</dc:subject>\n'
         '  <dc:title>Presentation</dc:title>\n'
         '  <cp:version>1.2.88</cp:version>\n'
         '</cp:coreProperties>\n'
     )
     return CoreProperties.load(None, None, xml, None)
コード例 #3
0
ファイル: test_coreprops.py プロジェクト: pjbayes/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 = CoreProperties.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties(tagname, str_val, attrs)
     return core_properties, prop_name, value, expected_xml
コード例 #4
0
ファイル: test_coreprops.py プロジェクト: pjbayes/python-pptx
 def revision_set_fixture(self, request):
     value, str_val = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CoreProperties.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties('cp:revision', str_val)
     return core_properties, value, expected_xml
コード例 #5
0
ファイル: test_coreprops.py プロジェクト: pjbayes/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 = CoreProperties.load(
         None, None, coreProperties, None
     )
     return core_properties, expected_revision
コード例 #6
0
 def date_prop_set_fixture(self, request):
     prop_name, tagname, value, str_val, attrs = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CoreProperties.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties(tagname, str_val, attrs)
     return core_properties, prop_name, value, expected_xml
コード例 #7
0
 def revision_set_fixture(self, request):
     value, str_val = request.param
     coreProperties = self.coreProperties(None, None)
     core_properties = CoreProperties.load(
         None, None, coreProperties, None
     )
     expected_xml = self.coreProperties('cp:revision', str_val)
     return core_properties, value, expected_xml
コード例 #8
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 = CoreProperties.load(
         None, None, coreProperties, None
     )
     return core_properties, expected_revision
コード例 #9
0
 def core_properties(self):
     """
     Instance of |CoreProperties| holding the read/write Dublin Core
     document properties for this presentation. 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 = CoreProperties.default()
         self.relate_to(core_props, RT.CORE_PROPERTIES)
         return core_props
コード例 #10
0
ファイル: package.py プロジェクト: CSberger/python-pptx
 def core_properties(self):
     """
     Instance of |CoreProperties| holding the read/write Dublin Core
     document properties for this presentation. 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 = CoreProperties.default()
         self.relate_to(core_props, RT.CORE_PROPERTIES)
         return core_props
コード例 #11
0
ファイル: test_coreprops.py プロジェクト: pjbayes/python-pptx
 def it_can_construct_a_default_core_props(self):
     core_props = CoreProperties.default()
     # verify -----------------------
     assert isinstance(core_props, CoreProperties)
     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
コード例 #12
0
 def it_can_construct_a_default_core_props(self):
     core_props = CoreProperties.default()
     # verify -----------------------
     assert isinstance(core_props, CoreProperties)
     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
コード例 #13
0
 def test_it_can_construct_default_core_props(self):
     core_props = CoreProperties.default()
     # verify -----------------------
     assert_that(core_props, is_(instance_of(CoreProperties)))
     assert_that(core_props.content_type, is_(CT.OPC_CORE_PROPERTIES))
     assert_that(core_props.partname, is_('/docProps/core.xml'))
     assert_that(core_props._element, is_(instance_of(CT_CoreProperties)))
     assert_that(core_props.title, is_('PowerPoint Presentation'))
     assert_that(core_props.last_modified_by, is_('python-pptx'))
     assert_that(core_props.revision, is_(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_that(modified_timedelta, less_than(max_expected_timedelta))