def design(): """Update the design.rst from the source module's docstrings""" info("Python version: {version}".format(version=version)) design_header = Project.design_header.strip() if design_header: py_files = _find_py_files(Project.package) if py_files: with open(Project.design_file, "w") as design_file: design_file.write("Design\n") design_file.write("======\n\n") design_file.write(design_header) design_file.write("\n\n") for py_file in sorted(py_files): docstring, functions, classes = _parse_py_file(py_file) design_file.write(py_file) design_file.write("\n") design_file.write("-" * len(py_file)) design_file.write("\n\n") design_file.write(docstring) design_file.write("\n\n") if functions: design_file.write("Functions:\n\n") for function in functions: design_file.write("* {name}\n".format(name=function)) design_file.write("\n\n") if classes: design_file.write("Classes:\n\n") for class_ in classes: design_file.write("* {name}\n".format(name=class_)) design_file.write("\n\n") else: touch(Project.design_file)
def test_is_newer(): file_b = _named_temporary_file().name touch(file_b) sleep(2) file_a = _named_temporary_file().name touch(file_a) assert is_newer(file_a, file_b) assert not is_newer(file_b, file_a)
def publish_gh_pages(): """copy documentation to github pages""" if Project.github_url is not None: tmp_repo_path = None try: tmp_repo_path = tempfile.mkdtemp() with LocalShell(verbose=True) as local: # clone repo selecting gh-pages branch # git clone {git_url} {directory} # git branch --list local.run("git clone {url} {dir}".format(url=Project.github_url, dir=tmp_repo_path)) with cd(tmp_repo_path, verbose=True): remote_branches = [ line.lstrip(r"[*\s]*").strip() for line in local.run("git branch --list -r").splitlines() ] if "origin/gh-pages" in remote_branches: local.run("git pull origin") local.run("git checkout -b gh-pages origin/gh-pages") # select branch # git checkout gh-pages local.run("git checkout gh-pages") # remove github pages clone directory # clean_directory(tmp_repo_path) # touch .nojekyl touch(".nojekyll") # copy documentation if os.path.isdir(Project.docs_html_path): dir_util.copy_tree(Project.docs_html_path, tmp_repo_path) # commit and push to github local.run("git add --all") local.run("git status") now = datetime.now().strftime("%c") message = "{project} Documentation {version} {date}".format( project=Project.title, version=Project.version, date=now ) local.run("git commit -m '{message}'".format(message=message)) local.run("git push origin gh-pages") else: info("Please create a 'gh-pages' branch on the github repository.") finally: if tmp_repo_path is not None: try: info("removing {repo}".format(repo=tmp_repo_path)) shutil.rmtree(tmp_repo_path) except OSError as ex: if ex.errno != errno.ENOENT: raise
def new_image(): """Create a new image directory and populate with a default Dockerfile.""" names = list(task.argv) if not names: if Project.prompt and task.arg_prompt is not None: name = prompt(task.arg_prompt) if name is not None and name.strip(): names.append(name) for name in names: container_dir = os.path.join(Project.docker_dir, Project.docker_containers_dir, name) mkdir_p(container_dir) # populate container dir with Dockerfile and .dockerignore dockerfile = os.path.join(container_dir, 'Dockerfile') dockerignore = os.path.join(container_dir, '.dockerignore') shutil.copyfile(DOCKERFILE_TEMPLATE, dockerfile) touch(dockerignore) info("Created folder for new image at: {dir}".format(dir=container_dir))