-
Notifications
You must be signed in to change notification settings - Fork 6
Fix KBART URL for Revista española de sanidad penitenciaria using ISSN redirect #84
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
180da15
Initial plan
Copilot 11a0a72
Fix KBART URL for Revista española de sanidad penitenciaria
Copilot 2e45476
Improve ISSN URL redirect implementation with config and precise regex
Copilot b06416c
Optimize ISSN redirect with pre-compiled regex patterns
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,11 +14,24 @@ | |||||||||||||||||||||||||||||||
| import argparse | ||||||||||||||||||||||||||||||||
| import logging | ||||||||||||||||||||||||||||||||
| import codecs | ||||||||||||||||||||||||||||||||
| import re | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| import utils | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| logger = logging.getLogger(__name__) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # ISSN redirects for journals that changed their ISSN in URLs | ||||||||||||||||||||||||||||||||
| # Maps old ISSN to new ISSN | ||||||||||||||||||||||||||||||||
| ISSN_URL_REDIRECTS = { | ||||||||||||||||||||||||||||||||
| '1575-0620': '2013-6463', # Revista española de sanidad penitenciaria (SciELO Spain) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Pre-compile regex patterns for ISSN redirects for better performance | ||||||||||||||||||||||||||||||||
| _ISSN_REDIRECT_PATTERNS = { | ||||||||||||||||||||||||||||||||
| old_issn: re.compile(r'([?&]pid=)' + re.escape(old_issn) + r'(&|$)') | ||||||||||||||||||||||||||||||||
| for old_issn in ISSN_URL_REDIRECTS.keys() | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def _config_logging(logging_level='INFO', logging_file=None): | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -164,7 +177,17 @@ def fmt_csv(self, data): | |||||||||||||||||||||||||||||||
| last_document.issue.number or '' if last_document and last_document.issue else '') | ||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||
| line += ['', '', ''] | ||||||||||||||||||||||||||||||||
| line.append(data.url().replace('sci_serial', 'sci_issues')) | ||||||||||||||||||||||||||||||||
| # Generate the URL | ||||||||||||||||||||||||||||||||
| url = data.url().replace('sci_serial', 'sci_issues') | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Apply ISSN redirects for journals that changed their ISSN in URLs | ||||||||||||||||||||||||||||||||
| # This is necessary for journals that no longer use their print ISSN | ||||||||||||||||||||||||||||||||
| for old_issn, new_issn in ISSN_URL_REDIRECTS.items(): | ||||||||||||||||||||||||||||||||
| # Use pre-compiled regex pattern for better performance | ||||||||||||||||||||||||||||||||
| pattern = _ISSN_REDIRECT_PATTERNS[old_issn] | ||||||||||||||||||||||||||||||||
| url = pattern.sub(r'\g<1>' + new_issn + r'\2', url) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+182
to
+189
|
||||||||||||||||||||||||||||||||
| # Apply ISSN redirects for journals that changed their ISSN in URLs | |
| # This is necessary for journals that no longer use their print ISSN | |
| for old_issn, new_issn in ISSN_URL_REDIRECTS.items(): | |
| # Use pre-compiled regex pattern for better performance | |
| pattern = _ISSN_REDIRECT_PATTERNS[old_issn] | |
| url = pattern.sub(r'\g<1>' + new_issn + r'\2', url) | |
| # Apply ISSN redirects for journals that changed their ISSN in URLs | |
| # This is necessary for journals that no longer use their print ISSN | |
| for old_issn, new_issn in ISSN_URL_REDIRECTS.items(): | |
| # Use pre-compiled regex pattern for better performance | |
| pattern = _ISSN_REDIRECT_PATTERNS[old_issn] | |
| url = pattern.sub(r'\g<1>' + new_issn + r'\2', url) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appears to be trailing whitespace on the blank line after the
url = ...assignment. Please remove the extra spaces to keep the diff clean and avoid whitespace-only changes.