nodes: 0, module; 1, function_definition; 2, function_name:title_from_rdf; 3, parameters; 4, block; 5, identifier:rdf; 6, identifier:url; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, with_statement; 14, string; 15, assignment; 16, identifier:title; 17, block; 18, identifier:url; 19, block; 20, assignment; 21, assignment; 22, with_clause; 23, block; 24, string_content:Try to extract a distribution title from a property.
      As it's not a mandatory property,
      it fallback on building a title from the URL
      then the format and in last ressort a generic resource name.; 25, identifier:title; 26, call; 27, return_statement; 28, expression_statement; 29, if_statement; 30, identifier:fmt; 31, call; 32, identifier:lang; 33, subscript; 34, with_item; 35, if_statement; 36, identifier:rdf_value; 37, argument_list; 38, identifier:title; 39, assignment; 40, boolean_operator; 41, block; 42, identifier:rdf_value; 43, argument_list; 44, attribute; 45, string; 46, call; 47, identifier:fmt; 48, block; 49, else_clause; 50, identifier:rdf; 51, attribute; 52, identifier:last_part; 53, subscript; 54, comparison_operator:'.' in last_part; 55, comparison_operator:'?' not in last_part; 56, return_statement; 57, identifier:rdf; 58, call; 59, identifier:current_app; 60, identifier:config; 61, string_content:DEFAULT_LANGUAGE; 62, attribute; 63, argument_list; 64, return_statement; 65, block; 66, identifier:DCT; 67, identifier:title; 68, call; 69, unary_operator; 70, string; 71, identifier:last_part; 72, string; 73, identifier:last_part; 74, identifier:last_part; 75, attribute; 76, argument_list; 77, identifier:i18n; 78, identifier:language; 79, identifier:lang; 80, call; 81, return_statement; 82, attribute; 83, argument_list; 84, integer:1; 85, string_content:.; 86, string_content:?; 87, identifier:DCT; 88, identifier:term; 89, string; 90, attribute; 91, argument_list; 92, call; 93, identifier:url; 94, identifier:split; 95, string; 96, string_content:format; 97, call; 98, identifier:format; 99, keyword_argument; 100, attribute; 101, argument_list; 102, string_content:/; 103, attribute; 104, argument_list; 105, identifier:format; 106, call; 107, identifier:i18n; 108, identifier:_; 109, string; 110, identifier:i18n; 111, identifier:_; 112, string; 113, attribute; 114, argument_list; 115, string_content:Nameless resource; 116, string_content:{format} resource; 117, identifier:fmt; 118, identifier:lower
code: def title_from_rdf(rdf, url):
      '''
      Try to extract a distribution title from a property.
      As it's not a mandatory property,
      it fallback on building a title from the URL
      then the format and in last ressort a generic resource name.
      '''
      title = rdf_value(rdf, DCT.title)
      if title:
          return title
      if url:
          last_part = url.split('/')[-1]
          if '.' in last_part and '?' not in last_part:
              return last_part
      fmt = rdf_value(rdf, DCT.term('format'))
      lang = current_app.config['DEFAULT_LANGUAGE']
      with i18n.language(lang):
          if fmt:
              return i18n._('{format} resource').format(format=fmt.lower())
          else:
              return i18n._('Nameless resource')