code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
import pygame, os
import newtest
class cursor:
def __init__(self):
# self.image = pygame.image.load("ttt.png")
# self.imagerect = self.image.get_rect(0,0,1,1)
self.imagerect = pygame.Rect(0,0,1,1)
def update(self):
self.imagerect.topleft = pygame.mou... | Python |
import pygame
from pygame.locals import *
import menu
if (__name__ == "__main__"):
pygame.init()
pygame.display.set_caption("--SHIT WAR--")
screen = pygame.display.set_mode((600, 400))
menu.Menu(screen)
| Python |
import pygame
import msg
import random
STARNUM = 80
MAXOBJ = 90
GUNFIRETOP = 130
TOTALFIRETOP = 140
class pcounter:
def __init__(self):
self.score = 0
class cplayer:
def __init__(self, playernum, screen, screen_width, screen_height, objlist, mid = True):
self.screen = screen
... | Python |
import pygame
class msgimage:
def __init__(self, msg, pos, size = 16):
self.msg = msg
self.font = pygame.font.Font(pygame.font.get_default_font(),size)
self.msgimage = self.font.render(msg, False, (255,255,255))
self.pos = pos
self.msgimagerect = self.msgimage.get_re... | Python |
import pygame
import random,sys,math
#virtical shotting game...
STARNUM = 80
MAXOBJ = 90
GUNFIRETOP = 130
TOTALFIRETOP = 140
class obj:
GUNFROFFSETV = 10
GUNFROFFSETH = 14
NON_TYPE = 0
GUN_FIRE = 1
ENEMY = 2
STAR = 3
FLAME1 = 4
FLAME2 =... | Python |
import pygame
import mynewobject,msg,player
import sys,random
pygame.init()
STARNUM = 80
MAXOBJ = 90
GUNFIRETOP = 130
TOTALFIRETOP = 140
def mkenemy(objlist, playerlist):
o = objlist[random.randint(STARNUM,MAXOBJ)]
if (o.type == o.NON_TYPE):
o.set_type(o.ENEMY, playerlist[random.randint... | Python |
# Python script to get both the data and resource fork from a BinHex encoded
# file.
# Author: Taro Muraoka
# Last Change: 2003 Oct 25
import sys
import binhex
input = sys.argv[1]
conv = binhex.HexBin(input)
info = conv.FInfo
out = conv.FName
out_data = out
out_rsrc = out + '.rsrcfork'
#print 'out_rsrc=' + out_rsrc
p... | Python |
from .resolver import resolver
from django.utils.importlib import import_module
def __repr__(self):
return '<%s, %s, %s, %s>' % (self.alias, self.col, self.field.name,
self.field.model.__name__)
from django.db.models.sql.where import Constraint
Constraint.__repr__ = __repr__
# TODO: manipulate a copy of ... | Python |
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.db.models.sql.constants import JOIN_TYPE, LHS_ALIAS, LHS_JOIN_COL, \
TABLE_NAME, RHS_JOIN_COL
from django.utils.tree import Node
from djangotoolbox.fields import ListField
from .lookups import StandardLookup
OR = 'OR'
#... | Python |
from django.db import models
from django.test import TestCase
from .api import register_index
from .lookups import StandardLookup
from .resolver import resolver
from djangotoolbox.fields import ListField
from datetime import datetime
import re
class ForeignIndexed2(models.Model):
name_fi2 = models.CharField(max_le... | Python |
from django.db import models
from djangotoolbox.fields import ListField
from copy import deepcopy
import re
regex = type(re.compile(''))
class LookupDoesNotExist(Exception):
pass
class LookupBase(type):
def __new__(cls, name, bases, attrs):
new_cls = type.__new__(cls, name, bases, attrs)
if n... | Python |
from django.conf import settings
from django.utils.importlib import import_module
def merge_dicts(d1, d2):
'''Update dictionary recursively. If values for a given key exist in both dictionaries and are dict-like they are merged.'''
for k, v in d2.iteritems():
# Try to merge the values as if they wer... | Python |
from django.conf import settings
from django.utils.importlib import import_module
from django.core.exceptions import ImproperlyConfigured
class Resolver(object):
def __init__(self):
self.backends = []
self.load_backends(getattr(settings, 'DBINDEXER_BACKENDS',
('dbinde... | Python |
def autodiscover():
from autoload import autodiscover as auto_discover
auto_discover('dbindexes')
def load_indexes():
from django.conf import settings
from django.utils.importlib import import_module
for name in getattr(settings, 'DB_INDEX_MODULES', ()):
import_module(name)
| Python |
from .lookups import LookupDoesNotExist, ExtraFieldLookup
from . import lookups as lookups_module
from .resolver import resolver
import inspect
# TODO: add possibility to add lookup modules
def create_lookup(lookup_def):
for _, cls in inspect.getmembers(lookups_module):
if inspect.isclass(cls) and issubcla... | Python |
from django import forms
class CommForm(forms.Form):
"""
TODO: evaluate message
"""
message = forms.CharField(widget=forms.Textarea, max_length=400)
class DealForm(forms.Form):
deal = forms.BooleanField(label='Seal The Deal?')
class CancelForm(forms.Form):
cancel = forms.BooleanField(label='Cancel The Dea... | Python |
from django.db import models
from userTools.models import user_profile
from itemTools.models import items
import datetime
import logging
# Create your models here.
class Comm(models.Model):
"""
status codes:
2 = Done!
1 = Waiting!
0 = Ongoing
-1 = Failed (Not urgent)
"""
buyer = models.ForeignKey(user_profi... | Python |
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 a... | Python |
from userTools.main import handle_login_register, user, handle_optional_login, myprofile_links
from userTools.models import user_profile
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from itemTools.models import items
from forms import CommForm, DealForm, CancelForm
from... | Python |
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('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 t... | Python |
import mimetypes
import os
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from django.conf import settings
from django.core.files.base import File
from django.core.files.storage import Storage
from django.core.files.uploadedfile import UploadedFile
from django.core.files... | Python |
# Initialize Django.
from djangoappengine import main
from django.utils.importlib import import_module
from django.conf import settings
# Load all models.py to ensure signal handling installation or index
# loading of some apps.
for app in settings.INSTALLED_APPS:
try:
import_module('%s.models' % app)
... | Python |
# Initialize Django
from djangoappengine import main
from google.appengine.ext.appstats.ui import app as application, main
if __name__ == '__main__':
main()
| Python |
# Initialize Django.
from djangoappengine import main
from google.appengine.ext.appstats.ui import app as application
| Python |
from django.test import TestCase
from .testmodels import OrderedModel
class OrderTest(TestCase):
def create_ordered_model_items(self):
pks = []
priorities = [5, 2, 9, 1]
for pk, priority in enumerate(priorities):
pk += 1
model = OrderedModel(pk=pk, priority=priori... | Python |
import datetime
import time
from django.db import models
from django.db.models import Q
from django.db.utils import DatabaseError
from django.test import TestCase
from django.utils import unittest
from google.appengine.api.datastore import Get, Key
from ..db.utils import get_cursor, set_cursor
from .testmodels impor... | Python |
from django.db import models
from django.db.utils import DatabaseError
from django.test import TestCase
class A(models.Model):
value = models.IntegerField()
class B(A):
other = models.IntegerField()
class BackendTest(TestCase):
def test_model_forms(self):
from django import forms
cla... | Python |
from django.db.models import F
from django.test import TestCase
from .testmodels import EmailModel
class TransactionTest(TestCase):
emails = ['app-engine@scholardocs.com', 'sharingan@uchias.com',
'rinnengan@sage.de', 'rasengan@naruto.com']
def setUp(self):
EmailModel(email=self.emails[... | Python |
import datetime
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.test import TestCase
from .testmodels import FieldsWithOptionsModel, OrderedModel, \
SelfReferenceModel
class NonReturnSetsTest(TestCase):
floats = [5.3, 2.6, 9.1, 1.58, 2.4]
emails = ['app-engine@... | Python |
import datetime
from django.test import TestCase
from django.db.utils import DatabaseError
from django.db.models.fields import NOT_PROVIDED
from google.appengine.api import users
from google.appengine.api.datastore import Get
from google.appengine.api.datastore_types import Text, Category, Email, Link, \
PhoneNum... | Python |
from __future__ import with_statement
import warnings
from django.db import connection, models
from django.db.utils import DatabaseError
from django.test import TestCase
from django.utils import unittest
from djangotoolbox.fields import ListField
class AutoKey(models.Model):
pass
class CharKey(models.Model):
... | Python |
from .backend import BackendTest
from .field_db_conversion import FieldDBConversionTest
from .field_options import FieldOptionsTest
from .filter import FilterTest
from .keys import KeysTest
from .not_return_sets import NonReturnSetsTest
from .order import OrderTest
from .transactions import TransactionTest
| Python |
from django.db import models
from djangotoolbox.fields import BlobField
from ..db.db_settings import get_indexes
class EmailModel(models.Model):
email = models.EmailField()
number = models.IntegerField(null=True)
class DateTimeModel(models.Model):
datetime = models.DateTimeField()
datetime_auto_no... | Python |
import datetime
from django.test import TestCase
from google.appengine.api.datastore import Get
from google.appengine.api.datastore_types import Text, Category, Email, \
Link, PhoneNumber, PostalAddress, Text, Blob, ByteString, GeoPt, IM, \
Key, Rating, BlobKey
from .testmodels import FieldsWithoutOptionsMod... | Python |
import logging
import os
import sys
def find_project_dir():
"""
Go through the path, and look for manage.py
"""
for path in sys.path:
abs_path = os.path.join(os.path.abspath(path), "manage.py")
if os.path.exists(abs_path):
return os.path.dirname(abs_path)
raise Runt... | Python |
# Initialize App Engine SDK if necessary.
try:
from google.appengine.api import apiproxy_stub_map
except ImportError:
from .boot import setup_env
setup_env()
from djangoappengine.utils import on_production_server, have_appserver
DEBUG = not on_production_server
TEMPLATE_DEBUG = DEBUG
ROOT_URLCONF = 'url... | Python |
# Python 2.5 CGI handler.
import os
import sys
from djangoappengine.main import application
from google.appengine.ext.webapp.util import run_wsgi_app
from djangoappengine.boot import setup_logging, env_ext
from django.conf import settings
path_backup = None
def real_main():
# Reset path and environment variabl... | Python |
import os
import sys
# Add parent folder to sys.path, so we can import boot.
# 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 project_dir
# multiple times.
project_dir = os.path.abspath(
os.path.dirname(os.path.dirname(os.path.dirnam... | Python |
import os
from google.appengine.api import apiproxy_stub_map
from google.appengine.api.app_identity import get_application_id
have_appserver = bool(apiproxy_stub_map.apiproxy.GetStub('datastore_v3'))
if have_appserver:
appid = get_application_id()
else:
try:
from google.appengine.tools import dev_ap... | Python |
from django.core.management import execute_from_command_line
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = "Runs a command with access to the remote App Engine production " \
"server (e.g. manage.py remote shell)."
args = "remotecommand"
def run_from_ar... | Python |
import logging
import time
import sys
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand
from ...boot import PROJECT_DIR
from ...utils import appconfig
PRE_DEPLOY_COMMANDS = ()
if 'mediagenerator' in settings.INSTALLED_APPS:
PRE_D... | Python |
from django.core.management.base import BaseCommand
from google.appengine.api import apiproxy_stub_map
from google.appengine.datastore import datastore_stub_util
from optparse import make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--noinput', action='store_f... | Python |
import logging
from optparse import make_option
import sys
from django.db import connections
from django.core.management.base import BaseCommand
from django.core.management.commands.runserver import BaseRunserverCommand
from django.core.exceptions import ImproperlyConfigured
from google.appengine.tools import dev_app... | Python |
from django.conf import settings
from django.http import HttpResponse
from django.utils.importlib import import_module
def warmup(request):
"""
Provides default procedure for handling warmup requests on App
Engine. Just add this view to your main urls.py.
"""
for app in settings.INSTALLED_APPS:
... | Python |
from functools import wraps
import sys
from django.db.models.fields import AutoField
from django.db.models.sql import aggregates as sqlaggregates
from django.db.models.sql.constants import LOOKUP_SEP, MULTI, SINGLE
from django.db.models.sql.where import AND, OR
from django.db.utils import DatabaseError, IntegrityError... | Python |
from django.db.models.sql.expressions import SQLEvaluator
from django.db.models.expressions import ExpressionNode
OPERATION_MAP = {
ExpressionNode.ADD: lambda x, y: x + y,
ExpressionNode.SUB: lambda x, y: x - y,
ExpressionNode.MUL: lambda x, y: x * y,
ExpressionNode.DIV: lambda x, y: x / y,
Expres... | Python |
import logging
import os
import time
from urllib2 import HTTPError, URLError
from google.appengine.ext.testbed import Testbed
from ..boot import PROJECT_DIR
from ..utils import appid, have_appserver
REMOTE_API_SCRIPTS = (
'$PYTHON_LIB/google/appengine/ext/remote_api/handler.py',
'google.appengine.ext.remote... | Python |
from djangotoolbox.db.creation import NonrelDatabaseCreation
from .db_settings import get_model_indexes
from .stubs import stub_manager
class DatabaseCreation(NonrelDatabaseCreation):
# For TextFields and XMLFields we'll default to the unindexable,
# but not length-limited, db.Text (db_type of "string" fiel... | Python |
from google.appengine.datastore.datastore_query import Cursor
from django.db import models, DEFAULT_DB_ALIAS
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.3, 2.4 fallback.
class CursorQueryMixin(object):
def clone(self, *args, **kwargs):
... | Python |
from django.conf import settings
from django.utils.importlib import import_module
# TODO: Add autodiscover() and make API more like dbindexer's
# register_index.
# TODO: Add support for eventual consistency setting on specific
# models.
_MODULE_NAMES = getattr(settings, 'GAE_SETTINGS_MODULES', ())
FIEL... | Python |
import datetime
import decimal
import logging
import os
import shutil
from django.db.utils import DatabaseError
from google.appengine.api.datastore import Delete, Query
from google.appengine.api.datastore_errors import BadArgumentError, \
BadValueError
from google.appengine.api.datastore_types import Blob, Key, T... | Python |
from google.appengine.api.memcache import *
| Python |
from email.MIMEBase import MIMEBase
from django.core.mail.backends.base import BaseEmailBackend
from django.core.mail import EmailMultiAlternatives
from django.core.exceptions import ImproperlyConfigured
from google.appengine.api import mail as aeemail
from google.appengine.runtime import apiproxy_errors
def _send_... | Python |
# Initialize Django.
from djangoappengine import main
from django.utils.importlib import import_module
from django.conf import settings
# Load all models.py to ensure signal handling installation or index
# loading of some apps
for app in settings.INSTALLED_APPS:
try:
import_module('%s.models' % (app))
... | Python |
from django.conf import settings
if 'django.contrib.auth' in settings.INSTALLED_APPS:
from dbindexer.api import register_index
from django.contrib.auth.models import User
register_index(User, {
'username': 'iexact',
'email': 'iexact',
})
if 'django.contrib.admin' in settings.INSTALLE... | Python |
from django.forms import ModelForm, Form
from django import forms
from models import user_profile, admins
class ProfileForm(ModelForm):
class Meta:
model = user_profile
fields = ('f_name', 'l_name', 'email_visibility', 'about_me')
class AdminProfileForm(ModelForm):
class Meta:
model = ... | Python |
from django.db import models
import logging
class user_profile(models.Model):
google_user_id = models.CharField(max_length=200, editable=False, unique=True)
f_name = models.CharField(max_length=30, null=True, blank=True, verbose_name='First Name')
l_name = models.CharField(max_length=30, null=True, blank=True, ve... | Python |
from models import user_profile, admins
from google.appengine.api import users
from django.shortcuts import render
from forms import NickForm
myprofile_links = [('/myprofile/', 'My Profile'), ('/myprofile/edit/', 'Edit Profile'), ('/my_items/', 'My Items'), ('/my_buys/', 'My Purchases'), ('/my_sells/', 'My Sold Items'... | Python |
import main
from main import handle_login_register, user
from django.http import HttpResponse, HttpResponseRedirect
from google.appengine.api import users
from django.shortcuts import render
from forms import ProfileForm, DelForm, AddAdminForm, ConfirmForm
from models import user_profile, admins
from itemTools.models i... | Python |
from django.conf.urls.defaults import patterns, include, url
import views
import userTools.views
import itemTools.views
import searchTools.views
import commTools.views
import expiry
urlpatterns = patterns('',
url(r'^$', views.home),
url(r'^myprofile/$', userTools.views.user_info),
url(r'^myprofile/edit/$'... | Python |
from __future__ import with_statement
from decimal import Decimal, InvalidOperation
import time
from django.core import serializers
from django.db import models
from django.db.models import Q
from django.db.models.signals import post_save
from django.db.utils import DatabaseError
from django.dispatch.dispatcher import... | Python |
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):
def default(self, ... | Python |
# All fields except for BlobField written by Jonas Haag <jonas@lophus.org>
from django.core.exceptions import ValidationError
from django.utils.importlib import import_module
from django.db import models
from django.db.models.fields.subclassing import Creator
from django.db.utils import IntegrityError
from django.db.m... | Python |
from django.conf import settings
from django.http import HttpResponseRedirect
from django.utils.cache import patch_cache_control
LOGIN_REQUIRED_PREFIXES = getattr(settings, 'LOGIN_REQUIRED_PREFIXES', ())
NO_LOGIN_REQUIRED_PREFIXES = getattr(settings,
'NO_LOGIN_REQUIRED_PREFIXES', ... | Python |
from django.conf import settings
from django.core.cache import cache
from django.contrib.sites.models import Site
from djangotoolbox.utils import make_tls_property
_default_site_id = getattr(settings, 'SITE_ID', None)
SITE_ID = settings.__class__.SITE_ID = make_tls_property()
class DynamicSiteIDMiddleware(object):
... | Python |
from django.test import TestCase
from django.test.simple import DjangoTestSuiteRunner
from django.utils.unittest import TextTestRunner
from .utils import object_list_to_table
class ModelTestCase(TestCase):
"""
A test case for models that provides an easy way to validate the DB
contents against a given li... | Python |
def make_tls_property(default=None):
"""
Creates a class-wide instance property with a thread-specific
value.
"""
class TLSProperty(object):
def __init__(self):
from threading import local
self.local = local()
def __get__(self, instance, cls):
i... | Python |
from django import forms
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User, Group
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'email', 'first_name', 'last_name', 'is_active',
... | Python |
from django.forms import widgets
from django.template.defaultfilters import filesizeformat
from django.utils.safestring import mark_safe
class BlobWidget(widgets.FileInput):
def render(self, name, value, attrs=None):
try:
blob_size = len(value)
except:
blob_size = 0
... | Python |
from django.db.backends.creation import BaseDatabaseCreation
class NonrelDatabaseCreation(BaseDatabaseCreation):
# "Types" used by database conversion methods to decide how to
# convert data for or from the database. Type is understood here
# a bit differently than in vanilla Django -- it should be read
... | Python |
import datetime
import random
from django.conf import settings
from django.db.models.fields import NOT_PROVIDED
from django.db.models.query import QuerySet
from django.db.models.sql import aggregates as sqlaggregates
from django.db.models.sql.compiler import SQLCompiler
from django.db.models.sql.constants import LOOKU... | Python |
from django.db.backends.util import format_number
def decimal_to_string(value, max_digits=16, decimal_places=0):
"""
Converts decimal to a unicode string for storage / lookup by nonrel
databases that don't support decimals natively.
This is an extension to `django.db.backends.util.format_number`
... | Python |
import cPickle as pickle
import datetime
from django.db.backends import (
BaseDatabaseFeatures,
BaseDatabaseOperations,
BaseDatabaseWrapper,
BaseDatabaseClient,
BaseDatabaseValidation,
BaseDatabaseIntrospection)
from django.db.utils import DatabaseError
from django.utils.functional import Promi... | Python |
from django import http
from django.template import RequestContext, loader
def server_error(request, template_name='500.html'):
"""
500 error handler.
Templates: `500.html`
Context:
request_path
The path of the requested URL (e.g., '/app/pages/bad_page/')
"""
# You need t... | Python |
from djangoappengine.settings_base import *
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
SECRET_KEY = '=r-$bi9LA73jc58&9003mmk5ch1k-3d3vfc4(wk0rn3wa1dhvi'
INSTALLED_APPS = (
'djangoappengine',
'djangotoolbox',
'django.contrib.contenttypes',
'django.contrib.sessions',
'userTools',
'itemTools'... | Python |
from django import forms
from itemTools.forms import max_price
class SearchItemForm(forms.Form):
term = forms.CharField(min_length=3, max_length=20, label='Search Term')
search_descrip = forms.BooleanField(label='Search in Item Description', required=False)
price_from = forms.IntegerField(label='Min Price (-1: Skip... | Python |
from django.db import models
# Create your models here.
| Python |
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 a... | Python |
from userTools.main import handle_login_register, user, handle_optional_login, myprofile_links
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from itemTools.models import items
from userTools.models import user_profile
from forms import SearchItemForm, max_price
from djan... | Python |
from itemTools.models import items
class foo:
def __init__(self, boo):
self.str = boo
import re
regex = re.compile('.*'+str(boo)+'.*')
def __eq__(self, tmp):
print tmp
if regex.match(str(tmp)) != None:
return False
return True | Python |
from django import forms
from models import items
max_price = 1000000
class SellForm(forms.ModelForm):
class Meta:
model = items
exclude = ['title_join_descrip', 'is_expired', 'is_active', 'is_sold', 'buyer']
def clean_price(self):
price = self.cleaned_data['price']
if price<0:
r... | Python |
from django.db import models
from userTools.models import user_profile
import logging
class items(models.Model):
"""
is_active yet to be implemented into the App
"""
user = models.ForeignKey(user_profile, editable=False)
title = models.CharField(max_length=30)
descrip = models.TextField(max_length=400, verbose_n... | Python |
from userTools.main import handle_login_register, user, handle_optional_login, myprofile_links
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from models import items
from forms import SellForm, DelForm
from django.core.paginator import Paginator, EmptyPage, PageNotAnInte... | Python |
from models import items
from dbindexer.api import register_index
register_index(items, {'title': ('icontains'), 'title_join_descrip': ('icontains')}) | Python |
from django.http import HttpResponse
from django.template import Template, Context, loader, RequestContext
from django.shortcuts import render
from google.appengine.api import users
from userTools.models import user_profile, admins
from userTools.main import user
def common_proc(request):
"""
Provides common details
... | Python |
# Load the siteconf module
from django.conf import settings
from django.utils.importlib import import_module
SITECONF_MODULE = getattr(settings, 'AUTOLOAD_SITECONF', settings.ROOT_URLCONF)
import_module(SITECONF_MODULE)
| Python |
from django.utils.importlib import import_module
from django.conf import settings
# load all models.py to ensure signal handling installation or index loading
# of some apps
for app in settings.INSTALLED_APPS:
try:
import_module('%s.models' % (app))
except ImportError:
pass
class AutoloadMidd... | Python |
def autodiscover(module_name):
"""
Automatically loads modules specified by module_name for each app in
installed apps.
"""
from django.conf import settings
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
for app in settings.... | Python |
import datetime
import os
import re
import sys
import types
from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
from django.template import (Template, Context, TemplateDoesNotExist,
TemplateSyntaxError)
from django.template.defaultfilters import forc... | Python |
"""
Decorators for views based on HTTP headers.
"""
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
from calendar import timegm
from datetime import timedelta
from django.utils.decorators import decorator_from_middleware, available_attrs
... | Python |
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
from django.utils.cache import patch_vary_headers
from django.utils.decorators import available_attrs
def vary_on_headers(*headers):
"""
A view decorator that adds the specified heade... | Python |
from django.utils.decorators import decorator_from_middleware
from django.middleware.gzip import GZipMiddleware
gzip_page = decorator_from_middleware(GZipMiddleware)
gzip_page.__doc__ = "Decorator for views that gzips pages if the client supports it."
| Python |
from django.middleware.csrf import CsrfViewMiddleware
from django.utils.decorators import decorator_from_middleware, available_attrs
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
csrf_protect = decorator_from_middleware(CsrfViewMiddlewar... | Python |
try:
from functools import wraps
except ImportError:
from django.utils.functional import wraps # Python 2.4 fallback.
from django.utils.decorators import decorator_from_middleware_with_args, available_attrs
from django.utils.cache import patch_cache_control, add_never_cache_headers
from django.middleware.cach... | Python |
"""
Views and functions for serving static files. These are only to be used
during development, and SHOULD NOT be used in a production setting.
"""
import mimetypes
import os
import posixpath
import re
import urllib
from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseNotModified
from djan... | Python |
from django.http import HttpResponseForbidden
from django.template import Context, Template
from django.conf import settings
# We include the template inline since we need to be able to reliably display
# this error message, especially for the sake of developers, and there isn't any
# other way of making it available ... | Python |
import time
import datetime
from django.db import models
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext as _
from django.views.generic.base import View
from django.views.generic.detail ... | Python |
from django.template import loader, RequestContext
from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseGone
from django.utils.log import getLogger
import warnings
warnings.warn(
'Function-based generic views have been deprecated; use class-based views instead.',
... | Python |
from django.forms.models import ModelFormMetaclass, ModelForm
from django.template import RequestContext, loader
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.core.xheaders import populate_xheaders
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
from django.... | Python |
import re
from django.core.paginator import Paginator, InvalidPage
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
from django.utils.encoding import smart_str
from django.utils.translation import ugettext as _
from django.views.generic.base import TemplateResponseMixin, View
c... | 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.