mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 05:34:51 +08:00
Make lines easier copyable in the fuzzer
This commit is contained in:
@@ -27,7 +27,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import pickle
|
import pickle
|
||||||
import difflib
|
|
||||||
|
|
||||||
import parso
|
import parso
|
||||||
from parso.utils import split_lines
|
from parso.utils import split_lines
|
||||||
@@ -55,6 +54,14 @@ def find_python_files_in_tree(file_path):
|
|||||||
yield os.path.join(root, name)
|
yield os.path.join(root, name)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_copyable_lines(lines):
|
||||||
|
for line in lines:
|
||||||
|
line = repr(line)[1:-1]
|
||||||
|
if line.endswith(r'\n'):
|
||||||
|
line = line[:-2] + '\n'
|
||||||
|
print(line, end='')
|
||||||
|
|
||||||
|
|
||||||
class LineReplacement:
|
class LineReplacement:
|
||||||
def __init__(self, line_nr, new_line):
|
def __init__(self, line_nr, new_line):
|
||||||
self._line_nr = line_nr
|
self._line_nr = line_nr
|
||||||
@@ -147,9 +154,10 @@ class FileModification:
|
|||||||
|
|
||||||
if print_code:
|
if print_code:
|
||||||
print('Original:')
|
print('Original:')
|
||||||
print(code)
|
_print_copyable_lines(code_lines)
|
||||||
print('Modified:')
|
print('\nModified:')
|
||||||
print(modified_code)
|
_print_copyable_lines(modified_lines)
|
||||||
|
print()
|
||||||
|
|
||||||
grammar.parse(code, diff_cache=True)
|
grammar.parse(code, diff_cache=True)
|
||||||
grammar.parse(modified_code, diff_cache=True)
|
grammar.parse(modified_code, diff_cache=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user