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