[IMP] compare to None by identity

bzr revid: xmo@openerp.com-20121214121638-6k5h0ztg94i4f5t6
This commit is contained in:
Xavier Morel 2012-12-14 13:16:38 +01:00
parent 576571bae2
commit 4cb3685f70
11 changed files with 38 additions and 38 deletions

View File

@ -144,7 +144,7 @@ class ir_ui_menu(osv.osv):
return res
def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None):
if context == None:
if context is None:
context = {}
res = {}
for elmt in self.browse(cr, uid, ids, context=context):

View File

@ -2675,7 +2675,7 @@ class BaseModel(object):
groupby = group_by
for r in cr.dictfetchall():
for fld, val in r.items():
if val == None: r[fld] = False
if val is None: r[fld] = False
alldata[r['id']] = r
del r['id']
@ -3584,7 +3584,7 @@ class BaseModel(object):
context = {}
if not ids:
return []
if fields_to_read == None:
if fields_to_read is None:
fields_to_read = self._columns.keys()
# Construct a clause for the security rules.

View File

@ -96,7 +96,7 @@ class report_custom(report_int):
else:
# Process group_by data first
key = []
if group_by != None and fields[group_by] != None:
if group_by is not None and fields[group_by] is not None:
if fields[group_by][0] in levels.keys():
key.append(fields[group_by][0])
for l in levels.keys():
@ -212,7 +212,7 @@ class report_custom(report_int):
new_res = []
prev = None
if groupby != None:
if groupby is not None:
res_dic = {}
for line in results:
if not line[groupby] and prev in res_dic:
@ -322,7 +322,7 @@ class report_custom(report_int):
col.attrib.update(para='yes',
tree='yes',
space=str(3*shift)+'mm')
if line[f] != None:
if line[f] is not None:
col.text = prefix+str(line[f]) or ''
else:
col.text = '/'
@ -381,7 +381,7 @@ class report_custom(report_int):
# plots are usually displayed year by year
# so we do so if the first field is a date
data_by_year = {}
if date_idx != None:
if date_idx is not None:
for r in results:
key = process_date['Y'](r[date_idx])
if key not in data_by_year:
@ -480,7 +480,7 @@ class report_custom(report_int):
# plot are usually displayed year by year
# so we do so if the first field is a date
data_by_year = {}
if date_idx != None:
if date_idx is not None:
for r in results:
key = process_date['Y'](r[date_idx])
if key not in data_by_year:
@ -602,7 +602,7 @@ class report_custom(report_int):
node_line = etree.SubElement(lines, 'row')
for f in range(len(fields)):
col = etree.SubElement(node_line, 'col', tree='no')
if line[f] != None:
if line[f] is not None:
col.text = line[f] or ''
else:
col.text = '/'

View File

@ -119,7 +119,7 @@ class report_printscreen_list(report_int):
precision=(('digits' in fields[f]) and fields[f]['digits'][1]) or 2
line[f]=round(line[f],precision)
col = etree.SubElement(node_line, 'col', tree='no')
if line[f] != None:
if line[f] is not None:
col.text = tools.ustr(line[f] or '')
else:
col.text = '/'

View File

@ -230,7 +230,7 @@ class report_printscreen_list(report_int):
col.text = line[f] = 'Undefined'
col.set('tree', 'undefined')
if line[f] != None:
if line[f] is not None:
col.text = tools.ustr(line[f] or '')
if float_flag:
col.set('tree','float')
@ -245,7 +245,7 @@ class report_printscreen_list(report_int):
for f in range(0, len(fields_order)):
col = etree.SubElement(node_line, 'col', para='group', tree='no')
col.set('tree', 'float')
if tsum[f] != None:
if tsum[f] is not None:
if tsum[f] != 0.0:
digits = fields[fields_order[f]].get('digits', (16, 2))
prec = '%%.%sf' % (digits[1], )

View File

