diff --git a/python/COMMENTS.md b/python/COMMENTS.md index 6846d26..e39c055 100644 --- a/python/COMMENTS.md +++ b/python/COMMENTS.md @@ -2,7 +2,7 @@ This page represents all my comments from my solutions currently hosted on [Exercism.io](https://exercism.io/). You can view my profile [here](https://exercism.io/profiles/Xevion). The reason for this is simply to have a place where I can collect my comments, as well as just have some fun with Python and webscraping. Exercise file and exercise submission links will be provided for each and every exercise. -This file is for the **Python** track, contains **48** submissions, **18** of which have comments. This file was built on **24-07-2019** at **04:10:14 UTC**. +This file is for the **Python** track, contains **48** submissions, **18** of which have comments. This file was built on **24-07-2019** at **04:30:19 UTC**. ## Word Count @@ -167,6 +167,9 @@ This exercise should be renamed 'Cardinal Numbers' or something along those line Added comments for clarification on what stuff does. For some reason Pytest fails, I believe it's got some kind of problem with it, as only 1 of the 5 tests fails, and I don't exactly see the reason why, so I have reason to believe the pytest itself is incorrect. +Here's my pytest output, which looks correct yet it errors anyways: +https://gist.github.com/Xevion/87995553d7b078208b5dd1f72371db69 + ## Grade School [Link to File](./grade-school/grade_school.py) | [Link to Submission](https://exercism.io/tracks/python/exercises/grade-school/solutions/fe5fbb3e83c14bb392fcc8c1a0275e57) @@ -239,6 +242,10 @@ I forgot that a couple things could be omitted, and decided to trim the nouns so I liked this exercise honestly. I learned about some new modules and methods, for example, while trying to create the invert flag, I was looking into how to negate the matching function, and the `functools` module allows one to create a wrapper that can negate any function you pass through it. +Additionally, I learned that `filter(None, container)` can filter out any and all `False` (in a boolean context, e.g. `None`/`[]`/`''`) items. I actually used that one. + +Otherwise, this exercise was pretty thorough in making one think, and I really had to put my skills to the test to create a scene which I genuinely liked. However, the implementation of overwriting the `open()` function for the pytests seems kind of rigid and would make debugging difficult for anyone running into weird problems (of which I thankfully did not). + ## Tournament [Link to File](./tournament/tournament.py) | [Link to Submission](https://exercism.io/tracks/python/exercises/tournament/solutions/6617ee41fac443be992d3090e650a16e) diff --git a/track_comments.py b/track_comments.py index 85f2b8e..b0fc344 100644 --- a/track_comments.py +++ b/track_comments.py @@ -1,3 +1,4 @@ +import progressbar as pb import requests import pprint import datetime @@ -20,7 +21,7 @@ def simpleReq(url): def parseComment(name, url, soup): comment = soup.find(get_reflection) if comment['class'] == ['reflection']: - return descend(comment)[3].text + return '\n\n'.join(list(map(lambda item : item.text, comment.find_all('p')))) return '' # This script works on the assumption that you have a setup similar to mine. @@ -52,7 +53,12 @@ tracks = {k : list() for k in dict.fromkeys(list(map(lambda i : get_url(i[1]), s # Get all comment data & parse, then put into track dictionary print('Requesting Page Data for {} solution{} from {} {}'.format(len(solutions), 's' if len(solutions) > 1 else '', len(tracks.keys()), 'different tracks' if abs(len(tracks.keys())) != 1 else 'track')) -solutions = [(solution[0], solution[1], bs4.BeautifulSoup(simpleReq(solution[1]), 'html.parser')) for solution in solutions] +# Progress bar +temp = [] +for solution in pb.progressbar(solutions): + soup = bs4.BeautifulSoup(simpleReq(solution[1]), 'html.parser') + temp.append((solution[0], solution[1], soup)) +solutions = temp solutions = [{'name' : solution[0], 'url' : solution[1], 'comment' : parseComment(*solution)} for solution in solutions] # Send all the solutions to their appropriate tracks.