code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
"""Statistics analyzer for HotShot."""
import profile
import pstats
import hotshot.log
from hotshot.log import ENTER, EXIT
def load(filename):
return StatsLoader(filename).load()
class StatsLoader:
def __init__(self, logfn):
self._logfn = logfn
self._code = {}
self._stack = []
... | Python |
import _hotshot
import os.path
import parser
import symbol
from _hotshot import \
WHAT_ENTER, \
WHAT_EXIT, \
WHAT_LINENO, \
WHAT_DEFINE_FILE, \
WHAT_DEFINE_FUNC, \
WHAT_ADD_INFO
__all__ = ["LogReader", "ENTER", "EXIT", "LINE"]
ENTER = WHAT_ENTER
EXIT = WHAT_EXIT
LINE = WHAT_LINENO
... | Python |
"""High-perfomance logging profiler, mostly written in C."""
import _hotshot
from _hotshot import ProfilerError
from warnings import warnpy3k as _warnpy3k
_warnpy3k("The 'hotshot' module is not supported in 3.x, "
"use the 'profile' module instead.", stacklevel=2)
class Profile:
def __init__(self, logf... | Python |
import errno
import hotshot
import hotshot.stats
import sys
import test.pystone
def main(logfile):
p = hotshot.Profile(logfile)
benchtime, stones = p.runcall(test.pystone.pystones)
p.close()
print "Pystone(%s) time for %d passes = %g" % \
(test.pystone.__version__, test.pystone.LOOPS, bencht... | Python |
# Author: Steven J. Bethard <steven.bethard@gmail.com>.
"""Command-line parsing library
This module is an optparse-inspired command-line parsing library that:
- handles both optional and positional arguments
- produces highly informative usage messages
- supports parsers that dispatch to sub-parsers
The... | Python |
"""Read and cache directory listings.
The listdir() routine returns a sorted list of the files in a directory,
using a cache to avoid reading the directory more often than necessary.
The annotate() routine appends slashes to directories."""
from warnings import warnpy3k
warnpy3k("the dircache module has been removed i... | Python |
"""Backport of importlib.import_module from 3.x."""
# While not critical (and in no way guaranteed!), it would be nice to keep this
# code compatible with Python 2.3.
import sys
def _resolve_name(name, package, level):
"""Return the absolute name of the module to be imported."""
if not hasattr(package, 'rindex... | Python |
# Access WeakSet through the weakref module.
# This code is separated-out because it is needed
# by abc.py to load everything else at startup.
from _weakref import ref
__all__ = ['WeakSet']
class _IterationGuard(object):
# This context manager registers itself in the current iterators of the
# weak containe... | Python |
import kf_lib_v2_2 as lib
import gzip
import urllib2
import thread
import time
WX_base = "http://aviationweather.gov/adds/dataserver_current/current/%s.cache.csv.gz"
WX_ADDRESSES = dict(metar="metars", pirep="aircraftreports",
taf="tafs", airmet="airsigmets")
... | Python |
"""*****************************************************************************
WARNING
Copyright 2012 Hamilton Sundstrand Corporation. This document is the
property of Hamilton Sundstrand Corporation ("HSC"). You may not possess,
use, copy or disclose this document or ... | Python |
# -*- coding: iso-8859-15 -*-
import vue
import flocking
import SETTINGS
class Controleur(object):
def __init__(self):
self.modele = flocking.Modele(self)
self.vue = vue.Vue(self)
self.loopControle()
self.vue.root.mainloop()
def loopCon... | Python |
# -*- coding: iso-8859-15 -*-
import moteur
import SETTINGS
from Tkinter import *
class Vue(object):
def __init__(self, ctrl):
self.ctrl = ctrl
self.root = Tk()
self.frameSettings()
self.canvas = Canvas(self.root, width=SETTINGS.LARGEUR, height=SETTINGS.HAUTEUR, bd=2, re... | Python |
# -*- coding: iso-8859-15 -*-
"@author: Benoit L.-Dufresne"
import random
import math
class Camera(object):
def __init__(self,x=0,y=0,z=-200, roll=0, yaw=0, pitch=0):
self.x = x
self.y = y
self.z = z
self.roll = roll #Roll: tourner autour de l'axe z (se toucher l'epau... | Python |
#! /usr/bin/env python
# flickrwatcher - Keep track of your friends' flickr photos.
# Copyright (C) 2008 Joseph G. Echeverria (joey42+flickrwatcher@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
#! /usr/bin/env python
# flickrwatcher - Keep track of your friends' flickr photos.
# Copyright (C) 2008 Joseph G. Echeverria (joey42+flickrwatcher@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
#! /usr/bin/env python
import os, sys, shutil, time, traceback
import urllib2
import flickrapi
import sqlite3
apiKey = 'e597cdeedb619f3f47ca999cd6f42149'
apiSecret = '578a2ab88db7e31b'
class NotConnectedException(Exception):
def __init__(self, db):
self.db = db
def __str__(self):
retu... | Python |
#! /usr/bin/env python
import os, sys, shutil, time, traceback
import urllib2
import flickrapi
import sqlite3
apiKey = 'e597cdeedb619f3f47ca999cd6f42149'
apiSecret = '578a2ab88db7e31b'
class NotConnectedException(Exception):
def __init__(self, db):
self.db = db
def __str__(self):
retu... | Python |
#! /usr/bin/env python
import os, sys, shutil
import urllib2
import flickrapi
import sqlite3
api_key = 'e597cdeedb619f3f47ca999cd6f42149'
api_secret = '578a2ab88db7e31b'
dbconn = sqlite3.connect('flickrwatcher.db')
cursor = dbconn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS watch (username text, user... | Python |
#! /usr/bin/env python
import os, sys, shutil
import urllib2
import flickrapi
import sqlite3
api_key = 'e597cdeedb619f3f47ca999cd6f42149'
api_secret = '578a2ab88db7e31b'
dbconn = sqlite3.connect('flickrwatcher.db')
cursor = dbconn.cursor()
cursor.execute('CREATE TABLE IF NOT EXISTS watch (username text, user... | Python |
#! /usr/bin/env python
# flickrwatcher - Keep track of your friends' flickr photos.
# Copyright (C) 2008 Joseph G. Echeverria (joey42+flickrwatcher@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
#! /usr/bin/env python
# flickrwatcher - Keep track of your friends' flickr photos.
# Copyright (C) 2008 Joseph G. Echeverria (joey42+flickrwatcher@gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
# Django settings for moviering project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to data... | Python |
from google.appengine.api import users
from google.appengine.ext import db
from common import *
import datetime
string_encoding = 'latin1'
class Dude(db.Model):
email = db.StringProperty()
nickname = db.StringProperty()
homepage = db.StringProperty()
created_on = db.DateTimeProperty(auto_no... | Python |
import types
string_encoding = 'latin1'
def st(s):
return unicode(s, string_encoding)
status_dict = {
1 : 'Ordered',
2 : 'Available',
3 : 'Unavailable',
4 : 'Wanted',
5 : 'Review'
}
media_dict = {
1: 'Blu-ray',
2: 'DVD',
3: 'Other'
}
genre_dict = {
1: '... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll ha... | Python |
from django.conf.urls.defaults import *
from feeds import LatestEntries
latest_feeds = {
'latest': LatestEntries,
'categories': LatestEntries,
}
urlpatterns = patterns('',
(r'^$', 'moviering.moviering.views.index'),
(r'profile/$', 'moviering.moviering.views.profile'),
#(r'newsletter/$',... | Python |
from django.contrib.syndication.feeds import Feed
from moviering.views import get_movies
class LatestEntries(Feed):
title = "Movie Ring"
link = "/"
description = "Some movies."
def items(self):
return get_flicks()
| Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll ha... | Python |
import os,sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'moviering.settings'
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Force Django to reload its settings.
from django.conf import settings
settings._target = None
import django.core.handlers.wsgi
import django.core.signals
i... | Python |
import multiprocessing
| Python |
# -*- coding: utf-8 -*-
from ragendja.settings_pre import *
# Increase this when you update your media on the production site, so users
# don't have to refresh their cache. By setting this your MEDIA_URL
# automatically becomes /media/MEDIA_VERSION/
MEDIA_VERSION = 1
# By hosting media on a different domain we can ge... | Python |
# Django settings for moviering project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '' # Or path to data... | Python |
from google.appengine.api import users
from google.appengine.ext import db
from common import *
import datetime
string_encoding = 'latin1'
class Dude(db.Model):
email = db.StringProperty()
nickname = db.StringProperty()
homepage = db.StringProperty()
created_on = db.DateTimeProperty(auto_no... | Python |
import types
string_encoding = 'latin1'
def st(s):
return unicode(s, string_encoding)
status_dict = {
1 : 'Ordered',
2 : 'Available',
3 : 'Unavailable',
4 : 'Wanted',
5 : 'Review'
}
media_dict = {
1: 'Blu-ray',
2: 'DVD',
3: 'Other'
}
genre_dict = {
1: '... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll ha... | Python |
from django.conf.urls.defaults import *
from feeds import LatestEntries
latest_feeds = {
'latest': LatestEntries,
'categories': LatestEntries,
}
urlpatterns = patterns('',
(r'^$', 'moviering.moviering.views.index'),
(r'profile/$', 'moviering.moviering.views.profile'),
#(r'newsletter/$',... | Python |
from django.contrib.syndication.feeds import Feed
from moviering.views import get_movies
class LatestEntries(Feed):
title = "Movie Ring"
link = "/"
description = "Some movies."
def items(self):
return get_flicks()
| Python |
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll ha... | Python |
from ragendja.settings_post import settings
settings.add_app_media('combined-%(LANGUAGE_CODE)s.js',
'myapp/code.js',
)
| Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
rootpatterns = patterns('',
(r'^person/', include('myapp.urls')),
)
| Python |
# -*- coding: utf-8 -*-
from django.db.models import permalink, signals
from google.appengine.ext import db
from ragendja.dbutils import cleanup_relations
class Person(db.Model):
"""Basic user profile with personal details."""
first_name = db.StringProperty(required=True)
last_name = db.StringProperty(requ... | Python |
# -*- coding: utf-8 -*-
from django import forms
from django.contrib.auth.models import User
from django.core.files.uploadedfile import UploadedFile
from django.utils.translation import ugettext_lazy as _, ugettext as __
from myapp.models import Person, File, Contract
from ragendja.auth.models import UserTraits
from ra... | Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
urlpatterns = patterns('myapp.views',
(r'^create_admin_user$', 'create_admin_user'),
(r'^$', 'list_people'),
(r'^create/$', 'add_person'),
(r'^show/(?P<key>.+)$', 'show_person'),
(r'^edit/(?P<key>.+)$', 'edit_person'),
(r'^delete/(... | Python |
# -*- coding: utf-8 -*-
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django.http import HttpResponse, Http404
from django.views.generic.list_detail import object_list, object_detail
from django.views.generic.create_update import create_object, delete_object, \
update... | Python |
from django.contrib import admin
from myapp.models import Person, File
class FileInline(admin.TabularInline):
model = File
class PersonAdmin(admin.ModelAdmin):
inlines = (FileInline,)
list_display = ('first_name', 'last_name')
admin.site.register(Person, PersonAdmin)
| Python |
#!/usr/bin/env python
if __name__ == '__main__':
from common.appenginepatch.aecmd import setup_env
setup_env(manage_py_env=True)
# Recompile translation files
from mediautils.compilemessages import updatemessages
updatemessages()
# Generate compressed media files for manage.py update
impor... | Python |
import os,sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'moviering.settings'
# Google App Engine imports.
from google.appengine.ext.webapp import util
# Force Django to reload its settings.
from django.conf import settings
settings._target = None
import django.core.handlers.wsgi
import django.core.signals
i... | Python |
from ragendja.settings_post import settings
settings.add_app_media('combined-%(LANGUAGE_DIR)s.css',
'blueprintcss/reset.css',
'blueprintcss/typography.css',
'blueprintcss/forms.css',
'blueprintcss/grid.css',
'blueprintcss/lang-%(LANGUAGE_DIR)s.css',
)
settings.add_app_media('combined-print-%(LANGUAG... | Python |
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from ragendja.urlsauto import urlpatterns
from ragendja.auth.urls import urlpatterns as auth_patterns
from myapp.forms import UserRegistrationForm
from django.contrib import admin
admin.autodiscover()
handler500 = 'ragendja.views.server_error'
urlpatter... | Python |
from ragendja.settings_post import settings
if not hasattr(settings, 'ACCOUNT_ACTIVATION_DAYS'):
settings.ACCOUNT_ACTIVATION_DAYS = 30
| Python |
from django.conf.urls.defaults import *
rootpatterns = patterns('',
(r'^account/', include('registration.urls')),
)
| Python |
import datetime
import random
import re
import sha
from google.appengine.ext import db
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.db import models
from django.template.loader import render_to_string
from django.utils.translatio... | Python |
"""
Forms and validation code for user registration.
"""
from django.contrib.auth.models import User
from django import forms
from django.utils.translation import ugettext_lazy as _
from registration.models import RegistrationProfile
# I put this on all required fields, because it's easier to pick up
# on them wit... | Python |
"""
Unit tests for django-registration.
These tests assume that you've completed all the prerequisites for
getting django-registration running in the default setup, to wit:
1. You have ``registration`` in your ``INSTALLED_APPS`` setting.
2. You have created all of the templates mentioned in this
application's doc... | Python |
"""
URLConf for Django user registration and authentication.
If the default behavior of the registration views is acceptable to
you, simply use a line like this in your root URLConf to set up the
default URLs for registration::
(r'^accounts/', include('registration.urls')),
This will also automatically set up th... | Python |
"""
A management command which deletes expired accounts (e.g.,
accounts which signed up but never activated) from the database.
Calls ``RegistrationProfile.objects.delete_expired_users()``, which
contains the actual logic for determining which accounts are deleted.
"""
from django.core.management.base import NoArgsC... | Python |
"""
Views which allow users to create and activate accounts.
"""
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from registration.forms import Registr... | Python |
from django.contrib import admin
from registration.models import RegistrationProfile
class RegistrationAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'activation_key_expired')
search_fields = ('user__username', 'user__first_name')
admin.site.register(RegistrationProfile, RegistrationAdmin)
| Python |
from django.dispatch import Signal
# A new user has registered.
user_registered = Signal(providing_args=["user"])
# A user has activated his or her account.
user_activated = Signal(providing_args=["user"])
| Python |
import multiprocessing
| Python |
# -*- coding: utf-8 -*-
import os, sys
COMMON_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
PROJECT_DIR = os.path.dirname(COMMON_DIR)
ZIP_PACKAGES_DIRS = (os.path.join(PROJECT_DIR, 'zip-packages'),
os.path.join(COMMON_DIR, 'zip-packages'))
# Overrides for os.environ
env_ext = {... | Python |
#!/usr/bin/env python
if __name__ == '__main__':
from common.appenginepatch.aecmd import setup_env
setup_env(manage_py_env=True)
# Recompile translation files
from mediautils.compilemessages import updatemessages
updatemessages()
# Generate compressed media files for manage.py update
impor... | Python |
# -*- coding: utf-8 -*-
import os, sys
# Add current folder to sys.path, so we can import aecmd.
# App Engine causes main.py to be reloaded if an exception gets raised
# on the first request of a main.py instance, so don't add current_dir multiple
# times.
current_dir = os.path.abspath(os.path.dirname(__file__))
if cu... | Python |
# Empty file neeed to make this a Django app.
| Python |
#!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Python |
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
from google.appengine.ext import db
| Python |
# -*- coding: utf-8 -*-
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext as _
from ragendja.template import render_to_response
| Python |
#!/usr/bin/python2.4
#
# Copyright 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Python |
# -*- coding: utf-8 -*-
from django.db.models import signals
from django.test import TestCase
from ragendja.dbutils import cleanup_relations
from ragendja.testutils import ModelTestCase
from google.appengine.ext import db
from google.appengine.ext.db.polymodel import PolyModel
from datetime import datetime
# Test clas... | Python |
# -*- coding: utf-8 -*-
# Unfortunately, we have to fix a few App Engine bugs here because otherwise
# not all of our features will work. Still, we should keep the number of bug
# fixes to a minimum and report everything to Google, please:
# http://code.google.com/p/googleappengine/issues/list
from google.appengine.ex... | Python |
from google.appengine.api import apiproxy_stub_map
from google.appengine.ext import db
from django.dispatch import Signal
from django.db.models import signals
from django.utils._threading_local import local
from functools import wraps
# Add signals which can be run after a transaction has been committed
signals.post_... | Python |
from google.appengine.api import apiproxy_stub_map
import os, sys
have_appserver = bool(apiproxy_stub_map.apiproxy.GetStub('datastore_v3'))
if have_appserver:
appid = os.environ.get('APPLICATION_ID')
else:
try:
from google.appengine.tools import dev_appserver
from aecmd import PROJECT_DIR
... | Python |
from google.appengine.api.memcache import *
| Python |
from ragendja.settings_post import settings
from appenginepatcher import have_appserver, on_production_server
if have_appserver and not on_production_server and \
settings.MEDIA_URL.startswith('/'):
if settings.ADMIN_MEDIA_PREFIX.startswith(settings.MEDIA_URL):
settings.ADMIN_MEDIA_PREFIX = '/genera... | Python |
# -*- coding: utf-8 -*-
from django.conf import settings
from django.utils.simplejson import dumps
from os.path import getmtime
import os, codecs, shutil, logging, re
class MediaGeneratorError(Exception):
pass
path_re = re.compile(r'/[^/]+/\.\./')
MEDIA_VERSION = unicode(settings.MEDIA_VERSION)
COMPRESSOR = os.p... | Python |
# -*- coding: utf-8 -*-
from os.path import getmtime
import codecs, os
def updatemessages():
from django.conf import settings
if not settings.USE_I18N:
return
from django.core.management.commands.compilemessages import compile_messages
if any([needs_update(path) for path in settings.LOCALE_PATH... | Python |
# -*- coding: utf-8 -*-
"""
This app combines media files specified in the COMBINE_MEDIA setting into one
single file. It's a dictionary mapping the combined name to a tuple of files
that should be combined:
COMBINE_MEDIA = {
'global/js/combined.js': (
'global/js/main.js',
'app/js/other.js',
),... | Python |
# -*- coding: utf-8 -*-
from django.core.management.base import NoArgsCommand, CommandError
from optparse import make_option
import os, cStringIO, gzip, mimetypes
class Command(NoArgsCommand):
help = 'Uploads your _generated_media folder to Amazon S3.'
option_list = NoArgsCommand.option_list + (
make_o... | Python |
# -*- coding: utf-8 -*-
from django.http import HttpResponse, Http404
from django.views.decorators.cache import cache_control
from mediautils.generatemedia import get_targets, get_copy_targets, \
get_target_content, get_media_dirs
from mimetypes import guess_type
from ragendja.template import render_to_response
@c... | Python |
# -*- coding: utf-8 -*-
from django.conf import settings
from mediautils.views import get_file
class MediaMiddleware(object):
"""Returns media files.
This is a middleware, so it can handle the request as early as possible
and thus with minimum overhead."""
def process_request(self, request):
... | Python |
from django.conf import settings
from django.core.cache import cache
from django.contrib.sites.models import Site
from ragendja.dbutils import db_create
from ragendja.pyutils import make_tls_property
_default_site_id = getattr(settings, 'SITE_ID', None)
SITE_ID = settings.__class__.SITE_ID = make_tls_property()
class... | Python |
# -*- coding: utf-8 -*-
"""
Imports urlpatterns from apps, so we can have nice plug-n-play installation. :)
"""
from django.conf.urls.defaults import *
from django.conf import settings
IGNORE_APP_URLSAUTO = getattr(settings, 'IGNORE_APP_URLSAUTO', ())
check_app_imports = getattr(settings, 'check_app_imports', None)
u... | Python |
from django.conf import settings
import os
def import_module(module_name):
return __import__(module_name, {}, {}, [''])
def import_package(package_name):
package = [import_module(package_name)]
if package[0].__file__.rstrip('.pyc').rstrip('.py').endswith('__init__'):
package.extend([import_module(... | Python |
# -*- coding: utf-8 -*-
from django.utils._threading_local import local
def make_tls_property(default=None):
"""Creates a class-wide instance property with a thread-specific value."""
class TLSProperty(object):
def __init__(self):
self.local = local()
def __get__(self, instance, cl... | Python |
# -*- coding: utf-8 -*-
from django.test import TestCase
from google.appengine.ext import db
from pyutils import object_list_to_table, equal_lists
import os
class ModelTestCase(TestCase):
"""
A test case for models that provides an easy way to validate the DB
contents against a given list of row-values.
... | Python |
from copy import deepcopy
import re
from django import forms
from django.utils.datastructures import SortedDict, MultiValueDict
from django.utils.html import conditional_escape
from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode
from django.utils.safestring import mark_safe
from django.forms.... | Python |
# -*- coding: utf-8 -*-
from copy import deepcopy
from django.forms.forms import NON_FIELD_ERRORS
from django.template import Library
from django.utils.datastructures import SortedDict
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from ragendja.dbutils import prefetch_... | Python |
# -*- coding: utf-8 -*-
from django.conf import settings
from django.template import Library
from django.utils.html import escape
from google.appengine.api import users
register = Library()
@register.simple_tag
def google_login_url(redirect=settings.LOGIN_REDIRECT_URL):
return escape(users.create_login_url(redire... | Python |
from django.contrib.auth.models import *
from django.contrib.auth.models import DjangoCompatibleUser as User
| Python |
# -*- coding: utf-8 -*-
"""
Provides basic set of auth urls.
"""
from django.conf.urls.defaults import *
from django.conf import settings
urlpatterns = patterns('')
LOGIN = '^%s$' % settings.LOGIN_URL.lstrip('/')
LOGOUT = '^%s$' % settings.LOGOUT_URL.lstrip('/')
# If user set a LOGOUT_REDIRECT_URL we do a redirect.
... | Python |
# -*- coding: utf-8 -*-
from google.appengine.api import users
def google_user(request):
return {'google_user': users.get_current_user()}
| Python |
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from google.appengine.api import users
from google.appengine.ext import db
from ragendja.auth.models import EmailUserTraits
class GoogleUserTraits(EmailUserTraits):
@classmethod
def get_djangouser_for_user(cls, user):
... | Python |
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required
from functools import wraps
from ragendja.auth.views import google_redirect_to_login
from ragendja.template import render_to_response
def staff_only(view):
"""
Decorator that requires user.is_staff. Otherwise renders no_access.ht... | Python |
# -*- coding: utf-8 -*-
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.views import login, logout
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext as _
from google.appengine.api import users
from ragendja.template i... | Python |
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
class UserAdmin(admin.ModelAdmin):
fieldsets = (
(_('Personal info'), {'fields': ('user',)}),
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'user_permissions')}),
(_('Important... | Python |
# Parts of this code are taken from Google's django-helper (license: Apache 2)
class LazyGoogleUser(object):
def __init__(self, middleware_class):
self._middleware_class = middleware_class
def __get__(self, request, obj_type=None):
if not hasattr(request, '_cached_user'):
from djan... | Python |
from django.utils.translation import ugettext_lazy as _
from google.appengine.ext import db
from ragendja.auth.google_models import GoogleUserTraits
class User(GoogleUserTraits):
"""User class that provides support for Django and Google Accounts."""
user = db.UserProperty()
user_id = db.StringProperty()
... | Python |
# -*- coding: utf-8 -*-
"""
This is a set of utilities for faster development with Django templates.
render_to_response() and render_to_string() use RequestContext internally.
The app_prefixed_loader is a template loader that loads directly from the app's
'templates' folder when you specify an app prefix ('app/templa... | Python |
# -*- coding: utf-8 -*-
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from django.http import HttpResponse
from django.utils import simplejson
from django.utils.encoding import force_unicode
from django.utils.functional import Promise
class LazyEncoder(DjangoJSONEncoder):
... | Python |
# -*- coding: utf-8 -*-
from django.http import HttpRequest
class RegisterVars(dict):
"""
This class provides a simplified mechanism to build context processors
that only add variables or functions without processing a request.
Your module should have a global instance of this class called 'regist... | Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.