nodes: 0, module; 1, function_definition; 2, function_name:pipe_fetchdata; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, comment:# todo: iCal and KML; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:context; 18, None; 19, identifier:_INPUT; 20, None; 21, identifier:conf; 22, None; 23, identifier:kwargs; 24, comment:"""A source that fetches and parses an XML or JSON file. Loopable.
  
      Parameters
      ----------
      context : pipe2py.Context object
      _INPUT : pipeforever pipe or an iterable of items or fields
      conf : {
          'URL': {'value': <url>},
          'path': {'value': <dot separated path to data list>}
      }
  
      Yields
      ------
      _OUTPUT : items
  
      Examples
      --------
      >>> from os import path as p
      >>> from pipe2py.modules.pipeforever import pipe_forever
      >>> parent = p.dirname(p.dirname(__file__))
      >>> abspath = p.abspath(p.join(parent, 'data', 'gigs.json'))
      >>> path = 'value.items'
      >>> url = "file://%s" % abspath
      >>> conf = {'URL': {'value': url}, 'path': {'value': path}}
      >>> pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys()[:5]
      [u'y:repeatcount', u'description', u'pubDate', u'title', u'y:published']
      >>> abspath = p.abspath(p.join(parent, 'data', 'places.xml'))
      >>> path = 'appointment'
      >>> url = "file://%s" % abspath
      >>> conf = {'URL': {'value': url}, 'path': {'value': path}}
      >>> sorted(pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys())
      ['alarmTime', 'begin', 'duration', 'places', 'subject', 'uid']
      >>> conf = {'URL': {'value': url}, 'path': {'value': ''}}
      >>> sorted(pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys())
      ['appointment', 'reminder']
      """; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, identifier:_OUTPUT; 31, identifier:funcs; 32, call; 33, identifier:parsed; 34, call; 35, identifier:results; 36, call; 37, identifier:items; 38, call; 39, identifier:_OUTPUT; 40, call; 41, identifier:get_splits; 42, argument_list; 43, identifier:get_parsed; 44, argument_list; 45, identifier:starmap; 46, argument_list; 47, identifier:imap; 48, argument_list; 49, attribute; 50, argument_list; 51, None; 52, identifier:conf; 53, dictionary_splat; 54, identifier:_INPUT; 55, subscript; 56, identifier:parse_result; 57, identifier:parsed; 58, attribute; 59, identifier:results; 60, identifier:utils; 61, identifier:multiplex; 62, identifier:items; 63, call; 64, identifier:funcs; 65, integer:0; 66, identifier:utils; 67, identifier:gen_items; 68, identifier:cdicts; 69, argument_list; 70, identifier:opts; 71, identifier:kwargs
code: def pipe_fetchdata(context=None, _INPUT=None, conf=None, **kwargs):
      """A source that fetches and parses an XML or JSON file. Loopable.
  
      Parameters
      ----------
      context : pipe2py.Context object
      _INPUT : pipeforever pipe or an iterable of items or fields
      conf : {
          'URL': {'value': <url>},
          'path': {'value': <dot separated path to data list>}
      }
  
      Yields
      ------
      _OUTPUT : items
  
      Examples
      --------
      >>> from os import path as p
      >>> from pipe2py.modules.pipeforever import pipe_forever
      >>> parent = p.dirname(p.dirname(__file__))
      >>> abspath = p.abspath(p.join(parent, 'data', 'gigs.json'))
      >>> path = 'value.items'
      >>> url = "file://%s" % abspath
      >>> conf = {'URL': {'value': url}, 'path': {'value': path}}
      >>> pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys()[:5]
      [u'y:repeatcount', u'description', u'pubDate', u'title', u'y:published']
      >>> abspath = p.abspath(p.join(parent, 'data', 'places.xml'))
      >>> path = 'appointment'
      >>> url = "file://%s" % abspath
      >>> conf = {'URL': {'value': url}, 'path': {'value': path}}
      >>> sorted(pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys())
      ['alarmTime', 'begin', 'duration', 'places', 'subject', 'uid']
      >>> conf = {'URL': {'value': url}, 'path': {'value': ''}}
      >>> sorted(pipe_fetchdata(_INPUT=pipe_forever(), conf=conf).next().keys())
      ['appointment', 'reminder']
      """
      # todo: iCal and KML
      funcs = get_splits(None, conf, **cdicts(opts, kwargs))
      parsed = get_parsed(_INPUT, funcs[0])
      results = starmap(parse_result, parsed)
      items = imap(utils.gen_items, results)
      _OUTPUT = utils.multiplex(items)
      return _OUTPUT