Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(8)  |  Derive(0)  |  Import(0)
Open an encoded file using the given mode and return
a wrapped version providing transparent encoding/decoding.

Note: The wrapped version will only accept the object format
defined by the codecs, i.e. Unicode objects for most builtin
codecs. Output is also codec dependent and will usually be
Unicode as well.

Files are always opened in binary mode, even if no binary mode
was specified. This is done to avoid data loss due to encodings(more...)

        def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):

    """ Open an encoded file using the given mode and return
        a wrapped version providing transparent encoding/decoding.

        Note: The wrapped version will only accept the object format
        defined by the codecs, i.e. Unicode objects for most builtin
        codecs. Output is also codec dependent and will usually be
        Unicode as well.

        Files are always opened in binary mode, even if no binary mode
        was specified. This is done to avoid data loss due to encodings
        using 8-bit values. The default file mode is 'rb' meaning to
        open the file in binary read mode.

        encoding specifies the encoding which is to be used for the
        file.

        errors may be given to define the error handling. It defaults
        to 'strict' which causes ValueErrors to be raised in case an
        encoding error occurs.

        buffering has the same meaning as for the builtin open() API.
        It defaults to line buffered.

        The returned wrapped file object provides an extra attribute
        .encoding which allows querying the used encoding. This
        attribute is only available if an encoding was specified as
        parameter.

    """
    if encoding is not None:
        if 'U' in mode:
            # No automatic conversion of '\n' is done on reading and writing
            mode = mode.strip().replace('U', '')
            if mode[:1] not in set('rwa'):
                mode = 'r' + mode
        if 'b' not in mode:
            # Force opening of the file in binary mode
            mode = mode + 'b'
    file = __builtin__.open(filename, mode, buffering)
    if encoding is None:
        return file
    info = lookup(encoding)
    srw = StreamReaderWriter(file, info.streamreader, info.streamwriter, errors)
    # Add attributes to simplify introspection
    srw.encoding = encoding
    return srw
        


src/a/l/allure-python-HEAD/allure/common.py   allure-python(Download)
 
        if py.std.sys.version_info[0] < 3:  # @UndefinedVariable
            logfile = py.std.codecs.open(reportpath, 'w', encoding=encoding)  # @UndefinedVariable
        else:
            logfile = open(reportpath, 'w', encoding=encoding)

src/n/u/nupic-linux64-HEAD/lib/python2.6/site-packages/_pytest/junitxml.py   nupic-linux64(Download)
    def pytest_sessionfinish(self, session, exitstatus, __multicall__):
        if py.std.sys.version_info[0] < 3:
            logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
        else:
            logfile = open(self.logfile, 'w', encoding='utf-8')

src/p/y/pytest-2.5.2/_pytest/junitxml.py   pytest(Download)
    def pytest_sessionfinish(self):
        if py.std.sys.version_info[0] < 3:
            logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
        else:
            logfile = open(self.logfile, 'w', encoding='utf-8')

src/p/y/pytest-mozwebqa-1.1.1/pytest_mozwebqa/html_report.py   pytest-mozwebqa(Download)
    def pytest_sessionfinish(self, session, exitstatus, __multicall__):
        self._make_report_dir()
        logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
 
        suite_stop_time = time.time()

src/p/y/pytest-allure-adaptor-1.3.7/allure/common.py   pytest-allure-adaptor(Download)
 
        if py.std.sys.version_info[0] < 3:  # @UndefinedVariable
            logfile = py.std.codecs.open(reportpath, 'w', encoding=encoding)  # @UndefinedVariable
        else:
            logfile = open(reportpath, 'w', encoding=encoding)

src/p/y/pytest-mozwebqa-HEAD/pytest_mozwebqa/html_report.py   pytest-mozwebqa(Download)
    def pytest_sessionfinish(self, session, exitstatus, __multicall__):
        self._make_report_dir()
        logfile = py.std.codecs.open(self.logfile, 'w', encoding='utf-8')
 
        suite_stop_time = time.time()

src/p/y/py-1.4.20/testing/io_/test_terminalwriter.py   py(Download)
def test_terminalwriter_file_unicode(tmpdir):
    f = py.std.codecs.open(str(tmpdir.join("xyz")), "wb", "utf8")
    tw = py.io.TerminalWriter(file=f)
    assert tw.encoding == "utf8"
 
def test_unicode_on_file_with_ascii_encoding(tmpdir, monkeypatch, encoding):
    msg = py.builtin._totext('hell\xf6', "latin1")
    #pytest.raises(UnicodeEncodeError, lambda: bytes(msg))
    f = py.std.codecs.open(str(tmpdir.join("x")), "w", encoding)
    tw = py.io.TerminalWriter(f)