当前位置: 首页>>代码示例>>Python>>正文


Python Request.__init__方法代码示例

本文整理汇总了Python中request.Request.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Request.__init__方法的具体用法?Python Request.__init__怎么用?Python Request.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在request.Request的用法示例。


在下文中一共展示了Request.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, attackCard, context):
     """ Initialize the Request with the attack """
     self.attackCard = attackCard
     self.context = context
     self.defenseFilters = [ComparisonFilter(zoneType, FixedCriteria("defendFrom", zoneType, "==")) for zoneType in self.ZONES]
     self.cardsForZone = {}
     Request.__init__(self, [context.player])
开发者ID:cloew,项目名称:DeckBuilding,代码行数:9,代码来源:defend_request.py

示例2: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
    def __init__(self, url, password, proxy=None):

        Request.__init__(self, url, proxy)

        self.password = password
        self.extractor = re.compile("<%s>(.*)</%s>" % (self.password[2:], self.password[2:]), re.DOTALL)
        # 		self.extractor_debug = re.compile( "<%sDEBUG>(.*)</%sDEBUG>" % ( self.password[2:], self.password[2:] ), re.DOTALL )
        self.parsed = urlparse.urlparse(self.url)
        self.data = None

        if not self.parsed.path:
            self.query = self.parsed.netloc.replace("/", " ")
        else:
            self.query = "".join(self.parsed.path.split(".")[:-1]).replace("/", " ")
开发者ID:jorik041,项目名称:weevils,代码行数:16,代码来源:cmdrequest.py

示例3: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, cards, player, cost, toDescription):
     """ Initialize the Request with the potential options """
     self.cards = cards
     self.cost = cost
     self.toDescription = toDescription
     Request.__init__(self, [player])
开发者ID:cloew,项目名称:DeckBuilding,代码行数:8,代码来源:pick_up_to_n_cost_request.py

示例4: str

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
'''Helpful print statements'''
print 'Beginning torrent for ' + name 
print 'Average piece length: ' + str(piece_length)
if debug:
	print 'The last piece will be of size: ' + str(last_piece_length)
print 'Total length: ' + str(total_length) 
print 'Number of pieces to receive: ' + str(num_pieces) + '\n'
'''////////////////////////''' 

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = socket.gethostname() # Get local machine name
'''host = 'bl_tardis'			'kate-english' - HE'''
port = 42044                # 25159 - HE
s.connect((host, port)) 	#connect to <host> at <port>

Request.__init__(s, num_pieces, piece_length, last_piece_length, debug, pieces, name) 

# Handshake
peer_id = ""
while len(peer_id) != 12:
	peer_id = peer_id + choice("1234567890")

peer_id = '-' + 'PY' + '0001' + '-' + peer_id
protocol_id = 'BitTorrent protocol'
# len_id = str(len(protocol_id))
reserved = '\x00'*7 + '\x01'
handshake = '\x13' + protocol_id + reserved + info_hash + peer_id

s.send(handshake)
data = s.recv(len(handshake))
开发者ID:henglish3,项目名称:BitTorrentClient,代码行数:32,代码来源:client.py

示例5: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, sender):
     Request.__init__(self)
     self.response = '{} pong! Hehe that was fun!'.format(sender)
开发者ID:Saiai,项目名称:Mai-chan,代码行数:5,代码来源:ping.py

示例6: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, id, message):
     Request.__init__(self, 'POST', 'http://www.reddit.com/api/comment', api_type='json',
                      text=message, thing_id=id)
开发者ID:morgan-cromell,项目名称:RedBot,代码行数:5,代码来源:post_comment_request.py

示例7: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, username, password):
     Request.__init__(self, 'POST', 'http://www.reddit.com/api/login', api_type='json', user=username, passwd=password)
开发者ID:morgan-cromell,项目名称:RedBot,代码行数:4,代码来源:login_request.py

示例8: __init__

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import __init__ [as 别名]
 def __init__(self, post_url, limit=25):
     Request.__init__(self, 'GET', '{0}.json'.format(post_url), limit=limit)
     self.json = None
     self.comments = []
开发者ID:morgan-cromell,项目名称:RedBot,代码行数:6,代码来源:get_post_comments_request.py


注:本文中的request.Request.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。