parameters: ()
return_statement: return fields
docstring: Return our widechar_width.h as a string
docstring_summary: Return our widechar_width.h as a string
docstring_tokens: Return our widechar_width . h as a string
function: def generate():
      """ Return our widechar_width.h as a string """
      # Read our three files.
      unicode_data, unicode_hash = read_datafile(UNICODE_DATA_URL)
      eaw_data, eaw_hash = read_datafile(EAW_URL)
      emoji_data, emoji_hash = read_datafile(EMOJI_DATA_URL)
  
      log("Thinking...")
  
      # Generate a CodePoint for each value.
      cps = [CodePoint(i) for i in xrange(MAX_CODEPOINT + 1)]
  
      set_general_categories(unicode_data, cps)
      set_eaw_widths(eaw_data, cps)
      set_emoji_widths(emoji_data, cps)
      set_hardcoded_ranges(cps)
  
      def categories(cats):
          """Return a carray string of codepoints in any of the given categories."""
          catset = set(cats)
          matches = [cp for cp in cps if cp.category in catset]
          return codepoints_to_carray_str(matches)
  
      def codepoints_with_width(width):
          """ Return a carray string of codepoints with the given width. """
          return codepoints_to_carray_str([cp for cp in cps if cp.width == width])
  
      def ascii_codepoints():
          """ Return a carray string of codepoints with the given width. """
          return codepoints_to_carray_str(
              [cp for cp in cps if cp.codepoint < 0x7F and cp.codepoint >= 0x20]
          )
  
      fields = {
          "p": CPP_PREFIX,
          "filename": OUTPUT_FILENAME,
          "today": str(datetime.date.today()),
          "unicode_hash": unicode_hash,
          "eaw_hash": eaw_hash,
          "emoji_hash": emoji_hash,
          "ascii": ascii_codepoints(),
          "private": categories([CAT_PRIVATE_USE]),
          "noncharacters": categories([CAT_NON_CHARACTERS]),
          "nonprint": categories(["Cc", "Cf", "Zl", "Zp", CAT_SURROGATE]),
          "combining": categories(["Mn", "Mc", "Me"]),
          "doublewide": codepoints_with_width(2),
          "unassigned": categories([CAT_UNASSIGNED]),
          "ambiguous": codepoints_with_width(WIDTH_AMBIGUOUS_EASTASIAN),
          "widenedin9": codepoints_with_width(WIDTH_WIDENED_IN_9),
      }
      return fields
function_tokens: def generate ( ) : # Read our three files. unicode_data , unicode_hash = read_datafile ( UNICODE_DATA_URL ) eaw_data , eaw_hash = read_datafile ( EAW_URL ) emoji_data , emoji_hash = read_datafile ( EMOJI_DATA_URL ) log ( "Thinking..." ) # Generate a CodePoint for each value. cps = [ CodePoint ( i ) for i in xrange ( MAX_CODEPOINT + 1 ) ] set_general_categories ( unicode_data , cps ) set_eaw_widths ( eaw_data , cps ) set_emoji_widths ( emoji_data , cps ) set_hardcoded_ranges ( cps ) def categories ( cats ) : """Return a carray string of codepoints in any of the given categories.""" catset = set ( cats ) matches = [ cp for cp in cps if cp . category in catset ] return codepoints_to_carray_str ( matches ) def codepoints_with_width ( width ) : """ Return a carray string of codepoints with the given width. """ return codepoints_to_carray_str ( [ cp for cp in cps if cp . width == width ] ) def ascii_codepoints ( ) : """ Return a carray string of codepoints with the given width. """ return codepoints_to_carray_str ( [ cp for cp in cps if cp . codepoint < 0x7F and cp . codepoint >= 0x20 ] ) fields = { "p" : CPP_PREFIX , "filename" : OUTPUT_FILENAME , "today" : str ( datetime . date . today ( ) ) , "unicode_hash" : unicode_hash , "eaw_hash" : eaw_hash , "emoji_hash" : emoji_hash , "ascii" : ascii_codepoints ( ) , "private" : categories ( [ CAT_PRIVATE_USE ] ) , "noncharacters" : categories ( [ CAT_NON_CHARACTERS ] ) , "nonprint" : categories ( [ "Cc" , "Cf" , "Zl" , "Zp" , CAT_SURROGATE ] ) , "combining" : categories ( [ "Mn" , "Mc" , "Me" ] ) , "doublewide" : codepoints_with_width ( 2 ) , "unassigned" : categories ( [ CAT_UNASSIGNED ] ) , "ambiguous" : codepoints_with_width ( WIDTH_AMBIGUOUS_EASTASIAN ) , "widenedin9" : codepoints_with_width ( WIDTH_WIDENED_IN_9 ) , } return fields