diff options
author | hut <hut@lepus.uberspace.de> | 2014-12-03 18:47:17 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2014-12-03 18:47:17 +0100 |
commit | 8d1b25656c488314073f4d317fa4d794b253f723 (patch) | |
tree | ce1d0934d33932dfb937257230f5c4f986584798 /ranger | |
parent | 1bf835096a9e864fa46c009973b690acf4aee59d (diff) | |
download | ranger-8d1b25656c488314073f4d317fa4d794b253f723.tar.gz |
ext.papermanager: added docstring
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/ext/papermanager.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/ranger/ext/papermanager.py b/ranger/ext/papermanager.py index a013585f..69b3095c 100644 --- a/ranger/ext/papermanager.py +++ b/ranger/ext/papermanager.py @@ -1,6 +1,19 @@ # Copyright (C) 2014 Roman Zimbelmann <hut@lepus.uberspace.de> # This software is distributed under the terms of the GNU GPL version 3. +""" +A Paper Manager that reads metadata information about papers from a file. + +The file is named .paperinfo and is formatted as comma-separated values. + +The columns are: +1. Filename +2. Date +3. Title +4. Authors +5. URL +""" + import csv from os.path import join, dirname, exists, basename @@ -19,7 +32,8 @@ class PaperManager(object): try: return self.metadata_cache[filename] except KeyError: - result = OpenStruct(title=None, year=None, filename=filename) + result = OpenStruct(filename=filename, title=None, year=None, + authors=None, url=None) metafile = join(dirname(filename), ".paperinfo") # get entries of the metadata file @@ -30,7 +44,7 @@ class PaperManager(object): reader = csv.reader(open(metafile, "r"), skipinitialspace=True) - entries = list(entry for entry in reader if len(entry) == 3) + entries = list(entry for entry in reader if len(entry) == 5) self.metafile_cache[metafile] = entries else: # No metadata file @@ -48,8 +62,8 @@ class PaperManager(object): return result def _fill_ostruct_with_data(self, ostruct, dataset): - filename, year, title = dataset - if year: - ostruct.year = year - if title: - ostruct.title = title + filename, year, title, authors, url = dataset + if year: ostruct.year = year + if title: ostruct.title = title + if authors: ostruct.authors = authors + if url: ostruct.url = url |