code: def gen_bidi(output, ascii_props=False, append=False, prefix=""):
      
  
      bidi_class = {}
      max_range = MAXASCII if ascii_props else MAXUNICODE
      with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'UnicodeData.txt'), 'r', 'utf-8') as uf:
          for line in uf:
              data = line.strip().split(';')
              if data:
                  bidi = data[4].strip().lower()
                  if not bidi:
                      continue
                  value = int(data[0].strip(), 16)
  
                  if bidi not in bidi_class:
                      bidi_class[bidi] = []
  
                  if value > max_range:
                      continue
  
                  bidi_class[bidi].append(value)
  
      for name in list(bidi_class.keys()):
          s = set(bidi_class[name])
          bidi_class[name] = sorted(s)
  
      # Convert characters values to ranges
      char2range(bidi_class, is_bytes=ascii_props)
  
      with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
          if not append:
              f.write(HEADER)
          f.write('%s_bidi_classes = {\n' % prefix)
          count = len(bidi_class) - 1
          i = 0
          for k1, v1 in sorted(bidi_class.items()):
              f.write('    "%s": "%s"' % (k1, v1))
              if i == count:
                  f.write('\n}\n')
              else:
                  f.write(',\n')
              i += 1
docs: Generate `bidi class` property.