Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Actually use history module for reading history

  • Loading branch information...
commit 5a500a5da476987cb204eb0cc6d6824a03257c43 1 parent b024d31
@lavelle authored
Showing with 8 additions and 10 deletions.
  1. +7 −9 src/lib/history.py
  2. +1 −1  src/lib/main.py
View
16 src/lib/history.py
@@ -12,7 +12,8 @@ class History:
"""
def __init__(self):
- self.history = PyJson(HISTORY_PATH, base={'history': []})
+ self.history_file = PyJson(HISTORY_PATH, base={'history': []})
+ self.history = self.history_file.doc['history']
def display(self, limit, sort_by, direction, start):
"""
@@ -25,12 +26,11 @@ def display(self, limit, sort_by, direction, start):
- start: the record number to start at
"""
- history = self.history.doc['history']
- if len(history) < 1:
+ if len(self.history) < 1:
print 'No records to display'
return
- history = sorted(history, key=lambda k: k[sort_by], reverse=direction == 'd')
+ history = sorted(self.history, key=lambda k: k[sort_by], reverse=direction == 'd')
grid = [['Id', 'URL', 'Local File', 'Date Created']]
# iterate through the array of records, parse them and create a new 2d array of the formatted values
@@ -60,9 +60,7 @@ def add(self, path, filename, url):
- url: the shortened URl that points to the copy of the file hosted on the users dropbox acount
"""
- history = self.history.doc['history']
-
- id_ = 1 if len(history) == 0 else history[-1]['id'] + 1
+ id_ = 1 if len(self.history) == 0 else self.history[-1]['id'] + 1
record = {
'id': id_,
'path': path,
@@ -71,5 +69,5 @@ def add(self, path, filename, url):
'timestamp': time()
}
- history.append(record)
- self.history.save()
+ self.history.append(record)
+ self.history_file.save()
View
2  src/lib/main.py
@@ -189,7 +189,7 @@ def revisit(args):
"""Perform operations on previously uploaded files such as reuploading or viewing"""
# Load the history
- history = PyJson(HISTORY_PATH).doc['history']
+ history = History().history
# Ensure that the record that user specified exists
if args.id <= len(history):
Please sign in to comment.
Something went wrong with that request. Please try again.