Switch to regex; update styles
This commit is contained in:
parent
f57940fc54
commit
850d385564
@ -21,6 +21,7 @@ from __future__ import print_function
|
||||
import collections
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
@ -63,8 +64,13 @@ def process_file(in_filename, out_filename, upgrader):
|
||||
|
||||
|
||||
def skip_magic(code_line, magic_list):
|
||||
"""
|
||||
Checks if the cell has magic, that is not python-based.
|
||||
"""Checks if the cell has magic, that is not Python-based.
|
||||
|
||||
Args:
|
||||
code_line: A line of Python code
|
||||
magic_list: A list of jupyter "magic" exceptions
|
||||
Returns:
|
||||
If the line jupyter "magic" line, not Python line
|
||||
|
||||
>>> skip_magic('!ls -laF', ['%', '!', '?'])
|
||||
True
|
||||
@ -78,18 +84,18 @@ def skip_magic(code_line, magic_list):
|
||||
|
||||
|
||||
def check_line_split(code_line):
|
||||
r"""
|
||||
Checks if a line was splitted with `\`.
|
||||
r"""Checks if a line was split with `\`.
|
||||
|
||||
Args:
|
||||
code_line: A line of Python code
|
||||
Returns:
|
||||
If the line was split with `\`
|
||||
|
||||
>>> skip_magic("!gcloud ml-engine models create ${MODEL} \\\n")
|
||||
True
|
||||
"""
|
||||
|
||||
if code_line.endswith('\\\n'):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
return re.search(r'\\\s*\n$', code_line)
|
||||
|
||||
def _get_code(input_file):
|
||||
"""Loads the ipynb file and returns a list of CodeLines."""
|
||||
|
Loading…
Reference in New Issue
Block a user