code stringlengths 1 1.49M | vector listlengths 0 7.38k | snippet listlengths 0 7.38k |
|---|---|---|
#! /usr/bin/env python
#coding=utf-8
# -*- coding: utf-8 -*-
import log
#
# transitionMap = {
# (fromState, event):toState,
# (fromState, event):toState,
# ...
# }
#
#
#
class IFsmCallbackObj(object):
def __init__(self):
pass
def OnEnterState(self, state):
pass
def OnLeaveState(s... | [
[
1,
0,
0.0784,
0.0196,
0,
0.66,
0,
432,
0,
1,
0,
0,
432,
0,
0
],
[
3,
0,
0.402,
0.2353,
0,
0.66,
0.5,
381,
0,
4,
0,
0,
186,
0,
0
],
[
2,
1,
0.3235,
0.0392,
1,
0.82... | [
"import log",
"class IFsmCallbackObj(object):\n\tdef __init__(self):\n\t\tpass\n\n\tdef OnEnterState(self, state):\n\t\tpass\n\n\tdef OnLeaveState(self, state):",
"\tdef __init__(self):\n\t\tpass",
"\tdef OnEnterState(self, state):\n\t\tpass",
"\tdef OnLeaveState(self, state):\n\t\tpass",
"\tdef OnEvent(s... |
#! /usr/bin/env python
#coding=utf-8
import math3d,math
LEFT_SIDE = 0x01
RIGHT_SIDE = 0x02
NONE_SIDE = 0x03
def angle(o, s, e):
cosfi = 0
fi = 0
norm = 0
dsx = s[0] - o[0]
dsy = s[1] - o[1]
dex = e[0] - o[0]
dey = e[1] - o[1]
cosfi = dsx * dex + dsy * dey
norm = (dsx * dsx + dsy * dsy)... | [
[
1,
0,
0.0135,
0.0045,
0,
0.66,
0,
679,
0,
2,
0,
0,
679,
0,
0
],
[
14,
0,
0.027,
0.0045,
0,
0.66,
0.0526,
654,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.0315,
0.0045,
0,
0... | [
"import math3d,math",
"LEFT_SIDE = 0x01",
"RIGHT_SIDE = 0x02",
"NONE_SIDE = 0x03",
"def angle(o, s, e):\n\tcosfi = 0\n\tfi = 0\n\tnorm = 0\n\tdsx = s[0] - o[0]\n\tdsy = s[1] - o[1]\n\tdex = e[0] - o[0]\n\tdey = e[1] - o[1]",
"\tcosfi = 0",
"\tfi = 0",
"\tnorm = 0",
"\tdsx = s[0] - o[0]",
"\tdsy = ... |
#-- coding: utf-8 -*-
import utils, sys
lstDir = utils.listdir("tgame/script/")
print "lstDir = %s" % str(lstDir)
sys.path.extend(lstDir)
import tgame_net_handler, t_cmd
import tgame_room_logic
import iapi
import tgame_ready
import tgame_menu
tgame_API = None
GAMEID = -1
GAME_MODE = None
UID = None
GA... | [
[
1,
0,
0.0167,
0.0083,
0,
0.66,
0,
970,
0,
2,
0,
0,
970,
0,
0
],
[
14,
0,
0.025,
0.0083,
0,
0.66,
0.0625,
419,
3,
1,
0,
0,
551,
10,
1
],
[
8,
0,
0.0333,
0.0083,
0,
... | [
"import utils, sys",
"lstDir = utils.listdir(\"tgame/script/\")",
"print(\"lstDir = %s\" % str(lstDir))",
"sys.path.extend(lstDir)",
"import tgame_net_handler, t_cmd",
"import tgame_room_logic",
"import iapi",
"import tgame_ready",
"import tgame_menu",
"tgame_API = None",
"GAMEID = -1",
"GAME_... |
#! /usr/bin/env python
#coding=utf-8
#-- coding: utf-8 -*-
import tgame_room_logic, t_cmd
def init():
#网络消息到具体回调函数的映射表
global MSG_MAP
MSG_MAP = {
#游戏模式信息
"game_s_game_mode" : tgame_room_logic.inst.s_game_mode, \
#玩家进入
"game_s_user_in_game" : tgame_room_logic.inst.s_user_in_game, \
#玩家退出
"g... | [
[
1,
0,
0.0976,
0.0244,
0,
0.66,
0,
102,
0,
2,
0,
0,
102,
0,
0
],
[
2,
0,
0.5732,
0.878,
0,
0.66,
1,
319,
0,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.6098,
0.8049,
1,
0.6,
... | [
"import tgame_room_logic, t_cmd",
"def init():\n\t#网络消息到具体回调函数的映射表\n\tglobal MSG_MAP\n\tMSG_MAP\t= {\n\t\t#游戏模式信息\n\t\t\"game_s_game_mode\" : tgame_room_logic.inst.s_game_mode, \\\n\t\t#玩家进入\n\t\t\"game_s_user_in_game\" : tgame_room_logic.inst.s_user_in_game, \\",
"\tMSG_MAP\t= {\n\t\t#游戏模式信息\n\t\t\"game_s_game... |
#-- coding: utf-8 -*-
#游戏客户端的入口函数,当使用独立公共大厅的时候,这个函数将在玩家登陆游戏房间的时候被调用,从此程序逻辑将交给各个游戏自己完成
def init(**kargs):
#进入游戏自己的初始化函数
import tgame_game
tgame_game.start_from_init(int(kargs["gameid"]), int(kargs["gamemode"]), int(kargs["uid"]))
#游戏客户端的退出函数,当玩家从游戏房间退出时,公共大厅逻辑会调用这个函数,游戏逻辑需要在这个函数里完成游戏对象的释放工作,防止内存泄漏
def force_... | [
[
2,
0,
0.375,
0.3333,
0,
0.66,
0,
319,
0,
1,
0,
0,
0,
0,
4
],
[
1,
1,
0.4167,
0.0833,
1,
0.03,
0,
272,
0,
1,
0,
0,
272,
0,
0
],
[
8,
1,
0.5,
0.0833,
1,
0.03,
1... | [
"def init(**kargs):\n\t#进入游戏自己的初始化函数\n\timport tgame_game\n\ttgame_game.start_from_init(int(kargs[\"gameid\"]), int(kargs[\"gamemode\"]), int(kargs[\"uid\"]))",
"\timport tgame_game",
"\ttgame_game.start_from_init(int(kargs[\"gameid\"]), int(kargs[\"gamemode\"]), int(kargs[\"uid\"]))",
"def force_destroy():\n... |
#! /usr/bin/env python
#coding=utf-8
#-- coding: utf-8 -*-
import tgame_room_logic, t_cmd
def init():
#网络消息到具体回调函数的映射表
global MSG_MAP
MSG_MAP = {
#游戏模式信息
"game_s_game_mode" : tgame_room_logic.inst.s_game_mode, \
#玩家进入
"game_s_user_in_game" : tgame_room_logic.inst.s_user_in_game, \
#玩家退出
"g... | [
[
1,
0,
0.0976,
0.0244,
0,
0.66,
0,
102,
0,
2,
0,
0,
102,
0,
0
],
[
2,
0,
0.5732,
0.878,
0,
0.66,
1,
319,
0,
0,
0,
0,
0,
0,
0
],
[
14,
1,
0.6098,
0.8049,
1,
0.64,
... | [
"import tgame_room_logic, t_cmd",
"def init():\n\t#网络消息到具体回调函数的映射表\n\tglobal MSG_MAP\n\tMSG_MAP\t= {\n\t\t#游戏模式信息\n\t\t\"game_s_game_mode\" : tgame_room_logic.inst.s_game_mode, \\\n\t\t#玩家进入\n\t\t\"game_s_user_in_game\" : tgame_room_logic.inst.s_user_in_game, \\",
"\tMSG_MAP\t= {\n\t\t#游戏模式信息\n\t\t\"game_s_game... |
import iapi
API = None
def init():
global API
API = iapi.API()
| [
[
1,
0,
0.125,
0.125,
0,
0.66,
0,
692,
0,
1,
0,
0,
692,
0,
0
],
[
14,
0,
0.5,
0.125,
0,
0.66,
0.5,
839,
1,
0,
0,
0,
0,
9,
0
],
[
2,
0,
0.875,
0.375,
0,
0.66,
1,... | [
"import iapi",
"API = None",
"def init():\n\tglobal API\n\tAPI = iapi.API()",
"\tAPI = iapi.API()"
] |
from t_const import *
#关卡开启需求信息,key是关卡id,value是一个列表,表示开启关卡必须完成的其他关卡的id列表
STAGE_REQUIRE = {
1 : [],
}
DATA = {
1 : {
"monster" : "tgame_map_demo",
},
}
def set_stage_info():
global DATA
for value in DATA.values():
tgame_map = value["monster"]
tgame_map = __import__(tgame_map)
s... | [
[
1,
0,
0.0312,
0.0312,
0,
0.66,
0,
855,
0,
1,
0,
0,
855,
0,
0
],
[
14,
0,
0.1562,
0.0938,
0,
0.66,
0.25,
833,
0,
0,
0,
0,
0,
6,
0
],
[
14,
0,
0.375,
0.2188,
0,
0.6... | [
"from t_const import *",
"STAGE_REQUIRE = {\n\t\t1 : [],\n}",
"DATA = {\n\n\t1 : {\n\t\t\t\"monster\" : \"tgame_map_demo\",\n\t\t},\n\n}",
"def set_stage_info():\n\tglobal DATA\n\tfor value in DATA.values():\n\t\ttgame_map = value[\"monster\"]\n\t\ttgame_map = __import__(tgame_map)\n\t\tstage_info = tgame_map... |
# 事件定义
# 转向
C_TUREND = 0x01
S_TUREND = 0x01
# 移动
C_MOVE = 0x02
S_MOVE = 0x02
# 移动2
C_RUN = 0x03
S_RUN = 0x03
# 攻击
C_ATK = 0x04
S_ATK = 0X04
# 拾取
C_PICKITEM = 0X05
S_PICKITEM = 0X05
# 使用物品
C_USEITEM = 0X06
S_USEITEM = 0X06
# 游戏时间
S_GAMETIME = 0x91
# 出现僵尸
S_GAME_BULZB = 0x71
# 事件
S_GAME_EVENT = 0x... | [
[
14,
0,
0.0162,
0.0054,
0,
0.66,
0,
682,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.0216,
0.0054,
0,
0.66,
0.0625,
108,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.0324,
0.0054,
0,
0... | [
"C_TUREND = 0x01",
"S_TUREND = 0x01",
"C_MOVE = 0x02",
"S_MOVE = 0x02",
"C_RUN = 0x03",
"S_RUN = 0x03",
"C_ATK = 0x04",
"S_ATK = 0X04",
"C_PICKITEM = 0X05",
"S_PICKITEM = 0X05",
"C_USEITEM = 0X06",
"S_USEITEM = 0X06",
"S_GAMETIME = 0x91",
"S_GAME_BULZB = 0x71",
"S_GAME_EVENT = 0x81",
"... |
#-- coding: utf-8 -*-
import t_const
"""巫师指令定义方面客户端和服务端公用,其他的函数为客户端专用"""
WIZARD_CHANGE_SUN = 0x01 #改变阳光数量
WIZARD_END_GAME = 0x02 #立刻结束游戏
WIZARD_ADD_ZOMBIE = 0x03 #立刻刷新僵尸
#帮助文字字典
HELP_TEXT = {WIZARD_CHANGE_SUN : "改变阳光数量指令//change_sun:参数1:整数(可正负,代表阳光数量的改变值),示例://change_sun 100", \
WIZARD_END_GAM... | [
[
1,
0,
0.0189,
0.0094,
0,
0.66,
0,
855,
0,
1,
0,
0,
855,
0,
0
],
[
8,
0,
0.0377,
0.0094,
0,
0.66,
0.1111,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0472,
0.0094,
0,
0.6... | [
"import t_const",
"\"\"\"巫师指令定义方面客户端和服务端公用,其他的函数为客户端专用\"\"\"",
"WIZARD_CHANGE_SUN\t= 0x01\t\t\t\t#改变阳光数量",
"WIZARD_END_GAME\t\t= 0x02\t\t\t\t#立刻结束游戏",
"WIZARD_ADD_ZOMBIE\t= 0x03\t\t\t\t#立刻刷新僵尸",
"HELP_TEXT = {WIZARD_CHANGE_SUN : \"改变阳光数量指令//change_sun:参数1:整数(可正负,代表阳光数量的改变值),示例://change_sun 100\", \\\n\t\t... |
# -*- coding: utf-8 -*-
import base_object
import t_cmd
import cg_network
import cPickle
import tgame_room_logic
import tgame_mapmgr
inst = None
#模块初始化函数
def init():
global inst
if not inst:
inst = CCommand()
#模块自清理函数,释放引用
def destroy():
global inst
if inst:
inst.destroy()
inst = None
... | [
[
1,
0,
0.0206,
0.0103,
0,
0.66,
0,
882,
0,
1,
0,
0,
882,
0,
0
],
[
1,
0,
0.0309,
0.0103,
0,
0.66,
0.1111,
496,
0,
1,
0,
0,
496,
0,
0
],
[
1,
0,
0.0412,
0.0103,
0,
... | [
"import base_object",
"import t_cmd",
"import cg_network",
"import cPickle",
"import tgame_room_logic",
"import tgame_mapmgr",
"inst = None",
"def init():\n\tglobal inst\n\tif not inst:\n\t\tinst = CCommand()",
"\tif not inst:\n\t\tinst = CCommand()",
"\t\tinst = CCommand()",
"def destroy():\n\t... |
'''
main.py
Main file for 2 Pints
2 Pints is an implementation of Quarto written in Python
Dave Schwantes
2010
www.dinosaurseateverybody.com
'''
from QuartoGame import *
def main():
print "2 Pints"
print "a Quarto implementation by Dave Schwantes"
print ""
game = QuartoGame()
print "The Boa... | [
[
8,
0,
0.1058,
0.1923,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2308,
0.0192,
0,
0.66,
0.3333,
549,
0,
1,
0,
0,
549,
0,
0
],
[
2,
0,
0.5962,
0.6731,
0,
0.66... | [
"'''\nmain.py\n\nMain file for 2 Pints\n2 Pints is an implementation of Quarto written in Python\n\nDave Schwantes\n2010",
"from QuartoGame import *",
"def main():\n print(\"2 Pints\")\n print(\"a Quarto implementation by Dave Schwantes\")\n print(\"\")\n game = QuartoGame()\n \n print(\"The B... |
'''
QuartoGame.py
Class for the QuartoGame object
'''
import math
from QuartoBoard import *
from QuartoPiece import *
class QuartoGame:
def __init__(self):
self.board = QuartoBoard()
self.turn = 0
self.availablePieces = []
self.buildPieces()
self.history ... | [
[
8,
0,
0.0229,
0.0382,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0534,
0.0076,
0,
0.66,
0.25,
526,
0,
1,
0,
0,
526,
0,
0
],
[
1,
0,
0.0687,
0.0076,
0,
0.66,
... | [
"'''\nQuartoGame.py\n\nClass for the QuartoGame object\n'''",
"import math",
"from QuartoBoard import *",
"from QuartoPiece import *",
"class QuartoGame:\n def __init__(self):\n self.board = QuartoBoard()\n self.turn = 0\n self.availablePieces = []\n self.buildPieces()\n ... |
'''
main.py
Main file for 2 Pints
2 Pints is an implementation of Quarto written in Python
Dave Schwantes
2010
www.dinosaurseateverybody.com
'''
from QuartoGame import *
from TwoPints import *
def main():
print "2 Pints"
print "a Quarto playing bot by Dave Schwantes"
print ""
game = QuartoGame()
... | [
[
8,
0,
0.0846,
0.1538,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1846,
0.0154,
0,
0.66,
0.25,
549,
0,
1,
0,
0,
549,
0,
0
],
[
1,
0,
0.2,
0.0154,
0,
0.66,
... | [
"'''\nmain.py\n\nMain file for 2 Pints\n2 Pints is an implementation of Quarto written in Python\n\nDave Schwantes\n2010",
"from QuartoGame import *",
"from TwoPints import *",
"def main():\n print(\"2 Pints\")\n print(\"a Quarto playing bot by Dave Schwantes\")\n print(\"\")\n game = QuartoGame()... |
'''
QuartoPiece.py
Class for the QuartoPiece object
def of
'''
class QuartoPiece:
def __init__(self, height, color, shape, fill):
self.attributes = (height, color, shape, fill)
self.onBoard = False
self.placedBy = None
pass
def displayPiece(self):
print self.at... | [
[
8,
0,
0.2222,
0.3889,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
3,
0,
0.75,
0.5556,
0,
0.66,
1,
693,
0,
2,
0,
0,
0,
0,
1
],
[
2,
1,
0.6667,
0.2778,
1,
0.5,
0,
... | [
"'''\nQuartoPiece.py\n\nClass for the QuartoPiece object\n\ndef of \n'''",
"class QuartoPiece:\n def __init__(self, height, color, shape, fill):\n self.attributes = (height, color, shape, fill)\n self.onBoard = False\n self.placedBy = None\n pass",
" def __init__(self, height, ... |
#!/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... | [
[
1,
0,
0.1429,
0.0714,
0,
0.66,
0,
879,
0,
1,
0,
0,
879,
0,
0
],
[
1,
0,
0.2143,
0.0714,
0,
0.66,
0.25,
201,
0,
1,
0,
0,
201,
0,
0
],
[
7,
0,
0.4643,
0.4286,
0,
0.... | [
"from django.core.management import execute_manager",
"import imp",
"try:\n imp.find_module('settings') # Assumed to be in the same directory.\nexcept ImportError:\n import sys\n sys.stderr.write(\"Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized thi... |
#!/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... | [
[
1,
0,
0.1429,
0.0714,
0,
0.66,
0,
879,
0,
1,
0,
0,
879,
0,
0
],
[
1,
0,
0.2143,
0.0714,
0,
0.66,
0.25,
201,
0,
1,
0,
0,
201,
0,
0
],
[
7,
0,
0.4643,
0.4286,
0,
0.... | [
"from django.core.management import execute_manager",
"import imp",
"try:\n imp.find_module('settings') # Assumed to be in the same directory.\nexcept ImportError:\n import sys\n sys.stderr.write(\"Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized thi... |
from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin
admin.autodiscover()
from django.views.generic.simple import direct_to_template
import settings
urlpatterns = patterns('',
(r'^$', 'Exam.views.exam_list'),
(r'^exams/?$', 'Exam.views.exam_list'),
(r'^view... | [
[
1,
0,
0.0333,
0.0333,
0,
0.66,
0,
341,
0,
3,
0,
0,
341,
0,
0
],
[
1,
0,
0.0667,
0.0333,
0,
0.66,
0.2,
302,
0,
1,
0,
0,
302,
0,
0
],
[
8,
0,
0.1,
0.0333,
0,
0.66,
... | [
"from django.conf.urls.defaults import patterns, include, url",
"from django.contrib import admin",
"admin.autodiscover()",
"from django.views.generic.simple import direct_to_template",
"import settings",
"urlpatterns = patterns('',\n (r'^$', 'Exam.views.exam_list'),\n (r'^exams/?$', 'Exam.views.exa... |
import os.path
# Django settings for YourSchool 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', ... | [
[
1,
0,
0.0069,
0.0069,
0,
0.66,
0,
79,
0,
1,
0,
0,
79,
0,
0
],
[
14,
0,
0.0276,
0.0069,
0,
0.66,
0.037,
309,
1,
0,
0,
0,
0,
4,
0
],
[
14,
0,
0.0345,
0.0069,
0,
0.6... | [
"import os.path",
"DEBUG = True",
"TEMPLATE_DEBUG = DEBUG",
"ADMINS = (\n # ('Your Name', 'your_email@example.com'),\n)",
"MANAGERS = ADMINS",
"DATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.\n ... |
from django.db import models
class Exam(models.Model):
name = models.CharField(max_length=64)
created = models.DateField()
deadline = models.DateField()
author = models.CharField(max_length=64)
class ExamQuestion(models.Model):
question = models.CharField(max_length=64)
exam = models.ForeignKey(... | [
[
1,
0,
0.025,
0.025,
0,
0.66,
0,
40,
0,
1,
0,
0,
40,
0,
0
],
[
3,
0,
0.125,
0.125,
0,
0.66,
0.1429,
150,
0,
0,
0,
0,
996,
0,
4
],
[
14,
1,
0.1,
0.025,
1,
0.43,
... | [
"from django.db import models",
"class Exam(models.Model):\n\tname = models.CharField(max_length=64)\n\tcreated = models.DateField()\n\tdeadline = models.DateField()\n\tauthor = models.CharField(max_length=64)",
"\tname = models.CharField(max_length=64)",
"\tcreated = models.DateField()",
"\tdeadline = mode... |
"""
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... | [
[
8,
0,
0.2188,
0.375,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.5,
0.0625,
0,
0.66,
0.5,
944,
0,
1,
0,
0,
944,
0,
0
],
[
3,
0,
0.8438,
0.375,
0,
0.66,
1,... | [
"\"\"\"\nThis file demonstrates writing tests using the unittest module. These will pass\nwhen you run \"manage.py test\".\n\nReplace this with more appropriate tests for your application.\n\"\"\"",
"from django.test import TestCase",
"class SimpleTest(TestCase):\n def test_basic_addition(self):\n \"\... |
# Create your views here.
# -*- coding: utf-8 -*-
from audioop import reverse
from datetime import datetime, date
import string
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, redirect, HttpResponse, RequestContext, get_object_or_404
from django.contrib.auth import l... | [
[
1,
0,
0.015,
0.005,
0,
0.66,
0,
296,
0,
1,
0,
0,
296,
0,
0
],
[
1,
0,
0.02,
0.005,
0,
0.66,
0.0588,
426,
0,
2,
0,
0,
426,
0,
0
],
[
1,
0,
0.025,
0.005,
0,
0.66,
... | [
"from audioop import reverse",
"from datetime import datetime, date",
"import string",
"from django.http import HttpResponseRedirect",
"from django.shortcuts import render_to_response, redirect, HttpResponse, RequestContext, get_object_or_404",
"from django.contrib.auth import logout",
"from django.cont... |
import liblo, math
#import pyglet, rabbyt
class touchList(list):
"""a class that responds to OSC messages with TUIO data"""
lastAlive=[]
lastSet=[]
def tuioAlive(self,pointsList):
"""process the arguments of a TUIO Alive message"""
for x in self:
if x[0] not in pointsList:
self.remove(x)
self.statsR... | [
[
1,
0,
0.0055,
0.0055,
0,
0.66,
0,
925,
0,
2,
0,
0,
925,
0,
0
],
[
3,
0,
0.0956,
0.153,
0,
0.66,
0.125,
75,
0,
3,
0,
0,
430,
0,
10
],
[
8,
1,
0.0273,
0.0055,
1,
0.... | [
"import liblo, math",
"class touchList(list):\n\t\"\"\"a class that responds to OSC messages with TUIO data\"\"\"\n\tlastAlive=[]\n\tlastSet=[]\n\tdef tuioAlive(self,pointsList):\n\t\t\"\"\"process the arguments of a TUIO Alive message\"\"\"\n\t\tfor x in self:\n\t\t\tif x[0] not in pointsList:",
"\t\"\"\"a cla... |
#!/usr/bin/python
# gameswf_batch_test.py -Thatcher Ulrich <tu@tulrich.com> 2005
# This source code has been donated to the Public Domain. Do
# whatever you want with it.
# Script for batch regression tests on gameswf.
import string
import sys
import commands
import difflib
import re
GAMESWF = "./g... | [
[
1,
0,
0.0588,
0.0059,
0,
0.66,
0,
890,
0,
1,
0,
0,
890,
0,
0
],
[
1,
0,
0.0647,
0.0059,
0,
0.66,
0.0625,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0706,
0.0059,
0,
... | [
"import string",
"import sys",
"import commands",
"import difflib",
"import re",
"GAMESWF = \"./gameswf_test_ogl\"",
"BATCH_ARGS = \" -r 0 -1 -t 10 -v \"",
"def run_batch_test(testname, testfile, expected_output):\n '''Run gameswf on a test file, and compare its output to the given expected output.\n... |
#!/usr/bin/python
# gameswf_batch_test.py -Thatcher Ulrich <tu@tulrich.com> 2005
# This source code has been donated to the Public Domain. Do
# whatever you want with it.
# Script to interactively run all the .swf's in samples/ one-by-one.
#
# Pass a path argument to start with a particular test file.
i... | [
[
1,
0,
0.2222,
0.0185,
0,
0.66,
0,
958,
0,
1,
0,
0,
958,
0,
0
],
[
1,
0,
0.2407,
0.0185,
0,
0.66,
0.125,
760,
0,
1,
0,
0,
760,
0,
0
],
[
1,
0,
0.2593,
0.0185,
0,
0... | [
"import glob",
"import commands",
"import re",
"import sys",
"GAMESWF = \"./gameswf_test_ogl\"",
"BATCH_ARGS = \" -v \"",
"def run_swf(testfile):\n '''Run gameswf on a test file.\n\n Returns: True if gameswf exited with OK status, False otherwise.\n '''\n\n print(\"Running: \" + testfile)",
" '''... |
#!/usr/bin/python
# gameswf_batch_test.py -Thatcher Ulrich <tu@tulrich.com> 2005
# This source code has been donated to the Public Domain. Do
# whatever you want with it.
# Script for batch regression tests on gameswf.
import string
import sys
import commands
import difflib
import re
GAMESWF = "./g... | [
[
1,
0,
0.0588,
0.0059,
0,
0.66,
0,
890,
0,
1,
0,
0,
890,
0,
0
],
[
1,
0,
0.0647,
0.0059,
0,
0.66,
0.0625,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.0706,
0.0059,
0,
... | [
"import string",
"import sys",
"import commands",
"import difflib",
"import re",
"GAMESWF = \"./gameswf_test_ogl\"",
"BATCH_ARGS = \" -r 0 -1 -t 10 -v \"",
"def run_batch_test(testname, testfile, expected_output):\n '''Run gameswf on a test file, and compare its output to the given expected output.\n... |
#!/usr/bin/python
# gameswf_batch_test.py -Thatcher Ulrich <tu@tulrich.com> 2005
# This source code has been donated to the Public Domain. Do
# whatever you want with it.
# Script to interactively run all the .swf's in samples/ one-by-one.
#
# Pass a path argument to start with a particular test file.
i... | [
[
1,
0,
0.2222,
0.0185,
0,
0.66,
0,
958,
0,
1,
0,
0,
958,
0,
0
],
[
1,
0,
0.2407,
0.0185,
0,
0.66,
0.125,
760,
0,
1,
0,
0,
760,
0,
0
],
[
1,
0,
0.2593,
0.0185,
0,
0... | [
"import glob",
"import commands",
"import re",
"import sys",
"GAMESWF = \"./gameswf_test_ogl\"",
"BATCH_ARGS = \" -v \"",
"def run_swf(testfile):\n '''Run gameswf on a test file.\n\n Returns: True if gameswf exited with OK status, False otherwise.\n '''\n\n print(\"Running: \" + testfile)",
" '''... |
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
| [
[
7,
0,
0.6667,
0.8333,
0,
0.66,
0,
0,
0,
1,
0,
0,
0,
0,
3
],
[
8,
1,
0.5,
0.1667,
1,
0.78,
0,
736,
3,
1,
0,
0,
0,
0,
2
],
[
1,
1,
0.8333,
0.1667,
1,
0.78,
0,
... | [
"try:\n __import__('pkg_resources').declare_namespace(__name__)\nexcept ImportError:\n from pkgutil import extend_path\n __path__ = extend_path(__path__, __name__)",
" __import__('pkg_resources').declare_namespace(__name__)",
" from pkgutil import extend_path",
" __path__ = extend_path(__pat... |
import unittest
from zope.testing import doctestunit
from zope.component import testing
from Testing import ZopeTestCase as ztc
from Products.Five import zcml
from Products.Five import fiveconfigure
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import PloneSite
ptc.setupPlo... | [
[
1,
0,
0.0189,
0.0189,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0566,
0.0189,
0,
0.66,
0.0833,
984,
0,
1,
0,
0,
984,
0,
0
],
[
1,
0,
0.0755,
0.0189,
0,
0.... | [
"import unittest",
"from zope.testing import doctestunit",
"from zope.component import testing",
"from Testing import ZopeTestCase as ztc",
"from Products.Five import zcml",
"from Products.Five import fiveconfigure",
"from Products.PloneTestCase import PloneTestCase as ptc",
"from Products.PloneTestCa... |
from plone.theme.interfaces import IDefaultPloneLayer
class IThemeSpecific(IDefaultPloneLayer):
"""Marker interface that defines a Zope 3 browser layer.
If you need to register a viewlet only for the
"My315okTheme" theme, this interface must be its layer
(in my315oktheme/viewlets/configure.zcm... | [
[
1,
0,
0.125,
0.125,
0,
0.66,
0,
862,
0,
1,
0,
0,
862,
0,
0
],
[
3,
0,
0.6875,
0.75,
0,
0.66,
1,
327,
0,
0,
0,
0,
514,
0,
0
],
[
8,
1,
0.75,
0.625,
1,
0.13,
0,... | [
"from plone.theme.interfaces import IDefaultPloneLayer",
"class IThemeSpecific(IDefaultPloneLayer):\n \"\"\"Marker interface that defines a Zope 3 browser layer.\n If you need to register a viewlet only for the\n \"My315okTheme\" theme, this interface must be its layer\n (in my315oktheme/view... |
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.layout.viewlets.common import ViewletBase
# Sample code for a basic viewlet (In order to use it, you'll have to):
# - Un-comment the following useable piece of code (viewlet python class).
# - Rename the viewlet template file ('brow... | [
[
1,
0,
0.0476,
0.0476,
0,
0.66,
0,
624,
0,
1,
0,
0,
624,
0,
0
],
[
1,
0,
0.0952,
0.0476,
0,
0.66,
1,
37,
0,
1,
0,
0,
37,
0,
0
]
] | [
"from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile",
"from plone.app.layout.viewlets.common import ViewletBase"
] |
#
| [] | [] |
def setupVarious(context):
# Ordinarily, GenericSetup handlers check for the existence of XML files.
# Here, we are not parsing an XML file, but we use this text file as a
# flag to check that we actually meant for this import step to be run.
# The file is found in profiles/default.
if context.rea... | [
[
2,
0,
0.4545,
0.8182,
0,
0.66,
0,
222,
0,
1,
0,
0,
0,
0,
1
],
[
4,
1,
0.7727,
0.1818,
1,
0.21,
0,
0,
0,
0,
0,
0,
0,
0,
1
],
[
13,
2,
0.8182,
0.0909,
2,
0.13,
... | [
"def setupVarious(context):\n\n # Ordinarily, GenericSetup handlers check for the existence of XML files.\n # Here, we are not parsing an XML file, but we use this text file as a\n # flag to check that we actually meant for this import step to be run.\n # The file is found in profiles/default.\n\n if... |
def initialize(context):
"""Initializer called when used as a Zope 2 product."""
| [
[
2,
0,
0.8333,
0.6667,
0,
0.66,
0,
393,
0,
1,
0,
0,
0,
0,
0
],
[
8,
1,
1,
0.3333,
1,
0.42,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
] | [
"def initialize(context):\n \"\"\"Initializer called when used as a Zope 2 product.\"\"\"",
" \"\"\"Initializer called when used as a Zope 2 product.\"\"\""
] |
from setuptools import setup, find_packages
import os
version = '1.0'
setup(name='Products.my315oktheme',
version=version,
description="A theme that integrated portletmanager function to Ptortal-header,portal-footer and body",
long_description=open("README.txt").read() + "\n" +
... | [
[
1,
0,
0.027,
0.027,
0,
0.66,
0,
182,
0,
2,
0,
0,
182,
0,
0
],
[
1,
0,
0.0541,
0.027,
0,
0.66,
0.3333,
688,
0,
1,
0,
0,
688,
0,
0
],
[
14,
0,
0.1081,
0.027,
0,
0.6... | [
"from setuptools import setup, find_packages",
"import os",
"version = '1.0'",
"setup(name='Products.my315oktheme',\n version=version,\n description=\"A theme that integrated portletmanager function to Ptortal-header,portal-footer and body\",\n long_description=open(\"README.txt\").read() + \"\... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Base class for fixers (optional, but recommended)."""
# Python imports
import logging
import itertools
# Local imports
from .patcomp import PatternCompiler
from . import pygram
from .fixer_util import does_tree_imp... | [
[
8,
0,
0.0214,
0.0053,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0374,
0.0053,
0,
0.66,
0.1429,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0428,
0.0053,
0,
0.66... | [
"\"\"\"Base class for fixers (optional, but recommended).\"\"\"",
"import logging",
"import itertools",
"from .patcomp import PatternCompiler",
"from . import pygram",
"from .fixer_util import does_tree_import",
"class BaseFix(object):\n\n \"\"\"Optional base class for fixers.\n\n The subclass nam... |
"Utility functions used by the btm_matcher module"
from . import pytree
from .pgen2 import grammar, token
from .pygram import pattern_symbols, python_symbols
syms = pattern_symbols.__dict__
pysyms = python_symbols.__dict__
tokens = grammar.opmap
token_labels = token.__dict__
TYPE_ANY = -1
TYPE_ALTERNATIVES = -2
TYPE... | [
[
8,
0,
0.0035,
0.0035,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0105,
0.0035,
0,
0.66,
0.0714,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.0139,
0.0035,
0,
0.66,
... | [
"\"Utility functions used by the btm_matcher module\"",
"from . import pytree",
"from .pgen2 import grammar, token",
"from .pygram import pattern_symbols, python_symbols",
"syms = pattern_symbols.__dict__",
"pysyms = python_symbols.__dict__",
"tokens = grammar.opmap",
"token_labels = token.__dict__",
... |
"""
Main program for 2to3.
"""
from __future__ import with_statement
import sys
import os
import difflib
import logging
import shutil
import optparse
from . import refactor
def diff_texts(a, b, filename):
"""Return a unified diff of two strings."""
a = a.splitlines()
b = b.splitlines()
return diffl... | [
[
8,
0,
0.011,
0.0166,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0276,
0.0055,
0,
0.66,
0.0833,
777,
0,
1,
0,
0,
777,
0,
0
],
[
1,
0,
0.0387,
0.0055,
0,
0.66,... | [
"\"\"\"\nMain program for 2to3.\n\"\"\"",
"from __future__ import with_statement",
"import sys",
"import os",
"import difflib",
"import logging",
"import shutil",
"import optparse",
"from . import refactor",
"def diff_texts(a, b, filename):\n \"\"\"Return a unified diff of two strings.\"\"\"\n ... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Pattern compiler.
The grammer is taken from PatternGrammar.txt.
The compiler compiles a pattern to a pytree.*Pattern instance.
"""
__author__ = "Guido van Rossum <guido@python.org>"
# Python imports
import os
# ... | [
[
8,
0,
0.0319,
0.0294,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0539,
0.0049,
0,
0.66,
0.0769,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.0686,
0.0049,
0,
0.66,... | [
"\"\"\"Pattern compiler.\n\nThe grammer is taken from PatternGrammar.txt.\n\nThe compiler compiles a pattern to a pytree.*Pattern instance.\n\"\"\"",
"__author__ = \"Guido van Rossum <guido@python.org>\"",
"import os",
"from .pgen2 import driver, literals, token, tokenize, parse, grammar",
"from . import py... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Export the Python grammar and symbols."""
# Python imports
import os
# Local imports
from .pgen2 import token
from .pgen2 import driver
from . import pytree
# The grammar file
_GRAMMAR_FILE = os.path.join(os.path.... | [
[
8,
0,
0.1,
0.025,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.175,
0.025,
0,
0.66,
0.0833,
688,
0,
1,
0,
0,
688,
0,
0
],
[
1,
0,
0.25,
0.025,
0,
0.66,
0.1... | [
"\"\"\"Export the Python grammar and symbols.\"\"\"",
"import os",
"from .pgen2 import token",
"from .pgen2 import driver",
"from . import pytree",
"_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__), \"Grammar.txt\")",
"_PATTERN_GRAMMAR_FILE = os.path.join(os.path.dirname(__file__),\n ... |
"""Utility functions, node construction macros, etc."""
# Author: Collin Winter
# Local imports
from .pgen2 import token
from .pytree import Leaf, Node
from .pygram import python_symbols as syms
from . import patcomp
###########################################################
### Common node-construction "macros"
##... | [
[
8,
0,
0.0024,
0.0024,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0119,
0.0024,
0,
0.66,
0.0238,
607,
0,
1,
0,
0,
607,
0,
0
],
[
1,
0,
0.0143,
0.0024,
0,
0.66... | [
"\"\"\"Utility functions, node construction macros, etc.\"\"\"",
"from .pgen2 import token",
"from .pytree import Leaf, Node",
"from .pygram import python_symbols as syms",
"from . import patcomp",
"def KeywordArg(keyword, value):\n return Node(syms.argument,\n [keyword, Leaf(token.EQUAL... |
#! /usr/bin/env python3
"""Token constants (from "token.h")."""
# Taken from Python (r53757) and modified to include some tokens
# originally monkeypatched in by pgen2.tokenize
#--start constants--
ENDMARKER = 0
NAME = 1
NUMBER = 2
STRING = 3
NEWLINE = 4
INDENT = 5
DEDENT = 6
LPAR = 7
RPAR = 8
LSQB = 9
RSQB = 10
... | [
[
8,
0,
0.0366,
0.0122,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1098,
0.0122,
0,
0.66,
0.0159,
977,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.122,
0.0122,
0,
0.66,... | [
"\"\"\"Token constants (from \"token.h\").\"\"\"",
"ENDMARKER = 0",
"NAME = 1",
"NUMBER = 2",
"STRING = 3",
"NEWLINE = 4",
"INDENT = 5",
"DEDENT = 6",
"LPAR = 7",
"RPAR = 8",
"LSQB = 9",
"RSQB = 10",
"COLON = 11",
"COMMA = 12",
"SEMI = 13",
"PLUS = 14",
"MINUS = 15",
"STAR = 16",
... |
#! /usr/bin/env python3
"""Token constants (from "token.h")."""
# Taken from Python (r53757) and modified to include some tokens
# originally monkeypatched in by pgen2.tokenize
#--start constants--
ENDMARKER = 0
NAME = 1
NUMBER = 2
STRING = 3
NEWLINE = 4
INDENT = 5
DEDENT = 6
LPAR = 7
RPAR = 8
LSQB = 9
RSQB = 10
... | [
[
8,
0,
0.0366,
0.0122,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1098,
0.0122,
0,
0.66,
0.0159,
977,
1,
0,
0,
0,
0,
1,
0
],
[
14,
0,
0.122,
0.0122,
0,
0.66,... | [
"\"\"\"Token constants (from \"token.h\").\"\"\"",
"ENDMARKER = 0",
"NAME = 1",
"NUMBER = 2",
"STRING = 3",
"NEWLINE = 4",
"INDENT = 5",
"DEDENT = 6",
"LPAR = 7",
"RPAR = 8",
"LSQB = 9",
"RSQB = 10",
"COLON = 11",
"COMMA = 12",
"SEMI = 13",
"PLUS = 14",
"MINUS = 15",
"STAR = 16",
... |
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
# All rights reserved.
"""Tokenization help for Python programs.
generate_tokens(readline) is a generator that breaks a stream of
text into Python tokens. It accepts a readline-like method which is called
repeatedly to get the next line o... | [
[
8,
0,
0.03,
0.046,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.056,
0.002,
0,
0.66,
0.0167,
777,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.059,
0.004,
0,
0.66,
0... | [
"\"\"\"Tokenization help for Python programs.\n\ngenerate_tokens(readline) is a generator that breaks a stream of\ntext into Python tokens. It accepts a readline-like method which is called\nrepeatedly to get the next line of input (or \"\" for EOF). It generates\n5-tuples with these members:\n\n the token typ... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Convert graminit.[ch] spit out by pgen to Python code.
Pgen is the Python parser generator. It is useful to quickly create a
parser from a grammar file in Python's grammar notation. But I don't
wa... | [
[
8,
0,
0.0603,
0.0934,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1167,
0.0039,
0,
0.66,
0.3333,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.1284,
0.0039,
0,
0.66... | [
"\"\"\"Convert graminit.[ch] spit out by pgen to Python code.\n\nPgen is the Python parser generator. It is useful to quickly create a\nparser from a grammar file in Python's grammar notation. But I don't\nwant my parsers to be written in C (yet), so I'm translating the\nparsing tables to Python data structures a... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Safely evaluate Python string literals without using eval()."""
import re
simple_escapes = {"a": "\a",
"b": "\b",
"f": "\f",
"n": "\n",
... | [
[
8,
0,
0.0667,
0.0167,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1,
0.0167,
0,
0.66,
0.1667,
540,
0,
1,
0,
0,
540,
0,
0
],
[
14,
0,
0.2083,
0.1667,
0,
0.66,
... | [
"\"\"\"Safely evaluate Python string literals without using eval().\"\"\"",
"import re",
"simple_escapes = {\"a\": \"\\a\",\n \"b\": \"\\b\",\n \"f\": \"\\f\",\n \"n\": \"\\n\",\n \"r\": \"\\r\",\n \"t\": \"\\t\",\n ... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Pgen imports
from . import grammar, token, tokenize
class PgenGrammar(grammar.Grammar):
pass
class ParserGenerator(object):
def __init__(self, filename, stream=None):
close_stream =... | [
[
1,
0,
0.013,
0.0026,
0,
0.66,
0,
0,
0,
3,
0,
0,
0,
0,
0
],
[
3,
0,
0.0194,
0.0052,
0,
0.66,
0.2,
344,
0,
0,
0,
0,
407,
0,
0
],
[
3,
0,
0.4469,
0.8446,
0,
0.66,
... | [
"from . import grammar, token, tokenize",
"class PgenGrammar(grammar.Grammar):\n pass",
"class ParserGenerator(object):\n\n def __init__(self, filename, stream=None):\n close_stream = None\n if stream is None:\n stream = open(filename)\n close_stream = stream.close\n ... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""This module defines the data structures used to represent a grammar.
These are a bit arcane because they are derived from the data
structures used by Python's 'pgen' parser generator.
There's also ... | [
[
8,
0,
0.0462,
0.0543,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.087,
0.0054,
0,
0.66,
0.1667,
848,
0,
1,
0,
0,
848,
0,
0
],
[
1,
0,
0.1033,
0.0054,
0,
0.66,... | [
"\"\"\"This module defines the data structures used to represent a grammar.\n\nThese are a bit arcane because they are derived from the data\nstructures used by Python's 'pgen' parser generator.\n\nThere's also a table here mapping operators to their names in the\ntoken module; the Python tokenize module reports al... |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""The pgen2 package."""
| [
[
8,
0,
1,
0.25,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
]
] | [
"\"\"\"The pgen2 package.\"\"\""
] |
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
# Modifications:
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Parser driver.
This provides a high-level interface to parse a file into a synta... | [
[
8,
0,
0.068,
0.034,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0952,
0.0068,
0,
0.66,
0.0909,
777,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.1088,
0.0068,
0,
0.66,
... | [
"\"\"\"Parser driver.\n\nThis provides a high-level interface to parse a file into a syntax tree.\n\n\"\"\"",
"__author__ = \"Guido van Rossum <guido@python.org>\"",
"__all__ = [\"Driver\", \"load_grammar\"]",
"import codecs",
"import os",
"import logging",
"import sys",
"from . import grammar, parse,... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""
Python parse tree definitions.
This is a very concrete parse tree; we need to keep every token and
even the comments and whitespace between tokens.
There's also a pattern matching implementation here.
"""
__autho... | [
[
8,
0,
0.0084,
0.0089,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0145,
0.0011,
0,
0.66,
0.0588,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.0168,
0.0011,
0,
0.66,... | [
"\"\"\"\nPython parse tree definitions.\n\nThis is a very concrete parse tree; we need to keep every token and\neven the comments and whitespace between tokens.\n\nThere's also a pattern matching implementation here.\n\"\"\"",
"__author__ = \"Guido van Rossum <guido@python.org>\"",
"import sys",
"import warni... |
"""A bottom-up tree matching algorithm implementation meant to speed
up 2to3's matching process. After the tree patterns are reduced to
their rarest linear path, a linear Aho-Corasick automaton is
created. The linear automaton traverses the linear paths from the
leaves to the root of the AST and returns a set of nodes ... | [
[
8,
0,
0.0206,
0.0353,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.0471,
0.0059,
0,
0.66,
0.1429,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.0588,
0.0059,
0,
0.66,... | [
"\"\"\"A bottom-up tree matching algorithm implementation meant to speed\nup 2to3's matching process. After the tree patterns are reduced to\ntheir rarest linear path, a linear Aho-Corasick automaton is\ncreated. The linear automaton traverses the linear paths from the\nleaves to the root of the AST and returns a s... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that turns <> into !=."""
# Local imports
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
class FixNe(fixer_base.BaseFix):
# This is so simple that we don't need the pattern com... | [
[
8,
0,
0.1739,
0.0435,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3043,
0.0435,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3478,
0.0435,
0,
0.66,
... | [
"\"\"\"Fixer that turns <> into !=.\"\"\"",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"class FixNe(fixer_base.BaseFix):\n # This is so simple that we don't need the pattern compiler.\n\n _accept_type = token.NOTEQUAL\n\n def match(self, node):\n # Ove... |
"""Fixer for generator.throw(E, V, T).
g.throw(E) -> g.throw(E)
g.throw(E, V) -> g.throw(E(V))
g.throw(E, V, T) -> g.throw(E(V).with_traceback(T))
g.throw("foo"[, V[, T]]) will warn about string exceptions."""
# Author: Collin Winter
# Local imports
from .. import pytree
from ..pgen2 import token
from .. im... | [
[
8,
0,
0.069,
0.1207,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1897,
0.0172,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2069,
0.0172,
0,
0.66,
0.... | [
"\"\"\"Fixer for generator.throw(E, V, T).\n\ng.throw(E) -> g.throw(E)\ng.throw(E, V) -> g.throw(E(V))\ng.throw(E, V, T) -> g.throw(E(V).with_traceback(T))\n\ng.throw(\"foo\"[, V[, T]]) will warn about string exceptions.\"\"\"",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fi... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for apply().
This converts apply(func, v, k) into (func)(*v, **k)."""
# Local imports
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Call, Comma, parenthesi... | [
[
8,
0,
0.0833,
0.05,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.15,
0.0167,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.1667,
0.0167,
0,
0.66,
0.4,
... | [
"\"\"\"Fixer for apply().\n\nThis converts apply(func, v, k) into (func)(*v, **k).\"\"\"",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer_util import Call, Comma, parenthesize",
"class FixApply(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTER... |
"""Fixer for import statements.
If spam is being imported from the local directory, this import:
from spam import eggs
Becomes:
from .spam import eggs
And this import:
import spam
Becomes:
from . import spam
"""
# Local imports
from .. import fixer_base
from os.path import dirname, join, exists, sep
f... | [
[
8,
0,
0.06,
0.11,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.14,
0.01,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.15,
0.01,
0,
0.66,
0.4,
79,
... | [
"\"\"\"Fixer for import statements.\nIf spam is being imported from the local directory, this import:\n from spam import eggs\nBecomes:\n from .spam import eggs\n\nAnd this import:\n import spam",
"from .. import fixer_base",
"from os.path import dirname, join, exists, sep",
"from ..fixer_util import... |
"""Fixer for 'raise E, V, T'
raise -> raise
raise E -> raise E
raise E, V -> raise E(V)
raise E, V, T -> raise E(V).with_traceback(T)
raise (((E, E'), E''), E'''), V -> raise E(V)
raise "foo", V, T -> warns about string exceptions
CAVEATS:
1) "raise E, V" will be incorrectly translate... | [
[
8,
0,
0.131,
0.25,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2976,
0.0119,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3095,
0.0119,
0,
0.66,
0.4,... | [
"\"\"\"Fixer for 'raise E, V, T'\n\nraise -> raise\nraise E -> raise E\nraise E, V -> raise E(V)\nraise E, V, T -> raise E(V).with_traceback(T)\n\nraise (((E, E'), E''), E'''), V -> raise E(V)",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for print.
Change:
'print' into 'print()'
'print ...' into 'print(...)'
'print ... ,' into 'print(..., end=" ")'
'print >>x, ...' into 'print(..., file=x)'
No changes are appl... | [
[
8,
0,
0.1034,
0.1264,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1954,
0.0115,
0,
0.66,
0.1429,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2069,
0.0115,
0,
0.66,
... | [
"\"\"\"Fixer for print.\n\nChange:\n 'print' into 'print()'\n 'print ...' into 'print(...)'\n 'print ... ,' into 'print(..., end=\" \")'\n 'print >>x, ...' into 'print(..., file=x)'",
"from .. import patcomp",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import... |
"""Fixer that changes input(...) into eval(input(...))."""
# Author: Andre Roberge
# Local imports
from .. import fixer_base
from ..fixer_util import Call, Name
from .. import patcomp
context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >")
class FixInput(fixer_base.BaseFix):
BM_compatible ... | [
[
8,
0,
0.0357,
0.0357,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1786,
0.0357,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2143,
0.0357,
0,
0.66,
0... | [
"\"\"\"Fixer that changes input(...) into eval(input(...)).\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Call, Name",
"from .. import patcomp",
"context = patcomp.compile_pattern(\"power< 'eval' trailer< '(' any ')' > >\")",
"class FixInput(fixer_base.BaseFix):\n\n BM_compatible = Tru... |
"""Fixer that changes 'a ,b' into 'a, b'.
This also changes '{a :b}' into '{a: b}', but does not touch other
uses of colons. It does not touch other uses of whitespace.
"""
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
class FixWsComma(fixer_base.BaseFix):
explicit = True # The use... | [
[
8,
0,
0.0897,
0.1538,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2051,
0.0256,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2308,
0.0256,
0,
0.66,
... | [
"\"\"\"Fixer that changes 'a ,b' into 'a, b'.\n\nThis also changes '{a :b}' into '{a: b}', but does not touch other\nuses of colons. It does not touch other uses of whitespace.\n\n\"\"\"",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"class FixWsComma(fixer_base.BaseFi... |
"""Adjust some old Python 2 idioms to their modern counterparts.
* Change some type comparisons to isinstance() calls:
type(x) == T -> isinstance(x, T)
type(x) is T -> isinstance(x, T)
type(x) != T -> not isinstance(x, T)
type(x) is not T -> not isinstance(x, T)
* Change "while 1:" into "while True:".... | [
[
8,
0,
0.0921,
0.1776,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2039,
0.0066,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2105,
0.0066,
0,
0.66,
0... | [
"\"\"\"Adjust some old Python 2 idioms to their modern counterparts.\n\n* Change some type comparisons to isinstance() calls:\n type(x) == T -> isinstance(x, T)\n type(x) is T -> isinstance(x, T)\n type(x) != T -> not isinstance(x, T)\n type(x) is not T -> not isinstance(x, T)",
"from .. import fixer_... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for StandardError -> Exception."""
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixStandarderror(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
... | [
[
8,
0,
0.2,
0.05,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.35,
0.05,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.4,
0.05,
0,
0.66,
0.6667,
... | [
"\"\"\"Fixer for StandardError -> Exception.\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixStandarderror(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"\"\"\n 'StandardError'\n \"\"\"",
" BM_compatible = True",
" PATTER... |
"""Fix incompatible renames
Fixes:
* sys.maxint -> sys.maxsize
"""
# Author: Christian Heimes
# based on Collin Winter's fix_import
# Local imports
from .. import fixer_base
from ..fixer_util import Name, attr_chain
MAPPING = {"sys": {"maxint" : "maxsize"},
}
LOOKUP = {}
def alternates(members):
re... | [
[
8,
0,
0.0417,
0.0694,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1389,
0.0139,
0,
0.66,
0.1429,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.1528,
0.0139,
0,
0.66,
... | [
"\"\"\"Fix incompatible renames\n\nFixes:\n * sys.maxint -> sys.maxsize\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name, attr_chain",
"MAPPING = {\"sys\": {\"maxint\" : \"maxsize\"},\n }",
"LOOKUP = {}",
"def alternates(members):\n return \"(\" + \"|\".join(map(repr, me... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that changes xrange(...) into range(...)."""
# Local imports
from .. import fixer_base
from ..fixer_util import Name, Call, consuming_calls
from .. import patcomp
class FixXrange(fixer_base.BaseFix):
BM... | [
[
8,
0,
0.0533,
0.0133,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0933,
0.0133,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.1067,
0.0133,
0,
0.66,
... | [
"\"\"\"Fixer that changes xrange(...) into range(...).\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name, Call, consuming_calls",
"from .. import patcomp",
"class FixXrange(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"\"\"\n power<\n (nam... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that turns 'long' into 'int' everywhere.
"""
# Local imports
from lib2to3 import fixer_base
from lib2to3.fixer_util import is_probably_builtin
class FixLong(fixer_base.BaseFix):
BM_compatible = True
... | [
[
8,
0,
0.2143,
0.0952,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.381,
0.0476,
0,
0.66,
0.3333,
617,
0,
1,
0,
0,
617,
0,
0
],
[
1,
0,
0.4286,
0.0476,
0,
0.66,... | [
"\"\"\"Fixer that turns 'long' into 'int' everywhere.\n\"\"\"",
"from lib2to3 import fixer_base",
"from lib2to3.fixer_util import is_probably_builtin",
"class FixLong(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"'long'\"\n\n def transform(self, node, results):\n if is_probably... |
# Copyright 2008 Armin Ronacher.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that cleans up a tuple argument to isinstance after the tokens
in it were fixed. This is mainly used to remove double occurrences of
tokens as a leftover of the long -> int / unicode -> str conversion.
eg. isinstance(x, (int,... | [
[
8,
0,
0.1296,
0.1296,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2222,
0.0185,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2407,
0.0185,
0,
0.66,
... | [
"\"\"\"Fixer that cleans up a tuple argument to isinstance after the tokens\nin it were fixed. This is mainly used to remove double occurrences of\ntokens as a leftover of the long -> int / unicode -> str conversion.\n\neg. isinstance(x, (int, long)) -> isinstance(x, (int, int))\n -> isinstance(x, int)\n\"\... |
""" Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and
itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363)
imports from itertools are fixed in fix_itertools_import.py
If itertools is imported as something else (ie: import itertools as it;
it.izip(spam, eggs)) method calls w... | [
[
8,
0,
0.1023,
0.1818,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.25,
0.0227,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2727,
0.0227,
0,
0.66,
... | [
"\"\"\" Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and\n itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363)\n\n imports from itertools are fixed in fix_itertools_import.py\n\n If itertools is imported as something else (ie: import itertools as it;\n it.izip(spam, eggs)) ... |
"""Fix changes imports of urllib which are now incompatible.
This is rather similar to fix_imports, but because of the more
complex nature of the fixing for urllib, it has its own fixer.
"""
# Author: Nick Edds
# Local imports
from .fix_imports import alternates, FixImports
from .. import fixer_base
from ..fixer... | [
[
8,
0,
0.0139,
0.0222,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0444,
0.0056,
0,
0.66,
0.1429,
438,
0,
2,
0,
0,
438,
0,
0
],
[
1,
0,
0.05,
0.0056,
0,
0.66,
... | [
"\"\"\"Fix changes imports of urllib which are now incompatible.\n This is rather similar to fix_imports, but because of the more\n complex nature of the fixing for urllib, it has its own fixer.\n\"\"\"",
"from .fix_imports import alternates, FixImports",
"from .. import fixer_base",
"from ..fixer_util im... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that changes buffer(...) into memoryview(...)."""
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBuffer(fixer_base.BaseFix):
BM_compatible = True
explicit = True #... | [
[
8,
0,
0.1739,
0.0435,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3043,
0.0435,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3478,
0.0435,
0,
0.66,
... | [
"\"\"\"Fixer that changes buffer(...) into memoryview(...).\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixBuffer(fixer_base.BaseFix):\n\n BM_compatible = True\n\n explicit = True # The user must ask for this fixer\n\n PATTERN = \"\"\"\n power< name='buff... |
"""Fixer for __metaclass__ = X -> (metaclass=X) methods.
The various forms of classef (inherits nothing, inherits once, inherints
many) don't parse the same in the CST so we look at ALL classes for
a __metaclass__ and if we find one normalize the inherits to all be
an arglist.
For one-liner classes ('c... | [
[
8,
0,
0.0393,
0.0742,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0917,
0.0044,
0,
0.66,
0.1,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.0961,
0.0044,
0,
0.66,
0... | [
"\"\"\"Fixer for __metaclass__ = X -> (metaclass=X) methods.\n\n The various forms of classef (inherits nothing, inherits once, inherints\n many) don't parse the same in the CST so we look at ALL classes for\n a __metaclass__ and if we find one normalize the inherits to all be\n an arglist.\n\n For one-li... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for has_key().
Calls to .has_key() methods are expressed in terms of the 'in'
operator:
d.has_key(k) -> k in d
CAVEATS:
1) While the primary target of this fixer is dict.has_key(), the
fixer will chan... | [
[
8,
0,
0.1532,
0.2432,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2973,
0.009,
0,
0.66,
0.2,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3063,
0.009,
0,
0.66,
0.4... | [
"\"\"\"Fixer for has_key().\n\nCalls to .has_key() methods are expressed in terms of the 'in'\noperator:\n\n d.has_key(k) -> k in d\n\nCAVEATS:",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer_util import Name, parenthesize",
"class FixHasKey(fixer_base... |
"""
Fixer that changes os.getcwdu() to os.getcwd().
"""
# Author: Victor Stinner
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixGetcwdu(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< 'os' trailer< dot='.' name='getcwdu' > any* >
"... | [
[
8,
0,
0.1,
0.15,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.35,
0.05,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.4,
0.05,
0,
0.66,
0.6667,
... | [
"\"\"\"\nFixer that changes os.getcwdu() to os.getcwd().\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixGetcwdu(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"\"\"\n power< 'os' trailer< dot='.' name='getcwdu' > any* >\n \"\"\""... |
# Copyright 2006 Georg Brandl.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for intern().
intern(s) -> sys.intern(s)"""
# Local imports
from .. import pytree
from .. import fixer_base
from ..fixer_util import Name, Attr, touch_import
class FixIntern(fixer_base.BaseFix):
BM_compatible = True
... | [
[
8,
0,
0.1087,
0.0652,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1957,
0.0217,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2174,
0.0217,
0,
0.66,
... | [
"\"\"\"Fixer for intern().\n\nintern(s) -> sys.intern(s)\"\"\"",
"from .. import pytree",
"from .. import fixer_base",
"from ..fixer_util import Name, Attr, touch_import",
"class FixIntern(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"\"\"\n power< 'intern'\n trailer< lpar... |
"""Fix incompatible imports and module references."""
# Authors: Collin Winter, Nick Edds
# Local imports
from .. import fixer_base
from ..fixer_util import Name, attr_chain
MAPPING = {'StringIO': 'io',
'cStringIO': 'io',
'cPickle': 'pickle',
'__builtin__' : 'builtins',
'c... | [
[
8,
0,
0.0068,
0.0068,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0342,
0.0068,
0,
0.66,
0.1667,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.0411,
0.0068,
0,
0.66,
... | [
"\"\"\"Fix incompatible imports and module references.\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name, attr_chain",
"MAPPING = {'StringIO': 'io',\n 'cStringIO': 'io',\n 'cPickle': 'pickle',\n '__builtin__' : 'builtins',\n 'copy_reg': 'copyreg',\n ... |
# Copyright 2008 Armin Ronacher.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for reduce().
Makes sure reduce() is imported from the functools module if reduce is
used in that module.
"""
from lib2to3 import fixer_base
from lib2to3.fixer_util import touch_import
class FixReduce(fixer_base.BaseFix):
... | [
[
8,
0,
0.1765,
0.1471,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2941,
0.0294,
0,
0.66,
0.3333,
617,
0,
1,
0,
0,
617,
0,
0
],
[
1,
0,
0.3235,
0.0294,
0,
0.66... | [
"\"\"\"Fixer for reduce().\n\nMakes sure reduce() is imported from the functools module if reduce is\nused in that module.\n\"\"\"",
"from lib2to3 import fixer_base",
"from lib2to3.fixer_util import touch_import",
"class FixReduce(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"\"\"\n p... |
"""Fixer for basestring -> str."""
# Author: Christian Heimes
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixBasestring(fixer_base.BaseFix):
BM_compatible = True
PATTERN = "'basestring'"
def transform(self, node, results):
return Name("str", prefix=node.prefix)... | [
[
8,
0,
0.0667,
0.0667,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3333,
0.0667,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.4,
0.0667,
0,
0.66,
0... | [
"\"\"\"Fixer for basestring -> str.\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixBasestring(fixer_base.BaseFix):\n\n BM_compatible = True\n\n PATTERN = \"'basestring'\"\n\n def transform(self, node, results):\n return Name(\"str\", prefix=node.prefix)",
" ... |
"""
Optional fixer to transform set() calls to set literals.
"""
# Author: Benjamin Peterson
from lib2to3 import fixer_base, pytree
from lib2to3.fixer_util import token, syms
class FixSetLiteral(fixer_base.BaseFix):
BM_compatible = True
explicit = True
PATTERN = """power< 'set' trailer< '('
... | [
[
8,
0,
0.037,
0.0556,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1296,
0.0185,
0,
0.66,
0.3333,
617,
0,
2,
0,
0,
617,
0,
0
],
[
1,
0,
0.1481,
0.0185,
0,
0.66,... | [
"\"\"\"\nOptional fixer to transform set() calls to set literals.\n\"\"\"",
"from lib2to3 import fixer_base, pytree",
"from lib2to3.fixer_util import token, syms",
"class FixSetLiteral(fixer_base.BaseFix):\n\n BM_compatible = True\n\n explicit = True\n\n PATTERN = \"\"\"power< 'set' trailer< '('\n ... |
"""Fixer for function definitions with tuple parameters.
def func(((a, b), c), d):
...
->
def func(x, d):
((a, b), c) = x
...
It will also support lambdas:
lambda (x, y): x + y -> lambda t: t[0] + t[1]
# The parens are a syntax error in Python 3
lambda (x): x + y -> lambda x: x + y
"""... | [
[
8,
0,
0.054,
0.1023,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.125,
0.0057,
0,
0.66,
0.1,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.1307,
0.0057,
0,
0.66,
0.2... | [
"\"\"\"Fixer for function definitions with tuple parameters.\n\ndef func(((a, b), c), d):\n ...\n\n ->\n\ndef func(x, d):",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer_util import Assign, Name, Newline, Number, Subscript, syms",
"def is_docstring(... |
"""
Convert use of sys.exitfunc to use the atexit module.
"""
# Author: Benjamin Peterson
from lib2to3 import pytree, fixer_base
from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms
class FixExitfunc(fixer_base.BaseFix):
keep_line_order = True
BM_compatible = True
PATTERN = """
... | [
[
8,
0,
0.0274,
0.0411,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0959,
0.0137,
0,
0.66,
0.3333,
617,
0,
2,
0,
0,
617,
0,
0
],
[
1,
0,
0.1096,
0.0137,
0,
0.66... | [
"\"\"\"\nConvert use of sys.exitfunc to use the atexit module.\n\"\"\"",
"from lib2to3 import pytree, fixer_base",
"from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms",
"class FixExitfunc(fixer_base.BaseFix):\n\n keep_line_order = True\n BM_compatible = True\n\n PATTERN = \"\"\"\n ... |
"""Fixer that turns 1L into 1, 0755 into 0o755.
"""
# Copyright 2007 Georg Brandl.
# Licensed to PSF under a Contributor Agreement.
# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
# This is so simple that we don't need ... | [
[
8,
0,
0.05,
0.0667,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2333,
0.0333,
0,
0.66,
0.25,
607,
0,
1,
0,
0,
607,
0,
0
],
[
1,
0,
0.2667,
0.0333,
0,
0.66,
... | [
"\"\"\"Fixer that turns 1L into 1, 0755 into 0o755.\n\"\"\"",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer_util import Number",
"class FixNumliterals(fixer_base.BaseFix):\n # This is so simple that we don't need the pattern compiler.\n\n _accept_type = token.NUMBER\n\n de... |
"""Fix "for x in f.xreadlines()" -> "for x in f".
This fixer will also convert g(f.xreadlines) into g(f.__iter__)."""
# Author: Collin Winter
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixXreadlines(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< c... | [
[
8,
0,
0.0741,
0.1111,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2593,
0.037,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2963,
0.037,
0,
0.66,
... | [
"\"\"\"Fix \"for x in f.xreadlines()\" -> \"for x in f\".\n\nThis fixer will also convert g(f.xreadlines) into g(f.__iter__).\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixXreadlines(fixer_base.BaseFix):\n\n BM_compatible = True\n \n PATTERN = \"\"\"\n power< call... |
# Dummy file to make this directory a package.
| [] | [] |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for execfile.
This converts usages of the execfile function into calls to the built-in
exec() function.
"""
from .. import fixer_base
from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node,
... | [
[
8,
0,
0.1132,
0.0943,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1887,
0.0189,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.217,
0.0377,
0,
0.66,
... | [
"\"\"\"Fixer for execfile.\n\nThis converts usages of the execfile function into calls to the built-in\nexec() function.\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node,\n ArgList, String, syms)",
"class FixExecfile(fixer_... |
"""Fixer that changes unicode to str, unichr to chr, and u"..." into "...".
"""
import re
from ..pgen2 import token
from .. import fixer_base
_mapping = {"unichr" : "chr", "unicode" : "str"}
_literal_re = re.compile(r"[uU][rR]?[\'\"]")
class FixUnicode(fixer_base.BaseFix):
BM_compatible = True
PATTERN = "... | [
[
8,
0,
0.0741,
0.1111,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1852,
0.037,
0,
0.66,
0.1667,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.2222,
0.037,
0,
0.66,
... | [
"\"\"\"Fixer that changes unicode to str, unichr to chr, and u\"...\" into \"...\".\n\n\"\"\"",
"import re",
"from ..pgen2 import token",
"from .. import fixer_base",
"_mapping = {\"unichr\" : \"chr\", \"unicode\" : \"str\"}",
"_literal_re = re.compile(r\"[uU][rR]?[\\'\\\"]\")",
"class FixUnicode(fixer_... |
""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """
# Local imports
from lib2to3 import fixer_base
from lib2to3.fixer_util import BlankLine, syms, token
class FixItertoolsImports(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
import_from< 'from' 'itertools' 'i... | [
[
8,
0,
0.0172,
0.0172,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.069,
0.0172,
0,
0.66,
0.3333,
617,
0,
1,
0,
0,
617,
0,
0
],
[
1,
0,
0.0862,
0.0172,
0,
0.66,... | [
"\"\"\" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) \"\"\"",
"from lib2to3 import fixer_base",
"from lib2to3.fixer_util import BlankLine, syms, token",
"class FixItertoolsImports(fixer_base.BaseFix):\n\n BM_compatible = True\n \n PATTERN = \"\"\"\n import_from< 'from'... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for dict methods.
d.keys() -> list(d.keys())
d.items() -> list(d.items())
d.values() -> list(d.values())
d.iterkeys() -> iter(d.keys())
d.iteritems() -> iter(d.items())
d.itervalues() -> iter(d.values())
d.v... | [
[
8,
0,
0.1495,
0.2336,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2897,
0.0093,
0,
0.66,
0.125,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2991,
0.0093,
0,
0.66,
... | [
"\"\"\"Fixer for dict methods.\n\nd.keys() -> list(d.keys())\nd.items() -> list(d.items())\nd.values() -> list(d.values())\n\nd.iterkeys() -> iter(d.keys())\nd.iteritems() -> iter(d.items())",
"from .. import pytree",
"from .. import patcomp",
"from ..pgen2 import token",
"from .. import fixer_base",
"fro... |
"""Fixer for __nonzero__ -> __bool__ methods."""
# Author: Collin Winter
# Local imports
from .. import fixer_base
from ..fixer_util import Name, syms
class FixNonzero(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
classdef< 'class' any+ ':'
suite< any*
fu... | [
[
8,
0,
0.0435,
0.0435,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2174,
0.0435,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2609,
0.0435,
0,
0.66,
... | [
"\"\"\"Fixer for __nonzero__ -> __bool__ methods.\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name, syms",
"class FixNonzero(fixer_base.BaseFix):\n\n BM_compatible = True\n \n PATTERN = \"\"\"\n classdef< 'class' any+ ':'\n suite< any*\n funcdef<... |
"""Fixer for except statements with named exceptions.
The following cases will be converted:
- "except E, T:" where T is a name:
except E as T:
- "except E, T:" where T is not a name, tuple or list:
except E as t:
T = t
This is done because the target of an "except" clause must be a
... | [
[
8,
0,
0.117,
0.2234,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.266,
0.0106,
0,
0.66,
0.1667,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2766,
0.0106,
0,
0.66,
... | [
"\"\"\"Fixer for except statements with named exceptions.\n\nThe following cases will be converted:\n\n- \"except E, T:\" where T is a name:\n\n except E as T:",
"from .. import pytree",
"from ..pgen2 import token",
"from .. import fixer_base",
"from ..fixer_util import Assign, Attr, Name, is_tuple, is_l... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer that changes filter(F, X) into list(filter(F, X)).
We avoid the transformation if the filter() call is directly contained
in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or
for V in <>:.
NOTE: This... | [
[
8,
0,
0.1169,
0.1429,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2208,
0.013,
0,
0.66,
0.25,
607,
0,
1,
0,
0,
607,
0,
0
],
[
1,
0,
0.2338,
0.013,
0,
0.66,
... | [
"\"\"\"Fixer that changes filter(F, X) into list(filter(F, X)).\n\nWe avoid the transformation if the filter() call is directly contained\nin iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or\nfor V in <>:.\n\nNOTE: This is still not correct if the original code was depending on\nfilter(F, X) to return a s... |
"""
Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...)
unless there exists a 'from future_builtins import zip' statement in the
top-level namespace.
We avoid the transformation if the zip() call is directly contained in
iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:.
"""
#... | [
[
8,
0,
0.125,
0.2222,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3056,
0.0278,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3333,
0.0278,
0,
0.66,
... | [
"\"\"\"\nFixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...)\nunless there exists a 'from future_builtins import zip' statement in the\ntop-level namespace.\n\nWe avoid the transformation if the zip() call is directly contained in\niter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V ... |
"""Fix incompatible imports and module references that must be fixed after
fix_imports."""
from . import fix_imports
MAPPING = {
'whichdb': 'dbm',
'anydbm': 'dbm',
}
class FixImports2(fix_imports.FixImports):
run_order = 7
mapping = MAPPING
| [
[
8,
0,
0.0938,
0.125,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1875,
0.0625,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
14,
0,
0.4688,
0.25,
0,
0.66,
... | [
"\"\"\"Fix incompatible imports and module references that must be fixed after\nfix_imports.\"\"\"",
"from . import fix_imports",
"MAPPING = {\n 'whichdb': 'dbm',\n 'anydbm': 'dbm',\n }",
"class FixImports2(fix_imports.FixImports):\n\n run_order = 7\n\n mapping = MAPPING",... |
"""Fixer for sys.exc_{type, value, traceback}
sys.exc_type -> sys.exc_info()[0]
sys.exc_value -> sys.exc_info()[1]
sys.exc_traceback -> sys.exc_info()[2]
"""
# By Jeff Balogh and Benjamin Peterson
# Local imports
from .. import fixer_base
from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms
clas... | [
[
8,
0,
0.1094,
0.1875,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3438,
0.0312,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.375,
0.0312,
0,
0.66,
... | [
"\"\"\"Fixer for sys.exc_{type, value, traceback}\n\nsys.exc_type -> sys.exc_info()[0]\nsys.exc_value -> sys.exc_info()[1]\nsys.exc_traceback -> sys.exc_info()[2]\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms",
"class FixSysExc(fixer_base.Base... |
# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for removing uses of the types module.
These work for only the known names in the types module. The forms above
can include types. or not. ie, It is assumed the module is imported either as:
import type... | [
[
8,
0,
0.1875,
0.2656,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3594,
0.0156,
0,
0.66,
0.1667,
607,
0,
1,
0,
0,
607,
0,
0
],
[
1,
0,
0.375,
0.0156,
0,
0.66,... | [
"\"\"\"Fixer for removing uses of the types module.\n\nThese work for only the known names in the types module. The forms above\ncan include types. or not. ie, It is assumed the module is imported either as:\n\n import types\n from types import ... # either * or specific types",
"from ..pgen2 import token... |
"""Remove __future__ imports
from __future__ import foo is replaced with an empty line.
"""
# Author: Christian Heimes
# Local imports
from .. import fixer_base
from ..fixer_util import BlankLine
class FixFuture(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """import_from< 'from' module_name="__f... | [
[
8,
0,
0.1087,
0.1739,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3478,
0.0435,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3913,
0.0435,
0,
0.66,
... | [
"\"\"\"Remove __future__ imports\n\nfrom __future__ import foo is replaced with an empty line.\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import BlankLine",
"class FixFuture(fixer_base.BaseFix):\n\n BM_compatible = True\n \n PATTERN = \"\"\"import_from< 'from' module_name=\"__future__\... |
"""Fix bound method attributes (method.im_? -> method.__?__).
"""
# Author: Christian Heimes
# Local imports
from .. import fixer_base
from ..fixer_util import Name
MAP = {
"im_func" : "__func__",
"im_self" : "__self__",
"im_class" : "__self__.__class__"
}
class FixMethodattrs(fixer_base.BaseFix):
... | [
[
8,
0,
0.0577,
0.0769,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2308,
0.0385,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2692,
0.0385,
0,
0.66,
... | [
"\"\"\"Fix bound method attributes (method.im_? -> method.__?__).\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"MAP = {\n \"im_func\" : \"__func__\",\n \"im_self\" : \"__self__\",\n \"im_class\" : \"__self__.__class__\"\n }",
"class FixMethodattrs(fixer_base.BaseFix):\... |
"""Fixer that addes parentheses where they are required
This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``."""
# By Taek Joo Kim and Benjamin Peterson
# Local imports
from .. import fixer_base
from ..fixer_util import LParen, RParen
# XXX This doesn't support nested for loops like [x for x in 1, 2 for x... | [
[
8,
0,
0.0444,
0.0667,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1778,
0.0222,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2,
0.0222,
0,
0.66,
0... | [
"\"\"\"Fixer that addes parentheses where they are required\n\nThis converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import LParen, RParen",
"class FixParen(fixer_base.BaseFix):\n\n BM_compatible = True\n \n PATTERN = \"\"\"\n a... |
"""Fixer for it.next() -> next(it), per PEP 3114."""
# Author: Collin Winter
# Things that currently aren't covered:
# - listcomp "next" names aren't warned
# - "with" statement targets aren't checked
# Local imports
from ..pgen2 import token
from ..pygram import python_symbols as syms
from .. import fixer_base
f... | [
[
8,
0,
0.0095,
0.0095,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0857,
0.0095,
0,
0.66,
0.1111,
607,
0,
1,
0,
0,
607,
0,
0
],
[
1,
0,
0.0952,
0.0095,
0,
0.66... | [
"\"\"\"Fixer for it.next() -> next(it), per PEP 3114.\"\"\"",
"from ..pgen2 import token",
"from ..pygram import python_symbols as syms",
"from .. import fixer_base",
"from ..fixer_util import Name, Call, find_binding",
"bind_warning = \"Calls to builtin next() possibly shadowed by global binding\"",
"c... |
"""Fixer that changes raw_input(...) into input(...)."""
# Author: Andre Roberge
# Local imports
from .. import fixer_base
from ..fixer_util import Name
class FixRawInput(fixer_base.BaseFix):
BM_compatible = True
PATTERN = """
power< name='raw_input' trailer< '(' [any] ')' > any* >
... | [
[
8,
0,
0.0556,
0.0556,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.2778,
0.0556,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3333,
0.0556,
0,
0.66,
... | [
"\"\"\"Fixer that changes raw_input(...) into input(...).\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Name",
"class FixRawInput(fixer_base.BaseFix):\n \n BM_compatible = True\n\n PATTERN = \"\"\"\n power< name='raw_input' trailer< '(' [any] ')' > any* >\n ... |
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
"""Fixer for exec.
This converts usages of the exec statement into calls to a built-in
exec() function.
exec code in ns1, ns2 -> exec(code, ns1, ns2)
"""
# Local imports
from .. import pytree
from .. import fixer_bas... | [
[
8,
0,
0.1707,
0.1707,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.3171,
0.0244,
0,
0.66,
0.25,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.3415,
0.0244,
0,
0.66,
... | [
"\"\"\"Fixer for exec.\n\nThis converts usages of the exec statement into calls to a built-in\nexec() function.\n\nexec code in ns1, ns2 -> exec(code, ns1, ns2)\n\"\"\"",
"from .. import pytree",
"from .. import fixer_base",
"from ..fixer_util import Comma, Name, Call",
"class FixExec(fixer_base.BaseFix):\n... |
"""Fixer for operator.{isCallable,sequenceIncludes}
operator.isCallable(obj) -> hasattr(obj, '__call__')
operator.sequenceIncludes(obj) -> operator.contains(obj)
"""
# Local imports
from .. import fixer_base
from ..fixer_util import Call, Name, String
class FixOperator(fixer_base.BaseFix):
BM_compatible = True
... | [
[
8,
0,
0.0714,
0.119,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.1905,
0.0238,
0,
0.66,
0.3333,
0,
0,
1,
0,
0,
0,
0,
0
],
[
1,
0,
0.2143,
0.0238,
0,
0.66,
... | [
"\"\"\"Fixer for operator.{isCallable,sequenceIncludes}\n\noperator.isCallable(obj) -> hasattr(obj, '__call__')\noperator.sequenceIncludes(obj) -> operator.contains(obj)\n\"\"\"",
"from .. import fixer_base",
"from ..fixer_util import Call, Name, String",
"class FixOperator(fixer_base.BaseFix):\n\n BM_comp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.