'Get data from text file, truncating if necessary.'

def text_data(self, hda, preview=True):

    MAX_PEEK_SIZE = 1000000
    truncated = False
    hda_data = None
    if (not isinstance(hda.datatype, datatypes.data.Text)):
        return (truncated, hda_data)
    if (not os.path.exists(hda.file_name)):
        return (truncated, hda_data)
    truncated = (preview and (os.stat(hda.file_name).st_size > MAX_PEEK_SIZE))
    hda_data = open(hda.file_name).read(MAX_PEEK_SIZE)
    return (truncated, hda_data)
