Beispiel #1
0
def script_get_book():
    dd = el.default_directory()
    d1 = el.locate_dominating_file(dd, "Cookbook.py")
    d2 = el.locate_dominating_file(dd, "cook/Cookbook.py")
    if d1 and (not d2 or len(d1) > len(d2) - 5):
        return (d1, el.file_name_directory(d1))
    elif d2:
        return (d2, el.file_name_directory(el.file_name_directory(d2)))
    else:
        raise RuntimeError("No Cookbook.py or cook/Cookbook.py found")
Beispiel #2
0
#* Description
__doc__ = "Run an arbitary amount of commands inside Docker."

#* Imports
import sys
import os
import re
import argparse
import json
import pycook.elisp as el
lf = el.lf
dd = el.default_directory()


#* Functions
def docker_opt_mount(fr, to, opts="rw"):
    return lf("-v '{fr}:{to}:{opts}'")


def docker_opt_env_mount(v, d):
    return lf("-e {v}={d} ") + docker_opt_mount(d, d)


def docker_opt_tty():
    if sys.stdout.isatty():
        return "-it"
    else:
        return "-i"


def docker_opt_cleanup():
Beispiel #3
0
#* Includes
import sys
import os
import re
import subprocess
import imp
import ast
import inspect
import collections
import pycook.elisp as el
import pycook.recipes as recipes
lf = el.lf

#* Globals
start_dir = el.default_directory()


#* Functions
def recipe_p(x):
    try:
        return inspect.getfullargspec(x[1]).args[0] == "recipe"
    except:
        return None


def recipe_names_ordered(book):
    body = ast.parse(el.slurp(book)).body
    return [f.name for f in body if isinstance(f, ast.FunctionDef)]


def recipe_dict(book):
Beispiel #4
0
def reinstall(recipe, user_input=True):
    dd = el.default_directory()
    git1 = el.locate_dominating_file(dd, ".git")
    git2 = el.file_name_directory(git1)
    pip = get_pip()
    return ["cd " + git2, lf("{pip} install --upgrade .")]
Beispiel #5
0
Datei: emacs.py Projekt: zed/cook
def elisp_files_cwd():
    return el.directory_files(el.default_directory(), False, ".*el$")
Beispiel #6
0
 def __enter__(self):
     self._old_dir = el.default_directory()
     os.chdir(self.d)