Commit 731e0a8f authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

[autopep8] E20 - Remove extraneous whitespace

parent ec97ef11e221
......@@ -92,7 +92,7 @@ class ExpenseLine(AnyEntity):
def dc_long_title(self):
expense = self.parent_expense
if expense :
if expense:
return u'%s - %s' % (self.title, expense.dc_title())
else:
return self.dc_title()
......
This diff is collapsed.
......@@ -51,7 +51,7 @@ class FreshPageTemplate(PageTemplate):
PageTemplate.__init__(self, id=template_id, frames=[main_f])
def beforeDrawPage(self, canvas, document) :
def beforeDrawPage(self, canvas, document):
"""
Overrides the method called before drawing on a new page of the PDF
document. This method draws various static data on the page
......@@ -69,7 +69,7 @@ class FreshPageTemplate(PageTemplate):
canvas.restoreState()
def draw_static_content(self, canvas, document) :
def draw_static_content(self, canvas, document):
"""
Draws on the PDF page the static content that is displayed on all
pages, i.e. logo, company address, header, page number.
......@@ -108,7 +108,7 @@ class FreshPageTemplate(PageTemplate):
except IOError:
# Unable to read logo filename
canvas.setFont("Helvetica",12)
str_data = xml_escape( self.company_data["company-name"] )
str_data = xml_escape(self.company_data["company-name"])
canvas.drawString(1.2*cm,28*cm,str_data)
canvas.setFont("Helvetica",8)
......@@ -167,17 +167,17 @@ class FreshPageTemplate(PageTemplate):
# Old version of reportlab library. must provide font informations
str_width = canvas.stringWidth(string,canvas._fontname,
canvas._fontsize)
if str_width > width :
if str_width > width:
string = string+u"..."
str_width = canvas.stringWidth(string)
while str_width > width :
while str_width > width:
string = string[:-4]+u"..."
str_width = canvas.stringWidth(string)
canvas.drawString(x,y,string)
class FreshDocTemplate(BaseDocTemplate) :
class FreshDocTemplate(BaseDocTemplate):
"""
The Fresh document template is a class explaining how to create a PDF
document for the Fresh application (Expense or Refund). It uses
......@@ -196,8 +196,8 @@ class FreshDocTemplate(BaseDocTemplate) :
the company.
"""
# Initializes the document template with the correct page templates
templates = [ FreshPageTemplate(doc_type, company_data,
template_id="Pages", _=_) ]
templates = [FreshPageTemplate(doc_type, company_data,
template_id="Pages", _=_)]
BaseDocTemplate.__init__(self, output, pageTemplates=templates,
allowSplitting=1)
......
......@@ -6,7 +6,7 @@ functions.
"""
def format_number(number, digits=2) :
def format_number(number, digits=2):
"""
Function that formats a number to be written in the PDF document. It uses
the separating characters for numbers defined in the localized
......@@ -31,7 +31,7 @@ def format_number(number, digits=2) :
count = 0
for char in str_int[::-1]:
if char in '0123456789':
if count != 0 and count % 3 == 0 :
if count != 0 and count % 3 == 0:
# result_int = _(u"thousands sep") + result_int
result_int = u'\u00a0%s' % result_int
result_int = char + result_int
......@@ -41,8 +41,8 @@ def format_number(number, digits=2) :
result_int = u" ".join(result_int.split())
if digits == 0 :
if digits == 0:
formatted_num = result_int
else :
else:
formatted_num = u'%s,%s' % (result_int, str_num.split('.')[1])
return formatted_num
......@@ -34,7 +34,7 @@ class PDFWriter(object):
self._doc_type = None # string "expense" or "refund"
def __init_flow_generator(self, entity) :
def __init_flow_generator(self, entity):
"""
Instanciates the flow generator that will create the PDF flow content
of the document. The real class of flow generator
......@@ -56,7 +56,7 @@ class PDFWriter(object):
self._flow_generator = None
def write(self, entity, output) :
def write(self, entity, output):
"""
Writes a PDF document representing the entity object.
......@@ -77,4 +77,4 @@ class PDFWriter(object):
pdf_doc = FreshDocTemplate(output, self._doc_type, self.company_data, entity._cw._)
# Builds it with the content flow returned by the flow generator
pdf_doc.build( self._flow_generator.generate_flow(entity) )
pdf_doc.build(self._flow_generator.generate_flow(entity))
......@@ -91,7 +91,7 @@ class has_lines(RelationType):
# Expense, and not on refund. ExpenseLines are supposed to be added to
# Refund automatically via a hook through an unsafe_execute
__permissions__ = {
'read' : ('managers', 'users'),
'read': ('managers', 'users'),
'add': ('managers', RRQLExpression('S is Expense, S in_state ST, NOT ST name "accepted"')),
'delete': ('managers', RRQLExpression('S is Expense, S in_state ST, NOT ST name "accepted"')),
}
......
......@@ -7,31 +7,31 @@ except ImportError:
options = (
('logo-filename',
{'type' : 'string',
{'type': 'string',
'default': u"/some/path/to/logo.png",
'help': 'path to the logo used to build pdfs',
'group': 'expense', 'level': 2,
}),
('company-name',
{'type' : 'string',
{'type': 'string',
'default': u"MyCompany",
'help': 'name of the company editing PDFs',
'group': 'expense', 'level': 2,
}),
('company-address',
{'type' : 'string',
{'type': 'string',
'default': u"1, Rue du chat qui pêche - 75005 Paris",
'help': 'address of the company editing PDFs',
'group': 'expense', 'level': 2,
}),
('company-offnum',
{'type' : 'string',
{'type': 'string',
'default': u"123.456.789.00011",
'help': 'official ID number of the company editing PDFs',
'group': 'expense', 'level': 2,
}),
('company-actnum',
{'type' : 'string',
{'type': 'string',
'default': u"101AZ",
'help': 'activity number of the company editing PDFs',
'group': 'expense', 'level': 2,
......
......@@ -27,7 +27,7 @@ class UpdateRefundStateOperation(hook.Operation):
execute = cnx.execute
rql = 'Any A,U,EL ORDERBY A WHERE X has_lines EL, EL paid_by A, ' \
'A associated_to U?, X eid %(x)s'
acc_rset = execute(rql, {'x' : self.expense})
acc_rset = execute(rql, {'x': self.expense})
for account, lines in groupby(acc_rset, lambda row: row[0]):
# reset refund to None for this new account
ref = None
......@@ -36,7 +36,7 @@ class UpdateRefundStateOperation(hook.Operation):
break
ref = ref or self.get_or_create_refund_for(account)
# users don't have permissions to add lines to refunds
execute('SET R has_lines EL WHERE R is Refund, R eid %(r)s, EL eid %(el)s, NOT EXISTS(R has_lines EL)', {'r' : ref, 'el': line})
execute('SET R has_lines EL WHERE R is Refund, R eid %(r)s, EL eid %(el)s, NOT EXISTS(R has_lines EL)', {'r': ref, 'el': line})
def get_or_create_refund_for(self, account):
rql = 'Any R WHERE R is Refund, R to_account A, A eid %(a)s, ' \
......
......@@ -105,7 +105,7 @@ class ExpenseSummaryComponent(component.EntityCtxComponent):
'WHERE X has_lines E, X eid %(x)s, E eid EID, '
'E type T, E title ET, E currency EC, '
'E amount EA, E paid_by C?, C label CL, '
'E paid_for CC, CC label CCL' ,
'E paid_for CC, CC label CCL',
{'x': entity.eid})
self._cw.view('expense.table', rset, w=w)
......@@ -113,7 +113,7 @@ class ExpenseSummaryComponent(component.EntityCtxComponent):
class ExpenseTable(tableview.RsetTableView):
__regid__ = 'expense.table'
headers = [_('eid'), _('type'), _('title'), _('amount'), _('currency'),
_('paid_by'), _('paid_for') ]
_('paid_by'), _('paid_for')]
layout_args = {'display_filter': 'top'}
......
......@@ -10,7 +10,7 @@ class EntitiesTC(HelpersTC):
self.add_expense_line(cnx, expense, self.account1)
self.add_expense_line(cnx, expense, self.account2)
self.add_expense_line(cnx, expense, self.account1)
paid_by = dict( (euser.eid, value)
paid_by = dict((euser.eid, value)
for euser, value in expense.totals_paid_by().items())
self.assertEqual(paid_by, {self.user1: 2, self.user2: 1})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment