Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trailing colon #547

Merged
merged 2 commits into from Aug 12, 2019
Merged

Conversation

andersonberg
Copy link
Member

Fixes #537
I added code to strip trailing colon and also a test for this code

@codecov
Copy link

codecov bot commented Jul 30, 2019

Codecov Report

Merging #547 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #547      +/-   ##
==========================================
+ Coverage   95.01%   95.01%   +<.01%     
==========================================
  Files         302      302              
  Lines        2466     2468       +2     
==========================================
+ Hits         2343     2345       +2     
  Misses        123      123
Impacted Files Coverage Δ
dateparser/date.py 97.93% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11a761c...632145f. Read the comment docs.

@andersonberg andersonberg self-assigned this Jul 31, 2019
@asadurski asadurski added this to To review in Project board Jul 31, 2019
tests/test_date.py Show resolved Hide resolved
dateparser/date.py Outdated Show resolved Hide resolved
@@ -39,6 +39,7 @@
RE_NBSP = re.compile(u'\xa0', flags=re.UNICODE)
RE_SPACES = re.compile(r'\s+')
RE_TRIM_SPACES = re.compile(r'^\s+(\S.*?)\s+$')
RE_TRIM_COLONS = re.compile(r'(\S.*?):*$')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only strip from the beginning, I think \s*:+$ and .sub(r'', date_string) make a bit more sense: we don’t find a match unless there is at least one colon, and we also remove any extra spacing there might be before the colon (I assume space after the colon would have be stripped already somewhere else, but I did not check).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume space after the colon would have be stripped already somewhere else, but I did not check

It wouldn't, and it's probably a bug... '31/07/2019: ' won't be parsed, because RE_TRIM_SPACES assumes spaces present at both sides of the date string.
I'm not sure if it should be handled in this PR though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what's the best approach here. what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it for another PR. Your approach undeniably fixes the target issue - and that's the point.

Copy link
Member

@asadurski asadurski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Much appreciated!

@andersonberg andersonberg merged commit a01d40a into scrapinghub:master Aug 12, 2019
@asadurski asadurski moved this from To review to To release in Project board Aug 13, 2019
@asadurski asadurski modified the milestones: v0.7.1, v0.7.2 Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Project board
To release
Development

Successfully merging this pull request may close these issues.

Failed to parse, if date ends with colon, "06/25/2019:"
3 participants