code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <zhb@iredmail.org>
# Purpose: Add three service name in 'enabledService' attribute.
# Required in iRedMail-0.7.0.
# Date: 2011-01-28
import sys
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'ldap://1... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <zhb@iredmail.org>
# Purpose: Add three new services name in 'enabledService' attribute.
# Required in iRedMail-0.6.0.
# Date: 2010-05-31
import sys
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'lda... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <zhb@iredmail.org>
# Purpose: Add enabledService=lda for all mail users.
# Required in iRedMail-0.7.3.
# Date: 2011-07-12
import sys
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'ldap://127.0.0.1:38... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <michaelbibby (at) gmail.com>
# Purpose: Add three new services name in 'enabledService' attribute.
# Required in iRedMail-0.5.1.
import sys
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'ldap://127.0.0.... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <zhb@iredmail.org>
# Purpose: Delete specified mail accounts.
# Date: 2011-03-01
import sys
import shlex
import subprocess
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'ldap://127.0.0.1:389'
basedn = 'o=domai... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <michaelbibby (at) gmail.com>
# Purpose: Change password of ALL users under domain.
# Usage:
# - Change LDAP related settings below:
# + uri
# + basedn
# + bind_dn
# + bind_pw
# - Run this script with domain name and new p... | Python |
#!/usr/bin/env python
# encoding: utf-8
# Author: Zhang Huangbin <michaelbibby (at) gmail.com>
# Purpose: Add three new services name in 'enabledService' attribute.
# Required in iRedMail-0.5.1.
import sys
import ldap
# Note:
# * bind_dn must have write privilege on LDAP server.
uri = 'ldap://127.0.0.... | Python |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
#
# qooxdoo - the new era of web development
#
# http://qooxdoo.org
#
# Copyright:
# 2008 - 2012 1&1 Internet AG, Germany, http://www.1und1.de
#
# License:
# LGPL: http://www.gnu.org/... | Python |
import shutil, os
import tarfile
import json
def concat(dst, src1, src2):
destination = open(dst, 'wb')
shutil.copyfileobj(open(src1, 'rb'), destination)
shutil.copyfileobj(open(src2, 'rb'), destination)
destination.close()
def tarLinuxFiles(tarname, src):
tar = tarfile.open(tarname, "w:gz")
... | Python |
#!/usr/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
import codecs
import string
import modules.log4py as log4py
log = log4py.log4py('[phonetic]')
Chinese = 1
#sublang
Mandarin = 11
Cantonese = 12
class Phonetic():
''' Proc... | Python |
#!/bin/dev python
# coding=utf8
from memory import *
import codecs
import string
import modules.log4py as log4py
log = log4py.log4py('[Char]')
Chinese = 1
Japanese = 3
Korean=5
Vietnamese = 6
English = 8
#sublang
Mandarin = 11
Cantonese = 12
JapaneseOn = 31
JapaneseKun = 32
Hangul = 51
Korean_roman = 52
Us_en ... | Python |
#!/bin/dev python
# coding=utf8
from log4py import *
from char import *
import exceptions
import memory
import codecs
log = log4py.log4py('[group]')
class OverflowException(Exception):
pass
class Iter():
def __init__(self,maxsize):
self.items = []
self.maxsize = maxsize
def __iter__(self):... | Python |
#!/usr/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
class Mutitone():
'''多音字处理'''
def __init__(self, mtonefile):
self.mtonefile = mtonefile
self.mtones = {}
def initfile(self):
lines = open(sel... | Python |
#!/usr/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
import codecs
import string
import modules.log4py as log4py
log = log4py.log4py('[phonetic]')
Chinese = 1
#sublang
Mandarin = 11
Cantonese = 12
class Phonetic():
''' Proc... | Python |
#!/bin/env python
#coding=utf8
class User():
def __init(self,name,passwd):
self.name = name
self.passwd = passwd | Python |
#!/bin/env python
# --*-- coding=utf8 --*--
#
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License ... | Python |
#!/bin/dev python
# coding=utf8
import time
#记忆曲线,5min,30min,12hour,1day,2days,4days,7days,15days
REM_TIME=[300,1800,43200,86400,172800,345600,604800,1296000]
ISOTIMEFORMAT = '%Y-%m-%d %X'
class Memory():
"""
一、 复习点的确定(根据艾宾浩斯记忆曲线制定):
1. 第一个记忆周期:5分钟
2. 第二个记忆周期:30分钟
3. 第三个记忆周期:12小时
4. 第四个记忆周期:1天
5. 第五个记忆周期:2天
6. 第... | Python |
#!/usr/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
class Mutitone():
'''多音字处理'''
def __init__(self, mtonefile):
self.mtonefile = mtonefile
self.mtones = {}
def initfile(self):
lines = open(sel... | Python |
#!/bin/dev python
# coding=utf8
from memory import *
class Hanzi:
def __init__(self,hanzi):
self.mem=None
self.hanzi=hanzi
self.freq=1
self.pinyin=''
self.bihua=1
def setfreq(self, freq):
self.freq = freq
def setpinyin(self, pinyin):
s... | Python |
#!/bin/env python
# --*-- coding=utf8 --*--
#
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License ... | Python |
#!/bin/env python
#coding=utf8
class User():
def __init(self,name,passwd):
self.name = name
self.passwd = passwd | Python |
#!/bin/env python
# coding=utf8
| Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
import cPickle as pk
import sys
import traceback
log = log4py.log4py('[unihan]')
file_src = '../data/Unihandata.txt'
file_write='../data/unihan3.txt'
'''
0x4E00-0x9FFF CJK 统一字型 常用... | Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
import cPickle as pk
import traceback
import sys
WUBI=1
CANGJIE=2
FOURCORNER=3
ZHENGMA=4
'''
0x4E00-0x9FFF CJK 统一字型 常用字 共 20992个(实际只定义到0x9FC3)
0x3400-0x4DFF CJK 统一字... | Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
import cPickle as pk
import sys
import traceback
log = log4py.log4py('[unihan]')
file_src = '../data/Unihandata.txt'
file_write='../data/unihan3.txt'
'''
0x4E00-0x9FFF CJK 统一字型 常用... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# author ablozhou 周海汉
# ablozhou@gmail.com
# http://blog.csdn.net/ablo_zhou
# 2010.3.14
import chardet
import urllib
import modules.log4py as log4py
import sys
log = log4py.log4py('[encdet]')
def detect(filename, text = '', encoding = None):
defaultenc = sys.getfiles... | Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
dict={}
spaces=['',' ','\t','\n']
hzlist=[]
log = log4py.log4py('[unihan1]')
file_src = '../data/unihan2.txt'
file_write='../data/wubi.txt'
splitline = []
f=codecs.open(file_src, 'r','utf8')
fw = c... | Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
import cPickle as pk
import traceback
import sys
WUBI=1
CANGJIE=2
FOURCORNER=3
ZHENGMA=4
'''
0x4E00-0x9FFF CJK 统一字型 常用字 共 20992个(实际只定义到0x9FC3)
0x3400-0x4DFF CJK 统一字... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# author ablozhou 周海汉
# ablozhou@gmail.com
# http://blog.csdn.net/ablo_zhou
# 2010.3.14
import chardet
import urllib
import modules.log4py as log4py
import sys
log = log4py.log4py('[encdet]')
def detect(filename, text = '', encoding = None):
defaultenc = sys.getfiles... | Python |
#!/bin/env python
#coding:utf8
import modules.log4py as log4py
import modules.char as char
import codecs
import string
dict={}
spaces=['',' ','\t','\n']
hzlist=[]
log = log4py.log4py('[unihan1]')
file_src = '../data/unihan2.txt'
file_write='../data/wubi.txt'
splitline = []
f=codecs.open(file_src, 'r','utf8')
fw = c... | Python |
class Phonetic():
''' Process phonetic symbols of Chiese characters
or other languages.
'''
def replace(self,phonestr,tone):
if tone=='5':
return phonestr
arry_a = ['ā', 'á', 'ǎ', 'à']
arry_o = ['ō', 'ó', 'ǒ', 'ò']
arry_e = ['ē', 'é', 'ě', 'è']
arry_... | Python |
#!/bin/dev python
# coding=utf8
#from memory import *
import codecs
import string
import modules.log4py as log4py
log = log4py.log4py('[Char]')
Chinese = 1
Japanese = 3
Korean=5
Vietnamese = 6
English = 8
#sublang
Mandarin = 11
Cantonese = 12
JapaneseOn = 31
JapaneseKun = 32
Hangul = 51
Korean_roman = ... | Python |
#!/bin/env python
# --*-- coding=utf8 --*--
#
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License ... | Python |
#!/bin/env python
# --*-- coding=utf8 --*--
#
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License ... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published b... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# HZDQ(Hanzi Daquan) is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public Lice... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
import wx
import mainui_xrc
import wx.xrc as xrc
#import modules.group as group
import modules.log4py as log4py
import string
import procdict
import cPickle as pk
log = log4py.log4py('[hzdqframe]')
class hzdqframe(mainui_xrc.xrcmframe):
def __init__(self,parent):... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
# Author: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyright 2010 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# HZDQ(Hanzi Daquan) is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public Lice... | Python |
#!/bin/env python
# -*- coding: utf8 -*-
import wx
import mainui_xrc
import wx.xrc as xrc
#import modules.group as group
import modules.log4py as log4py
import string
import procdict
import cPickle as pk
log = log4py.log4py('[hzdqframe]')
class hzdqframe(mainui_xrc.xrcmframe):
def __init__(self,parent):... | Python |
#!/bin/env python
# coding=utf8
| Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import os
import mainui_xrc
import wx.xrc as xrc
import modules.group as group
import modules.log4py as log4py
import string
import codecs
import tools.encdet as encdet
log = log4py.log4py('[abcframe]')
class abcframe(mainui_xrc.xrcmframe):
def __init__(sel... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import os
import abcxrc
import wx.xrc as xrc
import modules.group as group
import modules.log4py as log4py
import string
import codecs
import tools.encdet as encdet
log = log4py.log4py('[abclfrm]')
class abclfrm(abcxrc.xrcmframe):
def __init__(self,parent):... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import os
import abcxrc
import wx.xrc as xrc
import modules.group as group
import modules.log4py as log4py
import string
import codecs
import tools.encdet as encdet
log = log4py.log4py('[abclfrm]')
class abclfrm(abcxrc.xrcmframe):
def __init__(self,parent):... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import os
import mainui_xrc
import wx.xrc as xrc
import modules.group as group
import modules.log4py as log4py
import string
import codecs
import tools.encdet as encdet
log = log4py.log4py('[abcframe]')
class abcframe(mainui_xrc.xrcmframe):
def __init__(sel... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import sys
import abcxrc
import abclfrm
class AbclApp(wx.App):
def OnInit(self):
self.mainfrm = abclfrm.abclfrm(parent = None)
self.SetTopWindow(self.mainfrm)
self.mainfrm.Show()
return True
def Exit(self):
pass... | Python |
#!/bin/env python
#coding=utf8
import wx
import sys
import modules.group
#import modules.char
class MainPanel(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self,parent,id,style=wx.BORDER_SUNKEN)
leftbox = wx.BoxSizer(wx.VERTICAL)
self.medit = wx.TextCtrl(self,-1,name='med... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import mainui_xrc
import abcframe
class AbclApp(wx.App):
def OnInit(self):
self.mainfrm = abcframe.abcframe(parent = None)
self.SetTopWindow(self.mainfrm)
self.mainfrm.Show()
return True
def Exit(self):
pass
... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import sys
import abcxrc
import abclfrm
class AbclApp(wx.App):
def OnInit(self):
self.mainfrm = abclfrm.abclfrm(parent = None)
self.SetTopWindow(self.mainfrm)
self.mainfrm.Show()
return True
def Exit(self):
pass... | Python |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import wx
import mainui_xrc
import abcframe
class AbclApp(wx.App):
def OnInit(self):
self.mainfrm = abcframe.abcframe(parent = None)
self.SetTopWindow(self.mainfrm)
self.mainfrm.Show()
return True
def Exit(self):
pass
... | Python |
#!/bin/env python
#coding=utf8
import wx
import sys
import modules.group
#import modules.char
class MainPanel(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self,parent,id,style=wx.BORDER_SUNKEN)
leftbox = wx.BoxSizer(wx.VERTICAL)
self.medit = wx.TextCtrl(self,-1,name='med... | Python |
#!/bin/dev python
# coding=utf8
import os
import sys
#import hanzi
import codecs
import time
#from modules import *
import modules.group
import ui.mainui
#todo group 要作成迭代器
workpath = os.path.dirname(os.path.realpath(sys.argv[0]))
confpath = os.path.join(workpath, 'conf')
sys.path.insert(0, workpath)
sys.path.insert... | Python |
#!/usr/bin/env python
import os,sys
import string
import urllib2
import zipfile
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
if __name__ == '__main__':
if len(sys.argv) != 2:
print "Ni hao! Chu cuo le!"
sys.exit(1)
if os.getenv("... | Python |
#!/bin/env python
#coding=utf8
import wx
import sys
class Panel(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self,parent,id,style=wx.BORDER_SUNKEN)
class Frame(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size = (500,400))
... | Python |
#!/bin/env python
# coding:utf8
class Fib:
'''生成菲波拉稀数列的迭代器'''
def __init__(self, max):
self.max = max
def __iter__(self):
self.a = 0
self.b = 1
return self
def next(self):
fib = self.a
if fib > self.max:
raise StopIteration
self.a, s... | Python |
#!/bin/env python
#-*- coding=utf8 -*-
import wx
import hello_xrc
app = wx.PySimpleApp()
frame = hello_xrc.xrczframe(parent = None)
frame.Show()
app.MainLoop() | Python |
#!/usr/bin/python3.0
# -*- coding:utf-8 -*-
# by: Tony
# from: <a href="http://tonychen123.blog.ubuntu.org.cn" target="_blank">Loving Ubuntu</a>
style_dic = {0:'Normal', 1:'Bold', 4:'Underline',
5:'Blink', 7:'Inverse'}
list_sdic = list(style_dic.keys())
for style in list_sdic:
#print... | Python |
#!/usr/bin/env python
#encoding=utf-8
#Copyright @ 2008 Jianjun Kong
import wx
import sys
import os,sys,string
import wx.richtext as rt
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
def search(x = ''):
if x == '':
return
... | Python |
#!/usr/bin/env python
#encoding=utf-8
#Copyright @ 2008 Jianjun Kong
import wx
import sys
import os,sys,string
import wx.richtext as rt
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
def search(x = ''):
if x == '':
return
... | Python |
#!/usr/bin/env python
#encoding=utf-8
#Copyright @ 2008 Jianjun Kong
import wx
import sys
import os,sys,string
import wx.richtext as rt
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
def search(x = ''):
if x == '':
return
... | Python |
#!/usr/bin/env python
#encoding=utf-8
#Copyright @ 2008 Jianjun Kong
import wx
import sys
import os,sys,string
import wx.richtext as rt
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
def search(x = ''):
if x == '':
return
... | Python |
#!/bin/env python
# coding=utf8
#能将列表封装出迭代器吗?
class Iter():
def __init__(self):
self.item = [1,2,3]
def __iter__(self):
self.i = 0
return self
def next(self):
if self.i < len(self.item):
it = self.item[self.i]
self.i += 1
re... | Python |
#!/bin/env python
# --*-- coding : utf8 --*--
# Programmer: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyleft 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public L... | Python |
#!/bin/env python
#-*- coding=utf8 -*-
import wx
import hello_xrc
app = wx.PySimpleApp()
frame = hello_xrc.xrczframe(parent = None)
frame.Show()
app.MainLoop() | Python |
#!/bin/env python
#coding=utf8
import wx
import sys
class Panel(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self,parent,id,style=wx.BORDER_SUNKEN)
class Frame(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size = (500,400))
... | Python |
#!/bin/env python
# coding:utf8
class Fib:
'''生成菲波拉稀数列的迭代器'''
def __init__(self, max):
self.max = max
def __iter__(self):
self.a = 0
self.b = 1
return self
def next(self):
fib = self.a
if fib > self.max:
raise StopIteration
self.a, s... | Python |
#!/bin/env python
# coding=utf8
#import sys
#sys.path.append('/home/zhouhh/abclearning')
import unittest
import sys
print sys.path
import modules.group
#no module named modules?
gs = modules.group.Groups(2,2)
gs.open('./data/freq_part.txt')
class testgroup(unittest.TestCase):
def testwalk(self):
gs.w... | Python |
#!/usr/bin/env python
import os,sys
import string
import urllib2
import zipfile
def find_it(x, lines):
ret = []
for line in lines:
if line.find(x)!=-1:
ret.append(line.split(":")[0].strip())
return ret
if __name__ == '__main__':
if len(sys.argv) != 2:
print "Ni hao! Chu cuo le!"
sys.exit(1)
if os.getenv("... | Python |
#!/usr/bin/python3.0
# -*- coding:utf-8 -*-
# by: Tony
# from: <a href="http://tonychen123.blog.ubuntu.org.cn" target="_blank">Loving Ubuntu</a>
style_dic = {0:'Normal', 1:'Bold', 4:'Underline',
5:'Blink', 7:'Inverse'}
list_sdic = list(style_dic.keys())
for style in list_sdic:
#print... | Python |
#!/bin/env python
# --*-- coding : utf8 --*--
# Programmer: ablozhou
# E-mail: ablozhou@gmail.com
#
# Copyleft 2009 ablozhou
#
# Distributed under the terms of the GPL (GNU Public License)
#
# abcl is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public L... | Python |
##################################################################################
#General:
# read http://wiki.wxpython.org/index.cgi/UsingXmlResources for more information about how to use xrc
#
#Problems:
# google "(class 'wxMenuBar') not found ", visit http://aspn.activestate.com/ASPN/Mail/Message/wxPython-users/... | Python |
#!/bin/env python
# coding=utf8
#能将列表封装出迭代器吗?
class Iter():
def __init__(self):
self.item = [1,2,3]
def __iter__(self):
self.i = 0
return self
def next(self):
if self.i < len(self.item):
it = self.item[self.i]
self.i += 1
re... | Python |
#!/bin/env python
# coding=utf8
#import sys
#sys.path.append('/home/zhouhh/abclearning')
import unittest
import sys
print sys.path
import modules.group
#no module named modules?
gs = modules.group.Groups(2,2)
gs.open('./data/freq_part.txt')
class testgroup(unittest.TestCase):
def testwalk(self):
gs.w... | Python |
#!/usr/bin/python2.6
#
# Simple http server to emulate api.playfoursquare.com
import logging
import shutil
import sys
import urlparse
import SimpleHTTPServer
import BaseHTTPServer
class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Handle playfoursquare.com requests, for testing."""
def do_GET(self... | Python |
#!/usr/bin/python
import os
import subprocess
import sys
BASEDIR = '../main/src/com/joelapenna/foursquare'
TYPESDIR = '../captures/types/v1'
captures = sys.argv[1:]
if not captures:
captures = os.listdir(TYPESDIR)
for f in captures:
basename = f.split('.')[0]
javaname = ''.join([c.capitalize() for c in basena... | Python |
#!/usr/bin/python
"""
Pull a oAuth protected page from foursquare.
Expects ~/.oget to contain (one on each line):
CONSUMER_KEY
CONSUMER_KEY_SECRET
USERNAME
PASSWORD
Don't forget to chmod 600 the file!
"""
import httplib
import os
import re
import sys
import urllib
import urllib2
import urlparse
import user
from xml.... | Python |
#!/usr/bin/python
import datetime
import sys
import textwrap
import common
from xml.dom import pulldom
PARSER = """\
/**
* Copyright 2009 Joe LaPenna
*/
package com.joelapenna.foursquare.parsers;
import com.joelapenna.foursquare.Foursquare;
import com.joelapenna.foursquare.error.FoursquareError;
import com.joel... | Python |
#!/usr/bin/python
import logging
from xml.dom import minidom
from xml.dom import pulldom
BOOLEAN = "boolean"
STRING = "String"
GROUP = "Group"
# Interfaces that all FoursquareTypes implement.
DEFAULT_INTERFACES = ['FoursquareType']
# Interfaces that specific FoursqureTypes implement.
INTERFACES = {
}
DEFAULT_CLA... | Python |
from djangoappengine.settings_base import *
FACEBOOK_API_KEY = ''
FACEBOOK_APP_ID = ''
FACEBOOK_SECRET_KEY = ''
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET_KEY = ''
TWITTER_REQUEST_TOKEN_URL = ''
TWITTER_ACCESS_TOKEN_URL = ''
TWITTER_AUTHORIZATION_URL = ''
SECRET_KEY = '=r-$b*8hglm+858&9t043hlm6-&6-3d3vfc4((7y... | Python |
from exceptions import ImportError, ValueError
from django.contrib import admin
from django.db import models
from django.core.exceptions import SuspiciousOperation
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
impor... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from django import template
from django import forms
from django.http import HttpResponseRedirect
import datetime,sys
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from tagging.models import Tag, TaggedItem
from pirate_reputation.models import ReputationManager, ... | Python |
# Create your views here.
| Python |
from django.db import models
# Create your models here.
from piston.handler import BaseHandler
from myapp.models import Blogpost
class BlogpostHandler(BaseHandler):
allowed_methods = ('GET',)
model = Blogpost
def read(self, request, post_slug): | 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 django.conf.urls.defaults import *
from handlers import ContentHandler, UserHandler, VoteHandler, PKHandler
from piston.resource import Resource
content_handler = Resource(ContentHandler)
user_handler = Resource(UserHandler)
vote_handler = Resource(VoteHandler)
pk_handler = Resource(PKHandler)
urlpatterns = pat... | Python |
from piston.handler import BaseHandler
from pirate_forum.models import ForumDimension
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
from pirate_profile.models import Profile
from pirate_consensus.models import UpDownVote, RatingVote
from pirate_core.templatetags.... | Python |
# Create your views here.
| Python |
from django.db import models
from django.contrib import admin
# Create your models here.
class Register(models.Model):
name = models.CharField(max_length=140, unique = True)
password1 = models.CharField(max_length=600)
password2 = models.CharField(max_length=600)
email = models.CharField(max_length=600... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from django import template
from django import forms
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404
import datetime
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from pirate_core import HttpRedirectException, namespace... | Python |
# Create your views here.
from django.contrib.auth import logout
from django.http import HttpResponseRedirect
from pirate_core import HttpRedirectException, namespace_get, FormMixin
def logout_view(request):
try:goto = request.session['currently_visiting']
except: goto = '/index.html'
logout(request)
r... | Python |
from dbindexer.api import register_index
from tagging.models import Tag
register_index(MyModel, {'name': 'icontains'})
| Python |
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from pirate_core import HttpRedirectException, namespace_get, FormMixin
from pirate_sources.models import IMGSource
from pirate_social.models import Locati... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | Python |
from django import template
from django import forms
from django.http import HttpResponseRedirect
import datetime
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from tagging.models import Tag, TaggedItem
from pirate_profile.models import Profile
from pirate_core.h... | Python |
# Create your views here.
| Python |
from django.contrib.contenttypes.models import ContentType
from django.db.models import signals
from django.conf import settings
from django.utils.translation import ugettext_noop as _
from pirate_forum.templatetags.blobtags import get_models
if "pirate_badges" in settings.INSTALLED_APPS:
from pirate_badges.models... | Python |
from exceptions import ImportError, ValueError
from django.contrib import admin
from django.db import models
from django.core.exceptions import SuspiciousOperation
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
from ... | Python |
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
... | 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.