parent
e2dcdc460f
commit
52a9132664
|
@ -47,20 +47,22 @@ class Book(models.Model):
|
|||
#Generate a string from book info
|
||||
def to_string(self, commit=False):
|
||||
scratch = ''
|
||||
authors = ','.join(map(lambda x: str(x),self.get_authors()))
|
||||
if commit:
|
||||
# generate commit string by sending self.to_dict to oysteini function
|
||||
print self.to_dict()
|
||||
print fileformat.write_action(self.to_dict())
|
||||
|
||||
else:
|
||||
format = '%-15s: %50s \n'
|
||||
for field in book_fields:
|
||||
try:
|
||||
scratch += '%-15s: %50s' % (field[1],eval('self.'+field[0])) + '\n'
|
||||
scratch += format % (field[1],eval('self.'+field[0]))
|
||||
except AttributeError:
|
||||
scratch += '%-15s: %50s' % (field[1], '') + '\n'
|
||||
scratch += 'Authors'.ljust(15, ' ') + ':'
|
||||
scratch += authors.rjust(51, ' ')
|
||||
scratch += format % (field[1], '')
|
||||
authors = ','.join(map(lambda x: str(x),self.get_authors()))
|
||||
scratch += format % ('Authors', authors)
|
||||
# scratch += 'Authors'.ljust(15, ' ') + ':'
|
||||
# scratch += authors.rjust(51, ' ')
|
||||
|
||||
scratch += '\n'
|
||||
return scratch
|
||||
|
|
Reference in New Issue