本文整理汇总了Python中mylib.print_console函数的典型用法代码示例。如果您正苦于以下问题:Python print_console函数的具体用法?Python print_console怎么用?Python print_console使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_console函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: compare_users
def compare_users(self, user, user2):
try:
# comparison = self.api.get_user(user).compare_with_user(user2)
user1_favs = self.api.get_user(user).get_top_artists('overall', 1000)
user2_favs = self.api.get_user(user2).get_top_artists('overall', 1000)
except pylast.WSError as e:
print_console(LEL + " WSError %s: %s" % (e.status, e.details))
exit(-1)
n_artists1 = len(user1_favs)
n_artists2 = len(user2_favs)
user1_favs = [i.item.__str__() for i in user1_favs]
user2_favs = [i.item.__str__() for i in user2_favs]
intersection = [artist for artist in user1_favs if artist in user2_favs]
artist_list = intersection[:5]
comparison_index = round(200.0 * len(intersection) / (n_artists1 + n_artists2), 2)
if comparison_index < 1.0:
bar = PRETTY_BAR[4]
else:
bar = PRETTY_BAR[int(comparison_index / 25.01)]
if artist_list:
parsed_list = [str(item) for item in artist_list]
chart_text = ", ".join(parsed_list)
else:
chart_text = "N/A"
print_console(LEL + " Comparison: %s %s %s: Similarity: %d%% - Common Artists: %s" % (user, bar, user2, comparison_index, chart_text))
开发者ID:b0nk,项目名称:mbot-shell,代码行数:34,代码来源:lastfm.py
示例2: getBundle
def getBundle(b):
charities = ["Electronic Frontier Foundation", "American Red Cross", "Child's Play Charity",
"Mozilla Foundation", "CodeNow", "Maker Education Initiative",
"Save the Children", "charity: water", "Exclusive Dreamcast T-Shirt",
"AbleGamers", "Willow", "SpecialEffect",
"GamesAid", "Girls Who Code", "The V Foundation",
"buildOn", "The IndieCade Foundation", "Extra Life / Children's Miracle Network Hospitals",
"Heifer International", "Comic Book Legal Defense Fund",
"More games coming soon!", "More content coming soon!"]
items = []
if b is 'm':
soup = bs4.BeautifulSoup(requests.get("https://humblebundle.com/mobile").text, "html.parser")
elif b is 'b':
soup = bs4.BeautifulSoup(requests.get("https://humblebundle.com/books").text, "html.parser")
else:
soup = bs4.BeautifulSoup(requests.get("https://humblebundle.com/").text, "html.parser")
res = soup.find_all('span', 'game-box')
if res:
bTitle = soup.find('img', class_="promo-logo")['alt']
for i in res:
item = i.find('img')['alt']
if item not in charities and "Soundtrack" not in item:
items.append(item)
print_console("07%s: %s" % (bTitle, ", ".join(items)))
else:
print_console("This bundle is over!")
开发者ID:xhip,项目名称:mbot-shell,代码行数:32,代码来源:humblebundle.py
示例3: init
def init():
for feed in FEEDS:
f = Feed(feed["id"], feed["logo"], feed["url"])
print_console("Init %s" % f.feedid)
f.mark_all_as_read()
f.save()
print_console("All unseen items marked as read.")
开发者ID:jruben84,项目名称:mbot-shell,代码行数:8,代码来源:rss3.py
示例4: degredo
def degredo():
"""Processo aleatorio"""
request = requests.get('https://inquisicao.deadbsd.org/api/degredo', timeout=TIMEOUT)
j = request.json()
result = auto_de_fe(j)
print_console(result)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:8,代码来源:inquisicao.py
示例5: get_user_info
def get_user_info(self, user):
try:
ui = self.api.get_user(user).get_info()
except pylast.WSError as e:
print_console(LEL + " WSError %s: %s" % (e.status,e.details))
exit(-1)
print_console(LEL + " Profile info for %s (%s, %s, %s) - Country: %s - Registered: %s - Play count: %s -- %s" % (ui['name'], ui['realname'], ui['age'], ui['gender'], ui['country'], ui['registered'], ui['playcount'], ui['url']))
开发者ID:punnie,项目名称:mbot-dongs,代码行数:9,代码来源:lastfm.py
示例6: save
def save(self):
try:
f = open(FEEDFILE, "w+")
obj = f
pickle.dump(self.feeds, obj)
f.close()
except Exception as e:
print_console(e)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:9,代码来源:rss2.py
示例7: item
def item(feedid, n):
exists = False
for f in r.feeds:
if r.feeds[f].feedid == feedid:
exists = True
r.feeds[f].get_item(n)
r.save()
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:10,代码来源:rss2.py
示例8: init
def init():
if not os.path.exists("./rss-data"):
os.makedirs("./rss-data")
for feed in FEEDS:
f = Feed(feed["id"], feed["logo"], feed["url"])
print_console("Init %s" % f.feedid)
f.mark_all_as_read()
f.save()
print_console("All unseen items marked as read.")
开发者ID:b0nk,项目名称:mbot-shell,代码行数:11,代码来源:rss3.py
示例9: item
def item(feedid, n):
exists = False
for feed in FEEDS:
if feed["id"] == feedid:
f = Feed(feed["id"], feed["logo"], feed["url"])
exists = True
f.get_item(n)
f.save()
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:11,代码来源:rss3.py
示例10: recent
def recent(feedid, n):
exists = False
for feed in FEEDS:
if feed["id"] == feedid:
f = Feed(feed["id"], feed["logo"], feed["url"])
exists = True
f.get_recent(n, mark_all_as_read=True)
f.save()
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:11,代码来源:rss3.py
示例11: recent
def recent(feedid, n):
exists = False
for f in r.feeds:
if r.feeds[f].feedid == feedid:
exists = True
r.feeds[f].get_recent(n, mark_all_as_read = True)
r.save()
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:11,代码来源:rss2.py
示例12: load
def load(self):
try:
f = open(FEEDFILE, "rb")
obj = pickle.load(f)
self.feeds = obj
f.close()
except IOError as e:
if e.errno == 2: #ignore when file doesn't exist
pass
except Exception as e:
print_console(e)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:12,代码来源:rss2.py
示例13: reset
def reset(feedid):
exists = False
for feed in FEEDS:
if feed["id"] == feedid:
f = Feed(feed["id"], feed["logo"], feed["url"])
exists = True
f.entries = []
f.save
print_console("Cleared feed %s" % feedid)
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:12,代码来源:rss3.py
示例14: reset
def reset(feedid):
exists = False
for f in r.feeds:
if r.feeds[f].feedid == feedid:
exists = True
r.feeds[f].entries = []
print_console("Cleared feed %s" % feedid)
if not exists:
print_console("Feed %s doesn't exist! :(" % feedid)
else:
r.save()
开发者ID:b0nk,项目名称:mbot-shell,代码行数:12,代码来源:rss2.py
示例15: ad_cautelam
def ad_cautelam(key, page):
"""Pesquisa em elementos de um Processo"""
request = requests.get(
'https://inquisicao.deadbsd.org/api/adcautelam?key=' + key +
'&page=' + str(page), timeout=TIMEOUT)
if request.status_code == 404:
print_console("Not found")
else:
j = request.json()
result = auto_de_fe(j, pesquisa=True)
print_console(result)
开发者ID:b0nk,项目名称:mbot-shell,代码行数:13,代码来源:inquisicao.py
示例16: save
def save(self):
try:
with FileLock(self.feedfile, timeout=5):
f = open(self.feedfile, "w+")
obj = f
pickle.dump(self.entries, obj)
f.close()
except Exception as e:
print_console(e)
except FileLockException:
print_error("Lock Timeout")
开发者ID:b0nk,项目名称:mbot-shell,代码行数:13,代码来源:rss3.py
示例17: get_artist_events
def get_artist_events(self, artist):
try:
artist_info = self.api.get_artist(artist)
artist_events = artist_info.get_upcoming_events()
# list comprehension wont do cause EXCEPTIONS
events_str = ""
n = 0
for event in artist_events:
try:
e_date = event.get_start_date()
e_name = event.get_title()
e_url = event.get_url()
events_str += " - %s: %s - %s\n" % (e_date[:-9], e_name, e_url)
n += 1
if n >= NUM_EVENTS:
break
except pylast.WSError:
pass
if n > 0:
print_console(LEL + " events for %s:" % artist_info.get_name())
print_console(events_str)
else:
print_console(LEL + " no events found for artist %s." % artist_info.get_name())
except pylast.WSError as e:
print_console(LEL + " WSError %s: %s" % (e.status, e.details))
exit(-1)
开发者ID:xhip,项目名称:mbot-shell,代码行数:31,代码来源:lastfm.py
示例18: get_artist_info
def get_artist_info(self, artist):
try:
artist_info = self.api.get_artist(artist)
bio = artist_info.get_bio_summary()
if bio:
bio = re.sub("<[^<]+?>", "", bio)
name = artist_info.get_name()
listener_count = artist_info.get_listener_count()
tags = artist_info.get_top_tags()
tag_text = ""
if tags:
tag_text = ", ".join([tag.item.__str__() for tag in tags[:10]])
tag_text = "Tags: %s." % tag_text
similars = artist_info.get_similar()
similars_text = ", ".join([similar.item.__str__() for similar in similars[:10]])
print_console(LEL + " %s (%d listeners). %s" % (name, listener_count, tag_text))
print_console("Similar Artists: %s" % (similars_text))
if bio:
print_console(bio)
except pylast.WSError as e:
print_console(LEL + " WSError %s: %s" % (e.status, e.details))
exit(-1)
开发者ID:xhip,项目名称:mbot-shell,代码行数:29,代码来源:lastfm.py
示例19: getResults
def getResults(n):
# Request Data
r=requests.get('https://api.twitch.tv/api/channels/{0}'.format(n))
l=requests.get('https://api.twitch.tv/kraken/streams?channel={0}'.format(n))
# Check Status Code
if r.status_code == 200:
# Check Account
j=r.json()
if 'message' not in j:
# User Info
data='Twitch {0}\'s - Title: \002"{1}"\002 - Game: \002"{2}"\002'.format(j["display_name"],c(j["status"]),j["game"])
# Partner Info
if j["partner"] != False:
data+=' [\0036 Partner \003]'
# Steam Info
if j["steam_id"] != None:
data+=' [ Steam: http://steamcommunity.com/profiles/{0} ]'.format(j["steam_id"])
# Status Info
if l.status_code == 200:
l=l.json()
# If "Online"
if l["_total"] != 0:
# User Totals
sf=l["streams"][0]["channel"]["followers"]
st=l["streams"][0]["channel"]["views"]
data+=' [ Totals: {0} Followers | {1} Viewers ]'.format(sf,st)
# Viewers
sv=l["streams"][0]["viewers"]
data+=' [\0039 \002Live\002 w/ {0} viewers \003]'.format(sv)
else:
data+=' [\0034 \002Off\002 \003]'
#Note:
# - Bold: \002
# - Color's: \0034 red \0039 green \0036 purle \0003 clear)
# Output
print_console('{0} - http://www.twitch.tv/{1}'.format(data,n))
else:
print_console('Twitch Returned: {0}'.format(c(j["message"])))
elif r.status_code == 400 or r.status_code == 404:
j=r.json()
print_console('Twitch Returned: {0}'.format(c(j["message"])))
else:
print_console('Request Returned: "{0}" status code.'.format(r.status_code))
开发者ID:jruben84,项目名称:mbot-shell,代码行数:59,代码来源:twitch.py
示例20: compare_users
def compare_users(self, user, user2):
try:
comparison = self.api.get_user(user).compare_with_user(user2)
except pylast.WSError as e:
print_console(LEL + " WSError %s: %s" % (e.status,e.details))
exit(-1)
comparison_index = round(float(comparison[0]),2)*100
artist_list = comparison[1]
parsed_list = [item.__str__() for item in artist_list]
chart_text = ", ".join(parsed_list);
print_console(LEL + " Comparison between %s and %s: Similarity: %d%% - Common Artists: %s" % (user, user2, comparison_index, chart_text))
开发者ID:punnie,项目名称:mbot-dongs,代码行数:15,代码来源:lastfm.py
注:本文中的mylib.print_console函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论