Skip to content

Commit

Permalink
general cleanup from stefan, != None must be is not None etc.
Browse files Browse the repository at this point in the history
git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@785 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information
lkcl committed Jul 5, 2009
1 parent 42e7746 commit 7b39338
Show file tree
Hide file tree
Showing 58 changed files with 184 additions and 178 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,9 @@
Changes made to Pyjamas since 0.5p1 Changes made to Pyjamas since 0.5p1
----------------------------------- -----------------------------------


* Patch from Stefan Schwarzer to replace != None with is not None
and == None with is None, general clean-up.

* Got SVG 2D Canvas addonsgallery example working under Pyjamas-Desktop * Got SVG 2D Canvas addonsgallery example working under Pyjamas-Desktop
(Gecko Engine). Requires a patch to XulRunner, for drawImage to work: (Gecko Engine). Requires a patch to XulRunner, for drawImage to work:
https://bugzilla.mozilla.org/show_bug.cgi?id=502234 https://bugzilla.mozilla.org/show_bug.cgi?id=502234
Expand Down
2 changes: 1 addition & 1 deletion doc/book/public/ui_module.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ class TreeDemo(SimplePanel):
def createItem(self, label, value=None): def createItem(self, label, value=None):
item = TreeItem(label) item = TreeItem(label)
DOM.setStyleAttribute(item.getElement(), "cursor", "pointer") DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
if value != None: if value is not None:
item.setUserObject(value) item.setUserObject(value)
return item return item


Expand Down
6 changes: 3 additions & 3 deletions examples/infohierarchy/InfoDirectory.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class CollapserPanel(SimplePanel): class CollapserPanel(SimplePanel):
def __init__(self, sink): def __init__(self, sink):
SimplePanel.__init__(self) SimplePanel.__init__(self)
self.sink = sink self.sink = sink
self.caption = HTML() self.caption = HTML()
self.child = None self.child = None
self.showing = False self.showing = False
Expand Down Expand Up @@ -120,10 +120,10 @@ def doDetachChildren(self):
self.caption.onDetach() self.caption.onDetach()


def setWidget(self, widget): def setWidget(self, widget):
if self.child != None: if self.child is not None:
self.panel.remove(self.child) self.panel.remove(self.child)


if widget != None: if widget is not None:
self.panel.setWidget(1, 0, widget) self.panel.setWidget(1, 0, widget)


self.child = widget self.child = widget
Expand Down
2 changes: 1 addition & 1 deletion examples/infohierarchy/Trees.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, text, children=None):
self.text = text self.text = text
self.root = '/' self.root = '/'


if children != None: if children is not None:
self.children = children self.children = children


def pathify(self): def pathify(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchensink/Trees.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, text, children=None):
self.item = None self.item = None
self.text = text self.text = text


if children != None: if children is not None:
self.children = children self.children = children




Expand Down
2 changes: 1 addition & 1 deletion examples/mail/MailList.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def selectRow(self, row):
# When a row (other than the first one, which is used as a header) is # When a row (other than the first one, which is used as a header) is
# selected, display its associated MailItem. # selected, display its associated MailItem.
item = MailItems().getMailItem(self.startIndex + row) item = MailItems().getMailItem(self.startIndex + row)
if (item == None): if item is None:
return return


self.styleRow(self.selectedRow, False) self.styleRow(self.selectedRow, False)
Expand Down
4 changes: 2 additions & 2 deletions examples/shell/Popups.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def doDetachChildren(self):
self.caption.onDetach() self.caption.onDetach()


def setWidget(self, widget): def setWidget(self, widget):
if self.child != None: if self.child is not None:
self.panel.remove(self.child) self.panel.remove(self.child)


if widget != None: if widget is not None:
self.panel.setWidget(1, 0, widget) self.panel.setWidget(1, 0, widget)


self.child = widget self.child = widget
Expand Down
8 changes: 4 additions & 4 deletions examples/showcase/pyColourize.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def Main():
except: except:
scheme = None scheme = None


