コード例 #1
0
ファイル: import_pptx.py プロジェクト: NiJeLorg/GAHTC
        """Remove all current notes from the slide
        """
        for shape in self.shapes:
            if shape.has_text_frame:
                shape.text_frame.clear()

    def get_slide_runs(self):
        for shape in self.shapes:
            if shape.has_text_frame and shape.is_placeholder:
                for p in shape.text_frame.paragraphs:
                    for run in p.runs:
                        yield run


# Register the <p:notes> root tag
register_element_cls('p:notes', CT_NotesSlide)

# Add our NotesSlide as a valid Part for the notes Content Type
content_type_to_part_class_map[CT.PML_NOTES_SLIDE] = NotesSlide
PartFactory.part_type_for.update(content_type_to_part_class_map)


def strip_non_ascii(string):
    ''' Returns the string without non ASCII characters'''
    stripped = (c for c in string if ord(c) >= 32 or ord(c) <= 126)
    return ''.join(stripped)



class Command(BaseCommand):
    
コード例 #2
0
        """Remove all current notes from the slide
		"""
        for shape in self.shapes:
            if shape.has_text_frame:
                shape.text_frame.clear()

    def get_slide_runs(self):
        for shape in self.shapes:
            if shape.has_text_frame and shape.is_placeholder:
                for p in shape.text_frame.paragraphs:
                    for run in p.runs:
                        yield run


# Register the <p:notes> root tag
register_element_cls('p:notes', CT_NotesSlide)

# Add our NotesSlide as a valid Part for the notes Content Type
content_type_to_part_class_map[CT.PML_NOTES_SLIDE] = NotesSlide
PartFactory.part_type_for.update(content_type_to_part_class_map)


def strip_non_ascii(string):
    ''' Returns the string without non ASCII characters'''
    stripped = (c for c in string if ord(c) >= 32 or ord(c) <= 126)
    return ''.join(stripped)


class Command(BaseCommand):
    def extract_text_images_from_pptx(self):
        prs = Presentation(self.lecturesObject.presentation)
コード例 #3
0
class Geometry2D(BaseOxmlElement):

    avLst = ZeroOrOne("a:avLst")
    gdLst = ZeroOrOne("a:gdLst")
    pathLst = ZeroOrOne("a:pathLst")

#===============================================================================

class PresetShape(Geometry2D):
    """`drawml:PresetShape` element class."""

    name = RequiredAttribute("name", XsdString)

#===============================================================================

oxml.register_element_cls("a:custGeom", Geometry2D)
oxml.register_element_cls("a:gdLst", CT_GeomGuideList)

oxml.register_element_cls("drawml:presetShapeDefinition", PresetShapeDefinition)
oxml.register_element_cls("drawml:presetShape", PresetShape)

#===============================================================================

class Shapes(object):

    definitions_ = {}



    with open(os.path.join(os.path.dirname(__file__), 'presetShapeDefinitions.xml'), 'rb') as defs:
        for defn in PresetShapeDefinition.new(defs.read()):
コード例 #4
0
class CT_ZomChild(BaseOxmlElement):
    """
    Zom standing for 'ZeroOrMore', ``<p:zomChild>`` element, representing an
    optional child element that can appear multiple times in sequence.
    """


class CT_ZooChild(BaseOxmlElement):
    """
    Zoo standing for 'ZeroOrOne', ``<p:zooChild>`` element, an invented
    element for use in testing.
    """


register_element_cls('p:parent',   CT_Parent)
register_element_cls('p:choice',   CT_Choice)
register_element_cls('p:oomChild', CT_OomChild)
register_element_cls('p:zomChild', CT_ZomChild)
register_element_cls('p:zooChild', CT_ZooChild)


class CT_ChoiceBuilder(BaseBuilder):
    __tag__ = 'p:choice'
    __nspfxs__ = ('p',)
    __attrs__ = ()


class CT_Choice2Builder(BaseBuilder):
    __tag__ = 'p:choice2'
    __nspfxs__ = ('p',)
コード例 #5
0
    gdLst = ZeroOrOne("a:gdLst")
    pathLst = ZeroOrOne("a:pathLst")


#===============================================================================


class PresetShape(Geometry2D):
    """`drawml:PresetShape` element class."""

    name = RequiredAttribute("name", XsdString)


#===============================================================================

oxml.register_element_cls("a:custGeom", Geometry2D)
oxml.register_element_cls("a:gdLst", CT_GeomGuideList)

oxml.register_element_cls("drawml:presetShapeDefinition",
                          PresetShapeDefinition)
oxml.register_element_cls("drawml:presetShape", PresetShape)

#===============================================================================


class Shapes(object):
    definitions_ = {}

    with open(
            os.path.join(os.path.dirname(__file__),
                         'presetShapeDefinitions.xml'), 'rb') as defs:
コード例 #6
0
 def it_determines_cust_elm_class_constructed_for_specified_tag(
         self, xml_bytes):
     register_element_cls('a:foo', CustElmCls)
     foo = etree.fromstring(xml_bytes, oxml_parser)
     assert type(foo) is CustElmCls
     assert type(foo.find(qn('a:bar'))) is etree._Element
コード例 #7
0
class CT_ZomChild(BaseOxmlElement):
    """
    Zom standing for 'ZeroOrMore', ``<p:zomChild>`` element, representing an
    optional child element that can appear multiple times in sequence.
    """


class CT_ZooChild(BaseOxmlElement):
    """
    Zoo standing for 'ZeroOrOne', ``<p:zooChild>`` element, an invented
    element for use in testing.
    """


register_element_cls("p:parent", CT_Parent)
register_element_cls("p:choice", CT_Choice)
register_element_cls("p:oomChild", CT_OomChild)
register_element_cls("p:zomChild", CT_ZomChild)
register_element_cls("p:zooChild", CT_ZooChild)


class CT_ChoiceBuilder(BaseBuilder):
    __tag__ = "p:choice"
    __nspfxs__ = ("p",)
    __attrs__ = ()


class CT_Choice2Builder(BaseBuilder):
    __tag__ = "p:choice2"
    __nspfxs__ = ("p",)