Did I find the right examples for you? yes no

All Samples(16)  |  Call(8)  |  Derive(0)  |  Import(8)
Opens a file as usual on Python 3, and with UTF-8 encoding on Python 2.

:param filename: Name of file to open.

        def unicode_open(filename, *args, **kwargs):
    """
    Opens a file as usual on Python 3, and with UTF-8 encoding on Python 2.

    :param filename: Name of file to open.
    """
    if PY3:
        return open(filename, *args, **kwargs)
    kwargs['encoding'] = "utf-8"
    return codecs.open(filename, *args, **kwargs)
        


src/c/o/complexity-0.9.1/complexity/generate.py   complexity(Download)
 
from .exceptions import MissingTemplateDirException
from .utils import make_sure_path_exists, unicode_open
 
 
 
        # Write the generated file
        with unicode_open(output_filename, 'w') as fh:
            fh.write(rendered_html)
            return True
            # Open the JSON file and convert to Python object
            json_file = os.path.join(context_dir, file_name)
            with unicode_open(json_file) as f:
                obj = json.load(f)
 

src/c/o/complexity-HEAD/complexity/generate.py   complexity(Download)
 
from .exceptions import MissingTemplateDirException
from .utils import make_sure_path_exists, unicode_open
 
 
 
        # Write the generated file
        with unicode_open(output_filename, 'w') as fh:
            fh.write(rendered_html)
            return True
            # Open the JSON file and convert to Python object
            json_file = os.path.join(context_dir, file_name)
            with unicode_open(json_file) as f:
                obj = json.load(f)
 

src/c/o/cookiecutter-0.7.1/cookiecutter/generate.py   cookiecutter(Download)
from .exceptions import NonTemplatedInputDirException
from .find import find_template
from .utils import make_sure_path_exists, unicode_open, work_in
from .hooks import run_hook
 
        logging.debug("Writing {0}".format(outfile))
 
        with unicode_open(outfile, 'w') as fh:
            fh.write(rendered_file)
 

src/c/o/cookiecutter-HEAD/cookiecutter/generate.py   cookiecutter(Download)
from .exceptions import NonTemplatedInputDirException
from .find import find_template
from .utils import make_sure_path_exists, unicode_open, work_in
from .hooks import run_hook
 
        logging.debug("Writing {0}".format(outfile))
 
        with unicode_open(outfile, 'w') as fh:
            fh.write(rendered_file)
 

src/c/o/cookiecutter-0.7.1/cookiecutter/config.py   cookiecutter(Download)
 
from .exceptions import ConfigDoesNotExistException
from .utils import unicode_open
from .exceptions import InvalidConfiguration
 
 
    print("config_path is {0}".format(config_path))
    with unicode_open(config_path) as file_handle:
        try:
            yaml_dict = yaml.safe_load(file_handle)

src/c/o/cookiecutter-HEAD/cookiecutter/config.py   cookiecutter(Download)
 
from .exceptions import ConfigDoesNotExistException
from .utils import unicode_open
from .exceptions import InvalidConfiguration
 
 
    print("config_path is {0}".format(config_path))
    with unicode_open(config_path) as file_handle:
        try:
            yaml_dict = yaml.safe_load(file_handle)

src/c/o/cookiecutter-0.7.1/cookiecutter/hooks.py   cookiecutter(Download)
import sys
 
from .utils import make_sure_path_exists, unicode_open, work_in
 
_HOOKS = [

src/c/o/cookiecutter-HEAD/cookiecutter/hooks.py   cookiecutter(Download)
import sys
 
from .utils import make_sure_path_exists, unicode_open, work_in
 
_HOOKS = [