Commits

Yohann Gabory  committed b04225b

pep8 check

  • Participants
  • Parent commits d214779

Comments (0)

Files changed (8)

File mustachebox/backends/base_backend.py

         self.name = kwargs.pop('name')
         self.data = json.dumps(self.fetch(self.name, **kwargs))
 
-
     def fetch(self, method, **kwargs):
         """
         Return a set of data formated information

File mustachebox/backends/example_backend.py

 import random
 from mustachebox.backends import BaseBackend
 
+
 def time_serie(**kwargs):
     """
     Render a time serie
     for i in range(2):
         for k, v in resp.iteritems():
             v.append(int((random.random() * random.random()) * 10000))
-        resp['label'] = ['year','sales', 'expenses']
+        resp['label'] = ['year', 'sales', 'expenses']
     return resp
 
 
-
 class Backend(BaseBackend):
     """
     A backend get data formated as mustache need them.
         for elem in words:
             activities.append([elem, int(random.random() * 10)])
 
-        return {'label' : label, 'activities': activities}
+        return {'label': label, 'activities': activities}
 
     def line_chart(self):
         """
         for i in range(1500):
             date += datetime.timedelta(days=2)
             response.append({
-                    'date': time.mktime(date.timetuple()) * 1000,
-                    'value': (i*10) + int(random.random()*1000)
-                    })
+                'date': time.mktime(date.timetuple()) * 1000,
+                'value': (i * 10) + int(random.random() * 1000)})
         return response

File mustachebox/backends/monitoring_backend.py

 import random
 from mustachebox.backends import BaseBackend
 
+
 def time_serie(**kwargs):
     """
     Render a time serie
     for i in range(2):
         for k, v in resp.iteritems():
             v.append(int((random.random() * random.random()) * 10000))
-        resp['label'] = ['year','sales', 'expenses']
+        resp['label'] = ['year', 'sales', 'expenses']
     return resp
 
 
-
 class Backend(BaseBackend):
     """
     A backend get data formated as mustache need them.
                      'La2': record.La2,
                      'La3': record.La3,
                      'date': record.date
-                     }
-                    )
+                     })
         self.template = "crossfilter"
         return records
 
+
 class Record(object):
     """
     Metric about an instance.
     def __init__(self, instance, date):
         """ instance is just a name to identify a set of data """
         self.instance = instance
-        self.CPU  = random.random() * 100
-        self.RAM  = random.random() * 100
+        self.CPU = random.random() * 100
+        self.RAM = random.random() * 100
         self.La1 = random.random() * 10
         self.La2 = random.random() * 10
         self.La3 = random.random() * 10
         self.date = time.mktime(date.timetuple())
 
 
-
 class Instance(object):
     """
     An instance to identify metrics.
     """
     def __init__(self, name):
         self.name = "instance_%i" % name
-
-        

File mustachebox/backends/tutorial_backend.py

 from mustachebox.backends import BaseBackend
 import random
 
+
 class Backend(BaseBackend):
-    
+
     def test_method(self, **kwargs):
         """
           render a simple time serie suitable for javascript graphs :
         for i in range(2):
             for k, v in resp.iteritems():
                     v.append(int((random.random() * random.random()) * 10000))
-        resp['label'] = ['year','sales', 'expenses']
+        resp['label'] = ['year', 'sales', 'expenses']
         return resp

File mustachebox/templatetags/__init__.py

-

File mustachebox/templatetags/graph.py

 
 register = template.Library()
 
+
 def do_graph_node(parser, token):
     """
     render a GraphNode with the right parameters
     def render(self, context):
         backend = __import__(
             settings.GRAPH_BACKEND,
-            fromlist=["Backend"]
-            )
+            fromlist=["Backend"])
         klass = getattr(backend, "Backend")
         try:
             name = self.method.resolve(context)
             name = unicode(self.method)
         self.obj = klass(name=name,
                          *self.args)
-        
+
         t = template.loader.get_template(
-            'mustachebox/tags/{0}.html'.format(self.obj.template)
-            )
+            'mustachebox/tags/{0}.html'.format(self.obj.template))
 
         return t.render(
             template.Context(
                 {'object': self.obj,
-                 "STATIC_URL":context['STATIC_URL']},
-                 autoescape=context.autoescape)
-            )
+                 "STATIC_URL": context['STATIC_URL']},
+                autoescape=context.autoescape))
 
 register.tag('graph', do_graph_node)

File mustachebox/urls.py

 
 urlpatterns = patterns(
     '',
-#    url(r'^$', HomeView.as_view(), name='home'),
     url(r'^all/$', GraphListView.as_view()),
     url(r'^template_tag_test/$', TemplateView.as_view(
         template_name="mustachebox/templatetags_test.html")),

File mustachebox/views.py

 from django.conf import settings
 from django import http
 
+
 class GraphListView(ListView):
     """
     This class return all the avalaible graphs in the current backend
         """
         backend = __import__(
             settings.GRAPH_BACKEND,
-            fromlist=["Backend"]
-            )
+            fromlist=["Backend"])
+
         klass = getattr(backend, "Backend")
         responses = []
         for k, v in klass.__dict__.iteritems():
 
 class GraphDetailView(DetailView):
     """
-    This class represent a graph data.
-    The data you will use to represent a graph may not be part of you application
-    nor your project. It can be somethin' commin' from an external API, a nosql backend, 
-    your cache backend and so one.
+    This class represent a graph data.  The data you will use to
+    represent a graph may not be part of you application nor your
+    project. It can be somethin' commin' from an external API, a nosql
+    backend, your cache backend and so one.
 
-    So GraphDetailView implement a "get object" method to retreive the data using the backend you have define
-    in your settings.
+    So GraphDetailView implement a "get object" method to retreive the
+    data using the backend you have define in your settings.
 
     Look at mustachebox.backends for an example backend
     """
+
     def get_object(self):
         backend = __import__(
             settings.GRAPH_BACKEND,
-            fromlist=["Backend"]
-            )
+            fromlist=["Backend"])
         klass = getattr(backend, "Backend")
         try:
             obj = klass(**self.kwargs)
         except AttributeError:
             raise http.Http404
         return obj
-    
-    def get_context_object_name(self,obj):
+
+    def get_context_object_name(self, obj):
         return "object"
 
     def get_template_names(self):
     def render_to_response(self, context, **response_kwargs):
         if self.request.is_ajax():
             return http.HttpResponse(context['object'].data,
-                                 content_type='application/json',
-                                 **response_kwargs)
-        return super(GraphDetailView, self).render_to_response(context, **response_kwargs)
+                                     content_type='application/json',
+                                     **response_kwargs)
+        return super(
+            GraphDetailView, self).render_to_response(
+                context,
+                **response_kwargs)