mirror of https://github.com/Flinner/dots.git
				
				
				
			feat: fix isbn -> bibtex
This commit is contained in:
		
							parent
							
								
									a992534c6c
								
							
						
					
					
						commit
						ba5680253d
					
				| 
						 | 
					@ -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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue