]> git.donarmstrong.com Git - bin.git/commitdiff
update bibtex to paper
authorDon Armstrong <don@donarmstrong.com>
Thu, 5 Jun 2014 18:14:04 +0000 (11:14 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 5 Jun 2014 18:14:04 +0000 (11:14 -0700)
bibtex_to_paper

index 77bfe0f0a63deccc9ef90f577a8864266f8bb63b..c7165a3b2beab9b12bd6caf1ab83d4f73313a0af 100755 (executable)
@@ -225,7 +225,7 @@ sub open_bibtex_key {
         if ($options->{search_by_pmid}) {
             $entry = select_entry_from_pmid($dbh,$sth,$bibtex_key);
         } else {
-            select_entry_from_bibtex_key($dbh,$sth,$bibtex_key);
+            $entry = select_entry_from_bibtex_key($dbh,$sth,$bibtex_key);
         }
         p $entry if $DEBUG;
         open_entry($dbh,$sth,$entry,$options);
@@ -270,6 +270,10 @@ sub open_entry{
     my ($dbh,$sth,$entry,$options) = @_;
 
     return unless defined $entry and ref $entry and keys %{$entry};
+    if ($DEBUG) {
+        print STDERR "Entry: \n";
+        p $entry;
+    }
     if (defined $entry->{file_name} and length $entry->{file_name}) {
         my $paper = select_one($dbh,$sth->{select_papers_by_name},$entry->{file_name});
         if (not defined $paper) {
@@ -287,6 +291,8 @@ sub open_entry{
             }
             open_pdf($paper->{path},$options,$paper->{has_xoj});
             return;
+        } else {
+            print STDERR "Unable to find paper\n" if $DEBUG;
         }
     }
     if (defined $entry->{doi}) {
@@ -321,9 +327,11 @@ sub select_entry_from_bibtex_key{
 
     my $entry = select_one($dbh,$sth->{select_bibtex_by_key},$bibtex_key);
     if (not defined $entry) {
+        print STDERR "Unable to find entry by exact search\n" if $DEBUG;
         $bibtex_key =~ s/:.*$//;
         $entry = select_one($dbh,$sth->{select_bibtex_by_approximate_key},$bibtex_key.'%');
     }
+    print STDERR "Found entry\n" if $DEBUG and defined $entry;
     return $entry;
 }