'Get CSV data from the directive content, from an external
file, or from a URL reference.'

def get_csv_data(self):

    encoding = self.options.get('encoding', self.state.document.settings.input_encoding)
    if self.content:
        if (self.options.has_key('file') or self.options.has_key('url')):
            error = self.state_machine.reporter.error(('"%s"    directive    may    not    both    specify    an    external    file    and    have    content.' % self.name), nodes.literal_block(self.block_text, self.block_text), line=self.lineno)
            raise SystemMessagePropagation(error)
        source = self.content.source(0)
        csv_data = self.content
    elif self.options.has_key('file'):
        if self.options.has_key('url'):
            error = self.state_machine.reporter.error(('The    "file"    and    "url"    options    may    not    be    simultaneously    specified    for    the    "%s"    directive.' % self.name), nodes.literal_block(self.block_text, self.block_text), line=self.lineno)
            raise SystemMessagePropagation(error)
        source_dir = os.path.dirname(os.path.abspath(self.state.document.current_source))
        source = os.path.normpath(os.path.join(source_dir, self.options['file']))
        source = utils.relative_path(None, source)
        try:
            self.state.document.settings.record_dependencies.add(source)
            csv_file = io.FileInput(source_path=source, encoding=encoding, error_handler=self.state.document.settings.input_encoding_error_handler, handle_io_errors=None)
            csv_data = csv_file.read().splitlines()
        except IOError as error:
            severe = self.state_machine.reporter.severe(('Problems    with    "%s"    directive    path:\n%s.' % (self.name, error)), nodes.literal_block(self.block_text, self.block_text), line=self.lineno)
            raise SystemMessagePropagation(severe)
    elif self.options.has_key('url'):
        import urllib2
        source = self.options['url']
        try:
            csv_text = urllib2.urlopen(source).read()
        except (urllib2.URLError, IOError, OSError, ValueError) as error:
            severe = self.state_machine.reporter.severe(('Problems    with    "%s"    directive    URL    "%s":\n%s.' % (self.name, self.options['url'], error)), nodes.literal_block(self.block_text, self.block_text), line=self.lineno)
            raise SystemMessagePropagation(severe)
        csv_file = io.StringInput(source=csv_text, source_path=source, encoding=encoding, error_handler=self.state.document.settings.input_encoding_error_handler)
        csv_data = csv_file.read().splitlines()
    else:
        error = self.state_machine.reporter.warning(('The    "%s"    directive    requires    content;    none    supplied.' % self.name), nodes.literal_block(self.block_text, self.block_text), line=self.lineno)
        raise SystemMessagePropagation(error)
    return (csv_data, source)
