old_contents: """
  Utility to generate terminology.py from PITerminology.h and
  PIStringTerminology.h in the Photoshop SDK. Use with Python 3.
  
  Usage:
  
      python3 tools/extract_terminology.py \
          photoshopsdk/PITerminology.h \
          photoshopsdk/PIStringTerminology.h \
          src/psd_tools/terminology.py
  """
  import re
  import sys
  
  
  FILE_HEADER = '''"""
  Constants for descriptor.
  
  This file is automaticaly generated by tools/extract_terminology.py
  """
  from enum import Enum, IntEnum\n\n'''
  
  
  TERM_DEF = '''class Term(Enum):
      """
      Term definitions extracted from PITerminology.h in Photoshop SDK.
  
      See https://www.adobe.com/devnet/photoshop/sdk.html
      """'''
  
  
  TERM_PATTERN = re.compile(
      r"^#define\s+(?P<key>\w+)\s+'(?P<value>....)'(\s+//\s(?P<comment>.*))?$"
  )
  
  
  STERM_DEF = '''class StringTerm(Enum):
      """
      String terms extracted from PIStringTerminology.h in Photoshop SDK.
  
      This defines constants for the strings used to access descriptor events,
      keys, classes, enum types, and enum values.
  
      See https://www.adobe.com/devnet/photoshop/sdk.html
      """'''
  
  
  STERM_PATTERN = re.compile(
      r'^#define\s+(?P<key>\w+)\s+"(?P<value>[^"]+)"(\s+//\s(?P<comment>.*))?$'
  )
  
  
  
  def extract_and_print(filepath, header, pattern, **kwargs):
      print(header, **kwargs)
      keys = set()
      with open(filepath, 'r') as f:
          for line in f:
              m = re.match(pattern, line)
              if m:
                  if m.group('key') in keys:
                      continue
                  print('    %s = b%r' % (m.group('key'), m.group('value')),
                        **kwargs)
                  keys.add(m.group('key'))
  
  
  def main():
      with open(sys.argv[3], 'w') as f:
          print(FILE_HEADER, file=f)
          extract_and_print(sys.argv[1], TERM_DEF, TERM_PATTERN, file=f)
          print('\n', file=f)
          extract_and_print(sys.argv[2], STERM_DEF, STERM_PATTERN, file=f)
  
  
  if __name__ == '__main__':
      main()
  
new_contents: """
  Utility to generate terminology.py from PITerminology.h and
  PIStringTerminology.h in the Photoshop SDK. Use with Python 3.
  
  Usage:
  
      python3 tools/extract_terminology.py \
          photoshopsdk/PITerminology.h \
          photoshopsdk/PIStringTerminology.h \
          src/psd_tools/terminology.py
  
  .. note:: Adobe explicitly prohibits Photoshop SDK to be used for Open source
      software. Therefore, psd-tools does not bundle the official header files.
      https://www.adobe.com/devnet/photoshop/sdk/eula.html
  """
  import re
  import sys
  
  
  FILE_HEADER = '''"""
  Constants for descriptor.
  
  This file is automaticaly generated by tools/extract_terminology.py
  """
  from enum import Enum, IntEnum\n\n'''
  
  
  TERM_DEF = '''class Term(Enum):
      """
      Term definitions extracted from PITerminology.h in Photoshop SDK.
  
      See https://www.adobe.com/devnet/photoshop/sdk.html
      """'''
  
  
  TERM_PATTERN = re.compile(
      r"^#define\s+(?P<key>\w+)\s+'(?P<value>....)'(\s+//\s(?P<comment>.*))?$"
  )
  
  
  STERM_DEF = '''class StringTerm(Enum):
      """
      String terms extracted from PIStringTerminology.h in Photoshop SDK.
  
      This defines constants for the strings used to access descriptor events,
      keys, classes, enum types, and enum values.
  
      See https://www.adobe.com/devnet/photoshop/sdk.html
      """'''
  
  
  STERM_PATTERN = re.compile(
      r'^#define\s+(?P<key>\w+)\s+"(?P<value>[^"]+)"(\s+//\s(?P<comment>.*))?$'
  )
  
  
  
  def extract_and_print(filepath, header, pattern, **kwargs):
      print(header, **kwargs)
      keys = set()
      with open(filepath, 'r') as f:
          for line in f:
              m = re.match(pattern, line)
              if m:
                  if m.group('key') in keys:
                      continue
                  print('    %s = b%r' % (m.group('key'), m.group('value')),
                        **kwargs)
                  keys.add(m.group('key'))
  
  
  def main():
      with open(sys.argv[3], 'w') as f:
          print(FILE_HEADER, file=f)
          extract_and_print(sys.argv[1], TERM_DEF, TERM_PATTERN, file=f)
          print('\n', file=f)
          extract_and_print(sys.argv[2], STERM_DEF, STERM_PATTERN, file=f)
  
  
  if __name__ == '__main__':
      main()
  
subject: Update docstring