if input == None: if input is None:
# if there was no input specified then we try to # if there was no input specified then we try to
# parse ourselves and do it in diffrent flavors. # parse ourselves and do it in diffrent flavors.
WebIt(sys.argv[0], '/MyDir/null', _Null, 1) WebIt(sys.argv[0], '/MyDir/null', _Null, 1)
Expand All @@ -263,7 +263,7 @@ def WebAll(sourcePath, outdir=None, colors=None, show=0):
# Then we need to colorize them with WebIt # Then we need to colorize them with WebIt
else: else:
fileList = WalkDir(sourcePath) fileList = WalkDir(sourcePath)
if fileList != None: if fileList is not None:
for i in fileList: for i in fileList:
c+=1 c+=1
WebIt(i, outdir, colors, show) WebIt(i, outdir, colors, show)
Expand All @@ -273,11 +273,11 @@ def WebIt(sourcePath, outdir=None, colors=None, show=0):
''' Converts python source to html. ''' Converts python source to html.
''' '''
print" Converting %s into HTML" % sourcePath print" Converting %s into HTML" % sourcePath
if colors == None: if colors is None:
# Default colorscheme # Default colorscheme
colors = _Dark colors = _Dark
# If no outdir is given we use the sourcePath # If no outdir is given we use the sourcePath
if outdir == None: if outdir is None:
htmlPath = sourcePath + '.html' htmlPath = sourcePath + '.html'
else: else:
# If we do give an outdir, and it does # If we do give an outdir, and it does
Expand Down
6 changes: 3 additions & 3 deletions examples/showcase/src/Showcase.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def onTreeItemSelected(self, item):
""" Respond to the user selecting an item in our tree. """ Respond to the user selecting an item in our tree.
""" """
demo = item.getUserObject() demo = item.getUserObject()
if demo == None: if demo is None:
self.showDemo(None) self.showDemo(None)
else: else:
self.showDemo(demo['name']) self.showDemo(demo['name'])
Expand All @@ -154,7 +154,7 @@ def onTreeItemStateChanged(self, item):
def showDemo(self, name): def showDemo(self, name):
""" Show the demonstration with the given name. """ Show the demonstration with the given name.
""" """
if self._curContents != None: if self._curContents is not None:
self._rightPanel.remove(self._curContents) self._rightPanel.remove(self._curContents)
self._curContents = None self._curContents = None


Expand All @@ -164,7 +164,7 @@ def showDemo(self, name):
demo = d demo = d
break break


if demo != None: if demo is not None:
exampleID = HTMLPanel.createUniqueId() exampleID = HTMLPanel.createUniqueId()


html = [] html = []
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/demos_widgets/tree.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self):
def createItem(self, label, value=None): def createItem(self, label, value=None):
item = TreeItem(label) item = TreeItem(label)
DOM.setStyleAttribute(item.getElement(), "cursor", "pointer") DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
if value != None: if value is not None:
item.setUserObject(value) item.setUserObject(value)
return item return item


