Ejemplo n.º 1
0
def norm_open(path):
    """return a stream for a file with content with normalized line feeds

    :type path: str
    :param path: path to the file to open

    :rtype: file or StringIO
    :return: the opened file with normalized line feeds
    """
    if _HAS_UNIV_OPEN:
        return open(path, 'U')
    return StringIO(_LINE_RGX.sub('\n', open(path).read()))
Ejemplo n.º 2
0
def norm_open(path):
    """return a stream for a file with content with normalized line feeds

    :type path: str
    :param path: path to the file to open

    :rtype: file or StringIO
    :return: the opened file with normalized line feeds
    """
    if _HAS_UNIV_OPEN:
        return open(path, 'U')
    return StringIO(_LINE_RGX.sub('\n', open(path).read()))
Ejemplo n.º 3
0
def norm_read(path):
    """return the content of the file with normalized line feeds

    :type path: str
    :param path: path to the file to read

    :rtype: str
    :return: the content of the file with normalized line feeds
    """
    if _HAS_UNIV_OPEN:
        return open(path, 'U').read()
    return _LINE_RGX.sub('\n', open(path).read())
Ejemplo n.º 4
0
def norm_read(path):
    """return the content of the file with normalized line feeds

    :type path: str
    :param path: path to the file to read

    :rtype: str
    :return: the content of the file with normalized line feeds
    """
    if _HAS_UNIV_OPEN:
        return open(path, 'U').read()
    return _LINE_RGX.sub('\n', open(path).read())