code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Created on 2009-11-18.
# $Id$
#
from django import template
from django.utils.safestring import mark_safe
register = template.Library()
@register.filter
def mark_escape(value):
return mark_safe(value)
# EOF
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Created on 2010-02-12.
# $Id$
#
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Created on 2010-02-12.
# $Id$
#
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2008 ZHENG Zhong <heavyzheng nospam at gmail D0T com>
# - http://heavyz.blogspot.com/
# - http://buggarden.blogspot.com/
#
# Created on 2008-04-28
# $Id: __init__.py 26 2009-08-04 22:06:00Z guolin.mobi $
#
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Created on 2010-02-05.
# $Id: main.py 41 2010-07-21 10:33:30Z guolin.mobi $
#
"""Bootstrap script for running a Django application on Google App Engine.
"""
#---------------------------------------------------------------------------------------------------
#... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2008 ZHENG Zhong <heavyzheng nospam at gmail D0T com>
# - http://heavyz.blogspot.com/
# - http://buggarden.blogspot.com/
#
# Created on 2008-04-28
# $Id: __init__.py 26 2009-08-04 22:06:00Z guolin.mobi $
#
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Created on 2010-02-05.
# $Id: main.py 41 2010-07-21 10:33:30Z guolin.mobi $
#
"""Bootstrap script for running a Django application on Google App Engine.
"""
#---------------------------------------------------------------------------------------------------
#... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright 2008 ZHENG Zhong <heavyzheng nospam at gmail D0T com>
# - http://heavyz.blogspot.com/
# - http://buggarden.blogspot.com/
#
# Created on 2008-04-28
# $Id: __init__.py 26 2009-08-04 22:06:00Z guolin.mobi $
#
| Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''Allows you to create and edit skin for ForumFree.net and ForumCommunity.net without knowing css'''
'''
Copyright (C) 2008-2009 Nicola Bizzoca <nicola.bizzoca@gmail.com> and Ltk_Sim <staff@universalsite.org>
This program is free software: you can redistribute it and/... | Python |
from distutils.core import setup
import py2exe
import glob
setup (windows = [{"script": 'ffskinner.py'}],
options={"py2exe" : {"includes" : ["sip", "PyQt4.QtNetwork",
'pygments.*', 'pygments.lexers.*', 'pygments.formatters.*',
... | Python |
'''
Created on 17/set/2009
@author: nico
'''
__module_name__ = "ForumFree Utenza"
__module_version__ = "1.0"
__module_description__ = "Crea un grafico dell'utenza su ForumFree"
import xchat
import datetime
import cPickle
from odict import OrderedDict
from pygooglechart import Chart
from pygooglechart import Sim... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
from odict import OrderedDict
import cssutils
"""Una libreria per il parsing di CSS"""
class SelectorReference(OrderedDict):
def addReference(self, selector):
pass
class SelectorList(OrderedDict):
"""
... | Python |
import os
from PyQt4 import QtCore, QtGui, QtWebKit
from lib.parsehtml import MakeWebPreview
class JSBridge(QtCore.QObject):
def __init__(self, skinEditor):
QtCore.QObject.__init__(self, skinEditor)
self.setObjectName('JSBridge')
self.inspect = True
self.skinEditor = skin... | Python |
from PyQt4 import QtCore, QtGui
class PushButton(QtGui.QPushButton):
def __init__(self, text, selector, parent):
QtGui.QPushButton.__init__(self, text, parent)
self.selector = selector
self.connect(self, QtCore.SIGNAL('clicked()'), self.clickedText)
def clickedText(self... | Python |
# odict.py
# An Ordered Dictionary object
# Copyright (C) 2005 Nicola Larosa, Michael Foord
# E-mail: nico AT tekNico DOT net, fuzzyman AT voidspace DOT org DOT uk
# This software is licensed under the terms of the BSD license.
# http://www.voidspace.org.uk/python/license.shtml
# Basically you're free to copy, modify,... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
from pygments import highlight
from pygments.lexers import CssLexer
from pygments.formatters import HtmlFormatter
from lib.skinparser import SkinParser
from lib.skinundoredo import SkinUndoRedo
class CssTextEditor(QtGui.QTextEdit):
... | Python |
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
from PyQt4 import QtCore
from BeautifulSoup import BeautifulSoup, Tag, NavigableString
class ParseHTML(QtCore.QThread):
'''
Effettua il parsing in un thread separato di un file html trmiate BeautifulSoup
'''
def __init__(self, parent = None):
... | Python |
import cPickle
class SkinUndoRedo(dict):
def newSkin(self, skinName):
if skinName not in self:
self[skinName] = {'undo' : [], 'redo' : []}
def saveToDisk(self):
cPickle.dump(self[:], '../saved/skinList')
| Python |
config = {
'version' : 'alpha',
'undoredo' : True,
'size' : { 'w' : 900,
'h' : 500},
'mapBackground' : { 'home' : { 'file' :'images/home.jpg',
'w' : 870,
... | Python |
__author__ = 'XingHua'
from os.path import basename
from urlparse import urlsplit
import urllib2
def url2name(url):
print urlsplit(url)[2]
return basename(urlsplit(url)[2])
def download(url, localFileName=None):
localName = url2name(url)
req = urllib2.Request(url)
r = urllib2.url... | Python |
#coding:utf-8
__author__ = 'XingHua'
#!/usr/bin/python
# Author: YiBang Ruan
import pyodbc
class ODBC_QQ:
def __init__( self, DRIVER, SERVER, DATABASE, UID, PWD):
''' initialization '''
self.DRIVER = DRIVER
self.SERVER = SERVER
self.DATABASE = DATABASE
self.U... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
最近需要将内存中的Flash Dump出来,找到一款软件 Flash吸血鬼,可以查找内存中的Flash,不过没有注册版本的不能直接
保存为Flash格式,于是自己摸索了半天,弄了一个Python版本的。
swf文件有两种,一种为未压缩的,另外一种为zlib压缩过的。
未压缩的:
1-3字节为:Hex: 46 57 53(ASCII: FWS),
第4字节为:版本,
第5-8字节为swf文件大小,包含8字节文件头。
结尾4个字节为Hex:40 00 00 00
zli... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
import urllib, urllib2, cookielib, sys
class Login_e10000:
login_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4'}
signin_header = {'User-Agent':'Mozilla/5.0 (Windows NT 6... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
#首先知道他的密码是8位的数字 这就好办了
import urllib, urllib2, cookielib
import threading
cookie_support = urllib2.HTTPCookieProcessor(cookielib.CookieJar())
opener = urllib2.build_opener(cookie_support, urllib2.HTTPHandler)
urllib2.install_opener(opener)
url = ''
... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
import re
import mechanize
import sys
print sys.getdefaultencoding()
print sys.getfilesystemencoding()
br = mechanize.Browser()
br.open("http://www.taobao.com/")
# follow second link with element text matching regular expression
regex3 = "2"
respons... | Python |
__author__ = 'XingHua'
import MySQLdb
def Foo():
conn = MySQLdb.connect(host='localhost',
user='root', passwd='abc123', db='test')
cursor = conn.cursor()
cursor.execute('SELECT * FROM people')
id, name = cursor.fetchone()
print id, name
if __name__ == '_... | Python |
__author__ = 'XingHua'
import urllib2
def Foo():
print urllib2.urlopen('http://www.google.com/').read()
if __name__ == '__main__':
Foo() | Python |
__author__ = 'XingHua'
import fudge
from MySQLdb_fun import Foo
mysqldb = fudge.Fake('MySQLdb')
conn = mysqldb.expects('connect').returns_fake()
curs = conn.provides('cursor').returns_fake()
curs = curs.expects('execute').returns(1)
curs = curs.provides('fetchone').returns((1, 'Nathan'))
@fudge.with_fak... | Python |
__author__ = 'XingHua'
import fudge
from cStringIO import StringIO
from network import Foo
urlopen = fudge.Fake('urlopen', callable=True) \
.returns(StringIO('HelloWorld'))
@fudge.with_fakes
@fudge.with_patched_object('urllib2', 'urlopen', urlopen)
def Test():
Foo() # prints: HelloWorld
i... | Python |
__author__ = 'XingHua'
import os
def Foo():
print os.listdir('.')
open('a.txt', 'w').write('HelloWorld')
if __name__ == '__main__':
Foo() | Python |
__author__ = 'XingHua'
| Python |
__author__ = 'XingHua'
import fudge
from cStringIO import StringIO
from fileSystem import Foo
listdir = fudge.Fake(callable=True).returns(['a.txt', 'b.jpg'])
buf = StringIO()
myopen = lambda filename, mode: buf
@fudge.with_fakes
@fudge.with_patched_object('os', 'listdir', listdir)
@fudge.with_patched_o... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
# +-----------------------------------------------------------------------------
# | File: xiami_auto_checkin.py
# | Author: huxuan
# | E-mail: i(at)huxuan.org
# | Created: 2011-12-11
# | Last modified: 2012-02-06
# | Description:
# | Description ... | Python |
#coding=utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
import fudge
mock = fudge.Fake('mock')
mock.expects('method')\
.with_arg_count(arg1=1, arg2='2').returns(True)
mock.method(arg1=1, arg2='2')
fudge.verify()
| Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
"""
import os
totalfile = {}
# print os.getcwd()
for root, dirs, files in os.walk(os.getcwd(), True):
flst = [os.path.join(root, f) for f in files if f.endswith(('.php', '.js', '.css', '.txt', '.py'))]
print flst
for fname... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
#!/usr/bin/env python
#encoding=utf-8
import sys
import re
import urllib2
import urllib
import cookielib
class Renren(object):
def __init__(self):
self.name = self.pwd = self.content = self.domain = self.origURL = ''
self.ope... | Python |
__author__ = 'XingHua'
import unittest
class MyTestCase(unittest.TestCase):
def test1(self):
"""Run test 1"""
print "test1"
pass
def test2(self):
"""Run test 2"""
pass
if __name__ == '__main__':
unittest.main() | Python |
#coding:utf-8
#!/usr/env/bin python
__author__ = 'XingHua'
import time,datetime
import urllib2
def chk_qq(qqnum):
chkurl = 'http://wpa.qq.com/pa?p=1:'+`qqnum`+':1'
a = urllib2.urlopen(chkurl)
length=a.headers.get("content-length")
a.close()
print datetime.datetime.now()
if lengt... | Python |
#!/usr/bin/env python
# coding: UTF-8
__author__ = 'XingHua'
'''
windows和linux采用了不同的编码,这让很多人伤透了脑经,
这里我采用了Python的chardet库获得代码的编码,然后修改编码
'''
import sys
import os
import chardet
def print_usage():
print '''usage:
change_charset [file|directory] [charset] [output file]\n
for example:
chang... | Python |
#!/usr/bin/env python
# coding: UTF-8
__author__ = 'XingHua'
'''
windows和linux采用了不同的编码,这让很多人伤透了脑经,
这里我采用了Python的chardet库获得代码的编码,然后修改编码
'''
import sys
import os
import chardet
def print_usage():
print '''usage:
change_charset [file|directory] [charset] [output file]\n
for example:
chang... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
import winpcapy ,struct
pack=winpcapy.pcap()
pack.setfilter('udp')
key=''
for recv_time,recv_data in pack:
recv_len=len(recv_data)
if recv_len == 102 and recv_data[42]== chr(02) and recv_data[101] == chr(03):
print struct.unpack('>I',rec... | Python |
#-*-coding:utf8 -*-
#!/usr/env python
__author__ = 'SIOM'
import GdImageFile
import matplotlib.pyplot as plt
#x=GdImageFile.open(r"c:\2200.TIF")
#x=GdImageFile.open(r'c:\1.jpg')
x=plt.imread(r'c:\2200.TIF')
plt.imshow(x)
plt.show() | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
闲着没事做,前段时间买了个摄像头,在ubuntu上用。打开cheese这个软件,一片空白,怎么不能用阿!
google一番,装上gspca,还是不能用!
用lsusb命令查看下
lingshangwen@eagle:~$ lsusb
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 0c... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
此方案为朋友LSJ提出并实现的,转过来供学习用,由于在测试时没有架设WEB服务器,也没有做手机上的测试,仅通过PC测试了下,最完整解决方案请参考原出处《DIY手机监控系统》。
方法:
1 下载并安装VideoCapture、PIL。
2.编码,3s抓一个图片并保存
"""
from VideoCapture import Device
import time, string
interval = 2
cam = Device(devnum=0, sho... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from VideoCapture import Device
import time
import sys, pygame
pygame.init()
size = width, height = 620, 485
speed = [2, 2]
black = 0, 0, 0
pygame.display.set_caption('视频窗口@dyx10... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
# -*- coding: utf-8 -*-
###########################################################################
## Python code generated with wxFormBuilder (version Jun 30 2011)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
########... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
import re
if __name__=='__main__':
txt = open(r'C:\Users\SAF\Desktop\fish_log.txt').read()
#print txt
#txt = 'Fish 7 ss'
pattern1 = re.compile(r'Fish 7 attemps to attack \w+')
m1=re.findall(pattern1,txt)
#print m
# for i... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
"""
from pydbg import *
dbg=pydbg()
heap_free_count = 0
def heap_free_handler(dbg):
global printf_count
heap_free_count += 1
print "enter heap free handler ", heap_free_count
return DBG_CONTINUE
def entry_... | Python |
#coding:utf-8
#!/usr/env/bin python
__author__ = 'SIOM'
a='''本系统选用德国TOPAS公司的ATM 241
气溶胶发生器,该发生器可产生最高浓度大于108
颗/cm3 的多分散气溶胶粒子,且浓度可调节,能
够满足检漏系统对高浓度粒子的需求。管路中的喷
嘴装置和压差计用于测量管道中的风量值。三通管
路设计一路为主气流管,用作测试气流;另一路为
旁通管,在更换被测过滤器过程中主气流电动阀关
闭时打开。这样一方面可以防止在更换过滤器时,
高浓度气溶胶污染检测环境;另一方面使得检测下
一只过滤器时,上游粒子浓度稳定时间大大缩短,
减少等待时间。
... | Python |
#-*- coding:utf8 -*-
#!/usr/bin/env python
__author__ = 'SIOM'
import numpy as np
import matplotlib.pyplot as plt
filename=r'c:\Data14H15M9S.txt'
data1_plot=plt.plotfile(filename,(2,),delimiter='\t')
ax=plt.gca()
plt.show()
#data1=data1_plot.get_data()
#plt.show() | Python |
__author__ = 'SIOM'
from mpl_toolkits.mplot3d import Axes3D
import matplotlib
import numpy as np
from matplotlib import cm
from matplotlib import pyplot as plt
step = 0.04
maxval = 1.0
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# create supporting points in polar coordinates
r = np.linsp... | Python |
__author__ = 'SIOM'
"""
An example of how to use Basemap in pyqt4 application.
Copyright(C) 2011 dbzhang800#gmail.com
"""
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from mpl_toolkits.basemap import Basemap
from PyQt4 import QtGui
... | Python |
#-*- coding:utf-8 -*-
#!/usr/bin/env python
__author__ = 'aaqqxx'
'''
用于处理EN1822程序中,生成的下游粒子数3D柱状图。
'''
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.patches import Rectangle
import sys
from time impor... | Python |
__author__ = 'SIOM'
from matplotlib.pylab import * # pylab is the easiest approach to any plotting
import time # we'll do this rendering i real time
ion() # interaction mode needs to be turned off
x = arange(0,2*pi,0.01) # we'll create an x-axis from 0 to... | Python |
__author__ = 'SIOM'
import numpy as np
from matplotlib import pyplot as plt
import random
from time import sleep
plt.ion() # set plot to animated
ydata = [0] * 50
ax1=plt.axes()
# make plot
line, = plt.plot(ydata)
plt.ylim([10,40])
# start data collection
while True:
#data = ser.readline().rs... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
from tkinter import *
import os, sys
from threading import Thread
from queue import Queue, Empty
import _thread
import time
from paramiko import SSHClient, Transport, AutoAddPolicy, WarningPolicy
import getpass
def start(client):
try:
... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
# Author: 柠之漠然 <shiniv.ning@gmail.com>
#
# 使用说明:
# 1.安装python 2.x
# 2.在脚本当前目录下建立'config'文件
# config文件中,一行一个账号,格式为
# ID1,email1,cookie1
# 不希望收到邮件提醒的email写'x' (邮件提醒在网络不好时可能引起错误导致崩溃)
# ID2,x,cookie2
# cookie可以在贴吧页面ctrl+sh... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
"""
金山快盘自动签到
"""
import urllib
import urllib2
import cookielib
import json
import re
class Login_kp:
def __init__(self):
cj = cookielib.CookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
"""
from twisted.internet import protocol, reactor
class Echo(protocol.Protocol):
def dataReceived(self, data):
print data
self.transport.write(data)
class EchoFactory(protocol.Factory):
def buildProtocol(self... | Python |
# coding:utf-8
#!/usr/bin/env python
'''
用来检测同一网段的IP,mac地址
'''
__author__ = 'SAF'
import threading
import os
from time import sleep
import time
from ip2mac import IP2MAC
def ping(ip, usedIP):
x = os.popen("ping %s -n 1" % str(ip))
res = x.readlines()
if check_res(res):
for... | Python |
# coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
"""
from twisted.internet.protocol import ClientCreator, Protocol
from twisted.protocols.basic import LineReceiver
from twisted.internet import reactor
import sys
class Sender(Protocol):
def sendCommand(self, command):
prin... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
| Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
f = file(r"C:\Users\SAF\Documents\Tencent Files\506926059\FileRecv\ZA.c",'r')
x = f.readlines()
# print x
txt = x[8]
print txt.decode('utf-8',
#errors='ignore'
).encode('gbk','replace')
# for i,each in enumerate(x):
... | Python |
from distutils.core import setup
import py2exe
setup(console=['ping_all.py'])
| Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'SAF'
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import platform
import re
class IP2MAC:
def __init__(self):
self.patt_mac = re.compile('([a-f0-9]{2}[-:]){5}[a-f0-9]{2}', re.I)
def getMac(self, ip):
sysstr = platf... | Python |
#coding: utf-8
#/usr/bin/env python
"""
这个Python脚本用于登录北科大校园网,修改文件中的username和password后,将文件
放到启动项中,就可以实现开机自动登录校园网了。
Python版本:2.7.3
"""
import httplib
import subprocess
import re
def get_local_ipv6_address():
"""
This function will return your local machine's ipv6 address if it exits.
If the... | Python |
__author__ = 'XingHua'
#!/usr/bin/env python3.2
import ctypes,sys
from ctypes.util import find_library
#pcap = ctypes.cdll.LoadLibrary("libpcap.so")
pcap = None
if(find_library("libpcap") == None):
print("We are here!")
pcap = ctypes.cdll.LoadLibrary("libpcap.so")
else:
pcap = ctypes.cdll.LoadLibr... | Python |
#coding:utf-8
#!/usr/bin/env python
__author__ = 'XingHua'
"""
1.最简单的办法是把文件读入一个大的列表中,然后统计列表的长度.如果文件的路径是以参数的形式filepath传递的,
那么只用一行代码就可以完成我们的需求了:
2.当外部系统提供统计行数的方法时,你可以使用它们(通过os.popen),如unix的wc - l.当然,通过自己的程序来完成会更简单
,快捷和通用.你可以假设大多数的文本文件都有合理的大小,所以把它们一次读入内存中处理是可行的.对于这样的情况,len方
法返回readlines的大小是最简单的.假如一个文件的大小大于内存... | Python |
#coding:utf-8
#!/usr/env/bin python
'''
最初的目的:GoogleChrome的缓存图片会自动把文件名去掉,浏览的图片想查看不太方便,想要实现在其缓冲的文件夹下面找到可能是
图片的文件,为其添加后缀方便在Windows系统中使用图像浏览器浏览。
在所需文件夹下,查找相应的文件名,找到后,添加文件后缀。
'''
__author__ = 'aaqqxx'
import os
import re
import sys
path=
def find_the_file(path=os.getcwd(),pattern="*"):
file_names_r... | Python |
print("Hallo world")
| Python |
from django.db import models
from django.contrib import admin
from forfood.restaurant.models import Restaurant
class Menu(models.Model):
menu_name = models.CharField(max_length = 20, unique = True)
restaurant = models.ForeignKey(Restaurant)
#in_use = models.IntegerField()
def __unicode__(self... | 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... | Python |
from django.http import HttpResponse
from django.template import Context
from django.template.loader import get_template
from django.http import HttpResponse, Http404
from django.contrib.auth.models import User
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.... | Python |
from django.db import models
from django.contrib import admin
class Province(models.Model):
province = models.CharField(max_length=20)
def __unicode__(self):
return self.province
class ProvinceAdmin(admin.ModelAdmin):
search_fields = ("province",)
admin.site.register(Province, ProvinceAdmi... | 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... | Python |
# -*-coding:utf-8 -*-
from django.http import HttpResponse, Http404
from forfood.address.models import *
from forfood.helpers.user_helper import *
none = "None"
def get_province(request):
provinces = Province.objects.all()
rv = "province&<option></option>"
for p in provinces:
if p.pro... | 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 custo... | Python |
from django.db import models
from django.contrib import admin
from forfood.customer.models import Customer
from forfood.restaurant.models import Restaurant
class Star(models.Model):
customer = models.ForeignKey(Customer)
restaurant = models.ForeignKey(Restaurant)
class StarAdmin(admin.ModelAdmin):
... | 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... | Python |
# Create your views here.
| Python |
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from django.contrib.auth.utils import get_hexdigest
from forfood.address.models import Address
url = "http://127.0.0.1:8000/"
class Customer(User):
name = models.CharField(max_length=10)
phone = m... | 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... | Python |
# -*-coding:utf-8 -*-
from django.http import HttpResponse, Http404
from django.http import HttpResponseRedirect
from django.template import Context
from django.template import RequestContext
from forfood.customer.models import Customer
from forfood.restaurant.models import Restaurant
from forfood.star.models im... | Python |
from forfood.customer.models import Customer
from forfood.restaurant.models import Restaurant
def find_customer(user):
try:
customer = Customer.objects.get(username = user.username)
except:
customer = None
pass
return customer
def find_restaurant(user):
try:
... | 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 custo... | Python |
from django.conf.urls.defaults import patterns, include, url
import os.path
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
site_media = os.path.join(
os.path.dirname(__file__), 'site_media'
)
urlpatterns = patterns('',
# Examples:
# url(... | Python |
# Django settings for forfood project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracl... | Python |
from django.db import models
from django.contrib import admin
from forfood.restaurant.models import Restaurant
from forfood.customer.models import Customer
class Comment(models.Model):
comment_content = models.CharField(max_length = 200)
datestamp = models.DateTimeField()
replied_comment_id = mod... | 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... | Python |
# Create your views here.
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
from forfood.restaurant.models import Restaurant
from forfood.helpers.user_helper import *
from forfood... | Python |
# -*-coding:utf-8 -*-
import re
from django import forms
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from forfood.customer.models import *
from django.contrib.auth import authenticate
class LoginForm(forms.Form):
email = forms.EmailField(label='Email')... | 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... | Python |
from django.http import HttpResponse
from django.template import Context
from django.template.loader import get_template
from django.http import HttpResponse, Http404
from django.contrib.auth.models import User
from django.template import RequestContext
from django.http import HttpResponseRedirect
#from django.c... | Python |
# -*-coding:utf-8 -*-
from django import forms
class AddMenuCategoryForm(forms.Form):
name = forms.CharField(label='类别名', max_length=30)
class EditMenuCategoryForm(forms.Form):
old_category = forms.TypedChoiceField(label='旧类别名',choices=())
new_category = forms.CharField(label='新类别名', max_lengt... | Python |
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin
from forfood.address.models import Address
from time import time
class Restaurant(User):
name = models.CharField(max_length=100)
phone = models.CharField(max_length=15)
address = models.Foreig... | 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... | Python |
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.http import HttpResponse, Http404
from forfood.restaurant.models import Restaurant
from forfood.helpers.user_helper import *
from forfood.restaurant.forms import *
... | Python |
# -*-coding:utf-8 -*-
from django.db import models
from django.contrib import admin
from forfood.customer.models import Customer
from forfood.restaurant.models import Restaurant
from forfood.menu.models import MenuItem
from time import time
from time import ctime
from time import strftime
from time import loca... | 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... | 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.