
def extractCMAP(ttFont):
    cmap = {}
    cmapIDs = [(3, 10), (0, 3), (3, 1)]
    for i in range(len(cmapIDs)):
        if ttFont["cmap"].getcmap(*cmapIDs[i]):
            cmap = ttFont["cmap"].getcmap(*cmapIDs[i]).cmap
            break
    if not cmap:
        from compositor.error import CompositorError
        raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")
    return cmap

def reverseCMAP(cmap):
    reversed = {}
    for value, name in cmap.items():
        if name not in reversed:
            reversed[name] = []
        reversed[name].append(value)
    return reversed


def extractCMAP(ttFont):
    for platformID, encodingID in [(3, 10), (0, 3), (3, 1)]:
        cmapSubtable = ttFont["cmap"].getcmap(platformID, encodingID)
        if cmapSubtable is not None:
            return cmapSubtable.cmap
    from compositor.error import CompositorError
    raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")

def reverseCMAP(cmap):
    reversed = {}
    for value, name in cmap.items():
        if name not in reversed:
            reversed[name] = []
        reversed[name].append(value)
    return reversed

Make the code more compact
Make the code more compact

  
  def extractCMAP(ttFont):
+     for platformID, encodingID in [(3, 10), (0, 3), (3, 1)]:
+         cmapSubtable = ttFont["cmap"].getcmap(platformID, encodingID)
+         if cmapSubtable is not None:
+             return cmapSubtable.cmap
-     cmap = {}
-     cmapIDs = [(3, 10), (0, 3), (3, 1)]
-     for i in range(len(cmapIDs)):
-         if ttFont["cmap"].getcmap(*cmapIDs[i]):
-             cmap = ttFont["cmap"].getcmap(*cmapIDs[i]).cmap
-             break
-     if not cmap:
-         from compositor.error import CompositorError
+     from compositor.error import CompositorError
-         raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")
+     raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")
-     return cmap
  
  def reverseCMAP(cmap):
      reversed = {}
      for value, name in cmap.items():
          if name not in reversed:
              reversed[name] = []
          reversed[name].append(value)
      return reversed
  
Make the code more compact
## Code Before:

def extractCMAP(ttFont):
    cmap = {}
    cmapIDs = [(3, 10), (0, 3), (3, 1)]
    for i in range(len(cmapIDs)):
        if ttFont["cmap"].getcmap(*cmapIDs[i]):
            cmap = ttFont["cmap"].getcmap(*cmapIDs[i]).cmap
            break
    if not cmap:
        from compositor.error import CompositorError
        raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")
    return cmap

def reverseCMAP(cmap):
    reversed = {}
    for value, name in cmap.items():
        if name not in reversed:
            reversed[name] = []
        reversed[name].append(value)
    return reversed

## Instruction:
Make the code more compact
## Code After:

def extractCMAP(ttFont):
    for platformID, encodingID in [(3, 10), (0, 3), (3, 1)]:
        cmapSubtable = ttFont["cmap"].getcmap(platformID, encodingID)
        if cmapSubtable is not None:
            return cmapSubtable.cmap
    from compositor.error import CompositorError
    raise CompositorError("Found neither CMAP (3, 10), (0, 3), nor (3, 1) in font.")

def reverseCMAP(cmap):
    reversed = {}
    for value, name in cmap.items():
        if name not in reversed:
            reversed[name] = []
        reversed[name].append(value)
    return reversed
