Anonymous avatar Anonymous committed d395b7c

Added removeorphanpycs function and some inline documentation

Comments (0)

Files changed (1)

scripts/initenv_generic

     return 1
 fi
 
-# Some useful functions
-function cdroot() {
-    cd $PROJECT_ROOT/$1
-}
-function cdjango () {
-    cd $PROJECT_ROOT/$DJANGO_PROJECT/$1
-}
-function djadmin() {
-    django-admin.py $* # Forget manage.py :)
-}
-function pipup() {
-    if [ -z "$1" ]; then
-        echo Usage: pipup '<requirements-identifier>'
-        return 1
-    else
-        pip install --requirement=$PROJECT_ROOT/requirements/libs-$1.txt
-    fi
-}
-function runserver() {
-    django-admin.py runserver `$PROJECT_ROOT/scripts/get_local_server_port.py`
-}
-
-# Change working directory
-cdjango
-
 # Show environment info
 if [ "$SHOW_DJANGO_ENVIRONMENT" = "yes" ]; then
     echo Welcome to $DJANGO_PROJECT. Environment info:
     PAGER=cat python -c "import $DJANGO_SETTINGS_MODULE; help($DJANGO_SETTINGS_MODULE)" | grep -v "^$"
     echo
 fi
+
+# Some useful functions
+
+# Change directory to project root
+function cdroot() {
+    cd $PROJECT_ROOT/$1
+}
+
+# Change directory to django project
+function cdjango () {
+    cd $PROJECT_ROOT/$DJANGO_PROJECT/$1
+}
+
+# Install dependencies for an environment (first argument); the file
+# with the dependencies should be in the requirements directory and
+# should have the format 'libs-<environment>.txt'
+function pipup() {
+    if [ -z "$1" ]; then
+        echo Usage: pipup '<requirements-identifier>'
+        return 1
+    else
+        pip install --requirement=$PROJECT_ROOT/requirements/libs-$1.txt
+    fi
+}
+
+# Remove .pyc files without a corresponding .py
+function removeorphanpycs() {
+    for pyc in `find . -name \*.pyc`; do
+        [ -f  `echo $pyc | sed 's/c$//'` ] || rm -v $pyc
+    done
+}
+
+# Forget manage.py, django-admin.py respects our settings!
+function djadmin() {
+    django-admin.py $*
+}
+
+# Run development server on settings.LOCAL_SERVER_PORT
+function runserver() {
+    django-admin.py runserver `$PROJECT_ROOT/scripts/get_local_server_port.py`
+}
+
+# Change working directory - time to party
+cdjango
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.