summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChenZheng <chen.zheng@easystack.cn>2014-02-27 18:03:28 +0800
committerChenZheng <chen.zheng@easystack.cn>2014-02-27 18:03:28 +0800
commit339f3e4de075d7790286e993b525d81756a763ca (patch)
tree0990730eef0a1c11fa08baf17a40da00dbd6f769 /tools
parent8503781c6777b525b73ef5ac71ed6cb97468b621 (diff)
downloadpython-heatclient-339f3e4de075d7790286e993b525d81756a763ca.tar.gz
Sort requirement files in alphabetical order
This makes code more readable, and can check whether specific library in the requirement files easily. We also enforce the check in pep8. Change-Id: I08434dd56d41a82045e4119e547b7b3f60d66698 Closes-Bug: #1285478
Diffstat (limited to 'tools')
-rwxr-xr-xtools/requirements_style_check.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/requirements_style_check.sh b/tools/requirements_style_check.sh
new file mode 100755
index 0000000..ccbff3b
--- /dev/null
+++ b/tools/requirements_style_check.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Enforce the requirement that dependencies are listed in the input
+# files in alphabetical order.
+
+# FIXME(dhellmann): This doesn't deal with URL requirements very
+# well. We should probably sort those on the egg-name, rather than the
+# full line.
+
+function check_file() {
+ typeset f=$1
+
+ # We don't care about comment lines.
+ grep -v '^#' $f > ${f}.unsorted
+ sort -i -f ${f}.unsorted > ${f}.sorted
+ diff -c ${f}.unsorted ${f}.sorted
+ rc=$?
+ rm -f ${f}.sorted ${f}.unsorted
+ return $rc
+}
+
+exit_code=0
+for filename in $@
+do
+ check_file $filename
+ if [ $? -ne 0 ]
+ then
+ echo "Please list requirements in $filename in alphabetical order" 1>&2
+ exit_code=1
+ fi
+done
+exit $exit_code