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: I138b332102a94557f153f8982ec00d493e2472b0
Closes-Bug: #1285478
This commit is contained in:
ChenZheng 2014-02-27 19:34:47 +08:00
parent b24df35476
commit 07827ed717
4 changed files with 36 additions and 3 deletions

View File

@ -1,8 +1,8 @@
pbr>=0.5.21,<1.0
anyjson>=0.3.3
argparse
httplib2
lxml>=2.3
pbr>=0.5.21,<1.0
PrettyTable>=0.7,<0.8
python-keystoneclient>=0.4.2
six>=1.4.1

View File

@ -1,9 +1,9 @@
hacking>=0.8.0,<0.9
Babel>=1.3
coverage>=3.6
discover
fixtures>=0.3.14
hacking>=0.8.0,<0.9
mock>=1.0
Babel>=1.3
python-subunit
sphinx>=1.1.2,<1.2
testrepository>=0.0.17

View File

@ -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

View File

@ -17,6 +17,7 @@ downloadcache = ~/cache/pip
[testenv:pep8]
commands =
flake8 {posargs}
{toxinidir}/tools/requirements_style_check.sh requirements.txt test-requirements.txt
[testenv:cover]
setenv = VIRTUAL_ENV={envdir}