Expand Down
8 changes: 4 additions & 4 deletions examples/showcase/src/uiHelpers.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ def indent(contents, all=None, left=None, right=None, top=None, bottom=None,
Upon completion, we return a Panel object contained the wrapped-up Upon completion, we return a Panel object contained the wrapped-up
contents. contents.
""" """
if all != None: if all is not None:
left = all left = all
right = all right = all
top = all top = all
bottom = all bottom = all


if hIndent != None: if hIndent is not None:
left = hIndent left = hIndent
right = hIndent right = hIndent


if vIndent != None: if vIndent is not None:
top = vIndent top = vIndent
bottom = vIndent bottom = vIndent


Expand Down Expand Up @@ -198,7 +198,7 @@ def showPanel(self, panelID):
""" """
if panelID == self._curPanelID: return if panelID == self._curPanelID: return


if self._curPanelID != None: if self._curPanelID is not None:
self._root.remove(self._panels[self._curPanelID]) self._root.remove(self._panels[self._curPanelID])


self._root.add(self._panels[panelID]) self._root.add(self._panels[panelID])
Expand Down
4 changes: 2 additions & 2 deletions library/browser.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


class Element: class Element:
def __init__(self, tag=None, element=None): def __init__(self, tag=None, element=None):
if tag != None: if tag is not None:
JS(''' JS('''
this.element = $doc.createElement(tag); this.element = $doc.createElement(tag);
''') ''')
elif element != None: elif element is not None:
self.element = element self.element = element
else: else:
raise Exception("Cannot create Element without tag or element") raise Exception("Cannot create Element without tag or element")
Expand Down
14 changes: 8 additions & 6 deletions library/gtk.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
HAS_DEFAULT = 1024 HAS_DEFAULT = 1024
HAS_GRAB = 2048 HAS_GRAB = 2048
RC_STYLE = 4096 RC_STYLE = 4096
COMPOSITE_CHILD = 8192 COMPOSITE_CHILD = 8192
NO_REPARENT = 16384 NO_REPARENT = 16384
APP_PAINTABLE = 32768 APP_PAINTABLE = 32768
RECEIVES_DEFAULT = 65536 RECEIVES_DEFAULT = 65536
Expand All @@ -42,6 +42,7 @@
POS_TOP = 4 POS_TOP = 4
POS_BOTTOM = 8 POS_BOTTOM = 8



class GObject: class GObject:
def __init__(self): def __init__(self):
self.callbacks = {} self.callbacks = {}
Expand Down Expand Up @@ -402,7 +403,7 @@ def __init__(self, label=None):
Bin.__init__(self) Bin.__init__(self)
self.widget_cont.catchEvents(['click'], self) self.widget_cont.catchEvents(['click'], self)
self.child = None self.child = None
if label != None: if label is not None:
self.add(Label(label)) self.add(Label(label))


self.widget_int.setStyle('textAlign','center') self.widget_int.setStyle('textAlign','center')
Expand Down Expand Up @@ -480,7 +481,7 @@ def __init__(self, label=None):
self.box.pack_start(self.check_widget, False) self.box.pack_start(self.check_widget, False)
self.add(self.box) self.add(self.box)


if label!=None: if label is not None:
self.label = Label(label) self.label = Label(label)
self.box.pack_start(self.label, False) self.box.pack_start(self.label, False)
self.widget_int.setProperty('className','checkbutton') self.widget_int.setProperty('className','checkbutton')
Expand Down Expand Up @@ -512,7 +513,7 @@ class RadioButton(CheckButton):
def __init__(self, group=None, label=None): def __init__(self, group=None, label=None):
CheckButton.__init__(self, label) CheckButton.__init__(self, label)
self.check.setProperty('type','radio') self.check.setProperty('type','radio')
if group==None: if group is None:
self.group = RadioButton.counter self.group = RadioButton.counter
RadioButton.counter += 1 RadioButton.counter += 1
RadioButton.groups[self.group] = [self] RadioButton.groups[self.group] = [self]
Expand Down Expand Up @@ -567,6 +568,7 @@ def _redraw(self):
self.minwidth = self.img.getWidth() self.minwidth = self.img.getWidth()
self.minheight = self.img.getHeight() self.minheight = self.img.getHeight()



class Label(Misc): class Label(Misc):


def __init__(self, str=None): def __init__(self, str=None):
Expand Down Expand Up @@ -642,7 +644,7 @@ def __init__(self, adjustment=None):
self.value = browser.Element('div') self.value = browser.Element('div')
self.value.setStyle('position', 'absolute') self.value.setStyle('position', 'absolute')
self.widget_cont.append(self.value) self.widget_cont.append(self.value)
if adjustment!=None: if adjustment is not None:
self.adjustment = adjustment self.adjustment = adjustment
else: else:
self.adjustment = Adjustment() self.adjustment = Adjustment()
Expand Down Expand Up @@ -1129,7 +1131,7 @@ def _clicked(self, elem, data=None):


def _selected(self, elem, data=None): def _selected(self, elem, data=None):
act = self.menu.get_active() act = self.menu.get_active()
if act!=None: if act is not None:
self.label.set_text(act.label_cont) self.label.set_text(act.label_cont)


def set_menu(self, menu): def set_menu(self, menu):
Expand Down
2 changes: 1 addition & 1 deletion library/pyjamas/DOM.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def eventGetCurrentEvent():
def insertListItem(select, item, value, index): def insertListItem(select, item, value, index):
option = createElement("OPTION") option = createElement("OPTION")
setInnerText(option, item) setInnerText(option, item)
if value != None: if value is not None:
setAttribute(option, "value", value) setAttribute(option, "value", value)
if index == -1: if index == -1:
appendChild(select, option) appendChild(select, option)
Expand Down
2 changes: 1 addition & 1 deletion library/pyjamas/DeferredCommand.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def flushDeferredCommands(self):
current = deferredCommands[0] current = deferredCommands[0]
del deferredCommands[0] del deferredCommands[0]


if current == None: if current is None:
return return
else: else:
current.execute() current.execute()
Expand Down
4 changes: 2 additions & 2 deletions library/pyjamas/HTTPRequest.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
class HTTPRequest: class HTTPRequest:
# also callable as: asyncPost(self, url, postData, handler) # also callable as: asyncPost(self, url, postData, handler)
def asyncPost(self, user, pwd, url, postData=None, handler=None): def asyncPost(self, user, pwd, url, postData=None, handler=None):
if postData == None: if postData is None:
return self.asyncPostImpl(None, None, user, pwd, url) return self.asyncPostImpl(None, None, user, pwd, url)
return self.asyncPostImpl(user, pwd, url, postData, handler) return self.asyncPostImpl(user, pwd, url, postData, handler)


# also callable as: asyncGet(self, url, handler) # also callable as: asyncGet(self, url, handler)
def asyncGet(self, user, pwd, url, handler): def asyncGet(self, user, pwd, url, handler):
if url == None: if url is None:
return self.asyncGetImpl(None, None, user, pwd) return self.asyncGetImpl(None, None, user, pwd)
return self.asyncGetImpl(user, pwd, url, handler) return self.asyncGetImpl(user, pwd, url, handler)


Expand Down
8 changes: 4 additions & 4 deletions library/pyjamas/JSONService.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


# no stream support # no stream support
class JSONService: class JSONService:
def __init__(self, url, handler = None): def __init__(self, url, handler=None):
""" """
Create a JSON remote service object. The url is the URL that will receive Create a JSON remote service object. The url is the URL that will receive
POST data with the JSON request. See the JSON-RPC spec for more information. POST data with the JSON request. See the JSON-RPC spec for more information.
Expand All @@ -28,10 +28,10 @@ def __init__(self, url, handler = None):
self.handler = handler self.handler = handler


def callMethod(self, method, params, handler = None): def callMethod(self, method, params, handler = None):
if handler == None: if handler is None:
handler = self.handler handler = self.handler


if handler == None: if handler is None:
return self.__sendNotify(method, params) return self.__sendNotify(method, params)
else: else:
return self.__sendRequest(method, params, handler) return self.__sendRequest(method, params, handler)
Expand All @@ -40,7 +40,7 @@ def onCompletion(self):
pass pass


def sendNotify(self, method, params): def sendNotify(self, method, params):
msg = {"id":None, "method":method, "params":params} msg = {"id": None, "method": method, "params": params}
msg_data = dumps(msg) msg_data = dumps(msg)
if not HTTPRequest().asyncPost(self.url, msg_data, self): if not HTTPRequest().asyncPost(self.url, msg_data, self):
return -1 return -1
Expand Down
2 changes: 1 addition & 1 deletion library/pyjamas/Window.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def fireClosingImpl():
ret = None ret = None
for listener in closingListeners: for listener in closingListeners:
msg = listener.onWindowClosing() msg = listener.onWindowClosing()
if ret == None: if ret is None:
ret = msg ret = msg
return ret return ret


Expand Down
2 changes: 1 addition & 1 deletion library/pyjamas/platform/DOMPyJS.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ def eventGetCurrentEvent():
def insertListItem(select, item, value, index): def insertListItem(select, item, value, index):
option = createElement("OPTION") option = createElement("OPTION")
setInnerText(option, item) setInnerText(option, item)
if value != None: if value is not None:
setAttribute(option, "value", value) setAttribute(option, "value", value)
if index == -1: if index == -1:
appendChild(select, option) appendChild(select, option)
Expand Down
4 changes: 2 additions & 2 deletions library/pyjamas/platform/HTTPRequestPyJS.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ class HTTPRequest:
# also callable as: asyncPost(self, url, postData, handler) # also callable as: asyncPost(self, url, postData, handler)
def asyncPost(self, user, pwd, url, postData=None, handler=None, def asyncPost(self, user, pwd, url, postData=None, handler=None,
returnxml=0): returnxml=0):
if postData == None: if postData is None:
return self.asyncPostImpl(None, None, user, pwd, url, returnxml) return self.asyncPostImpl(None, None, user, pwd, url, returnxml)
return self.asyncPostImpl(user, pwd, url, postData, handler, returnxml) return self.asyncPostImpl(user, pwd, url, postData, handler, returnxml)


# also callable as: asyncGet(self, url, handler) # also callable as: asyncGet(self, url, handler)
def asyncGet(self, user, pwd, url, handler, returnxml=0): def asyncGet(self, user, pwd, url, handler, returnxml=0):
if url == None: if url is None:
return self.asyncGetImpl(None, None, user, pwd, returnxml) return self.asyncGetImpl(None, None, user, pwd, returnxml)
return self.asyncGetImpl(user, pwd, url, handler, returnxml) return self.asyncGetImpl(user, pwd, url, handler, returnxml)


Expand Down
4 changes: 2 additions & 2 deletions library/pyjamas/platform/JSONServicePyJS.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def __init__(self, url, handler = None):
self.handler = handler self.handler = handler


def callMethod(self, method, params, handler = None): def callMethod(self, method, params, handler = None):
if handler == None: if handler is None:
handler = self.handler handler = self.handler


if handler == None: if handler is None:
return self.__sendNotify(method, params) return self.__sendNotify(method, params)
else: else:
return self.__sendRequest(method, params, handler) return self.__sendRequest(method, params, handler)
Expand Down
2 changes: 1 addition & 1 deletion library/pyjamas/ui/AbsolutePanel.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):
def add(self, widget, left=None, top=None): def add(self, widget, left=None, top=None):
ComplexPanel.add(self, widget, self.getElement()) ComplexPanel.add(self, widget, self.getElement())


if left != None: if left is not None:
self.setWidgetPosition(widget, left, top) self.setWidgetPosition(widget, left, top)


def setWidgetPosition(self, widget, left, top): def setWidgetPosition(self, widget, left, top):
Expand Down
4 changes: 2 additions & 2 deletions library/pyjamas/ui/AutoComplete.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def complete(self):


class SimpleAutoCompletionItems: class SimpleAutoCompletionItems:
def __init__(self, items = None): def __init__(self, items = None):
if items == None: if items is None:
items = [] items = []
self.completions = items self.completions = items


def getCompletionItems(self, match): def getCompletionItems(self, match):
matches = [] matches = []
match = match.lower() match = match.lower()


for i in range(len(self.completions)): for i in range(len(self.completions)):
Expand Down
Loading

0 comments on commit 7b39338

Please sign in to comment.