Skip to content

Commit 2eef113

Browse files
author
mjbommar
committed
travis/pylint iteration
1 parent b957a3e commit 2eef113

File tree

6 files changed

+26
-33
lines changed

6 files changed

+26
-33
lines changed

lexpredict_openedgar/openedgar/clients/edgar.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ def get_buffer(remote_path: str, base_path: str = HTTP_SEC_HOST):
7373
if 'Last-Modified' in r.headers:
7474
try:
7575
last_modified_date = dateutil.parser.parse(r.headers['Last-Modified']).date()
76-
except Exception as e:
77-
logger.error("Unable to update last modified date: {0}".format(remote_path, failures, e))
76+
except Exception as e: # pylint: disable=broad-except
77+
logger.error("Unable to update last modified date for {0}: {1}".format(remote_path, e))
7878

7979
file_buffer = r.content
8080
complete = True
8181

8282
# Sleep if set gt0
8383
if HTTP_SLEEP_DEFAULT > 0:
8484
time.sleep(HTTP_SLEEP_DEFAULT)
85-
except Exception as e:
85+
except Exception as e: # pylint: disable=broad-excepts
8686
# Handle and sleep
8787
if failures < len(HTTP_FAIL_SLEEP):
8888
logger.warning("File {0}, failure {1}: {2}".format(remote_path, failures, e))
@@ -114,7 +114,7 @@ def list_path(remote_path: str):
114114
"""
115115
# Log entrance
116116
logger.info("Retrieving directory listing from {0}".format(remote_path))
117-
remote_buffer, last_modified_date = get_buffer(remote_path)
117+
remote_buffer, _ = get_buffer(remote_path)
118118

119119
# Parse the index listing
120120
if remote_buffer is None:
@@ -256,7 +256,7 @@ def get_company(cik: Union[int, str]):
256256
encoding="utf-8").decode("utf-8")
257257
mailing_address = " ".join(raw_address.splitlines()[1:]).strip()
258258
company_data["mailing_address"] = mailing_address
259-
except Exception as e:
259+
except Exception as e: # pylint: disable=broad-except
260260
logger.warning("Unable to parse mailing_address: {0}".format(e))
261261
company_data["mailing_address"] = None
262262

@@ -265,34 +265,34 @@ def get_company(cik: Union[int, str]):
265265
encoding="utf-8").decode("utf-8")
266266
business_address = " ".join(raw_address.splitlines()[1:]).strip()
267267
company_data["business_address"] = business_address
268-
except Exception as e:
268+
except Exception as e: # pylint: disable=broad-except
269269
logger.warning("Unable to parse business_address: {0}".format(e))
270270
company_data["business_address"] = None
271271

272272
try:
273273
company_data["name"] = list(list(company_info_div)[2])[0].text.strip()
274-
except Exception as e:
274+
except Exception as e: # pylint: disable=broad-except
275275
logger.warning("Unable to parse name: {0}".format(e))
276276
company_data["name"] = None
277277

278278
try:
279279
ident_info_p = list(list(company_info_div)[2])[1]
280280
company_data["sic"] = list(ident_info_p)[1].text
281-
except Exception as e:
281+
except Exception as e: # pylint: disable=broad-except
282282
logger.warning("Unable to parse SIC: {0}".format(e))
283283
company_data["sic"] = None
284284

285285
try:
286286
ident_info_p = list(list(company_info_div)[2])[1]
287287
company_data["state_location"] = list(ident_info_p)[3].text
288-
except Exception as e:
288+
except Exception as e: # pylint: disable=broad-except
289289
logger.warning("Unable to parse SIC: {0}".format(e))
290290
company_data["state_location"] = None
291291

292292
try:
293293
ident_info_p = list(list(company_info_div)[2])[1]
294294
company_data["state_incorporation"] = list(ident_info_p)[4].text
295-
except Exception as e:
295+
except Exception as e: # pylint: disable=broad-except
296296
logger.warning("Unable to parse SIC: {0}".format(e))
297297
company_data["state_incorporation"] = None
298298

lexpredict_openedgar/openedgar/processes/s3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def clean_rate_limited_files(cik: int = None, fix: bool = True, client=None):
144144

145145
# Fix if requested
146146
if fix:
147-
logger.info("Fixing file...".format(remote_path))
147+
logger.info("Fixing file: {0}".format(remote_path))
148148

149149
# Ensure path is correct
150150
if not remote_path.strip("/").startswith("Archives/"):
@@ -153,7 +153,7 @@ def clean_rate_limited_files(cik: int = None, fix: bool = True, client=None):
153153
edgar_url = remote_path
154154

155155
# Get buffer from EDGAR
156-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(edgar_url)
156+
buffer, _ = openedgar.clients.edgar.get_buffer(edgar_url)
157157

158158
# Replace bad remote path on S3
159159
openedgar.clients.s3.put_buffer(remote_path, buffer, client)
@@ -203,7 +203,7 @@ def clean_empty_files(cik: int = None, fix: bool = True, client=None):
203203

204204
# Fix if requested
205205
if fix:
206-
logger.info("Fixing file...".format(remote_path))
206+
logger.info("Fixing file: {0}".format(remote_path))
207207

208208
# Ensure path is correct
209209
if not remote_path.strip("/").startswith("Archives/"):
@@ -212,7 +212,7 @@ def clean_empty_files(cik: int = None, fix: bool = True, client=None):
212212
edgar_url = remote_path
213213

214214
# Get buffer from EDGAR
215-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(edgar_url)
215+
buffer, _ = openedgar.clients.edgar.get_buffer(edgar_url)
216216

217217
# Replace bad remote path on S3
218218
if len(buffer) > 0:
@@ -266,7 +266,7 @@ def clean_access_denied_files(cik: int = None, fix: bool = True, client=None):
266266

267267
# Fix if requested
268268
if fix:
269-
logger.info("Removing file...".format(remote_path))
269+
logger.info("Removing file: {0}".format(remote_path))
270270

271271
# Replace bad remote path on S3
272272
success = openedgar.clients.s3.delete_path(remote_path, client)

lexpredict_openedgar/openedgar/tasks.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ def process_filing_index(s3_path: str, filing_index_buffer: Union[str, bytes] =
237237
try:
238238
filing = Filing.objects.get(s3_path=filing_path)
239239
logger.info("Filing record already exists: {0}".format(filing))
240-
except Filing.MultipleObjectsReturned as _:
240+
except Filing.MultipleObjectsReturned as e:
241241
# Create new filing record
242242
logger.error("Multiple Filing records found for s3_path={0}, skipping...".format(filing_path))
243243
continue
244-
except Filing.DoesNotExist as _:
244+
except Filing.DoesNotExist as f:
245245
# Create new filing record
246246
logger.info("No Filing record found for {0}, creating...".format(filing_path))
247247

@@ -250,8 +250,8 @@ def process_filing_index(s3_path: str, filing_index_buffer: Union[str, bytes] =
250250
# Download
251251
try:
252252
filing_buffer, _ = openedgar.clients.edgar.get_buffer("/Archives/{0}".format(filing_path))
253-
except RuntimeError as e:
254-
logger.error("Unable to access resource {0} from EDGAR: {1}".format(filing_path, e))
253+
except RuntimeError as g:
254+
logger.error("Unable to access resource {0} from EDGAR: {1}".format(filing_path, g))
255255
bad_record_count += 1
256256
create_filing_error(row, filing_path)
257257
continue
@@ -399,7 +399,7 @@ def process_filing(s3_path: str, filing_buffer: Union[str, bytes] = None, store_
399399
filing.is_processed = False
400400
filing.is_error = True
401401
filing.save()
402-
except Exception as e: # pylint: disable=bare-except
402+
except Exception as e: # pylint: disable=broad-except
403403
logger.error("Unable to create filing record: {0}".format(e))
404404
return None
405405

@@ -410,7 +410,7 @@ def process_filing(s3_path: str, filing_buffer: Union[str, bytes] = None, store_
410410
filing.is_error = False
411411
filing.save()
412412
return filing
413-
except Exception as e: # pylint: disable=bare-except
413+
except Exception as e: # pylint: disable=broad-except
414414
logger.error("Unable to create filing documents for {0}: {1}".format(filing, e))
415415
return None
416416

@@ -522,3 +522,4 @@ def extract_filing_document_data_sha1(sha1: str):
522522
document_buffer = openedgar.clients.s3.get_buffer(text_s3_path).decode("utf-8")
523523

524524
# TODO: Build your own database here.
525+
_ = len(document_buffer)

lexpredict_openedgar/openedgar/tests.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
"""
24-
25-
from django.test import TestCase
26-
27-
# Create your tests here.

