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

Sourcery refactored master branch #107

Closed
wants to merge 1 commit into from
Closed

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Oct 26, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from adbar October 26, 2023 11:23
Comment on lines -221 to +231
attempt = try_date_expr(
if attempt := try_date_expr(
text, outputformat, extensive_search, min_date, max_date
)
if attempt:
):
return attempt
# try link title (Blogspot)
title_attr = trim_text(elem.get("title", ""))
if len(title_attr) > MIN_SEGMENT_LEN:
title_attr = NON_DIGITS_REGEX.sub("", title_attr[:MAX_SEGMENT_LEN])
attempt = try_date_expr(
if attempt := try_date_expr(
title_attr, outputformat, extensive_search, min_date, max_date
)
if attempt:
):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function examine_date_elements refactored with the following changes:

Comment on lines -407 to +405
year_match = yearpat.search(pattern)
if year_match:
if year_match := yearpat.search(pattern):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function select_candidate refactored with the following changes:

Comment on lines -645 to +642
year = "19" + year if year[0] == "9" else "20" + year
year = f"19{year}" if year[0] == "9" else f"20{year}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function normalize_match refactored with the following changes:

Comment on lines -873 to +870
month = "0" + month
month = f"0{month}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function search_page refactored with the following changes:

@@ -3,6 +3,7 @@
Custom parsers and XPath expressions for date extraction
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 88-88 refactored with the following changes:

Comment on lines -233 to +234
match = COMPLETE_URL.search(testurl)
if match:
if match := COMPLETE_URL.search(testurl):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function extract_url_date refactored with the following changes:

# 2. Try YYYYMMDD, use regex
match = YMD_NO_SEP_PATTERN.search(string)
if match:
if match := YMD_NO_SEP_PATTERN.search(string):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function custom_parse refactored with the following changes:

This removes the following comments ( why? ):

# 4. Try the Y-M and M-Y patterns
# 2. Try YYYYMMDD, use regex
# 3. Try the very common YMD, Y-M-D, and D-M-Y patterns

match = TEXT_PATTERNS.search(htmlstring) # EN+DE+TR
if match:
if match := TEXT_PATTERNS.search(htmlstring):
parts = list(filter(None, match.groups()))
if len(parts) == 3:
candidate = None
if len(parts[0]) == 4:
candidate = datetime(int(parts[0]), int(parts[1]), int(parts[2]))
elif len(parts[2]) in (2, 4):
elif len(parts[2]) in {2, 4}:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function idiosyncrasies_search refactored with the following changes:

This removes the following comments ( why? ):

# EN+DE+TR

@adbar adbar closed this Oct 26, 2023
@adbar adbar deleted the sourcery/master branch October 26, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant