diff --git a/.gitignore b/.gitignore index 47b5298..31870b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ cachefile.doir index.html -links/ -.idea/ +links +.idea diff --git a/doir.py b/doir.py index 862e4aa..2c0c77b 100755 --- a/doir.py +++ b/doir.py @@ -8,14 +8,15 @@ import socketserver parser = argparse.ArgumentParser() parser.add_argument("directory", help="directory which contains the files to resolve", type=str, default=".") -parser.add_argument("cachefile", help="path to the cache file containing already resolved DOIs", type=str, - default="cachefile.doir", nargs='?') -parser.add_argument("htmlfile", help="path to the html result file", type=str, default="index.html", nargs='?') +parser.add_argument("port", help="port on which the result will be served", type=int, default=8888, nargs='?') args = parser.parse_args() +if os.path.exists("links"): + os.remove("links") + cr = Crossref() results = {} -# Fifty days +# Fifty days in seconds - seconds * minutes * hours * days fifty_days = 60 * 60 * 24 * 50 @@ -86,20 +87,20 @@ def walk_files(dir, prefix): def write_cache(file): - with open(file, 'w') as cache_file: + with open(file, "w") as cache_file: cache_file.write(json.dumps(results)) def read_cache(file): if os.path.isfile(file): - with open(file, 'r') as cache_file: + with open(file, "r") as cache_file: return json.loads(cache_file.read()) else: return {} def write_html(file): - with open(file, 'w') as html_file: + with open(file, "w") as html_file: html_file.write("
| Title | Year | Link |
|---|---|---|