Change in vdsm[master]: pep8: Make vdsm_api pep8 clean

agl at us.ibm.com agl at us.ibm.com
Thu Oct 18 16:00:57 UTC 2012


Adam Litke has uploaded a new change for review.

Change subject: pep8: Make vdsm_api pep8 clean
......................................................................

pep8: Make vdsm_api pep8 clean

Since the vdsm_api directory does not yet have a Makefile.am, the files cannot
be checked because vdsm_api isn't included in the distribution.  The next patch
in this series will remedy that by establishing an automake presense in
vdsm_api/ .

Change-Id: I2285729264f7ea2ee9cd2b32fdaeab264ae9121e
Signed-off-by: Adam Litke <agl at us.ibm.com>
---
M vdsm_api/process-schema.py
M vdsm_api/vdsmapi.py
2 files changed, 35 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/8664/1

diff --git a/vdsm_api/process-schema.py b/vdsm_api/process-schema.py
index d4992c4..58a4c8c 100755
--- a/vdsm_api/process-schema.py
+++ b/vdsm_api/process-schema.py
@@ -152,6 +152,7 @@
 
     return symbol
 
+
 def read_schema_doc(f, symbols):
     """
     Read all of the documentation information from the schema and attach it to
@@ -165,11 +166,13 @@
             read_symbol_comment(f, symbols)
             continue
 
+
 def html_escape(text):
     """
     Escape stings for proper display in html documents.
     """
-    return "".join(html_escape_table.get(c,c) for c in text)
+    return "".join(html_escape_table.get(c, c) for c in text)
+
 
 def write_symbol(f, s):
     """
@@ -278,6 +281,7 @@
 
     f.write('</p><br/>\n')
 
+
 def create_doc(symbols, filename):
     f = open(filename, 'w')
 
@@ -321,6 +325,7 @@
         write_symbol(f, s)
     f.write(footer)
 
+
 def main():
     schema = sys.argv[1]
     output = sys.argv[2]
@@ -334,5 +339,6 @@
         symbols = read_schema_doc(f, symbols)
     create_doc(symbols, output)
 
+
 if __name__ == '__main__':
     main()
diff --git a/vdsm_api/vdsmapi.py b/vdsm_api/vdsmapi.py
index 7995dc4..7a169bd 100644
--- a/vdsm_api/vdsmapi.py
+++ b/vdsm_api/vdsmapi.py
@@ -26,6 +26,7 @@
 
 from collections import OrderedDict
 
+
 def tokenize(data):
     while len(data):
         if data[0] in ['{', '}', ':', ',', '[', ']']:
@@ -42,6 +43,7 @@
             data = data[1:]
             yield string
 
+
 def parse(tokens):
     if tokens[0] == '{':
         ret = OrderedDict()
@@ -50,7 +52,7 @@
             key = tokens[0]
             tokens = tokens[1:]
 
-            tokens = tokens[1:] # :
+            tokens = tokens[1:]  # Skip ':'
 
             value, tokens = parse(tokens)
 
@@ -73,8 +75,10 @@
     else:
         return tokens[0], tokens[1:]
 
+
 def evaluate(string):
     return parse(map(lambda x: x, tokenize(string)))[0]
+
 
 def parse_schema(fp):
     exprs = []
@@ -89,9 +93,9 @@
             expr += line
         elif expr:
             expr_eval = evaluate(expr)
-            if expr_eval.has_key('enum'):
+            if 'enum' in expr_eval:
                 add_enum(expr_eval['enum'])
-            elif expr_eval.has_key('union'):
+            elif 'union' in expr_eval:
                 add_enum('%sKind' % expr_eval['union'])
             exprs.append(expr_eval)
             expr = line
@@ -100,13 +104,14 @@
 
     if expr:
         expr_eval = evaluate(expr)
-        if expr_eval.has_key('enum'):
+        if 'enum' in expr_eval:
             add_enum(expr_eval['enum'])
-        elif expr_eval.has_key('union'):
+        elif 'union' in expr_eval:
             add_enum('%sKind' % expr_eval['union'])
         exprs.append(expr_eval)
 
     return exprs
+
 
 def parse_args(typeinfo):
     for member in typeinfo:
@@ -121,6 +126,7 @@
             structured = True
         yield (argname, argentry, optional, structured)
 
+
 def de_camel_case(name):
     new_name = ''
     for ch in name:
@@ -131,6 +137,7 @@
         else:
             new_name += ch.lower()
     return new_name
+
 
 def camel_case(name):
     new_name = ''
@@ -145,29 +152,37 @@
             new_name += ch.lower()
     return new_name
 
+
 def c_var(name):
     return name.replace('-', '_').lstrip("*")
+
 
 def c_fun(name):
     return c_var(name).replace('.', '_')
 
+
 def c_list_type(name):
     return '%sList' % name
+
 
 def type_name(name):
     if type(name) == list:
         return c_list_type(name[0])
     return name
 
+
 enum_types = []
+
 
 def add_enum(name):
     global enum_types
     enum_types.append(name)
 
+
 def is_enum(name):
     global enum_types
     return (name in enum_types)
+
 
 def c_type(name):
     if name == 'str':
@@ -189,21 +204,26 @@
     else:
         return '%s *' % name
 
+
 def genindent(count):
     ret = ""
     for i in range(count):
         ret += " "
     return ret
 
+
 indent_level = 0
+
 
 def push_indent(indent_amount=4):
     global indent_level
     indent_level += indent_amount
 
+
 def pop_indent(indent_amount=4):
     global indent_level
     indent_level -= indent_amount
+
 
 def cgen(code, **kwds):
     indent = genindent(indent_level)
@@ -211,12 +231,15 @@
     lines = map(lambda x: indent + x, lines)
     return '\n'.join(lines) % kwds + '\n'
 
+
 def mcgen(code, **kwds):
     return cgen('\n'.join(code.split('\n')[1:-1]), **kwds)
 
+
 def basename(filename):
     return filename.split("/")[-1]
 
+
 def guardname(filename):
     guard = basename(filename).rsplit(".", 1)[0]
     for substr in [".", " ", "-"]:


--
To view, visit http://gerrit.ovirt.org/8664
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2285729264f7ea2ee9cd2b32fdaeab264ae9121e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <agl at us.ibm.com>


More information about the vdsm-patches mailing list