This is a style I frequently use for self-contained command-line python scripts.
It distinctly separates:
- Core functionality
- Unit testing
- Command-line behaviour -
main_cli
- Graphical (GUI) behaviour -
main_gui
#!/usr/bin/env python | |
import sqlite3 | |
def create_connection(db_file): | |
""" create a database connection to the SQLite database | |
specified by the db_file | |
:param db_file: database file | |
:return: Connection object or None | |
""" |
#... portion of .bashrc | |
export GIT_PS1_SHOWDIRTYSTATE=true # staged '+', unstaged '*' | |
export GIT_PS1_SHOWUNTRACKEDFILES=true # '%' untracked files | |
export GIT_PS1_SHOWUPSTREAM="auto" # '<' behind, '>' ahead, '<>' diverged, '=' no difference | |
export GIT_PS1_SHOWSTASHSTATE=true # '$' something is stashed | |
function __prompt_command() { | |
local ERRORCODE="$?" |
__pycache__ | |
myfile.json |
./test.sh
output is:
FreeCAD 0.17, Libs: 0.17R13522 (Git)
Fasteners workbench Loaded
[
FROM ubuntu:16.04 | |
# build-time arguments | |
ARG tester_name=tester | |
ADD . /code | |
WORKDIR /code | |
USER root | |
RUN bash /code/setup.sh |
import sys | |
import os | |
import subprocess | |
# Set sync source & destination | |
source_path = "temp/a" | |
dest_path = "temp/b" | |
# Sync: source_path -> mountpoint | |
if sys.platform.startswith('win'): |
*.pyc |