lexpredict_openedgar/openedgar/tests/test_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_filing_parser_header():
5959
:return:
6060
"""
6161
uri = "/Archives/edgar/data/1599891/0001193125-18-000566.txt"
62-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(uri)
62+
buffer, _ = openedgar.clients.edgar.get_buffer(uri)
6363

6464
# parser buffer
6565
expected_name = "Sunshine Bancorp, Inc."
@@ -78,7 +78,7 @@ def test_filing_parser_header_old():
7878
:return:
7979
"""
8080
uri = "/Archives/edgar/data/7323/0000007323-94-000018.txt"
81-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(uri)
81+
buffer, _ = openedgar.clients.edgar.get_buffer(uri)
8282

8383
# parser buffer
8484
expected_name = "ARKANSAS POWER & LIGHT CO"
@@ -99,7 +99,7 @@ def test_filing_parser_pdf():
9999
:return:
100100
"""
101101
uri = "/Archives/edgar/data/721994/0000721994-18-000014.txt"
102-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(uri)
102+
buffer, _ = openedgar.clients.edgar.get_buffer(uri)
103103

104104
# parser buffer
105105
segment_count = 0
@@ -127,7 +127,7 @@ def test_index_parser():
127127
"""
128128
# download index
129129
uri = "/Archives/edgar/daily-index/1994/QTR3/form.093094.idx"
130-
buffer, last_modified_date = openedgar.clients.edgar.get_buffer(uri)
130+
buffer, _ = openedgar.clients.edgar.get_buffer(uri)
131131

132132
# save to temp file
133133
with tempfile.NamedTemporaryFile(delete=False) as temp_file:

lexpredict_openedgar/openedgar/views.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
SOFTWARE.
2323
"""
24-
25-
from django.shortcuts import render
26-
27-
# Create your views here.

0 commit comments

Comments
 (0)