Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

pep8

  • Loading branch information...
commit 257bddfef70e4a6679a2bf94b5d38be3cf673149 1 parent be5cc32
Wraithan (Chris McDonald) authored August 18, 2012
6  bin/client.py
@@ -25,9 +25,7 @@
25 25
 import slumber
26 26
 
27 27
 api = slumber.API("http://localhost:8000/api/v1/")
28  
-
29  
-LIMIT=500
30  
-
  28
+LIMIT = 500
31 29
 test_data = [
32 30
     ["rtd", "http://readthedocs.org"],
33 31
     ["google", "http://google.com"],
@@ -61,7 +59,7 @@
61 59
             print ret['slug']
62 60
 
63 61
     if sys.argv[1] == 'delete':
64  
-        ret =  api.hydra.get(limit=LIMIT)
  62
+        ret = api.hydra.get(limit=LIMIT)
65 63
         for ret in ret['objects']:
66 64
             slug = ret['slug']
67 65
             print slug,
12  src/hydra/api.py
@@ -14,26 +14,33 @@
14 14
 
15 15
 r = redis.StrictRedis.from_url(settings.REDIS_URL)
16 16
 
  17
+
17 18
 def make_slug(val, version="latest"):
18 19
     return "hydra:v1:redirects:%s:%s" % (version, val)
19 20
 
  21
+
20 22
 def remove_slug(val, version="latest"):
21 23
     return val.replace("hydra:v1:redirects:%s:" % version, "")
22 24
 
  25
+
23 26
 def save(slug, url, version="latest"):
24 27
     redis_slug = make_slug(slug, version)
25 28
     return r.zincrby(redis_slug, url, 1)
26 29
     #r.set(redis_slug, urls)
27 30
 
  31
+
28 32
 def get_range(pk, withscores=True):
29 33
     return r.zrange(make_slug(pk), 0, -1, withscores=withscores)
30 34
 
  35
+
31 36
 def get_keys(key):
32 37
     return r.keys(make_slug('%s' % key))
33 38
 
  39
+
34 40
 def delete(slug):
35 41
     return r.delete(make_slug(slug))
36 42
 
  43
+
37 44
 def get_urls(slug, count=None):
38 45
     ret_val = []
39 46
     # Could have defaulted to -1 but that is a less obvious API
@@ -141,6 +148,9 @@ def obj_delete_list(self, request=None, **kwargs):
141 148
             r.delete(slug)
142 149
 
143 150
     def override_urls(self):
  151
+        raw_url = r"^(?P<resource_name>%s)/(?P<pk>^(schema)[^/]+)/$"
144 152
         return [
145  
-            url(r"^(?P<resource_name>%s)/(?P<pk>^(schema)[^/]+)/$" % self._meta.resource_name, self.wrap_view('dispatch_detail'), name="api_dispatch_detail"),
  153
+            url(raw_url % self._meta.resource_name,
  154
+                self.wrap_view('dispatch_detail'),
  155
+                name="api_dispatch_detail"),
146 156
         ]
5  src/hydra/management/commands/import.py
@@ -8,14 +8,17 @@
8 8
 
9 9
 from hydra.api import r, save, make_slug
10 10
 
  11
+
11 12
 def safe_save(slug, url):
12 13
     if not r.keys(make_slug(slug)):
13 14
         save(slug, url)
14 15
 
  16
+
15 17
 class Command(NoArgsCommand):
16 18
     def handle_noargs(self, **options):
17 19
         read(os.path.join(settings.ROOT_DIR, 'django.inv'))
18 20
 
  21
+
19 22
 def read(file):
20 23
     urlpattern = 'http://django.readthedocs.org/en/latest/%s'
21 24
     f = open(file)
@@ -27,7 +30,7 @@ def read(file):
27 30
         inner_keys = data[top_key].keys()
28 31
         for inner_key in inner_keys:
29 32
             #print "INNER KEY: %s" % inner_key
30  
-            project, version, url, title =  data[top_key][inner_key]
  33
+            project, version, url, title = data[top_key][inner_key]
31 34
             url_key = url.split('#')[1]
32 35
             if ":" in url_key:
33 36
                 #This dumps junk data into the url namespace we don't need
1  src/zzz/urls.py
@@ -23,4 +23,3 @@
23 23
     url(r'^_analytics/', include('analytics.urls')),
24 24
     url(r'^', include('hydra.urls.slug')),
25 25
 )
26  
-

0 notes on commit 257bddf

Please sign in to comment.
Something went wrong with that request. Please try again.