[Nym3-commit] r478 - trunk/nymbaron/Server

laurent at conuropsis.org laurent at conuropsis.org
Wed Mar 15 22:28:38 CET 2006


Author: laurent
Date: 2006-03-15 22:28:37 +0100 (Wed, 15 Mar 2006)
New Revision: 478

Modified:
   trunk/nymbaron/Server/Main.py
Log:
Style, see PEP-8 for details.
if foo == 'bar': Correct.
if (foo == 'bar'): Wrong.
if(foo=='bar'): So Very Wrong.


Modified: trunk/nymbaron/Server/Main.py
===================================================================
--- trunk/nymbaron/Server/Main.py	2006-03-15 21:21:29 UTC (rev 477)
+++ trunk/nymbaron/Server/Main.py	2006-03-15 21:28:37 UTC (rev 478)
@@ -89,7 +89,7 @@
         except OSError:
             config = Config.Config()
 
-def mapAccount(fun, funargs = None):
+def mapAccount(fun, funargs=None):
     """Applies the function fun to each account of the server. The signature of
     fun is: fun(account[, tuple of arguments specific to fun]), returns nothing
     """
@@ -131,7 +131,7 @@
     sr = Message.StrReader(msg)
     try:
         h = sr.readHeader()
-        if (h.nym == ""):
+        if h.nym == "":
             comList = sr.readCommandCToSList()
             try:
                 if (len(comList) != 3):
@@ -144,7 +144,7 @@
                 mdgst = _cr.sha1(msg)
                 #phase 1 we look for the command create
                 for idx, com in enumerate(comList):
-                    if(com.ct() == 0): # TODO : evil numeric litteral
+                    if com.ct() == 0: # TODO : evil numeric litteral
                         #the Create command
                         for pnym in com.list:
                             try:
@@ -167,16 +167,16 @@
                                     #it doesn't: we clean and continue
                                     del nymUser
                                     nymUser = None
-                            if nymUser != None:
+                            if nymUser is not None:
                                 break
-                        if (nymUser == None):
+                        if nymUser is None:
                             #TODO send an Error message to the client when surbs become available?
                             #for the time being just ignore
                             logger.info("All nyms proposed in the list were already attributed")
                             raise MalformedControlMessage()
                         del comList[idx]
                         break
-                if (nymUser == None):
+                if nymUser is None:
                     #TODO send an Error message to the client when surbs become available?
                     #for the time being just ignore
                     logger.info("No Create Command")
@@ -184,7 +184,7 @@
                         
                 #phase 2 we look for the command surb
                 for idx, com in enumerate(comList):
-                    if(com.ct()==2): # TODO : evil numeric litteral
+                    if com.ct() == 2: # TODO : evil numeric litteral
                         nymUser.addSurbs(com.surbs)
                         if nymUser['nSurbs'] < 3:
                             logger.info("Not Enough Surbs")
@@ -234,26 +234,26 @@
             nymUser.received(h.seqNo)
             comList = sr.readCommandCToSList()
             for com in comList:
-                if (com.ct() == Message.CToSCODE['Create']):
+                if com.ct() == Message.CToSCODE['Create']:
                     #we ignore the Create command if it comes from the nymholder of an account, should we rise an error?
                     pass
                 #if the account is not initialized, or if it is already up we ignore Create2 messages
-                elif (com.ct() == Message.CToSCODE['Create2']):
+                elif com.ct() == Message.CToSCODE['Create2']:
                     #for the time being we forget about CREATE2 messages
                     pass
                     #if not nymUser.isUp():
                 #       if(nymUser.checkChallenge(com.cr)):
                 #           nymUser.setUp()
                 #other commands are only taken into account if the account is up
-                elif (nymUser.isUp()):
-                    if (com.ct() == Message.CToSCODE['Surb']):
-                        if (len(com.surbs) == 0):
+                elif nymUser.isUp():
+                    if com.ct() == Message.CToSCODE['Surb']:
+                        if len(com.surbs) == 0:
                             nymUser.delSurbs()
                         else:
                             nymUser.addSurbs(com.surbs)
-                    elif (com.ct() == Message.CToSCODE['Newpk']):
+                    elif com.ct() == Message.CToSCODE['Newpk']:
                         nymUser.setKeys(com.kid, com.kenc)
-                    elif (com.ct() == Message.CToSCODE['Relay']):
+                    elif com.ct() == Message.CToSCODE['Relay']:
 #                        ec = Mail.relay(h.nym, com.rt, com.ri,
 #                                        config.serverName, com.body)
 #                        if (ec != 0):
@@ -272,9 +272,8 @@
                         else:
                             logger.error('Unsupported relay option %s specified' % config.relay_method)
                             sys.exit(2)
-
                             
-                    elif (com.ct() == Message.CToSCODE['Get']):
+                    elif com.ct() == Message.CToSCODE['Get']:
                         msgList = []
                         sendList = []
                         for m in com.l:
@@ -286,16 +285,16 @@
                         ec = nymUser.advanced_send(
                                 Message.buildMessage(msgList))
                         logger.debug("EC is " + str(ec))
-                        if (ec == 0):
+                        if ec == 0:
                             nymUser.markMid(sendList, lifeCycle['sent-in-full'])
-                            if(nymUser['HoldUntilAck'] == 'never'):
+                            if nymUser['HoldUntilAck'] == 'never':
                                 map(nymUser.delete_msg, sendList)
                             
                         else:
                             logger.error("mixminion exited abnormally with error code %d" % ec)
                             sys.exit(2)
                                 
-                    elif (com.ct() == Message.CToSCODE['Summarize']):
+                    elif com.ct() == Message.CToSCODE['Summarize']:
                         comList = []
                         sendList = nymUser.prepareSummary(com.num, com.after)
                         mList = []
@@ -310,16 +309,16 @@
                             sumCom.fromData("\x00\x00","")
                             comList = [sumCom]
                         ec = nymUser.send(Message.buildMessage(comList))
-                        if (ec == 0):
+                        if ec == 0:
                             nymUser.markMid(mList, lifeCycle['synopsis-sent'])
                         else:
                             logger.error("mixminion exited abnormally with error code %d" % ec)
                             sys.exit(2)
 
-                    elif (com.ct() == Message.CToSCODE['Delete']):
+                    elif com.ct() == Message.CToSCODE['Delete']:
                         for mid in com.l:
                             nymUser.delete_msg(mid)
-                    elif (com.ct() == Message.CToSCODE['Policy']):
+                    elif com.ct() == Message.CToSCODE['Policy']:
                         if(com.opt in Common.userPolicy):
                             nymUser[com.opt] = com.val
                     else:



More information about the Nym3-commit mailing list