_id
stringlengths 2
7
| title
stringlengths 1
88
| partition
stringclasses 3
values | text
stringlengths 75
19.8k
| language
stringclasses 1
value | meta_information
dict |
|---|---|---|---|---|---|
q20200
|
GetFile
|
train
|
def GetFile(message=None, title=None, directory=None, fileName=None,
allowsMultipleSelection=False, fileTypes=None):
"""
An get file dialog.
Optionally a `message`, `title`, `directory`, `fileName` and
`allowsMultipleSelection` can be provided.
::
from fontParts.ui import GetFile
print(GetFile())
"""
return dispatcher["GetFile"](message=message, title=title, directory=directory,
fileName=fileName,
allowsMultipleSelection=allowsMultipleSelection,
fileTypes=fileTypes)
|
python
|
{
"resource": ""
}
|
q20201
|
Message
|
train
|
def Message(message, title='FontParts', informativeText=""):
"""
An message dialog.
Optionally a `message`, `title` and `informativeText` can be provided.
::
from fontParts.ui import Message
print(Message("This is a message"))
"""
return dispatcher["Message"](message=message, title=title,
informativeText=informativeText)
|
python
|
{
"resource": ""
}
|
q20202
|
SearchList
|
train
|
def SearchList(items, message="Select an item:", title='FontParts'):
"""
A dialgo to search a given list.
Optionally a `message`, `title` and `allFonts` can be provided.
::
from fontParts.ui import SearchList
result = SearchList(["a", "b", "c"])
print(result)
"""
return dispatcher["SearchList"](items=items, message=message, title=title)
|
python
|
{
"resource": ""
}
|
q20203
|
SelectFont
|
train
|
def SelectFont(message="Select a font:", title='FontParts', allFonts=None):
"""
Select a font from all open fonts.
Optionally a `message`, `title` and `allFonts` can be provided.
If `allFonts` is `None` it will list all open fonts.
::
from fontParts.ui import SelectFont
font = SelectFont()
print(font)
"""
return dispatcher["SelectFont"](message=message, title=title, allFonts=allFonts)
|
python
|
{
"resource": ""
}
|
q20204
|
SelectGlyph
|
train
|
def SelectGlyph(aFont, message="Select a glyph:", title='FontParts'):
"""
Select a glyph for a given font.
Optionally a `message` and `title` can be provided.
::
from fontParts.ui import SelectGlyph
font = CurrentFont()
glyph = SelectGlyph(font)
print(glyph)
"""
return dispatcher["SelectGlyph"](aFont=aFont, message=message, title=title)
|
python
|
{
"resource": ""
}
|
q20205
|
ProgressBar
|
train
|
def ProgressBar(title="RoboFab...", ticks=None, label=""):
"""
A progess bar dialog.
Optionally a `title`, `ticks` and `label` can be provided.
::
from fontParts.ui import ProgressBar
bar = ProgressBar()
# do something
bar.close()
"""
return dispatcher["ProgressBar"](title=title, ticks=ticks, label=label)
|
python
|
{
"resource": ""
}
|
q20206
|
BasePoint._get_index
|
train
|
def _get_index(self):
"""
Get the point's index.
This must return an ``int``.
Subclasses may override this method.
"""
contour = self.contour
if contour is None:
return None
return contour.points.index(self)
|
python
|
{
"resource": ""
}
|
q20207
|
BaseObject.copy
|
train
|
def copy(self):
"""
Copy this object into a new object of the same type.
The returned object will not have a parent object.
"""
copyClass = self.copyClass
if copyClass is None:
copyClass = self.__class__
copied = copyClass()
copied.copyData(self)
return copied
|
python
|
{
"resource": ""
}
|
q20208
|
BaseObject.copyData
|
train
|
def copyData(self, source):
"""
Subclasses may override this method.
If so, they should call the super.
"""
for attr in self.copyAttributes:
selfValue = getattr(self, attr)
sourceValue = getattr(source, attr)
if isinstance(selfValue, BaseObject):
selfValue.copyData(sourceValue)
else:
setattr(self, attr, sourceValue)
|
python
|
{
"resource": ""
}
|
q20209
|
TransformationMixin.transformBy
|
train
|
def transformBy(self, matrix, origin=None):
"""
Transform the object.
>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0))
>>> obj.transformBy((0.5, 0, 0, 2.0, 10, 0), origin=(500, 500))
**matrix** must be a :ref:`type-transformation`.
**origin** defines the point at with the transformation
should originate. It must be a :ref:`type-coordinate`
or ``None``. The default is ``(0, 0)``.
"""
matrix = normalizers.normalizeTransformationMatrix(matrix)
if origin is None:
origin = (0, 0)
origin = normalizers.normalizeCoordinateTuple(origin)
if origin is not None:
t = transform.Transform()
oX, oY = origin
t = t.translate(oX, oY)
t = t.transform(matrix)
t = t.translate(-oX, -oY)
matrix = tuple(t)
self._transformBy(matrix)
|
python
|
{
"resource": ""
}
|
q20210
|
TransformationMixin.moveBy
|
train
|
def moveBy(self, value):
"""
Move the object.
>>> obj.transformBy((10, 0))
**value** must be an iterable containing two
:ref:`type-int-float` values defining the x and y
values to move the object by.
"""
value = normalizers.normalizeTransformationOffset(value)
self._moveBy(value)
|
python
|
{
"resource": ""
}
|
q20211
|
TransformationMixin.scaleBy
|
train
|
def scaleBy(self, value, origin=None):
"""
Scale the object.
>>> obj.transformBy(2.0)
>>> obj.transformBy((0.5, 2.0), origin=(500, 500))
**value** must be an iterable containing two
:ref:`type-int-float` values defining the x and y
values to scale the object by. **origin** defines the
point at with the scale should originate. It must be
a :ref:`type-coordinate` or ``None``. The default is
``(0, 0)``.
"""
value = normalizers.normalizeTransformationScale(value)
if origin is None:
origin = (0, 0)
origin = normalizers.normalizeCoordinateTuple(origin)
self._scaleBy(value, origin=origin)
|
python
|
{
"resource": ""
}
|
q20212
|
TransformationMixin.rotateBy
|
train
|
def rotateBy(self, value, origin=None):
"""
Rotate the object.
>>> obj.transformBy(45)
>>> obj.transformBy(45, origin=(500, 500))
**value** must be a :ref:`type-int-float` values
defining the angle to rotate the object by. **origin**
defines the point at with the rotation should originate.
It must be a :ref:`type-coordinate` or ``None``.
The default is ``(0, 0)``.
"""
value = normalizers.normalizeRotationAngle(value)
if origin is None:
origin = (0, 0)
origin = normalizers.normalizeCoordinateTuple(origin)
self._rotateBy(value, origin=origin)
|
python
|
{
"resource": ""
}
|
q20213
|
TransformationMixin.skewBy
|
train
|
def skewBy(self, value, origin=None):
"""
Skew the object.
>>> obj.skewBy(11)
>>> obj.skewBy((25, 10), origin=(500, 500))
**value** must be rone of the following:
* single :ref:`type-int-float` indicating the
value to skew the x direction by.
* iterable cointaining type :ref:`type-int-float`
defining the values to skew the x and y directions by.
**origin** defines the point at with the skew should
originate. It must be a :ref:`type-coordinate` or
``None``. The default is ``(0, 0)``.
"""
value = normalizers.normalizeTransformationSkewAngle(value)
if origin is None:
origin = (0, 0)
origin = normalizers.normalizeCoordinateTuple(origin)
self._skewBy(value, origin=origin)
|
python
|
{
"resource": ""
}
|
q20214
|
BaseInfo.fromMathInfo
|
train
|
def fromMathInfo(self, mathInfo, guidelines=True):
"""
Replaces the contents of this info object with the contents of ``mathInfo``.
>>> font.fromMathInfo(mg)
``mathInfo`` must be an object following the
`MathInfo protocol <https://github.com/typesupply/fontMath>`_.
"""
return self._fromMathInfo(mathInfo, guidelines=guidelines)
|
python
|
{
"resource": ""
}
|
q20215
|
BaseInfo.interpolate
|
train
|
def interpolate(self, factor, minInfo, maxInfo, round=True, suppressError=True):
"""
Interpolate all pairs between minInfo and maxInfo.
The interpolation occurs on a 0 to 1.0 range where minInfo
is located at 0 and maxInfo is located at 1.0.
factor is the interpolation value. It may be less than 0
and greater than 1.0. It may be a number (integer, float)
or a tuple of two numbers. If it is a tuple, the first
number indicates the x factor and the second number
indicates the y factor.
round indicates if the result should be rounded to integers.
suppressError indicates if incompatible data should be ignored
or if an error should be raised when such incompatibilities are found.
"""
factor = normalizers.normalizeInterpolationFactor(factor)
if not isinstance(minInfo, BaseInfo):
raise TypeError(("Interpolation to an instance of %r can not be "
"performed from an instance of %r.") %
(self.__class__.__name__, minInfo.__class__.__name__))
if not isinstance(maxInfo, BaseInfo):
raise TypeError(("Interpolation to an instance of %r can not be "
"performed from an instance of %r.") %
(self.__class__.__name__, maxInfo.__class__.__name__))
round = normalizers.normalizeBoolean(round)
suppressError = normalizers.normalizeBoolean(suppressError)
self._interpolate(factor, minInfo, maxInfo,
round=round, suppressError=suppressError)
|
python
|
{
"resource": ""
}
|
q20216
|
autoprefixCSS
|
train
|
def autoprefixCSS(sassPath):
'''
Take CSS file and automatically add browser prefixes with postCSS autoprefixer
'''
print("Autoprefixing CSS")
cssPath = os.path.splitext(sassPath)[0] + ".css"
command = "postcss --use autoprefixer --autoprefixer.browsers '> 5%' -o" + cssPath + " " + cssPath
subprocess.call(command, shell=True)
|
python
|
{
"resource": ""
}
|
q20217
|
BaseFont.generate
|
train
|
def generate(self, format, path=None, **environmentOptions):
"""
Generate the font to another format.
>>> font.generate("otfcff")
>>> font.generate("otfcff", "/path/to/my/font.otf")
**format** defines the file format to output.
Standard format identifiers can be found in :attr:`BaseFont.generateFormatToExtension`:
Environments are not required to support all of these
and environments may define their own format types.
**path** defines the location where the new file should
be created. If a file already exists at that location,
it will be overwritten by the new file. If **path** defines
a directory, the file will be output as the current
file name, with the appropriate suffix for the format,
into the given directory. If no **path** is given, the
file will be output into the same directory as the source
font with the file named with the current file name,
with the appropriate suffix for the format.
Environments may allow unique keyword arguments in this
method. For example, if a tool allows decomposing components
during a generate routine it may allow this:
>>> font.generate("otfcff", "/p/f.otf", decompose=True)
"""
import warnings
if format is None:
raise ValueError("The format must be defined when generating.")
elif not isinstance(format, basestring):
raise TypeError("The format must be defined as a string.")
env = {}
for key, value in environmentOptions.items():
valid = self._isValidGenerateEnvironmentOption(key)
if not valid:
warnings.warn("The %s argument is not supported "
"in this environment." % key, UserWarning)
env[key] = value
environmentOptions = env
ext = self.generateFormatToExtension(format, "." + format)
if path is None and self.path is None:
raise IOError(("The file cannot be generated because an "
"output path was not defined."))
elif path is None:
path = os.path.splitext(self.path)[0]
path += ext
elif os.path.isdir(path):
if self.path is None:
raise IOError(("The file cannot be generated because "
"the file does not have a path."))
fileName = os.path.basename(self.path)
fileName += ext
path = os.path.join(path, fileName)
path = normalizers.normalizeFilePath(path)
return self._generate(
format=format,
path=path,
environmentOptions=environmentOptions
)
|
python
|
{
"resource": ""
}
|
q20218
|
BaseFont.appendGuideline
|
train
|
def appendGuideline(self, position=None, angle=None, name=None, color=None, guideline=None):
"""
Append a new guideline to the font.
>>> guideline = font.appendGuideline((50, 0), 90)
>>> guideline = font.appendGuideline((0, 540), 0, name="overshoot",
>>> color=(0, 0, 0, 0.2))
**position** must be a :ref:`type-coordinate`
indicating the position of the guideline.
**angle** indicates the :ref:`type-angle` of
the guideline. **name** indicates the name
for the guideline. This must be a :ref:`type-string`
or ``None``. **color** indicates the color for
the guideline. This must be a :ref:`type-color`
or ``None``. This will return the newly created
:class:`BaseGuidline` object.
``guideline`` may be a :class:`BaseGuideline` object from which
attribute values will be copied. If ``position``, ``angle``, ``name``
or ``color`` are specified as arguments, those values will be used
instead of the values in the given guideline object.
"""
identifier = None
if guideline is not None:
guideline = normalizers.normalizeGuideline(guideline)
if position is None:
position = guideline.position
if angle is None:
angle = guideline.angle
if name is None:
name = guideline.name
if color is None:
color = guideline.color
if guideline.identifier is not None:
existing = set([g.identifier for g in self.guidelines if g.identifier is not None])
if guideline.identifier not in existing:
identifier = guideline.identifier
position = normalizers.normalizeCoordinateTuple(position)
angle = normalizers.normalizeRotationAngle(angle)
if name is not None:
name = normalizers.normalizeGuidelineName(name)
if color is not None:
color = normalizers.normalizeColor(color)
identifier = normalizers.normalizeIdentifier(identifier)
guideline = self._appendGuideline(position, angle, name=name, color=color, identifier=identifier)
guideline.font = self
return guideline
|
python
|
{
"resource": ""
}
|
q20219
|
BaseFont.interpolate
|
train
|
def interpolate(self, factor, minFont, maxFont,
round=True, suppressError=True):
"""
Interpolate all possible data in the font.
>>> font.interpolate(0.5, otherFont1, otherFont2)
>>> font.interpolate((0.5, 2.0), otherFont1, otherFont2, round=False)
The interpolation occurs on a 0 to 1.0 range where **minFont**
is located at 0 and **maxFont** is located at 1.0. **factor**
is the interpolation value. It may be less than 0 and greater
than 1.0. It may be a :ref:`type-int-float` or a tuple of
two :ref:`type-int-float`. If it is a tuple, the first
number indicates the x factor and the second number indicates
the y factor. **round** indicates if the result should be
rounded to integers. **suppressError** indicates if incompatible
data should be ignored or if an error should be raised when
such incompatibilities are found.
"""
factor = normalizers.normalizeInterpolationFactor(factor)
if not isinstance(minFont, BaseFont):
raise TypeError(("Interpolation to an instance of %r can not be "
"performed from an instance of %r.")
% (self.__class__.__name__, minFont.__class__.__name__))
if not isinstance(maxFont, BaseFont):
raise TypeError(("Interpolation to an instance of %r can not be "
"performed from an instance of %r.")
% (self.__class__.__name__, maxFont.__class__.__name__))
round = normalizers.normalizeBoolean(round)
suppressError = normalizers.normalizeBoolean(suppressError)
self._interpolate(factor, minFont, maxFont,
round=round, suppressError=suppressError)
|
python
|
{
"resource": ""
}
|
q20220
|
BaseContour.getIdentifierForPoint
|
train
|
def getIdentifierForPoint(self, point):
"""
Create a unique identifier for and assign it to ``point``.
If the point already has an identifier, the existing
identifier will be returned.
>>> contour.getIdentifierForPoint(point)
'ILHGJlygfds'
``point`` must be a :class:`BasePoint`. The returned value
will be a :ref:`type-identifier`.
"""
point = normalizers.normalizePoint(point)
return self._getIdentifierforPoint(point)
|
python
|
{
"resource": ""
}
|
q20221
|
BaseContour.contourInside
|
train
|
def contourInside(self, otherContour):
"""
Determine if ``otherContour`` is in the black or white of this contour.
>>> contour.contourInside(otherContour)
True
``contour`` must be a :class:`BaseContour`.
"""
otherContour = normalizers.normalizeContour(otherContour)
return self._contourInside(otherContour)
|
python
|
{
"resource": ""
}
|
q20222
|
BaseContour.appendSegment
|
train
|
def appendSegment(self, type=None, points=None, smooth=False, segment=None):
"""
Append a segment to the contour.
"""
if segment is not None:
if type is not None:
type = segment.type
if points is None:
points = [(point.x, point.y) for point in segment.points]
smooth = segment.smooth
type = normalizers.normalizeSegmentType(type)
pts = []
for pt in points:
pt = normalizers.normalizeCoordinateTuple(pt)
pts.append(pt)
points = pts
smooth = normalizers.normalizeBoolean(smooth)
self._appendSegment(type=type, points=points, smooth=smooth)
|
python
|
{
"resource": ""
}
|
q20223
|
BaseContour.insertSegment
|
train
|
def insertSegment(self, index, type=None, points=None, smooth=False, segment=None):
"""
Insert a segment into the contour.
"""
if segment is not None:
if type is not None:
type = segment.type
if points is None:
points = [(point.x, point.y) for point in segment.points]
smooth = segment.smooth
index = normalizers.normalizeIndex(index)
type = normalizers.normalizeSegmentType(type)
pts = []
for pt in points:
pt = normalizers.normalizeCoordinateTuple(pt)
pts.append(pt)
points = pts
smooth = normalizers.normalizeBoolean(smooth)
self._insertSegment(index=index, type=type,
points=points, smooth=smooth)
|
python
|
{
"resource": ""
}
|
q20224
|
BaseContour.removeSegment
|
train
|
def removeSegment(self, segment, preserveCurve=False):
"""
Remove segment from the contour.
If ``preserveCurve`` is set to ``True`` an attempt
will be made to preserve the shape of the curve
if the environment supports that functionality.
"""
if not isinstance(segment, int):
segment = self.segments.index(segment)
segment = normalizers.normalizeIndex(segment)
if segment >= self._len__segments():
raise ValueError("No segment located at index %d." % segment)
preserveCurve = normalizers.normalizeBoolean(preserveCurve)
self._removeSegment(segment, preserveCurve)
|
python
|
{
"resource": ""
}
|
q20225
|
BaseContour._removeSegment
|
train
|
def _removeSegment(self, segment, preserveCurve, **kwargs):
"""
segment will be a valid segment index.
preserveCurve will be a boolean.
Subclasses may override this method.
"""
segment = self.segments[segment]
for point in segment.points:
self.removePoint(point, preserveCurve)
|
python
|
{
"resource": ""
}
|
q20226
|
BaseContour.setStartSegment
|
train
|
def setStartSegment(self, segment):
"""
Set the first segment on the contour.
segment can be a segment object or an index.
"""
segments = self.segments
if not isinstance(segment, int):
segmentIndex = segments.index(segment)
else:
segmentIndex = segment
if len(self.segments) < 2:
return
if segmentIndex == 0:
return
if segmentIndex >= len(segments):
raise ValueError(("The contour does not contain a segment "
"at index %d" % segmentIndex))
self._setStartSegment(segmentIndex)
|
python
|
{
"resource": ""
}
|
q20227
|
BaseContour.appendBPoint
|
train
|
def appendBPoint(self, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
"""
Append a bPoint to the contour.
"""
if bPoint is not None:
if type is None:
type = bPoint.type
if anchor is None:
anchor = bPoint.anchor
if bcpIn is None:
bcpIn = bPoint.bcpIn
if bcpOut is None:
bcpOut = bPoint.bcpOut
type = normalizers.normalizeBPointType(type)
anchor = normalizers.normalizeCoordinateTuple(anchor)
if bcpIn is None:
bcpIn = (0, 0)
bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
if bcpOut is None:
bcpOut = (0, 0)
bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
self._appendBPoint(type, anchor, bcpIn=bcpIn, bcpOut=bcpOut)
|
python
|
{
"resource": ""
}
|
q20228
|
BaseContour.insertBPoint
|
train
|
def insertBPoint(self, index, type=None, anchor=None, bcpIn=None, bcpOut=None, bPoint=None):
"""
Insert a bPoint at index in the contour.
"""
if bPoint is not None:
if type is None:
type = bPoint.type
if anchor is None:
anchor = bPoint.anchor
if bcpIn is None:
bcpIn = bPoint.bcpIn
if bcpOut is None:
bcpOut = bPoint.bcpOut
index = normalizers.normalizeIndex(index)
type = normalizers.normalizeBPointType(type)
anchor = normalizers.normalizeCoordinateTuple(anchor)
if bcpIn is None:
bcpIn = (0, 0)
bcpIn = normalizers.normalizeCoordinateTuple(bcpIn)
if bcpOut is None:
bcpOut = (0, 0)
bcpOut = normalizers.normalizeCoordinateTuple(bcpOut)
self._insertBPoint(index=index, type=type, anchor=anchor,
bcpIn=bcpIn, bcpOut=bcpOut)
|
python
|
{
"resource": ""
}
|
q20229
|
BaseContour.removeBPoint
|
train
|
def removeBPoint(self, bPoint):
"""
Remove the bpoint from the contour.
bpoint can be a point object or an index.
"""
if not isinstance(bPoint, int):
bPoint = bPoint.index
bPoint = normalizers.normalizeIndex(bPoint)
if bPoint >= self._len__points():
raise ValueError("No bPoint located at index %d." % bPoint)
self._removeBPoint(bPoint)
|
python
|
{
"resource": ""
}
|
q20230
|
BaseContour._removeBPoint
|
train
|
def _removeBPoint(self, index, **kwargs):
"""
index will be a valid index.
Subclasses may override this method.
"""
bPoint = self.bPoints[index]
nextSegment = bPoint._nextSegment
offCurves = nextSegment.offCurve
if offCurves:
offCurve = offCurves[0]
self.removePoint(offCurve)
segment = bPoint._segment
offCurves = segment.offCurve
if offCurves:
offCurve = offCurves[-1]
self.removePoint(offCurve)
self.removePoint(bPoint._point)
|
python
|
{
"resource": ""
}
|
q20231
|
BaseContour.appendPoint
|
train
|
def appendPoint(self, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
"""
Append a point to the contour.
"""
if point is not None:
if position is None:
position = point.position
type = point.type
smooth = point.smooth
if name is None:
name = point.name
if identifier is not None:
identifier = point.identifier
self.insertPoint(
len(self.points),
position=position,
type=type,
smooth=smooth,
name=name,
identifier=identifier
)
|
python
|
{
"resource": ""
}
|
q20232
|
BaseContour.insertPoint
|
train
|
def insertPoint(self, index, position=None, type="line", smooth=False, name=None, identifier=None, point=None):
"""
Insert a point into the contour.
"""
if point is not None:
if position is None:
position = point.position
type = point.type
smooth = point.smooth
if name is None:
name = point.name
if identifier is not None:
identifier = point.identifier
index = normalizers.normalizeIndex(index)
position = normalizers.normalizeCoordinateTuple(position)
type = normalizers.normalizePointType(type)
smooth = normalizers.normalizeBoolean(smooth)
if name is not None:
name = normalizers.normalizePointName(name)
if identifier is not None:
identifier = normalizers.normalizeIdentifier(identifier)
self._insertPoint(
index,
position=position,
type=type,
smooth=smooth,
name=name,
identifier=identifier
)
|
python
|
{
"resource": ""
}
|
q20233
|
BaseContour.removePoint
|
train
|
def removePoint(self, point, preserveCurve=False):
"""
Remove the point from the contour.
point can be a point object or an index.
If ``preserveCurve`` is set to ``True`` an attempt
will be made to preserve the shape of the curve
if the environment supports that functionality.
"""
if not isinstance(point, int):
point = self.points.index(point)
point = normalizers.normalizeIndex(point)
if point >= self._len__points():
raise ValueError("No point located at index %d." % point)
preserveCurve = normalizers.normalizeBoolean(preserveCurve)
self._removePoint(point, preserveCurve)
|
python
|
{
"resource": ""
}
|
q20234
|
BaseKerning.asDict
|
train
|
def asDict(self, returnIntegers=True):
"""
Return the Kerning as a ``dict``.
This is a backwards compatibility method.
"""
d = {}
for k, v in self.items():
d[k] = v if not returnIntegers else normalizers.normalizeRounding(v)
return d
|
python
|
{
"resource": ""
}
|
q20235
|
BaseSimpleType.validate_float
|
train
|
def validate_float(cls, value):
"""
Note that int values are accepted.
"""
if not isinstance(value, (int, float)):
raise TypeError(
"value must be a number, got %s" % type(value)
)
|
python
|
{
"resource": ""
}
|
q20236
|
ST_Angle.convert_to_xml
|
train
|
def convert_to_xml(cls, value):
"""
Convert signed angle float like -42.42 to int 60000 per degree,
normalized to positive value.
"""
# modulo normalizes negative and >360 degree values
rot = int(round(value * cls.DEGREE_INCREMENTS)) % cls.THREE_SIXTY
return str(rot)
|
python
|
{
"resource": ""
}
|
q20237
|
ST_PositiveFixedAngle.convert_to_xml
|
train
|
def convert_to_xml(cls, degrees):
"""Convert signed angle float like -427.42 to int 60000 per degree.
Value is normalized to a positive value less than 360 degrees.
"""
if degrees < 0.0:
degrees %= -360
degrees += 360
elif degrees > 0.0:
degrees %= 360
return str(int(round(degrees * cls.DEGREE_INCREMENTS)))
|
python
|
{
"resource": ""
}
|
q20238
|
LayoutPlaceholder._base_placeholder
|
train
|
def _base_placeholder(self):
"""
Return the master placeholder this layout placeholder inherits from.
"""
base_ph_type = {
PP_PLACEHOLDER.BODY: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.CHART: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.BITMAP: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.CENTER_TITLE: PP_PLACEHOLDER.TITLE,
PP_PLACEHOLDER.ORG_CHART: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.DATE: PP_PLACEHOLDER.DATE,
PP_PLACEHOLDER.FOOTER: PP_PLACEHOLDER.FOOTER,
PP_PLACEHOLDER.MEDIA_CLIP: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.OBJECT: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.PICTURE: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.SLIDE_NUMBER: PP_PLACEHOLDER.SLIDE_NUMBER,
PP_PLACEHOLDER.SUBTITLE: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.TABLE: PP_PLACEHOLDER.BODY,
PP_PLACEHOLDER.TITLE: PP_PLACEHOLDER.TITLE,
}[self._element.ph_type]
slide_master = self.part.slide_master
return slide_master.placeholders.get(base_ph_type, None)
|
python
|
{
"resource": ""
}
|
q20239
|
NotesSlidePlaceholder._base_placeholder
|
train
|
def _base_placeholder(self):
"""
Return the notes master placeholder this notes slide placeholder
inherits from, or |None| if no placeholder of the matching type is
present.
"""
notes_master = self.part.notes_master
ph_type = self.element.ph_type
return notes_master.placeholders.get(ph_type=ph_type)
|
python
|
{
"resource": ""
}
|
q20240
|
GroupShape.shapes
|
train
|
def shapes(self):
"""|GroupShapes| object for this group.
The |GroupShapes| object provides access to the group's member shapes
and provides methods for adding new ones.
"""
from pptx.shapes.shapetree import GroupShapes
return GroupShapes(self._element, self)
|
python
|
{
"resource": ""
}
|
q20241
|
load_adjustment_values
|
train
|
def load_adjustment_values():
"""load adjustment values and their default values from XML"""
# parse XML --------------------------------------------
thisdir = os.path.split(__file__)[0]
prst_defs_relpath = (
'ISO-IEC-29500-1/schemas/dml-geometries/OfficeOpenXML-DrawingMLGeomet'
'ries/presetShapeDefinitions.xml'
)
prst_defs_path = os.path.join(thisdir, prst_defs_relpath)
presetShapeDefinitions = objectify.parse(prst_defs_path).getroot()
# load individual records into tuples to return --------
ns = 'http://schemas.openxmlformats.org/drawingml/2006/main'
avLst_qn = '{%s}avLst' % ns
adjustment_values = []
for shapedef in presetShapeDefinitions.iterchildren():
prst = shapedef.tag
try:
avLst = shapedef[avLst_qn]
except AttributeError:
continue
for idx, gd in enumerate(avLst.gd):
name = gd.get('name')
val = int(gd.get('fmla')[4:]) # strip off leading 'val '
record = (prst, idx+1, name, val)
adjustment_values.append(record)
return adjustment_values
|
python
|
{
"resource": ""
}
|
q20242
|
print_mso_auto_shape_type_spec
|
train
|
def print_mso_auto_shape_type_spec():
"""print spec dictionary for msoAutoShapeType"""
auto_shape_types = MsoAutoShapeTypeCollection.load(sort='const_name')
out = render_mso_auto_shape_type_spec(auto_shape_types)
print out
|
python
|
{
"resource": ""
}
|
q20243
|
render_desc
|
train
|
def render_desc(desc):
"""calculate desc string, wrapped if too long"""
desc = desc + '.'
desc_lines = split_len(desc, 54)
if len(desc_lines) > 1:
join_str = "'\n%s'" % (' '*21)
lines_str = join_str.join(desc_lines)
out = "('%s')" % lines_str
else:
out = "'%s'" % desc_lines[0]
return out
|
python
|
{
"resource": ""
}
|
q20244
|
parse_args
|
train
|
def parse_args(spectypes):
"""
Return arguments object formed by parsing the command line used to launch
the program.
"""
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument(
"-c", "--constants",
help="emit constants instead of spec dict",
action="store_true"
)
arg_parser.add_argument(
"spectype",
help="specifies the spec type to be generated",
choices=spectypes
)
return arg_parser.parse_args()
|
python
|
{
"resource": ""
}
|
q20245
|
MsoAutoShapeTypeCollection.load_adjustment_values
|
train
|
def load_adjustment_values(self, c):
"""load adjustment values for auto shape types in self"""
# retrieve auto shape types in const_name order --------
for mast in self:
# retriev adj vals for this auto shape type --------
c.execute(
' SELECT name, val\n'
' FROM adjustment_values\n'
' WHERE prst = ?\n'
'ORDER BY seq_nmbr', (mast.prst,)
)
for name, val in c:
mast.adj_vals.append(AdjustmentValue(name, val))
|
python
|
{
"resource": ""
}
|
q20246
|
_required_attribute
|
train
|
def _required_attribute(element, name, default):
"""
Add attribute with default value to element if it doesn't already exist.
"""
if element.get(name) is None:
element.set(name, default)
|
python
|
{
"resource": ""
}
|
q20247
|
ComplexType.add_element
|
train
|
def add_element(self, element):
"""
Add an element to this ComplexType and also append it to element dict
of parent type graph.
"""
self.elements.append(element)
self.type_graph.add_element(element)
|
python
|
{
"resource": ""
}
|
q20248
|
NotesSlide.notes_placeholder
|
train
|
def notes_placeholder(self):
"""
Return the notes placeholder on this notes slide, the shape that
contains the actual notes text. Return |None| if no notes placeholder
is present; while this is probably uncommon, it can happen if the
notes master does not have a body placeholder, or if the notes
placeholder has been deleted from the notes slide.
"""
for placeholder in self.placeholders:
if placeholder.placeholder_format.type == PP_PLACEHOLDER.BODY:
return placeholder
return None
|
python
|
{
"resource": ""
}
|
q20249
|
SlideLayout.iter_cloneable_placeholders
|
train
|
def iter_cloneable_placeholders(self):
"""
Generate a reference to each layout placeholder on this slide layout
that should be cloned to a slide when the layout is applied to that
slide.
"""
latent_ph_types = (
PP_PLACEHOLDER.DATE, PP_PLACEHOLDER.FOOTER,
PP_PLACEHOLDER.SLIDE_NUMBER
)
for ph in self.placeholders:
if ph.element.ph_type not in latent_ph_types:
yield ph
|
python
|
{
"resource": ""
}
|
q20250
|
SlideLayout.used_by_slides
|
train
|
def used_by_slides(self):
"""Tuple of slide objects based on this slide layout."""
# ---getting Slides collection requires going around the horn a bit---
slides = self.part.package.presentation_part.presentation.slides
return tuple(s for s in slides if s.slide_layout == self)
|
python
|
{
"resource": ""
}
|
q20251
|
Presentation.slides
|
train
|
def slides(self):
"""
|Slides| object containing the slides in this presentation.
"""
sldIdLst = self._element.get_or_add_sldIdLst()
self.part.rename_slide_parts([sldId.rId for sldId in sldIdLst])
return Slides(sldIdLst, self)
|
python
|
{
"resource": ""
}
|
q20252
|
FreeformBuilder.new
|
train
|
def new(cls, shapes, start_x, start_y, x_scale, y_scale):
"""Return a new |FreeformBuilder| object.
The initial pen location is specified (in local coordinates) by
(*start_x*, *start_y*).
"""
return cls(
shapes, int(round(start_x)), int(round(start_y)),
x_scale, y_scale
)
|
python
|
{
"resource": ""
}
|
q20253
|
FreeformBuilder.convert_to_shape
|
train
|
def convert_to_shape(self, origin_x=0, origin_y=0):
"""Return new freeform shape positioned relative to specified offset.
*origin_x* and *origin_y* locate the origin of the local coordinate
system in slide coordinates (EMU), perhaps most conveniently by use
of a |Length| object.
Note that this method may be called more than once to add multiple
shapes of the same geometry in different locations on the slide.
"""
sp = self._add_freeform_sp(origin_x, origin_y)
path = self._start_path(sp)
for drawing_operation in self:
drawing_operation.apply_operation_to(path)
return self._shapes._shape_factory(sp)
|
python
|
{
"resource": ""
}
|
q20254
|
FreeformBuilder.shape_offset_x
|
train
|
def shape_offset_x(self):
"""Return x distance of shape origin from local coordinate origin.
The returned integer represents the leftmost extent of the freeform
shape, in local coordinates. Note that the bounding box of the shape
need not start at the local origin.
"""
min_x = self._start_x
for drawing_operation in self:
if hasattr(drawing_operation, 'x'):
min_x = min(min_x, drawing_operation.x)
return min_x
|
python
|
{
"resource": ""
}
|
q20255
|
FreeformBuilder.shape_offset_y
|
train
|
def shape_offset_y(self):
"""Return y distance of shape origin from local coordinate origin.
The returned integer represents the topmost extent of the freeform
shape, in local coordinates. Note that the bounding box of the shape
need not start at the local origin.
"""
min_y = self._start_y
for drawing_operation in self:
if hasattr(drawing_operation, 'y'):
min_y = min(min_y, drawing_operation.y)
return min_y
|
python
|
{
"resource": ""
}
|
q20256
|
FreeformBuilder._add_line_segment
|
train
|
def _add_line_segment(self, x, y):
"""Add a |_LineSegment| operation to the drawing sequence."""
self._drawing_operations.append(_LineSegment.new(self, x, y))
|
python
|
{
"resource": ""
}
|
q20257
|
FreeformBuilder._dx
|
train
|
def _dx(self):
"""Return integer width of this shape's path in local units."""
min_x = max_x = self._start_x
for drawing_operation in self:
if hasattr(drawing_operation, 'x'):
min_x = min(min_x, drawing_operation.x)
max_x = max(max_x, drawing_operation.x)
return max_x - min_x
|
python
|
{
"resource": ""
}
|
q20258
|
FreeformBuilder._dy
|
train
|
def _dy(self):
"""Return integer height of this shape's path in local units."""
min_y = max_y = self._start_y
for drawing_operation in self:
if hasattr(drawing_operation, 'y'):
min_y = min(min_y, drawing_operation.y)
max_y = max(max_y, drawing_operation.y)
return max_y - min_y
|
python
|
{
"resource": ""
}
|
q20259
|
FreeformBuilder._local_to_shape
|
train
|
def _local_to_shape(self, local_x, local_y):
"""Translate local coordinates point to shape coordinates.
Shape coordinates have the same unit as local coordinates, but are
offset such that the origin of the shape coordinate system (0, 0) is
located at the top-left corner of the shape bounding box.
"""
return (
local_x - self.shape_offset_x,
local_y - self.shape_offset_y
)
|
python
|
{
"resource": ""
}
|
q20260
|
FillFormat.background
|
train
|
def background(self):
"""
Sets the fill type to noFill, i.e. transparent.
"""
noFill = self._xPr.get_or_change_to_noFill()
self._fill = _NoFill(noFill)
|
python
|
{
"resource": ""
}
|
q20261
|
FillFormat.gradient
|
train
|
def gradient(self):
"""Sets the fill type to gradient.
If the fill is not already a gradient, a default gradient is added.
The default gradient corresponds to the default in the built-in
PowerPoint "White" template. This gradient is linear at angle
90-degrees (upward), with two stops. The first stop is Accent-1 with
tint 100%, shade 100%, and satMod 130%. The second stop is Accent-1
with tint 50%, shade 100%, and satMod 350%.
"""
gradFill = self._xPr.get_or_change_to_gradFill()
self._fill = _GradFill(gradFill)
|
python
|
{
"resource": ""
}
|
q20262
|
FillFormat.gradient_stops
|
train
|
def gradient_stops(self):
"""|GradientStops| object providing access to stops of this gradient.
Raises |TypeError| when fill is not gradient (call `fill.gradient()`
first). Each stop represents a color between which the gradient
smoothly transitions.
"""
if self.type != MSO_FILL.GRADIENT:
raise TypeError('Fill is not of type MSO_FILL_TYPE.GRADIENT')
return self._fill.gradient_stops
|
python
|
{
"resource": ""
}
|
q20263
|
FillFormat.patterned
|
train
|
def patterned(self):
"""Selects the pattern fill type.
Note that calling this method does not by itself set a foreground or
background color of the pattern. Rather it enables subsequent
assignments to properties like fore_color to set the pattern and
colors.
"""
pattFill = self._xPr.get_or_change_to_pattFill()
self._fill = _PattFill(pattFill)
|
python
|
{
"resource": ""
}
|
q20264
|
FillFormat.solid
|
train
|
def solid(self):
"""
Sets the fill type to solid, i.e. a solid color. Note that calling
this method does not set a color or by itself cause the shape to
appear with a solid color fill; rather it enables subsequent
assignments to properties like fore_color to set the color.
"""
solidFill = self._xPr.get_or_change_to_solidFill()
self._fill = _SolidFill(solidFill)
|
python
|
{
"resource": ""
}
|
q20265
|
Point.format
|
train
|
def format(self):
"""
The |ChartFormat| object providing access to the shape formatting
properties of this data point, such as line and fill.
"""
dPt = self._ser.get_or_add_dPt_for_point(self._idx)
return ChartFormat(dPt)
|
python
|
{
"resource": ""
}
|
q20266
|
Point.marker
|
train
|
def marker(self):
"""
The |Marker| instance for this point, providing access to the visual
properties of the data point marker, such as fill and line. Setting
these properties overrides any value set at the series level.
"""
dPt = self._ser.get_or_add_dPt_for_point(self._idx)
return Marker(dPt)
|
python
|
{
"resource": ""
}
|
q20267
|
CT_GroupShape.recalculate_extents
|
train
|
def recalculate_extents(self):
"""Adjust x, y, cx, and cy to incorporate all contained shapes.
This would typically be called when a contained shape is added,
removed, or its position or size updated.
This method is recursive "upwards" since a change in a group shape
can change the position and size of its containing group.
"""
if not self.tag == qn('p:grpSp'):
return
x, y, cx, cy = self._child_extents
self.chOff.x = self.x = x
self.chOff.y = self.y = y
self.chExt.cx = self.cx = cx
self.chExt.cy = self.cy = cy
self.getparent().recalculate_extents()
|
python
|
{
"resource": ""
}
|
q20268
|
CT_GroupShape._next_shape_id
|
train
|
def _next_shape_id(self):
"""Return unique shape id suitable for use with a new shape element.
The returned id is the next available positive integer drawing object
id in shape tree, starting from 1 and making use of any gaps in
numbering. In practice, the minimum id is 2 because the spTree
element itself is always assigned id="1".
"""
id_str_lst = self.xpath('//@id')
used_ids = [int(id_str) for id_str in id_str_lst if id_str.isdigit()]
for n in range(1, len(used_ids)+2):
if n not in used_ids:
return n
|
python
|
{
"resource": ""
}
|
q20269
|
CT_PlotArea.iter_xCharts
|
train
|
def iter_xCharts(self):
"""
Generate each xChart child element in document.
"""
plot_tags = (
qn('c:area3DChart'), qn('c:areaChart'), qn('c:bar3DChart'),
qn('c:barChart'), qn('c:bubbleChart'), qn('c:doughnutChart'),
qn('c:line3DChart'), qn('c:lineChart'), qn('c:ofPieChart'),
qn('c:pie3DChart'), qn('c:pieChart'), qn('c:radarChart'),
qn('c:scatterChart'), qn('c:stockChart'), qn('c:surface3DChart'),
qn('c:surfaceChart')
)
for child in self.iterchildren():
if child.tag not in plot_tags:
continue
yield child
|
python
|
{
"resource": ""
}
|
q20270
|
LineFormat.color
|
train
|
def color(self):
"""
The |ColorFormat| instance that provides access to the color settings
for this line. Essentially a shortcut for ``line.fill.fore_color``.
As a side-effect, accessing this property causes the line fill type
to be set to ``MSO_FILL.SOLID``. If this sounds risky for your use
case, use ``line.fill.type`` to non-destructively discover the
existing fill type.
"""
if self.fill.type != MSO_FILL.SOLID:
self.fill.solid()
return self.fill.fore_color
|
python
|
{
"resource": ""
}
|
q20271
|
GraphicFrame.chart_part
|
train
|
def chart_part(self):
"""
The |ChartPart| object containing the chart in this graphic frame.
"""
rId = self._element.chart_rId
chart_part = self.part.related_parts[rId]
return chart_part
|
python
|
{
"resource": ""
}
|
q20272
|
GraphicFrame.table
|
train
|
def table(self):
"""
The |Table| object contained in this graphic frame. Raises
|ValueError| if this graphic frame does not contain a table.
"""
if not self.has_table:
raise ValueError('shape does not contain a table')
tbl = self._element.graphic.graphicData.tbl
return Table(tbl, self)
|
python
|
{
"resource": ""
}
|
q20273
|
TextFitter._fits_inside_predicate
|
train
|
def _fits_inside_predicate(self):
"""
Return a function taking an integer point size argument that returns
|True| if the text in this fitter can be wrapped to fit entirely
within its extents when rendered at that point size.
"""
def predicate(point_size):
"""
Return |True| if the text in *line_source* can be wrapped to fit
entirely within *extents* when rendered at *point_size* using the
font defined in *font_file*.
"""
text_lines = self._wrap_lines(self._line_source, point_size)
cy = _rendered_size('Ty', point_size, self._font_file)[1]
return (cy * len(text_lines)) <= self._height
return predicate
|
python
|
{
"resource": ""
}
|
q20274
|
Categories.levels
|
train
|
def levels(self):
"""
Return a sequence of |CategoryLevel| objects representing the
hierarchy of this category collection. The sequence is empty when the
category collection is not hierarchical, that is, contains only
leaf-level categories. The levels are ordered from the leaf level to
the root level; so the first level will contain the same categories
as this category collection.
"""
cat = self._xChart.cat
if cat is None:
return []
return [CategoryLevel(lvl) for lvl in cat.lvls]
|
python
|
{
"resource": ""
}
|
q20275
|
FontFiles._font_directories
|
train
|
def _font_directories(cls):
"""
Return a sequence of directory paths likely to contain fonts on the
current platform.
"""
if sys.platform.startswith('darwin'):
return cls._os_x_font_directories()
if sys.platform.startswith('win32'):
return cls._windows_font_directories()
raise OSError('unsupported operating system')
|
python
|
{
"resource": ""
}
|
q20276
|
FontFiles._os_x_font_directories
|
train
|
def _os_x_font_directories(cls):
"""
Return a sequence of directory paths on a Mac in which fonts are
likely to be located.
"""
os_x_font_dirs = [
'/Library/Fonts',
'/Network/Library/Fonts',
'/System/Library/Fonts',
]
home = os.environ.get('HOME')
if home is not None:
os_x_font_dirs.extend([
os.path.join(home, 'Library', 'Fonts'),
os.path.join(home, '.fonts')
])
return os_x_font_dirs
|
python
|
{
"resource": ""
}
|
q20277
|
CT_TableCell.is_merge_origin
|
train
|
def is_merge_origin(self):
"""True if cell is top-left in merged cell range."""
if self.gridSpan > 1 and not self.vMerge:
return True
if self.rowSpan > 1 and not self.hMerge:
return True
return False
|
python
|
{
"resource": ""
}
|
q20278
|
CT_TableCell.text
|
train
|
def text(self):
"""str text contained in cell"""
# ---note this shadows lxml _Element.text---
txBody = self.txBody
if txBody is None:
return ''
return '\n'.join([p.text for p in txBody.p_lst])
|
python
|
{
"resource": ""
}
|
q20279
|
CT_TableCell._get_marX
|
train
|
def _get_marX(self, attr_name, default):
"""
Generalized method to get margin values.
"""
if self.tcPr is None:
return Emu(default)
return Emu(int(self.tcPr.get(attr_name, default)))
|
python
|
{
"resource": ""
}
|
q20280
|
TcRange.from_merge_origin
|
train
|
def from_merge_origin(cls, tc):
"""Return instance created from merge-origin tc element."""
other_tc = tc.tbl.tc(
tc.row_idx + tc.rowSpan - 1, # ---other_row_idx
tc.col_idx + tc.gridSpan - 1 # ---other_col_idx
)
return cls(tc, other_tc)
|
python
|
{
"resource": ""
}
|
q20281
|
TcRange.contains_merged_cell
|
train
|
def contains_merged_cell(self):
"""True if one or more cells in range are part of a merged cell."""
for tc in self.iter_tcs():
if tc.gridSpan > 1:
return True
if tc.rowSpan > 1:
return True
if tc.hMerge:
return True
if tc.vMerge:
return True
return False
|
python
|
{
"resource": ""
}
|
q20282
|
TcRange.in_same_table
|
train
|
def in_same_table(self):
"""True if both cells provided to constructor are in same table."""
if self._tc.tbl is self._other_tc.tbl:
return True
return False
|
python
|
{
"resource": ""
}
|
q20283
|
TcRange.move_content_to_origin
|
train
|
def move_content_to_origin(self):
"""Move all paragraphs in range to origin cell."""
tcs = list(self.iter_tcs())
origin_tc = tcs[0]
for spanned_tc in tcs[1:]:
origin_tc.append_ps_from(spanned_tc)
|
python
|
{
"resource": ""
}
|
q20284
|
TcRange._bottom
|
train
|
def _bottom(self):
"""Index of row following last row of range"""
_, top, _, height = self._extents
return top + height
|
python
|
{
"resource": ""
}
|
q20285
|
TcRange._right
|
train
|
def _right(self):
"""Index of column following the last column in range"""
left, _, width, _ = self._extents
return left + width
|
python
|
{
"resource": ""
}
|
q20286
|
DataLabels.font
|
train
|
def font(self):
"""
The |Font| object that provides access to the text properties for
these data labels, such as bold, italic, etc.
"""
defRPr = self._element.defRPr
font = Font(defRPr)
return font
|
python
|
{
"resource": ""
}
|
q20287
|
DataLabel.font
|
train
|
def font(self):
"""The |Font| object providing text formatting for this data label.
This font object is used to customize the appearance of automatically
inserted text, such as the data point value. The font applies to the
entire data label. More granular control of the appearance of custom
data label text is controlled by a font object on runs in the text
frame.
"""
txPr = self._get_or_add_txPr()
text_frame = TextFrame(txPr, self)
paragraph = text_frame.paragraphs[0]
return paragraph.font
|
python
|
{
"resource": ""
}
|
q20288
|
Legend.include_in_layout
|
train
|
def include_in_layout(self):
"""|True| if legend should be located inside plot area.
Read/write boolean specifying whether legend should be placed inside
the plot area. In many cases this will cause it to be superimposed on
the chart itself. Assigning |None| to this property causes any
`c:overlay` element to be removed, which is interpreted the same as
|True|. This use case should rarely be required and assigning
a boolean value is recommended.
"""
overlay = self._element.overlay
if overlay is None:
return True
return overlay.val
|
python
|
{
"resource": ""
}
|
q20289
|
PresentationPart.notes_master_part
|
train
|
def notes_master_part(self):
"""
Return the |NotesMasterPart| object for this presentation. If the
presentation does not have a notes master, one is created from
a default template. The same single instance is returned on each
call.
"""
try:
return self.part_related_by(RT.NOTES_MASTER)
except KeyError:
notes_master_part = NotesMasterPart.create_default(self.package)
self.relate_to(notes_master_part, RT.NOTES_MASTER)
return notes_master_part
|
python
|
{
"resource": ""
}
|
q20290
|
Movie.poster_frame
|
train
|
def poster_frame(self):
"""Return |Image| object containing poster frame for this movie.
Returns |None| if this movie has no poster frame (uncommon).
"""
slide_part, rId = self.part, self._element.blip_rId
if rId is None:
return None
return slide_part.get_image(rId)
|
python
|
{
"resource": ""
}
|
q20291
|
Picture.auto_shape_type
|
train
|
def auto_shape_type(self):
"""Member of MSO_SHAPE indicating masking shape.
A picture can be masked by any of the so-called "auto-shapes"
available in PowerPoint, such as an ellipse or triangle. When
a picture is masked by a shape, the shape assumes the same dimensions
as the picture and the portion of the picture outside the shape
boundaries does not appear. Note the default value for
a newly-inserted picture is `MSO_AUTO_SHAPE_TYPE.RECTANGLE`, which
performs no cropping because the extents of the rectangle exactly
correspond to the extents of the picture.
The available shapes correspond to the members of
:ref:`MsoAutoShapeType`.
The return value can also be |None|, indicating the picture either
has no geometry (not expected) or has custom geometry, like
a freeform shape. A picture with no geometry will have no visible
representation on the slide, although it can be selected. This is
because without geometry, there is no "inside-the-shape" for it to
appear in.
"""
prstGeom = self._pic.spPr.prstGeom
if prstGeom is None: # ---generally means cropped with freeform---
return None
return prstGeom.prst
|
python
|
{
"resource": ""
}
|
q20292
|
Picture.image
|
train
|
def image(self):
"""
An |Image| object providing access to the properties and bytes of the
image in this picture shape.
"""
slide_part, rId = self.part, self._element.blip_rId
if rId is None:
raise ValueError('no embedded image')
return slide_part.get_image(rId)
|
python
|
{
"resource": ""
}
|
q20293
|
_BaseSeries.name
|
train
|
def name(self):
"""
The string label given to this series, appears as the title of the
column for this series in the Excel worksheet. It also appears as the
label for this series in the legend.
"""
names = self._element.xpath('./c:tx//c:pt/c:v/text()')
name = names[0] if names else ''
return name
|
python
|
{
"resource": ""
}
|
q20294
|
_BaseCategorySeries.values
|
train
|
def values(self):
"""
Read-only. A sequence containing the float values for this series, in
the order they appear on the chart.
"""
def iter_values():
val = self._element.val
if val is None:
return
for idx in range(val.ptCount_val):
yield val.pt_v(idx)
return tuple(iter_values())
|
python
|
{
"resource": ""
}
|
q20295
|
TextFrame.clear
|
train
|
def clear(self):
"""
Remove all paragraphs except one empty one.
"""
for p in self._txBody.p_lst[1:]:
self._txBody.remove(p)
p = self.paragraphs[0]
p.clear()
|
python
|
{
"resource": ""
}
|
q20296
|
TextFrame.fit_text
|
train
|
def fit_text(self, font_family='Calibri', max_size=18, bold=False,
italic=False, font_file=None):
"""Fit text-frame text entirely within bounds of its shape.
Make the text in this text frame fit entirely within the bounds of
its shape by setting word wrap on and applying the "best-fit" font
size to all the text it contains. :attr:`TextFrame.auto_size` is set
to :attr:`MSO_AUTO_SIZE.NONE`. The font size will not be set larger
than *max_size* points. If the path to a matching TrueType font is
provided as *font_file*, that font file will be used for the font
metrics. If *font_file* is |None|, best efforts are made to locate
a font file with matchhing *font_family*, *bold*, and *italic*
installed on the current system (usually succeeds if the font is
installed).
"""
# ---no-op when empty as fit behavior not defined for that case---
if self.text == '':
return
font_size = self._best_fit_font_size(
font_family, max_size, bold, italic, font_file
)
self._apply_fit(font_family, font_size, bold, italic)
|
python
|
{
"resource": ""
}
|
q20297
|
TextFrame.paragraphs
|
train
|
def paragraphs(self):
"""
Immutable sequence of |_Paragraph| instances corresponding to the
paragraphs in this text frame. A text frame always contains at least
one paragraph.
"""
return tuple([_Paragraph(p, self) for p in self._txBody.p_lst])
|
python
|
{
"resource": ""
}
|
q20298
|
TextFrame.word_wrap
|
train
|
def word_wrap(self):
"""
Read-write setting determining whether lines of text in this shape
are wrapped to fit within the shape's width. Valid values are True,
False, or None. True and False turn word wrap on and off,
respectively. Assigning None to word wrap causes any word wrap
setting to be removed from the text frame, causing it to inherit this
setting from its style hierarchy.
"""
return {
ST_TextWrappingType.SQUARE: True,
ST_TextWrappingType.NONE: False,
None: None
}[self._txBody.bodyPr.wrap]
|
python
|
{
"resource": ""
}
|
q20299
|
_Paragraph.clear
|
train
|
def clear(self):
"""
Remove all content from this paragraph. Paragraph properties are
preserved. Content includes runs, line breaks, and fields.
"""
for elm in self._element.content_children:
self._element.remove(elm)
return self
|
python
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.