本文整理汇总了Python中utils.out函数的典型用法代码示例。如果您正苦于以下问题:Python out函数的具体用法?Python out怎么用?Python out使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了out函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initiate_round
def initiate_round(self, dealer_seat):
for player in self.players:
player.draw_hand(self.deck)
player.in_hand = True
player.curr_bet = 0
player.all_in = False
player.has_acted = False
player.sidepot = None
self.pot = self.big_blind + self.small_blind
self.bet = self.big_blind
self.small_blind_seat = self.get_next_seat(dealer_seat)
self.players[self.small_blind_seat].chips -= self.small_blind
self.players[self.small_blind_seat].curr_bet = self.small_blind
utils.out('%s(%d) posts small blind of %d.' % (
self.players[self.small_blind_seat].name,
self.players[self.small_blind_seat].chips, self.small_blind),
self.debug_level)
big_blind_seat = self.get_next_seat(self.small_blind_seat)
self.players[big_blind_seat].chips -= self.big_blind
self.players[big_blind_seat].curr_bet = self.big_blind
utils.out('%s(%d) posts big blind of %d.' % (
self.players[big_blind_seat].name, self.players[big_blind_seat].chips, self.big_blind),
self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:26,代码来源:deal.py
示例2: set_player_ranks
def set_player_ranks(self):
for player in self.players:
if player.in_hand:
player.rank = hand_rank.get_rank(
player.hand.read_as_list() + self.communal_cards)
utils.out('%s(%s) has %s' % (player.name,
player.hand.read_out(), player.rank._to_string()), self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:7,代码来源:deal.py
示例3: __init__
def __init__(self):
progDir = os.path.dirname(sys.argv[0])
(self.args, files) = self.parseArgs(sys.argv[1:])
out.level = self.args.verbosity
out(out.DEBUG, 'Parsed arguments: %s', self.args)
self.config = CONFIG
gui.init(self.config, files)
开发者ID:ze-phyr-us,项目名称:galene,代码行数:7,代码来源:galene.py
示例4: update_player_with_bet
def update_player_with_bet(self, player, bet_size):
self.bet = bet_size
player.curr_bet += self.bet
player.chips -= self.bet
self.pot += self.bet
utils.out("%s(%d) bets %d. Pot is %d" % (
player.name, player.chips, self.bet, self.pot), self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:7,代码来源:deal.py
示例5: print_output
def print_output(name, src, toStdErr):
try:
while not finished and src is not None:
out(toStdErr, src.readline())
flush(toStdErr)
src.close()
except:
pass
开发者ID:TeraprocSoftware,项目名称:jaguar,代码行数:8,代码来源:service.py
示例6: delete
def delete(self, dryrun=True):
if dryrun:
out(u"dry run: delete %s" % self.filepath)
else:
path = self.filepath.encode("utf-8")
try:
self.ftp.delete(path)
except Exception, err:
out(u"Error deleting %s: %s" % (repr(path), err))
开发者ID:alexandraferguson,项目名称:python-code-snippets,代码行数:9,代码来源:ftp_base.py
示例7: update_player_with_raise
def update_player_with_raise(self, player, raise_increase):
amount_to_call = self.bet - player.curr_bet
player.chips -= amount_to_call + raise_increase
self.bet += raise_increase
player.curr_bet = self.bet
self.pot += amount_to_call + raise_increase
self.curr_raise += raise_increase
utils.out("%s(%d) raises to %d. Pot is %d" % (
player.name, player.chips, self.bet, self.pot), self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:9,代码来源:deal.py
示例8: main
def main(ENTITY_TYPE):
entity_type_table = ENTITY_TYPE.replace('-', '_')
url_relationship_table = 'l_%s_url' % entity_type_table if ENTITY_TYPE != 'work' else 'l_url_%s' % entity_type_table
main_entity_entity_point = "entity0" if ENTITY_TYPE != 'work' else "entity1"
url_entity_point = "entity1" if ENTITY_TYPE != 'work' else "entity0"
query = """
WITH
entities_wo_wikidata AS (
SELECT DISTINCT e.id AS entity_id, e.gid AS entity_gid, u.url AS wp_url, substring(u.url from '//(([a-z]|-)+)\\.') as wp_lang
FROM """ + entity_type_table + """ e
JOIN """ + url_relationship_table + """ l ON l.""" + main_entity_entity_point + """ = e.id AND l.link IN (SELECT id FROM link WHERE link_type = """ + str(WIKIPEDIA_RELATIONSHIP_TYPES[ENTITY_TYPE]) + """)
JOIN url u ON u.id = l.""" + url_entity_point + """ AND u.url LIKE 'http://%%.wikipedia.org/wiki/%%'
WHERE
/* No existing WikiData relationship for this entity */
NOT EXISTS (SELECT 1 FROM """ + url_relationship_table + """ ol WHERE ol.""" + main_entity_entity_point + """ = e.id AND ol.link IN (SELECT id FROM link WHERE link_type = """ + str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE]) + """))
/* WP link should only be linked to this entity */
AND NOT EXISTS (SELECT 1 FROM """ + url_relationship_table + """ ol WHERE ol.""" + url_entity_point + """ = u.id AND ol.""" + main_entity_entity_point + """ <> e.id)
AND l.edits_pending = 0
)
SELECT e.id, e.gid, e.name, ewf.wp_url, b.processed
FROM entities_wo_wikidata ewf
JOIN """ + entity_type_table + """ e ON ewf.entity_id = e.id
LEFT JOIN bot_wp_wikidata_links b ON e.gid = b.gid AND b.lang = ewf.wp_lang
ORDER BY b.processed NULLS FIRST, e.id
LIMIT 500
"""
seen = set()
matched = set()
for entity in db.execute(query):
if entity['gid'] in matched:
continue
colored_out(bcolors.OKBLUE, 'Looking up entity "%s" http://musicbrainz.org/%s/%s' % (entity['name'], ENTITY_TYPE, entity['gid']))
out(' * wiki:', entity['wp_url'])
page = WikiPage.fetch(entity['wp_url'], False)
if page.wikidata_id:
wikidata_url = 'http://www.wikidata.org/wiki/%s' % page.wikidata_id.upper()
edit_note = 'From %s' % (entity['wp_url'],)
colored_out(bcolors.OKGREEN, ' * found WikiData identifier:', wikidata_url)
time.sleep(1)
out(' * edit note:', edit_note.replace('\n', ' '))
mb.add_url(ENTITY_TYPE.replace('-', '_'), entity['gid'], str(WIKIDATA_RELATIONSHIP_TYPES[ENTITY_TYPE]), wikidata_url, edit_note, True)
matched.add(entity['gid'])
if entity['processed'] is None and entity['gid'] not in seen:
db.execute("INSERT INTO bot_wp_wikidata_links (gid, lang) VALUES (%s, %s)", (entity['gid'], page.lang))
else:
db.execute("UPDATE bot_wp_wikidata_links SET processed = now() WHERE (gid, lang) = (%s, %s)", (entity['gid'], page.lang))
seen.add(entity['gid'])
stats['seen'][ENTITY_TYPE] = len(seen)
stats['matched'][ENTITY_TYPE] = len(matched)
开发者ID:tommycrock,项目名称:musicbrainz-bot,代码行数:55,代码来源:wp_wikidata_links.py
示例9: amazon_lookup_asin
def amazon_lookup_asin(url):
params = {"ResponseGroup": "ItemAttributes,Medium,Images", "IdType": "ASIN"}
loc = amazon_url_loc(url)
asin = amazon_url_asin(url)
if loc not in amazon_api:
amazon_api[loc] = amazonproduct.API(locale=loc)
try:
root = amazon_api[loc].item_lookup(asin, **params)
except amazonproduct.errors.InvalidParameterValue, e:
out(e)
return None
开发者ID:weisslj,项目名称:musicbrainz-bot,代码行数:11,代码来源:asin_links_remove.py
示例10: get_sidepot
def get_sidepot(self, player):
bets_this_round = sum(player.curr_bet for player in self.players)
pot_before_bet = self.pot - bets_this_round
sidepot = pot_before_bet + player.curr_bet
for other in self.players:
#To do: players cannot have the same name
if other.name != player.name:
if other.curr_bet < player.curr_bet:
sidepot += other.curr_bet
else:
sidepot += player.curr_bet
utils.out('%s has a sidepot of %d' % (player.name, sidepot), self.debug_level)
return sidepot
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:13,代码来源:deal.py
示例11: play_round
def play_round(self):
#Preflop
for player in self.players:
utils.out("%s is dealt %s" % (player.name, player.hand.read_out()), self.debug_level)
seat_to_act = self.get_next_seat(self.small_blind_seat, num_seats=2)
if self.play_all_actions(seat_to_act):
return
self.clean_up_betting_round()
#Flop
self.communal_cards += self.deck.draw(num_cards=3)
utils.out("Flop: %s %s %s" % (self.communal_cards[0].read_out(), self.communal_cards[1].read_out(),
self.communal_cards[2].read_out()), self.debug_level)
if self.play_all_actions(self.small_blind_seat):
return
self.clean_up_betting_round()
#Turn
self.communal_cards += self.deck.draw()
utils.out("Turn: %s" % self.communal_cards[3].read_out(), self.debug_level)
if self.play_all_actions(self.small_blind_seat):
return
self.clean_up_betting_round()
#River
self.communal_cards += self.deck.draw()
utils.out("River: %s" % self.communal_cards[4].read_out(), self.debug_level)
if self.play_all_actions(self.small_blind_seat):
return
self.set_player_ranks()
self.clean_up(players_by_rank = self.get_players_by_rank())
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:31,代码来源:deal.py
示例12: pay_winnings
def pay_winnings(self, winnings, winners):
for i, winner in enumerate(winners):
#Pay remainder to the first winner
if i == 0:
remainder = winnings % len(winners)
winner.chips += remainder
self.pot -= remainder
utils.out('%s(%d) wins remainder of %d' % (winner.name, winner.chips,
remainder), self.debug_level)
winner.chips += winnings / len(winners)
utils.out('%s(%d) wins %d chips with %s' % (winner.name, winner.chips,
winnings, winner.hand.read_out()), self.debug_level)
self.pot -= winnings / len(winners)
return winners
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:15,代码来源:deal.py
示例13: update_player_with_call
def update_player_with_call(self, player):
#Note: call_amount is 0 in the case that the big blind calls preflop.
amount_to_call = self.bet - player.curr_bet
#Check if player is all-in
if amount_to_call > player.chips:
player.curr_bet += player.chips
self.pot += player.chips
utils.out('%s(0) calls for %d and is all in. Pot is %d' % (
player.name, player.chips, self.pot), self.debug_level)
player.chips = 0
else:
player.curr_bet = self.bet
player.chips -= amount_to_call
self.pot += amount_to_call
utils.out("%s(%d) calls for %d. Pot is %d" % (
player.name, player.chips, amount_to_call, self.pot), self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:16,代码来源:deal.py
示例14: __init__
def __init__(self, players, small_blind=1, big_blind=2, dealer_seat=0, debug_level=0):
self.debug_level = debug_level
self.players = players
self.deck = Deck()
self.small_blind = small_blind
self.big_blind = big_blind
self.pot = 0
self.curr_raise = 0
self.num_players_in_hand = len(self.players)
self.num_active_players_in_hand = self.num_players_in_hand
self.communal_cards = []
self.initiate_round(dealer_seat)
utils.out('---------------------------------------', self.debug_level)
utils.out('%s(%d) is dealer.' % (self.players[dealer_seat].name, self.players[dealer_seat].chips),
self.debug_level)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:17,代码来源:deal.py
示例15: main
def main():
seen = set()
matched = set()
for artist in db.execute(query):
if artist['gid'] in matched:
continue
colored_out(bcolors.OKBLUE, 'Looking up artist "%s" http://musicbrainz.org/artist/%s' % (artist['name'], artist['gid']))
out(' * wiki:', artist['wp_url'])
page = WikiPage.fetch(artist['wp_url'], False)
identifiers = determine_authority_identifiers(page)
if 'VIAF' in identifiers:
if not isinstance(identifiers['VIAF'], basestring):
colored_out(bcolors.FAIL, ' * multiple VIAF found: %s' % ', '.join(identifiers['VIAF']))
elif identifiers['VIAF'] == '' or identifiers['VIAF'] is None:
colored_out(bcolors.FAIL, ' * invalid empty VIAF found')
else:
viaf_url = 'http://viaf.org/viaf/%s' % identifiers['VIAF']
edit_note = 'From %s' % (artist['wp_url'],)
colored_out(bcolors.OKGREEN, ' * found VIAF:', viaf_url)
# Check if this VIAF has not been deleted
skip = False
try:
resp, content = httplib2.Http().request(viaf_url)
except socket.error:
colored_out(bcolors.FAIL, ' * timeout!')
skip = True
deleted_message = 'abandonedViafRecord'
if skip == False and (resp.status == '404' or deleted_message in content):
colored_out(bcolors.FAIL, ' * deleted VIAF!')
skip = True
if skip == False:
time.sleep(3)
out(' * edit note:', edit_note.replace('\n', ' '))
mb.add_url('artist', artist['gid'], str(VIAF_RELATIONSHIP_TYPES['artist']), viaf_url, edit_note)
matched.add(artist['gid'])
if artist['processed'] is None and artist['gid'] not in seen:
db.execute("INSERT INTO bot_wp_artist_viaf (gid, lang) VALUES (%s, %s)", (artist['gid'], page.lang))
else:
db.execute("UPDATE bot_wp_artist_viaf SET processed = now() WHERE (gid, lang) = (%s, %s)", (artist['gid'], page.lang))
seen.add(artist['gid'])
开发者ID:legoktm,项目名称:musicbrainz-bot,代码行数:43,代码来源:wp_artist_viaf.py
示例16: clean_up
def clean_up(self, players_by_rank=None, winning_seat=None):
#If the hand did not go to showdown, pay the entire pot to the remaining player.
if winning_seat is not None:
winner = self.players[winning_seat]
winner.chips += self.pot
utils.out("%s(%d) wins the pot of %d" % (
winner.name, winner.chips, self.pot), self.debug_level)
#Otherwise, pay the pot to the winners in order of their hands, taking into account
#sidepots and split pots.
else:
while self.pot > 0:
#Get the set of winners with the highest rank
winners, players_by_rank = self.get_winners_with_highest_rank(players_by_rank)
#Pay out the winners with the highest rank that have sidepots.
winners = self.divide_sidepots_among_winners(winners)
#If at least one winner did not have a sidepot, pay the remaining pot.
if len(winners) > 0:
winners = self.pay_winnings(self.pot, winners)
开发者ID:dschwarz26,项目名称:PokerBot,代码行数:21,代码来源:deal.py
示例17: determine_country
def determine_country(page):
all_countries = set()
all_reasons = []
countries, reason = determine_country_from_infobox(page.infobox)
if countries:
all_countries.update(countries)
all_reasons.append(reason)
countries, reason = determine_country_from_text(page)
if countries:
all_countries.update(countries)
all_reasons.append(reason)
countries, reason, category_count = determine_country_from_categories(page.categories)
has_categories = False
if countries:
all_countries.update(countries)
all_reasons.append(reason)
has_categories = True
if len(all_reasons) < 1 or not all_countries or not has_categories:
out(' * not enough sources for countries', all_countries, all_reasons)
return None, []
if len(all_countries) > 1:
out(' * conflicting countries', all_countries, all_reasons)
return None, []
country = list(all_countries)[0]
country_id = country_ids[country]
out(' * new country:', country, country_id)
return country_id, all_reasons
开发者ID:reosarevok,项目名称:musicbrainz-bot,代码行数:27,代码来源:wp_artist_country.py
示例18: build_stop_line_info_file
def build_stop_line_info_file(stop_line_info_file, name_index):
""" Build the stop line info file """
file_matches = os.path.join(
settings['build_folder'],
settings['tnds_file_glob']
)
namespace = {'n': 'http://www.transxchange.org.uk/'}
ref_xpath = './n:StopPoints/n:AnnotatedStopPointRef/n:StopPointRef'
stop_sets = {}
for name in glob.glob(file_matches):
current_set = os.path.basename(name)[4:-4]
if current_set not in name_index:
out('Unknown set {}'.format(current_set))
line_name = '?'
else:
line_name = name_index[current_set]
out('Parsing set {}...'.format(current_set))
root = xml.etree.ElementTree.parse(name).getroot()
for ref in root.findall(ref_xpath, namespace):
code = ref.text.strip()
if code not in stop_sets:
stop_sets[code] = []
stop_sets[code].append(line_name)
out('Saving results file {}...'.format(stop_line_info_file))
with open(stop_line_info_file, 'w') as outfile:
json.dump(stop_sets, outfile)
开发者ID:aliceh75,项目名称:brightbus,代码行数:26,代码来源:build_stop_line_info.py
示例19: build_stops_database
def build_stops_database():
""" Build the stops database """
stops_file_name = os.path.join(
settings['build_folder'],
settings['stops_file']
)
stop_line_info_file_name = os.path.join(
settings['build_folder'],
settings['stop_line_info_file']
)
with open(stop_line_info_file_name) as f:
line_info = json.load(f)
naptan_less_count = 0
database = []
with open(stops_file_name) as stops_file:
reader = csv.DictReader(stops_file)
for row in reader:
if row['LocalityName'] in settings['localities']:
obj = get_stop_definition(row, line_info)
if obj['naptanCode'] != '':
database.append(obj)
else:
naptan_less_count += 1
# Order them, and remove order info as it's not needed.
database = sorted(database, key=lambda o: o['order'])
for o in database:
del o['order']
out("Found {c} stops.".format(c=len(database)))
if naptan_less_count > 0:
out("{x} stops didn't have a Naptan code and were ignored.".format(x=naptan_less_count))
out("Saving database...")
with open(settings['result_file_path'], 'w') as result_file:
result_file.write(json.dumps(database))
开发者ID:aliceh75,项目名称:brightbus,代码行数:34,代码来源:databuilder.py
示例20: main
def main(args):
if not args:
out('Usage: cancel_edits.py <edit_number edit_note>...\n')
out('Example: cancel_edits.py "Edit #123 my mistake"')
out(' cancel_edits.py 123 124 125')
return
edits = []
for arg in args:
if not isinstance(arg, unicode):
arg = unicode(arg, locale.getpreferredencoding())
m = re.match(ur'(?:[Ee]dit )?#?([0-9]+) ?(.*)$', arg)
if not m:
out('invalid edit number "%s", aborting!' % arg)
return
edit_nr = str(m.group(1))
edit_note = m.group(2).lstrip()
edits.append((edit_nr, edit_note))
mb = MusicBrainzClient(cfg.MB_USERNAME, cfg.MB_PASSWORD, cfg.MB_SITE)
for edit_nr, edit_note in edits:
out(u'Cancel edit #%s: %s' % (edit_nr, edit_note if edit_note else u'<no edit note>'))
mb.cancel_edit(str(edit_nr), edit_note)
开发者ID:Freso,项目名称:musicbrainz-bot,代码行数:23,代码来源:cancel_edits.py
注:本文中的utils.out函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论