Skip to content

Commit

Permalink
Noise presumably due to upgrading https://github.com/google/yapf.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlorg committed May 13, 2019
1 parent f7e1e24 commit fa59b02
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 80 deletions.
4 changes: 2 additions & 2 deletions metabot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@


def main(): # pylint: disable=missing-docstring
logging.basicConfig(
format='%(asctime)s %(levelname)s %(filename)s:%(lineno)s] %(message)s', level=logging.INFO)
logging.basicConfig(format='%(asctime)s %(levelname)s %(filename)s:%(lineno)s] %(message)s',
level=logging.INFO)

modules = set()
for _, name, _ in pkgutil.iter_modules(modules_package.__path__):
Expand Down
27 changes: 12 additions & 15 deletions metabot/modules/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ def _hourly():
preambles = groupconf.get('dailytext', '').splitlines()
preamble = (preambles and preambles[now.toordinal() % len(preambles)] or
'')
bot.send_message(
chat_id=groupid,
text=_format_daily_message(preamble, events),
parse_mode='HTML',
disable_web_page_preview=True,
disable_notification=True)
bot.send_message(chat_id=groupid,
text=_format_daily_message(preamble, events),
parse_mode='HTML',
disable_web_page_preview=True,
disable_notification=True)
_queue()

_queue()
Expand Down Expand Up @@ -239,12 +238,11 @@ def inline(ctx, modconf): # pylint: disable=too-many-branches,too-many-locals
})
if not nextid:
break
ctx.reply_inline(
results,
is_personal=True,
cache_time=30,
switch_pm_text='Settings',
switch_pm_parameter='L2V2ZW50cyBzZXQ')
ctx.reply_inline(results,
is_personal=True,
cache_time=30,
switch_pm_text='Settings',
switch_pm_parameter='L2V2ZW50cyBzZXQ')


def format_event(bot, event, tzinfo, full=True):
Expand All @@ -267,9 +265,8 @@ def format_event(bot, event, tzinfo, full=True):
def humanize_range(start, end, tzinfo):
"""Return the range between start and end as human-friendly text."""

return humanize.range(
datetime.datetime.fromtimestamp(start, tzinfo), datetime.datetime.fromtimestamp(
end, tzinfo))
return humanize.range(datetime.datetime.fromtimestamp(start, tzinfo),
datetime.datetime.fromtimestamp(end, tzinfo))


def settings(ctx, msg, modconf):
Expand Down
4 changes: 2 additions & 2 deletions metabot/modules/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


def cgi_escape(text): # pylint: disable=missing-docstring
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace(
'"', '&quot;')
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>',
'&gt;').replace('"', '&quot;')


ALIASES = ('channel', 'channels', 'group', 'groups', 'room', 'rooms')
Expand Down
4 changes: 2 additions & 2 deletions metabot/modules/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_invalid_user(conversation): # pylint: disable=redefined-outer-name

assert conversation.message('/admin', user_id=2000) == error_message
assert conversation.message('/admin dummy', user_id=2000) == error_message
assert conversation.message(
'/admin modulestestbot admin add 2000', user_id=2000) == error_message
assert conversation.message('/admin modulestestbot admin add 2000',
user_id=2000) == error_message


def test_default(conversation): # pylint: disable=redefined-outer-name
Expand Down
3 changes: 1 addition & 2 deletions metabot/modules/test_countdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def test_help(conversation): # pylint: disable=redefined-outer-name
conversation.multibot.conf['bots']['modulestestbot']['issue37']['countdown'][
'count2'] = 15349068000

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
<b>Commands</b>
Expand Down
3 changes: 1 addition & 2 deletions metabot/modules/test_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ def test_help(conversation): # pylint: disable=redefined-outer-name
conversation.multibot.conf['bots']['modulestestbot']['issue37']['echo']['rules2'] = (
'These are the rules: Have fun!!')

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
<b>Commands</b>
Expand Down
30 changes: 12 additions & 18 deletions metabot/modules/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na

assert conversation.message('/notevents') == ''

assert conversation.message(
'/events', chat_type='supergroup') == """\
assert conversation.message('/events', chat_type='supergroup') == """\
[chat_id=-1001000001000 disable_web_page_preview=True parse_mode=HTML reply_to_message_id=2000]
I'm not configured for this group! Ask a bot admin to go into the <b>moderator</b> module settings, group <b>-1001000001000</b>, and choose one or more calendars and set the time zone.
"""
Expand Down Expand Up @@ -113,8 +112,8 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator -1001000001000]
"""

