[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 return res
def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None): def _get_full_name(self, cr, uid, ids, name=None, args=None, context=None):
if context == None: if context is None:
context = {} context = {}
res = {} res = {}
for elmt in self.browse(cr, uid, ids, context=context): for elmt in self.browse(cr, uid, ids, context=context):

View File

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

View File

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

View File

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

View File

@ -81,7 +81,7 @@ def readObject(stream, pdf):
return NumberObject.readFromStream(stream) return NumberObject.readFromStream(stream)
peek = stream.read(20) peek = stream.read(20)
stream.seek(-len(peek), 1) # reset to start 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) return IndirectObject.readFromStream(stream, pdf)
else: else:
return NumberObject.readFromStream(stream) return NumberObject.readFromStream(stream)
@ -169,7 +169,7 @@ class IndirectObject(PdfObject):
def __eq__(self, other): def __eq__(self, other):
return ( return (
other != None and other is not None and
isinstance(other, IndirectObject) and isinstance(other, IndirectObject) and
self.idnum == other.idnum and self.idnum == other.idnum and
self.generation == other.generation 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. # return None if no metadata was found on the document root.
def getXmpMetadata(self): def getXmpMetadata(self):
metadata = self.get("/Metadata", None) metadata = self.get("/Metadata", None)
if metadata == None: if metadata is None:
return None return None
metadata = metadata.getObject() metadata = metadata.getObject()
import xmp import xmp

View File

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

View File

@ -66,7 +66,7 @@ class XmpInformation(PdfObject):
for desc in self.rdfRoot.getElementsByTagNameNS(RDF_NAMESPACE, "Description"): for desc in self.rdfRoot.getElementsByTagNameNS(RDF_NAMESPACE, "Description"):
if desc.getAttributeNS(RDF_NAMESPACE, "about") == aboutUri: if desc.getAttributeNS(RDF_NAMESPACE, "about") == aboutUri:
attr = desc.getAttributeNodeNS(namespace, name) attr = desc.getAttributeNodeNS(namespace, name)
if attr != None: if attr is not None:
yield attr yield attr
for element in desc.getElementsByTagNameNS(namespace, name): for element in desc.getElementsByTagNameNS(namespace, name):
yield element yield element
@ -187,7 +187,7 @@ class XmpInformation(PdfObject):
else: else:
value = self._getText(element) value = self._getText(element)
break break
if value != None: if value is not None:
value = converter(value) value = converter(value)
ns_cache = self.cache.setdefault(namespace, {}) ns_cache = self.cache.setdefault(namespace, {})
ns_cache[name] = value ns_cache[name] = value
@ -353,5 +353,5 @@ class XmpInformation(PdfObject):
custom_properties = property(custom_properties) 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])') 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): def get(col_str):
if col_str == None: if col_str is None:
col_str = '' col_str = ''
global allcols global allcols
if col_str in allcols.keys(): if col_str in allcols.keys():

View File

@ -220,7 +220,7 @@ class _flowable(object):
def rec_render(self,node): def rec_render(self,node):
""" Recursive render: fill outarr with text of current 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: if node.tag in self._tags:
self._tags[node.tag](node) self._tags[node.tag](node)
else: else:

View File

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