Skip to content

Commit 6409574

Browse files
committed
Clean copy of scripts directory, not everything has been added yet.
0 parents  commit 6409574

10 files changed

+1127
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
scripts
3+
-------
4+
5+
'''XXX fill me in!'''
6+

boilerplate-bash

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
################################################################################
3+
#
4+
# boilerplate-bash
5+
# ----------------
6+
# A simple utility to copy a file to a new location with a new name, and then
7+
# immediately start editing it. For boilerplates.
8+
#
9+
# @author Isis Agora Lovecruft, 0x2cdb8b35
10+
# @date 16 May 2012
11+
# @version 0.0.1
12+
#
13+
################################################################################
14+

boilerplater

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
##############################################################################
3+
#
4+
# boilerplater
5+
# ------------
6+
# A simple utility to copy a file to a new location with a new name, and then
7+
# immediately start editing it. For boilerplates.
8+
#
9+
# You should create a file containing the boilerplate to use, see the examples
10+
# boilerplate-bash and boilerplate-python, and then (probably in your
11+
# .bashrc) do:
12+
#
13+
# alias boilerpy="/path/to/boilerplate.sh boilerplate-python "
14+
#
15+
# and use that alias like this "$ boilerpy foobar.py".
16+
#
17+
# @author Isis Agora Lovecruft, 0x2cdb8b35
18+
# @date 16 May 2012
19+
# @version 0.0.1
20+
##############################################################################
21+
22+
## Local variables:
23+
AUTHOR_NAME="Isis Agora Lovecruft"
24+
AUTHOR_GPG_KEY="0x2cdb8b35"
25+
26+
function usage () {
27+
echo "Usage: $0 <boilerplate_file> <new_file_name>"
28+
echo
29+
echo "You should set the following environment variables:"
30+
echo "\$AUTHOR_NAME The name to be credited"
31+
echo "\$AUTHOR_GPG_KEY The GPG keyID or email address of the author"
32+
echo "\$EDITOR Your preferred editor"
33+
echo
34+
}
35+
36+
if [[ "$#" != "2" ]]; then
37+
usage
38+
else
39+
echo "Please provide a short docstring description of the file "
40+
echo "which you are about to create: "
41+
42+
read FDOCSTR
43+
44+
## If docstring is blank, boilerplate that too:
45+
if [[ "x${FDOCSTR}" == "x" ]] ; then
46+
FDOCSTR="XXX fill me in"
47+
fi
48+
49+
## Wrap docstring lines:
50+
INT=0
51+
while [[ ${#FDOCSTR} > 75 ]] ; do
52+
NEWSTR=FDOCSTR_${INT}
53+
eval ${NEWSTR}="# "${FDOCSTR:0:75}
54+
INT=$(( $INT + 1 ))
55+
FDOCSTR=${FDOCSTR:75:}
56+
done
57+
58+
if [[ x$1 == x*sh ]] ; then
59+
cat >$2 <<-EOF
60+
#!/bin/bash
61+
##############################################################################
62+
#
63+
# $2
64+
# -------------------
65+
EOF
66+
67+
if [[ $INT -gt "0" ]] ; then
68+
for int in `seq 0 $INT`; do
69+
cat >>$2 <<EOF
70+
$($FDOCSTR_$int)
71+
EOF
72+
done
73+
fi
74+
75+
cat >>$2 <<EOF
76+
# $FDOCSTR
77+
#
78+
# @author $AUTHOR_NAME, $AUTHOR_GPG_KEY
79+
# @date `date "+%e %B %Y"`
80+
# @version 0.0.1
81+
##############################################################################
82+
83+
84+
EOF
85+
86+
elif [[ x$1 == x*py ]] || [[ x$1 == x*python ]] ; then
87+
cat >$2 <<-EOF
88+
#!/usr/bin/env python
89+
#-*- coding: utf-8 -*-
90+
##############################################################################
91+
#
92+
# $2
93+
# --------------------
94+
EOF
95+
96+
if [[ $INT > 0 ]] ; then
97+
for int in `seq 0 $INT`; do
98+
CURRENT_STR=FDOCSTR_$int
99+
cat >>$2 <<<$CURRENT_STR
100+
done
101+
fi
102+
103+
cat >>$2 <<-EOF
104+
# $FDOCSTR
105+
#
106+
# @author $AUTHOR_NAME, $AUTHOR_GPG_KEY
107+
# @date `date "+%e %B %Y"`
108+
# @version 0.0.1
109+
##############################################################################
110+
111+
import os
112+
113+
114+
def foo():
115+
"""
116+
117+
"""
118+
pass
119+
120+
121+
if __name__ == "__main":
122+
123+
124+
EOF
125+
else
126+
cp $1 $2
127+
fi
128+
## Make it executable and start the editor
129+
chmod +x $2
130+
$EDITOR $2
131+
fi

0 commit comments

Comments
 (0)