assert conversation.message(
'/admin modulestestbot moderator -1001000001000 timezone', language_code='en-us') == """\
assert conversation.message('/admin modulestestbot moderator -1001000001000 timezone',
language_code='en-us') == """\
[chat_id=1000 disable_web_page_preview=True parse_mode=HTML]
Bot Admin \u203a modulestestbot \u203a moderator \u203a -1001000001000 \u203a timezone: <b>Choose a time zone</b>
Expand All @@ -131,8 +130,8 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator -1001000001000]
"""

assert conversation.message(
'/admin modulestestbot moderator -1001000001000 timezone', language_code='en-ca') == """\
assert conversation.message('/admin modulestestbot moderator -1001000001000 timezone',
language_code='en-ca') == """\
[chat_id=1000 disable_web_page_preview=True parse_mode=HTML]
Bot Admin \u203a modulestestbot \u203a moderator \u203a -1001000001000 \u203a timezone: <b>Choose a time zone</b>
Expand All @@ -148,8 +147,8 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator -1001000001000]
"""

assert conversation.message(
'/admin modulestestbot moderator -1001000001000 timezone', language_code='en-gb') == """\
assert conversation.message('/admin modulestestbot moderator -1001000001000 timezone',
language_code='en-gb') == """\
[chat_id=1000 disable_web_page_preview=True parse_mode=HTML]
Bot Admin \u203a modulestestbot \u203a moderator \u203a -1001000001000 \u203a timezone: <b>Choose a time zone</b>
Expand Down Expand Up @@ -208,8 +207,7 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator]
"""

assert conversation.message(
'/events', chat_type='supergroup') == """\
assert conversation.message('/events', chat_type='supergroup') == """\
[chat_id=-1001000001000 disable_web_page_preview=True parse_mode=HTML reply_to_message_id=2000]
<b>Alpha Summary</b>
<a href="https://t.me/modulestestbot?start=L2V2ZW50cyA2ZmMyYzUxMDphbHBoYQ">TODAY, Wed 31, 4:16\u20134:33 pm</a> @ <a href="https://maps.google.com/maps?q=Alpha+Venue%2C+Rest+of+Alpha+Location">Alpha Venue</a>
Expand All @@ -231,8 +229,7 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator]
"""

assert conversation.message(
'/events', chat_type='supergroup') == """\
assert conversation.message('/events', chat_type='supergroup') == """\
[chat_id=-1001000001000 disable_web_page_preview=True parse_mode=HTML reply_to_message_id=2000]
<b>Alpha Summary</b>
<a href="https://t.me/modulestestbot?start=L2V2ZW50cyA2ZmMyYzUxMDphbHBoYQ">TODAY, Thu 1, 12:16\u201312:33 am</a> @ <a href="https://maps.google.com/maps?q=Alpha+Venue%2C+Rest+of+Alpha+Location">Alpha Venue</a>
Expand All @@ -256,17 +253,15 @@ def test_group(conversation, monkeypatch): # pylint: disable=redefined-outer-na
[Back | /admin modulestestbot moderator]
"""

assert conversation.message(
'/events', chat_type='supergroup') == """\
assert conversation.message('/events', chat_type='supergroup') == """\
[chat_id=-1001000001000 disable_web_page_preview=True parse_mode=HTML reply_to_message_id=2000]
<b>Alpha Summary</b>
<a href="https://t.me/modulestestbot?start=L2V2ZW50cyA2ZmMyYzUxMDphbHBoYQ">TODAY, Thu 1, 12:16\u201312:33 am</a> @ <a href="https://maps.google.com/maps?q=Alpha+Venue%2C+Rest+of+Alpha+Location">Alpha Venue</a>
"""

monkeypatch.setattr('time.time', lambda: 2000000.)

assert conversation.message(
'/events', chat_type='supergroup') == """\
assert conversation.message('/events', chat_type='supergroup') == """\
[chat_id=-1001000001000 disable_web_page_preview=True parse_mode=HTML reply_to_message_id=2000]
No events in the next 6 days!
"""
Expand Down Expand Up @@ -600,8 +595,7 @@ def test_settings(conversation): # pylint: disable=redefined-outer-name
def test_help(conversation): # pylint: disable=redefined-outer-name
"""Test /help."""

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
<b>Commands</b>
Expand Down
8 changes: 3 additions & 5 deletions metabot/modules/test_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def test_conversation(conversation, requests_mock): # pylint: disable=redefined
[Back | /admin modulestestbot]
"""

