class_docstr: Base class for retrieving the outline in a segment-oriented
  way. The PointPen protocol is simple yet also a little tricky,
  so when you need an outline presented as segments but you have
  as points, do use this base implementation as it properly takes
  care of all the edge cases.
class_docstr_tok: ["Base","class","for","retrieving","the","outline","in","a","segment-oriented","way",".","The","PointPen","protocol","is","simple","yet","also","a","little","tricky",",","so","when","you","need","an","outline","presented","as","segments","but","you","have","as","points",",","do","use","this","base","implementation","as","it","properly","takes","care","of","all","the","edge","cases","."]
code: def endPath(self):
      if self.currentPath is None:
          raise PenError("Path not begun.")
      points = self.currentPath
      self.currentPath = None
      if not points:
          return
      if len(points) == 1:
          # Not much more we can do than output a single move segment.
          pt, segmentType, smooth, name, kwargs = points[0]
          segments = [("move", [(pt, smooth, name, kwargs)])]
          self._flushContour(segments)
          return
      segments = []
      if points[0][1] == "move":
          # It's an open contour, insert a "move" segment for the first
          # point and remove that first point from the point list.
          pt, segmentType, smooth, name, kwargs = points[0]
          segments.append(("move", [(pt, smooth, name, kwargs)]))
          points.pop(0)
      else:
          # It's a closed contour. Locate the first on-curve point, and
          # rotate the point list so that it _ends_ with an on-curve
          # point.
          firstOnCurve = None
          for i in range(len(points)):
              segmentType = points[i][1]
              if segmentType is not None:
                  firstOnCurve = i
                  break
          if firstOnCurve is None:
              # Special case for quadratics: a contour with no on-curve
              # points. Add a "None" point. (See also the Pen protocol's
              # qCurveTo() method and fontTools.pens.basePen.py.)
              points.append((None, "qcurve", None, None, None))
          else:
              points = (
                  points[firstOnCurve + 1 :]
                  + points[: firstOnCurve + 1]
              )
  
      currentSegment = []
      for pt, segmentType, smooth, name, kwargs in points:
          currentSegment.append((pt, smooth, name, kwargs))
          if segmentType is None:
              continue
          segments.append((segmentType, currentSegment))
          currentSegment = []
  
      self._flushContour(segments)
  
imports: import math
  from typing import Any, Optional, Tuple, Dict
  from fontTools.pens.basePen import AbstractPen, PenError
  from fontTools.misc.transform import DecomposedTransform
label_desc: Use image node_id 4 for calling the BasePointToSegmentPen obj's underlying member method code with example usage: obj.endPath() without return types