Check if given lines of code are complete and proper Python code
<p>Sorry for my English. This problem is complicated, and my English isn't thats good to describe everything clearly.</p>

<p>Ok, I have this example code. This is only a small code, in real environment i operate on much larger code than that.</p>

<pre><code>01: multi_line_string = """Abc
02: Dfg
03: Hjk"""
04: # Comment
05: do_somethingA()
06: do_somethingB()
07: do_somethingC()
08: string_with_linebrak = "Abc \
09: Dfg \
10: Hjk"
</code></pre>

<p>This  code, each line as list element i get as argument in my function with one line number. In result i need to return list of 2 lines around given line number. For example, with this code i get line number 5. This is <code>do_somethingA()</code> line.</p>

<p>My function must return list with 5 elements - 2 lines before line 5, line 5 and 2 lines after line 5. That is:</p>

<pre><code>03: Hjk"""
04: # Comment
05: do_somethingA()
06: do_somethingB()
07: do_somethingB()
</code></pre>

<p>As you see in return i have broken Python code. Unfortunately, I must get complete code. So, I need somehow detect that line 3 are not complete line of Python code and i need to detect where this broken line are started or ended and get all lines along the way. So, what i need is:</p>

<pre><code>01: multi_line_string = """Abc
02: Dfg
03: Hjk"""
04: # Comment
05: do_somethingA()
06: do_somethingB()
07: do_somethingC()
</code></pre>

<p>Lexing complete code is not an option, I need most CPU efficient way to do this.</p>
