code
stringlengths
1
1.72M
language
stringclasses
1 value
from pysqlite2 import dbapi2 as sqlite3 persons = [ ("Hugo", "Boss"), ("Calvin", "Klein") ] con = sqlite3.connect(":memory:") # Create the table con.execute("create table person(firstname, lastname)") # Fill the table con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) # P...
Python
from pysqlite2 import dbapi2 as sqlite3 con = sqlite3.connect("mydb") cur = con.cursor() who = "Yeltsin" age = 72 cur.execute("select name_last, age from people where name_last=:who and age=:age", locals()) print cur.fetchone()
Python
# Not referenced from the documentation, but builds the database file the other # code snippets expect. from pysqlite2 import dbapi2 as sqlite3 import os DB_FILE = "mydb" if os.path.exists(DB_FILE): os.remove(DB_FILE) con = sqlite3.connect(DB_FILE) cur = con.cursor() cur.execute(""" create table people ...
Python
from pysqlite2 import dbapi2 as sqlite3 con = sqlite3.connect("mydb") cur = con.cursor() who = "Yeltsin" age = 72 cur.execute("select name_last, age from people where name_last=:who and age=:age", {"who": who, "age": age}) print cur.fetchone()
Python
from pysqlite2 import dbapi2 as sqlite3 import datetime con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) cur = con.cursor() cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) dt = cur.fetchone()[0] print dt, type(dt)
Python
from pysqlite2 import dbapi2 as sqlite3 def char_generator(): import string for c in string.letters[:26]: yield (c,) con = sqlite3.connect(":memory:") cur = con.cursor() cur.execute("create table characters(c)") cur.executemany("insert into characters(c) values (?)", char_generator()) cur.execute("s...
Python
from pysqlite2 import dbapi2 as sqlite3 con = sqlite3.connect("mydb") cur = con.cursor() newPeople = ( ('Lebed' , 53), ('Zhirinovsky' , 57), ) for person in newPeople: cur.execute("insert into people (name_last, age) values (?, ?)", person) # The changes will not be saved unless the transaction...
Python
from pysqlite2 import dbapi2 as sqlite3 class Point(object): def __init__(self, x, y): self.x, self.y = x, y def __conform__(self, protocol): if protocol is sqlite3.PrepareProtocol: return "%f;%f" % (self.x, self.y) con = sqlite3.connect(":memory:") cur = con.cursor() p = Point(4...
Python
from pysqlite2 import dbapi2 as sqlite3 class Point(object): def __init__(self, x, y): self.x, self.y = x, y def __repr__(self): return "(%f;%f)" % (self.x, self.y) def adapt_point(point): return "%f;%f" % (point.x, point.y) def convert_point(s): x, y = map(float, s.split(";")) r...
Python
from pysqlite2 import dbapi2 as sqlite3 class IterChars: def __init__(self): self.count = ord('a') def __iter__(self): return self def next(self): if self.count > ord('z'): raise StopIteration self.count += 1 return (chr(self.count - 1),) # this is a 1-...
Python
from pysqlite2 import dbapi2 as sqlite3 import apsw apsw_con = apsw.Connection(":memory:") apsw_con.createscalarfunction("times_two", lambda x: 2*x, 1) # Create pysqlite connection from APSW connection con = sqlite3.connect(apsw_con) result = con.execute("select times_two(15)").fetchone()[0] assert result == 30 con.c...
Python
from pysqlite2 import dbapi2 as sqlite3 import datetime, time def adapt_datetime(ts): return time.mktime(ts.timetuple()) sqlite3.register_adapter(datetime.datetime, adapt_datetime) con = sqlite3.connect(":memory:") cur = con.cursor() now = datetime.datetime.now() cur.execute("select ?", (now,)) print cur.fetcho...
Python
# Author: Paul Kippes <kippesp@gmail.com> import unittest from pysqlite2 import dbapi2 as sqlite class DumpTests(unittest.TestCase): def setUp(self): self.cx = sqlite.connect(":memory:") self.cu = self.cx.cursor() def tearDown(self): self.cx.close() def CheckTableDump(self): ...
Python
# Mimic the sqlite3 console shell's .dump command # Author: Paul Kippes <kippesp@gmail.com> def _iterdump(connection): """ Returns an iterator to the dump of the database in an SQL text format. Used to produce an SQL dump of the database. Useful to save an in-memory database for later restoration. T...
Python
#coding:utf8 from bottle import route, run, debug, template, request, validate, error, response, redirect from y_common import * from weibopy.auth import WebOAuthHandler from weibopy import oauth @route('/login') def login(): redirect('/sina/login') @route('/sina/login') def sina_login(): auth = WebOAuthH...
Python
from bottle import route, run, debug, template, request, validate, error, response, redirect @route('/apply/sent') @route('/apply/sent/show') def apply_sent_show(): return template('home') @route('/apply/sent/add/:tweet_id') def apply_sent_add(tweet_id): return template('home') @route('/apply/sent/exist/...
Python
from bottle import route, run, debug, template, request, validate, error, response, redirect @route('/') @route('/home') def home(): return template('home') #return 'Ybole - Python backend ... Coming soon!'
Python
from bottle import route, run, debug, template, request, validate, error, response, redirect @route('/admin/') def admin(): return template("home") @route('/admin/tag') def admin_tag(): return template("home") @route('/admin/tag/edit') def admin_tag(): return template("home")
Python
import re, base64, json baseurl = "http://www.ybole.com:81" gng_secret = "HUSTGNGisVeryGelivable" sina_consumer_key= "961495784" sina_consumer_secret ="47d9d806a1dc04cc758be6f7213465bc" def htmlEncode(str): """ Returns the HTML encoded version of the given string. This is useful to display a plain ASCII...
Python
#coding:utf8 # Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from urllib2 import Request, urlopen import base64 from weibopy import oauth from weibopy.error import WeibopError from weibopy.api import API class AuthHandler(object): def apply_auth(self, url, method, headers, parameters): ...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. class WeibopError(Exception): """Weibopy exception""" def __init__(self, reason): try: self.reason = reason.encode('utf-8') except: self.reason = reason def __str__(self): return self.reason...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.utils import parse_datetime, parse_html_value, parse_a_href, \ parse_search_datetime, unescape_html class ResultSet(list): """A list like object that holds results from a Twitter API query.""" class Model(object): def _...
Python
""" The MIT License Copyright (c) 2007 Leah Culver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publis...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.models import ModelFactory from weibopy.utils import import_simplejson from weibopy.error import WeibopError class Parser(object): def parse(self, method, payload): """ Parse the response payload and return the result...
Python
# Copyright 2010 Joshua Roesslein # See LICENSE for details. from datetime import datetime import time import htmlentitydefs import re def parse_datetime(str): # We must parse datetime this way to work in python 2.4 #return datetime(*(time.strptime(str, '%a %b %d %H:%M:%S +0800 %Y')[0:6])) #Change...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import httplib import urllib import time import re from weibopy.error import WeibopError from weibopy.utils import convert_to_utf8_str re_path_template = re.compile('{\w+}') def bind_api(**config): class APIMethod(object): path...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. """ weibo API library """ __version__ = '1.5' __author__ = 'Joshua Roesslein' __license__ = 'MIT' from weibopy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory, IDSModel from weibopy.error import WeibopErr...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import httplib from socket import timeout from threading import Thread from time import sleep import urllib from weibopy.auth import BasicAuthHandler from weibopy.models import Status from weibopy.api import API from weibopy.error import WeibopError ...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import os import mimetypes from weibopy.binder import bind_api from weibopy.error import WeibopError from weibopy.parsers import ModelParser class API(object): """Twitter API""" def __init__(self, auth_handler=None, host='api.t....
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.error import WeibopError class Cursor(object): """Pagination helper class""" def __init__(self, method, *args, **kargs): if hasattr(method, 'pagination_mode'): if method.pagination_mode == 'cursor': ...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import time import threading import os import cPickle as pickle try: import hashlib except ImportError: # python 2.4 import md5 as hashlib try: import fcntl except ImportError: # Probably on a windows system # TODO: use win32f...
Python
#coding:utf8 import os, sys from bottle import route, run, debug, template, request, validate, error, response, redirect # only needed when you run Bottle on mod_wsgi from bottle import default_app from y_home import * from y_apply import * from y_admin import * from y_login import * #reload(sys) #sys.setdefaultencodi...
Python
# -*- coding: utf-8 -*- """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with url parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines - all in a single file and with no dependencies...
Python
#!/usr/bin/env python #coding=utf-8 from weibopy.auth import OAuthHandler from weibopy.api import API import sqlite3 from threading import Thread from Queue import Queue from time import sleep from datetime import datetime, timedelta, date, time import sys from tag_detect import detect import os from signal import SIGT...
Python
from weibopy.auth import OAuthHandler from weibopy.api import API from threading import Thread from Queue import Queue from time import sleep from datetime import datetime, timedelta, date, time import sys from tag_detect import detect import os from crawler_id import idlist as A from weibopy.error import Wei...
Python
import sys, uuid from datetime import datetime def now(): return str(datetime.now()) + " " dic = open("tag_list.dict", "r") result = [] dic2 = [] dic3 = [] for item in dic: m = unicode(item, "utf-8").split() if len(m) > 1: tag, group = m else: tag, group = m[0], "0" ...
Python
#coding:utf-8 from threading import Thread from Queue import Queue from time import sleep import sqlite3 import sys, re, StringIO import urllib2 as urllib q = Queue() NUM = 17 JOBS = 3000 results = [] def craw(arguments): global results try: a = unicode(urllib.urlopen("http://tbole.com/result.php?searc...
Python
#coding:utf-8 #!/usr/bin/env python from threading import Thread from Queue import Queue from time import sleep import sqlite3 import sys, re, StringIO, os import urllib2 as urllib from datetime import datetime q = Queue() NUM = 20 TIMEOUT = 0.1 C = (u"名人堂", u"媒体汇", u"品牌馆") def now(): return str(dateti...
Python
#coding:utf-8 from threading import Thread from Queue import Queue import sqlite3 import sys, re, StringIO from time import sleep import urllib2, urllib TARGET = 1000 NUM = 10 ids = [] results = [] count = 0 q = Queue() KEYS = ['招聘'] class UserAgentProcessor(urllib2.BaseHandler): """A handler to add a custom UA...
Python
#!/usr/bin/env python #coding=utf-8 from weibopy.auth import OAuthHandler from weibopy.api import API import sqlite3 from threading import Thread from Queue import Queue from time import sleep from datetime import datetime, timedelta, date, time import sys from tag_detect import detect import os from signal import SIGT...
Python
#!/usr/bin/env python #coding=utf-8 catelist = [ (1, u"传统网络Internet"), (2, u"移动互联"), (3, u"网游"), (4, u"电子商务_B2C/团购"), (5, u"软件、电信"), (6, u"新媒体"), (7, u"风投/投行"), (8, u"其他外企"), ] idlist = [ [1, (u"超超Sandy", "d11c25990634d0e486235f1...
Python
from pymining.segmenter import Segmenter from pymining.configuration import Configuration class detect: def __init__(self): self.cfg = Configuration.FromFile("pymining/conf/test.xml") self.segmenter = Segmenter(self.cfg, "segmenter") def Split(self, line): wordList = self.segm...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from urllib2 import Request, urlopen import base64 from weibopy import oauth from weibopy.error import WeibopError from weibopy.api import API class AuthHandler(object): def apply_auth(self, url, method, headers, parameters): """Apply a...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. class WeibopError(Exception): """Weibopy exception""" def __init__(self, reason): self.reason = reason.encode('utf-8') def __str__(self): return self.reason
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.utils import parse_datetime, parse_html_value, parse_a_href, \ parse_search_datetime, unescape_html class ResultSet(list): """A list like object that holds results from a Twitter API query.""" class Model(object): def _...
Python
""" The MIT License Copyright (c) 2007 Leah Culver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publis...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.models import ModelFactory from weibopy.utils import import_simplejson from weibopy.error import WeibopError class Parser(object): def parse(self, method, payload): """ Parse the response payload and return the result...
Python
# Copyright 2010 Joshua Roesslein # See LICENSE for details. from datetime import datetime import time import htmlentitydefs import re def parse_datetime(str): # We must parse datetime this way to work in python 2.4 #return datetime(*(time.strptime(str, '%a %b %d %H:%M:%S +0800 %Y')[0:6])) #Change...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import httplib import urllib import time import re from weibopy.error import WeibopError from weibopy.utils import convert_to_utf8_str re_path_template = re.compile('{\w+}') def bind_api(**config): class APIMethod(object): path...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. """ weibo API library """ __version__ = '1.5' __author__ = 'Joshua Roesslein' __license__ = 'MIT' from weibopy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, ModelFactory, IDSModel from weibopy.error import WeibopErr...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import httplib from socket import timeout from threading import Thread from time import sleep import urllib from weibopy.auth import BasicAuthHandler from weibopy.models import Status from weibopy.api import API from weibopy.error import WeibopError ...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import os import mimetypes from weibopy.binder import bind_api from weibopy.error import WeibopError from weibopy.parsers import ModelParser class API(object): """Twitter API""" def __init__(self, auth_handler=None, host='api.t....
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. from weibopy.error import WeibopError class Cursor(object): """Pagination helper class""" def __init__(self, method, *args, **kargs): if hasattr(method, 'pagination_mode'): if method.pagination_mode == 'cursor': ...
Python
# Copyright 2009-2010 Joshua Roesslein # See LICENSE for details. import time import threading import os import cPickle as pickle try: import hashlib except ImportError: # python 2.4 import md5 as hashlib try: import fcntl except ImportError: # Probably on a windows system # TODO: use win32f...
Python
import math import pickle from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration class NaiveBayes: def __init__(self, config, nodeName, loadFromFile = False): #store variable(term)'s l...
Python
from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration from chisquare_filter import ChiSquareFilter from naive_bayes import NaiveBayes if __name__ == "__main__": config = Configuration.FromFile(...
Python
import math from segmenter import Segmenter from matrix import Matrix from py_mining import PyMining from configuration import Configuration class ClassifierMatrix: def __init__(self, config, nodeName, loadFromFile = False): self.node = config.GetChild(nodeName) self.segmenter = Segmenter(config, "...
Python
if __name__ == "__main__": """ train """ #init dm platfrom, include segmenter.. config = Configuration.FromFile("test.conf") PyMining.Init(config, "__global__") matCreater = ClassifierMatrix(config, "__matrix__") [trainx, trainy] = matCreater.CreateTrainMatrix("train.txt") #or usin...
Python
#encoding=utf-8 import math import pickle import sys from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration from chisquare_filter import ChiSquareFilter from twc_naive_bayes import TwcNaiveBayes ...
Python
from xml.dom import minidom class Configuration: mCurNode = None def __init__(self, node): self.mCurNode = node """ get first child """ def GetChild(self, name): for node in self.mCurNode.childNodes: if node.nodeName == name: return Configurati...
Python
#save materials produced during data-mining class PyMining: #dict store term -> id termToId = {} #dict store id -> term idToTerm = {} #dict store term -> how-many-docs-have-term idToDocCount = {} #dict store class -> how-many-docs-contained classToDocCount = {} #inverse document fre...
Python
from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration from chisquare_filter import ChiSquareFilter from naive_bayes import NaiveBayes if __name__ == "__main__": config = Configuration.FromFile(...
Python
import random import bisect class Tripple: def __init__(self, row, col, val): self.row = row self.col = col self.val = val def Transpose(self): tmp = self.row self.row = self.col self.col = tmp return self def TrippleCmp(t1, t2): if (t1....
Python
#coding=utf8= #mmseg from configuration import Configuration class Segmenter: def __init__(self, config, nodeName): curNode = config.GetChild(nodeName) self.mainDict = self.LoadMainDict(curNode.GetChild("main_dict").GetValue()) def Split(self, line): line = line.lower() index ...
Python
#encoding=utf8 from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration from chisquare_filter import ChiSquareFilter from naive_bayes import NaiveBayes if __name__ == "__main__": config = Configu...
Python
import math import pickle import sys from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration class TwcNaiveBayes: def __init__(self, config, nodeName, loadFromFile = False): #store weig...
Python
from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration class ChiSquareFilter: def __init__(self, config, nodeName, loadFromFile = False): self.curNode = config.GetChild(nodeName) ...
Python
import math import pickle import sys from matrix import Matrix from classifier_matrix import ClassifierMatrix from segmenter import Segmenter from py_mining import PyMining from configuration import Configuration from chisquare_filter import ChiSquareFilter from twc_naive_bayes import TwcNaiveBayes if __name__ == "...
Python
#coding:utf-8 import sys a=u"""3 工程师 Done. 1 php Done. 5 php 工程师 Done. 2 设计师 Done. 6 视觉设计 Done. 7 产品经理 Done. 9 web Done. 10 编辑 Done. 11 实习生 Done. 12 产品 Done. 13 交互设计 Done. 8 产品设计 Done. 18 java Done. 19 UI Done. 22 销售 Done. 25 医药代表 Done. 24 java php Done. 29 gongzhuo Done. 17 c++ Done. 30 css Done. 39 程序架构师 Done. 41 SUN...
Python
#!/usr/bin/env python #coding=utf-8 catelist = [ (1, u"传统网络Internet"), (2, u"移动互联"), (3, u"网游"), (4, u"电子商务_B2C/团购"), (5, u"软件、电信"), (6, u"新媒体"), (7, u"风投/投行"), (8, u"其他外企"), ] idlist = [ [1, (u"超超Sandy", "d11c25990634d0e486235f1...
Python
# -*- coding: utf-8 -*- from ragendja.settings_pre import * # Increase this when you update your 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 get a s...
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
''' Django middleware for HTTP authentication. Copyright (c) 2007, Accense Technology, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above cop...
Python
# -*- coding: utf-8 -*- from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ from ragendja.template import render_to_response from django.template import Context, RequestCont...
Python
# -*- coding: utf-8 -*- from django.utils.translation import ugettext_lazy as _ from google.appengine.ext import db from django.contrib.auth.models import User #from datetime import * import datetime class HacoUser( db.Model): user =db.ReferenceProperty( User) zip =db.StringProperty() twitterID =db.StringP...
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
#!/usr/bin/python """ NOTE: Tango is being renamed to Twython; all basic strings have been changed below, but there's still work ongoing in this department. Twython is an up-to-date library for Python that wraps the Twitter API. Other Python Twitter libraries seem to have fallen a bit behind, and Twitter's API...
Python
#!/usr/bin/python2.4 # # Copyright 2007 Google Inc. All Rights Reserved. # # 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...
Python
# -*- coding: utf8 -*- from twitter import Api import simplejson import urllib2 import logging class Api(Api): ''' twitter.Apiクラスの拡張 self._cacheの影響でファイル入出力が発生するため、 Apiクラスのラッパーとして利用する。 ''' def __init__(self, username=None, password=None, inp...
Python
#!/usr/bin/python2.4 # # Copyright 2007 Google Inc. All Rights Reserved. # # 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...
Python
from django.conf.urls.defaults import * from django.contrib.auth import views as auth_views from views import * from views2 import * from twit import * urlpatterns =patterns( '', #url( r'^login/$', # auth_views.login, # {'template_name': 'haco/login.html', # 'redirect_field_name...
Python
# -*- coding: utf-8 -*- from decimal import * from math import * def v2W(volt): if float(volt) < 0: return -1 else: watt = (float(volt) * 1100.0 / 1024.0) * 3000 / (0.9 * 100) / 1000 * 100 watt = Decimal(str(watt)).quantize(Decimal('.0'), rounding=ROUND_HALF_UP) ...
Python
# -*- coding: utf-8 -*- from django.http import HttpResponse from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ from haco.models import * from haco.jsTime import * import logging import twython from datetime import * def twitBot( request): mes ="<html><he...
Python
#!/usr/bin/python """ NOTE: Tango is being renamed to Twython; all basic strings have been changed below, but there's still work ongoing in this department. Twython is an up-to-date library for Python that wraps the Twitter API. Other Python Twitter libraries seem to have fallen a bit behind, and Twitter's API...
Python
# -*- coding: utf-8 -*- from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ from ragendja.template import render_to_response from django.template import Context, RequestContext, lo...
Python
# -*- coding: utf-8 -*- from django.contrib.auth.decorators import login_required from django.http import HttpResponse from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ from ragendja.template import render_to_response from django.template import Context, loader f...
Python
from django.contrib import admin from haco.models import HacoUser, Haco class HacoUserAdmin( admin.ModelAdmin): list_display =( 'user', 'prefecture', 'city') class HacoAdmin( admin.ModelAdmin): list_display =( 'temp', 'light', 'watt', 'date') admin.site.register( HacoUser) admin.site.register( Haco)
Python
# -*- coding: utf-8 -*- from datetime import * def now(): return datetime.now() + timedelta(hours=9) def today(): return now().replace(hour=0,minute=0,second=0,microsecond=0) def tomorrow(): return (now() + timedelta(days=1)).replace(hour=0,minute=0,second=0,microsecond=0) def someday(delta): ...
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 from django.contrib.auth import views as auth_views from haco import views...
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