Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|># coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals # http://yaml.org/type/int.html is where underscores in integers are defined class TestFloat: def test_round_trip_non_exp(self): <|code_end|> . Use current file imports: (import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.error import MantissaNoDotYAML1_1Warning) and context including class names, function names, or small code snippets from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
data = round_trip(
Based on the snippet: <|code_start|> assert -0.51 < data[11] < -0.49 def test_round_trip_zeros_0(self): data = round_trip( """\ - 0. - +0. - -0. - 0.0 - +0.0 - -0.0 - 0.00 - +0.00 - -0.00 """ ) print(data) for d in data: assert -0.00001 < d < 0.00001 def Xtest_round_trip_non_exp_trailing_dot(self): data = round_trip( """\ """ ) print(data) def test_yaml_1_1_no_dot(self): with pytest.warns(MantissaNoDotYAML1_1Warning): <|code_end|> , predict the immediate next line with the help of imports: import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.error import MantissaNoDotYAML1_1Warning and context (classes, functions, sometimes code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
round_trip_load(
Given snippet: <|code_start|> assert -0.00001 < d < 0.00001 def Xtest_round_trip_non_exp_trailing_dot(self): data = round_trip( """\ """ ) print(data) def test_yaml_1_1_no_dot(self): with pytest.warns(MantissaNoDotYAML1_1Warning): round_trip_load( """\ %YAML 1.1 --- - 1e6 """ ) class TestCalculations(object): def test_mul_00(self): # issue 149 reported by jan.brezina@tul.cz d = round_trip_load( """\ - 0.1 """ ) d[0] *= -1 <|code_end|> , continue by predicting the next line. Consider current file imports: import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.error import MantissaNoDotYAML1_1Warning and context: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) which might include code, classes, or functions. Output only the next line.
x = round_trip_dump(d)
Predict the next line after this snippet: <|code_start|># coding: utf-8 """ test flow style sequences as keys roundtrip """ # import pytest class TestFlowStyleSequenceKey: def test_so_39595807(self): inp = """\ %YAML 1.2 --- [2, 3, 4]: a: - 1 - 2 b: Hello World! c: 'Voilà!' """ <|code_end|> using the current file's imports: from .roundtrip import round_trip # , dedent, round_trip_load, round_trip_dump and any relevant context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data . Output only the next line.
round_trip(inp, preserve_quotes=True, explicit_start=True, version=(1, 2))
Based on the snippet: <|code_start|># coding: utf-8 # there is some work to do # provide a failing test xyz and a non-failing xyz_no_fail ( to see # what the current failing output is. # on fix of srsly.ruamel_yaml, move the marked test to the appropriate test (without mark) # and remove remove the xyz_no_fail class TestCommentFailures: @pytest.mark.xfail(strict=True) def test_set_comment_before_tag(self): # no comments before tags <|code_end|> , predict the immediate next line with the help of imports: import pytest from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap and context (classes, functions, sometimes code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
round_trip(
Given the code snippet: <|code_start|> class TestCommentFailures: @pytest.mark.xfail(strict=True) def test_set_comment_before_tag(self): # no comments before tags round_trip( """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ ) def test_set_comment_before_tag_no_fail(self): # no comments before tags inp = """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ <|code_end|> , generate the next line using the imports in this file: import pytest from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap and context (functions, classes, or occasionally code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(round_trip_load(inp)) == dedent(
Based on the snippet: <|code_start|> class TestCommentFailures: @pytest.mark.xfail(strict=True) def test_set_comment_before_tag(self): # no comments before tags round_trip( """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ ) def test_set_comment_before_tag_no_fail(self): # no comments before tags inp = """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ <|code_end|> , predict the immediate next line with the help of imports: import pytest from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap and context (classes, functions, sometimes code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(round_trip_load(inp)) == dedent(
Given the code snippet: <|code_start|> class TestCommentFailures: @pytest.mark.xfail(strict=True) def test_set_comment_before_tag(self): # no comments before tags round_trip( """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ ) def test_set_comment_before_tag_no_fail(self): # no comments before tags inp = """ # the beginning !!set # or this one? ? a # next one is B (lowercase) ? b # You see? Promised you. ? c # this is the end """ <|code_end|> , generate the next line using the imports in this file: import pytest from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap from srsly.ruamel_yaml.comments import CommentedKeyMap and context (functions, classes, or occasionally code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(round_trip_load(inp)) == dedent(
Here is a snippet: <|code_start|># coding: utf-8 """ comment testing is all about roundtrips these can be done in the "old" way by creating a file.data and file.roundtrip but there is little flexibility in doing that but some things are not easily tested, eog. how a roundtrip changes """ class TestComments: def test_no_end_of_file_eol(self): """not excluding comments caused some problems if at the end of the file without a newline. First error, then included \0 """ x = """\ - europe: 10 # abc""" <|code_end|> . Write the next line using the current file imports: import pytest import sys import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) , which may include functions, classes, or code. Output only the next line.
round_trip(x, extra="\n")
Here is a snippet: <|code_start|> def test_dropped(self): s = """\ # comment scalar ... """ round_trip(s, "scalar\n...\n") def test_main_mapping_begin_end(self): round_trip( """ # C start a # C start b abc: 1 ghi: 2 klm: 3 # C end a # C end b """ ) def test_reindent(self): x = """\ a: b: # comment 1 c: 1 # comment 2 """ d = round_trip_load(x) y = round_trip_dump(d, indent=4) <|code_end|> . Write the next line using the current file imports: import pytest import sys import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) , which may include functions, classes, or code. Output only the next line.
assert y == dedent(
Continue the code snippet: <|code_start|> """ ) def test_dropped(self): s = """\ # comment scalar ... """ round_trip(s, "scalar\n...\n") def test_main_mapping_begin_end(self): round_trip( """ # C start a # C start b abc: 1 ghi: 2 klm: 3 # C end a # C end b """ ) def test_reindent(self): x = """\ a: b: # comment 1 c: 1 # comment 2 """ <|code_end|> . Use current file imports: import pytest import sys import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
d = round_trip_load(x)
Based on the snippet: <|code_start|> ) def test_dropped(self): s = """\ # comment scalar ... """ round_trip(s, "scalar\n...\n") def test_main_mapping_begin_end(self): round_trip( """ # C start a # C start b abc: 1 ghi: 2 klm: 3 # C end a # C end b """ ) def test_reindent(self): x = """\ a: b: # comment 1 c: 1 # comment 2 """ d = round_trip_load(x) <|code_end|> , predict the immediate next line with the help of imports: import pytest import sys import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump and context (classes, functions, sometimes code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
y = round_trip_dump(d, indent=4)
Predict the next line for this snippet: <|code_start|>from __future__ import print_function # DATA = 'tests/data' # determine the position of data dynamically relative to program # this allows running test while the current path is not the top of the # repository, e.g. from the tests/data directory: python ../test_yaml.py DATA = __file__.rsplit(os.sep, 2)[0] + "/data" def find_test_functions(collections): if not isinstance(collections, list): collections = [collections] functions = [] for collection in collections: if not isinstance(collection, dict): collection = vars(collection) for key in sorted(collection): value = collection[key] if isinstance(value, types.FunctionType) and hasattr(value, "unittest"): functions.append(value) return functions def find_test_filenames(directory): filenames = {} for filename in os.listdir(directory): if os.path.isfile(os.path.join(directory, filename)): base, ext = os.path.splitext(filename) <|code_end|> with the help of current file imports: import sys import os import types import traceback import pprint import argparse from srsly.ruamel_yaml.compat import PY3 and context from other files: # Path: srsly/ruamel_yaml/compat.py # PY3 = sys.version_info[0] == 3 , which may contain function names, class names, or code. Output only the next line.
if base.endswith("-py2" if PY3 else "-py3"):
Given the code snippet: <|code_start|># coding: utf-8 from __future__ import print_function """ various test cases for string scalars in YAML files '|' for preserved newlines '>' for folded (newlines become spaces) and the chomping modifiers: '-' for stripping: final line break and any trailing empty lines are excluded '+' for keeping: final line break and empty lines are preserved '' for clipping: final line break preserved, empty lines at end not included in content (no modifier) """ # from srsly.ruamel_yaml.compat import ordereddict class TestLiteralScalarString: def test_basic_string(self): <|code_end|> , generate the next line using the imports in this file: import pytest import platform import srsly import srsly from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq and context (functions, classes, or occasionally code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
round_trip(
Continue the code snippet: <|code_start|> class TestQuotedScalarString: def test_single_quoted_string(self): inp = """ a: 'abc' """ round_trip(inp, preserve_quotes=True) def test_double_quoted_string(self): inp = """ a: "abc" """ round_trip(inp, preserve_quotes=True) def test_non_preserved_double_quoted_string(self): inp = """ a: "abc" """ exp = """ a: abc """ round_trip(inp, outp=exp) class TestReplace: """inspired by issue 110 from sandres23""" def test_replace_preserved_scalar_string(self): <|code_end|> . Use current file imports: import pytest import platform import srsly import srsly from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
s = dedent(
Continue the code snippet: <|code_start|> def test_double_quoted_string(self): inp = """ a: "abc" """ round_trip(inp, preserve_quotes=True) def test_non_preserved_double_quoted_string(self): inp = """ a: "abc" """ exp = """ a: abc """ round_trip(inp, outp=exp) class TestReplace: """inspired by issue 110 from sandres23""" def test_replace_preserved_scalar_string(self): s = dedent( """\ foo: | foo foo bar foo """ ) <|code_end|> . Use current file imports: import pytest import platform import srsly import srsly from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
data = round_trip_load(s, preserve_quotes=True)
Predict the next line after this snippet: <|code_start|> foo """ ) def test_replace_double_quoted_scalar_string(self): s = dedent( """\ foo: "foo foo bar foo" """ ) data = round_trip_load(s, preserve_quotes=True) so = data["foo"].replace("foo", "bar", 2) assert isinstance(so, srsly.ruamel_yaml.scalarstring.DoubleQuotedScalarString) assert so == "bar bar bar foo" class TestWalkTree: def test_basic(self): data = CommentedMap() data[1] = "a" data[2] = "with\nnewline\n" walk_tree(data) exp = """\ 1: a 2: | with newline """ <|code_end|> using the current file's imports: import pytest import platform import srsly import srsly from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.scalarstring import walk_tree, preserve_literal from srsly.ruamel_yaml.scalarstring import DoubleQuotedScalarString as dq from srsly.ruamel_yaml.scalarstring import SingleQuotedScalarString as sq and any relevant context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(data) == dedent(exp)
Continue the code snippet: <|code_start|> from __future__ import absolute_import # This module contains abstractions for the input stream. You don't have to # looks further, there are no pretty code. # # We define two classes here. # # Mark(source, line, column) # It's just a record and its only use is producing nice error messages. # Parser does not use it for any other purposes. # # Reader(source, data) # Reader determines the encoding of `data` and converts it to unicode. # Reader provides the following methods and attributes: # reader.peek(length=1) - return the next `length` characters # reader.forward(length=1) - move the current position to `length` # characters. # reader.index - the number of the current character. # reader.line, stream.column - the line and the column of the current # character. if False: # MYPY # from srsly.ruamel_yaml.compat import StreamTextType # NOQA __all__ = ["Reader", "ReaderError"] <|code_end|> . Use current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): . Output only the next line.
class ReaderError(YAMLError):
Given snippet: <|code_start|> ch == u"\r" and self.buffer[self.pointer] != u"\n" ): self.line += 1 self.column = 0 elif ch != u"\uFEFF": self.column += 1 length -= 1 def forward(self, length=1): # type: (int) -> None if self.pointer + length + 1 >= len(self.buffer): self.update(length + 1) while length != 0: ch = self.buffer[self.pointer] self.pointer += 1 self.index += 1 if ch == u"\n" or (ch == u"\r" and self.buffer[self.pointer] != u"\n"): self.line += 1 self.column = 0 elif ch != u"\uFEFF": self.column += 1 length -= 1 def get_mark(self): # type: () -> Any if self.stream is None: return StringMark( self.name, self.index, self.line, self.column, self.buffer, self.pointer ) else: <|code_end|> , continue by predicting the next line. Consider current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): which might include code, classes, or functions. Output only the next line.
return FileMark(self.name, self.index, self.line, self.column)
Given snippet: <|code_start|> ch = self.buffer[self.pointer] self.pointer += 1 self.index += 1 if ch in u"\n\x85\u2028\u2029" or ( ch == u"\r" and self.buffer[self.pointer] != u"\n" ): self.line += 1 self.column = 0 elif ch != u"\uFEFF": self.column += 1 length -= 1 def forward(self, length=1): # type: (int) -> None if self.pointer + length + 1 >= len(self.buffer): self.update(length + 1) while length != 0: ch = self.buffer[self.pointer] self.pointer += 1 self.index += 1 if ch == u"\n" or (ch == u"\r" and self.buffer[self.pointer] != u"\n"): self.line += 1 self.column = 0 elif ch != u"\uFEFF": self.column += 1 length -= 1 def get_mark(self): # type: () -> Any if self.stream is None: <|code_end|> , continue by predicting the next line. Consider current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): which might include code, classes, or functions. Output only the next line.
return StringMark(
Here is a snippet: <|code_start|> # Yeah, it's ugly and slow. def __init__(self, stream, loader=None): # type: (Any, Any) -> None self.loader = loader if self.loader is not None and getattr(self.loader, "_reader", None) is None: self.loader._reader = self self.reset_reader() self.stream = stream # type: Any # as .read is called def reset_reader(self): # type: () -> None self.name = None # type: Any self.stream_pointer = 0 self.eof = True self.buffer = "" self.pointer = 0 self.raw_buffer = None # type: Any self.raw_decode = None self.encoding = None # type: Optional[Text] self.index = 0 self.line = 0 self.column = 0 @property def stream(self): # type: () -> Any try: return self._stream except AttributeError: <|code_end|> . Write the next line using the current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may include functions, classes, or code. Output only the next line.
raise YAMLStreamError("input stream needs to specified")
Predict the next line for this snippet: <|code_start|> self.stream = stream # type: Any # as .read is called def reset_reader(self): # type: () -> None self.name = None # type: Any self.stream_pointer = 0 self.eof = True self.buffer = "" self.pointer = 0 self.raw_buffer = None # type: Any self.raw_decode = None self.encoding = None # type: Optional[Text] self.index = 0 self.line = 0 self.column = 0 @property def stream(self): # type: () -> Any try: return self._stream except AttributeError: raise YAMLStreamError("input stream needs to specified") @stream.setter def stream(self, val): # type: (Any) -> None if val is None: return self._stream = None <|code_end|> with the help of current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may contain function names, class names, or code. Output only the next line.
if isinstance(val, text_type):
Predict the next line for this snippet: <|code_start|># # Reader(source, data) # Reader determines the encoding of `data` and converts it to unicode. # Reader provides the following methods and attributes: # reader.peek(length=1) - return the next `length` characters # reader.forward(length=1) - move the current position to `length` # characters. # reader.index - the number of the current character. # reader.line, stream.column - the line and the column of the current # character. if False: # MYPY # from srsly.ruamel_yaml.compat import StreamTextType # NOQA __all__ = ["Reader", "ReaderError"] class ReaderError(YAMLError): def __init__(self, name, position, character, encoding, reason): # type: (Any, Any, Any, Any, Any) -> None self.name = name self.character = character self.position = position self.encoding = encoding self.reason = reason def __str__(self): # type: () -> str <|code_end|> with the help of current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may contain function names, class names, or code. Output only the next line.
if isinstance(self.character, binary_type):
Next line prediction: <|code_start|> def check_printable(self, data): # type: (Any) -> None non_printable_match = self._get_non_printable(data) if non_printable_match is not None: start, character = non_printable_match position = self.index + (len(self.buffer) - self.pointer) + start raise ReaderError( self.name, position, ord(character), "unicode", "special characters are not allowed", ) def update(self, length): # type: (int) -> None if self.raw_buffer is None: return self.buffer = self.buffer[self.pointer :] self.pointer = 0 while len(self.buffer) < length: if not self.eof: self.update_raw() if self.raw_decode is not None: try: data, converted = self.raw_decode( self.raw_buffer, "strict", self.eof ) except UnicodeDecodeError as exc: <|code_end|> . Use current file imports: (import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA) and context including class names, function names, or small code snippets from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): . Output only the next line.
if PY3:
Here is a snippet: <|code_start|> self.column = 0 elif ch != u"\uFEFF": self.column += 1 length -= 1 def get_mark(self): # type: () -> Any if self.stream is None: return StringMark( self.name, self.index, self.line, self.column, self.buffer, self.pointer ) else: return FileMark(self.name, self.index, self.line, self.column) def determine_encoding(self): # type: () -> None while not self.eof and (self.raw_buffer is None or len(self.raw_buffer) < 2): self.update_raw() if isinstance(self.raw_buffer, binary_type): if self.raw_buffer.startswith(codecs.BOM_UTF16_LE): self.raw_decode = codecs.utf_16_le_decode # type: ignore self.encoding = "utf-16-le" elif self.raw_buffer.startswith(codecs.BOM_UTF16_BE): self.raw_decode = codecs.utf_16_be_decode # type: ignore self.encoding = "utf-16-be" else: self.raw_decode = codecs.utf_8_decode # type: ignore self.encoding = "utf-8" self.update(1) <|code_end|> . Write the next line using the current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may include functions, classes, or code. Output only the next line.
if UNICODE_SIZE == 2:
Given snippet: <|code_start|> elif ch != u"\uFEFF": self.column += 1 length -= 1 def get_mark(self): # type: () -> Any if self.stream is None: return StringMark( self.name, self.index, self.line, self.column, self.buffer, self.pointer ) else: return FileMark(self.name, self.index, self.line, self.column) def determine_encoding(self): # type: () -> None while not self.eof and (self.raw_buffer is None or len(self.raw_buffer) < 2): self.update_raw() if isinstance(self.raw_buffer, binary_type): if self.raw_buffer.startswith(codecs.BOM_UTF16_LE): self.raw_decode = codecs.utf_16_le_decode # type: ignore self.encoding = "utf-16-le" elif self.raw_buffer.startswith(codecs.BOM_UTF16_BE): self.raw_decode = codecs.utf_16_be_decode # type: ignore self.encoding = "utf-16-be" else: self.raw_decode = codecs.utf_8_decode # type: ignore self.encoding = "utf-8" self.update(1) if UNICODE_SIZE == 2: <|code_end|> , continue by predicting the next line. Consider current file imports: import codecs from .error import YAMLError, FileMark, StringMark, YAMLStreamError from .compat import text_type, binary_type, PY3, UNICODE_SIZE from .util import RegExp from typing import Any, Dict, Optional, List, Union, Text, Tuple, Optional # NOQA and context: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class FileMark(StreamMark): # __slots__ = () # # class StringMark(StreamMark): # __slots__ = "name", "index", "line", "column", "buffer", "pointer" # # def __init__(self, name, index, line, column, buffer, pointer): # # type: (Any, int, int, int, Any, Any) -> None # StreamMark.__init__(self, name, index, line, column) # self.buffer = buffer # self.pointer = pointer # # def get_snippet(self, indent=4, max_length=75): # # type: (int, int) -> Any # if self.buffer is None: # always False # return None # head = "" # start = self.pointer # while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": # start -= 1 # if self.pointer - start > max_length / 2 - 1: # head = " ... " # start += 5 # break # tail = "" # end = self.pointer # while ( # end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" # ): # end += 1 # if end - self.pointer > max_length / 2 - 1: # tail = " ... " # end -= 5 # break # snippet = utf8(self.buffer[start:end]) # caret = "^" # caret = "^ (line: {})".format(self.line + 1) # return ( # " " * indent # + head # + snippet # + tail # + "\n" # + " " * (indent + self.pointer - start + len(head)) # + caret # ) # # def __str__(self): # # type: () -> Any # snippet = self.get_snippet() # where = ' in "%s", line %d, column %d' % ( # self.name, # self.line + 1, # self.column + 1, # ) # if snippet is not None: # where += ":\n" + snippet # return where # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): which might include code, classes, or functions. Output only the next line.
NON_PRINTABLE = RegExp(
Next line prediction: <|code_start|>from __future__ import print_function """ various test cases for YAML files """ class TestYAML: def test_backslash(self): <|code_end|> . Use current file imports: (import sys import pytest # NOQA import platform import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.compat import ordereddict from collections import OrderedDict from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.constructor import CommentedSet) and context including class names, function names, or small code snippets from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
round_trip(
Continue the code snippet: <|code_start|>from __future__ import print_function """ various test cases for YAML files """ class TestYAML: def test_backslash(self): round_trip( """ handlers: static_files: applications/\\1/static/\\2 """ ) def test_omap_out(self): # ordereddict mapped to !!omap x = ordereddict([("a", 1), ("b", 2)]) res = srsly.ruamel_yaml.dump(x, default_flow_style=False) <|code_end|> . Use current file imports: import sys import pytest # NOQA import platform import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.compat import ordereddict from collections import OrderedDict from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.constructor import CommentedSet and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert res == dedent(
Predict the next line after this snippet: <|code_start|> round_trip( """ # Seq with empty lines in between items. b: - bar - baz """ ) @pytest.mark.skipif( platform.python_implementation() == "Jython", reason="Jython throws RepresenterError", ) def test_blank_line_after_literal_chip(self): s = """ c: - | This item has a blank line following it. - | To visually separate it from this item. This item contains a blank line. """ <|code_end|> using the current file's imports: import sys import pytest # NOQA import platform import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.compat import ordereddict from collections import OrderedDict from srsly.ruamel_yaml.compat import ordereddict from srsly.ruamel_yaml.constructor import CommentedSet and any relevant context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
d = round_trip_load(dedent(s))
Given the following code snippet before the placeholder: <|code_start|># coding: utf-8 from __future__ import print_function def load(s): return round_trip_load(dedent(s)) def compare(data, s, **kw): <|code_end|> , predict the next line using imports from the current file: import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.comments import CommentedSeq from srsly.ruamel_yaml.comments import CommentedMap from srsly.ruamel_yaml.comments import CommentedMap, CommentedSeq from srsly.ruamel_yaml.comments import CommentedMap, CommentedSeq and context including class names, function names, and sometimes code from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(data, **kw) == dedent(s)
Given the following code snippet before the placeholder: <|code_start|># coding: utf-8 """ Testing copy and deepcopy, instigated by Issue 84 (Peter Amstutz) """ class TestDeepCopy: def test_preserve_flow_style_simple(self): <|code_end|> , predict the next line using imports from the current file: import copy import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context including class names, function names, and sometimes code from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
x = dedent(
Using the snippet: <|code_start|># coding: utf-8 """ Testing copy and deepcopy, instigated by Issue 84 (Peter Amstutz) """ class TestDeepCopy: def test_preserve_flow_style_simple(self): x = dedent( """\ {foo: bar, baz: quux} """ ) <|code_end|> , determine the next line of code. You have imports: import copy import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context (class names, function names, or code) available: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
data = round_trip_load(x)
Using the snippet: <|code_start|># coding: utf-8 """ Testing copy and deepcopy, instigated by Issue 84 (Peter Amstutz) """ class TestDeepCopy: def test_preserve_flow_style_simple(self): x = dedent( """\ {foo: bar, baz: quux} """ ) data = round_trip_load(x) data_copy = copy.deepcopy(data) <|code_end|> , determine the next line of code. You have imports: import copy import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context (class names, function names, or code) available: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
y = round_trip_dump(data_copy)
Given snippet: <|code_start|> # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if "yaml_path_resolvers" not in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] # type: List[Any] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % (element,)) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is dict: node_check = MappingNode elif ( node_check not in [ScalarNode, SequenceNode, MappingNode] <|code_end|> , continue by predicting the next line. Consider current file imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): which might include code, classes, or functions. Output only the next line.
and not isinstance(node_check, string_types)
Continue the code snippet: <|code_start|> implicit = implicit[1] if bool(self.yaml_path_resolvers): exact_paths = self.resolver_exact_paths[-1] if kind in exact_paths: return exact_paths[kind] if None in exact_paths: return exact_paths[None] if kind is ScalarNode: return self.DEFAULT_SCALAR_TAG elif kind is SequenceNode: return self.DEFAULT_SEQUENCE_TAG elif kind is MappingNode: return self.DEFAULT_MAPPING_TAG @property def processing_version(self): # type: () -> Any try: version = self.loadumper._scanner.yaml_version except AttributeError: try: if hasattr(self.loadumper, "typ"): version = self.loadumper.version else: version = self.loadumper._serializer.use_version # dumping except AttributeError: version = None if version is None: version = self._loader_version if version is None: <|code_end|> . Use current file imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): . Output only the next line.
version = _DEFAULT_YAML_VERSION
Given snippet: <|code_start|> # root to the node that is being considered. `node_path` elements are # tuples `(node_check, index_check)`. `node_check` is a node class: # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if "yaml_path_resolvers" not in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] # type: List[Any] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % (element,)) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: node_check = SequenceNode elif node_check is dict: <|code_end|> , continue by predicting the next line. Consider current file imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): which might include code, classes, or functions. Output only the next line.
node_check = MappingNode
Based on the snippet: <|code_start|> def add_path_resolver(cls, tag, path, kind=None): # type: (Any, Any, Any) -> None # Note: `add_path_resolver` is experimental. The API could be changed. # `new_path` is a pattern that is matched against the path from the # root to the node that is being considered. `node_path` elements are # tuples `(node_check, index_check)`. `node_check` is a node class: # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if "yaml_path_resolvers" not in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] # type: List[Any] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % (element,)) else: node_check = None index_check = element if node_check is str: <|code_end|> , predict the immediate next line with the help of imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context (classes, functions, sometimes code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): . Output only the next line.
node_check = ScalarNode
Here is a snippet: <|code_start|> # Note: `add_path_resolver` is experimental. The API could be changed. # `new_path` is a pattern that is matched against the path from the # root to the node that is being considered. `node_path` elements are # tuples `(node_check, index_check)`. `node_check` is a node class: # `ScalarNode`, `SequenceNode`, `MappingNode` or `None`. `None` # matches any kind of a node. `index_check` could be `None`, a boolean # value, a string value, or a number. `None` and `False` match against # any _value_ of sequence and mapping nodes. `True` matches against # any _key_ of a mapping node. A string `index_check` matches against # a mapping value that corresponds to a scalar key which content is # equal to the `index_check` value. An integer `index_check` matches # against a sequence value with the index equal to `index_check`. if "yaml_path_resolvers" not in cls.__dict__: cls.yaml_path_resolvers = cls.yaml_path_resolvers.copy() new_path = [] # type: List[Any] for element in path: if isinstance(element, (list, tuple)): if len(element) == 2: node_check, index_check = element elif len(element) == 1: node_check = element[0] index_check = True else: raise ResolverError("Invalid path element: %s" % (element,)) else: node_check = None index_check = element if node_check is str: node_check = ScalarNode elif node_check is list: <|code_end|> . Write the next line using the current file imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may include functions, classes, or code. Output only the next line.
node_check = SequenceNode
Predict the next line for this snippet: <|code_start|># coding: utf-8 from __future__ import absolute_import if False: # MYPY __all__ = ["BaseResolver", "Resolver", "VersionedResolver"] # fmt: off # resolvers consist of # - a list of applicable version # - a tag # - a regexp # - a list of first characters to match implicit_resolvers = [ ([(1, 2)], u'tag:yaml.org,2002:bool', <|code_end|> with the help of current file imports: import re from typing import Any, Dict, List, Union, Text, Optional # NOQA from .compat import VersionType # NOQA from .compat import string_types, _DEFAULT_YAML_VERSION # NOQA from .error import * # NOQA from .nodes import MappingNode, ScalarNode, SequenceNode # NOQA from .util import RegExp # NOQA and context from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/nodes.py # class MappingNode(CollectionNode): # __slots__ = ('merge',) # id = 'mapping' # # def __init__( # self, # tag, # value, # start_mark=None, # end_mark=None, # flow_style=None, # comment=None, # anchor=None, # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # CollectionNode.__init__( # self, tag, value, start_mark, end_mark, flow_style, comment, anchor # ) # self.merge = None # # class ScalarNode(Node): # """ # styles: # ? -> set() ? key, no value # " -> double quoted # ' -> single quoted # | -> literal style # > -> folding style # """ # # __slots__ = ('style',) # id = 'scalar' # # def __init__( # self, tag, value, start_mark=None, end_mark=None, style=None, comment=None, anchor=None # ): # # type: (Any, Any, Any, Any, Any, Any, Any) -> None # Node.__init__(self, tag, value, start_mark, end_mark, comment=comment, anchor=anchor) # self.style = style # # class SequenceNode(CollectionNode): # __slots__ = () # id = 'sequence' # # Path: srsly/ruamel_yaml/util.py # class LazyEval(object): # def __init__(self, func, *args, **kwargs): # def lazy_self(): # def __getattribute__(self, name): # def __setattr__(self, name, value): # def load_yaml_guess_indent(stream, **kw): # def leading_spaces(l): # def configobj_walker(cfg): # def _walk_section(s, level=0): , which may contain function names, class names, or code. Output only the next line.
RegExp(u'''^(?:true|True|TRUE|false|False|FALSE)$''', re.X),
Given snippet: <|code_start|> __slots__ = "name", "index", "line", "column", "buffer", "pointer" def __init__(self, name, index, line, column, buffer, pointer): # type: (Any, int, int, int, Any, Any) -> None StreamMark.__init__(self, name, index, line, column) self.buffer = buffer self.pointer = pointer def get_snippet(self, indent=4, max_length=75): # type: (int, int) -> Any if self.buffer is None: # always False return None head = "" start = self.pointer while start > 0 and self.buffer[start - 1] not in u"\0\r\n\x85\u2028\u2029": start -= 1 if self.pointer - start > max_length / 2 - 1: head = " ... " start += 5 break tail = "" end = self.pointer while ( end < len(self.buffer) and self.buffer[end] not in u"\0\r\n\x85\u2028\u2029" ): end += 1 if end - self.pointer > max_length / 2 - 1: tail = " ... " end -= 5 break <|code_end|> , continue by predicting the next line. Consider current file imports: import warnings import textwrap from .compat import utf8 from typing import Any, Dict, Optional, List, Text # NOQA and context: # Path: srsly/ruamel_yaml/compat.py # def utf8(s): # # type: (str) -> str # return s which might include code, classes, or functions. Output only the next line.
snippet = utf8(self.buffer[start:end])
Predict the next line after this snippet: <|code_start|>""" class User0(object): def __init__(self, name, age): self.name = name self.age = age class User1(object): yaml_tag = u"!user" def __init__(self, name, age): self.name = name self.age = age @classmethod def to_yaml(cls, representer, node): return representer.represent_scalar( cls.yaml_tag, u"{.name}-{.age}".format(node, node) ) @classmethod def from_yaml(cls, constructor, node): return cls(*node.value.split("-")) class TestRegisterClass(object): def test_register_0_rt(self): <|code_end|> using the current file's imports: from .roundtrip import YAML from srsly.ruamel_yaml import yaml_object from srsly.ruamel_yaml import yaml_object and any relevant context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def YAML(**kw): # import srsly.ruamel_yaml # NOQA # # class MyYAML(srsly.ruamel_yaml.YAML): # """auto dedent string parameters on load""" # # def load(self, stream): # if isinstance(stream, str): # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # return srsly.ruamel_yaml.YAML.load(self, stream) # # def load_all(self, stream): # if isinstance(stream, str): # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # for d in srsly.ruamel_yaml.YAML.load_all(self, stream): # yield d # # def dump(self, data, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert ("stream" in kw) ^ ("compare" in kw) # if "stream" in kw: # return srsly.ruamel_yaml.YAML.dump(data, **kw) # lkw = kw.copy() # expected = textwrap.dedent(lkw.pop("compare")) # unordered_lines = lkw.pop("unordered_lines", False) # if expected and expected[0] == "\n": # expected = expected[1:] # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump(self, data, **lkw) # res = st.getvalue() # print(res) # if unordered_lines: # res = sorted(res.splitlines()) # expected = sorted(expected.splitlines()) # assert res == expected # # def round_trip(self, stream, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert isinstance(stream, (srsly.ruamel_yaml.compat.text_type, str)) # lkw = kw.copy() # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # data = srsly.ruamel_yaml.YAML.load(self, stream) # outp = lkw.pop("outp", stream) # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump(self, data, **lkw) # res = st.getvalue() # if res != outp: # diff(outp, res, "input string") # assert res == outp # # def round_trip_all(self, stream, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert isinstance(stream, (srsly.ruamel_yaml.compat.text_type, str)) # lkw = kw.copy() # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # data = list(srsly.ruamel_yaml.YAML.load_all(self, stream)) # outp = lkw.pop("outp", stream) # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump_all(self, data, **lkw) # res = st.getvalue() # if res != outp: # diff(outp, res, "input string") # assert res == outp # # return MyYAML(**kw) . Output only the next line.
yaml = YAML()
Using the snippet: <|code_start|>""" http://yaml.org/type/timestamp.html specifies the regexp to use for datetime.date and datetime.datetime construction. Date is simple but datetime can have 'T' or 't' as well as 'Z' or a timezone offset (in hours and minutes). This information was originally used to create a UTC datetime and then discarded examples from the above: canonical: 2001-12-15T02:59:43.1Z valid iso8601: 2001-12-14t21:59:43.10-05:00 space separated: 2001-12-14 21:59:43.10 -5 no time zone (Z): 2001-12-15 2:59:43.10 date (00:00:00Z): 2002-12-14 Please note that a fraction can only be included if not equal to 0 """ class TestDateTime: def test_date_only(self): inp = """ - 2011-10-02 """ exp = """ - 2011-10-02 """ <|code_end|> , determine the next line of code. You have imports: import copy import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA and context (class names, function names, or code) available: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
round_trip(inp, exp)
Given the following code snippet before the placeholder: <|code_start|> - 2011-10-02 16:45:00 """ exp = """ - 2011-10-02 16:45:00 """ round_trip(inp, exp) def test_iso(self): round_trip( """ - 2011-10-02T15:45:00+01:00 """ ) def test_zero_tz(self): round_trip( """ - 2011-10-02T15:45:00+0 """ ) def test_issue_45(self): round_trip( """ dt: 2016-08-19T22:45:47Z """ ) def test_deepcopy_datestring(self): # reported by Quuxplusone, http://stackoverflow.com/a/41577841/1307905 <|code_end|> , predict the next line using imports from the current file: import copy import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA and context including class names, function names, and sometimes code from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
x = dedent(
Predict the next line for this snippet: <|code_start|> round_trip(inp, exp) def test_iso(self): round_trip( """ - 2011-10-02T15:45:00+01:00 """ ) def test_zero_tz(self): round_trip( """ - 2011-10-02T15:45:00+0 """ ) def test_issue_45(self): round_trip( """ dt: 2016-08-19T22:45:47Z """ ) def test_deepcopy_datestring(self): # reported by Quuxplusone, http://stackoverflow.com/a/41577841/1307905 x = dedent( """\ foo: 2016-10-12T12:34:56 """ ) <|code_end|> with the help of current file imports: import copy import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) , which may contain function names, class names, or code. Output only the next line.
data = copy.deepcopy(round_trip_load(x))
Predict the next line for this snippet: <|code_start|> def test_iso(self): round_trip( """ - 2011-10-02T15:45:00+01:00 """ ) def test_zero_tz(self): round_trip( """ - 2011-10-02T15:45:00+0 """ ) def test_issue_45(self): round_trip( """ dt: 2016-08-19T22:45:47Z """ ) def test_deepcopy_datestring(self): # reported by Quuxplusone, http://stackoverflow.com/a/41577841/1307905 x = dedent( """\ foo: 2016-10-12T12:34:56 """ ) data = copy.deepcopy(round_trip_load(x)) <|code_end|> with the help of current file imports: import copy import pytest # NOQA from .roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) , which may contain function names, class names, or code. Output only the next line.
assert round_trip_dump(data) == x
Based on the snippet: <|code_start|> # type: (Any, Any) -> None setattr(self.lazy_self(), name, value) RegExp = partial(LazyEval, re.compile) # originally as comment # https://github.com/pre-commit/pre-commit/pull/211#issuecomment-186466605 # if you use this in your code, I suggest adding a test in your test suite # that check this routines output against a known piece of your YAML # before upgrades to this code break your round-tripped YAML def load_yaml_guess_indent(stream, **kw): # type: (StreamTextType, Any) -> Any """guess the indent and block sequence indent of yaml stream/string returns round_trip_loaded stream, indent level, block sequence indent - block sequence indent is the number of spaces before a dash relative to previous indent - if there are no block sequences, indent is taken from nested mappings, block sequence indent is unset (None) in that case """ # load a yaml file guess the indentation, if you use TABs ... def leading_spaces(l): # type: (Any) -> int idx = 0 while idx < len(l) and l[idx] == ' ': idx += 1 return idx <|code_end|> , predict the immediate next line with the help of imports: from functools import partial from .compat import text_type, binary_type from typing import Any, Dict, Optional, List, Text # NOQA from .compat import StreamTextType # NOQA from .main import round_trip_load from configobj import ConfigObj # type: ignore from configobj import Section import re and context (classes, functions, sometimes code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if isinstance(stream, text_type):
Given the code snippet: <|code_start|> RegExp = partial(LazyEval, re.compile) # originally as comment # https://github.com/pre-commit/pre-commit/pull/211#issuecomment-186466605 # if you use this in your code, I suggest adding a test in your test suite # that check this routines output against a known piece of your YAML # before upgrades to this code break your round-tripped YAML def load_yaml_guess_indent(stream, **kw): # type: (StreamTextType, Any) -> Any """guess the indent and block sequence indent of yaml stream/string returns round_trip_loaded stream, indent level, block sequence indent - block sequence indent is the number of spaces before a dash relative to previous indent - if there are no block sequences, indent is taken from nested mappings, block sequence indent is unset (None) in that case """ # load a yaml file guess the indentation, if you use TABs ... def leading_spaces(l): # type: (Any) -> int idx = 0 while idx < len(l) and l[idx] == ' ': idx += 1 return idx if isinstance(stream, text_type): yaml_str = stream # type: Any <|code_end|> , generate the next line using the imports in this file: from functools import partial from .compat import text_type, binary_type from typing import Any, Dict, Optional, List, Text # NOQA from .compat import StreamTextType # NOQA from .main import round_trip_load from configobj import ConfigObj # type: ignore from configobj import Section import re and context (functions, classes, or occasionally code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
elif isinstance(stream, binary_type):
Predict the next line for this snippet: <|code_start|> key, value = item try: v = self._mapping[key] except KeyError: return False else: return v == value def __iter__(self): # type: () -> Any for key in self._mapping._keys(): yield (key, self._mapping[key]) class CommentedMapValuesView(CommentedMapView): __slots__ = () def __contains__(self, value): # type: (Any) -> Any for key in self._mapping: if value == self._mapping[key]: return True return False def __iter__(self): # type: () -> Any for key in self._mapping._keys(): yield self._mapping[key] <|code_end|> with the help of current file imports: import sys import copy from .compat import ordereddict # type: ignore from .compat import PY2, string_types, MutableSliceableSequence from .scalarstring import ScalarString from .anchor import Anchor from collections import MutableSet, Sized, Set, Mapping from collections.abc import MutableSet, Sized, Set, Mapping from typing import Any, Dict, Optional, List, Union, Optional, Iterator # NOQA from .error import CommentMark from .tokens import CommentToken from srsly.ruamel_yaml.error import CommentMark from srsly.ruamel_yaml.tokens import CommentToken from .tokens import CommentToken from .error import CommentMark and context from other files: # Path: srsly/ruamel_yaml/compat.py # class ordereddict(OrderedDict): # type: ignore # if not hasattr(OrderedDict, "insert"): # # def insert(self, pos, key, value): # # type: (int, Any, Any) -> None # if pos >= len(self): # self[key] = value # return # od = ordereddict() # od.update(self) # for k in od: # del self[k] # for index, old_key in enumerate(od): # if pos == index: # self[key] = value # self[old_key] = od[old_key] # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/scalarstring.py # class ScalarString(text_type): # __slots__ = Anchor.attrib # # def __new__(cls, *args, **kw): # # type: (Any, Any) -> Any # anchor = kw.pop("anchor", None) # type: ignore # ret_val = text_type.__new__(cls, *args, **kw) # type: ignore # if anchor is not None: # ret_val.yaml_set_anchor(anchor, always_dump=True) # return ret_val # # def replace(self, old, new, maxreplace=-1): # # type: (Any, Any, int) -> Any # return type(self)((text_type.replace(self, old, new, maxreplace))) # # @property # def anchor(self): # # type: () -> Any # if not hasattr(self, Anchor.attrib): # setattr(self, Anchor.attrib, Anchor()) # return getattr(self, Anchor.attrib) # # def yaml_anchor(self, any=False): # # type: (bool) -> Any # if not hasattr(self, Anchor.attrib): # return None # if any or self.anchor.always_dump: # return self.anchor # return None # # def yaml_set_anchor(self, value, always_dump=False): # # type: (Any, bool) -> None # self.anchor.value = value # self.anchor.always_dump = always_dump , which may contain function names, class names, or code. Output only the next line.
class CommentedMap(ordereddict, CommentedBase): # type: ignore
Continue the code snippet: <|code_start|># coding: utf-8 from __future__ import absolute_import, print_function """ stuff to deal with comments and formatting on dict/list/ordereddict/set these are not really related, formatting could be factored out as a separate base """ <|code_end|> . Use current file imports: import sys import copy from .compat import ordereddict # type: ignore from .compat import PY2, string_types, MutableSliceableSequence from .scalarstring import ScalarString from .anchor import Anchor from collections import MutableSet, Sized, Set, Mapping from collections.abc import MutableSet, Sized, Set, Mapping from typing import Any, Dict, Optional, List, Union, Optional, Iterator # NOQA from .error import CommentMark from .tokens import CommentToken from srsly.ruamel_yaml.error import CommentMark from srsly.ruamel_yaml.tokens import CommentToken from .tokens import CommentToken from .error import CommentMark and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/compat.py # class ordereddict(OrderedDict): # type: ignore # if not hasattr(OrderedDict, "insert"): # # def insert(self, pos, key, value): # # type: (int, Any, Any) -> None # if pos >= len(self): # self[key] = value # return # od = ordereddict() # od.update(self) # for k in od: # del self[k] # for index, old_key in enumerate(od): # if pos == index: # self[key] = value # self[old_key] = od[old_key] # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/scalarstring.py # class ScalarString(text_type): # __slots__ = Anchor.attrib # # def __new__(cls, *args, **kw): # # type: (Any, Any) -> Any # anchor = kw.pop("anchor", None) # type: ignore # ret_val = text_type.__new__(cls, *args, **kw) # type: ignore # if anchor is not None: # ret_val.yaml_set_anchor(anchor, always_dump=True) # return ret_val # # def replace(self, old, new, maxreplace=-1): # # type: (Any, Any, int) -> Any # return type(self)((text_type.replace(self, old, new, maxreplace))) # # @property # def anchor(self): # # type: () -> Any # if not hasattr(self, Anchor.attrib): # setattr(self, Anchor.attrib, Anchor()) # return getattr(self, Anchor.attrib) # # def yaml_anchor(self, any=False): # # type: (bool) -> Any # if not hasattr(self, Anchor.attrib): # return None # if any or self.anchor.always_dump: # return self.anchor # return None # # def yaml_set_anchor(self, value, always_dump=False): # # type: (Any, bool) -> None # self.anchor.value = value # self.anchor.always_dump = always_dump . Output only the next line.
if PY2:
Predict the next line after this snippet: <|code_start|> def _yaml_add_eol_comment(self, comment, key): # type: (Any, Any) -> None raise NotImplementedError def _yaml_get_pre_comment(self): # type: () -> Any raise NotImplementedError def _yaml_get_column(self, key): # type: (Any) -> Any raise NotImplementedError class CommentedSeq(MutableSliceableSequence, list, CommentedBase): # type: ignore __slots__ = (Comment.attrib, "_lst") def __init__(self, *args, **kw): # type: (Any, Any) -> None list.__init__(self, *args, **kw) def __getsingleitem__(self, idx): # type: (Any) -> Any return list.__getitem__(self, idx) def __setsingleitem__(self, idx, value): # type: (Any, Any) -> None # try to preserve the scalarstring type if setting an existing key to a new value if idx < len(self): if ( <|code_end|> using the current file's imports: import sys import copy from .compat import ordereddict # type: ignore from .compat import PY2, string_types, MutableSliceableSequence from .scalarstring import ScalarString from .anchor import Anchor from collections import MutableSet, Sized, Set, Mapping from collections.abc import MutableSet, Sized, Set, Mapping from typing import Any, Dict, Optional, List, Union, Optional, Iterator # NOQA from .error import CommentMark from .tokens import CommentToken from srsly.ruamel_yaml.error import CommentMark from srsly.ruamel_yaml.tokens import CommentToken from .tokens import CommentToken from .error import CommentMark and any relevant context from other files: # Path: srsly/ruamel_yaml/compat.py # class ordereddict(OrderedDict): # type: ignore # if not hasattr(OrderedDict, "insert"): # # def insert(self, pos, key, value): # # type: (int, Any, Any) -> None # if pos >= len(self): # self[key] = value # return # od = ordereddict() # od.update(self) # for k in od: # del self[k] # for index, old_key in enumerate(od): # if pos == index: # self[key] = value # self[old_key] = od[old_key] # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/scalarstring.py # class ScalarString(text_type): # __slots__ = Anchor.attrib # # def __new__(cls, *args, **kw): # # type: (Any, Any) -> Any # anchor = kw.pop("anchor", None) # type: ignore # ret_val = text_type.__new__(cls, *args, **kw) # type: ignore # if anchor is not None: # ret_val.yaml_set_anchor(anchor, always_dump=True) # return ret_val # # def replace(self, old, new, maxreplace=-1): # # type: (Any, Any, int) -> Any # return type(self)((text_type.replace(self, old, new, maxreplace))) # # @property # def anchor(self): # # type: () -> Any # if not hasattr(self, Anchor.attrib): # setattr(self, Anchor.attrib, Anchor()) # return getattr(self, Anchor.attrib) # # def yaml_anchor(self, any=False): # # type: (bool) -> Any # if not hasattr(self, Anchor.attrib): # return None # if any or self.anchor.always_dump: # return self.anchor # return None # # def yaml_set_anchor(self, value, always_dump=False): # # type: (Any, bool) -> None # self.anchor.value = value # self.anchor.always_dump = always_dump . Output only the next line.
isinstance(value, string_types)
Using the snippet: <|code_start|> def yaml_set_tag(self, value): # type: (Any) -> None self.tag.value = value def copy_attributes(self, t, memo=None): # type: (Any, Any) -> None # fmt: off for a in [Comment.attrib, Format.attrib, LineCol.attrib, Anchor.attrib, Tag.attrib, merge_attrib]: if hasattr(self, a): if memo is not None: setattr(t, a, copy.deepcopy(getattr(self, a, memo))) else: setattr(t, a, getattr(self, a)) # fmt: on def _yaml_add_eol_comment(self, comment, key): # type: (Any, Any) -> None raise NotImplementedError def _yaml_get_pre_comment(self): # type: () -> Any raise NotImplementedError def _yaml_get_column(self, key): # type: (Any) -> Any raise NotImplementedError <|code_end|> , determine the next line of code. You have imports: import sys import copy from .compat import ordereddict # type: ignore from .compat import PY2, string_types, MutableSliceableSequence from .scalarstring import ScalarString from .anchor import Anchor from collections import MutableSet, Sized, Set, Mapping from collections.abc import MutableSet, Sized, Set, Mapping from typing import Any, Dict, Optional, List, Union, Optional, Iterator # NOQA from .error import CommentMark from .tokens import CommentToken from srsly.ruamel_yaml.error import CommentMark from srsly.ruamel_yaml.tokens import CommentToken from .tokens import CommentToken from .error import CommentMark and context (class names, function names, or code) available: # Path: srsly/ruamel_yaml/compat.py # class ordereddict(OrderedDict): # type: ignore # if not hasattr(OrderedDict, "insert"): # # def insert(self, pos, key, value): # # type: (int, Any, Any) -> None # if pos >= len(self): # self[key] = value # return # od = ordereddict() # od.update(self) # for k in od: # del self[k] # for index, old_key in enumerate(od): # if pos == index: # self[key] = value # self[old_key] = od[old_key] # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/scalarstring.py # class ScalarString(text_type): # __slots__ = Anchor.attrib # # def __new__(cls, *args, **kw): # # type: (Any, Any) -> Any # anchor = kw.pop("anchor", None) # type: ignore # ret_val = text_type.__new__(cls, *args, **kw) # type: ignore # if anchor is not None: # ret_val.yaml_set_anchor(anchor, always_dump=True) # return ret_val # # def replace(self, old, new, maxreplace=-1): # # type: (Any, Any, int) -> Any # return type(self)((text_type.replace(self, old, new, maxreplace))) # # @property # def anchor(self): # # type: () -> Any # if not hasattr(self, Anchor.attrib): # setattr(self, Anchor.attrib, Anchor()) # return getattr(self, Anchor.attrib) # # def yaml_anchor(self, any=False): # # type: (bool) -> Any # if not hasattr(self, Anchor.attrib): # return None # if any or self.anchor.always_dump: # return self.anchor # return None # # def yaml_set_anchor(self, value, always_dump=False): # # type: (Any, bool) -> None # self.anchor.value = value # self.anchor.always_dump = always_dump . Output only the next line.
class CommentedSeq(MutableSliceableSequence, list, CommentedBase): # type: ignore
Predict the next line after this snippet: <|code_start|> def _yaml_add_eol_comment(self, comment, key): # type: (Any, Any) -> None raise NotImplementedError def _yaml_get_pre_comment(self): # type: () -> Any raise NotImplementedError def _yaml_get_column(self, key): # type: (Any) -> Any raise NotImplementedError class CommentedSeq(MutableSliceableSequence, list, CommentedBase): # type: ignore __slots__ = (Comment.attrib, "_lst") def __init__(self, *args, **kw): # type: (Any, Any) -> None list.__init__(self, *args, **kw) def __getsingleitem__(self, idx): # type: (Any) -> Any return list.__getitem__(self, idx) def __setsingleitem__(self, idx, value): # type: (Any, Any) -> None # try to preserve the scalarstring type if setting an existing key to a new value if idx < len(self): if ( isinstance(value, string_types) <|code_end|> using the current file's imports: import sys import copy from .compat import ordereddict # type: ignore from .compat import PY2, string_types, MutableSliceableSequence from .scalarstring import ScalarString from .anchor import Anchor from collections import MutableSet, Sized, Set, Mapping from collections.abc import MutableSet, Sized, Set, Mapping from typing import Any, Dict, Optional, List, Union, Optional, Iterator # NOQA from .error import CommentMark from .tokens import CommentToken from srsly.ruamel_yaml.error import CommentMark from srsly.ruamel_yaml.tokens import CommentToken from .tokens import CommentToken from .error import CommentMark and any relevant context from other files: # Path: srsly/ruamel_yaml/compat.py # class ordereddict(OrderedDict): # type: ignore # if not hasattr(OrderedDict, "insert"): # # def insert(self, pos, key, value): # # type: (int, Any, Any) -> None # if pos >= len(self): # self[key] = value # return # od = ordereddict() # od.update(self) # for k in od: # del self[k] # for index, old_key in enumerate(od): # if pos == index: # self[key] = value # self[old_key] = od[old_key] # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): # # Path: srsly/ruamel_yaml/scalarstring.py # class ScalarString(text_type): # __slots__ = Anchor.attrib # # def __new__(cls, *args, **kw): # # type: (Any, Any) -> Any # anchor = kw.pop("anchor", None) # type: ignore # ret_val = text_type.__new__(cls, *args, **kw) # type: ignore # if anchor is not None: # ret_val.yaml_set_anchor(anchor, always_dump=True) # return ret_val # # def replace(self, old, new, maxreplace=-1): # # type: (Any, Any, int) -> Any # return type(self)((text_type.replace(self, old, new, maxreplace))) # # @property # def anchor(self): # # type: () -> Any # if not hasattr(self, Anchor.attrib): # setattr(self, Anchor.attrib, Anchor()) # return getattr(self, Anchor.attrib) # # def yaml_anchor(self, any=False): # # type: (bool) -> Any # if not hasattr(self, Anchor.attrib): # return None # if any or self.anchor.always_dump: # return self.anchor # return None # # def yaml_set_anchor(self, value, always_dump=False): # # type: (Any, bool) -> None # self.anchor.value = value # self.anchor.always_dump = always_dump . Output only the next line.
and not isinstance(value, ScalarString)
Given snippet: <|code_start|># coding: utf-8 from __future__ import print_function """ YAML 1.0 allowed root level literal style without indentation: "Usually top level nodes are not indented" (example 4.21 in 4.6.3) YAML 1.1 is a bit vague but says: "Regardless of style, scalar content must always be indented by at least one space" (4.4.3) "In general, the document’s node is indented as if it has a parent indented at -1 spaces." (4.3.3) YAML 1.2 is again clear about root literal level scalar after directive in example 9.5: %YAML 1.2 --- | %!PS-Adobe-2.0 ... %YAML1.2 --- # Empty ... """ class TestNoIndent: def test_root_literal_scalar_indent_example_9_5(self): <|code_end|> , continue by predicting the next line. Consider current file imports: import pytest # NOQA from .roundtrip import YAML # does an automatic dedent on load from textwrap import dedent from srsly.ruamel_yaml import safe_load and context: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def YAML(**kw): # import srsly.ruamel_yaml # NOQA # # class MyYAML(srsly.ruamel_yaml.YAML): # """auto dedent string parameters on load""" # # def load(self, stream): # if isinstance(stream, str): # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # return srsly.ruamel_yaml.YAML.load(self, stream) # # def load_all(self, stream): # if isinstance(stream, str): # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # for d in srsly.ruamel_yaml.YAML.load_all(self, stream): # yield d # # def dump(self, data, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert ("stream" in kw) ^ ("compare" in kw) # if "stream" in kw: # return srsly.ruamel_yaml.YAML.dump(data, **kw) # lkw = kw.copy() # expected = textwrap.dedent(lkw.pop("compare")) # unordered_lines = lkw.pop("unordered_lines", False) # if expected and expected[0] == "\n": # expected = expected[1:] # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump(self, data, **lkw) # res = st.getvalue() # print(res) # if unordered_lines: # res = sorted(res.splitlines()) # expected = sorted(expected.splitlines()) # assert res == expected # # def round_trip(self, stream, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert isinstance(stream, (srsly.ruamel_yaml.compat.text_type, str)) # lkw = kw.copy() # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # data = srsly.ruamel_yaml.YAML.load(self, stream) # outp = lkw.pop("outp", stream) # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump(self, data, **lkw) # res = st.getvalue() # if res != outp: # diff(outp, res, "input string") # assert res == outp # # def round_trip_all(self, stream, **kw): # from srsly.ruamel_yaml.compat import StringIO, BytesIO # NOQA # # assert isinstance(stream, (srsly.ruamel_yaml.compat.text_type, str)) # lkw = kw.copy() # if stream and stream[0] == "\n": # stream = stream[1:] # stream = textwrap.dedent(stream) # data = list(srsly.ruamel_yaml.YAML.load_all(self, stream)) # outp = lkw.pop("outp", stream) # lkw["stream"] = st = StringIO() # srsly.ruamel_yaml.YAML.dump_all(self, data, **lkw) # res = st.getvalue() # if res != outp: # diff(outp, res, "input string") # assert res == outp # # return MyYAML(**kw) which might include code, classes, or functions. Output only the next line.
yaml = YAML()
Given the code snippet: <|code_start|> r = load(inp, version="1.1") assert r[0] == 45296 assert r[1] == 45296.78 assert r[2] == 10 assert r[3] == "012345678" assert r[4] == "0o12" assert r[5] is True assert r[6] is False assert r[7] is True assert r[8] is False assert r[9] is True class TestIssue62: # bitbucket issue 62, issue_62 def test_00(self): s = dedent( """\ {}# Outside flow collection: - ::vector - ": - ()" - Up, up, and away! - -123 - http://example.com/foo#bar # Inside flow collection: - [::vector, ": - ()", "Down, down and away!", -456, http://example.com/foo#bar] """ ) with pytest.raises(srsly.ruamel_yaml.parser.ParserError): <|code_end|> , generate the next line using the imports in this file: import pytest # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import dedent, round_trip, round_trip_load and context (functions, classes, or occasionally code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) . Output only the next line.
round_trip(s.format("%YAML 1.1\n---\n"), preserve_quotes=True)
Continue the code snippet: <|code_start|># coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals if False: # MYPY __all__ = ["ScalarInt", "BinaryInt", "OctalInt", "HexInt", "HexCapsInt", "DecimalInt"] <|code_end|> . Use current file imports: from .compat import no_limit_int # NOQA from .anchor import Anchor from typing import Text, Any, Dict, List # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
class ScalarInt(no_limit_int):
Given the following code snippet before the placeholder: <|code_start|># coding: utf-8 if False: # MYPY def configobj_walker(cfg): # type: (Any) -> Any warnings.warn( "configobj_walker has moved to srsly.ruamel_yaml.util, please update your code" ) <|code_end|> , predict the next line using imports from the current file: import warnings from .util import configobj_walker as new_configobj_walker from typing import Any # NOQA and context including class names, function names, and sometimes code from other files: # Path: srsly/ruamel_yaml/util.py # def configobj_walker(cfg): # # type: (Any) -> Any # """ # walks over a ConfigObj (INI file with comments) generating # corresponding YAML output (including comments # """ # from configobj import ConfigObj # type: ignore # # assert isinstance(cfg, ConfigObj) # for c in cfg.initial_comment: # if c.strip(): # yield c # for s in _walk_section(cfg): # if s.strip(): # yield s # for c in cfg.final_comment: # if c.strip(): # yield c . Output only the next line.
return new_configobj_walker(cfg)
Given the following code snippet before the placeholder: <|code_start|># coding: utf-8 from __future__ import absolute_import from __future__ import print_function # Emitter expects events obeying the following grammar: # stream ::= STREAM-START document* STREAM-END # document ::= DOCUMENT-START node DOCUMENT-END # node ::= SCALAR | sequence | mapping # sequence ::= SEQUENCE-START node* SEQUENCE-END # mapping ::= MAPPING-START (node node)* MAPPING-END # fmt: off # fmt: on if False: # MYPY __all__ = ["Emitter", "EmitterError"] <|code_end|> , predict the next line using imports from the current file: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and context including class names, function names, and sometimes code from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
class EmitterError(YAMLError):
Predict the next line after this snippet: <|code_start|> self.best_sequence_indent = indent self.best_map_indent = self.best_sequence_indent # if self.best_sequence_indent < self.sequence_dash_offset + 1: # self.best_sequence_indent = self.sequence_dash_offset + 1 self.best_width = 80 if width and width > self.best_sequence_indent * 2: self.best_width = width self.best_line_break = u"\n" # type: Any if line_break in [u"\r", u"\n", u"\r\n"]: self.best_line_break = line_break # Tag prefixes. self.tag_prefixes = None # type: Any # Prepared anchor and tag. self.prepared_anchor = None # type: Any self.prepared_tag = None # type: Any # Scalar analysis and style. self.analysis = None # type: Any self.style = None # type: Any self.scalar_after_indicator = True # write a scalar on the same line as `---` @property def stream(self): # type: () -> Any try: return self._stream except AttributeError: <|code_end|> using the current file's imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and any relevant context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
raise YAMLStreamError("output stream needs to specified")
Continue the code snippet: <|code_start|> if self.style == '"': self.write_double_quoted(self.analysis.scalar, split) elif self.style == "'": self.write_single_quoted(self.analysis.scalar, split) elif self.style == ">": self.write_folded(self.analysis.scalar) elif self.style == "|": self.write_literal(self.analysis.scalar, self.event.comment) else: self.write_plain(self.analysis.scalar, split) self.analysis = None self.style = None if self.event.comment: self.write_post_comment(self.event) # Analyzers. def prepare_version(self, version): # type: (Any) -> Any major, minor = version if major != 1: raise EmitterError("unsupported YAML version: %d.%d" % (major, minor)) return u"%d.%d" % (major, minor) def prepare_tag_handle(self, handle): # type: (Any) -> Any if not handle: raise EmitterError("tag handle must not be empty") if handle[0] != u"!" or handle[-1] != u"!": raise EmitterError( <|code_end|> . Use current file imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
"tag handle must start and end with '!': %r" % (utf8(handle))
Here is a snippet: <|code_start|> and self.column + (end - start) > self.best_width and split ): data = text[start:end] + u"\\" if start < end: start = end self.column += len(data) if bool(self.encoding): data = data.encode(self.encoding) self.stream.write(data) self.write_indent() self.whitespace = False self.indention = False if text[start] == u" ": data = u"\\" self.column += len(data) if bool(self.encoding): data = data.encode(self.encoding) self.stream.write(data) end += 1 self.write_indicator(u'"', False) def determine_block_hints(self, text): # type: (Any) -> Any indent = 0 indicator = u"" hints = u"" if text: if text[0] in u" \n\x85\u2028\u2029": indent = self.best_sequence_indent <|code_end|> . Write the next line using the current file imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): , which may include functions, classes, or code. Output only the next line.
hints += text_type(indent)
Predict the next line after this snippet: <|code_start|> self.indents.append(self.indent, sequence) if self.indent is None: # top level if flow: # self.indent = self.best_sequence_indent if self.indents.last_seq() else \ # self.best_map_indent # self.indent = self.best_sequence_indent self.indent = self.requested_indent else: self.indent = 0 elif not indentless: self.indent += ( self.best_sequence_indent if self.indents.last_seq() else self.best_map_indent ) # if self.indents.last_seq(): # if self.indent == 0: # top level block sequence # self.indent = self.best_sequence_indent - self.sequence_dash_offset # else: # self.indent += self.best_sequence_indent # else: # self.indent += self.best_map_indent # States. # Stream handlers. def expect_stream_start(self): # type: () -> None if isinstance(self.event, StreamStartEvent): <|code_end|> using the current file's imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and any relevant context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if PY2:
Continue the code snippet: <|code_start|> if val is None: return if not hasattr(val, "write"): raise YAMLStreamError("stream argument needs to have a write() method") self._stream = val @property def serializer(self): # type: () -> Any try: if hasattr(self.dumper, "typ"): return self.dumper.serializer return self.dumper._serializer except AttributeError: return self # cyaml @property def flow_level(self): # type: () -> int return len(self.flow_context) def dispose(self): # type: () -> None # Reset the state attributes (to clear self-references) self.states = [] self.state = None def emit(self, event): # type: (Any) -> None if dbg(DBG_EVENT): <|code_end|> . Use current file imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
nprint(event)
Predict the next line after this snippet: <|code_start|> # type: (Any) -> None if val is None: return if not hasattr(val, "write"): raise YAMLStreamError("stream argument needs to have a write() method") self._stream = val @property def serializer(self): # type: () -> Any try: if hasattr(self.dumper, "typ"): return self.dumper.serializer return self.dumper._serializer except AttributeError: return self # cyaml @property def flow_level(self): # type: () -> int return len(self.flow_context) def dispose(self): # type: () -> None # Reset the state attributes (to clear self-references) self.states = [] self.state = None def emit(self, event): # type: (Any) -> None <|code_end|> using the current file's imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and any relevant context from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if dbg(DBG_EVENT):
Continue the code snippet: <|code_start|> # type: (Any) -> None if val is None: return if not hasattr(val, "write"): raise YAMLStreamError("stream argument needs to have a write() method") self._stream = val @property def serializer(self): # type: () -> Any try: if hasattr(self.dumper, "typ"): return self.dumper.serializer return self.dumper._serializer except AttributeError: return self # cyaml @property def flow_level(self): # type: () -> int return len(self.flow_context) def dispose(self): # type: () -> None # Reset the state attributes (to clear self-references) self.states = [] self.state = None def emit(self, event): # type: (Any) -> None <|code_end|> . Use current file imports: import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if dbg(DBG_EVENT):
Next line prediction: <|code_start|> while end < len(suffix): ch = suffix[end] if ( u"0" <= ch <= u"9" or u"A" <= ch <= u"Z" or u"a" <= ch <= u"z" or ch in ch_set or (ch == u"!" and handle != u"!") ): end += 1 else: if start < end: chunks.append(suffix[start:end]) start = end = end + 1 data = utf8(ch) for ch in data: chunks.append(u"%%%02X" % ord(ch)) if start < end: chunks.append(suffix[start:end]) suffix_text = "".join(chunks) if handle: return u"%s%s" % (handle, suffix_text) else: return u"!<%s>" % suffix_text def prepare_anchor(self, anchor): # type: (Any) -> Any if not anchor: raise EmitterError("anchor must not be empty") for ch in anchor: <|code_end|> . Use current file imports: (import sys from .error import YAMLError, YAMLStreamError from .events import * # NOQA from .compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ check_anchorname_char from typing import Any, Dict, List, Union, Text, Tuple, Optional # NOQA from .compat import StreamType # NOQA) and context including class names, function names, or small code snippets from other files: # Path: srsly/ruamel_yaml/error.py # class YAMLError(Exception): # pass # # class YAMLStreamError(Exception): # pass # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if not check_anchorname_char(ch):
Given snippet: <|code_start|> # ToDo use nullege to search add_multi_representer and add_path_resolver # and add some test code # Issue 127 reported by Tommy Wang def test_issue_127(): class Ref(srsly.ruamel_yaml.YAMLObject): yaml_constructor = srsly.ruamel_yaml.RoundTripConstructor yaml_representer = srsly.ruamel_yaml.RoundTripRepresenter yaml_tag = u"!Ref" def __init__(self, logical_id): self.logical_id = logical_id @classmethod def from_yaml(cls, loader, node): return cls(loader.construct_scalar(node)) @classmethod def to_yaml(cls, dumper, data): if isinstance(data.logical_id, srsly.ruamel_yaml.scalarstring.ScalarString): style = data.logical_id.style # srsly.ruamel_yaml>0.15.8 else: style = None return dumper.represent_scalar(cls.yaml_tag, data.logical_id, style=style) <|code_end|> , continue by predicting the next line. Consider current file imports: import re import pytest # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA import srsly.ruamel_yaml # NOQA from .roundtrip import dedent and context: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) which might include code, classes, or functions. Output only the next line.
document = dedent(
Using the snippet: <|code_start|># FLOW-SEQUENCE-START # FLOW-MAPPING-START # FLOW-SEQUENCE-END # FLOW-MAPPING-END # BLOCK-ENTRY # FLOW-ENTRY # KEY # VALUE # ALIAS(value) # ANCHOR(value) # TAG(value) # SCALAR(value, plain, style) # # RoundTripScanner # COMMENT(value) # # Read comments in the Scanner code for more details. # if False: # MYPY __all__ = ["Scanner", "RoundTripScanner", "ScannerError"] _THE_END = "\n\0\r\x85\u2028\u2029" _THE_END_SPACE_TAB = " \n\0\t\r\x85\u2028\u2029" _SPACE_TAB = " \t" <|code_end|> , determine the next line of code. You have imports: from .error import MarkedYAMLError from .tokens import * # NOQA from .compat import utf8, unichr, PY3, check_anchorname_char, nprint # NOQA from typing import Any, Dict, Optional, List, Union, Text # NOQA from .compat import VersionType # NOQA and context (class names, function names, or code) available: # Path: srsly/ruamel_yaml/error.py # class MarkedYAMLError(YAMLError): # def __init__( # self, # context=None, # context_mark=None, # problem=None, # problem_mark=None, # note=None, # warn=None, # ): # # type: (Any, Any, Any, Any, Any, Any) -> None # self.context = context # self.context_mark = context_mark # self.problem = problem # self.problem_mark = problem_mark # self.note = note # # warn is ignored # # def __str__(self): # # type: () -> Any # lines = [] # type: List[str] # if self.context is not None: # lines.append(self.context) # if self.context_mark is not None and ( # self.problem is None # or self.problem_mark is None # or self.context_mark.name != self.problem_mark.name # or self.context_mark.line != self.problem_mark.line # or self.context_mark.column != self.problem_mark.column # ): # lines.append(str(self.context_mark)) # if self.problem is not None: # lines.append(self.problem) # if self.problem_mark is not None: # lines.append(str(self.problem_mark)) # if self.note is not None and self.note: # note = textwrap.dedent(self.note) # lines.append(note) # return "\n".join(lines) # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
class ScannerError(MarkedYAMLError):
Predict the next line after this snippet: <|code_start|> return self.fetch_anchor() # Is it a tag? if ch == "!": return self.fetch_tag() # Is it a literal scalar? if ch == "|" and not self.flow_level: return self.fetch_literal() # Is it a folded scalar? if ch == ">" and not self.flow_level: return self.fetch_folded() # Is it a single quoted scalar? if ch == "'": return self.fetch_single() # Is it a double quoted scalar? if ch == '"': return self.fetch_double() # It must be a plain scalar then. if self.check_plain(): return self.fetch_plain() # No? It's an error. Let's produce a nice error message. raise ScannerError( "while scanning for the next token", None, <|code_end|> using the current file's imports: from .error import MarkedYAMLError from .tokens import * # NOQA from .compat import utf8, unichr, PY3, check_anchorname_char, nprint # NOQA from typing import Any, Dict, Optional, List, Union, Text # NOQA from .compat import VersionType # NOQA and any relevant context from other files: # Path: srsly/ruamel_yaml/error.py # class MarkedYAMLError(YAMLError): # def __init__( # self, # context=None, # context_mark=None, # problem=None, # problem_mark=None, # note=None, # warn=None, # ): # # type: (Any, Any, Any, Any, Any, Any) -> None # self.context = context # self.context_mark = context_mark # self.problem = problem # self.problem_mark = problem_mark # self.note = note # # warn is ignored # # def __str__(self): # # type: () -> Any # lines = [] # type: List[str] # if self.context is not None: # lines.append(self.context) # if self.context_mark is not None and ( # self.problem is None # or self.problem_mark is None # or self.context_mark.name != self.problem_mark.name # or self.context_mark.line != self.problem_mark.line # or self.context_mark.column != self.problem_mark.column # ): # lines.append(str(self.context_mark)) # if self.problem is not None: # lines.append(self.problem) # if self.problem_mark is not None: # lines.append(str(self.problem_mark)) # if self.note is not None and self.note: # note = textwrap.dedent(self.note) # lines.append(note) # return "\n".join(lines) # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
"found character %r that cannot start any token" % utf8(ch),
Based on the snippet: <|code_start|> length += 1 if length != 0: chunks.append(self.reader.prefix(length)) srf(length) ch = srp() if not double and ch == "'" and srp(1) == "'": chunks.append("'") srf(2) elif (double and ch == "'") or (not double and ch in '"\\'): chunks.append(ch) srf() elif double and ch == "\\": srf() ch = srp() if ch in self.ESCAPE_REPLACEMENTS: chunks.append(self.ESCAPE_REPLACEMENTS[ch]) srf() elif ch in self.ESCAPE_CODES: length = self.ESCAPE_CODES[ch] srf() for k in range(length): if srp(k) not in "0123456789ABCDEFabcdef": raise ScannerError( "while scanning a double-quoted scalar", start_mark, "expected escape sequence of %d hexdecimal " "numbers, but found %r" % (length, utf8(srp(k))), self.reader.get_mark(), ) code = int(self.reader.prefix(length), 16) <|code_end|> , predict the immediate next line with the help of imports: from .error import MarkedYAMLError from .tokens import * # NOQA from .compat import utf8, unichr, PY3, check_anchorname_char, nprint # NOQA from typing import Any, Dict, Optional, List, Union, Text # NOQA from .compat import VersionType # NOQA and context (classes, functions, sometimes code) from other files: # Path: srsly/ruamel_yaml/error.py # class MarkedYAMLError(YAMLError): # def __init__( # self, # context=None, # context_mark=None, # problem=None, # problem_mark=None, # note=None, # warn=None, # ): # # type: (Any, Any, Any, Any, Any, Any) -> None # self.context = context # self.context_mark = context_mark # self.problem = problem # self.problem_mark = problem_mark # self.note = note # # warn is ignored # # def __str__(self): # # type: () -> Any # lines = [] # type: List[str] # if self.context is not None: # lines.append(self.context) # if self.context_mark is not None and ( # self.problem is None # or self.problem_mark is None # or self.context_mark.name != self.problem_mark.name # or self.context_mark.line != self.problem_mark.line # or self.context_mark.column != self.problem_mark.column # ): # lines.append(str(self.context_mark)) # if self.problem is not None: # lines.append(self.problem) # if self.problem_mark is not None: # lines.append(str(self.problem_mark)) # if self.note is not None and self.note: # note = textwrap.dedent(self.note) # lines.append(note) # return "\n".join(lines) # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
chunks.append(unichr(code))
Using the snippet: <|code_start|> chunks.append(self.reader.prefix(length)) self.reader.forward(length) length = 0 if not chunks: raise ScannerError( "while parsing a %s" % (name,), start_mark, "expected URI, but found %r" % utf8(ch), self.reader.get_mark(), ) return "".join(chunks) def scan_uri_escapes(self, name, start_mark): # type: (Any, Any) -> Any # See the specification for details. srp = self.reader.peek srf = self.reader.forward code_bytes = [] # type: List[Any] mark = self.reader.get_mark() while srp() == "%": srf() for k in range(2): if srp(k) not in "0123456789ABCDEFabcdef": raise ScannerError( "while scanning a %s" % (name,), start_mark, "expected URI escape sequence of 2 hexdecimal numbers," " but found %r" % utf8(srp(k)), self.reader.get_mark(), ) <|code_end|> , determine the next line of code. You have imports: from .error import MarkedYAMLError from .tokens import * # NOQA from .compat import utf8, unichr, PY3, check_anchorname_char, nprint # NOQA from typing import Any, Dict, Optional, List, Union, Text # NOQA from .compat import VersionType # NOQA and context (class names, function names, or code) available: # Path: srsly/ruamel_yaml/error.py # class MarkedYAMLError(YAMLError): # def __init__( # self, # context=None, # context_mark=None, # problem=None, # problem_mark=None, # note=None, # warn=None, # ): # # type: (Any, Any, Any, Any, Any, Any) -> None # self.context = context # self.context_mark = context_mark # self.problem = problem # self.problem_mark = problem_mark # self.note = note # # warn is ignored # # def __str__(self): # # type: () -> Any # lines = [] # type: List[str] # if self.context is not None: # lines.append(self.context) # if self.context_mark is not None and ( # self.problem is None # or self.problem_mark is None # or self.context_mark.name != self.problem_mark.name # or self.context_mark.line != self.problem_mark.line # or self.context_mark.column != self.problem_mark.column # ): # lines.append(str(self.context_mark)) # if self.problem is not None: # lines.append(self.problem) # if self.problem_mark is not None: # lines.append(str(self.problem_mark)) # if self.note is not None and self.note: # note = textwrap.dedent(self.note) # lines.append(note) # return "\n".join(lines) # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
if PY3:
Based on the snippet: <|code_start|> raise ScannerError( "while scanning a directive", start_mark, "expected a comment or a line break, but found %r" % utf8(ch), self.reader.get_mark(), ) self.scan_line_break() def scan_anchor(self, TokenClass): # type: (Any) -> Any # The specification does not restrict characters for anchors and # aliases. This may lead to problems, for instance, the document: # [ *alias, value ] # can be interpteted in two ways, as # [ "value" ] # and # [ *alias , "value" ] # Therefore we restrict aliases to numbers and ASCII letters. srp = self.reader.peek start_mark = self.reader.get_mark() indicator = srp() if indicator == "*": name = "alias" else: name = "anchor" self.reader.forward() length = 0 ch = srp(length) # while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' \ # or ch in u'-_': <|code_end|> , predict the immediate next line with the help of imports: from .error import MarkedYAMLError from .tokens import * # NOQA from .compat import utf8, unichr, PY3, check_anchorname_char, nprint # NOQA from typing import Any, Dict, Optional, List, Union, Text # NOQA from .compat import VersionType # NOQA and context (classes, functions, sometimes code) from other files: # Path: srsly/ruamel_yaml/error.py # class MarkedYAMLError(YAMLError): # def __init__( # self, # context=None, # context_mark=None, # problem=None, # problem_mark=None, # note=None, # warn=None, # ): # # type: (Any, Any, Any, Any, Any, Any) -> None # self.context = context # self.context_mark = context_mark # self.problem = problem # self.problem_mark = problem_mark # self.note = note # # warn is ignored # # def __str__(self): # # type: () -> Any # lines = [] # type: List[str] # if self.context is not None: # lines.append(self.context) # if self.context_mark is not None and ( # self.problem is None # or self.problem_mark is None # or self.context_mark.name != self.problem_mark.name # or self.context_mark.line != self.problem_mark.line # or self.context_mark.column != self.problem_mark.column # ): # lines.append(str(self.context_mark)) # if self.problem is not None: # lines.append(self.problem) # if self.problem_mark is not None: # lines.append(str(self.problem_mark)) # if self.note is not None and self.note: # note = textwrap.dedent(self.note) # lines.append(note) # return "\n".join(lines) # # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
while check_anchorname_char(ch):
Given snippet: <|code_start|># coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals # http://yaml.org/type/int.html is where underscores in integers are defined class TestBinHexOct: def test_calculate(self): # make sure type, leading zero(s) and underscore are preserved <|code_end|> , continue by predicting the next line. Consider current file imports: import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) which might include code, classes, or functions. Output only the next line.
s = dedent(
Given the code snippet: <|code_start|># coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals # http://yaml.org/type/int.html is where underscores in integers are defined class TestBinHexOct: def test_calculate(self): # make sure type, leading zero(s) and underscore are preserved s = dedent( """\ - 42 - 0b101010 - 0x_2a - 0x2A - 0o00_52 """ ) <|code_end|> , generate the next line using the imports in this file: import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context (functions, classes, or occasionally code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
d = round_trip_load(s)
Continue the code snippet: <|code_start|> # http://yaml.org/type/int.html is where underscores in integers are defined class TestBinHexOct: def test_calculate(self): # make sure type, leading zero(s) and underscore are preserved s = dedent( """\ - 42 - 0b101010 - 0x_2a - 0x2A - 0o00_52 """ ) d = round_trip_load(s) for idx, elem in enumerate(d): elem -= 21 d[idx] = elem for idx, elem in enumerate(d): elem *= 2 d[idx] = elem for idx, elem in enumerate(d): t = elem elem **= 2 elem //= t d[idx] = elem <|code_end|> . Use current file imports: import pytest # NOQA from .roundtrip import dedent, round_trip_load, round_trip_dump and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) # # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) . Output only the next line.
assert round_trip_dump(d) == s
Continue the code snippet: <|code_start|># coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals if False: # MYPY __all__ = [ "ScalarString", "LiteralScalarString", "FoldedScalarString", "SingleQuotedScalarString", "DoubleQuotedScalarString", "PlainScalarString", # PreservedScalarString is the old name, as it was the first to be preserved on rt, # use LiteralScalarString instead "PreservedScalarString", ] <|code_end|> . Use current file imports: from .compat import text_type from .anchor import Anchor from typing import Text, Any, Dict, List # NOQA from .compat import string_types from .compat import MutableMapping, MutableSequence # type: ignore and context (classes, functions, or code) from other files: # Path: srsly/ruamel_yaml/compat.py # _DEFAULT_YAML_VERSION = (1, 2) # PY2 = sys.version_info[0] == 2 # PY3 = sys.version_info[0] == 3 # MAXSIZE = sys.maxsize # UNICODE_SIZE = 4 if sys.maxunicode > 65535 else 2 # DBG_TOKEN = 1 # DBG_EVENT = 2 # DBG_NODE = 4 # class ordereddict(OrderedDict): # type: ignore # class ObjectCounter(object): # class Nprint(object): # class MutableSliceableSequence(MutableSequence): # type: ignore # def insert(self, pos, key, value): # def utf8(s): # def to_str(s): # def to_unicode(s): # def utf8(s): # def to_str(s): # def to_unicode(s): # def with_metaclass(meta, *bases): # def __init__(self): # def __call__(self, k): # def dump(self): # def dbg(val=None): # def __init__(self, file_name=None): # def __call__(self, *args, **kw): # def set_max_print(self, i): # def check_namespace_char(ch): # def check_anchorname_char(ch): # def version_tnf(t1, t2=None): # def __getitem__(self, index): # def __setitem__(self, index, value): # def __delitem__(self, index): # def __getsingleitem__(self, index): # def __setsingleitem__(self, index, value): # def __delsingleitem__(self, index): . Output only the next line.
class ScalarString(text_type):
Given the code snippet: <|code_start|> def test_msgpack_dumps(): data = {"hello": "world", "test": 123} expected = [b"\x82\xa5hello\xa5world\xa4test{", b"\x82\xa4test{\xa5hello\xa5world"] msg = msgpack_dumps(data) assert msg in expected def test_msgpack_loads(): msg = b"\x82\xa5hello\xa5world\xa4test{" data = msgpack_loads(msg) assert len(data) == 2 assert data["hello"] == "world" assert data["test"] == 123 def test_read_msgpack_file(): file_contents = b"\x81\xa5hello\xa5world" with make_tempdir({"tmp.msg": file_contents}, mode="wb") as temp_dir: file_path = temp_dir / "tmp.msg" assert file_path.exists() <|code_end|> , generate the next line using the imports in this file: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context (functions, classes, or occasionally code) from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) . Output only the next line.
data = read_msgpack(file_path)
Based on the snippet: <|code_start|> data = msgpack_loads(msg) assert len(data) == 2 assert data["hello"] == "world" assert data["test"] == 123 def test_read_msgpack_file(): file_contents = b"\x81\xa5hello\xa5world" with make_tempdir({"tmp.msg": file_contents}, mode="wb") as temp_dir: file_path = temp_dir / "tmp.msg" assert file_path.exists() data = read_msgpack(file_path) assert len(data) == 1 assert data["hello"] == "world" def test_read_msgpack_file_invalid(): file_contents = b"\xa5hello\xa5world" with make_tempdir({"tmp.msg": file_contents}, mode="wb") as temp_dir: file_path = temp_dir / "tmp.msg" assert file_path.exists() with pytest.raises(ValueError): read_msgpack(file_path) def test_write_msgpack_file(): data = {"hello": "world", "test": 123} expected = [b"\x82\xa5hello\xa5world\xa4test{", b"\x82\xa4test{\xa5hello\xa5world"] with make_tempdir(mode="wb") as temp_dir: file_path = temp_dir / "tmp.msg" <|code_end|> , predict the immediate next line with the help of imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context (classes, functions, sometimes code) from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) . Output only the next line.
write_msgpack(file_path, data)
Continue the code snippet: <|code_start|> def test_msgpack_dumps(): data = {"hello": "world", "test": 123} expected = [b"\x82\xa5hello\xa5world\xa4test{", b"\x82\xa4test{\xa5hello\xa5world"] msg = msgpack_dumps(data) assert msg in expected def test_msgpack_loads(): msg = b"\x82\xa5hello\xa5world\xa4test{" <|code_end|> . Use current file imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context (classes, functions, or code) from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) . Output only the next line.
data = msgpack_loads(msg)
Predict the next line for this snippet: <|code_start|> def test_msgpack_dumps(): data = {"hello": "world", "test": 123} expected = [b"\x82\xa5hello\xa5world\xa4test{", b"\x82\xa4test{\xa5hello\xa5world"] <|code_end|> with the help of current file imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) , which may contain function names, class names, or code. Output only the next line.
msg = msgpack_dumps(data)
Predict the next line after this snippet: <|code_start|>@patch("srsly.msgpack._msgpack_numpy.np", None) @patch("srsly.msgpack._msgpack_numpy.has_numpy", False) def test_msgpack_without_numpy(): """Test that msgpack works without numpy and raises correct errors (e.g. when serializing datetime objects, the error should be msgpack's TypeError, not a "'np' is not defined error").""" with pytest.raises(TypeError): msgpack_loads(msgpack_dumps(datetime.datetime.now())) def test_msgpack_custom_encoder_decoder(): class CustomObject: def __init__(self, value): self.value = value def serialize_obj(obj, chain=None): if isinstance(obj, CustomObject): return {"__custom__": obj.value} return obj if chain is None else chain(obj) def deserialize_obj(obj, chain=None): if "__custom__" in obj: return CustomObject(obj["__custom__"]) return obj if chain is None else chain(obj) data = {"a": 123, "b": CustomObject({"foo": "bar"})} with pytest.raises(TypeError): msgpack_dumps(data) # Register custom encoders/decoders to handle CustomObject <|code_end|> using the current file's imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and any relevant context from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) . Output only the next line.
msgpack_encoders.register("custom_object", func=serialize_obj)
Here is a snippet: <|code_start|>@patch("srsly.msgpack._msgpack_numpy.has_numpy", False) def test_msgpack_without_numpy(): """Test that msgpack works without numpy and raises correct errors (e.g. when serializing datetime objects, the error should be msgpack's TypeError, not a "'np' is not defined error").""" with pytest.raises(TypeError): msgpack_loads(msgpack_dumps(datetime.datetime.now())) def test_msgpack_custom_encoder_decoder(): class CustomObject: def __init__(self, value): self.value = value def serialize_obj(obj, chain=None): if isinstance(obj, CustomObject): return {"__custom__": obj.value} return obj if chain is None else chain(obj) def deserialize_obj(obj, chain=None): if "__custom__" in obj: return CustomObject(obj["__custom__"]) return obj if chain is None else chain(obj) data = {"a": 123, "b": CustomObject({"foo": "bar"})} with pytest.raises(TypeError): msgpack_dumps(data) # Register custom encoders/decoders to handle CustomObject msgpack_encoders.register("custom_object", func=serialize_obj) <|code_end|> . Write the next line using the current file imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) , which may include functions, classes, or code. Output only the next line.
msgpack_decoders.register("custom_object", func=deserialize_obj)
Based on the snippet: <|code_start|> def test_msgpack_dumps(): data = {"hello": "world", "test": 123} expected = [b"\x82\xa5hello\xa5world\xa4test{", b"\x82\xa4test{\xa5hello\xa5world"] msg = msgpack_dumps(data) assert msg in expected def test_msgpack_loads(): msg = b"\x82\xa5hello\xa5world\xa4test{" data = msgpack_loads(msg) assert len(data) == 2 assert data["hello"] == "world" assert data["test"] == 123 def test_read_msgpack_file(): file_contents = b"\x81\xa5hello\xa5world" <|code_end|> , predict the immediate next line with the help of imports: import pytest import datetime import numpy from pathlib import Path from mock import patch from .._msgpack_api import read_msgpack, write_msgpack from .._msgpack_api import msgpack_loads, msgpack_dumps from .._msgpack_api import msgpack_encoders, msgpack_decoders from .util import make_tempdir and context (classes, functions, sometimes code) from other files: # Path: srsly/_msgpack_api.py # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # """Load a msgpack file. # # location (FilePath): The file path. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS (JSONOutputBin): The loaded and deserialized content. # """ # file_path = force_path(path) # with file_path.open("rb") as f: # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.load(f, raw=False, use_list=use_list) # gc.enable() # return msg # # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # """Create a msgpack file and dump contents. # # location (FilePath): The file path. # data (JSONInputBin): The data to serialize. # """ # file_path = force_path(path, require_exists=False) # with file_path.open("wb") as f: # msgpack.dump(data, f, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # """Deserialize msgpack bytes to a Python object. # # data (bytes): The data to deserialize. # use_list (bool): Don't use tuples instead of lists. Can make # deserialization slower. # RETURNS: The deserialized Python object. # """ # # msgpack-python docs suggest disabling gc before unpacking large messages # gc.disable() # msg = msgpack.loads(data, raw=False, use_list=use_list) # gc.enable() # return msg # # def msgpack_dumps(data: JSONInputBin) -> bytes: # """Serialize an object to a msgpack byte string. # # data: The data to serialize. # RETURNS (bytes): The serialized bytes. # """ # return msgpack.dumps(data, use_bin_type=True) # # Path: srsly/_msgpack_api.py # def msgpack_dumps(data: JSONInputBin) -> bytes: # def msgpack_loads(data: bytes, use_list: bool = True) -> JSONOutputBin: # def write_msgpack(path: FilePath, data: JSONInputBin) -> None: # def read_msgpack(path: FilePath, use_list: bool = True) -> JSONOutputBin: # # Path: srsly/tests/util.py # @contextmanager # def make_tempdir(files={}, mode="w"): # temp_dir_str = tempfile.mkdtemp() # temp_dir = Path(temp_dir_str) # for name, content in files.items(): # path = temp_dir / name # with path.open(mode) as file_: # file_.write(content) # yield temp_dir # shutil.rmtree(temp_dir_str) . Output only the next line.
with make_tempdir({"tmp.msg": file_contents}, mode="wb") as temp_dir:
Continue the code snippet: <|code_start|># coding: utf-8 class TestLeftOverDebug: # idea here is to capture round_trip_output via pytest stdout capture # if there is are any leftover debug statements they should show up def test_00(self, capsys): s = dedent( """ a: 1 b: [] c: [a, 1] d: {f: 3.14, g: 42} """ ) <|code_end|> . Use current file imports: import sys import pytest # NOQA from .roundtrip import round_trip_load, round_trip_dump, dedent and context (classes, functions, or code) from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) . Output only the next line.
d = round_trip_load(s)
Predict the next line for this snippet: <|code_start|># coding: utf-8 class TestLeftOverDebug: # idea here is to capture round_trip_output via pytest stdout capture # if there is are any leftover debug statements they should show up def test_00(self, capsys): s = dedent( """ a: 1 b: [] c: [a, 1] d: {f: 3.14, g: 42} """ ) d = round_trip_load(s) <|code_end|> with the help of current file imports: import sys import pytest # NOQA from .roundtrip import round_trip_load, round_trip_dump, dedent and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip_load(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) # # def round_trip_dump( # data, # stream=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # explicit_start=None, # explicit_end=None, # version=None, # ): # import srsly.ruamel_yaml # NOQA # # return srsly.ruamel_yaml.round_trip_dump( # data, # stream=stream, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # # def dedent(data): # try: # position_of_first_newline = data.index("\n") # for idx in range(position_of_first_newline): # if not data[idx].isspace(): # raise ValueError # except ValueError: # pass # else: # data = data[position_of_first_newline + 1 :] # return textwrap.dedent(data) , which may contain function names, class names, or code. Output only the next line.
round_trip_dump(d, sys.stdout)
Predict the next line for this snippet: <|code_start|># coding: utf-8 class TestDocument: def test_single_doc_begin_end(self): inp = """\ --- - a - b ... """ <|code_end|> with the help of current file imports: import pytest # NOQA from .roundtrip import round_trip, round_trip_load_all from srsly.ruamel_yaml import dump_all, RoundTripDumper from srsly.ruamel_yaml import parser and context from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def round_trip_load_all(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load_all( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) , which may contain function names, class names, or code. Output only the next line.
round_trip(inp, explicit_start=True, explicit_end=True)
Next line prediction: <|code_start|># coding: utf-8 class TestDocument: def test_single_doc_begin_end(self): inp = """\ --- - a - b ... """ round_trip(inp, explicit_start=True, explicit_end=True) def test_multi_doc_begin_end(self): inp = """\ --- - a ... --- - b ... """ <|code_end|> . Use current file imports: (import pytest # NOQA from .roundtrip import round_trip, round_trip_load_all from srsly.ruamel_yaml import dump_all, RoundTripDumper from srsly.ruamel_yaml import parser) and context including class names, function names, or small code snippets from other files: # Path: srsly/tests/ruamel_yaml/roundtrip.py # def round_trip( # inp, # outp=None, # extra=None, # intermediate=None, # indent=None, # block_seq_indent=None, # top_level_colon_align=None, # prefix_colon=None, # preserve_quotes=None, # explicit_start=None, # explicit_end=None, # version=None, # dump_data=None, # ): # """ # inp: input string to parse # outp: expected output (equals input if not specified) # """ # if outp is None: # outp = inp # doutp = dedent(outp) # if extra is not None: # doutp += extra # data = round_trip_load(inp, preserve_quotes=preserve_quotes) # if dump_data: # print("data", data) # if intermediate is not None: # if isinstance(intermediate, dict): # for k, v in intermediate.items(): # if data[k] != v: # print("{0!r} <> {1!r}".format(data[k], v)) # raise ValueError # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # if res != doutp: # diff(doutp, res, "input string") # print("\nroundtrip data:\n", res, sep="") # assert res == doutp # res = round_trip_dump( # data, # indent=indent, # block_seq_indent=block_seq_indent, # top_level_colon_align=top_level_colon_align, # prefix_colon=prefix_colon, # explicit_start=explicit_start, # explicit_end=explicit_end, # version=version, # ) # print("roundtrip second round data:\n", res, sep="") # assert res == doutp # return data # # def round_trip_load_all(inp, preserve_quotes=None, version=None): # import srsly.ruamel_yaml # NOQA # # dinp = dedent(inp) # return srsly.ruamel_yaml.load_all( # dinp, # Loader=srsly.ruamel_yaml.RoundTripLoader, # preserve_quotes=preserve_quotes, # version=version, # ) . Output only the next line.
docs = list(round_trip_load_all(inp))
Next line prediction: <|code_start|>from __future__ import unicode_literals class ReposCollaborators: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/collaborators' % ( self.client.user(user), repo), msg_type=UserListResponse) def get(self, repo, collaborator, owner=None): return self.client.get( 'repos/%s/%s/collaborators/%s' % ( <|code_end|> . Use current file imports: (from ..requests import UserResponse from ..requests import UserListResponse ) and context including class names, function names, or small code snippets from other files: # Path: flask_github/client/requests.py # class UserResponse(msgs.Message): # response = msgs.MessageField('User', 1) # # Path: flask_github/client/requests.py # class UserListResponse(msgs.Message): # response = msgs.MessageField('User', 1, repeated=True) . Output only the next line.
self.client.user(owner), repo, collaborator), msg_type=UserResponse)
Given the code snippet: <|code_start|>from __future__ import unicode_literals class ReposCollaborators: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/collaborators' % ( <|code_end|> , generate the next line using the imports in this file: from ..requests import UserResponse from ..requests import UserListResponse and context (functions, classes, or occasionally code) from other files: # Path: flask_github/client/requests.py # class UserResponse(msgs.Message): # response = msgs.MessageField('User', 1) # # Path: flask_github/client/requests.py # class UserListResponse(msgs.Message): # response = msgs.MessageField('User', 1, repeated=True) . Output only the next line.
self.client.user(user), repo), msg_type=UserListResponse)
Given the code snippet: <|code_start|>from __future__ import unicode_literals class IssuesLabels: def __init__(self, client): self.client = client def list_repo_labels(self, repo, user=None): return self.client.get('repos/%s/%s/labels' % ( repo, self.client.user(user)), msg_type=IssueLabelListResponse) def get(self, repo, id, user=None): return self.client.get('repos/%s/%s/labels/%s' % ( repo, self.client.user(user), id), msg_type=IssueLabelResponse) def create(self, repo, name, color, user=None): <|code_end|> , generate the next line using the imports in this file: from ..messages import IssueLabel from ..requests import IssueLabelResponse from ..requests import IssueLabelListResponse and context (functions, classes, or occasionally code) from other files: # Path: flask_github/client/messages.py # class IssueLabel(msgs.Message): # pass # # Path: flask_github/client/requests.py # class IssueLabelResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1) # # Path: flask_github/client/requests.py # class IssueLabelListResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1, repeated=True) . Output only the next line.
msg = IssueLabel(
Using the snippet: <|code_start|>from __future__ import unicode_literals class IssuesLabels: def __init__(self, client): self.client = client def list_repo_labels(self, repo, user=None): return self.client.get('repos/%s/%s/labels' % ( repo, self.client.user(user)), msg_type=IssueLabelListResponse) def get(self, repo, id, user=None): return self.client.get('repos/%s/%s/labels/%s' % ( <|code_end|> , determine the next line of code. You have imports: from ..messages import IssueLabel from ..requests import IssueLabelResponse from ..requests import IssueLabelListResponse and context (class names, function names, or code) available: # Path: flask_github/client/messages.py # class IssueLabel(msgs.Message): # pass # # Path: flask_github/client/requests.py # class IssueLabelResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1) # # Path: flask_github/client/requests.py # class IssueLabelListResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1, repeated=True) . Output only the next line.
repo, self.client.user(user), id), msg_type=IssueLabelResponse)
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals class IssuesLabels: def __init__(self, client): self.client = client def list_repo_labels(self, repo, user=None): return self.client.get('repos/%s/%s/labels' % ( <|code_end|> , predict the next line using imports from the current file: from ..messages import IssueLabel from ..requests import IssueLabelResponse from ..requests import IssueLabelListResponse and context including class names, function names, and sometimes code from other files: # Path: flask_github/client/messages.py # class IssueLabel(msgs.Message): # pass # # Path: flask_github/client/requests.py # class IssueLabelResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1) # # Path: flask_github/client/requests.py # class IssueLabelListResponse(msgs.Message): # response = msgs.MessageField('IssueLabel', 1, repeated=True) . Output only the next line.
repo, self.client.user(user)), msg_type=IssueLabelListResponse)
Using the snippet: <|code_start|> self.client = client def list(self, repo, sha=None, path=None, user=None): query = None if sha and path: query = {'sha': sha, 'path': path} return self.client.get('repos/%s/%s/commits' % ( self.client.user(user), repo), query=query, msg_type=CommitListResponse) def get(self, repo, sha, user=None): return self.client.get( 'repos/%s/%s/commits/%s' % ( self.client.user(user), repo, sha), msg_type=CommitResponse) def compare(self, repo, base, head, user=None): return self.client.get( 'repos/%s/%s/compare/%s...:%s' % ( self.client.user(user), repo, base, head), msg_type=None) # comments.. def list_comments(self, repo, sha=None, user=None): url = 'repos/%s/%s/comments' % ( self.client.user(user), repo) if sha: url = 'repos/%s/%s/commits/%s/comments' % ( self.client.user(user), repo, sha) return self.client.get(url, msg_type=CommentListResponse) def create_comment(self, repo, sha, body, line, path, position, user=None): <|code_end|> , determine the next line of code. You have imports: from ..messages import Commit from ..requests import CommitResponse from ..requests import CommitListResponse from ..requests import CommentResponse from ..requests import CommentListResponse and context (class names, function names, or code) available: # Path: flask_github/client/messages.py # class Commit(msgs.Message): # url = msgs.StringField(1) # sha = msgs.StringField(2) # committer = msgs.MessageField('User', 3) # author = msgs.MessageField('User', 4) # comment_count = msgs.IntegerField(5, default=0) # message = msgs.StringField(6) # # string reference allows for recursion.. # tree = msgs.MessageField('Commit', 7) # parents = msgs.MessageField('Commit', 8, repeated=True) # # fields that live on the tree api responses.. # path = msgs.StringField(9) # mode = msgs.StringField(10) # type = msgs.StringField(11) # size = msgs.IntegerField(12, default=0) # # fields for the hooks payload.. # id = msgs.StringField(13) # timestamp = msgs.StringField(14) # added = msgs.StringField(15, repeated=True) # removed = msgs.StringField(16, repeated=True) # modified = msgs.StringField(17, repeated=True) # commit = msgs.MessageField('Commit', 18) # # Path: flask_github/client/requests.py # class CommitResponse(msgs.Message): # response = msgs.MessageField('Commit', 1) # # Path: flask_github/client/requests.py # class CommitListResponse(msgs.Message): # response = msgs.MessageField('Commit', 1, repeated=True) # # Path: flask_github/client/requests.py # class CommentResponse(msgs.Message): # response = msgs.MessageField('Comment', 1) # # Path: flask_github/client/requests.py # class CommentListResponse(msgs.Message): # response = msgs.MessageField('Comment', 1, repeated=True) . Output only the next line.
msg = Commit(
Using the snippet: <|code_start|>from __future__ import unicode_literals class ReposCommits: def __init__(self, client): self.client = client def list(self, repo, sha=None, path=None, user=None): query = None if sha and path: query = {'sha': sha, 'path': path} return self.client.get('repos/%s/%s/commits' % ( self.client.user(user), repo), query=query, msg_type=CommitListResponse) def get(self, repo, sha, user=None): return self.client.get( 'repos/%s/%s/commits/%s' % ( <|code_end|> , determine the next line of code. You have imports: from ..messages import Commit from ..requests import CommitResponse from ..requests import CommitListResponse from ..requests import CommentResponse from ..requests import CommentListResponse and context (class names, function names, or code) available: # Path: flask_github/client/messages.py # class Commit(msgs.Message): # url = msgs.StringField(1) # sha = msgs.StringField(2) # committer = msgs.MessageField('User', 3) # author = msgs.MessageField('User', 4) # comment_count = msgs.IntegerField(5, default=0) # message = msgs.StringField(6) # # string reference allows for recursion.. # tree = msgs.MessageField('Commit', 7) # parents = msgs.MessageField('Commit', 8, repeated=True) # # fields that live on the tree api responses.. # path = msgs.StringField(9) # mode = msgs.StringField(10) # type = msgs.StringField(11) # size = msgs.IntegerField(12, default=0) # # fields for the hooks payload.. # id = msgs.StringField(13) # timestamp = msgs.StringField(14) # added = msgs.StringField(15, repeated=True) # removed = msgs.StringField(16, repeated=True) # modified = msgs.StringField(17, repeated=True) # commit = msgs.MessageField('Commit', 18) # # Path: flask_github/client/requests.py # class CommitResponse(msgs.Message): # response = msgs.MessageField('Commit', 1) # # Path: flask_github/client/requests.py # class CommitListResponse(msgs.Message): # response = msgs.MessageField('Commit', 1, repeated=True) # # Path: flask_github/client/requests.py # class CommentResponse(msgs.Message): # response = msgs.MessageField('Comment', 1) # # Path: flask_github/client/requests.py # class CommentListResponse(msgs.Message): # response = msgs.MessageField('Comment', 1, repeated=True) . Output only the next line.
self.client.user(user), repo, sha), msg_type=CommitResponse)
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals class ReposCommits: def __init__(self, client): self.client = client def list(self, repo, sha=None, path=None, user=None): query = None if sha and path: query = {'sha': sha, 'path': path} return self.client.get('repos/%s/%s/commits' % ( <|code_end|> , predict the next line using imports from the current file: from ..messages import Commit from ..requests import CommitResponse from ..requests import CommitListResponse from ..requests import CommentResponse from ..requests import CommentListResponse and context including class names, function names, and sometimes code from other files: # Path: flask_github/client/messages.py # class Commit(msgs.Message): # url = msgs.StringField(1) # sha = msgs.StringField(2) # committer = msgs.MessageField('User', 3) # author = msgs.MessageField('User', 4) # comment_count = msgs.IntegerField(5, default=0) # message = msgs.StringField(6) # # string reference allows for recursion.. # tree = msgs.MessageField('Commit', 7) # parents = msgs.MessageField('Commit', 8, repeated=True) # # fields that live on the tree api responses.. # path = msgs.StringField(9) # mode = msgs.StringField(10) # type = msgs.StringField(11) # size = msgs.IntegerField(12, default=0) # # fields for the hooks payload.. # id = msgs.StringField(13) # timestamp = msgs.StringField(14) # added = msgs.StringField(15, repeated=True) # removed = msgs.StringField(16, repeated=True) # modified = msgs.StringField(17, repeated=True) # commit = msgs.MessageField('Commit', 18) # # Path: flask_github/client/requests.py # class CommitResponse(msgs.Message): # response = msgs.MessageField('Commit', 1) # # Path: flask_github/client/requests.py # class CommitListResponse(msgs.Message): # response = msgs.MessageField('Commit', 1, repeated=True) # # Path: flask_github/client/requests.py # class CommentResponse(msgs.Message): # response = msgs.MessageField('Comment', 1) # # Path: flask_github/client/requests.py # class CommentListResponse(msgs.Message): # response = msgs.MessageField('Comment', 1, repeated=True) . Output only the next line.
self.client.user(user), repo), query=query, msg_type=CommitListResponse)
Here is a snippet: <|code_start|> 'repos/%s/%s/compare/%s...:%s' % ( self.client.user(user), repo, base, head), msg_type=None) # comments.. def list_comments(self, repo, sha=None, user=None): url = 'repos/%s/%s/comments' % ( self.client.user(user), repo) if sha: url = 'repos/%s/%s/commits/%s/comments' % ( self.client.user(user), repo, sha) return self.client.get(url, msg_type=CommentListResponse) def create_comment(self, repo, sha, body, line, path, position, user=None): msg = Commit( body=body, commit_id=sha, line=line, path=path, position=position) return self._create_comment(repo=repo, sha=sha, msg=msg, user=user) def _create_comment(self, repo, sha, msg, user=None): return self.client.post( 'repos/%s/%s/commits/%s/comments' % ( self.client.user(user), repo, sha), data=msg) def get_comment(self, repo, id, user=None): return self.client.get( 'repos/%s/%s/comment/%s' % ( <|code_end|> . Write the next line using the current file imports: from ..messages import Commit from ..requests import CommitResponse from ..requests import CommitListResponse from ..requests import CommentResponse from ..requests import CommentListResponse and context from other files: # Path: flask_github/client/messages.py # class Commit(msgs.Message): # url = msgs.StringField(1) # sha = msgs.StringField(2) # committer = msgs.MessageField('User', 3) # author = msgs.MessageField('User', 4) # comment_count = msgs.IntegerField(5, default=0) # message = msgs.StringField(6) # # string reference allows for recursion.. # tree = msgs.MessageField('Commit', 7) # parents = msgs.MessageField('Commit', 8, repeated=True) # # fields that live on the tree api responses.. # path = msgs.StringField(9) # mode = msgs.StringField(10) # type = msgs.StringField(11) # size = msgs.IntegerField(12, default=0) # # fields for the hooks payload.. # id = msgs.StringField(13) # timestamp = msgs.StringField(14) # added = msgs.StringField(15, repeated=True) # removed = msgs.StringField(16, repeated=True) # modified = msgs.StringField(17, repeated=True) # commit = msgs.MessageField('Commit', 18) # # Path: flask_github/client/requests.py # class CommitResponse(msgs.Message): # response = msgs.MessageField('Commit', 1) # # Path: flask_github/client/requests.py # class CommitListResponse(msgs.Message): # response = msgs.MessageField('Commit', 1, repeated=True) # # Path: flask_github/client/requests.py # class CommentResponse(msgs.Message): # response = msgs.MessageField('Comment', 1) # # Path: flask_github/client/requests.py # class CommentListResponse(msgs.Message): # response = msgs.MessageField('Comment', 1, repeated=True) , which may include functions, classes, or code. Output only the next line.
self.client.user(user), repo, id), msg_type=CommentResponse)
Given the code snippet: <|code_start|> class ReposCommits: def __init__(self, client): self.client = client def list(self, repo, sha=None, path=None, user=None): query = None if sha and path: query = {'sha': sha, 'path': path} return self.client.get('repos/%s/%s/commits' % ( self.client.user(user), repo), query=query, msg_type=CommitListResponse) def get(self, repo, sha, user=None): return self.client.get( 'repos/%s/%s/commits/%s' % ( self.client.user(user), repo, sha), msg_type=CommitResponse) def compare(self, repo, base, head, user=None): return self.client.get( 'repos/%s/%s/compare/%s...:%s' % ( self.client.user(user), repo, base, head), msg_type=None) # comments.. def list_comments(self, repo, sha=None, user=None): url = 'repos/%s/%s/comments' % ( self.client.user(user), repo) if sha: url = 'repos/%s/%s/commits/%s/comments' % ( self.client.user(user), repo, sha) <|code_end|> , generate the next line using the imports in this file: from ..messages import Commit from ..requests import CommitResponse from ..requests import CommitListResponse from ..requests import CommentResponse from ..requests import CommentListResponse and context (functions, classes, or occasionally code) from other files: # Path: flask_github/client/messages.py # class Commit(msgs.Message): # url = msgs.StringField(1) # sha = msgs.StringField(2) # committer = msgs.MessageField('User', 3) # author = msgs.MessageField('User', 4) # comment_count = msgs.IntegerField(5, default=0) # message = msgs.StringField(6) # # string reference allows for recursion.. # tree = msgs.MessageField('Commit', 7) # parents = msgs.MessageField('Commit', 8, repeated=True) # # fields that live on the tree api responses.. # path = msgs.StringField(9) # mode = msgs.StringField(10) # type = msgs.StringField(11) # size = msgs.IntegerField(12, default=0) # # fields for the hooks payload.. # id = msgs.StringField(13) # timestamp = msgs.StringField(14) # added = msgs.StringField(15, repeated=True) # removed = msgs.StringField(16, repeated=True) # modified = msgs.StringField(17, repeated=True) # commit = msgs.MessageField('Commit', 18) # # Path: flask_github/client/requests.py # class CommitResponse(msgs.Message): # response = msgs.MessageField('Commit', 1) # # Path: flask_github/client/requests.py # class CommitListResponse(msgs.Message): # response = msgs.MessageField('Commit', 1, repeated=True) # # Path: flask_github/client/requests.py # class CommentResponse(msgs.Message): # response = msgs.MessageField('Comment', 1) # # Path: flask_github/client/requests.py # class CommentListResponse(msgs.Message): # response = msgs.MessageField('Comment', 1, repeated=True) . Output only the next line.
return self.client.get(url, msg_type=CommentListResponse)
Continue the code snippet: <|code_start|>from __future__ import unicode_literals class ReposHooks: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/hooks' % ( self.client.user(user), repo), msg_type=HookListResponse) def get(self, repo, id, user=None): return self.client.get( 'repos/%s/%s/hooks/%s' % ( self.client.user(user), repo, id), msg_type=HookResponse) def create(self, repo, name, url, events=None, active=True, user=None): <|code_end|> . Use current file imports: from ..messages import Hook, HookConfig from ..requests import HookResponse from ..requests import HookTestResponse from ..requests import HookListResponse and context (classes, functions, or code) from other files: # Path: flask_github/client/messages.py # class Hook(msgs.Message): # id = msgs.IntegerField(1, default=0) # name = msgs.StringField(2) # events = msgs.StringField(3, repeated=True) # add_events = msgs.StringField(4, repeated=True) # remove_events = msgs.StringField(5, repeated=True) # active = msgs.BooleanField(6, default=True) # config = msgs.MessageField('HookConfig', 7) # # class HookConfig(msgs.Message): # url = msgs.StringField(1) # insecure_ssl = msgs.StringField(2) # content_type = msgs.StringField(3, default='json') # # Path: flask_github/client/requests.py # class HookResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookTestResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookListResponse(msgs.Message): # response = msgs.MessageField('Hook', 1, repeated=True) . Output only the next line.
msg = Hook(
Given the code snippet: <|code_start|>from __future__ import unicode_literals class ReposHooks: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/hooks' % ( self.client.user(user), repo), msg_type=HookListResponse) def get(self, repo, id, user=None): return self.client.get( 'repos/%s/%s/hooks/%s' % ( self.client.user(user), repo, id), msg_type=HookResponse) def create(self, repo, name, url, events=None, active=True, user=None): msg = Hook( name=name, <|code_end|> , generate the next line using the imports in this file: from ..messages import Hook, HookConfig from ..requests import HookResponse from ..requests import HookTestResponse from ..requests import HookListResponse and context (functions, classes, or occasionally code) from other files: # Path: flask_github/client/messages.py # class Hook(msgs.Message): # id = msgs.IntegerField(1, default=0) # name = msgs.StringField(2) # events = msgs.StringField(3, repeated=True) # add_events = msgs.StringField(4, repeated=True) # remove_events = msgs.StringField(5, repeated=True) # active = msgs.BooleanField(6, default=True) # config = msgs.MessageField('HookConfig', 7) # # class HookConfig(msgs.Message): # url = msgs.StringField(1) # insecure_ssl = msgs.StringField(2) # content_type = msgs.StringField(3, default='json') # # Path: flask_github/client/requests.py # class HookResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookTestResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookListResponse(msgs.Message): # response = msgs.MessageField('Hook', 1, repeated=True) . Output only the next line.
config=HookConfig(
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals class ReposHooks: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/hooks' % ( self.client.user(user), repo), msg_type=HookListResponse) def get(self, repo, id, user=None): return self.client.get( 'repos/%s/%s/hooks/%s' % ( <|code_end|> , predict the next line using imports from the current file: from ..messages import Hook, HookConfig from ..requests import HookResponse from ..requests import HookTestResponse from ..requests import HookListResponse and context including class names, function names, and sometimes code from other files: # Path: flask_github/client/messages.py # class Hook(msgs.Message): # id = msgs.IntegerField(1, default=0) # name = msgs.StringField(2) # events = msgs.StringField(3, repeated=True) # add_events = msgs.StringField(4, repeated=True) # remove_events = msgs.StringField(5, repeated=True) # active = msgs.BooleanField(6, default=True) # config = msgs.MessageField('HookConfig', 7) # # class HookConfig(msgs.Message): # url = msgs.StringField(1) # insecure_ssl = msgs.StringField(2) # content_type = msgs.StringField(3, default='json') # # Path: flask_github/client/requests.py # class HookResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookTestResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookListResponse(msgs.Message): # response = msgs.MessageField('Hook', 1, repeated=True) . Output only the next line.
self.client.user(user), repo, id), msg_type=HookResponse)
Given the code snippet: <|code_start|>from __future__ import unicode_literals class ReposHooks: def __init__(self, client): self.client = client def list(self, repo, user=None): return self.client.get( 'repos/%s/%s/hooks' % ( <|code_end|> , generate the next line using the imports in this file: from ..messages import Hook, HookConfig from ..requests import HookResponse from ..requests import HookTestResponse from ..requests import HookListResponse and context (functions, classes, or occasionally code) from other files: # Path: flask_github/client/messages.py # class Hook(msgs.Message): # id = msgs.IntegerField(1, default=0) # name = msgs.StringField(2) # events = msgs.StringField(3, repeated=True) # add_events = msgs.StringField(4, repeated=True) # remove_events = msgs.StringField(5, repeated=True) # active = msgs.BooleanField(6, default=True) # config = msgs.MessageField('HookConfig', 7) # # class HookConfig(msgs.Message): # url = msgs.StringField(1) # insecure_ssl = msgs.StringField(2) # content_type = msgs.StringField(3, default='json') # # Path: flask_github/client/requests.py # class HookResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookTestResponse(msgs.Message): # response = msgs.MessageField('Hook', 1) # # Path: flask_github/client/requests.py # class HookListResponse(msgs.Message): # response = msgs.MessageField('Hook', 1, repeated=True) . Output only the next line.
self.client.user(user), repo), msg_type=HookListResponse)