[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392403 - /team/dlee/ari-event-remodel2/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 21 00:39:31 CDT 2013


Author: dlee
Date: Fri Jun 21 00:39:29 2013
New Revision: 392403

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392403
Log:
pep8

Modified:
    team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
    team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py
    team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
    team/dlee/ari-event-remodel2/rest-api-templates/transform.py

Modified: team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py?view=diff&rev=392403&r1=392402&r2=392403
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py Fri Jun 21 00:39:29 2013
@@ -23,6 +23,11 @@
 import re
 
 from swagger_model import *
+
+try:
+    from collections import OrderedDict
+except ImportError:
+    from odict import OrderedDict
 
 
 def simple_name(name):
@@ -114,6 +119,7 @@
         """Gets count of children.
         """
         return len(self.__children)
+
 
 class AsteriskProcessor(SwaggerPostProcessor):
     """A SwaggerPostProcessor which adds fields needed to generate Asterisk
@@ -202,10 +208,11 @@
         return model
 
     def process_property(self, prop, context):
-	if "-" in prop.name:
+        if "-" in prop.name:
             raise SwaggerError("Property names cannot have dashes", context)
         if prop.name != prop.name.lower():
-            raise SwaggerError("Property name should not be lowercase", context)
+            raise SwaggerError("Property name should not be lowercase",
+                               context)
 
     def process_type(self, swagger_type, context):
         swagger_type.c_name = snakify(swagger_type.name)

Modified: team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py?view=diff&rev=392403&r1=392402&r2=392403
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/make_ari_stubs.py Fri Jun 21 00:39:29 2013
@@ -40,7 +40,7 @@
     """
     return os.path.join(TOPDIR, file)
 
-WIKI_PREFIX='Asterisk 12'
+WIKI_PREFIX = 'Asterisk 12'
 
 API_TRANSFORMS = [
     Transform(rel('api.wiki.mustache'),

Modified: team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py?view=diff&rev=392403&r1=392402&r2=392403
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py Fri Jun 21 00:39:29 2013
@@ -33,14 +33,9 @@
 import sys
 import traceback
 
-try:
-    from collections import OrderedDict
-except ImportError:
-    from odict import OrderedDict
-
-SWAGGER_VERSIONS=["1.1", "1.2"]
-
-SWAGGER_PRIMITIVES=[
+SWAGGER_VERSIONS = ["1.1", "1.2"]
+
+SWAGGER_PRIMITIVES = [
     'void',
     'string',
     'boolean',
@@ -52,6 +47,7 @@
     'Date',
     'DISCRIMINATOR',
 ]
+
 
 class Stringify(object):
     """Simple mix-in to make the repr of the model classes more meaningful.
@@ -294,6 +290,7 @@
         self.code = err_json.get('code')
         self.reason = err_json.get('reason')
         return self
+
 
 class SwaggerType(Stringify):
     """Model of a data type.
@@ -327,6 +324,7 @@
         self.is_primitive = self.singular_name in SWAGGER_PRIMITIVES
         processor.process_type(self, context)
         return self
+
 
 class Operation(Stringify):
     """Model of an operation on an API
@@ -491,7 +489,8 @@
             Property(k).load(j, processor, context) for (k, j) in props]
         self.__properties = sorted(self.__properties, key=lambda p: p.name)
 
-        discriminators = [p for p in self.__properties if p.type.is_discriminator]
+        discriminators = [
+            p for p in self.__properties if p.type.is_discriminator]
         if len(discriminators) > 1:
             raise SwaggerError("Model may have at most one discriminator",
                                context)
@@ -499,7 +498,8 @@
         if discriminators:
             self.__discriminator = discriminators[0]
 
-        self.model_json = json.dumps(model_json, indent=2, separators=(',', ': '))
+        self.model_json = json.dumps(model_json,
+                                     indent=2, separators=(',', ': '))
 
         processor.process_model(self, context)
         return self
@@ -533,7 +533,7 @@
         """Returns the full list of all subtypes.
         """
         res = self.__subtypes + \
-            [subsubtypes for subtype in self.__subtypes \
+            [subsubtypes for subtype in self.__subtypes
              for subsubtypes in subtype.subtypes()]
         return sorted(res, key=lambda m: m.id)
 
@@ -541,6 +541,7 @@
         """Returns True if type has any subtypes.
         """
         return len(self.subtypes()) > 0
+
 
 class ApiDeclaration(Stringify):
     """Model class for an API Declaration.
@@ -594,7 +595,7 @@
         """
         # If the version doesn't match, all bets are off.
         self.swagger_version = api_decl_json.get('swaggerVersion')
-        context = context.next(version = self.swagger_version)
+        context = context.next(version=self.swagger_version)
         if not self.swagger_version in SWAGGER_VERSIONS:
             raise SwaggerError(
                 "Unsupported Swagger version %s" % swagger_version, context)
@@ -610,8 +611,8 @@
         self.apis = [
             Api().load(j, processor, context) for j in api_json]
         models = api_decl_json.get('models').items() or []
-        self.models = [
-            Model().load(id, json, processor, context) for (id, json) in models]
+        self.models = [Model().load(id, json, processor, context)
+                       for (id, json) in models]
         self.models = sorted(self.models, key=lambda m: m.id)
         # Now link all base/extended types
         model_dict = dict((m.id, m) for m in self.models)

Modified: team/dlee/ari-event-remodel2/rest-api-templates/transform.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/transform.py?view=diff&rev=392403&r1=392402&r2=392403
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/transform.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/transform.py Fri Jun 21 00:39:29 2013
@@ -21,6 +21,7 @@
 import tempfile
 import filecmp
 import shutil
+
 
 class Transform(object):
     """Transformation for template to code.




More information about the asterisk-commits mailing list