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

Tool taking bibtex file and giving output md rf #401

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

adlina1
Copy link
Contributor

@adlina1 adlina1 commented Jul 23, 2024

output md rf = output markdown reference

def main():
parser = argparse.ArgumentParser()

parser.add_argument('-f', '--file', type=str,
Copy link
Contributor

Choose a reason for hiding this comment

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

This must be an argument, not an option. If no argument is provided, the script should throw an error and terminate.

Comment on lines 17 to 36
try:
authors = entry['author'].split(' and ')
if len(authors) > 1:
authors[-1] = 'and ' + authors[-1]

authors_formatted = ', '.join([a.replace('\n', ' ').strip() for a in authors])
title = entry['title']
year = int(entry['year'])
venue = entry.get('journal') or entry.get('booktitle') or entry.get('archivePrefix')

if not venue:
id_unprocessed = "[" + entry.key + " - " + entry.entry_type + "]"
unprocessed_entries.append(id_unprocessed)
continue

formatted_entries.append((year, f"{authors_formatted}. {title}. {venue.value}. ({year})."))

except KeyError as e:
print(f"One or more necessary fields {str(e)} not present in this BibTeX entry.")
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

All this loop body should be a separate function that takes a single entry as input and returns a string as output.

Comment on lines 55 to 58
parser.add_argument('-ord', '--order', type=str,
choices=['asc', 'desc'],
help='here we set a sort order. We have the choice between "asc" and "desc"',
required=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

this should not be required; if not provided, the order should be newest first

Comment on lines 64 to 67
apa_citations = format_simple(bibtex_str, args.order)
for citation in apa_citations:
print()
print(citation)
Copy link
Contributor

Choose a reason for hiding this comment

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

do not call this 'apa_citations', these might be formatted differently than APA

Copy link

cla-assistant bot commented Jul 23, 2024

CLA assistant check
All committers have signed the CLA.

@copernico copernico merged commit affb93d into SAP:main Jul 25, 2024
3 checks passed
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.

2 participants