added test. fixed few syntaxic bugs.
This commit is contained in:
parent
acab1b8044
commit
3c11994b6f
@ -1,11 +1,12 @@
|
|||||||
from .. import color
|
import os
|
||||||
from .. import files
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ConfigParser as configparser
|
import ConfigParser as configparser
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
|
from .. import color
|
||||||
|
from .. import files
|
||||||
|
from .. import pretty
|
||||||
|
|
||||||
|
|
||||||
def parser(subparsers, config):
|
def parser(subparsers, config):
|
||||||
@ -23,7 +24,7 @@ def command(config, pdffile, bibfile):
|
|||||||
papersdir = files.find_papersdir()
|
papersdir = files.find_papersdir()
|
||||||
|
|
||||||
fullpdfpath = os.path.abspath(pdffile)
|
fullpdfpath = os.path.abspath(pdffile)
|
||||||
fullbibpath = os.path.abspath(bibtex)
|
fullbibpath = os.path.abspath(bibfile)
|
||||||
files.check_file(fullpdfpath)
|
files.check_file(fullpdfpath)
|
||||||
files.check_file(fullbibpath)
|
files.check_file(fullbibpath)
|
||||||
|
|
||||||
@ -41,12 +42,12 @@ def command(config, pdffile, bibfile):
|
|||||||
|
|
||||||
meta.add_section('notes')
|
meta.add_section('notes')
|
||||||
|
|
||||||
if bibtex is not None:
|
if bibfile is not None:
|
||||||
bib_data = files.load_externalbibfile(fullbibpath)
|
bib_data = files.load_externalbibfile(fullbibpath)
|
||||||
print('{}bibliographic data present in {}{}{}'.format(
|
print('{}bibliographic data present in {}{}{}'.format(
|
||||||
color.grey, color.cyan, bibtex, color.end))
|
color.grey, color.cyan, bibfile, color.end))
|
||||||
print(bib_desc(bib_data))
|
print(pretty.bib_desc(bib_data))
|
||||||
files.write_bibfile(bib_data, filename)
|
files.write_bibdata(bib_data, filename)
|
||||||
|
|
||||||
papers = files.read_papers()
|
papers = files.read_papers()
|
||||||
count = papers.get('header', 'count')
|
count = papers.get('header', 'count')
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# init command
|
# init command
|
||||||
|
|
||||||
|
import os
|
||||||
try:
|
try:
|
||||||
import ConfigParser as configparser
|
import ConfigParser as configparser
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
try:
|
||||||
|
import ConfigParser as configparser
|
||||||
|
except ImportError:
|
||||||
|
import configparser
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from .. import files
|
from .. import files
|
||||||
from .. import color
|
from .. import color
|
||||||
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
def parser(subparsers, config):
|
def parser(subparsers, config):
|
||||||
parser = subparsers.add_parser('open', help="open the paper in a pdf viewer")
|
parser = subparsers.add_parser('open', help="open the paper in a pdf viewer")
|
||||||
parser.add_argument("citekey", help="the paper associated citekey")
|
parser.add_argument("citekey", help="the paper associated citekey")
|
||||||
@ -10,7 +14,12 @@ def parser(subparsers, config):
|
|||||||
|
|
||||||
def command(config, citekey):
|
def command(config, citekey):
|
||||||
papers = files.read_papers()
|
papers = files.read_papers()
|
||||||
filename = papers.get('papers', 'p' + str(citekey))
|
try:
|
||||||
|
filename = papers.get('papers', 'p' + str(citekey))
|
||||||
|
except configparser.NoOptionError:
|
||||||
|
print('{}error{}: paper with citekey {}{}{} not found{}'.format(
|
||||||
|
color.red, color.grey, color.cyan, citekey, color.grey, color.end))
|
||||||
|
exit(-1)
|
||||||
meta_data = files.load_meta(filename)
|
meta_data = files.load_meta(filename)
|
||||||
filepath = meta_data.get('metadata', 'path')
|
filepath = meta_data.get('metadata', 'path')
|
||||||
p = subprocess.Popen(['open', filepath])
|
p = subprocess.Popen(['open', filepath])
|
||||||
|
14
tests/data/pagerank.bib
Normal file
14
tests/data/pagerank.bib
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
@techreport{ilprints422,
|
||||||
|
number = {1999-66},
|
||||||
|
month = {November},
|
||||||
|
author = {Lawrence Page and Sergey Brin and Rajeev Motwani and Terry Winograd},
|
||||||
|
note = {Previous number = SIDL-WP-1999-0120},
|
||||||
|
title = {The PageRank Citation Ranking: Bringing Order to the Web.},
|
||||||
|
type = {Technical Report},
|
||||||
|
publisher = {Stanford InfoLab},
|
||||||
|
year = {1999},
|
||||||
|
institution = {Stanford InfoLab},
|
||||||
|
url = {http://ilpubs.stanford.edu:8090/422/},
|
||||||
|
abstract = {The importance of a Web page is an inherently subjective matter, which depends on the readers interests, knowledge and attitudes. But there is still much that can be said objectively about the relative importance of Web pages. This paper describes PageRank, a mathod for rating Web pages objectively and mechanically, effectively measuring the human interest and attention devoted to them. We compare PageRank to an idealized random Web surfer. We show how to efficiently compute PageRank for large numbers of pages. And, we show how to apply PageRank to search and to user navigation.}
|
||||||
|
}
|
||||||
|
|
BIN
tests/data/pagerank.pdf
Normal file
BIN
tests/data/pagerank.pdf
Normal file
Binary file not shown.
7
tests/test.sh
Executable file
7
tests/test.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
papers init;
|
||||||
|
papers list;
|
||||||
|
papers add data/pagerank.pdf data/pagerank.bib;
|
||||||
|
papers list;
|
||||||
|
papers open 0;
|
||||||
|
rm -Rf .papers;
|
Loading…
x
Reference in New Issue
Block a user