nodes: 0, module; 1, function_definition; 2, function_name:__parse_blacklist; 3, parameters; 4, block; 5, identifier:self; 6, identifier:json; 7, expression_statement; 8, try_statement; 9, comment:"""Parse blacklist entries using Sorting Hat format.
  
          The Sorting Hat blacklist format is a JSON stream that
          stores a list of blacklisted entries.
  
          Next, there is an example of a valid stream:
  
          {
              "blacklist": [
                  "John Doe",
                  "John Smith",
                  "root@example.com"
              ]
          }
  
          :param stream: stream to parse
  
          :raises InvalidFormatError: raised when the format of the stream is
              not valid.
          """; 10, block; 11, except_clause; 12, for_statement; 13, as_pattern; 14, block; 15, identifier:entry; 16, subscript; 17, block; 18, identifier:KeyError; 19, as_pattern_target; 20, expression_statement; 21, raise_statement; 22, identifier:json; 23, string; 24, if_statement; 25, expression_statement; 26, expression_statement; 27, if_statement; 28, identifier:e; 29, assignment; 30, call; 31, string_content:blacklist; 32, not_operator; 33, block; 34, assignment; 35, assignment; 36, not_operator; 37, block; 38, identifier:msg; 39, binary_operator:"invalid json format. Attribute %s not found" % e.args; 40, identifier:InvalidFormatError; 41, argument_list; 42, identifier:entry; 43, expression_statement; 44, raise_statement; 45, identifier:excluded; 46, call; 47, identifier:bl; 48, call; 49, identifier:bl; 50, expression_statement; 51, expression_statement; 52, string:"invalid json format. Attribute %s not found"; 53, attribute; 54, keyword_argument; 55, assignment; 56, call; 57, attribute; 58, argument_list; 59, attribute; 60, argument_list; 61, assignment; 62, assignment; 63, identifier:e; 64, identifier:args; 65, identifier:cause; 66, identifier:msg; 67, identifier:msg; 68, string:"invalid json format. Blacklist entries cannot be null or empty"; 69, identifier:InvalidFormatError; 70, argument_list; 71, identifier:self; 72, identifier:__encode; 73, identifier:entry; 74, attribute; 75, identifier:get; 76, identifier:excluded; 77, None; 78, identifier:bl; 79, call; 80, subscript; 81, identifier:bl; 82, keyword_argument; 83, identifier:self; 84, identifier:_blacklist; 85, identifier:MatchingBlacklist; 86, argument_list; 87, attribute; 88, identifier:excluded; 89, identifier:cause; 90, identifier:msg; 91, keyword_argument; 92, identifier:self; 93, identifier:_blacklist; 94, identifier:excluded; 95, identifier:excluded
code: def __parse_blacklist(self, json):
          """Parse blacklist entries using Sorting Hat format.
  
          The Sorting Hat blacklist format is a JSON stream that
          stores a list of blacklisted entries.
  
          Next, there is an example of a valid stream:
  
          {
              "blacklist": [
                  "John Doe",
                  "John Smith",
                  "root@example.com"
              ]
          }
  
          :param stream: stream to parse
  
          :raises InvalidFormatError: raised when the format of the stream is
              not valid.
          """
          try:
              for entry in json['blacklist']:
                  if not entry:
                      msg = "invalid json format. Blacklist entries cannot be null or empty"
                      raise InvalidFormatError(cause=msg)
  
                  excluded = self.__encode(entry)
  
                  bl = self._blacklist.get(excluded, None)
  
                  if not bl:
                      bl = MatchingBlacklist(excluded=excluded)
                      self._blacklist[excluded] = bl
          except KeyError as e:
              msg = "invalid json format. Attribute %s not found" % e.args
              raise InvalidFormatError(cause=msg)