Optimised and cleaned the code [MRG] #280
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Made some minor changes to the code – mostly making some parts of the code more Pythonic and readable – while trying to understand the implementation of Camelot. Great piece of work, and would love to work on more issues/features in the near future. Here is a list of changes which I have made.
camelot/core.py
— Modified the 'for' loops in lines 527-532 to a cleaner and optimised form.
camelot/utils.py
— Added "Accept-Encoding": "gzip;q=1.0, deflate;q=0.9, br;q=0.8, compress;q=0.7, *;q=0.1" to headers in line 86
camelot/handlers.py
— Modified line 38 as self.filepath = download_url(filepath) if is_url(filepath) else filepath
camelot/parsers/lattice.py
— Changed the attribute from 't' to 'table' in the static method _reduce_index() to match the docstring
— Changed the attribute from 't' to 'table' in the static method _copy_spanning_text() and the docstring for consistency across the code, and clarity of usage
— Code optimisations to if conditionals in lines 190-201 to become more Pythonic (Merged adjacent 'if' conditionals with 'and')