First 2to3 results

This commit is contained in:
José Padilla 2014-05-13 09:25:42 -04:00
parent 816bde6f3f
commit 600de7b5da
3 changed files with 44 additions and 42 deletions

View File

@ -41,7 +41,7 @@ class NoseStatsd(Plugin):
timings[k].append(v[2])
counts = {}
for k, v in statsd.cache.items():
for k, v in list(statsd.cache.items()):
k = k.split('|')[0]
longest = max(longest, len(k))
counts.setdefault(k, [])

View File

@ -1,3 +1,4 @@
import collections
from django import http
from django.conf import settings
from django.views.decorators.csrf import csrf_exempt
@ -5,46 +6,47 @@ from django.views.decorators.http import require_http_methods
from django_statsd.clients import statsd
boomerang = {
'window.performance.navigation.redirectCount': 'nt_red_cnt',
'window.performance.navigation.type': 'nt_nav_type',
'window.performance.timing.connectEnd': 'nt_con_end',
'window.performance.timing.connectStart': 'nt_con_st',
'window.performance.timing.domComplete': 'nt_domcomp',
'window.performance.timing.domContentLoaded': 'nt_domcontloaded',
'window.performance.timing.domInteractive': 'nt_domint',
'window.performance.timing.domLoading': 'nt_domloading',
'window.performance.timing.domainLookupEnd': 'nt_dns_end',
'window.performance.timing.domainLookupStart': 'nt_dns_st',
'window.performance.timing.fetchStart': 'nt_fet_st',
'window.performance.timing.loadEventEnd': 'nt_load_end',
'window.performance.timing.loadEventStart': 'nt_load_st',
'window.performance.timing.navigationStart': 'nt_nav_st',
'window.performance.timing.redirectEnd': 'nt_red_end',
'window.performance.timing.redirectStart': 'nt_red_st',
'window.performance.timing.requestStart': 'nt_req_st',
'window.performance.timing.responseEnd': 'nt_res_end',
'window.performance.timing.responseStart': 'nt_res_st',
'window.performance.timing.unloadEventEnd': 'nt_unload_end',
'window.performance.timing.unloadEventStart': 'nt_unload_st'
'window.performance.navigation.redirectCount': 'nt_red_cnt',
'window.performance.navigation.type': 'nt_nav_type',
'window.performance.timing.connectEnd': 'nt_con_end',
'window.performance.timing.connectStart': 'nt_con_st',
'window.performance.timing.domComplete': 'nt_domcomp',
'window.performance.timing.domContentLoaded': 'nt_domcontloaded',
'window.performance.timing.domInteractive': 'nt_domint',
'window.performance.timing.domLoading': 'nt_domloading',
'window.performance.timing.domainLookupEnd': 'nt_dns_end',
'window.performance.timing.domainLookupStart': 'nt_dns_st',
'window.performance.timing.fetchStart': 'nt_fet_st',
'window.performance.timing.loadEventEnd': 'nt_load_end',
'window.performance.timing.loadEventStart': 'nt_load_st',
'window.performance.timing.navigationStart': 'nt_nav_st',
'window.performance.timing.redirectEnd': 'nt_red_end',
'window.performance.timing.redirectStart': 'nt_red_st',
'window.performance.timing.requestStart': 'nt_req_st',
'window.performance.timing.responseEnd': 'nt_res_end',
'window.performance.timing.responseStart': 'nt_res_st',
'window.performance.timing.unloadEventEnd': 'nt_unload_end',
'window.performance.timing.unloadEventStart': 'nt_unload_st'
}
types = {
'0': 'navigate',
'1': 'reload',
'2': 'back_forward',
'255': 'reserved'
'0': 'navigate',
'1': 'reload',
'2': 'back_forward',
'255': 'reserved'
}
# These are the default keys that we will try and record.
stick_keys = [
'window.performance.timing.domComplete',
'window.performance.timing.domInteractive',
'window.performance.timing.domLoading',
'window.performance.timing.loadEventEnd',
'window.performance.timing.responseStart',
'window.performance.navigation.redirectCount',
'window.performance.navigation.type',
'window.performance.timing.domComplete',
'window.performance.timing.domInteractive',
'window.performance.timing.domLoading',
'window.performance.timing.loadEventEnd',
'window.performance.timing.responseStart',
'window.performance.navigation.redirectCount',
'window.performance.navigation.type',
]
@ -70,7 +72,7 @@ def _process_summaries(start, keys):
'rendering': keys['window.performance.timing.loadEventEnd'] -
keys['window.performance.timing.domComplete'],
}
for k, v in calculated.items():
for k, v in list(calculated.items()):
# If loadEventEnd still does not get populated, we could end up with
# negative numbers here.
statsd.timing('window.performance.calculated.%s' % k, max(v, 0))
@ -152,7 +154,7 @@ def record(request):
guard = getattr(settings, 'STATSD_RECORD_GUARD', None)
if guard:
if not callable(guard):
if not isinstance(guard, collections.Callable):
raise ValueError('STATSD_RECORD_GUARD must be callable')
result = guard(request)
if result:

View File

@ -40,8 +40,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'django-statsd'
copyright = u'2012, Andy McKay'
project = 'django-statsd'
copyright = '2012, Andy McKay'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -183,8 +183,8 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-statsd.tex', u'django-statsd Documentation',
u'Andy McKay', 'manual'),
('index', 'django-statsd.tex', 'django-statsd Documentation',
'Andy McKay', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -213,8 +213,8 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-statsd', u'django-statsd Documentation',
[u'Andy McKay'], 1)
('index', 'django-statsd', 'django-statsd Documentation',
['Andy McKay'], 1)
]
# If true, show URL addresses after external links.
@ -227,7 +227,7 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'django-statsd', u'django-statsd Documentation', u'Andy McKay',
('index', 'django-statsd', 'django-statsd Documentation', 'Andy McKay',
'django-statsd', 'One line description of project.', 'Miscellaneous'),
]