]> crepu.dev Git - config.git/blame_incremental - djavu-asus/elpa/elpy-20230803.1455/elpy/auto_pep8.py
Configuracion en desarrollo PC pega
[config.git] / djavu-asus / elpa / elpy-20230803.1455 / elpy / auto_pep8.py
... / ...
CommitLineData
1"""Glue for the "autopep8" library.
2
3"""
4
5from elpy.rpc import Fault
6import os
7
8
9try:
10 import autopep8
11except ImportError: # pragma: no cover
12 autopep8 = None
13
14
15def fix_code(code, directory):
16 """Formats Python code to conform to the PEP 8 style guide.
17
18 """
19 if not autopep8:
20 raise Fault('autopep8 not installed, cannot fix code.',
21 code=400)
22 old_dir = os.getcwd()
23 try:
24 os.chdir(directory)
25 return autopep8.fix_code(code, apply_config=True)
26 finally:
27 os.chdir(old_dir)