(paths: InputOutput, target: CompilationTarget)
return dependencies
Compiles a single file.
Compiles a single file.
Compiles a single file .
def _compile_file(paths: InputOutput, target: CompilationTarget) -> List[str]:
    """Compiles a single file."""
    with paths.input.open() as f:
        code = f.read()

    try:
        transformed, dependencies = _transform(paths.input.as_posix(),
                                               code, target)
    except SyntaxError as e:
        raise CompilationError(paths.input.as_posix(),
                               code, e.lineno, e.offset)

    try:
        paths.output.parent.mkdir(parents=True)
    except FileExistsError:
        pass

    if target == const.TARGETS['2.7']:
        transformed = '# -*- coding: utf-8 -*-\n{}'.format(transformed)

    with paths.output.open('w') as f:
        f.write(transformed)

    return dependencies
def _compile_file ( paths : InputOutput , target : CompilationTarget ) -> List [ str ] : with paths . input . open ( ) as f : code = f . read ( ) try : transformed , dependencies = _transform ( paths . input . as_posix ( ) , code , target ) except SyntaxError as e : raise CompilationError ( paths . input . as_posix ( ) , code , e . lineno , e . offset ) try : paths . output . parent . mkdir ( parents = True ) except FileExistsError : pass if target == const . TARGETS [ '2.7' ] : transformed = '# -*- coding: utf-8 -*-\n{}' . format ( transformed ) with paths . output . open ( 'w' ) as f : f . write ( transformed ) return dependencies