requests_mock.get(
'https://t.me/joinchat/DUMMY_INVITE_LINK',
text="""
requests_mock.get('https://t.me/joinchat/DUMMY_INVITE_LINK',
text="""
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -195,8 +194,7 @@ def test_conversation(conversation, requests_mock): # pylint: disable=redefined
def test_help(conversation): # pylint: disable=redefined-outer-name
"""Test /help."""

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
<b>Commands</b>
Expand Down
3 changes: 1 addition & 2 deletions metabot/modules/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def test_help(conversation): # pylint: disable=redefined-outer-name

assert conversation.message('/nothelp') == ''

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
I don't have much documentation\u2014check with a bot admin!
"""
Expand Down
3 changes: 1 addition & 2 deletions metabot/modules/test_newbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ def test_default(conversation): # pylint: disable=redefined-outer-name
def test_help(conversation): # pylint: disable=redefined-outer-name
"""Test /help."""

assert conversation.message(
'/help', user_id=2000) == """\
assert conversation.message('/help', user_id=2000) == """\
[chat_id=2000 disable_web_page_preview=True parse_mode=HTML]
<b>Commands</b>
Expand Down
5 changes: 3 additions & 2 deletions metabot/multibot.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ def __call__(self, bot, update): # pylint: disable=too-many-branches,too-many-l
for k, val in ctx.user.items():
if k not in ('first_name', 'id', 'last_name'):
ctx.userinfo.data[k] = val
ctx.userinfo.data.name = ('%s %s' % (ctx.user.get('first_name', ''),
ctx.user.get('last_name', ''))).strip()
ctx.userinfo.data.name = (
'%s %s' %
(ctx.user.get('first_name', ''), ctx.user.get('last_name', ''))).strip()

if not ctx.chat or ctx.chat['type'] not in ('channel', 'group', 'supergroup'):
ctx.groupinfo = None
Expand Down
4 changes: 2 additions & 2 deletions metabot/util/adminui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def calendars(ctx, msg, subconf, field, desc, text): # pylint: disable=too-many
msg.action = 'Select a calendar'
msg.add(desc)
msg.add('Select a calendar to add or remove from the list below:')
for calcode, calendar_info in sorted(
ctx.bot.multibot.calendars.items(), key=lambda pair: pair[1]['name']):
for calcode, calendar_info in sorted(ctx.bot.multibot.calendars.items(),
key=lambda pair: pair[1]['name']):
if calcode not in calcodes:
msg.button('Add %s' % calendar_info['name'], 'add %s' % calcode)
else:
Expand Down
4 changes: 2 additions & 2 deletions metabot/util/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


def cgi_escape(text): # pylint: disable=missing-docstring
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace(
'"', '&quot;')
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>',
'&gt;').replace('"', '&quot;')


class _HTMLSanitizer(HTMLParser.HTMLParser):
Expand Down
5 changes: 2 additions & 3 deletions metabot/util/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def totimestamp(isoformat):
r'([.]\d+)?'
r'(([-+]\d{1,2}):?(\d{1,2})|Z)?'
r')?$', isoformat).groups()
dtime = datetime.datetime(
int(year), int(month), int(day), int(hour or 0), int(minute or 0), int(second or 0),
int(1000000 * float(fraction or 0)))
dtime = datetime.datetime(int(year), int(month), int(day), int(hour or 0), int(minute or 0),
int(second or 0), int(1000000 * float(fraction or 0)))
if utchour and utcminute:
tzinfo = _TimeZone(int(utchour) + float(utcminute) / 60)
else:
Expand Down
4 changes: 2 additions & 2 deletions metabot/util/msgbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


def cgi_escape(text): # pylint: disable=missing-docstring
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace(
'"', '&quot;')
return text.replace('&', '&amp;').replace('<', '&lt;').replace('>',
'&gt;').replace('"', '&quot;')


class MessageBuilder(object):
Expand Down
33 changes: 16 additions & 17 deletions metabot/util/yamlutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,20 @@ def __init__(self,
explicit_end=None,
version=None,
tags=None):
yaml.emitter.Emitter.__init__(
self,
stream,
canonical=canonical,
indent=indent,
width=width,
allow_unicode=allow_unicode,
line_break=line_break)
yaml.serializer.Serializer.__init__(
self,
encoding=encoding,
explicit_start=explicit_start,
explicit_end=explicit_end,
version=version,
tags=tags)
_SimplifyingRepresenter.__init__(
self, default_style=default_style, default_flow_style=default_flow_style)
yaml.emitter.Emitter.__init__(self,
stream,
canonical=canonical,
indent=indent,
width=width,
allow_unicode=allow_unicode,
line_break=line_break)
yaml.serializer.Serializer.__init__(self,
encoding=encoding,
explicit_start=explicit_start,
explicit_end=explicit_end,
version=version,
tags=tags)
_SimplifyingRepresenter.__init__(self,
default_style=default_style,
default_flow_style=default_flow_style)
yaml.resolver.Resolver.__init__(self)

0 comments on commit fa59b02

Please sign in to comment.