Dan Kenigsberg has uploaded a new change for review.

Change subject: pep8ize vdsm_api
......................................................................

pep8ize vdsm_api

Change-Id: I38418b2251ab67ad96325a2a474e1d03eddeabba
Signed-off-by: Dan Kenigsberg <[email protected]>
---
M Makefile.am
M vdsm_api/process-schema.py
M vdsm_api/vdsmapi.py
3 files changed, 34 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/8012/1

diff --git a/Makefile.am b/Makefile.am
index 7ca09db..ae600bb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -96,6 +96,7 @@
        vdsm/supervdsm.py \
        vdsm/supervdsmServer.py \
        vdsm/tc.py \
+       vdsm_api \
        vdsm_cli \
        vdsm_hooks/fileinject/before_vm_start.py \
        vdsm_hooks/promisc/after_vm_start.py \
diff --git a/vdsm_api/process-schema.py b/vdsm_api/process-schema.py
index ff466b0..481ee3d 100755
--- a/vdsm_api/process-schema.py
+++ b/vdsm_api/process-schema.py
@@ -34,6 +34,7 @@
 # Symbols of these types are considered data types
 typeKinds = ('type', 'enum', 'map', 'union', 'alias')
 
+
 def read_symbol_comment(f, symbols):
     """
     In the VDSM API schema, each entity is preceeded by a comment that provides
@@ -150,6 +151,7 @@
 
     return symbol
 
+
 def read_schema_doc(f, symbols):
     """
     Read all of the documentation information from the schema and attach it to
@@ -163,11 +165,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):
     """
@@ -277,6 +281,7 @@
 
     f.write('</p><br/>\n')
 
+
 def create_doc(symbols, filename):
     f = open(filename, 'w')
 
@@ -320,6 +325,7 @@
         write_symbol(f, s)
     f.write(footer)
 
+
 def main():
     schema = sys.argv[1]
     output = sys.argv[2]
diff --git a/vdsm_api/vdsmapi.py b/vdsm_api/vdsmapi.py
index 7995dc4..6d81a4d 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:]  # :
 
             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,14 +152,18 @@
             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:
@@ -161,13 +172,16 @@
 
 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,6 +203,7 @@
     else:
         return '%s *' % name
 
+
 def genindent(count):
     ret = ""
     for i in range(count):
@@ -197,13 +212,16 @@
 
 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 +229,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/8012
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I38418b2251ab67ad96325a2a474e1d03eddeabba
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to