Skip to content

Commit

Permalink
Rename 'open_url' to simply 'open'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 12, 2022
1 parent cb8dea4 commit bf0b13e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pmxbot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def ticker(rest):
change_percent = 'p2'
format = ''.join((symbol, last_trade_time, last_trade_price, change_percent))
url = 'http://finance.yahoo.com/d/quotes.csv?s=%(ticker)s&f=%(format)s' % locals()
stock_info = csv.reader(util.open_url(url).text.splitlines())
stock_info = csv.reader(http.open(url).text.splitlines())
(last_trade,) = stock_info
ticker_given, time, price, diff = last_trade
if ticker_given != ticker:
Expand Down Expand Up @@ -434,7 +434,7 @@ def get_insult():
ins_type = random.randrange(4)
url = f'http://autoinsult.com/?style={ins_type}'
insre = re.compile('<div class="insult" id="insult">(.*?)</div>')
return insre.search(http.open_url(url).text).group(1), ins_type
return insre.search(http.open(url).text).group(1), ins_type


@command()
Expand Down
2 changes: 1 addition & 1 deletion pmxbot/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def _raise(resp):
return resp


def open_url(url):
def open(url):
return _raise(session().get(url))


Expand Down
4 changes: 2 additions & 2 deletions pmxbot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def urban_lookup(word):

def lookup_acronym(acronym, limit=3):
acronym = acronym.strip().upper().replace('.', '')
html = http.open_url('http://www.acronymfinder.com/%s.html' % acronym).text
html = http.open('http://www.acronymfinder.com/%s.html' % acronym).text
soup = bs4.BeautifulSoup(html, 'html.parser')
nodes = soup.findAll(name='td', attrs={'class': 'result-list__body__meaning'})
return [node.text for node in itertools.islice(nodes, limit)]
Expand All @@ -115,7 +115,7 @@ def load_emergency_compliments():
'1eEa2ra2yHBXVZ_ctH4J15tFSGEu-VTSunsrvaCAV598/od6/public/values'
'?alt=json'
)
doc = http.open_url(compurl).json()
doc = http.open(compurl).json()
return [entry['title']['$t'] for entry in doc['feed']['entry']]


Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from jaraco.context import ExceptionTrap

from pmxbot import http
import pmxbot.util


@jaraco.functools.once
def has_internet():
with ExceptionTrap() as trap:
http.open_url('http://www.google.com')
http.open('http://www.google.com')
return not trap


Expand Down

0 comments on commit bf0b13e

Please sign in to comment.