feat: fix isbn -> bibtex

This commit is contained in:
Flinner Yuu 2023-09-27 00:31:04 +03:00
parent a992534c6c
commit ba5680253d
Signed by: flinner
GPG Key ID: 95CE0DA7F0E58CA6
2 changed files with 7 additions and 3 deletions

View File

@ -9,7 +9,9 @@ import fileinput
# 2: Network error # 2: Network error
def eprint(*args, **kwargs): def eprint(*args, **kwargs):
# uncomment to enable debug...
#print(*args, file=sys.stderr, **kwargs) #print(*args, file=sys.stderr, **kwargs)
pass
#isbn can be a csv list #isbn can be a csv list
def convert_isbn_to_bibtex(isbn): def convert_isbn_to_bibtex(isbn):
@ -30,8 +32,8 @@ def convert_isbn_to_bibtex(isbn):
isbn = None isbn = None
if not sys.stdin.isatty() : if not sys.stdin.isatty() and fileinput.input():
stdin_ = list(fileinput.input().splitlines()) stdin_ = list(fileinput.input())
isbn = ",".join(stdin_) isbn = ",".join(stdin_)
print("isbn from stdin:", isbn) print("isbn from stdin:", isbn)
@ -51,3 +53,4 @@ if bibtex:
else: else:
print("Failed to convert ISBN to BibTeX") print("Failed to convert ISBN to BibTeX")
sys.exit(2) sys.exit(2)
sys.exit(0)

View File

@ -24,7 +24,8 @@ def read_clipboard():
def write_to_clipboard(text): def write_to_clipboard(text):
# Write the text to the clipboard on Linux # Write the text to the clipboard on Linux
subprocess.run(["echo", "-n", text, "|", "xclip", "-selection", "clipboard"], shell=True) subprocess.run(["xclip", "-selection", "clipboard"], input = text.strip().encode('utf-8'), check=True)
# bash_it("echo " + text + "|" + "xclip -sel c")
# Write the text to the clipboard on macOS # Write the text to the clipboard on macOS
# subprocess.run(["echo", "-n", text, "|", "pbcopy"], shell=True) # subprocess.run(["echo", "-n", text, "|", "pbcopy"], shell=True)