##// END OF EJS Templates
refactor to improve cell switching in edit mode...
refactor to improve cell switching in edit mode This code was repeated in both CodeCell and TextCell, both of which are extensions of Cell, so this just unifies the logic in Cell. TextCell had logic here to check if the cell was rendered or not, but I don't believe it is possible to end up triggering such a code path. (Should that be required, I can always just add back these methods to TextCell, performing the .rendered==True check, and calling the Cell prior to this, code mirror at_top would only return true on if the cursor was at the first character of the top line. Now, pressing up arrow on any character on the top line will take you to the cell above. The same applies for the bottom line. Pressing down arrow would only go to the next cell if the cursor was at a location *after* the last character (something that is only possible to achieve in vim mode if the last line is empty, for example). Now, down arrow on any character of the last line will go to the next cell.

File last commit:

r14903:3a071760
r15754:d60e793e
Show More
submodule.py
96 lines | 3.0 KiB | text/x-python | PythonLexer
MinRK
add utils.submodule
r10555 """utilities for checking submodule status"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
import os
import subprocess
import sys
#-----------------------------------------------------------------------------
# Globals
#-----------------------------------------------------------------------------
pjoin = os.path.join
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
def ipython_parent():
"""return IPython's parent (i.e. root if run from git)"""
from IPython.utils.path import get_ipython_package_dir
return os.path.abspath(os.path.dirname(get_ipython_package_dir()))
def ipython_submodules(root):
"""return IPython submodules relative to root"""
return [
MinRK
update references for IPython.html
r11035 pjoin(root, 'IPython', 'html', 'static', 'components'),
MinRK
add utils.submodule
r10555 ]
def is_repo(d):
"""is d a git repo?"""
return os.path.exists(pjoin(d, '.git'))
def check_submodule_status(root=None):
"""check submodule status
Has three return values:
'missing' - submodules are absent
'unclean' - submodules have unstaged changes
'clean' - all submodules are up to date
"""
if hasattr(sys, "frozen"):
MinRK
skip submodule check in package managers...
r10683 # frozen via py2exe or similar, don't bother
return 'clean'
MinRK
add utils.submodule
r10555
if not root:
root = ipython_parent()
Thomas Kluyver
Make submodule checks work under Python 3....
r10815
if not is_repo(root):
# not in git, assume clean
return 'clean'
MinRK
add utils.submodule
r10555
submodules = ipython_submodules(root)
for submodule in submodules:
if not os.path.exists(submodule):
return 'missing'
MinRK
unicode sadness on Windows in the submodule check
r14697
# Popen can't handle unicode cwd on Windows Python 2
if sys.platform == 'win32' and sys.version_info[0] < 3 \
and not isinstance(root, bytes):
root = root.encode(sys.getfilesystemencoding() or 'ascii')
MinRK
add utils.submodule
r10555 # check with git submodule status
proc = subprocess.Popen('git submodule status',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=root,
)
status, _ = proc.communicate()
MinRK
unicode sadness on Windows in the submodule check
r14697 status = status.decode("ascii", "replace")
MinRK
add utils.submodule
r10555
for line in status.splitlines():
MinRK
fix line/statys typo in utils.submodule
r14903 if line.startswith('-'):
MinRK
add utils.submodule
r10555 return 'missing'
MinRK
fix line/statys typo in utils.submodule
r14903 elif line.startswith('+'):
MinRK
add utils.submodule
r10555 return 'unclean'
return 'clean'
def update_submodules(repo_dir):
"""update submodules in a repo"""
MinRK
use check_call in update_submodules
r10583 subprocess.check_call("git submodule init", cwd=repo_dir, shell=True)
subprocess.check_call("git submodule update --recursive", cwd=repo_dir, shell=True)
MinRK
add utils.submodule
r10555