Browse code

Add while/until to the for/do rule

Like 'for/do' check that the while/until operator are on
the same line with the do.

Fixes some pep8 error along the way.

Change-Id: I440afe60691263365bf35310bf4212d94f30c339

Chmouel Boudjnah authored on 2014/02/04 23:20:15
Showing 4 changed files
... ...
@@ -47,7 +47,7 @@ IGNORE = None
47 47
 def register_ignores(ignores):
48 48
     global IGNORE
49 49
     if ignores:
50
-        IGNORE='^(' + '|'.join(ignores.split(',')) + ')'
50
+        IGNORE = '^(' + '|'.join(ignores.split(',')) + ')'
51 51
 
52 52
 
53 53
 def should_ignore(error):
... ...
@@ -64,11 +64,15 @@ def print_error(error, line):
64 64
 def not_continuation(line):
65 65
     return not re.search('\\\\$', line)
66 66
 
67
+
67 68
 def check_for_do(line):
68 69
     if not_continuation(line):
69
-        if re.search('^\s*for ', line):
70
+        match = re.match('^\s*(for|while|until)\s', line)
71
+        if match:
72
+            operator = match.group(1).strip()
70 73
             if not re.search(';\s*do(\b|$)', line):
71
-                print_error('E010: Do not on same line as for', line)
74
+                print_error('E010: Do not on same line as %s' % operator,
75
+                            line)
72 76
 
73 77
 
74 78
 def check_if_then(line):
... ...
@@ -71,8 +71,7 @@ MODE=""
71 71
 ROLE=Member
72 72
 USER_NAME=""
73 73
 USER_PASS=""
74
-while [ $# -gt 0 ]
75
-do
74
+while [ $# -gt 0 ]; do
76 75
     case "$1" in
77 76
     -h|--help) display_help; exit 0 ;;
78 77
     --os-username) export OS_USERNAME=$2; shift ;;
... ...
@@ -191,8 +191,7 @@ function wait_for_VM_to_halt() {
191 191
     domid=$(xe vm-list name-label="$GUEST_NAME" params=dom-id minimal=true)
192 192
     port=$(xenstore-read /local/domain/$domid/console/vnc-port)
193 193
     echo "vncviewer -via root@$mgmt_ip localhost:${port:2}"
194
-    while true
195
-    do
194
+    while true; do
196 195
         state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
197 196
         if [ -n "$state" ]; then
198 197
             break
... ...
@@ -42,8 +42,7 @@ EOF
42 42
 
43 43
 get_params()
44 44
 {
45
-    while getopts "hbn:r:l:t:" OPTION;
46
-    do
45
+    while getopts "hbn:r:l:t:" OPTION; do
47 46
         case $OPTION in
48 47
             h) usage
49 48
                 exit 1