dotfiles.venv package

Objectives

dotfiles.venv.venv_ipyconfig (venv_ipyconfig.py):

  • Set variables for standard Virtualenv paths in the environment dict (“Venv Paths”)

  • Define IPython aliases (%aliases)

  • Serialize variables and aliases to:

    • IPython configuration (variables, aliases)

    • Bash/ZSH configuration (variables, aliases, functions):

      venv.py -e --bash        # venv --print-bash --from-environ
      venv.py dotfiles --bash  # venv --print-bash --wh=~/-wrk/-ve27 --ve=dotfiles
      
    • JSON (variables, aliases) [--print]:

      venv.py -e --json
      venv.py dotfiles --json
      

dotfiles.venv.venv_ipymagics (venv_ipymagics.py):

  • Configure IPython %magic commands
    • ds – print dotfiles_status
    • cd*CdAliases for Venv Paths (e.g. %cdhelp, %cdp, %cdwh, %cdv, %cds, %cdw)

Configuration

Shell

:ref:`dotfiles` configuration`

# TODO:

source ${__DOTFILES}/scripts/venv.sh
source ${__VENV}/scripts/venv.sh

build-venv.sh:
    cat venv_core.sh > venv.sh
    cat venv_cdaliases >> venv.sh

source ${__DOTFILES}/etc/bash/10-bashrc.venv.sh   # venv(), workon_venv
    source ${__DOTFILES}/scripts/venv.sh          # cdaliases, work

etc/bash/10-bashrc.venv.sh is sourced by etc/bash/00-bashrc.before.sh, which is sourced by ~/.bashrc (a symlink to ${__DOTFILES}/etc/.bashrc created by bootstrap_dotfiles.sh -S).

IPython

To configure IPython with venv, venv_ipyconfig.py must be symlinked into ~/.ipython/profile_default/ipython_config.py and, optionally, for CdAliases, venv_ipymagics.py must be symlinked into e.g. ~/.ipython/profile_default/startup/20-venv_ipymagics.py):

# symlink paths relative to ${__DOTFILES}
__DOTFILES="~/-dotfiles"
# working directory (path to the dotfiles repository)
_WRD=${WORKON_HOME}/dotfiles/src/dotfiles

# MANUALLY INSTALL for each IPython profile
IPY_PROFILE="profile_default"
ln -s ${__DOTFILES}/scripts/venv_ipyconfig.py \
      ~/.ipython/${IPY_PROFILE}/ipython_config.py

ln -s ${__DOTFILES}/scripts/venv_ipymagics.py \
      ~/.ipython/${IPY_PROFILE}/startup/20-venv_ipymagics.py

Submodules

dotfiles.venv.ipython_config module

dotfiles.venv.ipython_config.in_venv_ipyconfig()[source]
Returns:True if get_ipython is in globals()
Return type:bool
dotfiles.venv.ipython_config.logevent(event, obj=None, logger=<Logger venv (WARNING)>, level=10, func=None, lineno=None, modpath=None, show_modpath=None, wrap=False, splitlines=True)[source]
Parameters:
  • event (str) – an event key
  • obj (thing) – thing to serialize and log
  • logger (logging.Logger) – logger to log to
  • level (int) – logging loglevel to log (event, obj)
  • wrap (bool) – Add header and footer <event> tags (default: False)
  • splitlines (bool) – split by newlines and emit one log message per line
Returns:

(event:str, output:str)

Return type:

tuple

exception dotfiles.venv.ipython_config.ConfigException[source]

Bases: Exception

exception dotfiles.venv.ipython_config.StepException[source]

Bases: Exception

exception dotfiles.venv.ipython_config.StepConfigException[source]

Bases: dotfiles.venv.ipython_config.StepException, dotfiles.venv.ipython_config.ConfigException

dotfiles.venv.ipython_config.prepend_comment_char(strblock, commentchar='##')[source]
Parameters:
  • strblock (str) – string to split by newlines and prepend
  • prefix (str) – comment string prefix (one space will be added)
Yields:

str – lines prefixed with prefix

dotfiles.venv.ipython_config.get_pyver(pyverstr=None)[source]
Parameters:pyver (str) – “major.minor” e.g. 2.7 or 3.4 (default: sys.version_info[:2])
Returns:python2.7, python.34
Return type:str
dotfiles.venv.ipython_config.get___WRK_default(env=None, **kwargs)[source]
dotfiles.venv.ipython_config.get_WORKON_HOME_default(env=None, from_environ=False, default='-ve27', **kwargs)[source]
Keyword Arguments:
 
  • env (dict) – Env dict to read from (default: None)
  • from_environ (bool) – read WORKON_HOME from os.environ
  • default (str) – default WORKON_HOME dirname
  • __WRK (str) –
Returns:

path to a WORKON_HOME directory

Return type:

str

class dotfiles.venv.ipython_config.VenvJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class dotfiles.venv.ipython_config.CmdAlias(cmdstr)[source]

Bases: object

to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:self.cmdstr (AS-IS)
Return type:str
to_ipython_alias()[source]

Generate an alias for IPython

Returns:self.cmdstr (AS-IS)
Return type:str
class dotfiles.venv.ipython_config.IpyAlias(cmdstr, name=None, complfuncstr=None)[source]

Bases: dotfiles.venv.ipython_config.CmdAlias

An IPython alias command string which expands to a shell function aliasname() { ... } and handles positional args %s and %l

References

  • TODO: IPython docs
to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:an alias or a function()
alias name=repr(cmdstr)
# or
cmdname () {
    cmdstr
}
Return type:str
class dotfiles.venv.ipython_config.CdAlias(pathvar, name=None, aliases=None)[source]

Bases: dotfiles.venv.ipython_config.CmdAlias

A CmdAlias for cd change directory functions with venv paths (e.g. $_WRD) for Bash, ZSH, IPython, Vim.

  • venv.sh bash functions with tab-completion (cdwrd, cdw, cdw<tab>)
  • venv_ipymagics.py: ipython magics (%cdwrd, cdwrd, cdw)
  • venv.vim: vim functions (:Cdwrd)
VENV_IPYMAGICS_FILE_HEADER = '\n#!/usr/bin/env ipython\n# dotfiles.venv.venv_ipymagics\nfrom __future__ import print_function\n"""\nIPython ``%magic`` commands\n\n* ``cd`` aliases\n* ``ds`` (``dotfiles_status``)\n* ``dr`` (``dotfiles_reload``)\n\nInstallation\n--------------\n.. code-block:: bash\n\n __DOTFILES="${HOME}/-dotfiles"\n ipython_profile="profile_default"\n ln -s ${__DOTFILES}/etc/ipython/venv_ipymagics.py \\\n ~/.ipython/${ipython_profile}/startup/venv_ipymagics.py\n"""\nimport os\nimport sys\ntry:\n from IPython.core.magic import (Magics, magics_class, line_magic)\nexcept ImportError:\n print("ImportError: IPython")\n # Mock IPython for building docs\n Magics = object\n magics_class = lambda cls, *args, **kwargs: cls\n line_magic = lambda func, *args, **kwargs: func\n\nif sys.version_info.major == 2:\n str = unicode\n\ndef ipymagic_quote(_str):\n return str(_str)\n\n@magics_class\nclass VenvMagics(Magics):\n def cd(self, envvar, line):\n """\n Change directory\n\n Args:\n envvar (str): os.environ variable name\n line (str): path to append to envvar\n """\n prefix = os.environ.get(envvar, "")\n _dstpath = line.lstrip(os.path.sep)\n path = os.path.join(prefix, _dstpath)\n cmd = ("cd %s" % ipymagic_quote(path))\n print("%" + cmd, file=sys.stderr)\n return self.shell.magic(cmd)'
VENV_IPYMAGIC_METHOD_TEMPLATE = '\n @line_magic\n def {ipy_func_name}(self, line):\n """{ipy_func_name} -- cd ${pathvar}/${{@}}"""\n return self.cd(\'{pathvar}\', line)'
to_ipython_method()[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:ipython method block
Return type:str
VIM_HEADER_TEMPLATE = '\n" ### venv.vim\n" # Src: https://github.com/westurner/venv.vim\n\n" "g:venv_list_only_dirs -- 1 -- 0 to list files in Cd* commands\n\nlet g:venv_list_only_dirs = 1\n\nfunction! Cd_help()\n" :Cdhelp -- list venv.vim cdalias commands\n :verbose command Cd\nendfunction\ncommand! -nargs=0 Cdhelp call Cd_help()\n\nfunction! ListDirsOrFiles(path, ArgLead, ...)\n let dirsonly = ((a:0>0) ? 1 : g:venv_list_only_dirs)\n let _glob = \'\' . a:ArgLead . ((g:venv_list_only_dirs>1) ? \'*/\' : \'*\')\n execute \'lcd\' a:path\n if dirsonly ==? 1\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:]\')\n elseif dirsonly ==? 0\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:] . (isdirectory(v:val) ? "/" : "")\')\n endif\n execute \'lcd -\'\n return output\nendfunction\n\nfunction! Cdhere(...)\n" :Cdhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n" :CDhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'cd\' _path\n pwd\nendfunction\nfunction! Compl_Cdhere(ArgLead, ...)\n return ListDirsOrFiles(expand(\'%:p:h\'), a:ArgLead, 1)\nendfor\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Cdhere call Cdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere CDhere call Cdhere(<f-args>)\n\nfunction! Lcdhere(...)\n" :Lcdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n" :LCdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'lcd\' _path\n pwd\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Lcdhere call Lcdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere LCdhere call Lcdhere(<f-args>)\n\n\nfunction! Cd___VAR_(varname, cmd, ...)\n" Cd___VAR_() -- cd expand(\'$\' . a:varname)/$1\n let _VARNAME = a:varname\n let _VAR_=expand(_VARNAME)\n if _VARNAME ==? _VAR_\n echoerr _VARNAME . " is not set"\n return\n endif\n let pathname = join([_VAR_, (a:0>0) ? a:1 : ""], "/")\n execute a:cmd pathname\n pwd\nendfunction\n\n'
VIM_CD_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- cd ${pathvar}/$1\n call Cd___VAR_(\'${pathvar}\', \'{vim_cd_func}\', (a:0>0)? a:1 : "")\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 1)\nendfunction\n'
VIM_CD_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- cd ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
VIM_EDIT_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- e ${pathvar}/$1\n let _path=expand("${pathvar}") . ((a:0>0)? "/" . a:1 : "")\n execute \'{vim_edit_func}\' _path\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 0)\nendfunction\n'
VIM_EDIT_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- e ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
vim_cmd_name

Returns: str: e.g “Cdwrd”

vim_cmd_names

Returns: list: self.vim_cmd_name + self.aliases.title()

to_vim_function()[source]
Returns:vim function block
Return type:str
BASH_CDALIAS_HEADER = '#!/bin/sh\n## venv.sh\n# generated from $(venv --print-bash --prefix=/)\n\n'
BASH_FUNCTION_TEMPLATE = '{bash_func_name} () {{\n # {bash_func_name:16} -- cd ${pathvar} /$@\n [ -z "${pathvar}" ] && echo "{pathvar} is not set" && return 1\n cd "${pathvar}"${{@:+"/${{@}}"}}\n}}\n{bash_compl_name} () {{\n local cur="$2";\n COMPREPLY=($({bash_func_name} && compgen -d -- "${{cur}}" ))\n}}\n'
BASH_ALIAS_TEMPLATE = '{cmd_name} () {{\n # {cmd_name:16} -- cd ${pathvar}\n {bash_func_name} $@\n}}\n'
BASH_COMPLETION_TEMPLATE = 'complete -o default -o nospace -F {bash_compl_name} {cmd_name}\n'
bash_func_name

Returns: str: e.g. “cdwrd”

bash_func_names

Returns: list: self.bash_func_name + self.aliases

to_bash_function(include_completions=True)[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:bash function block
Return type:str
to_shell_str()[source]
Returns:eval ‘{_to_bash_function()}’
Return type:str
class dotfiles.venv.ipython_config.Step(func=None, **kwargs)[source]

Bases: object

A build task step which builds or transforms an Env, by calling step.build(env=env, **step.conf)

name

Returns: str: a name for this Step

asdict()[source]
Returns:OrderedDict(self._iteritems())
Return type:OrderedDict
build_print_kwargs_env(env=None, **kwargs)[source]

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

DEFAULT_FUNC(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

build(env=None, **kwargs)[source]

Call self.func(env=env, **self.conf.copy().update(**kwargs))

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

self.func(env=env, **self.conf.copy().update(**kwargs))

Return type:

obj

class dotfiles.venv.ipython_config.PrintEnvStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.ipython_config.Step

Print env and kwargs to stdout

stdout = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
stderr = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

class dotfiles.venv.ipython_config.PrintEnvStderrStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.ipython_config.PrintEnvStep

Print env and kwargs to stderr

stdout = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
class dotfiles.venv.ipython_config.StepBuilder(**kwargs)[source]

Bases: object

A class for building a sequence of steps which modify env

name
debug

Returns: str: self.conf.get(‘debug’)

show_diffs

Returns: str: self.conf.get(‘show_diffs’)

add_step(func, **kwargs)[source]

Add a step to self.steps

Parameters:
  • func (Step or function or str) – func(env=None, **kwargs)
  • kwargs (dict) – kwargs for Step.conf
Keyword Arguments:
 

name (str) – function name (default: None)

Returns:

Step object appended to self.steps

Return type:

Step

build_iter(env=None, show_diffs=True, debug=False)[source]

Build a generator of (Step, Env) tuples from the functional composition of StepBuilder.steps given an initial Env (or None).

# pseudocode
env_previous = Env()
for step in self.steps:
    (step, env) = step.build(env=env_previous.copy(),**conf)
    env_previous=env
Keyword Arguments:
 
  • env (Env) – initial Env (default: None)
  • show_diffs (bool) – show difflib.ndiffs of Envs between steps
  • debug (bool) –
Yields:

tuple – (Step, Env)

build(*args, **kwargs)[source]

Build a list of Envs from self.build_iter(*args, **kwargs) and return the last Env.

Keyword Arguments:
 debug (bool) – log.debug(env)
Returns:the last env returned from .build_iter
Return type:Env or None
dotfiles.venv.ipython_config.lookup_from_kwargs_env(kwargs, env, attr, default=None)[source]

__getitem__ from kwargs, env, or default.

Parameters:
  • kwargs (dict) – kwargs dict
  • env (Env) – Env dict
  • attr (str) – attribute name
  • default (obj) – default value to return if not found in kwargs or env
Returns:

kwargs.get(attr, env.get(attr, default))

Return type:

obj

dotfiles.venv.ipython_config.build_dotfiles_env(env=None, **kwargs)[source]

Configure dotfiles base environment (HOME, __WRK, __SRC, __DOTFILES)

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • HOME (str) – home path ($HOME, ~)
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • __SRC (str) – path to source repos ($__WRK/-src)
  • __DOTFILES (str) – current dotfiles path (~/-dotfiles)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • HOME
  • __WRK
  • __SRC
  • __DOTFILES

Return type:

env (Env dict)

dotfiles.venv.ipython_config.build_virtualenvwrapper_env(env=None, **kwargs)[source]

Set WORKON_HOME to WORKON_HOME or WORKON_HOME_DEFAULT

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • WORKON_HOME_DEFAULT (str) – variable name (default: WORKON_HOME__py27)
  • WORKON_HOME__* (str) – path to a WORKON_HOME set
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • WORKON_HOME__py27=’${__WRK}/-ve27’
  • WORKON_HOME__py34=’${__WRK}/-ve34’
  • WORKON_HOME__*=kwargs.get(WORKON_HOME__*)
  • WORKON_HOME_DEFAULT=’WORKON_HOME_py27’

Return type:

env (Env dict)

dotfiles.venv.ipython_config.build_conda_env(env=None, **kwargs)[source]

Configure conda27 (2.7) and conda (3.4) with condaenvs in -wrk/-ce27 and -wrk/ce34.

Other Parameters:
 
  • __WRK (str) – workspace root ($__WRK, ~/-wrk)
  • CONDA_ROOT__py27 (str) – path to conda27 root environment
  • CONDA_ENVS__py27 (str) – path to conda27 envs (e.g. WORKON_HOME)
  • CONDA_ROOT__py34 (str) – path to conda34 root environment
  • CONDA_ENVS__py34 (str) – path to conda34 envs (e.g. WORKON_HOME)
Keyword Arguments:
 

env (Env dict) – dotfiles.venv.venv_ipyconfig.Env

Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

dotfiles.venv.ipython_config.build_conda_cfg_env(env=None, **kwargs)[source]

Configure conda for a specific environment TODO build_venv_config

Parameters:env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
Returns:dotfiles.venv.venv_ipyconfig.Env
Return type:env (Env dict)
dotfiles.venv.ipython_config.build_venv_paths_full_env(env=None, pyver=None, **kwargs)[source]

Set variables for standard paths in the environment

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env (default: None (Env()))
  • VENVPREFIX (str) – venv prefix path (default: None (VIRTUAL_ENV))
  • VENVSTR (str) – name of a VIRTUAL_ENV in WORKON_HOME or path to a VIRTUAL_ENV (default: None)
  • VIRTUAL_ENV (str) – path to a VIRTUAL_ENV (default: None)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Raises:

StepConfigException – When not any(( VIRTUAL_ENV, VENVPREFIX, VENVSTR, VENVSTRAPP))

References

dotfiles.venv.ipython_config.build_venv_paths_cdalias_env(env=None, **kwargs)[source]

Build CdAliases for standard paths

Keyword Arguments:
 env (Env dict) – Env
Returns:Env with .aliases extended.
Return type:env (Env dict)

Note

These do not work in IPython as they run in a subshell. See: dotfiles.venv.venv_ipymagics.

dotfiles.venv.ipython_config.build_user_aliases_env(env=None, dont_reflect=False, VIRTUAL_ENV=None, _SRC=None, _ETC=None, _CFG=None, PROJECT_FILES=None, **kwargs)[source]

Configure env variables and return an OrderedDict of aliases

Parameters:dont_reflect (bool) – Whether to always create aliases and functions referencing $_WRD even if $_WRD doesn’t exist. (default: False)
Returns:dict of aliases
Return type:OrderedDict
dotfiles.venv.ipython_config.build_usrlog_env(env=None, _TERM_ID=None, shell='bash', prefix=None, USER=None, HOSTNAME=None, lookup_hostname=False, **kwargs)[source]

Build environment variables and configuration like usrlog.sh

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • _TERM_ID (str) – terminal identifier string
  • shell (str) – shell name (“bash”, “zsh”)
  • prefix (str) – a path prefix (e.g. $VIRTUAL_ENV or $PREFIX)
  • USER (str) – system username ($USER) for HISTTIMEFORMAT
  • HOSTNAME (str) – system hostname (HOSTNAME) for HISTTIMEFORMAT
  • lookup_hostname (bool) – if True, HOSTNAME is None, and not env.get(‘HOSTNAME’), try to read HOSTNAME from os.environ and then socket.gethostname().
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Note

Like usrlog.sh, when HISTTIMEFORMAT is set, USER and HOSTNAME must be evaluated.

(When USER and HOSTNAME change, HISTTIMEFORMAT is not updated, and the .history file will contain only the most recent USER and HOSTNAME settings, which are not necessarily the actual USER and HOSTNAME.)

TODO: could/should instead (also) write USER and HOSTNAME to -usrlog.log.

dotfiles.venv.ipython_config.build_venv_activate_env(env=None, VENVSTR=None, VENVSTRAPP=None, from_environ=False, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, **kwargs)[source]
class dotfiles.venv.ipython_config.Env(*args, **kwargs)[source]

Bases: object

OrderedDict of variables for/from os.environ.

osenviron_keys_classic = ('VIMBIN', 'GVIMBIN', 'MVIMBIN', 'GUIVIMBIN', 'VIMCONF', 'EDITOR', 'EDITOR_', 'PAGER', '__WRK', '__DOTFILES', 'PROJECT_HOME', 'WORKON_HOME', 'WORKON_HOME__py27', 'WORKON_HOME__py34', 'VENVPREFIX', 'VENVSTR', 'VENVSTRAPP', '_APP', 'VIRTUAL_ENV_NAME', 'VIRTUAL_ENV', '_SRC', '_ETC', '_BIN', '_CFG', '_LIB', '_LOG', '_MNT', '_OPT', '_PYLIB', '_PYSITE', '_SRV', '_VAR', '_WRD', '_WRD_SETUPY', '_WWW', '__SRC', '__DOCSWWW', '_USRLOG', '__USRLOG', '_TERM_ID', '_TERM_URI')
osenviron_keys = {'CONDA_ENVS_PATH': '${__WRK}/-ce27', 'CONDA_ENVS__py27': '${__WRK}/-ce27', 'CONDA_ENVS__py34': '${__WRK}/-ce34', 'CONDA_ENVS__py35': '${__WRK}/-ce35', 'CONDA_ENVS__py36': '${__WRK}/-ce36', 'CONDA_ENVS__py37': '${__WRK}/-ce37', 'CONDA_ROOT': '${__WRK}/-conda27', 'CONDA_ROOT__py27': '${__WRK}/-conda27', 'CONDA_ROOT__py34': '${__WRK}/-conda34', 'CONDA_ROOT__py35': '${__WRK}/-conda35', 'CONDA_ROOT__py36': '${__WRK}/-conda36', 'CONDA_ROOT__py37': '${__WRK}/-conda37', 'PROJECT_HOME': '${__WRK}', 'VENVPREFIX': '${VIRTUAL_ENV}', 'VENVSTR': 'dotfiles', 'VENVSTRAPP': 'dotfiles', 'VIRTUAL_ENV': '${WORKON_HOME}/${VIRTUAL_ENV_NAME}', 'VIRTUAL_ENV_NAME': 'dotfiles', 'WORKON_HOME': '${__WRK}/-ve27', 'WORKON_HOME_DEFAULT': 'WORKON_HOME__py37', 'WORKON_HOME__py27': '${__WRK}/-ve27', 'WORKON_HOME__py34': '${__WRK}/-ve34', 'WORKON_HOME__py35': '${__WRK}/-ve35', 'WORKON_HOME__py36': '${__WRK}/-ve36', 'WORKON_HOME__py37': '${__WRK}/-ve37', '_APP': 'dotfiles', '_BIN': '${VIRTUAL_ENV}/bin', '_ETC': '${VIRTUAL_ENV}/etc', '_ETCOPT': '${_ETC}/opt', '_HOME': '${VIRTUAL_ENV}/home', '_LIB': '${VIRTUAL_ENV}/lib', '_LOG': '${_VAR}/log', '_MEDIA': '${VIRTUAL_ENV}/media', '_MNT': '${VIRTUAL_ENV}/mnt', '_OPT': '${VIRTUAL_ENV}/opt', '_PYLIB': '${_LIB}/python2.7', '_PYSITE': '${_PYLIB}/site-packages', '_ROOT': '${VIRTUAL_ENV}/root', '_SBIN': '${VIRTUAL_ENV}/sbin', '_SRC': '${VIRTUAL_ENV}/src', '_SRV': '${VIRTUAL_ENV}/srv', '_TMP': '${VIRTUAL_ENV}/tmp', '_USR': '${VIRTUAL_ENV}/usr', '_USRBIN': '${VIRTUAL_ENV}/usr/bin', '_USRINCLUDE': '${VIRTUAL_ENV}/usr/include', '_USRLIB': '${VIRTUAL_ENV}/usr/lib', '_USRLOCAL': '${VIRTUAL_ENV}/usr/local', '_USRLOCALBIN': '${VIRTUAL_ENV}/usr/local/bin', '_USRSBIN': '${VIRTUAL_ENV}/usr/sbin', '_USRSHARE': '${VIRTUAL_ENV}/usr/share', '_USRSRC': '${VIRTUAL_ENV}/usr/src', '_VAR': '${VIRTUAL_ENV}/var', '_VARCACHE': '${_VAR}/cache', '_VARLIB': '${_VAR}/lib', '_VARLOCK': '${_VAR}/lock', '_VARMAIL': '${_VAR}/mail', '_VAROPT': '${_VAR}/opt', '_VARRUN': '${_VAR}/run', '_VARSPOOL': '${_VAR}/spool', '_VARTMP': '${_VAR}/tmp', '_WRD': '${_SRC}/dotfiles', '_WWW': '${_VAR}/www', '__DOTFILES': '${HOME}/-dotfiles', '__SRC': '${__WRK}/-src', '__WRK': '${HOME}/-wrk'}
name
logevent(*args, **kwargs)[source]
iterkeys()[source]
iteritems_environ()[source]
iteritems()[source]
get(k, default=None)[source]
copy()[source]
classmethod from_environ(environ, verbose=False)[source]

Build an Env from a dict (e.g. os.environ)

Parameters:
  • environ (dict) – a dict with variable name keys and values
  • verbose (bool) – whether to be verbose about dict merging
Returns:

an Env environment built from the given environ dict

Return type:

Env

compress_paths(path_, keys=None, keyname=None)[source]

Given an arbitrary string, replace absolute paths (starting with ‘/’) with the longest matching Env path variables.

Parameters:path (str) – a path string
Returns:path string containing ${VARNAME} variables
Return type:str
to_string_iter(**kwargs)[source]
ndiff(other_env)[source]
Parameters:other_env (Env) – env to compare with
Returns:strings from difflib.ndiff
Return type:iterable
to_dict()[source]
to_json(*args, **kwargs)[source]
dotfiles.venv.ipython_config.shell_quote(var)[source]

Escape single quotes and add double quotes around a given variable.

Parameters:_str (str) – string to add quotes to
Returns:string wrapped in quotes
Return type:str

Warning

This is not safe for untrusted input and only valid in this context (os.environ).

dotfiles.venv.ipython_config.shell_varquote(str_)[source]

Add doublequotes and shell variable brackets to a string

Parameters:str (str) – string to varquote (e.g. VIRTUAL_ENV)
Returns:“${VIRTUAL_ENV}”
Return type:str
class dotfiles.venv.ipython_config.Venv(VENVSTR=None, VENVSTRAPP=None, _Venv__WRK=None, _Venv__DOTFILES=None, WORKON_HOME=None, VIRTUAL_ENV_NAME=None, VENVPREFIX=None, VIRTUAL_ENV=None, _SRC=None, _APP=None, _WRD=None, env=None, from_environ=False, open_editors=False, open_terminals=False, dont_reflect=True, debug=False, show_diffs=False, **kwargs)[source]

Bases: object

A virtual environment configuration generator

build(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, from_environ=False, dont_reflect=True, debug=False, show_diffs=False, build_user_aliases=False, build_userlog_env=False)[source]

Build Venv Steps with StepBuilder

static parse_VENVSTR(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, _Venv__WRK=None, WORKON_HOME=None, from_environ=False, **kwargs)[source]

Get the path to a virtualenv given a VENVSTR

Keyword Arguments:
 
  • env (Env) –
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) –
  • VENVPREFIX (str) –
  • WORKON_HOME (str) –
  • from_environ (bool) – whether to try and read from os.environ["VIRTUAL_ENV"]
Returns:

a path to a virtualenv (for $VIRTUAL_ENV)

Return type:

str

aliases

Returns: OrderedDict: self.env.aliases

configure_sys()[source]
Returns:sys.path list from _configure_sys.
Return type:list
classmethod workon(env=None, VENVSTR=None, VENVSTRAPP=None, **kwargs)[source]
Parameters:
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) – e.g. dotfiles or dotfiles/docs
  • kwargs (dict) – kwargs to pass to Venv (see Venv.__init__)
Returns:

an intialized Venv

Return type:

Venv

configure_ipython(*args, **kwargs)[source]

Configure IPython with Venv._configure_ipython and user_aliases from self.aliases.items().

Parameters:
  • args (list) – args for Venv._configure_ipython
  • kwargs (dict) – kwargs for Venv._configure_ipython.
generate_vars_env(**kwargs)[source]

Generate a string containing VARIABLE=’./value’

generate_bash_env(shell_keyword='export ', shell_quotefunc=<function shell_quote>, include_paths=True, include_aliases=True, include_cdaliases=False, **kwargs)[source]

Generate a source-able script for the environment variables, aliases, and functions defined by the current Venv.

Keyword Arguments:
 
  • shell_keyword (str) – shell variable def (default: “export “)
  • include_paths (bool) – Include environ vars in output (default: True)
  • include_aliases (bool) – Include aliases in output (default: True)
  • include_cdaliases (bool) – Include cdaliases in output (default: False)
  • compress_paths (bool) – Compress paths to $VAR (default=False)
Yields:

str – block of bash script

generate_bash_cdalias()[source]

Generate a source-able script for cdalias functions

Yields:str – block of bash script
generate_vim_cdalias()[source]

Generate a source-able vimscript for vim

Yields:str – block of vim script
generate_venv_ipymagics()[source]

Generate an venv_ipymagics.py file for IPython

Yields:str – block of Python code
project_files
PROJECT_FILES
system(cmd=None)[source]

Call os.system with the given command string

Parameters:

cmd (string) – command string to call os.system with

Raises:
  • Exception – if cmd is None
  • NotImplementedError – if cmd is a tuple
open_editors()[source]

Run self._edit_project_cmd

open_terminals()[source]

Run self._open_terminals_cmd

to_dict()[source]
Returns:OrderedDict(env=self.env, aliases=self.aliases)
Return type:OrderedDict
to_json(indent=None)[source]
Parameters:indent (int) – number of spaces with which to indent JSON output
Returns:json.dumps(self.to_dict())
Return type:str
static update_os_environ(venv, environ=None)[source]

Update os.environ for the given venv

Parameters:environ (dict) – if None, defaults to os.environ
Returns:updated environ dict
Return type:dict
call(command)[source]
Parameters:command (str) – command to run
Returns:output from subprocess.call
Return type:str
dotfiles.venv.ipython_config.get_IPYTHON_ALIAS_DEFAULTS(platform=None)[source]
dotfiles.venv.ipython_config.get_IPYTHON_ALIAS_OVERLAY()[source]
dotfiles.venv.ipython_config.get_USRLOG_ALIAS_OVERLAY()[source]
dotfiles.venv.ipython_config.ipython_main()[source]

Configure IPython with Venv :py:method:`configure_ipython` (:py:method:`_configure_ipython`).

dotfiles.venv.ipython_config.ipython_imports()[source]

Default imports for IPython (currently unused)

class dotfiles.venv.ipython_config.VenvTestUtils[source]

Bases: object

Test fixtures for TestCases and examples

static build_env_test_fixture(env=None)[source]
static capture_io(f)[source]

Add stdout and sterr kwargs to a function call and return (output, _stdout, _stderr)

class dotfiles.venv.ipython_config.VenvTestCase[source]

Bases: object

unittest.TestCase or object

class dotfiles.venv.ipython_config.Test_001_lookup(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

test_100_lookup()[source]
class dotfiles.venv.ipython_config.Test_100_Env(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

test_010_Env()[source]
test_020_Env_copy()[source]
test_Env_from_environ()[source]
class dotfiles.venv.ipython_config.Test_200_StepBuilder(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

test_000_Step()[source]
test_500_StepBuilder()[source]
test_600_StepBuilder()[source]
class dotfiles.venv.ipython_config.Test_250_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv_test_fixture()[source]
test_010_assert_venv_requires_VENVPREFIX__or__VIRTUAL_ENV()[source]
test_100_Venv_parse_VENVSTR_env__and__VENVSTR()[source]
test_110_Venv_parse_VENVSTR_VENVSTR()[source]
test_120_Venv_parse_VENVSTR_VENVSTR_VENVSTRAPP()[source]
class dotfiles.venv.ipython_config.Test_300_venv_build_env(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

test each build step independently

kwargs = {}
env = env.copy()
buildfunc = build_virtualenvwrapper_env
new_env = buildfunc(env=env, **kwargs)
setUp()[source]

Hook method for setting up the test fixture before exercising it.

static print_(self, *args, **kwargs)[source]
test_100_build_dotfiles_env()[source]
test_200_build_usrlog_env()[source]
test_400_build_virtualenvwrapper_env()[source]
test_500_build_conda_env()[source]
test_600_build_conda_cfg_env()[source]
test_600_build_venv_paths_full_env__prefix_None()[source]
test_610_build_venv_paths_full_env__prefix_root()[source]
test_620_build_venv_paths_full_env__prefix_None()[source]
test_650_build_venv_paths_cdalias_env()[source]
class dotfiles.venv.ipython_config.Test_500_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv()[source]
test_005_venv()[source]
test_010_venv__APP()[source]
test_011_venv__APP()[source]
test_020_venv_from_null_environ()[source]
test_030_venv_without_environ()[source]
test_050_venv__VENVSTR__WORKON_HOME()[source]
class dotfiles.venv.ipython_config.Test_900_Venv_main(methodName='runTest')[source]

Bases: dotfiles.venv.ipython_config.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_001_main_null()[source]
test_100_main()[source]
test_110_main_VENVSTR()[source]
test_120_main_print_bash_VENVSTR()[source]
test_130_main_print_bash_VENVSTR_VENVSTRAPP()[source]
test_140_main_VENVSTR_WORKON_HOME()[source]
test_200_main_print_bash_VENVSTR__APP()[source]
test_200_main_print_bash()[source]
test_210_main_print_bash_aliases()[source]
test_220_main_print_bash_cdaliases()[source]
test_300_main_print_zsh()[source]
test_400_main_print_vim()[source]
dotfiles.venv.ipython_config.build_venv_arg_parser()[source]
Returns:options for the commandline interface
Return type:optparse.OptionParser
dotfiles.venv.ipython_config.comment_comment(strblock, **kwargs)[source]
Parameters:strblock (str) – string block (possibly containing newlines)
Keyword Arguments:
 kwargs (dict) – kwargs for prepend_comment_char
Returns:string with each line prefixed with comment char
Return type:str
dotfiles.venv.ipython_config.main(*argv, **kwargs)[source]

main function called if __name__=="__main__"

Returns:nonzero on error
Return type:int

dotfiles.venv.ipython_magics module

dotfiles.venv.ipython_magics.magics_class(cls, *args, **kwargs)
dotfiles.venv.ipython_magics.line_magic(func, *args, **kwargs)
class dotfiles.venv.ipython_magics.VenvMagics[source]

Bases: object

cd(envvar, line)[source]

Change directory

Parameters:
  • envvar (str) – os.environ variable name
  • line (str) – path to append to envvar
cdhome(line)[source]

cdhome – cd $HOME/${@}

cdh(line)[source]

cdh – cd $HOME/${@}

cdwrk(line)[source]

cdwrk – cd $__WRK/${@}

cddotfiles(line)[source]

cddotfiles – cd $__DOTFILES/${@}

cdd(line)[source]

cdd – cd $__DOTFILES/${@}

cdprojecthome(line)[source]

cdprojecthome – cd $PROJECT_HOME/${@}

cdp(line)[source]

cdp – cd $PROJECT_HOME/${@}

cdph(line)[source]

cdph – cd $PROJECT_HOME/${@}

cdworkonhome(line)[source]

cdworkonhome – cd $WORKON_HOME/${@}

cdwh(line)[source]

cdwh – cd $WORKON_HOME/${@}

cdve(line)[source]

cdve – cd $WORKON_HOME/${@}

cdcondaenvspath(line)[source]

cdcondaenvspath – cd $CONDA_ENVS_PATH/${@}

cda(line)[source]

cda – cd $CONDA_ENVS_PATH/${@}

cdce(line)[source]

cdce – cd $CONDA_ENVS_PATH/${@}

cdvirtualenv(line)[source]

cdvirtualenv – cd $VIRTUAL_ENV/${@}

cdv(line)[source]

cdv – cd $VIRTUAL_ENV/${@}

cdsrc(line)[source]

cdsrc – cd $_SRC/${@}

cds(line)[source]

cds – cd $_SRC/${@}

cdwrd(line)[source]

cdwrd – cd $_WRD/${@}

cdw(line)[source]

cdw – cd $_WRD/${@}

cdbin(line)[source]

cdbin – cd $_BIN/${@}

cdb(line)[source]

cdb – cd $_BIN/${@}

cdetc(line)[source]

cdetc – cd $_ETC/${@}

cde(line)[source]

cde – cd $_ETC/${@}

cdlib(line)[source]

cdlib – cd $_LIB/${@}

cdl(line)[source]

cdl – cd $_LIB/${@}

cdlog(line)[source]

cdlog – cd $_LOG/${@}

cdpylib(line)[source]

cdpylib – cd $_PYLIB/${@}

cdpysite(line)[source]

cdpysite – cd $_PYSITE/${@}

cdsitepackages(line)[source]

cdsitepackages – cd $_PYSITE/${@}

cdvar(line)[source]

cdvar – cd $_VAR/${@}

cdwww(line)[source]

cdwww – cd $_WWW/${@}

cdww(line)[source]

cdww – cd $_WWW/${@}

cdhelp(line)[source]

cdhelp() – list cd commands

dotfiles_status(line)[source]

dotfiles_status() – print dotfiles_status() .

ds(line)[source]

ds() – print dotfiles_status() .

dotfiles_reload(line)[source]

dotfiles_reload() – print NotImplemented

dr(line)[source]

dr() – print NotImplemented [dotfiles_reload()]

dotfiles.venv.ipython_magics.main()[source]

Register VenvMagics with IPython

dotfiles.venv.venv module

dotfiles.venv.venv.in_venv_ipyconfig()[source]
Returns:True if get_ipython is in globals()
Return type:bool
dotfiles.venv.venv.logevent(event, obj=None, logger=<Logger venv (WARNING)>, level=10, func=None, lineno=None, modpath=None, show_modpath=None, wrap=False, splitlines=True)[source]
Parameters:
  • event (str) – an event key
  • obj (thing) – thing to serialize and log
  • logger (logging.Logger) – logger to log to
  • level (int) – logging loglevel to log (event, obj)
  • wrap (bool) – Add header and footer <event> tags (default: False)
  • splitlines (bool) – split by newlines and emit one log message per line
Returns:

(event:str, output:str)

Return type:

tuple

exception dotfiles.venv.venv.ConfigException[source]

Bases: Exception

exception dotfiles.venv.venv.StepException[source]

Bases: Exception

exception dotfiles.venv.venv.StepConfigException[source]

Bases: dotfiles.venv.venv.StepException, dotfiles.venv.venv.ConfigException

dotfiles.venv.venv.prepend_comment_char(strblock, commentchar='##')[source]
Parameters:
  • strblock (str) – string to split by newlines and prepend
  • prefix (str) – comment string prefix (one space will be added)
Yields:

str – lines prefixed with prefix

dotfiles.venv.venv.get_pyver(pyverstr=None)[source]
Parameters:pyver (str) – “major.minor” e.g. 2.7 or 3.4 (default: sys.version_info[:2])
Returns:python2.7, python.34
Return type:str
dotfiles.venv.venv.get___WRK_default(env=None, **kwargs)[source]
dotfiles.venv.venv.get_WORKON_HOME_default(env=None, from_environ=False, default='-ve27', **kwargs)[source]
Keyword Arguments:
 
  • env (dict) – Env dict to read from (default: None)
  • from_environ (bool) – read WORKON_HOME from os.environ
  • default (str) – default WORKON_HOME dirname
  • __WRK (str) –
Returns:

path to a WORKON_HOME directory

Return type:

str

class dotfiles.venv.venv.VenvJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class dotfiles.venv.venv.CmdAlias(cmdstr)[source]

Bases: object

to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:self.cmdstr (AS-IS)
Return type:str
to_ipython_alias()[source]

Generate an alias for IPython

Returns:self.cmdstr (AS-IS)
Return type:str
class dotfiles.venv.venv.IpyAlias(cmdstr, name=None, complfuncstr=None)[source]

Bases: dotfiles.venv.venv.CmdAlias

An IPython alias command string which expands to a shell function aliasname() { ... } and handles positional args %s and %l

References

  • TODO: IPython docs
to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:an alias or a function()
alias name=repr(cmdstr)
# or
cmdname () {
    cmdstr
}
Return type:str
class dotfiles.venv.venv.CdAlias(pathvar, name=None, aliases=None)[source]

Bases: dotfiles.venv.venv.CmdAlias

A CmdAlias for cd change directory functions with venv paths (e.g. $_WRD) for Bash, ZSH, IPython, Vim.

  • venv.sh bash functions with tab-completion (cdwrd, cdw, cdw<tab>)
  • venv_ipymagics.py: ipython magics (%cdwrd, cdwrd, cdw)
  • venv.vim: vim functions (:Cdwrd)
VENV_IPYMAGICS_FILE_HEADER = '\n#!/usr/bin/env ipython\n# dotfiles.venv.venv_ipymagics\nfrom __future__ import print_function\n"""\nIPython ``%magic`` commands\n\n* ``cd`` aliases\n* ``ds`` (``dotfiles_status``)\n* ``dr`` (``dotfiles_reload``)\n\nInstallation\n--------------\n.. code-block:: bash\n\n __DOTFILES="${HOME}/-dotfiles"\n ipython_profile="profile_default"\n ln -s ${__DOTFILES}/etc/ipython/venv_ipymagics.py \\\n ~/.ipython/${ipython_profile}/startup/venv_ipymagics.py\n"""\nimport os\nimport sys\ntry:\n from IPython.core.magic import (Magics, magics_class, line_magic)\nexcept ImportError:\n print("ImportError: IPython")\n # Mock IPython for building docs\n Magics = object\n magics_class = lambda cls, *args, **kwargs: cls\n line_magic = lambda func, *args, **kwargs: func\n\nif sys.version_info.major == 2:\n str = unicode\n\ndef ipymagic_quote(_str):\n return str(_str)\n\n@magics_class\nclass VenvMagics(Magics):\n def cd(self, envvar, line):\n """\n Change directory\n\n Args:\n envvar (str): os.environ variable name\n line (str): path to append to envvar\n """\n prefix = os.environ.get(envvar, "")\n _dstpath = line.lstrip(os.path.sep)\n path = os.path.join(prefix, _dstpath)\n cmd = ("cd %s" % ipymagic_quote(path))\n print("%" + cmd, file=sys.stderr)\n return self.shell.magic(cmd)'
VENV_IPYMAGIC_METHOD_TEMPLATE = '\n @line_magic\n def {ipy_func_name}(self, line):\n """{ipy_func_name} -- cd ${pathvar}/${{@}}"""\n return self.cd(\'{pathvar}\', line)'
to_ipython_method()[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:ipython method block
Return type:str
VIM_HEADER_TEMPLATE = '\n" ### venv.vim\n" # Src: https://github.com/westurner/venv.vim\n\n" "g:venv_list_only_dirs -- 1 -- 0 to list files in Cd* commands\n\nlet g:venv_list_only_dirs = 1\n\nfunction! Cd_help()\n" :Cdhelp -- list venv.vim cdalias commands\n :verbose command Cd\nendfunction\ncommand! -nargs=0 Cdhelp call Cd_help()\n\nfunction! ListDirsOrFiles(path, ArgLead, ...)\n let dirsonly = ((a:0>0) ? 1 : g:venv_list_only_dirs)\n let _glob = \'\' . a:ArgLead . ((g:venv_list_only_dirs>1) ? \'*/\' : \'*\')\n execute \'lcd\' a:path\n if dirsonly ==? 1\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:]\')\n elseif dirsonly ==? 0\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:] . (isdirectory(v:val) ? "/" : "")\')\n endif\n execute \'lcd -\'\n return output\nendfunction\n\nfunction! Cdhere(...)\n" :Cdhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n" :CDhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'cd\' _path\n pwd\nendfunction\nfunction! Compl_Cdhere(ArgLead, ...)\n return ListDirsOrFiles(expand(\'%:p:h\'), a:ArgLead, 1)\nendfor\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Cdhere call Cdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere CDhere call Cdhere(<f-args>)\n\nfunction! Lcdhere(...)\n" :Lcdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n" :LCdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'lcd\' _path\n pwd\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Lcdhere call Lcdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere LCdhere call Lcdhere(<f-args>)\n\n\nfunction! Cd___VAR_(varname, cmd, ...)\n" Cd___VAR_() -- cd expand(\'$\' . a:varname)/$1\n let _VARNAME = a:varname\n let _VAR_=expand(_VARNAME)\n if _VARNAME ==? _VAR_\n echoerr _VARNAME . " is not set"\n return\n endif\n let pathname = join([_VAR_, (a:0>0) ? a:1 : ""], "/")\n execute a:cmd pathname\n pwd\nendfunction\n\n'
VIM_CD_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- cd ${pathvar}/$1\n call Cd___VAR_(\'${pathvar}\', \'{vim_cd_func}\', (a:0>0)? a:1 : "")\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 1)\nendfunction\n'
VIM_CD_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- cd ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
VIM_EDIT_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- e ${pathvar}/$1\n let _path=expand("${pathvar}") . ((a:0>0)? "/" . a:1 : "")\n execute \'{vim_edit_func}\' _path\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 0)\nendfunction\n'
VIM_EDIT_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- e ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
vim_cmd_name

Returns: str: e.g “Cdwrd”

vim_cmd_names

Returns: list: self.vim_cmd_name + self.aliases.title()

to_vim_function()[source]
Returns:vim function block
Return type:str
BASH_CDALIAS_HEADER = '#!/bin/sh\n## venv.sh\n# generated from $(venv --print-bash --prefix=/)\n\n'
BASH_FUNCTION_TEMPLATE = '{bash_func_name} () {{\n # {bash_func_name:16} -- cd ${pathvar} /$@\n [ -z "${pathvar}" ] && echo "{pathvar} is not set" && return 1\n cd "${pathvar}"${{@:+"/${{@}}"}}\n}}\n{bash_compl_name} () {{\n local cur="$2";\n COMPREPLY=($({bash_func_name} && compgen -d -- "${{cur}}" ))\n}}\n'
BASH_ALIAS_TEMPLATE = '{cmd_name} () {{\n # {cmd_name:16} -- cd ${pathvar}\n {bash_func_name} $@\n}}\n'
BASH_COMPLETION_TEMPLATE = 'complete -o default -o nospace -F {bash_compl_name} {cmd_name}\n'
bash_func_name

Returns: str: e.g. “cdwrd”

bash_func_names

Returns: list: self.bash_func_name + self.aliases

to_bash_function(include_completions=True)[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:bash function block
Return type:str
to_shell_str()[source]
Returns:eval ‘{_to_bash_function()}’
Return type:str
class dotfiles.venv.venv.Step(func=None, **kwargs)[source]

Bases: object

A build task step which builds or transforms an Env, by calling step.build(env=env, **step.conf)

name

Returns: str: a name for this Step

asdict()[source]
Returns:OrderedDict(self._iteritems())
Return type:OrderedDict
build_print_kwargs_env(env=None, **kwargs)[source]

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

DEFAULT_FUNC(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

build(env=None, **kwargs)[source]

Call self.func(env=env, **self.conf.copy().update(**kwargs))

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

self.func(env=env, **self.conf.copy().update(**kwargs))

Return type:

obj

class dotfiles.venv.venv.PrintEnvStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.venv.Step

Print env and kwargs to stdout

stdout = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
stderr = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

class dotfiles.venv.venv.PrintEnvStderrStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.venv.PrintEnvStep

Print env and kwargs to stderr

stdout = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
class dotfiles.venv.venv.StepBuilder(**kwargs)[source]

Bases: object

A class for building a sequence of steps which modify env

name
debug

Returns: str: self.conf.get(‘debug’)

show_diffs

Returns: str: self.conf.get(‘show_diffs’)

add_step(func, **kwargs)[source]

Add a step to self.steps

Parameters:
  • func (Step or function or str) – func(env=None, **kwargs)
  • kwargs (dict) – kwargs for Step.conf
Keyword Arguments:
 

name (str) – function name (default: None)

Returns:

Step object appended to self.steps

Return type:

Step

build_iter(env=None, show_diffs=True, debug=False)[source]

Build a generator of (Step, Env) tuples from the functional composition of StepBuilder.steps given an initial Env (or None).

# pseudocode
env_previous = Env()
for step in self.steps:
    (step, env) = step.build(env=env_previous.copy(),**conf)
    env_previous=env
Keyword Arguments:
 
  • env (Env) – initial Env (default: None)
  • show_diffs (bool) – show difflib.ndiffs of Envs between steps
  • debug (bool) –
Yields:

tuple – (Step, Env)

build(*args, **kwargs)[source]

Build a list of Envs from self.build_iter(*args, **kwargs) and return the last Env.

Keyword Arguments:
 debug (bool) – log.debug(env)
Returns:the last env returned from .build_iter
Return type:Env or None
dotfiles.venv.venv.lookup_from_kwargs_env(kwargs, env, attr, default=None)[source]

__getitem__ from kwargs, env, or default.

Parameters:
  • kwargs (dict) – kwargs dict
  • env (Env) – Env dict
  • attr (str) – attribute name
  • default (obj) – default value to return if not found in kwargs or env
Returns:

kwargs.get(attr, env.get(attr, default))

Return type:

obj

dotfiles.venv.venv.build_dotfiles_env(env=None, **kwargs)[source]

Configure dotfiles base environment (HOME, __WRK, __SRC, __DOTFILES)

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • HOME (str) – home path ($HOME, ~)
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • __SRC (str) – path to source repos ($__WRK/-src)
  • __DOTFILES (str) – current dotfiles path (~/-dotfiles)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • HOME
  • __WRK
  • __SRC
  • __DOTFILES

Return type:

env (Env dict)

dotfiles.venv.venv.build_virtualenvwrapper_env(env=None, **kwargs)[source]

Set WORKON_HOME to WORKON_HOME or WORKON_HOME_DEFAULT

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • WORKON_HOME_DEFAULT (str) – variable name (default: WORKON_HOME__py27)
  • WORKON_HOME__* (str) – path to a WORKON_HOME set
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • WORKON_HOME__py27=’${__WRK}/-ve27’
  • WORKON_HOME__py34=’${__WRK}/-ve34’
  • WORKON_HOME__*=kwargs.get(WORKON_HOME__*)
  • WORKON_HOME_DEFAULT=’WORKON_HOME_py27’

Return type:

env (Env dict)

dotfiles.venv.venv.build_conda_env(env=None, **kwargs)[source]

Configure conda27 (2.7) and conda (3.4) with condaenvs in -wrk/-ce27 and -wrk/ce34.

Other Parameters:
 
  • __WRK (str) – workspace root ($__WRK, ~/-wrk)
  • CONDA_ROOT__py27 (str) – path to conda27 root environment
  • CONDA_ENVS__py27 (str) – path to conda27 envs (e.g. WORKON_HOME)
  • CONDA_ROOT__py34 (str) – path to conda34 root environment
  • CONDA_ENVS__py34 (str) – path to conda34 envs (e.g. WORKON_HOME)
Keyword Arguments:
 

env (Env dict) – dotfiles.venv.venv_ipyconfig.Env

Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

dotfiles.venv.venv.build_conda_cfg_env(env=None, **kwargs)[source]

Configure conda for a specific environment TODO build_venv_config

Parameters:env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
Returns:dotfiles.venv.venv_ipyconfig.Env
Return type:env (Env dict)
dotfiles.venv.venv.build_venv_paths_full_env(env=None, pyver=None, **kwargs)[source]

Set variables for standard paths in the environment

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env (default: None (Env()))
  • VENVPREFIX (str) – venv prefix path (default: None (VIRTUAL_ENV))
  • VENVSTR (str) – name of a VIRTUAL_ENV in WORKON_HOME or path to a VIRTUAL_ENV (default: None)
  • VIRTUAL_ENV (str) – path to a VIRTUAL_ENV (default: None)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Raises:

StepConfigException – When not any(( VIRTUAL_ENV, VENVPREFIX, VENVSTR, VENVSTRAPP))

References

dotfiles.venv.venv.build_venv_paths_cdalias_env(env=None, **kwargs)[source]

Build CdAliases for standard paths

Keyword Arguments:
 env (Env dict) – Env
Returns:Env with .aliases extended.
Return type:env (Env dict)

Note

These do not work in IPython as they run in a subshell. See: dotfiles.venv.venv_ipymagics.

dotfiles.venv.venv.build_user_aliases_env(env=None, dont_reflect=False, VIRTUAL_ENV=None, _SRC=None, _ETC=None, _CFG=None, PROJECT_FILES=None, **kwargs)[source]

Configure env variables and return an OrderedDict of aliases

Parameters:dont_reflect (bool) – Whether to always create aliases and functions referencing $_WRD even if $_WRD doesn’t exist. (default: False)
Returns:dict of aliases
Return type:OrderedDict
dotfiles.venv.venv.build_usrlog_env(env=None, _TERM_ID=None, shell='bash', prefix=None, USER=None, HOSTNAME=None, lookup_hostname=False, **kwargs)[source]

Build environment variables and configuration like usrlog.sh

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • _TERM_ID (str) – terminal identifier string
  • shell (str) – shell name (“bash”, “zsh”)
  • prefix (str) – a path prefix (e.g. $VIRTUAL_ENV or $PREFIX)
  • USER (str) – system username ($USER) for HISTTIMEFORMAT
  • HOSTNAME (str) – system hostname (HOSTNAME) for HISTTIMEFORMAT
  • lookup_hostname (bool) – if True, HOSTNAME is None, and not env.get(‘HOSTNAME’), try to read HOSTNAME from os.environ and then socket.gethostname().
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Note

Like usrlog.sh, when HISTTIMEFORMAT is set, USER and HOSTNAME must be evaluated.

(When USER and HOSTNAME change, HISTTIMEFORMAT is not updated, and the .history file will contain only the most recent USER and HOSTNAME settings, which are not necessarily the actual USER and HOSTNAME.)

TODO: could/should instead (also) write USER and HOSTNAME to -usrlog.log.

dotfiles.venv.venv.build_venv_activate_env(env=None, VENVSTR=None, VENVSTRAPP=None, from_environ=False, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, **kwargs)[source]
class dotfiles.venv.venv.Env(*args, **kwargs)[source]

Bases: object

OrderedDict of variables for/from os.environ.

osenviron_keys_classic = ('VIMBIN', 'GVIMBIN', 'MVIMBIN', 'GUIVIMBIN', 'VIMCONF', 'EDITOR', 'EDITOR_', 'PAGER', '__WRK', '__DOTFILES', 'PROJECT_HOME', 'WORKON_HOME', 'WORKON_HOME__py27', 'WORKON_HOME__py34', 'VENVPREFIX', 'VENVSTR', 'VENVSTRAPP', '_APP', 'VIRTUAL_ENV_NAME', 'VIRTUAL_ENV', '_SRC', '_ETC', '_BIN', '_CFG', '_LIB', '_LOG', '_MNT', '_OPT', '_PYLIB', '_PYSITE', '_SRV', '_VAR', '_WRD', '_WRD_SETUPY', '_WWW', '__SRC', '__DOCSWWW', '_USRLOG', '__USRLOG', '_TERM_ID', '_TERM_URI')
osenviron_keys = {'CONDA_ENVS_PATH': '${__WRK}/-ce27', 'CONDA_ENVS__py27': '${__WRK}/-ce27', 'CONDA_ENVS__py34': '${__WRK}/-ce34', 'CONDA_ENVS__py35': '${__WRK}/-ce35', 'CONDA_ENVS__py36': '${__WRK}/-ce36', 'CONDA_ENVS__py37': '${__WRK}/-ce37', 'CONDA_ROOT': '${__WRK}/-conda27', 'CONDA_ROOT__py27': '${__WRK}/-conda27', 'CONDA_ROOT__py34': '${__WRK}/-conda34', 'CONDA_ROOT__py35': '${__WRK}/-conda35', 'CONDA_ROOT__py36': '${__WRK}/-conda36', 'CONDA_ROOT__py37': '${__WRK}/-conda37', 'PROJECT_HOME': '${__WRK}', 'VENVPREFIX': '${VIRTUAL_ENV}', 'VENVSTR': 'dotfiles', 'VENVSTRAPP': 'dotfiles', 'VIRTUAL_ENV': '${WORKON_HOME}/${VIRTUAL_ENV_NAME}', 'VIRTUAL_ENV_NAME': 'dotfiles', 'WORKON_HOME': '${__WRK}/-ve27', 'WORKON_HOME_DEFAULT': 'WORKON_HOME__py37', 'WORKON_HOME__py27': '${__WRK}/-ve27', 'WORKON_HOME__py34': '${__WRK}/-ve34', 'WORKON_HOME__py35': '${__WRK}/-ve35', 'WORKON_HOME__py36': '${__WRK}/-ve36', 'WORKON_HOME__py37': '${__WRK}/-ve37', '_APP': 'dotfiles', '_BIN': '${VIRTUAL_ENV}/bin', '_ETC': '${VIRTUAL_ENV}/etc', '_ETCOPT': '${_ETC}/opt', '_HOME': '${VIRTUAL_ENV}/home', '_LIB': '${VIRTUAL_ENV}/lib', '_LOG': '${_VAR}/log', '_MEDIA': '${VIRTUAL_ENV}/media', '_MNT': '${VIRTUAL_ENV}/mnt', '_OPT': '${VIRTUAL_ENV}/opt', '_PYLIB': '${_LIB}/python2.7', '_PYSITE': '${_PYLIB}/site-packages', '_ROOT': '${VIRTUAL_ENV}/root', '_SBIN': '${VIRTUAL_ENV}/sbin', '_SRC': '${VIRTUAL_ENV}/src', '_SRV': '${VIRTUAL_ENV}/srv', '_TMP': '${VIRTUAL_ENV}/tmp', '_USR': '${VIRTUAL_ENV}/usr', '_USRBIN': '${VIRTUAL_ENV}/usr/bin', '_USRINCLUDE': '${VIRTUAL_ENV}/usr/include', '_USRLIB': '${VIRTUAL_ENV}/usr/lib', '_USRLOCAL': '${VIRTUAL_ENV}/usr/local', '_USRLOCALBIN': '${VIRTUAL_ENV}/usr/local/bin', '_USRSBIN': '${VIRTUAL_ENV}/usr/sbin', '_USRSHARE': '${VIRTUAL_ENV}/usr/share', '_USRSRC': '${VIRTUAL_ENV}/usr/src', '_VAR': '${VIRTUAL_ENV}/var', '_VARCACHE': '${_VAR}/cache', '_VARLIB': '${_VAR}/lib', '_VARLOCK': '${_VAR}/lock', '_VARMAIL': '${_VAR}/mail', '_VAROPT': '${_VAR}/opt', '_VARRUN': '${_VAR}/run', '_VARSPOOL': '${_VAR}/spool', '_VARTMP': '${_VAR}/tmp', '_WRD': '${_SRC}/dotfiles', '_WWW': '${_VAR}/www', '__DOTFILES': '${HOME}/-dotfiles', '__SRC': '${__WRK}/-src', '__WRK': '${HOME}/-wrk'}
name
logevent(*args, **kwargs)[source]
iterkeys()[source]
iteritems_environ()[source]
iteritems()[source]
get(k, default=None)[source]
copy()[source]
classmethod from_environ(environ, verbose=False)[source]

Build an Env from a dict (e.g. os.environ)

Parameters:
  • environ (dict) – a dict with variable name keys and values
  • verbose (bool) – whether to be verbose about dict merging
Returns:

an Env environment built from the given environ dict

Return type:

Env

compress_paths(path_, keys=None, keyname=None)[source]

Given an arbitrary string, replace absolute paths (starting with ‘/’) with the longest matching Env path variables.

Parameters:path (str) – a path string
Returns:path string containing ${VARNAME} variables
Return type:str
to_string_iter(**kwargs)[source]
ndiff(other_env)[source]
Parameters:other_env (Env) – env to compare with
Returns:strings from difflib.ndiff
Return type:iterable
to_dict()[source]
to_json(*args, **kwargs)[source]
dotfiles.venv.venv.shell_quote(var)[source]

Escape single quotes and add double quotes around a given variable.

Parameters:_str (str) – string to add quotes to
Returns:string wrapped in quotes
Return type:str

Warning

This is not safe for untrusted input and only valid in this context (os.environ).

dotfiles.venv.venv.shell_varquote(str_)[source]

Add doublequotes and shell variable brackets to a string

Parameters:str (str) – string to varquote (e.g. VIRTUAL_ENV)
Returns:“${VIRTUAL_ENV}”
Return type:str
class dotfiles.venv.venv.Venv(VENVSTR=None, VENVSTRAPP=None, _Venv__WRK=None, _Venv__DOTFILES=None, WORKON_HOME=None, VIRTUAL_ENV_NAME=None, VENVPREFIX=None, VIRTUAL_ENV=None, _SRC=None, _APP=None, _WRD=None, env=None, from_environ=False, open_editors=False, open_terminals=False, dont_reflect=True, debug=False, show_diffs=False, **kwargs)[source]

Bases: object

A virtual environment configuration generator

build(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, from_environ=False, dont_reflect=True, debug=False, show_diffs=False, build_user_aliases=False, build_userlog_env=False)[source]

Build Venv Steps with StepBuilder

static parse_VENVSTR(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, _Venv__WRK=None, WORKON_HOME=None, from_environ=False, **kwargs)[source]

Get the path to a virtualenv given a VENVSTR

Keyword Arguments:
 
  • env (Env) –
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) –
  • VENVPREFIX (str) –
  • WORKON_HOME (str) –
  • from_environ (bool) – whether to try and read from os.environ["VIRTUAL_ENV"]
Returns:

a path to a virtualenv (for $VIRTUAL_ENV)

Return type:

str

aliases

Returns: OrderedDict: self.env.aliases

configure_sys()[source]
Returns:sys.path list from _configure_sys.
Return type:list
classmethod workon(env=None, VENVSTR=None, VENVSTRAPP=None, **kwargs)[source]
Parameters:
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) – e.g. dotfiles or dotfiles/docs
  • kwargs (dict) – kwargs to pass to Venv (see Venv.__init__)
Returns:

an intialized Venv

Return type:

Venv

configure_ipython(*args, **kwargs)[source]

Configure IPython with Venv._configure_ipython and user_aliases from self.aliases.items().

Parameters:
  • args (list) – args for Venv._configure_ipython
  • kwargs (dict) – kwargs for Venv._configure_ipython.
generate_vars_env(**kwargs)[source]

Generate a string containing VARIABLE=’./value’

generate_bash_env(shell_keyword='export ', shell_quotefunc=<function shell_quote>, include_paths=True, include_aliases=True, include_cdaliases=False, **kwargs)[source]

Generate a source-able script for the environment variables, aliases, and functions defined by the current Venv.

Keyword Arguments:
 
  • shell_keyword (str) – shell variable def (default: “export “)
  • include_paths (bool) – Include environ vars in output (default: True)
  • include_aliases (bool) – Include aliases in output (default: True)
  • include_cdaliases (bool) – Include cdaliases in output (default: False)
  • compress_paths (bool) – Compress paths to $VAR (default=False)
Yields:

str – block of bash script

generate_bash_cdalias()[source]

Generate a source-able script for cdalias functions

Yields:str – block of bash script
generate_vim_cdalias()[source]

Generate a source-able vimscript for vim

Yields:str – block of vim script
generate_venv_ipymagics()[source]

Generate an venv_ipymagics.py file for IPython

Yields:str – block of Python code
project_files
PROJECT_FILES
system(cmd=None)[source]

Call os.system with the given command string

Parameters:

cmd (string) – command string to call os.system with

Raises:
  • Exception – if cmd is None
  • NotImplementedError – if cmd is a tuple
open_editors()[source]

Run self._edit_project_cmd

open_terminals()[source]

Run self._open_terminals_cmd

to_dict()[source]
Returns:OrderedDict(env=self.env, aliases=self.aliases)
Return type:OrderedDict
to_json(indent=None)[source]
Parameters:indent (int) – number of spaces with which to indent JSON output
Returns:json.dumps(self.to_dict())
Return type:str
static update_os_environ(venv, environ=None)[source]

Update os.environ for the given venv

Parameters:environ (dict) – if None, defaults to os.environ
Returns:updated environ dict
Return type:dict
call(command)[source]
Parameters:command (str) – command to run
Returns:output from subprocess.call
Return type:str
dotfiles.venv.venv.get_IPYTHON_ALIAS_DEFAULTS(platform=None)[source]
dotfiles.venv.venv.get_IPYTHON_ALIAS_OVERLAY()[source]
dotfiles.venv.venv.get_USRLOG_ALIAS_OVERLAY()[source]
dotfiles.venv.venv.ipython_main()[source]

Configure IPython with Venv :py:method:`configure_ipython` (:py:method:`_configure_ipython`).

dotfiles.venv.venv.ipython_imports()[source]

Default imports for IPython (currently unused)

class dotfiles.venv.venv.VenvTestUtils[source]

Bases: object

Test fixtures for TestCases and examples

static build_env_test_fixture(env=None)[source]
static capture_io(f)[source]

Add stdout and sterr kwargs to a function call and return (output, _stdout, _stderr)

class dotfiles.venv.venv.VenvTestCase[source]

Bases: object

unittest.TestCase or object

class dotfiles.venv.venv.Test_001_lookup(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

test_100_lookup()[source]
class dotfiles.venv.venv.Test_100_Env(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

test_010_Env()[source]
test_020_Env_copy()[source]
test_Env_from_environ()[source]
class dotfiles.venv.venv.Test_200_StepBuilder(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

test_000_Step()[source]
test_500_StepBuilder()[source]
test_600_StepBuilder()[source]
class dotfiles.venv.venv.Test_250_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv_test_fixture()[source]
test_010_assert_venv_requires_VENVPREFIX__or__VIRTUAL_ENV()[source]
test_100_Venv_parse_VENVSTR_env__and__VENVSTR()[source]
test_110_Venv_parse_VENVSTR_VENVSTR()[source]
test_120_Venv_parse_VENVSTR_VENVSTR_VENVSTRAPP()[source]
class dotfiles.venv.venv.Test_300_venv_build_env(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

test each build step independently

kwargs = {}
env = env.copy()
buildfunc = build_virtualenvwrapper_env
new_env = buildfunc(env=env, **kwargs)
setUp()[source]

Hook method for setting up the test fixture before exercising it.

static print_(self, *args, **kwargs)[source]
test_100_build_dotfiles_env()[source]
test_200_build_usrlog_env()[source]
test_400_build_virtualenvwrapper_env()[source]
test_500_build_conda_env()[source]
test_600_build_conda_cfg_env()[source]
test_600_build_venv_paths_full_env__prefix_None()[source]
test_610_build_venv_paths_full_env__prefix_root()[source]
test_620_build_venv_paths_full_env__prefix_None()[source]
test_650_build_venv_paths_cdalias_env()[source]
class dotfiles.venv.venv.Test_500_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv()[source]
test_005_venv()[source]
test_010_venv__APP()[source]
test_011_venv__APP()[source]
test_020_venv_from_null_environ()[source]
test_030_venv_without_environ()[source]
test_050_venv__VENVSTR__WORKON_HOME()[source]
class dotfiles.venv.venv.Test_900_Venv_main(methodName='runTest')[source]

Bases: dotfiles.venv.venv.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_001_main_null()[source]
test_100_main()[source]
test_110_main_VENVSTR()[source]
test_120_main_print_bash_VENVSTR()[source]
test_130_main_print_bash_VENVSTR_VENVSTRAPP()[source]
test_140_main_VENVSTR_WORKON_HOME()[source]
test_200_main_print_bash_VENVSTR__APP()[source]
test_200_main_print_bash()[source]
test_210_main_print_bash_aliases()[source]
test_220_main_print_bash_cdaliases()[source]
test_300_main_print_zsh()[source]
test_400_main_print_vim()[source]
dotfiles.venv.venv.build_venv_arg_parser()[source]
Returns:options for the commandline interface
Return type:optparse.OptionParser
dotfiles.venv.venv.comment_comment(strblock, **kwargs)[source]
Parameters:strblock (str) – string block (possibly containing newlines)
Keyword Arguments:
 kwargs (dict) – kwargs for prepend_comment_char
Returns:string with each line prefixed with comment char
Return type:str
dotfiles.venv.venv.main(*argv, **kwargs)[source]

main function called if __name__=="__main__"

Returns:nonzero on error
Return type:int

dotfiles.venv.venv_ipyconfig module

dotfiles.venv.venv_ipyconfig.in_venv_ipyconfig()[source]
Returns:True if get_ipython is in globals()
Return type:bool
dotfiles.venv.venv_ipyconfig.logevent(event, obj=None, logger=<Logger venv (WARNING)>, level=10, func=None, lineno=None, modpath=None, show_modpath=None, wrap=False, splitlines=True)[source]
Parameters:
  • event (str) – an event key
  • obj (thing) – thing to serialize and log
  • logger (logging.Logger) – logger to log to
  • level (int) – logging loglevel to log (event, obj)
  • wrap (bool) – Add header and footer <event> tags (default: False)
  • splitlines (bool) – split by newlines and emit one log message per line
Returns:

(event:str, output:str)

Return type:

tuple

exception dotfiles.venv.venv_ipyconfig.ConfigException[source]

Bases: Exception

exception dotfiles.venv.venv_ipyconfig.StepException[source]

Bases: Exception

exception dotfiles.venv.venv_ipyconfig.StepConfigException[source]

Bases: dotfiles.venv.venv_ipyconfig.StepException, dotfiles.venv.venv_ipyconfig.ConfigException

dotfiles.venv.venv_ipyconfig.prepend_comment_char(strblock, commentchar='##')[source]
Parameters:
  • strblock (str) – string to split by newlines and prepend
  • prefix (str) – comment string prefix (one space will be added)
Yields:

str – lines prefixed with prefix

dotfiles.venv.venv_ipyconfig.get_pyver(pyverstr=None)[source]
Parameters:pyver (str) – “major.minor” e.g. 2.7 or 3.4 (default: sys.version_info[:2])
Returns:python2.7, python.34
Return type:str
dotfiles.venv.venv_ipyconfig.get___WRK_default(env=None, **kwargs)[source]
dotfiles.venv.venv_ipyconfig.get_WORKON_HOME_default(env=None, from_environ=False, default='-ve27', **kwargs)[source]
Keyword Arguments:
 
  • env (dict) – Env dict to read from (default: None)
  • from_environ (bool) – read WORKON_HOME from os.environ
  • default (str) – default WORKON_HOME dirname
  • __WRK (str) –
Returns:

path to a WORKON_HOME directory

Return type:

str

class dotfiles.venv.venv_ipyconfig.VenvJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
class dotfiles.venv.venv_ipyconfig.CmdAlias(cmdstr)[source]

Bases: object

to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:self.cmdstr (AS-IS)
Return type:str
to_ipython_alias()[source]

Generate an alias for IPython

Returns:self.cmdstr (AS-IS)
Return type:str
class dotfiles.venv.venv_ipyconfig.IpyAlias(cmdstr, name=None, complfuncstr=None)[source]

Bases: dotfiles.venv.venv_ipyconfig.CmdAlias

An IPython alias command string which expands to a shell function aliasname() { ... } and handles positional args %s and %l

References

  • TODO: IPython docs
to_shell_str(name=None)[source]

Generate an alias or function for bash/zsh

Keyword Arguments:
 name (str) – funcname to override default
Returns:an alias or a function()
alias name=repr(cmdstr)
# or
cmdname () {
    cmdstr
}
Return type:str
class dotfiles.venv.venv_ipyconfig.CdAlias(pathvar, name=None, aliases=None)[source]

Bases: dotfiles.venv.venv_ipyconfig.CmdAlias

A CmdAlias for cd change directory functions with venv paths (e.g. $_WRD) for Bash, ZSH, IPython, Vim.

  • venv.sh bash functions with tab-completion (cdwrd, cdw, cdw<tab>)
  • venv_ipymagics.py: ipython magics (%cdwrd, cdwrd, cdw)
  • venv.vim: vim functions (:Cdwrd)
VENV_IPYMAGICS_FILE_HEADER = '\n#!/usr/bin/env ipython\n# dotfiles.venv.venv_ipymagics\nfrom __future__ import print_function\n"""\nIPython ``%magic`` commands\n\n* ``cd`` aliases\n* ``ds`` (``dotfiles_status``)\n* ``dr`` (``dotfiles_reload``)\n\nInstallation\n--------------\n.. code-block:: bash\n\n __DOTFILES="${HOME}/-dotfiles"\n ipython_profile="profile_default"\n ln -s ${__DOTFILES}/etc/ipython/venv_ipymagics.py \\\n ~/.ipython/${ipython_profile}/startup/venv_ipymagics.py\n"""\nimport os\nimport sys\ntry:\n from IPython.core.magic import (Magics, magics_class, line_magic)\nexcept ImportError:\n print("ImportError: IPython")\n # Mock IPython for building docs\n Magics = object\n magics_class = lambda cls, *args, **kwargs: cls\n line_magic = lambda func, *args, **kwargs: func\n\nif sys.version_info.major == 2:\n str = unicode\n\ndef ipymagic_quote(_str):\n return str(_str)\n\n@magics_class\nclass VenvMagics(Magics):\n def cd(self, envvar, line):\n """\n Change directory\n\n Args:\n envvar (str): os.environ variable name\n line (str): path to append to envvar\n """\n prefix = os.environ.get(envvar, "")\n _dstpath = line.lstrip(os.path.sep)\n path = os.path.join(prefix, _dstpath)\n cmd = ("cd %s" % ipymagic_quote(path))\n print("%" + cmd, file=sys.stderr)\n return self.shell.magic(cmd)'
VENV_IPYMAGIC_METHOD_TEMPLATE = '\n @line_magic\n def {ipy_func_name}(self, line):\n """{ipy_func_name} -- cd ${pathvar}/${{@}}"""\n return self.cd(\'{pathvar}\', line)'
to_ipython_method()[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:ipython method block
Return type:str
VIM_HEADER_TEMPLATE = '\n" ### venv.vim\n" # Src: https://github.com/westurner/venv.vim\n\n" "g:venv_list_only_dirs -- 1 -- 0 to list files in Cd* commands\n\nlet g:venv_list_only_dirs = 1\n\nfunction! Cd_help()\n" :Cdhelp -- list venv.vim cdalias commands\n :verbose command Cd\nendfunction\ncommand! -nargs=0 Cdhelp call Cd_help()\n\nfunction! ListDirsOrFiles(path, ArgLead, ...)\n let dirsonly = ((a:0>0) ? 1 : g:venv_list_only_dirs)\n let _glob = \'\' . a:ArgLead . ((g:venv_list_only_dirs>1) ? \'*/\' : \'*\')\n execute \'lcd\' a:path\n if dirsonly ==? 1\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:]\')\n elseif dirsonly ==? 0\n let output = map(sort(globpath(\'.\', _glob, 0, 1), \'i\'), \'v:val[2:] . (isdirectory(v:val) ? "/" : "")\')\n endif\n execute \'lcd -\'\n return output\nendfunction\n\nfunction! Cdhere(...)\n" :Cdhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n" :CDhere -- cd to here (this dir, dirname(__file__)) [cd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'cd\' _path\n pwd\nendfunction\nfunction! Compl_Cdhere(ArgLead, ...)\n return ListDirsOrFiles(expand(\'%:p:h\'), a:ArgLead, 1)\nendfor\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Cdhere call Cdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere CDhere call Cdhere(<f-args>)\n\nfunction! Lcdhere(...)\n" :Lcdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n" :LCdhere -- lcd to here (this dir, dirname(__file__)) [lcd %:p:h]\n let _path = expand(\'%:p:h\') . ((a:0>0) ? (\'/\' . a:1) : \'\')\n execute \'lcd\' _path\n pwd\nendfunction\ncommand! -nargs=* -complete=customlist,Compl_Cdhere Lcdhere call Lcdhere(<f-args>)\ncommand! -nargs=* -complete=customlist,Compl_Cdhere LCdhere call Lcdhere(<f-args>)\n\n\nfunction! Cd___VAR_(varname, cmd, ...)\n" Cd___VAR_() -- cd expand(\'$\' . a:varname)/$1\n let _VARNAME = a:varname\n let _VAR_=expand(_VARNAME)\n if _VARNAME ==? _VAR_\n echoerr _VARNAME . " is not set"\n return\n endif\n let pathname = join([_VAR_, (a:0>0) ? a:1 : ""], "/")\n execute a:cmd pathname\n pwd\nendfunction\n\n'
VIM_CD_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- cd ${pathvar}/$1\n call Cd___VAR_(\'${pathvar}\', \'{vim_cd_func}\', (a:0>0)? a:1 : "")\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 1)\nendfunction\n'
VIM_CD_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- cd ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
VIM_EDIT_FUNCTION_TEMPLATE = '\nfunction! {vim_func_name}(...)\n" {vim_func_name}() -- e ${pathvar}/$1\n let _path=expand("${pathvar}") . ((a:0>0)? "/" . a:1 : "")\n execute \'{vim_edit_func}\' _path\nendfunction\nfunction! Compl_{vim_func_name}(ArgLead, ...)\n return ListDirsOrFiles(${pathvar}, a:ArgLead, 0)\nendfunction\n'
VIM_EDIT_COMMAND_TEMPLATE = '" :{cmd_name:<10} -- e ${pathvar}/$1\ncommand! -nargs=* -complete=customlist,Compl_{vim_func_name} {cmd_name} call {vim_func_name}(<f-args>)\n'
vim_cmd_name

Returns: str: e.g “Cdwrd”

vim_cmd_names

Returns: list: self.vim_cmd_name + self.aliases.title()

to_vim_function()[source]
Returns:vim function block
Return type:str
BASH_CDALIAS_HEADER = '#!/bin/sh\n## venv.sh\n# generated from $(venv --print-bash --prefix=/)\n\n'
BASH_FUNCTION_TEMPLATE = '{bash_func_name} () {{\n # {bash_func_name:16} -- cd ${pathvar} /$@\n [ -z "${pathvar}" ] && echo "{pathvar} is not set" && return 1\n cd "${pathvar}"${{@:+"/${{@}}"}}\n}}\n{bash_compl_name} () {{\n local cur="$2";\n COMPREPLY=($({bash_func_name} && compgen -d -- "${{cur}}" ))\n}}\n'
BASH_ALIAS_TEMPLATE = '{cmd_name} () {{\n # {cmd_name:16} -- cd ${pathvar}\n {bash_func_name} $@\n}}\n'
BASH_COMPLETION_TEMPLATE = 'complete -o default -o nospace -F {bash_compl_name} {cmd_name}\n'
bash_func_name

Returns: str: e.g. “cdwrd”

bash_func_names

Returns: list: self.bash_func_name + self.aliases

to_bash_function(include_completions=True)[source]
Keyword Arguments:
 include_completions (bool) – generate inline Bash completions
Returns:bash function block
Return type:str
to_shell_str()[source]
Returns:eval ‘{_to_bash_function()}’
Return type:str
class dotfiles.venv.venv_ipyconfig.Step(func=None, **kwargs)[source]

Bases: object

A build task step which builds or transforms an Env, by calling step.build(env=env, **step.conf)

name

Returns: str: a name for this Step

asdict()[source]
Returns:OrderedDict(self._iteritems())
Return type:OrderedDict
build_print_kwargs_env(env=None, **kwargs)[source]

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

DEFAULT_FUNC(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

build(env=None, **kwargs)[source]

Call self.func(env=env, **self.conf.copy().update(**kwargs))

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

self.func(env=env, **self.conf.copy().update(**kwargs))

Return type:

obj

class dotfiles.venv.venv_ipyconfig.PrintEnvStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.venv_ipyconfig.Step

Print env and kwargs to stdout

stdout = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
stderr = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
func(env=None, **kwargs)

Default build_*_env Step.func function to print env

Keyword Arguments:
 
  • env (Env) – Env object (default: None)
  • kwargs (dict) – kwargs dict
Returns:

updated Env

Return type:

Env

class dotfiles.venv.venv_ipyconfig.PrintEnvStderrStep(func=None, **kwargs)[source]

Bases: dotfiles.venv.venv_ipyconfig.PrintEnvStep

Print env and kwargs to stderr

stdout = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
class dotfiles.venv.venv_ipyconfig.StepBuilder(**kwargs)[source]

Bases: object

A class for building a sequence of steps which modify env

name
debug

Returns: str: self.conf.get(‘debug’)

show_diffs

Returns: str: self.conf.get(‘show_diffs’)

add_step(func, **kwargs)[source]

Add a step to self.steps

Parameters:
  • func (Step or function or str) – func(env=None, **kwargs)
  • kwargs (dict) – kwargs for Step.conf
Keyword Arguments:
 

name (str) – function name (default: None)

Returns:

Step object appended to self.steps

Return type:

Step

build_iter(env=None, show_diffs=True, debug=False)[source]

Build a generator of (Step, Env) tuples from the functional composition of StepBuilder.steps given an initial Env (or None).

# pseudocode
env_previous = Env()
for step in self.steps:
    (step, env) = step.build(env=env_previous.copy(),**conf)
    env_previous=env
Keyword Arguments:
 
  • env (Env) – initial Env (default: None)
  • show_diffs (bool) – show difflib.ndiffs of Envs between steps
  • debug (bool) –
Yields:

tuple – (Step, Env)

build(*args, **kwargs)[source]

Build a list of Envs from self.build_iter(*args, **kwargs) and return the last Env.

Keyword Arguments:
 debug (bool) – log.debug(env)
Returns:the last env returned from .build_iter
Return type:Env or None
dotfiles.venv.venv_ipyconfig.lookup_from_kwargs_env(kwargs, env, attr, default=None)[source]

__getitem__ from kwargs, env, or default.

Parameters:
  • kwargs (dict) – kwargs dict
  • env (Env) – Env dict
  • attr (str) – attribute name
  • default (obj) – default value to return if not found in kwargs or env
Returns:

kwargs.get(attr, env.get(attr, default))

Return type:

obj

dotfiles.venv.venv_ipyconfig.build_dotfiles_env(env=None, **kwargs)[source]

Configure dotfiles base environment (HOME, __WRK, __SRC, __DOTFILES)

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • HOME (str) – home path ($HOME, ~)
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • __SRC (str) – path to source repos ($__WRK/-src)
  • __DOTFILES (str) – current dotfiles path (~/-dotfiles)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • HOME
  • __WRK
  • __SRC
  • __DOTFILES

Return type:

env (Env dict)

dotfiles.venv.venv_ipyconfig.build_virtualenvwrapper_env(env=None, **kwargs)[source]

Set WORKON_HOME to WORKON_HOME or WORKON_HOME_DEFAULT

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • __WRK (str) – workspace path ($__WRK, ~/-wrk)
  • WORKON_HOME_DEFAULT (str) – variable name (default: WORKON_HOME__py27)
  • WORKON_HOME__* (str) – path to a WORKON_HOME set
Returns:

dotfiles.venv.venv_ipyconfig.Env

Sets:

  • WORKON_HOME__py27=’${__WRK}/-ve27’
  • WORKON_HOME__py34=’${__WRK}/-ve34’
  • WORKON_HOME__*=kwargs.get(WORKON_HOME__*)
  • WORKON_HOME_DEFAULT=’WORKON_HOME_py27’

Return type:

env (Env dict)

dotfiles.venv.venv_ipyconfig.build_conda_env(env=None, **kwargs)[source]

Configure conda27 (2.7) and conda (3.4) with condaenvs in -wrk/-ce27 and -wrk/ce34.

Other Parameters:
 
  • __WRK (str) – workspace root ($__WRK, ~/-wrk)
  • CONDA_ROOT__py27 (str) – path to conda27 root environment
  • CONDA_ENVS__py27 (str) – path to conda27 envs (e.g. WORKON_HOME)
  • CONDA_ROOT__py34 (str) – path to conda34 root environment
  • CONDA_ENVS__py34 (str) – path to conda34 envs (e.g. WORKON_HOME)
Keyword Arguments:
 

env (Env dict) – dotfiles.venv.venv_ipyconfig.Env

Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

dotfiles.venv.venv_ipyconfig.build_conda_cfg_env(env=None, **kwargs)[source]

Configure conda for a specific environment TODO build_venv_config

Parameters:env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
Returns:dotfiles.venv.venv_ipyconfig.Env
Return type:env (Env dict)
dotfiles.venv.venv_ipyconfig.build_venv_paths_full_env(env=None, pyver=None, **kwargs)[source]

Set variables for standard paths in the environment

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env (default: None (Env()))
  • VENVPREFIX (str) – venv prefix path (default: None (VIRTUAL_ENV))
  • VENVSTR (str) – name of a VIRTUAL_ENV in WORKON_HOME or path to a VIRTUAL_ENV (default: None)
  • VIRTUAL_ENV (str) – path to a VIRTUAL_ENV (default: None)
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Raises:

StepConfigException – When not any(( VIRTUAL_ENV, VENVPREFIX, VENVSTR, VENVSTRAPP))

References

dotfiles.venv.venv_ipyconfig.build_venv_paths_cdalias_env(env=None, **kwargs)[source]

Build CdAliases for standard paths

Keyword Arguments:
 env (Env dict) – Env
Returns:Env with .aliases extended.
Return type:env (Env dict)

Note

These do not work in IPython as they run in a subshell. See: dotfiles.venv.venv_ipymagics.

dotfiles.venv.venv_ipyconfig.build_user_aliases_env(env=None, dont_reflect=False, VIRTUAL_ENV=None, _SRC=None, _ETC=None, _CFG=None, PROJECT_FILES=None, **kwargs)[source]

Configure env variables and return an OrderedDict of aliases

Parameters:dont_reflect (bool) – Whether to always create aliases and functions referencing $_WRD even if $_WRD doesn’t exist. (default: False)
Returns:dict of aliases
Return type:OrderedDict
dotfiles.venv.venv_ipyconfig.build_usrlog_env(env=None, _TERM_ID=None, shell='bash', prefix=None, USER=None, HOSTNAME=None, lookup_hostname=False, **kwargs)[source]

Build environment variables and configuration like usrlog.sh

Keyword Arguments:
 
  • env (Env dict) – dotfiles.venv.venv_ipyconfig.Env
  • _TERM_ID (str) – terminal identifier string
  • shell (str) – shell name (“bash”, “zsh”)
  • prefix (str) – a path prefix (e.g. $VIRTUAL_ENV or $PREFIX)
  • USER (str) – system username ($USER) for HISTTIMEFORMAT
  • HOSTNAME (str) – system hostname (HOSTNAME) for HISTTIMEFORMAT
  • lookup_hostname (bool) – if True, HOSTNAME is None, and not env.get(‘HOSTNAME’), try to read HOSTNAME from os.environ and then socket.gethostname().
Returns:

dotfiles.venv.venv_ipyconfig.Env

Return type:

env (Env dict)

Note

Like usrlog.sh, when HISTTIMEFORMAT is set, USER and HOSTNAME must be evaluated.

(When USER and HOSTNAME change, HISTTIMEFORMAT is not updated, and the .history file will contain only the most recent USER and HOSTNAME settings, which are not necessarily the actual USER and HOSTNAME.)

TODO: could/should instead (also) write USER and HOSTNAME to -usrlog.log.

dotfiles.venv.venv_ipyconfig.build_venv_activate_env(env=None, VENVSTR=None, VENVSTRAPP=None, from_environ=False, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, **kwargs)[source]
class dotfiles.venv.venv_ipyconfig.Env(*args, **kwargs)[source]

Bases: object

OrderedDict of variables for/from os.environ.

osenviron_keys_classic = ('VIMBIN', 'GVIMBIN', 'MVIMBIN', 'GUIVIMBIN', 'VIMCONF', 'EDITOR', 'EDITOR_', 'PAGER', '__WRK', '__DOTFILES', 'PROJECT_HOME', 'WORKON_HOME', 'WORKON_HOME__py27', 'WORKON_HOME__py34', 'VENVPREFIX', 'VENVSTR', 'VENVSTRAPP', '_APP', 'VIRTUAL_ENV_NAME', 'VIRTUAL_ENV', '_SRC', '_ETC', '_BIN', '_CFG', '_LIB', '_LOG', '_MNT', '_OPT', '_PYLIB', '_PYSITE', '_SRV', '_VAR', '_WRD', '_WRD_SETUPY', '_WWW', '__SRC', '__DOCSWWW', '_USRLOG', '__USRLOG', '_TERM_ID', '_TERM_URI')
osenviron_keys = {'CONDA_ENVS_PATH': '${__WRK}/-ce27', 'CONDA_ENVS__py27': '${__WRK}/-ce27', 'CONDA_ENVS__py34': '${__WRK}/-ce34', 'CONDA_ENVS__py35': '${__WRK}/-ce35', 'CONDA_ENVS__py36': '${__WRK}/-ce36', 'CONDA_ENVS__py37': '${__WRK}/-ce37', 'CONDA_ROOT': '${__WRK}/-conda27', 'CONDA_ROOT__py27': '${__WRK}/-conda27', 'CONDA_ROOT__py34': '${__WRK}/-conda34', 'CONDA_ROOT__py35': '${__WRK}/-conda35', 'CONDA_ROOT__py36': '${__WRK}/-conda36', 'CONDA_ROOT__py37': '${__WRK}/-conda37', 'PROJECT_HOME': '${__WRK}', 'VENVPREFIX': '${VIRTUAL_ENV}', 'VENVSTR': 'dotfiles', 'VENVSTRAPP': 'dotfiles', 'VIRTUAL_ENV': '${WORKON_HOME}/${VIRTUAL_ENV_NAME}', 'VIRTUAL_ENV_NAME': 'dotfiles', 'WORKON_HOME': '${__WRK}/-ve27', 'WORKON_HOME_DEFAULT': 'WORKON_HOME__py37', 'WORKON_HOME__py27': '${__WRK}/-ve27', 'WORKON_HOME__py34': '${__WRK}/-ve34', 'WORKON_HOME__py35': '${__WRK}/-ve35', 'WORKON_HOME__py36': '${__WRK}/-ve36', 'WORKON_HOME__py37': '${__WRK}/-ve37', '_APP': 'dotfiles', '_BIN': '${VIRTUAL_ENV}/bin', '_ETC': '${VIRTUAL_ENV}/etc', '_ETCOPT': '${_ETC}/opt', '_HOME': '${VIRTUAL_ENV}/home', '_LIB': '${VIRTUAL_ENV}/lib', '_LOG': '${_VAR}/log', '_MEDIA': '${VIRTUAL_ENV}/media', '_MNT': '${VIRTUAL_ENV}/mnt', '_OPT': '${VIRTUAL_ENV}/opt', '_PYLIB': '${_LIB}/python2.7', '_PYSITE': '${_PYLIB}/site-packages', '_ROOT': '${VIRTUAL_ENV}/root', '_SBIN': '${VIRTUAL_ENV}/sbin', '_SRC': '${VIRTUAL_ENV}/src', '_SRV': '${VIRTUAL_ENV}/srv', '_TMP': '${VIRTUAL_ENV}/tmp', '_USR': '${VIRTUAL_ENV}/usr', '_USRBIN': '${VIRTUAL_ENV}/usr/bin', '_USRINCLUDE': '${VIRTUAL_ENV}/usr/include', '_USRLIB': '${VIRTUAL_ENV}/usr/lib', '_USRLOCAL': '${VIRTUAL_ENV}/usr/local', '_USRLOCALBIN': '${VIRTUAL_ENV}/usr/local/bin', '_USRSBIN': '${VIRTUAL_ENV}/usr/sbin', '_USRSHARE': '${VIRTUAL_ENV}/usr/share', '_USRSRC': '${VIRTUAL_ENV}/usr/src', '_VAR': '${VIRTUAL_ENV}/var', '_VARCACHE': '${_VAR}/cache', '_VARLIB': '${_VAR}/lib', '_VARLOCK': '${_VAR}/lock', '_VARMAIL': '${_VAR}/mail', '_VAROPT': '${_VAR}/opt', '_VARRUN': '${_VAR}/run', '_VARSPOOL': '${_VAR}/spool', '_VARTMP': '${_VAR}/tmp', '_WRD': '${_SRC}/dotfiles', '_WWW': '${_VAR}/www', '__DOTFILES': '${HOME}/-dotfiles', '__SRC': '${__WRK}/-src', '__WRK': '${HOME}/-wrk'}
name
logevent(*args, **kwargs)[source]
iterkeys()[source]
iteritems_environ()[source]
iteritems()[source]
get(k, default=None)[source]
copy()[source]
classmethod from_environ(environ, verbose=False)[source]

Build an Env from a dict (e.g. os.environ)

Parameters:
  • environ (dict) – a dict with variable name keys and values
  • verbose (bool) – whether to be verbose about dict merging
Returns:

an Env environment built from the given environ dict

Return type:

Env

compress_paths(path_, keys=None, keyname=None)[source]

Given an arbitrary string, replace absolute paths (starting with ‘/’) with the longest matching Env path variables.

Parameters:path (str) – a path string
Returns:path string containing ${VARNAME} variables
Return type:str
to_string_iter(**kwargs)[source]
ndiff(other_env)[source]
Parameters:other_env (Env) – env to compare with
Returns:strings from difflib.ndiff
Return type:iterable
to_dict()[source]
to_json(*args, **kwargs)[source]
dotfiles.venv.venv_ipyconfig.shell_quote(var)[source]

Escape single quotes and add double quotes around a given variable.

Parameters:_str (str) – string to add quotes to
Returns:string wrapped in quotes
Return type:str

Warning

This is not safe for untrusted input and only valid in this context (os.environ).

dotfiles.venv.venv_ipyconfig.shell_varquote(str_)[source]

Add doublequotes and shell variable brackets to a string

Parameters:str (str) – string to varquote (e.g. VIRTUAL_ENV)
Returns:“${VIRTUAL_ENV}”
Return type:str
class dotfiles.venv.venv_ipyconfig.Venv(VENVSTR=None, VENVSTRAPP=None, _Venv__WRK=None, _Venv__DOTFILES=None, WORKON_HOME=None, VIRTUAL_ENV_NAME=None, VENVPREFIX=None, VIRTUAL_ENV=None, _SRC=None, _APP=None, _WRD=None, env=None, from_environ=False, open_editors=False, open_terminals=False, dont_reflect=True, debug=False, show_diffs=False, **kwargs)[source]

Bases: object

A virtual environment configuration generator

build(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, from_environ=False, dont_reflect=True, debug=False, show_diffs=False, build_user_aliases=False, build_userlog_env=False)[source]

Build Venv Steps with StepBuilder

static parse_VENVSTR(env=None, VENVSTR=None, VENVSTRAPP=None, VENVPREFIX=None, VIRTUAL_ENV=None, VIRTUAL_ENV_NAME=None, _APP=None, _SRC=None, _WRD=None, _Venv__WRK=None, WORKON_HOME=None, from_environ=False, **kwargs)[source]

Get the path to a virtualenv given a VENVSTR

Keyword Arguments:
 
  • env (Env) –
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) –
  • VENVPREFIX (str) –
  • WORKON_HOME (str) –
  • from_environ (bool) – whether to try and read from os.environ["VIRTUAL_ENV"]
Returns:

a path to a virtualenv (for $VIRTUAL_ENV)

Return type:

str

aliases

Returns: OrderedDict: self.env.aliases

configure_sys()[source]
Returns:sys.path list from _configure_sys.
Return type:list
classmethod workon(env=None, VENVSTR=None, VENVSTRAPP=None, **kwargs)[source]
Parameters:
  • VENVSTR (str) – a path to a virtualenv containing / OR just the name of a virtualenv in $WORKON_HOME
  • VENVSTRAPP (str) – e.g. dotfiles or dotfiles/docs
  • kwargs (dict) – kwargs to pass to Venv (see Venv.__init__)
Returns:

an intialized Venv

Return type:

Venv

configure_ipython(*args, **kwargs)[source]

Configure IPython with Venv._configure_ipython and user_aliases from self.aliases.items().

Parameters:
  • args (list) – args for Venv._configure_ipython
  • kwargs (dict) – kwargs for Venv._configure_ipython.
generate_vars_env(**kwargs)[source]

Generate a string containing VARIABLE=’./value’

generate_bash_env(shell_keyword='export ', shell_quotefunc=<function shell_quote>, include_paths=True, include_aliases=True, include_cdaliases=False, **kwargs)[source]

Generate a source-able script for the environment variables, aliases, and functions defined by the current Venv.

Keyword Arguments:
 
  • shell_keyword (str) – shell variable def (default: “export “)
  • include_paths (bool) – Include environ vars in output (default: True)
  • include_aliases (bool) – Include aliases in output (default: True)
  • include_cdaliases (bool) – Include cdaliases in output (default: False)
  • compress_paths (bool) – Compress paths to $VAR (default=False)
Yields:

str – block of bash script

generate_bash_cdalias()[source]

Generate a source-able script for cdalias functions

Yields:str – block of bash script
generate_vim_cdalias()[source]

Generate a source-able vimscript for vim

Yields:str – block of vim script
generate_venv_ipymagics()[source]

Generate an venv_ipymagics.py file for IPython

Yields:str – block of Python code
project_files
PROJECT_FILES
system(cmd=None)[source]

Call os.system with the given command string

Parameters:

cmd (string) – command string to call os.system with

Raises:
  • Exception – if cmd is None
  • NotImplementedError – if cmd is a tuple
open_editors()[source]

Run self._edit_project_cmd

open_terminals()[source]

Run self._open_terminals_cmd

to_dict()[source]
Returns:OrderedDict(env=self.env, aliases=self.aliases)
Return type:OrderedDict
to_json(indent=None)[source]
Parameters:indent (int) – number of spaces with which to indent JSON output
Returns:json.dumps(self.to_dict())
Return type:str
static update_os_environ(venv, environ=None)[source]

Update os.environ for the given venv

Parameters:environ (dict) – if None, defaults to os.environ
Returns:updated environ dict
Return type:dict
call(command)[source]
Parameters:command (str) – command to run
Returns:output from subprocess.call
Return type:str
dotfiles.venv.venv_ipyconfig.get_IPYTHON_ALIAS_DEFAULTS(platform=None)[source]
dotfiles.venv.venv_ipyconfig.get_IPYTHON_ALIAS_OVERLAY()[source]
dotfiles.venv.venv_ipyconfig.get_USRLOG_ALIAS_OVERLAY()[source]
dotfiles.venv.venv_ipyconfig.ipython_main()[source]

Configure IPython with Venv :py:method:`configure_ipython` (:py:method:`_configure_ipython`).

dotfiles.venv.venv_ipyconfig.ipython_imports()[source]

Default imports for IPython (currently unused)

class dotfiles.venv.venv_ipyconfig.VenvTestUtils[source]

Bases: object

Test fixtures for TestCases and examples

static build_env_test_fixture(env=None)[source]
static capture_io(f)[source]

Add stdout and sterr kwargs to a function call and return (output, _stdout, _stderr)

class dotfiles.venv.venv_ipyconfig.VenvTestCase[source]

Bases: object

unittest.TestCase or object

class dotfiles.venv.venv_ipyconfig.Test_001_lookup(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

test_100_lookup()[source]
class dotfiles.venv.venv_ipyconfig.Test_100_Env(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

test_010_Env()[source]
test_020_Env_copy()[source]
test_Env_from_environ()[source]
class dotfiles.venv.venv_ipyconfig.Test_200_StepBuilder(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

test_000_Step()[source]
test_500_StepBuilder()[source]
test_600_StepBuilder()[source]
class dotfiles.venv.venv_ipyconfig.Test_250_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv_test_fixture()[source]
test_010_assert_venv_requires_VENVPREFIX__or__VIRTUAL_ENV()[source]
test_100_Venv_parse_VENVSTR_env__and__VENVSTR()[source]
test_110_Venv_parse_VENVSTR_VENVSTR()[source]
test_120_Venv_parse_VENVSTR_VENVSTR_VENVSTRAPP()[source]
class dotfiles.venv.venv_ipyconfig.Test_300_venv_build_env(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

test each build step independently

kwargs = {}
env = env.copy()
buildfunc = build_virtualenvwrapper_env
new_env = buildfunc(env=env, **kwargs)
setUp()[source]

Hook method for setting up the test fixture before exercising it.

static print_(self, *args, **kwargs)[source]
test_100_build_dotfiles_env()[source]
test_200_build_usrlog_env()[source]
test_400_build_virtualenvwrapper_env()[source]
test_500_build_conda_env()[source]
test_600_build_conda_cfg_env()[source]
test_600_build_venv_paths_full_env__prefix_None()[source]
test_610_build_venv_paths_full_env__prefix_root()[source]
test_620_build_venv_paths_full_env__prefix_None()[source]
test_650_build_venv_paths_cdalias_env()[source]
class dotfiles.venv.venv_ipyconfig.Test_500_Venv(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_000_venv()[source]
test_005_venv()[source]
test_010_venv__APP()[source]
test_011_venv__APP()[source]
test_020_venv_from_null_environ()[source]
test_030_venv_without_environ()[source]
test_050_venv__VENVSTR__WORKON_HOME()[source]
class dotfiles.venv.venv_ipyconfig.Test_900_Venv_main(methodName='runTest')[source]

Bases: dotfiles.venv.venv_ipyconfig.VenvTestCase, unittest.case.TestCase

setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_001_main_null()[source]
test_100_main()[source]
test_110_main_VENVSTR()[source]
test_120_main_print_bash_VENVSTR()[source]
test_130_main_print_bash_VENVSTR_VENVSTRAPP()[source]
test_140_main_VENVSTR_WORKON_HOME()[source]
test_200_main_print_bash_VENVSTR__APP()[source]
test_200_main_print_bash()[source]
test_210_main_print_bash_aliases()[source]
test_220_main_print_bash_cdaliases()[source]
test_300_main_print_zsh()[source]
test_400_main_print_vim()[source]
dotfiles.venv.venv_ipyconfig.build_venv_arg_parser()[source]
Returns:options for the commandline interface
Return type:optparse.OptionParser
dotfiles.venv.venv_ipyconfig.comment_comment(strblock, **kwargs)[source]
Parameters:strblock (str) – string block (possibly containing newlines)
Keyword Arguments:
 kwargs (dict) – kwargs for prepend_comment_char
Returns:string with each line prefixed with comment char
Return type:str
dotfiles.venv.venv_ipyconfig.main(*argv, **kwargs)[source]

main function called if __name__=="__main__"

Returns:nonzero on error
Return type:int

dotfiles.venv.venv_ipymagics module

dotfiles.venv.venv_ipymagics.magics_class(cls, *args, **kwargs)
dotfiles.venv.venv_ipymagics.line_magic(func, *args, **kwargs)
dotfiles.venv.venv_ipymagics.ipymagic_quote(_str)[source]
class dotfiles.venv.venv_ipymagics.VenvMagics[source]

Bases: object

cd(envvar, line)[source]

Change directory

Parameters:
  • envvar (str) – os.environ variable name
  • line (str) – path to append to envvar
cdhome(line)[source]

cdhome – cd $HOME/${@}

cdh(line)[source]

cdh – cd $HOME/${@}

cdwrk(line)[source]

cdwrk – cd $__WRK/${@}

cddotfiles(line)[source]

cddotfiles – cd $__DOTFILES/${@}

cdd(line)[source]

cdd – cd $__DOTFILES/${@}

cdprojecthome(line)[source]

cdprojecthome – cd $PROJECT_HOME/${@}

cdp(line)[source]

cdp – cd $PROJECT_HOME/${@}

cdph(line)[source]

cdph – cd $PROJECT_HOME/${@}

cdworkonhome(line)[source]

cdworkonhome – cd $WORKON_HOME/${@}

cdwh(line)[source]

cdwh – cd $WORKON_HOME/${@}

cdve(line)[source]

cdve – cd $WORKON_HOME/${@}

cdcondaenvspath(line)[source]

cdcondaenvspath – cd $CONDA_ENVS_PATH/${@}

cda(line)[source]

cda – cd $CONDA_ENVS_PATH/${@}

cdce(line)[source]

cdce – cd $CONDA_ENVS_PATH/${@}

cdcondaroot(line)[source]

cdcondaroot – cd $CONDA_ROOT/${@}

cdr(line)[source]

cdr – cd $CONDA_ROOT/${@}

cdvirtualenv(line)[source]

cdvirtualenv – cd $VIRTUAL_ENV/${@}

cdv(line)[source]

cdv – cd $VIRTUAL_ENV/${@}

cdsrc(line)[source]

cdsrc – cd $_SRC/${@}

cds(line)[source]

cds – cd $_SRC/${@}

cdwrd(line)[source]

cdwrd – cd $_WRD/${@}

cdw(line)[source]

cdw – cd $_WRD/${@}

cdbin(line)[source]

cdbin – cd $_BIN/${@}

cdb(line)[source]

cdb – cd $_BIN/${@}

cdetc(line)[source]

cdetc – cd $_ETC/${@}

cde(line)[source]

cde – cd $_ETC/${@}

cdlib(line)[source]

cdlib – cd $_LIB/${@}

cdl(line)[source]

cdl – cd $_LIB/${@}

cdlog(line)[source]

cdlog – cd $_LOG/${@}

cdpylib(line)[source]

cdpylib – cd $_PYLIB/${@}

cdpysite(line)[source]

cdpysite – cd $_PYSITE/${@}

cdsitepackages(line)[source]

cdsitepackages – cd $_PYSITE/${@}

cdvar(line)[source]

cdvar – cd $_VAR/${@}

cdwww(line)[source]

cdwww – cd $_WWW/${@}

cdww(line)[source]

cdww – cd $_WWW/${@}

cdhelp(line)[source]

cdhelp() – list cd commands

dotfiles_status(line)[source]

dotfiles_status() – print dotfiles_status() .

ds(line)[source]

ds() – print dotfiles_status() .

dotfiles_reload(line)[source]

dotfiles_reload() – print NotImplemented

dr(line)[source]

dr() – print NotImplemented [dotfiles_reload()]

dotfiles.venv.venv_ipymagics.main()[source]

Register VenvMagics with IPython