##// END OF EJS Templates
Adding prompt area to non-CodeCells to indent content....
Adding prompt area to non-CodeCells to indent content. This is a reponse to the problem of having really long lines in Markdown cells, which makes the content difficult to read. Users want wide code cells, so we don't want to narrow everything. The solution here is to give a prompt area to the heading/md cells to narrow their content area slightly. The only problem is that this makes it more difficult to distinguish between output and md content that follows that output. The solve this, we are adding a narrow line between output and following md.

File last commit:

r11035:58fc464b
r13776:e285883b
Show More
submodule.py
92 lines | 2.8 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'
# check with git submodule status
proc = subprocess.Popen('git submodule status',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
cwd=root,
)
status, _ = proc.communicate()
status = status.decode("ascii")
for line in status.splitlines():
if status.startswith('-'):
return 'missing'
elif status.startswith('+'):
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