Skip to content

Commit

Permalink
Got rid of useless HaltExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryShomer committed May 12, 2019
1 parent 057f71a commit ba6f44e
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 53 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/live_scrape.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 1356d6ed8b9db867231d251175a19935
config: fed6b95c7870305f50fcb3b94bddc01d
tags: 645f666f9bcd5a90fca523b33c5a78b7
8 changes: 4 additions & 4 deletions docs/build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Index &#8212; hockey_scraper 1.3.1 documentation</title>
<title>Index &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand All @@ -38,7 +38,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -536,7 +536,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
8 changes: 4 additions & 4 deletions docs/build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Hockey-Scraper &#8212; hockey_scraper 1.3.1 documentation</title>
<title>Hockey-Scraper &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand All @@ -41,7 +41,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nhl_scrape_functions.html" title="NHL Scraping Functions"
accesskey="N">next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -308,7 +308,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nhl_scrape_functions.html" title="NHL Scraping Functions"
>next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="#">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
8 changes: 4 additions & 4 deletions docs/build/html/license_link.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>License &#8212; hockey_scraper 1.3.1 documentation</title>
<title>License &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand All @@ -41,7 +41,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="live_scrape.html" title="Live Scraping"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -803,7 +803,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="live_scrape.html" title="Live Scraping"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
10 changes: 5 additions & 5 deletions docs/build/html/live_scrape.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Live Scraping &#8212; hockey_scraper 1.3.1 documentation</title>
<title>Live Scraping &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand Down Expand Up @@ -45,7 +45,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nwhl_scrape_functions.html" title="NWHL Scraping Functions"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -538,7 +538,7 @@ <h2>Further Usage<a class="headerlink" href="#further-usage" title="Permalink to
<dl class="function">
<dt id="hockey_scraper.nhl.live_scrape.check_date_format">
<code class="descclassname">hockey_scraper.nhl.live_scrape.</code><code class="descname">check_date_format</code><span class="sig-paren">(</span><em>date</em><span class="sig-paren">)</span><a class="headerlink" href="#hockey_scraper.nhl.live_scrape.check_date_format" title="Permalink to this definition"></a></dt>
<dd><p>Verify the date format. If wrong raises a HaltException</p>
<dd><p>Verify the date format. If wrong raises a ValueError</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
Expand Down Expand Up @@ -631,7 +631,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nwhl_scrape_functions.html" title="NWHL Scraping Functions"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
8 changes: 4 additions & 4 deletions docs/build/html/nhl_scrape_functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>NHL Scraping Functions &#8212; hockey_scraper 1.3.1 documentation</title>
<title>NHL Scraping Functions &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand Down Expand Up @@ -45,7 +45,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="index.html" title="Hockey-Scraper"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -2219,7 +2219,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="index.html" title="Hockey-Scraper"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
8 changes: 4 additions & 4 deletions docs/build/html/nwhl_scrape_functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>NWHL Scraping Functions &#8212; hockey_scraper 1.3.1 documentation</title>
<title>NWHL Scraping Functions &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand Down Expand Up @@ -45,7 +45,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nhl_scrape_functions.html" title="NHL Scraping Functions"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -504,7 +504,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="nhl_scrape_functions.html" title="NHL Scraping Functions"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
Binary file modified docs/build/html/objects.inv
Binary file not shown.
8 changes: 4 additions & 4 deletions docs/build/html/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Python Module Index &#8212; hockey_scraper 1.3.1 documentation</title>
<title>Python Module Index &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand All @@ -40,7 +40,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="#" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -172,7 +172,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="#" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
8 changes: 4 additions & 4 deletions docs/build/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Search &#8212; hockey_scraper 1.3.1 documentation</title>
<title>Search &#8212; hockey_scraper 1.32 documentation</title>

<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.3.1',
VERSION: '1.32',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
Expand Down Expand Up @@ -45,7 +45,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>

Expand Down Expand Up @@ -96,7 +96,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.3.1 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="index.html">hockey_scraper 1.32 documentation</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/searchindex.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
# built documents.
#
# The short X.Y version.
version = '1.3.1'
version = '1.32'
# The full version, including alpha/beta/rc tags.
release = '1.3.1'
release = '1.32'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Binary file modified hockey_scraper/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions hockey_scraper/nhl/live_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def set_docs_dir(user_dir):

def check_date_format(date):
"""
Verify the date format. If wrong raises a HaltException
Verify the date format. If wrong raises a ValueError
:param date: User supplied date
Expand All @@ -40,8 +40,8 @@ def check_date_format(date):
try:
time.strptime(date, "%Y-%m-%d")
except ValueError:
raise shared.HaltException("Error: Incorrect format given for dates. They must be given like 'yyyy-mm-dd' "
"(ex: '2016-10-01').")
raise ValueError("Error: Incorrect format given for dates. They must be given like 'yyyy-mm-dd' "
"(ex: '2016-10-01').")


class LiveGame:
Expand Down
15 changes: 5 additions & 10 deletions hockey_scraper/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@
import os
import time
import warnings

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

from . import save_pages as sp


# When we want to kill the current process
class HaltException(Exception): pass

# Own warning...gets rid of junk when printing
def custom_formatwarning(msg, *args, **kwargs): return "Warning: " + str(msg) + '\n'
warnings.formatwarning = custom_formatwarning
Expand Down Expand Up @@ -219,7 +214,7 @@ def scrape_page(url):
except requests.exceptions.ReadTimeout:
# If it times out and it's the schedule print an error message...otherwise just make the page = None
if "schedule" in url:
raise HaltException("Timeout Error: The NHL API took too long to respond to our request. "
raise Exception("Timeout Error: The NHL API took too long to respond to our request. "
"\nPlease Try Again (you may need to try a few times before it works). ")
else:
print_warning("Timeout Error: The server took too long to respond to our request.")
Expand Down Expand Up @@ -251,7 +246,7 @@ def if_rescrape(user_rescrape):
if isinstance(user_rescrape, bool):
re_scrape = user_rescrape
else:
raise HaltException("Error: 'if_rescrape' must be a boolean. Not a {}".format(type(user_rescrape)))
raise ValueError("Error: 'if_rescrape' must be a boolean. Not a {}".format(type(user_rescrape)))


def add_dir(user_dir):
Expand Down Expand Up @@ -336,7 +331,7 @@ def check_data_format(data_format):
:return: Boolean - True if good
"""
if not data_format or data_format.lower() not in ['csv', 'pandas']:
raise HaltException('{} is an unspecified data format. The two options are Csv and Pandas '
raise ValueError('{} is an unspecified data format. The two options are Csv and Pandas '
'(Csv is default)\n'.format(data_format))


Expand All @@ -351,9 +346,9 @@ def check_valid_dates(from_date, to_date):
"""
try:
if time.strptime(to_date, "%Y-%m-%d") < time.strptime(from_date, "%Y-%m-%d"):
raise HaltException("Error: The second date input is earlier than the first one")
raise ValueError("Error: The second date input is earlier than the first one")
except ValueError:
raise HaltException("Error: Incorrect format given for dates. They must be given like 'yyyy-mm-dd' "
raise ValueError("Error: Incorrect format given for dates. They must be given like 'yyyy-mm-dd' "
"(ex: '2016-10-01').")


Expand Down

0 comments on commit ba6f44e

Please sign in to comment.