@ -81,7 +81,7 @@ def readObject(stream, pdf):
return NumberObject.readFromStream(stream)
peek = stream.read(20)
stream.seek(-len(peek), 1) # reset to start
if re.match(r"(\d+)\s(\d+)\sR[^a-zA-Z]", peek) != None:
if re.match(r"(\d+)\s(\d+)\sR[^a-zA-Z]", peek) is not None:
return IndirectObject.readFromStream(stream, pdf)
else:
return NumberObject.readFromStream(stream)
@ -169,7 +169,7 @@ class IndirectObject(PdfObject):
def __eq__(self, other):
return (
other != None and
other is not None and
isinstance(other, IndirectObject) and
self.idnum == other.idnum and
self.generation == other.generation and
@ -489,7 +489,7 @@ class DictionaryObject(dict, PdfObject):
# return None if no metadata was found on the document root.
def getXmpMetadata(self):
metadata = self.get("/Metadata", None)
if metadata == None:
if metadata is None:
return None
metadata = metadata.getObject()
import xmp

View File

@ -197,7 +197,7 @@ class PdfFileWriter(object):
# flag is on.
def encrypt(self, user_pwd, owner_pwd = None, use_128bit = True):
import time, random
if owner_pwd == None:
if owner_pwd is None:
owner_pwd = user_pwd
if use_128bit:
V = 2
@ -251,7 +251,7 @@ class PdfFileWriter(object):
# copying in a new copy of the page object.
for objIndex in xrange(len(self._objects)):
obj = self._objects[objIndex]
if isinstance(obj, PageObject) and obj.indirectRef != None:
if isinstance(obj, PageObject) and obj.indirectRef is not None:
data = obj.indirectRef
if not externalReferenceMap.has_key(data.pdf):
externalReferenceMap[data.pdf] = {}
@ -340,7 +340,7 @@ class PdfFileWriter(object):
return data
else:
newobj = externMap.get(data.pdf, {}).get(data.generation, {}).get(data.idnum, None)
if newobj == None:
if newobj is None:
newobj = data.pdf.getObject(data)
self._objects.append(None) # placeholder
idnum = len(self._objects)
@ -426,7 +426,7 @@ class PdfFileReader(object):
# Stability: Added in v1.0, will exist for all v1.x releases.
# @return Returns an integer.
def getNumPages(self):
if self.flattenedPages == None:
if self.flattenedPages is None:
self._flatten()
return len(self.flattenedPages)
@ -445,7 +445,7 @@ class PdfFileReader(object):
def getPage(self, pageNumber):
## ensure that we're not trying to access an encrypted PDF
#assert not self.trailer.has_key("/Encrypt")
if self.flattenedPages == None:
if self.flattenedPages is None:
self._flatten()
return self.flattenedPages[pageNumber]
@ -465,7 +465,7 @@ class PdfFileReader(object):
# @return Returns a dict which maps names to {@link #Destination
# destinations}.
def getNamedDestinations(self, tree=None, retval=None):
if retval == None:
if retval is None:
retval = {}
catalog = self.trailer["/Root"]
@ -477,7 +477,7 @@ class PdfFileReader(object):
if names.has_key("/Dests"):
tree = names['/Dests']
if tree == None:
if tree is None:
return retval
if tree.has_key("/Kids"):
@ -493,7 +493,7 @@ class PdfFileReader(object):
if isinstance(val, DictionaryObject) and val.has_key('/D'):
val = val['/D']
dest = self._buildDestination(key, val)
if dest != None:
if dest is not None:
retval[key] = dest
return retval
@ -511,7 +511,7 @@ class PdfFileReader(object):
# Stability: Added in v1.10, will exist for all future v1.x releases.
# @return Returns a nested list of {@link #Destination destinations}.
def getOutlines(self, node=None, outlines=None):
if outlines == None:
if outlines is None:
outlines = []
catalog = self.trailer["/Root"]
@ -522,7 +522,7 @@ class PdfFileReader(object):
node = lines["/First"]
self._namedDests = self.getNamedDestinations()
if node == None:
if node is None:
return outlines
# see if there are any more outlines
@ -588,9 +588,9 @@ class PdfFileReader(object):
NameObject("/Resources"), NameObject("/MediaBox"),
NameObject("/CropBox"), NameObject("/Rotate")
)
if inherit == None:
if inherit is None:
inherit = dict()
if pages == None:
if pages is None:
self.flattenedPages = []
catalog = self.trailer["/Root"].getObject()
pages = catalog["/Pages"].getObject()
@ -616,7 +616,7 @@ class PdfFileReader(object):
def getObject(self, indirectReference):
retval = self.resolvedObjects.get(indirectReference.generation, {}).get(indirectReference.idnum, None)
if retval != None:
if retval is not None:
return retval
if indirectReference.generation == 0 and \
self.xref_objStm.has_key(indirectReference.idnum):
@ -959,10 +959,10 @@ def getRectangle(self, name, defaults):
retval = self.get(name)
if isinstance(retval, RectangleObject):
return retval
if retval == None:
if retval is None:
for d in defaults:
retval = self.get(d)
if retval != None:
if retval is not None:
break
if isinstance(retval, IndirectObject):
retval = self.pdf.getObject(retval)

View File

@ -66,7 +66,7 @@ class XmpInformation(PdfObject):
for desc in self.rdfRoot.getElementsByTagNameNS(RDF_NAMESPACE, "Description"):
if desc.getAttributeNS(RDF_NAMESPACE, "about") == aboutUri:
attr = desc.getAttributeNodeNS(namespace, name)
if attr != None:
if attr is not None:
yield attr
for element in desc.getElementsByTagNameNS(namespace, name):
yield element
@ -187,7 +187,7 @@ class XmpInformation(PdfObject):
else:
value = self._getText(element)
break
if value != None:
if value is not None:
value = converter(value)
ns_cache = self.cache.setdefault(namespace, {})
ns_cache[name] = value
@ -353,5 +353,5 @@ class XmpInformation(PdfObject):
custom_properties = property(custom_properties)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,7 +28,7 @@ regex_t = re.compile('\(([0-9\.]*),([0-9\.]*),([0-9\.]*)\)')
regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])')
def get(col_str):
if col_str == None:
if col_str is None:
col_str = ''
global allcols
if col_str in allcols.keys():

View File

@ -220,7 +220,7 @@ class _flowable(object):
def rec_render(self,node):
""" Recursive render: fill outarr with text of current node
"""
if node.tag != None:
if node.tag is not None:
if node.tag in self._tags:
self._tags[node.tag](node)
else:

View File

@ -77,7 +77,7 @@ class LRU(object):
@synchronized()
def __iter__(self):
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.me[1]
cur = cur2
@ -89,7 +89,7 @@ class LRU(object):
@synchronized()
def iteritems(self):
cur = self.first
while cur != None:
while cur is not None:
cur2 = cur.next
yield cur.me
cur = cur2