Reformat code.

This commit is contained in:
Pavel Minaev 2019-07-22 12:33:54 -07:00 committed by Pavel Minaev
parent 5c6f3779d3
commit b2d5414d0e
6 changed files with 22 additions and 21 deletions

View file

@ -19,20 +19,21 @@ __all__ = [
"wait_for_attach",
]
# Force absolute path on Python 2.
import codecs
from os import path
# Force absolute path on Python 2.
__file__ = path.abspath(__file__)
del path
# Preload encodings that we're going to use to avoid import deadlocks on Python 2.
import codecs
codecs.lookup('ascii')
codecs.lookup('utf8')
codecs.lookup('utf-8')
codecs.lookup('latin1')
codecs.lookup('latin-1')
codecs.lookup("ascii")
codecs.lookup("utf8")
codecs.lookup("utf-8")
codecs.lookup("latin1")
codecs.lookup("latin-1")
from ptvsd import _version
__version__ = _version.get_versions()["version"]
del _version

View file

@ -48,6 +48,6 @@ if __name__ == "__main__":
# this simplifies imports in the latter.
import ptvsd # noqa
import pydevd # noqa
from ptvsd.server.__main__ import main
main()

View file

@ -19,6 +19,7 @@ class JsonEncoder(json.JSONEncoder):
If the object implements __getstate__, then that method is invoked, and its
result is serialized instead of the object itself.
"""
def default(self, value):
try:
get_state = value.__getstate__

View file

@ -192,7 +192,9 @@ def to_file(filename=None):
"ptvsd.to_file() cannot generate log file name - ptvsd.options.log_dir is not set"
)
return
_filename = fmt("{0}/{1}-{2}.log", options.log_dir, filename_prefix, os.getpid())
_filename = fmt(
"{0}/{1}-{2}.log", options.log_dir, filename_prefix, os.getpid()
)
file = io.open(_filename, "w", encoding="utf-8")
info(

View file

@ -103,9 +103,8 @@ class JsonIOStream(object):
self._writer.close()
def _log_message(self, dir, data, logger=log.debug):
format_string = (
"{0} {1} " +
("{2!j:indent=None}" if isinstance(data, list) else "{2!j}")
format_string = "{0} {1} " + (
"{2!j:indent=None}" if isinstance(data, list) else "{2!j}"
)
return logger(format_string, self.name, dir, data)

View file

@ -7,11 +7,7 @@ import ptvsd.server.options
from ptvsd.server.__main__ import run_file, run_module, run_code
RUNNERS = {
'module': run_module,
'script': run_file,
'code': run_code,
}
RUNNERS = {"module": run_module, "script": run_file, "code": run_code}
# Not actually used, but VS will try to add entries to it.
DONT_DEBUG = []
@ -21,14 +17,16 @@ DONT_DEBUG = []
# All new code should use the entrypoints in ptvsd.server.__main__ directly.
def debug(filename, port_num, debug_id, debug_options, run_as):
ptvsd.server.log.to_file()
ptvsd.server.log.info('debug{0!r}', (filename, port_num, debug_id, debug_options, run_as))
ptvsd.server.log.info(
"debug{0!r}", (filename, port_num, debug_id, debug_options, run_as)
)
try:
run = RUNNERS[run_as]
except KeyError:
raise ValueError('run_as must be one of: {0!r}'.format(tuple(RUNNERS.keys())))
raise ValueError("run_as must be one of: {0!r}".format(tuple(RUNNERS.keys())))
ptvsd.server.options.target_kind = 'file' if run_as == 'script' else run_as
ptvsd.server.options.target_kind = "file" if run_as == "script" else run_as
ptvsd.server.options.target = filename
ptvsd.server.options.port = port_num
ptvsd.server.options.client = True