Skip to content

Instantly share code, notes, and snippets.

@layus
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save layus/1b8926dcc4112aff29dd to your computer and use it in GitHub Desktop.

Select an option

Save layus/1b8926dcc4112aff29dd to your computer and use it in GitHub Desktop.
A script to refactor INGInious codebase for pip pacakging.
#!/bin/bash
mod=(backend common frontend)
mkdir inginious
git mv templates static "${mod[@]}" inginious
# fix all imports names
sub='"s/\<\(backend\|common\|frontend\)\(\.\|\>\)/inginious.&/g"'
find . -name '*.py' | parallel -m "sed -i $sub"
parallel -m "sed -i.bak $sub" ::: configuration.json
# copy modified files from branch 'egg'
files=(setup.py app_frontend.py inginious/__init__.py)
parallel 'wget -q https://raw.githubusercontent.com/layus/INGInious/egg-backup/{} -O {}' ::: "${files[@]}"
# stage modifications
find . -name '*.py' | parallel -m -j1 "git add"
git add "${files[@]}"
# Interact, then clean.
sed -i "s#\./tasks#$(pwd)/tasks#" ./configuration.json
bash
git reset --hard HEAD
git clean -df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment