Commits

Alfonso de la Guarda Reyes  committed a1a429f

Coding Styles Changes

  • Participants
  • Parent commits 5baca24

Comments (0)

Files changed (15)

 *.brn
 .hg/*
 .hgignore
+.idea/*
 chatbot_settings.xml
 cache/*
 errors/*

File .idea/cssxfire.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CssXFireSettings">
+    <general autoClear="false" autoExpand="false" />
+    <strategy useRoutes="false" mediaReduce="false" fileReduce="false" currentDocumentsReduce="false" resolveVariables="true" resolveMixins="true" />
+    <routes />
+  </component>
+</project>
+

File .idea/encodings.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+

File .idea/inspectionProfiles/Project_Default.xml

+<component name="InspectionProjectProfileManager">
+  <profile version="1.0" is_locked="false">
+    <option name="myName" value="Project Default" />
+    <option name="myLocal" value="false" />
+    <inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
+    <inspection_tool class="JSLint" enabled="true" level="ERROR" enabled_by_default="true" />
+  </profile>
+</component>

File .idea/inspectionProfiles/profiles_settings.xml

+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="PROJECT_PROFILE" />
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

File .idea/libraries/sass_stdlib.xml

+<component name="libraryTable">
+  <library name="sass-stdlib">
+    <CLASSES />
+    <SOURCES>
+      <root url="file://$APPLICATION_HOME_DIR$/plugins/sass/lib/stubs/sass_functions.scss" />
+    </SOURCES>
+  </library>
+</component>

File .idea/misc.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="DBNavigator.Project.ConnectionManager">
+    <connections />
+  </component>
+  <component name="DBNavigator.Project.DataEditorManager">
+    <record-view-column-sorting-type value="BY_INDEX" />
+    <value-preview-text-wrapping value="true" />
+    <value-preview-pinned value="false" />
+  </component>
+  <component name="DBNavigator.Project.DataExportManager">
+    <export-instructions>
+      <create-header value="true" />
+      <quote-values-containing-separator value="true" />
+      <quote-all-values value="false" />
+      <value-separator value="" />
+      <file-name value="" />
+      <file-location value="" />
+      <scope value="GLOBAL" />
+      <destination value="FILE" />
+      <format value="EXCEL" />
+    </export-instructions>
+  </component>
+  <component name="DBNavigator.Project.DatabaseBrowserManager">
+    <autoscroll-to-editor value="false" />
+    <autoscroll-from-editor value="true" />
+    <show-object-properties value="true" />
+  </component>
+  <component name="DBNavigator.Project.MethodExecutionManager">
+    <group-history-entries value="false" />
+    <method-browser />
+    <execution-inputs />
+  </component>
+  <component name="DBNavigator.Project.Settings">
+    <general-settings>
+      <regional-settings>
+        <date-format value="MEDIUM" />
+        <number-format value="UNGROUPED" />
+        <locale value="SYSTEM_DEFAULT" />
+        <use-custom-formats value="false" />
+      </regional-settings>
+      <environment>
+        <environment-types>
+          <environment-type name="Development" description="Development environment" color="-2430209" />
+          <environment-type name="Test" description="Testing environment" color="-2621494" />
+          <environment-type name="Production" description="Productive environment" color="-11574" />
+          <environment-type name="Other" description="" color="-1576" />
+        </environment-types>
+        <visibility-settings>
+          <connection-tabs value="true" />
+          <dialog-headers value="true" />
+          <object-editor-tabs value="true" />
+          <script-editor-tabs value="false" />
+          <execution-result-tabs value="true" />
+        </visibility-settings>
+      </environment>
+    </general-settings>
+    <browser-settings>
+      <general>
+        <display-mode value="TABBED" />
+        <navigation-history-size value="100" />
+        <show-object-details value="false" />
+      </general>
+      <filters>
+        <object-type-filter>
+          <object-type name="SCHEMA" enabled="true" />
+          <object-type name="USER" enabled="true" />
+          <object-type name="ROLE" enabled="true" />
+          <object-type name="PRIVILEGE" enabled="true" />
+          <object-type name="CHARSET" enabled="true" />
+          <object-type name="TABLE" enabled="true" />
+          <object-type name="VIEW" enabled="true" />
+          <object-type name="MATERIALIZED VIEW" enabled="true" />
+          <object-type name="NESTED TABLE" enabled="true" />
+          <object-type name="COLUMN" enabled="true" />
+          <object-type name="INDEX" enabled="true" />
+          <object-type name="CONSTRAINT" enabled="true" />
+          <object-type name="TRIGGER" enabled="true" />
+          <object-type name="SYNONYM" enabled="true" />
+          <object-type name="SEQUENCE" enabled="true" />
+          <object-type name="PROCEDURE" enabled="true" />
+          <object-type name="FUNCTION" enabled="true" />
+          <object-type name="PACKAGE" enabled="true" />
+          <object-type name="TYPE" enabled="true" />
+          <object-type name="TYPE ATTRIBUTE" enabled="true" />
+          <object-type name="ARGUMENT" enabled="true" />
+          <object-type name="DIMENSION" enabled="true" />
+          <object-type name="CLUSTER" enabled="true" />
+          <object-type name="DBLINK" enabled="true" />
+        </object-type-filter>
+      </filters>
+    </browser-settings>
+    <navigation-settings>
+      <lookup-filters>
+        <lookup-objects>
+          <object-type name="SCHEMA" enabled="true" />
+          <object-type name="USER" enabled="false" />
+          <object-type name="ROLE" enabled="false" />
+          <object-type name="PRIVILEGE" enabled="false" />
+          <object-type name="CHARSET" enabled="false" />
+          <object-type name="TABLE" enabled="true" />
+          <object-type name="VIEW" enabled="true" />
+          <object-type name="MATERIALIZED VIEW" enabled="true" />
+          <object-type name="NESTED TABLE" enabled="false" />
+          <object-type name="COLUMN" enabled="false" />
+          <object-type name="INDEX" enabled="true" />
+          <object-type name="CONSTRAINT" enabled="true" />
+          <object-type name="TRIGGER" enabled="true" />
+          <object-type name="SYNONYM" enabled="false" />
+          <object-type name="SEQUENCE" enabled="true" />
+          <object-type name="PROCEDURE" enabled="true" />
+          <object-type name="FUNCTION" enabled="true" />
+          <object-type name="PACKAGE" enabled="true" />
+          <object-type name="TYPE" enabled="true" />
+          <object-type name="TYPE ATTRIBUTE" enabled="false" />
+          <object-type name="ARGUMENT" enabled="false" />
+          <object-type name="DIMENSION" enabled="false" />
+          <object-type name="CLUSTER" enabled="false" />
+          <object-type name="DBLINK" enabled="true" />
+        </lookup-objects>
+        <force-database-load value="false" />
+        <prompt-connection-selection value="true" />
+      </lookup-filters>
+    </navigation-settings>
+    <dataset-editor-settings>
+      <text-editor-popup>
+        <active value="false" />
+        <active-if-empty value="false" />
+        <data-length-threshold value="100" />
+        <popup-delay value="1000" />
+      </text-editor-popup>
+      <values-list-popup>
+        <active-for-primary-keys value="false" />
+        <element-count-threshold value="1000" />
+        <data-length-threshold value="250" />
+      </values-list-popup>
+      <general>
+        <fetch-block-size value="100" />
+        <fetch-timeout value="30" />
+        <trim-whitespaces value="true" />
+        <convert-empty-strings-to-null value="true" />
+        <select-content-on-cell-edit value="true" />
+        <large-value-preview-active value="true" />
+      </general>
+      <filters>
+        <prompt-filter-dialog value="true" />
+        <default-filter-type value="BASIC" />
+      </filters>
+      <qualified-text-editor text-length-threshold="300">
+        <content-types>
+          <content-type name="Text" enabled="true" />
+          <content-type name="XML" enabled="true" />
+          <content-type name="DTD" enabled="true" />
+          <content-type name="HTML" enabled="true" />
+          <content-type name="XHTML" enabled="true" />
+          <content-type name="CSS" enabled="true" />
+          <content-type name="SQL" enabled="true" />
+          <content-type name="PL/SQL" enabled="true" />
+          <content-type name="JavaScript" enabled="true" />
+          <content-type name="YAML" enabled="true" />
+        </content-types>
+      </qualified-text-editor>
+      <record-navigation>
+        <navigation-target value="VIEWER" />
+      </record-navigation>
+    </dataset-editor-settings>
+    <code-completion-settings>
+      <filters>
+        <basic-filter>
+          <filter-element type="RESERVED_WORD" id="keyword" selected="true" />
+          <filter-element type="RESERVED_WORD" id="function" selected="false" />
+          <filter-element type="RESERVED_WORD" id="parameter" selected="false" />
+          <filter-element type="RESERVED_WORD" id="datatype" selected="true" />
+          <filter-element type="OBJECT" id="schema" selected="true" />
+          <filter-element type="OBJECT" id="user" selected="true" />
+          <user-schema>
+            <filter-element type="OBJECT" id="table" selected="true" />
+            <filter-element type="OBJECT" id="view" selected="true" />
+            <filter-element type="OBJECT" id="materialized view" selected="true" />
+            <filter-element type="OBJECT" id="index" selected="true" />
+            <filter-element type="OBJECT" id="constraint" selected="true" />
+            <filter-element type="OBJECT" id="trigger" selected="true" />
+            <filter-element type="OBJECT" id="synonym" selected="false" />
+            <filter-element type="OBJECT" id="sequence" selected="true" />
+            <filter-element type="OBJECT" id="procedure" selected="true" />
+            <filter-element type="OBJECT" id="function" selected="true" />
+            <filter-element type="OBJECT" id="package" selected="true" />
+            <filter-element type="OBJECT" id="type" selected="true" />
+            <filter-element type="OBJECT" id="dimension" selected="true" />
+            <filter-element type="OBJECT" id="cluster" selected="true" />
+            <filter-element type="OBJECT" id="dblink" selected="true" />
+          </user-schema>
+          <public-schema>
+            <filter-element type="OBJECT" id="table" selected="false" />
+            <filter-element type="OBJECT" id="view" selected="false" />
+            <filter-element type="OBJECT" id="materialized view" selected="false" />
+            <filter-element type="OBJECT" id="index" selected="false" />
+            <filter-element type="OBJECT" id="constraint" selected="false" />
+            <filter-element type="OBJECT" id="trigger" selected="false" />
+            <filter-element type="OBJECT" id="synonym" selected="false" />
+            <filter-element type="OBJECT" id="sequence" selected="false" />
+            <filter-element type="OBJECT" id="procedure" selected="false" />
+            <filter-element type="OBJECT" id="function" selected="false" />
+            <filter-element type="OBJECT" id="package" selected="false" />
+            <filter-element type="OBJECT" id="type" selected="false" />
+            <filter-element type="OBJECT" id="dimension" selected="false" />
+            <filter-element type="OBJECT" id="cluster" selected="false" />
+            <filter-element type="OBJECT" id="dblink" selected="false" />
+          </public-schema>
+          <any-schema>
+            <filter-element type="OBJECT" id="table" selected="true" />
+            <filter-element type="OBJECT" id="view" selected="true" />
+            <filter-element type="OBJECT" id="materialized view" selected="true" />
+            <filter-element type="OBJECT" id="index" selected="true" />
+            <filter-element type="OBJECT" id="constraint" selected="true" />
+            <filter-element type="OBJECT" id="trigger" selected="true" />
+            <filter-element type="OBJECT" id="synonym" selected="true" />
+            <filter-element type="OBJECT" id="sequence" selected="true" />
+            <filter-element type="OBJECT" id="procedure" selected="true" />
+            <filter-element type="OBJECT" id="function" selected="true" />
+            <filter-element type="OBJECT" id="package" selected="true" />
+            <filter-element type="OBJECT" id="type" selected="true" />
+            <filter-element type="OBJECT" id="dimension" selected="true" />
+            <filter-element type="OBJECT" id="cluster" selected="true" />
+            <filter-element type="OBJECT" id="dblink" selected="true" />
+          </any-schema>
+        </basic-filter>
+        <extended-filter>
+          <filter-element type="RESERVED_WORD" id="keyword" selected="true" />
+          <filter-element type="RESERVED_WORD" id="function" selected="true" />
+          <filter-element type="RESERVED_WORD" id="parameter" selected="true" />
+          <filter-element type="RESERVED_WORD" id="datatype" selected="true" />
+          <filter-element type="OBJECT" id="schema" selected="true" />
+          <filter-element type="OBJECT" id="user" selected="true" />
+          <user-schema>
+            <filter-element type="OBJECT" id="table" selected="true" />
+            <filter-element type="OBJECT" id="view" selected="true" />
+            <filter-element type="OBJECT" id="materialized view" selected="true" />
+            <filter-element type="OBJECT" id="index" selected="true" />
+            <filter-element type="OBJECT" id="constraint" selected="true" />
+            <filter-element type="OBJECT" id="trigger" selected="true" />
+            <filter-element type="OBJECT" id="synonym" selected="true" />
+            <filter-element type="OBJECT" id="sequence" selected="true" />
+            <filter-element type="OBJECT" id="procedure" selected="true" />
+            <filter-element type="OBJECT" id="function" selected="true" />
+            <filter-element type="OBJECT" id="package" selected="true" />
+            <filter-element type="OBJECT" id="type" selected="true" />
+            <filter-element type="OBJECT" id="dimension" selected="true" />
+            <filter-element type="OBJECT" id="cluster" selected="true" />
+            <filter-element type="OBJECT" id="dblink" selected="true" />
+          </user-schema>
+          <public-schema>
+            <filter-element type="OBJECT" id="table" selected="true" />
+            <filter-element type="OBJECT" id="view" selected="true" />
+            <filter-element type="OBJECT" id="materialized view" selected="true" />
+            <filter-element type="OBJECT" id="index" selected="true" />
+            <filter-element type="OBJECT" id="constraint" selected="true" />
+            <filter-element type="OBJECT" id="trigger" selected="true" />
+            <filter-element type="OBJECT" id="synonym" selected="true" />
+            <filter-element type="OBJECT" id="sequence" selected="true" />
+            <filter-element type="OBJECT" id="procedure" selected="true" />
+            <filter-element type="OBJECT" id="function" selected="true" />
+            <filter-element type="OBJECT" id="package" selected="true" />
+            <filter-element type="OBJECT" id="type" selected="true" />
+            <filter-element type="OBJECT" id="dimension" selected="true" />
+            <filter-element type="OBJECT" id="cluster" selected="true" />
+            <filter-element type="OBJECT" id="dblink" selected="true" />
+          </public-schema>
+          <any-schema>
+            <filter-element type="OBJECT" id="table" selected="true" />
+            <filter-element type="OBJECT" id="view" selected="true" />
+            <filter-element type="OBJECT" id="materialized view" selected="true" />
+            <filter-element type="OBJECT" id="index" selected="true" />
+            <filter-element type="OBJECT" id="constraint" selected="true" />
+            <filter-element type="OBJECT" id="trigger" selected="true" />
+            <filter-element type="OBJECT" id="synonym" selected="true" />
+            <filter-element type="OBJECT" id="sequence" selected="true" />
+            <filter-element type="OBJECT" id="procedure" selected="true" />
+            <filter-element type="OBJECT" id="function" selected="true" />
+            <filter-element type="OBJECT" id="package" selected="true" />
+            <filter-element type="OBJECT" id="type" selected="true" />
+            <filter-element type="OBJECT" id="dimension" selected="true" />
+            <filter-element type="OBJECT" id="cluster" selected="true" />
+            <filter-element type="OBJECT" id="dblink" selected="true" />
+          </any-schema>
+        </extended-filter>
+      </filters>
+      <sorting enabled="true">
+        <sorting-element type="RESERVED_WORD" id="keyword" />
+        <sorting-element type="RESERVED_WORD" id="datatype" />
+        <sorting-element type="OBJECT" id="column" />
+        <sorting-element type="OBJECT" id="table" />
+        <sorting-element type="OBJECT" id="view" />
+        <sorting-element type="OBJECT" id="materialized view" />
+        <sorting-element type="OBJECT" id="index" />
+        <sorting-element type="OBJECT" id="constraint" />
+        <sorting-element type="OBJECT" id="trigger" />
+        <sorting-element type="OBJECT" id="synonym" />
+        <sorting-element type="OBJECT" id="sequence" />
+        <sorting-element type="OBJECT" id="procedure" />
+        <sorting-element type="OBJECT" id="function" />
+        <sorting-element type="OBJECT" id="package" />
+        <sorting-element type="OBJECT" id="type" />
+        <sorting-element type="OBJECT" id="dimension" />
+        <sorting-element type="OBJECT" id="cluster" />
+        <sorting-element type="OBJECT" id="dblink" />
+        <sorting-element type="OBJECT" id="schema" />
+        <sorting-element type="RESERVED_WORD" id="function" />
+        <sorting-element type="RESERVED_WORD" id="parameter" />
+      </sorting>
+    </code-completion-settings>
+    <execution-engine-settings>
+      <statement-execution>
+        <fetch-block-size value="100" />
+        <execution-timeout value="20" />
+      </statement-execution>
+      <compiler>
+        <compile-type value="KEEP" />
+        <always-show-controls value="false" />
+      </compiler>
+    </execution-engine-settings>
+    <ddl-file-settings>
+      <extensions>
+        <mapping file-type-id="VIEW" extensions="vw" />
+        <mapping file-type-id="TRIGGER" extensions="trg" />
+        <mapping file-type-id="PROCEDURE" extensions="prc" />
+        <mapping file-type-id="FUNCTION" extensions="fnc" />
+        <mapping file-type-id="PACKAGE" extensions="pkg" />
+        <mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
+        <mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
+        <mapping file-type-id="TYPE" extensions="tpe" />
+        <mapping file-type-id="TYPE_SPEC" extensions="tps" />
+        <mapping file-type-id="TYPE_BODY" extensions="tpb" />
+      </extensions>
+      <general>
+        <statement-postfix value="/" />
+        <lookup-ddl-files value="true" />
+        <create-ddl-files value="false" />
+      </general>
+    </ddl-file-settings>
+  </component>
+  <component name="JSHintConfiguration">
+    <option bitwise="true" />
+    <option curly="true" />
+    <option eqeqeq="true" />
+    <option forin="true" />
+    <option noarg="true" />
+    <option noempty="true" />
+    <option nonew="true" />
+    <option strict="true" />
+    <option undef="true" />
+    <option browser="true" />
+    <option maxerr="50" />
+  </component>
+  <component name="JSLintConfiguration">
+    <option indent="4" />
+    <option maxerr="50" />
+  </component>
+  <component name="ProjectDictionaryState">
+    <dictionary name="alfonsodg" />
+  </component>
+  <component name="ProjectInspectionProfilesVisibleTreeState">
+    <entry key="Project Default">
+      <profile-state>
+        <expanded-state>
+          <State>
+            <id />
+          </State>
+          <State>
+            <id>Spelling</id>
+          </State>
+        </expanded-state>
+        <selected-state>
+          <State>
+            <id>SQL</id>
+          </State>
+        </selected-state>
+      </profile-state>
+    </entry>
+  </component>
+  <component name="ProjectResources">
+    <default-html-doctype>$APPLICATION_HOME_DIR$/lib/pycharm.jar!/resources/html5-schema/html5.rnc</default-html-doctype>
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.3 (/usr/bin/python2.7)" project-jdk-type="Python SDK" />
+  <component name="PyConsoleOptionsProvider">
+    <option name="myPythonConsoleState">
+      <PyConsoleSettings>
+        <option name="myUseModuleSdk" value="true" />
+      </PyConsoleSettings>
+    </option>
+    <option name="myDjangoConsoleState">
+      <PyConsoleSettings />
+    </option>
+  </component>
+  <component name="UnicodeBrowser">
+    <option name="fontName" value="DejaVu Sans Mono" />
+  </component>
+</project>
+

File .idea/modules.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/sboty.iml" filepath="$PROJECT_DIR$/.idea/sboty.iml" />
+    </modules>
+  </component>
+</project>
+

File .idea/sboty.iml

+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="DBNavigator.Module.ConnectionManager">
+    <connections />
+  </component>
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+

File .idea/scopes/scope_settings.xml

+<component name="DependencyValidationManager">
+  <state>
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </state>
+</component>

File .idea/vcs.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>
+

File chatbot_gtalk_setup.py

         sys.exit(1)
 
     if CONRES != "tls":
-        print (
+        print(
             "Advertencia: no se puede estabilizar conexion segura - TLS fallo")
 
     AUTHRES = CONN.auth(chatbotini.LOGINGTALK.split("@")[0],
     chatbotini.connection_log("Autenticando\n", "gtalk")
 
     if not AUTHRES:
-        print ("No se puede autorizar en %s - comprobar " +
-               "nombre de usuario / contrasenia.") % chatbotini.SERVER
+        print("No se puede autorizar en %s - comprobar " +
+              "nombre de usuario / contrasenia.") % chatbotini.SERVER
 
         chatbotini.connection_log("Login/Password incorrectos\n", "gtalk")
         chatbotini.connection_log("Terminando\n\n\n", "gtalk")

File chatbot_msn_setup.py

                 if not newmsgs:
                     return
 
-                print ("\rYou have %s unread email(s)" +
-                       " in your Hotmail account") % str(newmsgs)
+                print("\rYou have %s unread email(s)" +
+                      " in your Hotmail account") % str(newmsgs)
 
             elif headers["Content-Type"] == ("text/" +
                                              "x-msmsgsemailnotification;" +
                 from_addr = hotmail_info["From-Addr"]
                 subject = hotmail_info["Subject"]
 
-                print ("\rYou have just received an email in your" +
-                       " Hotmail account:")
+                print("\rYou have just received an email in your" +
+                      " Hotmail account:")
                 print "\r\tFrom: %s (%s)" % (from_name, from_addr)
                 print "\r\tSubject: %s" % subject
             return
         """
         When the server disconnect us from MSN.
         """
-        print ("\rServer sent disconnect" +
-               " (probably you logged in somewhere else)")
+        print("\rServer sent disconnect" +
+              " (probably you logged in somewhere else)")
 
         USEF_FUNCT.quit()
         msncb.cb_out(md1, type, tid, params)
                 if comp != MSN:
                     if comp.msgqueue:
                         nick = USEF_FUNCT.emailtonick(comp.emails[0])
-                        print ("\rConnection with %s closed - the following" +
-                               "messages couldn't be sent:") % (nick)
+                        print("\rConnection with %s closed - the following" +
+                              "messages couldn't be sent:") % (nick)
 
                         for mssage in comp.msgqueue:
                             print "\t>>> %s" % mssage

File msn_lib/msncb.py

 # md5 is deprecated in favour of hashlib since python 2.5; hashlib was
 # introduced in python 2.5
 try:
-	from hashlib import md5
+    from hashlib import md5
 except:
-	from md5 import md5
+    from md5 import md5
 
 import msnlib
 
 the main connection object; you probably already know what it is.
 
 The models are:
-error: 		def cb_err(md, errno, params)
-server:		def cb_def(md, type, tid, params)
-switchboard:	def cb_usr(md, type, tid, params, sbd)
+error:          def cb_err(md, errno, params)
+server:         def cb_def(md, type, tid, params)
+switchboard:    def cb_usr(md, type, tid, params, sbd)
 
 See below for more examples.
 
 
 
 class cb:
-	def __init__(self):
-		self.unk = cb_unk	# unknown
-		self.err = cb_err	# server error
-		self.msg = cb_msg	# get a message
-		self.notice = cb_notice	# notice notification
-		self.chl = cb_chl	# challenge
-		self.qry = cb_ign	# query response
-		self.iln = cb_iln	# status notification
-		self.chg = cb_ign	# status change
-		self.nln = cb_nln	# status notification
-		self.fln = cb_fln	# status offline
-		self.out = cb_out	# disconnect
-		self.blp = cb_ign	# privacy mode change
-		self.lst = cb_lst	# list requests
-		self.bpr = cb_bpr	# user info
-		self.gtc = cb_ign	# add notification
-		self.syn = cb_syn	# list sync confirmation
-		self.prp = cb_prp	# private info
-		self.lsg = cb_lsg	# group list
-		self.add = cb_add	# user add
-		self.rem = cb_rem	# user remove
-		self.adg = cb_adg	# group add
-		self.rmg = cb_rmg	# group del
-		self.reg = cb_reg	# group rename
-		self.rea = cb_rea	# nick change
-		self.rng = cb_rng	# switchboard invitation
-		self.iro = cb_iro	# multi-user chat
-		self.ans = cb_ans	# answer confirmation
-		self.xfr = cb_xfr	# switchboard request
-		self.usr = cb_usr	# sb request initial identification
-		self.cal = cb_ign	# call confirmation
-		self.joi = cb_joi	# session join
-		self.ack = cb_ack	# message acknowledge
-		self.nak = cb_nak	# message negative acknowledge
-		self.bye = cb_bye	# switchboard user disconnect
-
+    def __init__(self):
+        self.unk = cb_unk       # unknown
+        self.err = cb_err       # server error
+        self.msg = cb_msg       # get a message
+        self.notice = cb_notice  # notice notification
+        self.chl = cb_chl       # challenge
+        self.qry = cb_ign       # query response
+        self.iln = cb_iln       # status notification
+        self.chg = cb_ign       # status change
+        self.nln = cb_nln       # status notification
+        self.fln = cb_fln       # status offline
+        self.out = cb_out       # disconnect
+        self.blp = cb_ign       # privacy mode change
+        self.lst = cb_lst       # list requests
+        self.bpr = cb_bpr       # user info
+        self.gtc = cb_ign       # add notification
+        self.syn = cb_syn       # list sync confirmation
+        self.prp = cb_prp       # private info
+        self.lsg = cb_lsg       # group list
+        self.add = cb_add       # user add
+        self.rem = cb_rem       # user remove
+        self.adg = cb_adg       # group add
+        self.rmg = cb_rmg       # group del
+        self.reg = cb_reg       # group rename
+        self.rea = cb_rea       # nick change
+        self.rng = cb_rng       # switchboard invitation
+        self.iro = cb_iro       # multi-user chat
+        self.ans = cb_ans       # answer confirmation
+        self.xfr = cb_xfr       # switchboard request
+        self.usr = cb_usr       # sb request initial identification
+        self.cal = cb_ign       # call confirmation
+        self.joi = cb_joi       # session join
+        self.ack = cb_ack       # message acknowledge
+        self.nak = cb_nak       # message negative acknowledge
+        self.bye = cb_bye       # switchboard user disconnect
 
 
 error_table = {
-	-10: 'Local error',
-	200: 'Syntax error',
-	201: 'Invalid parameter',
-	205: 'Invalid user',
-	206: 'Domain name missing',
-	207: 'Already logged in',
-	208: 'Invalid username',
-	209: 'Invalid fusername',
-	210: 'User list full',
-	215: 'User already there',
-	216: 'User already on list',
-	217: 'User not online',
-	218: 'Already in mode',
-	219: 'User is in the opposite list',
-	280: 'Switchboard failed',
-	281: 'Transfer to switchboard failed',
-	300: 'Required field missing',
-	302: 'Not logged in',
-	500: 'Internal server error',
-	501: 'Database server error',
-	510: 'File operation failed',
-	520: 'Memory allocation failed',
-	600: 'Server is busy',
-	601: 'Server is unavaliable',
-	602: 'Peer nameserver is down',
-	603: 'Database connection failed',
-	604: 'Server is going down',
-	707: 'Could not create connection',
-	711: 'Write is blocking',
-	712: 'Session is overloaded',
-	713: 'Too many active users',
-	714: 'Too many sessions',
-	715: 'Not expected',
-	717: 'Bad friend file',
-	911: 'Authentication failed',
-	913: 'Not allowed when offline',
-	920: 'Not accepting new users',
+    -10: 'Local error',
+    200: 'Syntax error',
+    201: 'Invalid parameter',
+    205: 'Invalid user',
+    206: 'Domain name missing',
+    207: 'Already logged in',
+    208: 'Invalid username',
+    209: 'Invalid fusername',
+    210: 'User list full',
+    215: 'User already there',
+    216: 'User already on list',
+    217: 'User not online',
+    218: 'Already in mode',
+    219: 'User is in the opposite list',
+    280: 'Switchboard failed',
+    281: 'Transfer to switchboard failed',
+    300: 'Required field missing',
+    302: 'Not logged in',
+    500: 'Internal server error',
+    501: 'Database server error',
+    510: 'File operation failed',
+    520: 'Memory allocation failed',
+    600: 'Server is busy',
+    601: 'Server is unavaliable',
+    602: 'Peer nameserver is down',
+    603: 'Database connection failed',
+    604: 'Server is going down',
+    707: 'Could not create connection',
+    711: 'Write is blocking',
+    712: 'Session is overloaded',
+    713: 'Too many active users',
+    714: 'Too many sessions',
+    715: 'Not expected',
+    717: 'Bad friend file',
+    911: 'Authentication failed',
+    913: 'Not allowed when offline',
+    920: 'Not accepting new users',
 }
 
+
 def cb_err(md, errno, params):
-	"Handle server errors"
-	if not error_table.has_key(errno):
-		desc = 'Unknown error %d' % errno
-	else:
-		desc = error_table[errno]
+    "Handle server errors"
+    if errno not in error_table:
+        desc = 'Unknown error %d' % errno
+    else:
+        desc = error_table[errno]
 
-	debug('SERVER ERROR %d: %s - %s' % (errno, desc, params))
+    debug('SERVER ERROR %d: %s - %s' % (errno, desc, params))
 
 
 def cb_def(md, type, tid, params):
-	"Default callback. It just prints the args"
-	debug('DEFAULT type: ' + type + ' :: Params: ' + str(params))
+    "Default callback. It just prints the args"
+    debug('DEFAULT type: ' + type + ' :: Params: ' + str(params))
 
 
 def cb_unk(md, type, tid, params):
-	"Handles the unknown types"
-	debug('Error! unknown event type "%s"' % type)
-	debug('params: ' + str(params))
+    "Handles the unknown types"
+    debug('Error! unknown event type "%s"' % type)
+    debug('params: ' + str(params))
 
 
 def cb_chl(md, type, tid, params):
-	"Handles the challenges"
-	if type != 'CHL': raise 'CallbackMess', (md, type, params)
-	hash = params + 'VT6PX?UQTM4WM%YR' # magic from www.hypothetic.org
-	hash = md5(hash).hexdigest()
-	md._send('QRY', 'PROD0038W!61ZTF9 32')
-	md.fd.send(hash)
+    "Handles the challenges"
+    if type != 'CHL':
+        raise 'CallbackMess', (md, type, params)
+    hash = params + 'VT6PX?UQTM4WM%YR'  # magic from www.hypothetic.org
+    hash = md5(hash).hexdigest()
+    md._send('QRY', 'PROD0038W!61ZTF9 32')
+    md.fd.send(hash)
 
 
-def cb_ign(md, type, tid, params, nd = None):
-	"Ignores"
-	pass
+def cb_ign(md, type, tid, params, nd=None):
+    "Ignores"
+    pass
 
 
 def cb_out(md, type, tid, params):
-	"Server disconnected us"
-	debug('!!! Server closed the connection: ' + params)
+    "Server disconnected us"
+    debug('!!! Server closed the connection: ' + params)
 
 
 def cb_iln(md, type, tid, params):
-	"Handles a friend status change"
-	t = params.split(' ')
-	status = t[0]
-	email = t[1]
-	if len(params) > 2: nick = urllib.unquote(t[2])
-	else: nick = ''
+    "Handles a friend status change"
+    t = params.split(' ')
+    status = t[0]
+    email = t[1]
+    if len(params) > 2:
+        nick = urllib.unquote(t[2])
+    else:
+        nick = ''
 
-	md.users[email].status = status
-	md.users[email].realnick = nick
-	debug('FRIEND %s (%s) changed status to :%s:' % (nick, email, status))
+    md.users[email].status = status
+    md.users[email].realnick = nick
+    debug('FRIEND %s (%s) changed status to :%s:' % (nick, email, status))
 
 
 def cb_fln(md, type, tid, params):
-	"Handles a friend disconnection"
-	email = tid
-	debug('FRIEND %s disconnected (%s)' % (email, type))
-	md.users[email].status = type
+    "Handles a friend disconnection"
+    email = tid
+    debug('FRIEND %s disconnected (%s)' % (email, type))
+    md.users[email].status = type
 
 
 def cb_nln(md, type, tid, params):
-	"Handles a friend status change"
-	status = tid
-	t = params.split(' ')
-	email = t[0]
-	if len(t) > 1: nick = urllib.unquote(t[1])
-	else: nick = ''
+    "Handles a friend status change"
+    status = tid
+    t = params.split(' ')
+    email = t[0]
+    if len(t) > 1:
+        nick = urllib.unquote(t[1])
+    else:
+        nick = ''
 
-	md.users[email].status = status
-	md.users[email].realnick = nick
-	debug('FRIEND %s (%s) changed status to :%s:' % (nick, email, status))
+    md.users[email].status = status
+    md.users[email].realnick = nick
+    debug('FRIEND %s (%s) changed status to :%s:' % (nick, email, status))
 
 
 def cb_bpr(md, type, tid, params):
-	"Update friend info"
-	# the email is deduced from the last lst we got; if it's None it means
-	# that we come from an add (the protocol behaves different if coming
-	# from SYN or ADD)
-	email = md._last_lst
-	if email:
-		# we come from SYN
-		type = tid
-		param = urllib.unquote(params)
-	else:
-		# we come from ADD
-		t = params.split(' ')
-		email = t[0]
-		type = t[1]
-		if len(t) >= 3:
-			param = urllib.unquote(t[2])
-		else:
-			param = ''
-
-	if not md.users.has_key(email): return
-
-	if   type == 'PHH': md.users[email].homep = param
-	elif type == 'PHW': md.users[email].workp = param
-	elif type == 'PHM': md.users[email].mobilep = param
-	else: pass
+    "Update friend info"
+    # the email is deduced from the last lst we got; if it's None it means
+    # that we come from an add (the protocol behaves different if coming
+    # from SYN or ADD)
+    email = md._last_lst
+    if email:
+        # we come from SYN
+        type = tid
+        param = urllib.unquote(params)
+    else:
+        # we come from ADD
+        t = params.split(' ')
+        email = t[0]
+        type = t[1]
+        if len(t) >= 3:
+            param = urllib.unquote(t[2])
+        else:
+            param = ''
+
+    if email not in md.users:
+        return
+
+    if   type == 'PHH':
+        md.users[email].homep = param
+    elif type == 'PHW':
+        md.users[email].workp = param
+    elif type == 'PHM':
+        md.users[email].mobilep = param
+    else:
+        pass
 
 
 def cb_syn(md, type, tid, params):
-	"Receive a SYN notification"
-	t = params.split()
-	if len(t) != 3:
-		raise "SYNError"
+    "Receive a SYN notification"
+    t = params.split()
+    if len(t) != 3:
+        raise "SYNError"
 
-	lver = int(t[0])
-	total = int(t[1])
-	ngroups = int(t[2])
+    lver = int(t[0])
+    total = int(t[1])
+    ngroups = int(t[2])
 
-	md.syn_lver = lver
-	md.syn_total = total
-	md.syn_ngroups = ngroups
+    md.syn_lver = lver
+    md.syn_total = total
+    md.syn_ngroups = ngroups
 
 
 def cb_lst(md, type, tid, params):
-	p = params.split(' ')
-	email = tid
-	nick = urllib.unquote(p[0])
-	listmask = int(p[1])
-	if len(p) == 3:
-		groups = p[2]
-	else:
-		groups = '0'
-
-	# we only use one main group id
-	gid = groups.split(',')[0]
-
-	if email in md.users.keys():
-		user = md.users[email]
-	else:
-		user = msnlib.user(email, nick, gid)
-
-	# the list mask is a bitmask, composed of:
-	# FL: 1
-	# AL: 2
-	# BL: 4
-	# RL: 8
-
-	# in forward
-	if listmask & 1:
-		user.lists.append('F')
-		md.users[email] = user
-
-	# in reverse
-	if listmask & 8:
-		user.lists.append('R')
-		md.reverse[email] = user
-
-	# in allow
-	if listmask & 2:
-		user.lists.append('A')
-
-	# in block
-	if listmask & 4:
-		user.lists.append('B')
-
-	md.lst_total += 1
-
-	# save in the global last_lst the email, because BPRs might need it
-	md._last_lst = email
+    p = params.split(' ')
+    email = tid
+    nick = urllib.unquote(p[0])
+    listmask = int(p[1])
+    if len(p) == 3:
+        groups = p[2]
+    else:
+        groups = '0'
+
+    # we only use one main group id
+    gid = groups.split(',')[0]
+
+    if email in md.users.keys():
+        user = md.users[email]
+    else:
+        user = msnlib.user(email, nick, gid)
+
+    # the list mask is a bitmask, composed of:
+    # FL: 1
+    # AL: 2
+    # BL: 4
+    # RL: 8
+
+    # in forward
+    if listmask & 1:
+        user.lists.append('F')
+        md.users[email] = user
+
+    # in reverse
+    if listmask & 8:
+        user.lists.append('R')
+        md.reverse[email] = user
+
+    # in allow
+    if listmask & 2:
+        user.lists.append('A')
+
+    # in block
+    if listmask & 4:
+        user.lists.append('B')
+
+    md.lst_total += 1
+
+    # save in the global last_lst the email, because BPRs might need it
+    md._last_lst = email
+
 
 def cb_lsg(md, type, tid, params):
-	"Handles group list"
-	p = params.split(' ')
-	gid = tid
-	name, unk = p[0:]
-	# if we get the group 0, start from scratch
-	if gid == '0':
-		md.groups = {}
-	name = urllib.unquote(name)
-	md.groups[gid] = name
+    "Handles group list"
+    p = params.split(' ')
+    gid = tid
+    name, unk = p[0:]
+    # if we get the group 0, start from scratch
+    if gid == '0':
+        md.groups = {}
+    name = urllib.unquote(name)
+    md.groups[gid] = name
 
 
 def cb_prp(md, type, tid, params):
-	"Handles private info"
-	t = params.split(' ')
-	type = t[0]
-	if len(t) > 1: param = urllib.unquote(t[1])
-	else: param = ''
-
-	if   type == 'PHH': md.homep = param
-	elif type == 'PHW': md.workp = param
-	elif type == 'PHM': md.mobilep = param
-	else: pass
+    "Handles private info"
+    t = params.split(' ')
+    type = t[0]
+    if len(t) > 1:
+        param = urllib.unquote(t[1])
+    else:
+        param = ''
+
+    if   type == 'PHH':
+        md.homep = param
+    elif type == 'PHW':
+        md.workp = param
+    elif type == 'PHM':
+        md.mobilep = param
+    else:
+        pass
 
 
 def cb_add(md, type, tid, params):
-	"Handles a user add; both you adding a user and a user adding you"
-	t = params.split(' ')
-	type = t[0]
-	if type == 'RL':
-		email = t[2]
-		nick = urllib.unquote(t[3])
-		debug('ADD: %s (%s) added you' % (nick, email))
-	elif type == 'FL':
-		email = t[2]
-		nick = urllib.unquote(t[3])
-		gid = t[4]
-		md.users[email] = msnlib.user(email, nick, gid)
-		# put None in last_lst so BPRs know it's not coming from sync
-		md._last_lst = None
-		debug('ADD: adding %s (%s)' % (email, nick))
-	else:
-		pass
+    "Handles a user add; both you adding a user and a user adding you"
+    t = params.split(' ')
+    type = t[0]
+    if type == 'RL':
+        email = t[2]
+        nick = urllib.unquote(t[3])
+        debug('ADD: %s (%s) added you' % (nick, email))
+    elif type == 'FL':
+        email = t[2]
+        nick = urllib.unquote(t[3])
+        gid = t[4]
+        md.users[email] = msnlib.user(email, nick, gid)
+        # put None in last_lst so BPRs know it's not coming from sync
+        md._last_lst = None
+        debug('ADD: adding %s (%s)' % (email, nick))
+    else:
+        pass
+
 
 def cb_rem(md, type, tid, params):
-	"""Handles a user del.
-	Only make something in the case of a user removing you"""
-	t = params.split(' ')
-	type = t[0]
-	if type == 'RL':
-		email = t[2]
-		debug('REM: %s removed you' % email)
-	elif type == 'FL':
-		email = t[2]
-		if md.users[email].sbd:
-			md.close(md.users[email].sbd)
-		del(md.users[email])
-		debug('REM: removing %s' % email)
-	else:
-		pass
+    """Handles a user del.
+    Only make something in the case of a user removing you"""
+    t = params.split(' ')
+    type = t[0]
+    if type == 'RL':
+        email = t[2]
+        debug('REM: %s removed you' % email)
+    elif type == 'FL':
+        email = t[2]
+        if md.users[email].sbd:
+            md.close(md.users[email].sbd)
+        del(md.users[email])
+        debug('REM: removing %s' % email)
+    else:
+        pass
+
 
 def cb_adg(md, type, tid, params):
-	"Handle a group add"
-	t = params.split(' ')
-	lver, name, gid = t[0:3]
-	md.groups[gid] = name
-	debug('ADG: group %s (%s) added' % (name, gid))
+    "Handle a group add"
+    t = params.split(' ')
+    lver, name, gid = t[0:3]
+    md.groups[gid] = name
+    debug('ADG: group %s (%s) added' % (name, gid))
+
 
 def cb_rmg(md, type, tid, params):
-	"Handle a group del"
-	t = params.split(' ')
-	lver, gid = t[0:2]
-	for e in md.users.keys():
-		if md.users[e].gid == gid:
-			if md.users[e].sbd:
-				md.close(md.users[e].sbd)
-			del(md.users[e])
-	del(md.groups[gid])
-	debug('RMG: group %s removed' % gid)
+    "Handle a group del"
+    t = params.split(' ')
+    lver, gid = t[0:2]
+    for e in md.users.keys():
+        if md.users[e].gid == gid:
+            if md.users[e].sbd:
+                md.close(md.users[e].sbd)
+            del(md.users[e])
+    del(md.groups[gid])
+    debug('RMG: group %s removed' % gid)
+
 
 def cb_reg(md, type, tid, params):
-	"Handle a group rename"
-	t = params.split(' ')
-	gid = t[1]
-	name = t[2]
-	md.groups[gid] = name
-	debug('REG: group %s renamed to %s' % (name, gid))
+    "Handle a group rename"
+    t = params.split(' ')
+    gid = t[1]
+    name = t[2]
+    md.groups[gid] = name
+    debug('REG: group %s renamed to %s' % (name, gid))
+
 
 def cb_rea(md, type, tid, params):
-	"Handles our info change"
-	t = params.split(' ')
-	email = t[1]
-	nick = urllib.unquote(t[2])
-	if email != md.email:
-		md.users[email].nick = nick
-	else:
-		md.nick = nick
-	debug('NICK CHANGE: email %s - nick %s' % (email, nick))
+    "Handles our info change"
+    t = params.split(' ')
+    email = t[1]
+    nick = urllib.unquote(t[2])
+    if email != md.email:
+        md.users[email].nick = nick
+    else:
+        md.nick = nick
+    debug('NICK CHANGE: email %s - nick %s' % (email, nick))
 
 
 def cb_rng(md, type, tid, params):
-	"Handles switchboard invitations."
-	t = params.split(' ')
-	sid = tid
-	ip, port = t[0].split(':')
-	port = int(port)
-	hash = t[2]
-	email = t[3]
-
-	fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-	# we set the socket nonblocking so we don't block (duh!) on connect();
-	# it will be picked up later from the select loop and handled via the
-	# main read() call, which you will have to see to find out the rest.
-	fd.setblocking(0)
-	fd.connect_ex((ip, port))
-
-	sbd = msnlib.sbd()
-	sbd.fd = fd
-	sbd.block = 0
-	sbd.state = 'cp'
-	sbd.type = 'answer'
-	sbd.endpoint = (ip, port)
-	sbd.emails.append(email)
-	sbd.hash = hash
-	sbd.session_id = sid
-	md.submit_sbd(sbd) 		# it has the connect pending
+    "Handles switchboard invitations."
+    t = params.split(' ')
+    sid = tid
+    ip, port = t[0].split(':')
+    port = int(port)
+    hash = t[2]
+    email = t[3]
+
+    fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    # we set the socket nonblocking so we don't block (duh!) on connect();
+    # it will be picked up later from the select loop and handled via the
+    # main read() call, which you will have to see to find out the rest.
+    fd.setblocking(0)
+    fd.connect_ex((ip, port))
+
+    sbd = msnlib.sbd()
+    sbd.fd = fd
+    sbd.block = 0
+    sbd.state = 'cp'
+    sbd.type = 'answer'
+    sbd.endpoint = (ip, port)
+    sbd.emails.append(email)
+    sbd.hash = hash
+    sbd.session_id = sid
+    md.submit_sbd(sbd)              # it has the connect pending
 
 
 def cb_xfr(md, type, tid, params):
-	"Handles switchboard requests"
-	t = params.split(' ')
-	ip, port = t[1].split(':')
-	port = int(port)
-	hash = t[3]
-
-	fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-	fd.setblocking(0)		# see cb_rng
-	fd.connect_ex((ip, port))
-
-	# look for the sbd, matching the tid
-	sbd = None
-	for i in md.sb_fds:
-		if i.state == 'xf' and i.orig_tid == tid:
-			sbd = i
-			break
-	if not sbd:
-		debug('AIEEE: XFR without sbd!')
-		raise 'XFRError', (type, tid, params)
-
-	sbd.fd = fd
-	sbd.block = 0
-	sbd.state = 'cp'
-	sbd.endpoint = (ip, port)
-	sbd.hash = hash
+    "Handles switchboard requests"
+    t = params.split(' ')
+    ip, port = t[1].split(':')
+    port = int(port)
+    hash = t[3]
+
+    fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    fd.setblocking(0)               # see cb_rng
+    fd.connect_ex((ip, port))
+
+    # look for the sbd, matching the tid
+    sbd = None
+    for i in md.sb_fds:
+        if i.state == 'xf' and i.orig_tid == tid:
+            sbd = i
+            break
+    if not sbd:
+        debug('AIEEE: XFR without sbd!')
+        raise 'XFRError', (type, tid, params)
+
+    sbd.fd = fd
+    sbd.block = 0
+    sbd.state = 'cp'
+    sbd.endpoint = (ip, port)
+    sbd.hash = hash
+
 
 def cb_iro(md, type, tid, params, sbd):
-	"Handles the switchboard participant list"
-	p = params.split(' ')
-	uid, ucount, email, nick = p
-	if ucount == '1':
-		# do nothing if we only have one participant
-		return
-	else:
-		if email not in md.users.keys():
-			md.users[email] = msnlib.user(email)
-		if email not in sbd.emails:
-			sbd.emails.append(email)
-		debug("FRIEND %s joined chat with %s" % (email, sbd.emails[0]))
+    "Handles the switchboard participant list"
+    p = params.split(' ')
+    uid, ucount, email, nick = p
+    if ucount == '1':
+        # do nothing if we only have one participant
+        return
+    else:
+        if email not in md.users.keys():
+            md.users[email] = msnlib.user(email)
+        if email not in sbd.emails:
+            sbd.emails.append(email)
+        debug("FRIEND %s joined chat with %s" % (email, sbd.emails[0]))
+
 
 def cb_usr(md, type, tid, params, sbd):
-	"Handles switchboard requests initial identification"
-	email = sbd.emails[0]
-	md._send('CAL', email, sbd)
-	sbd.state = 'ca'
+    "Handles switchboard requests initial identification"
+    email = sbd.emails[0]
+    md._send('CAL', email, sbd)
+    sbd.state = 'ca'
 
 
 def cb_joi(md, type, tid, params, sbd):
-	"Handles a switchboard join, and sends the pending messages"
-	email = tid
-	# if it's a multi-user chat, just append it to the list
-	if sbd.emails and email != sbd.emails[0]:
-		sbd.emails.append(email)
-		if email not in md.users.keys():
-			md.users[email] = msnlib.user(email)
-		debug('CALL: user %s joined chat with %s' % \
-			(email, sbd.emails[0]))
-	# otherwise (common path) set up the sbd and flush the messages
-	else:
-		sbd.state = 'es'
-		debug('CALL: user %s replied your chat request; flushing' % email)
-		md.sendmsg(email)
-		debug('CALL: message queue for %s flushed' % email)
+    "Handles a switchboard join, and sends the pending messages"
+    email = tid
+    # if it's a multi-user chat, just append it to the list
+    if sbd.emails and email != sbd.emails[0]:
+        sbd.emails.append(email)
+        if email not in md.users.keys():
+            md.users[email] = msnlib.user(email)
+        debug('CALL: user %s joined chat with %s' %
+              (email, sbd.emails[0]))
+    # otherwise (common path) set up the sbd and flush the messages
+    else:
+        sbd.state = 'es'
+        debug('CALL: user %s replied your chat request; flushing' % email)
+        md.sendmsg(email)
+        debug('CALL: message queue for %s flushed' % email)
 
 
 def cb_ans(md, type, tid, params, sbd):
-	"""Answer confirmation to an invitation, replied after the connect()
-	ending by read()"""
-	sbd.state = 'es'
+    """Answer confirmation to an invitation, replied after the connect()
+    ending by read()"""
+    sbd.state = 'es'
 
 
 def cb_msg(md, type, tid, params, sbd):
-	"Get a message"
-	debug('MESSAGE\n+++ Header: %s\n%s\n\n' % (str(tid), str(params)))
+    "Get a message"
+    debug('MESSAGE\n+++ Header: %s\n%s\n\n' % (str(tid), str(params)))
+
 
 def cb_ack(md, type, tid, params, sbd):
-	"Get a message acknowledge"
-	debug('ACK: tid:%s' % tid)
+    "Get a message acknowledge"
+    debug('ACK: tid:%s' % tid)
+
 
 def cb_notice(md, type, tid, params, sbd):
-	"Get a notice"
-	debug('NOTICE\n+++ %s\n\n' % str(params))
+    "Get a notice"
+    debug('NOTICE\n+++ %s\n\n' % str(params))
 
 
 def cb_nak(md, type, tid, params, sbd):
-	"Get a message negative acknowledge"
-	debug('NAK: tid:%s' % tid)
+    "Get a message negative acknowledge"
+    debug('NAK: tid:%s' % tid)
 
 
 def cb_bye(md, type, tid, params, sbd):
-	"Handles a user sb disconnect"
-	email = tid
-	if email != sbd.emails[0]:
-		debug('BYE: user %s leaving sbd' % email)
-		if email in sbd.emails:
-			sbd.emails.remove(email)
-	else:
-		debug('BYE: closing %s' % str(sbd))
-		md.close(sbd)
+    "Handles a user sb disconnect"
+    email = tid
+    if email != sbd.emails[0]:
+        debug('BYE: user %s leaving sbd' % email)
+        if email in sbd.emails:
+            sbd.emails.remove(email)
+    else:
+        debug('BYE: closing %s' % str(sbd))
+        md.close(sbd)
+
+
 def cb_qng(md, type, tid, params):
-	"Get the response of a ping"
-	debug('PONG!: answered by the server')
+    "Get the response of a ping"
+    debug('PONG!: answered by the server')

File msn_lib/msnlib.py

 LOGIN_PORT = 1863
 
 status_table = {
-    'online':       'NLN',
-    'away':         'AWY',
-    'busy':         'BSY',
-    'brb':          'BRB',
-    'phone':        'PHN',
-    'lunch':        'LUN',
-    'invisible':    'HDN',
-    'idle':         'IDL',
-    'offline':      'FLN',
+    'online': 'NLN',
+    'away': 'AWY',
+    'busy': 'BSY',
+    'brb': 'BRB',
+    'phone': 'PHN',
+    'lunch': 'LUN',
+    'invisible': 'HDN',
+    'idle': 'IDL',
+    'offline': 'FLN',
 }
 
 reverse_status = {
-    'NLN':		'online',
-    'AWY':		'away',
-    'BSY':		'busy',
-    'BRB':		'brb',
-    'PHN':		'phone',
-    'LUN':		'lunch',
-    'HDN':		'invisible',
-    'IDL':		'idle',
-    'FLN':		'offline',
+    'NLN': 'online',
+    'AWY': 'away',
+    'BSY': 'busy',
+    'BRB': 'brb',
+    'PHN': 'phone',
+    'LUN': 'lunch',
+    'HDN': 'invisible',
+    'IDL': 'idle',
+    'FLN': 'offline',
 }
 
 
     sys.stderr.write('\r' + str(s) + '\n')
     sys.stderr.flush()
 
+
 def nickquote(nick):
     """Quotes a nick the way the server likes it: replacing spaces with
     '%20' but leaving extender characters alone, as they get sent UTF-8
     nick = nick.replace(' ', '%20')
     return nick
 
+
 class user:
     """User class, used to store your 'friends'"""
-    def __init__(self, email = '', nick = '', gid = None):
+    def __init__(self, email='', nick='', gid=None):
         self.email = email
         self.nick = nick
         self.realnick = ''
 
     def __repr__(self):
         return '<user email:%s nick:"%s" gid:%s>' % (self.email,
-                self.nick, self.gid)
+                                                     self.nick, self.gid)
 
 
 class sbd:
 
     def __init__(self):
         self.fd = None		# connection fd
-        self.state = None	# connection's state (see doc above)
-        self.emails = []	# emails we talk to through
-        self.msgqueue = []	# outgoing message queue
-        self.hash = None	# server-sent hash
-        self.session_id = None	# server-sent sid
-        self.endpoint = ()	# remote end (ip, port)
-        self.type = None	# either 'answer' or 'invite'
+        self.state = None  # connection's state (see doc above)
+        self.emails = []  # emails we talk to through
+        self.msgqueue = []  # outgoing message queue
+        self.hash = None  # server-sent hash
+        self.session_id = None  # server-sent sid
+        self.endpoint = ()  # remote end (ip, port)
+        self.type = None  # either 'answer' or 'invite'
         self.tid = 1		# the transaction id, it needs to be
                     # unique for consistency
         self.block = 1		# blocking state
-        self.orig_tid = None	# tid of the original XFR
+        self.orig_tid = None  # tid of the original XFR
 
     def __repr__(self):
         return '<sbd: emails:%s state:%s fd:%d endpoint:%s>' % \
-            (str(self.emails), self.state, \
-            self.fileno(), self.endpoint)
+            (str(self.emails), self.state,
+             self.fileno(), self.endpoint)
 
     def fileno(self):
         return self.fd.fileno()
         return str(self.tid - 1)
 
 
-
 class msnd:
     """MSN Descriptor
     This is the main and most important class; it represents a msn
         self.mobilep = None		# mobile phone
 
         self.status = 'FLN'		# status
-        self.encoding = 'iso-8859-1'	# local encoding
+        self.encoding = 'iso-8859-1'  # local encoding
 
         self.lhost = LOGIN_HOST
         self.lport = LOGIN_PORT
         self.reverse = {}		# reverse user list
         self.groups = {}		# group list
 
-
     def __repr__(self):
         return '<msnd object, fd:%s, email:%s, tid:%s>' % (self.fd,
-            self.email, self.tid)
+                                                           self.email, self.tid)
 
     def fileno(self):
         """Useful for select()"""
         except:
             return s
 
-
     def pollable(self):
         """Return a pair of lists of poll()/select()ables network
         descriptors (ie. they are not fds, but actually classes that
         owtd = []
         iwtd.append(self)
         for nd in self.sb_fds:
-            if nd.state == 'cp':	# connect is pending
+            if nd.state == 'cp':  # connect is pending
                 owtd.append(nd)
-            elif nd.state == 'xf':	# skip this case because it's
+            elif nd.state == 'xf':  # skip this case because it's
                         # not connected yet
                 pass
             else:			# readable!
                 iwtd.append(nd)
         return (iwtd, owtd)
 
-
     def get_tid(self):
         """Returns a valid tid as string"""
         self.tid = self.tid + 1
         return str(self.tid - 1)
 
-
-    def _send(self, cmd, params = '', nd = None, raw = 0):
+    def _send(self, cmd, params='', nd=None, raw=0):
         """Sends a command to the server, building it first as a
         string; uses, if specified, the pseudo fd (it can be either
         msnd or sbd)."""
         tid = nd.get_tid()
         fd = nd.fd
         c = cmd + ' ' + tid
-        if params: c = c + ' ' + params
+        if params:
+            c = c + ' ' + params
         debug(str(fd.fileno()) + ' >>> ' + c)
         if not raw:
             c = c + '\r\n'
         c = self.encode(c)
         return fd.send(c)
 
-
-    def _recv(self, fd = None):
+    def _recv(self, fd=None):
         """Reads a command from the server, returns (cmd, tid, params)"""
         if not fd:
             fd = self.fd
         debug(str(fd.fileno()) + ' <<< ' + buf)
         return (cmd, tid, params)
 
-
-    def _recvmsg(self, msglen, fd = None):
+    def _recvmsg(self, msglen, fd=None):
         """Read a message from the server, returns it"""
         if not fd:
             fd = self.fd
 
         return self.decode(buf)
 
-
     def submit_sbd(self, sbd):
         """Submits a switchboard descriptor to add to our list; it is
         also put on our global list.
         self.users[email].sbd = sbd
         return
 
-
     def change_status(self, st):
         """Changes the current status to: online, away, busy, brb,
         phone, lunch, invisible, idle, offline"""
-        if not status_table.has_key(st): return 0
+        if st not in status_table:
+            return 0
         self.status = status_table[st]
         self._send('CHG', self.status)
         return 1
 
-
-    def privacy(self, public = 1, auth = 0):
+    def privacy(self, public=1, auth=0):
         """Sets our privacy state. First parameter define if you get
         messages from everybody or only from people on your list; the
         second defines if you want users to ask for authorization or
         let everybody add you"""
-        if public:	self._send('BLP', 'AL') # be social
-        else:		self._send('BLP', 'BL') # live in a cave
+        if public:
+            self._send('BLP', 'AL')  # be social
+        else:
+            self._send('BLP', 'BL')  # live in a cave
 
-        if auth:	self._send('GTC', 'A')	# ask for auth
-        else:		self._send('GTC', 'N')	# let them add you
+        if auth:
+            self._send('GTC', 'A')  # ask for auth
+        else:
+            self._send('GTC', 'N')  # let them add you
 
         return 1
 
-
     def change_nick(self, nick):
         """Changes our nick"""
         nick = nickquote(nick)
         self._send('REA', self.email + ' ' + nick)
         return 1
 
-
     def sync(self):
         """Syncronizes the tables"""
         self._send('SYN', '0')
         return 1
 
-
-    def useradd(self, email, nick = None, gid = '0'):
+    def useradd(self, email, nick=None, gid='0'):
         """Adds a user"""
-        if not nick: nick = email
+        if not nick:
+            nick = email
         nick = nickquote(nick)
         self._send('ADD', 'AL ' + email + ' ' + nick)
         self._send('ADD', 'FL ' + email + ' ' + nick + ' ' + gid)
         self.fd.send('OUT\r\n')
         self.fd.close()
 
-
     def close(self, sb):
         """Closes a given sbd"""
         try:
             self.sb_fds.remove(sb)
             self.users[sb.emails[0]].sbd = None
-            self._send('BYE', self.email, nd = sb)
+            self._send('BYE', self.email, nd=sb)
             sb.fd.close()
         except:
             pass
         del(sb)
 
-
     def invite(self, email, sbd):
         """Invites a user into an existing sbd"""
-        self._send('CAL', email, nd = sbd)
+        self._send('CAL', email, nd=sbd)
 
     def login(self):
         """Logins to the server, really boring"""
             raise Exception('Error de version')
 
         # lie the version, just in case
-        self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ' + self.email)
-        self._recv()	# we just don't care what we get
+        self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS ' +
+                   self.email)
+        self._recv()  # we just don't care what we get
 
         # ask for notification server
         self._send('USR', 'TWN I ' + self.email)
             raise Exception('Error de version')
 
         # lie the version, just in case
-        self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS	' + self.email)
-        self._recv()	# we just don't care what we get
+        self._send('CVR', '0x0409 win 4.10 i386 MSNMSGR 5.0.0544 MSMSGS	' +
+                   self.email)
+        self._recv()  # we just don't care what we get
 
         # auth: send user, get hash
         self._send('USR', 'TWN I ' + self.email)
 
         return 1
 
-
     def passport_auth(self, hash):
         """Logins into passport and obtains an ID used for
         authorization; it's a helper function for login"""
         login_host = d['DALogin'].split('/')[0]
 
         # build the authentication headers
-        ahead =  'Passport1.4 OrgVerb=GET'
+        ahead = 'Passport1.4 OrgVerb=GET'
         ahead += ',OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom'
         ahead += ',sign-in=' + urllib.quote(self.email)
         ahead += ',pwd=' + urllib.quote(self.pwd)
         ahead += 'ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=0,'
         ahead += 'kpp=1,kv=5,ver=2.1.0173.1,'
         ahead += hash
-        headers = { 'Authorization': ahead }
+        headers = {'Authorization': ahead}
 
         # connect to the given server
         debug('SSL Connect to %s' % login_server)
             login_host = login_server.split('/')[2]
             debug('SSL Redirect to %s' % login_server)
             ls = httplib.HTTPSConnection(login_host)
-            headers = { 'Authorization': ahead }
+            headers = {'Authorization': ahead}
             ls.request('GET', login_server, '', headers)
             resp = ls.getresponse()
             debug('SSL Response %d' % resp.status)
         passportid = passportid[1:-1]		# remove the "'"
         return passportid
 
-
-    def read(self, nd = None):
+    def read(self, nd=None):
         """Reads from the specified nd and run the callback. The nd
         can be either a msnd or a sbd (that's why it's called 'nd'
         from 'network descriptor').
             if nd.state == 'cp':
                 # see if the connect went well
                 r = nd.fd.getsockopt(socket.SOL_SOCKET,
-                    socket.SO_ERROR)
+                                     socket.SO_ERROR)
                 if r != 0:
                     raise socket.error('ConnectFailed')
                 nd.fd.setblocking(1)
                 nd.state = 'us'
                 return
 
-
-
         r = self._recv(nd.fd)
         type = r[0]
         tid = r[1]
         params = string.strip(r[2])
 
-        if   type == 'CHL': self.cb.chl(self, type, tid, params)
-        elif type == 'QRY': self.cb.qry(self, type, tid, params)
-        elif type == 'ILN': self.cb.iln(self, type, tid, params)
-        elif type == 'CHG': self.cb.chg(self, type, tid, params)
-        elif type == 'OUT': self.cb.out(self, type, tid, params)
-        elif type == 'FLN': self.cb.fln(self, type, tid, params)
-        elif type == 'NLN': self.cb.nln(self, type, tid, params)
-        elif type == 'BLP': self.cb.blp(self, type, tid, params)
-        elif type == 'LST': self.cb.lst(self, type, tid, params)
-        elif type == 'GTC': self.cb.gtc(self, type, tid, params)
-        elif type == 'SYN': self.cb.syn(self, type, tid, params)
-        elif type == 'PRP': self.cb.prp(self, type, tid, params)
-        elif type == 'LSG': self.cb.lsg(self, type, tid, params)
-        elif type == 'BPR': self.cb.bpr(self, type, tid, params)
-        elif type == 'ADD': self.cb.add(self, type, tid, params)
-        elif type == 'REA': self.cb.rea(self, type, tid, params)
-        elif type == 'REM': self.cb.rem(self, type, tid, params)
-        elif type == 'ADG': self.cb.adg(self, type, tid, params)
-        elif type == 'RMG': self.cb.rmg(self, type, tid, params)
-        elif type == 'REG': self.cb.reg(self, type, tid, params)
-        elif type == 'RNG': self.cb.rng(self, type, tid, params)
-
-        elif type == 'IRO': self.cb.iro(self, type, tid, params, nd)
-        elif type == 'ANS': self.cb.ans(self, type, tid, params, nd)
-        elif type == 'XFR': self.cb.xfr(self, type, tid, params)
-        elif type == 'USR': self.cb.usr(self, type, tid, params, nd)
-        elif type == 'CAL': self.cb.cal(self, type, tid, params, nd)
-        elif type == 'JOI': self.cb.joi(self, type, tid, params, nd)
-
-        elif type == 'ACK': self.cb.ack(self, type, tid, params, nd)
-        elif type == 'NAK': self.cb.nak(self, type, tid, params, nd)
-        elif type == 'BYE': self.cb.bye(self, type, tid, params, nd)
+        if   type == 'CHL':
+            self.cb.chl(self, type, tid, params)
+        elif type == 'QRY':
+            self.cb.qry(self, type, tid, params)
+        elif type == 'ILN':
+            self.cb.iln(self, type, tid, params)
+        elif type == 'CHG':
+            self.cb.chg(self, type, tid, params)
+        elif type == 'OUT':
+            self.cb.out(self, type, tid, params)
+        elif type == 'FLN':
+            self.cb.fln(self, type, tid, params)
+        elif type == 'NLN':
+            self.cb.nln(self, type, tid, params)
+        elif type == 'BLP':
+            self.cb.blp(self, type, tid, params)
+        elif type == 'LST':
+            self.cb.lst(self, type, tid, params)
+        elif type == 'GTC':
+            self.cb.gtc(self, type, tid, params)
+        elif type == 'SYN':
+            self.cb.syn(self, type, tid, params)
+        elif type == 'PRP':
+            self.cb.prp(self, type, tid, params)
+        elif type == 'LSG':
+            self.cb.lsg(self, type, tid, params)
+        elif type == 'BPR':
+            self.cb.bpr(self, type, tid, params)
+        elif type == 'ADD':
+            self.cb.add(self, type, tid, params)
+        elif type == 'REA':
+            self.cb.rea(self, type, tid, params)
+        elif type == 'REM':
+            self.cb.rem(self, type, tid, params)
+        elif type == 'ADG':
+            self.cb.adg(self, type, tid, params)
+        elif type == 'RMG':
+            self.cb.rmg(self, type, tid, params)
+        elif type == 'REG':
+            self.cb.reg(self, type, tid, params)
+        elif type == 'RNG':
+            self.cb.rng(self, type, tid, params)
+
+        elif type == 'IRO':
+            self.cb.iro(self, type, tid, params, nd)
+        elif type == 'ANS':
+            self.cb.ans(self, type, tid, params, nd)
+        elif type == 'XFR':
+            self.cb.xfr(self, type, tid, params)
+        elif type == 'USR':
+            self.cb.usr(self, type, tid, params, nd)
+        elif type == 'CAL':
+            self.cb.cal(self, type, tid, params, nd)
+        elif type == 'JOI':
+            self.cb.joi(self, type, tid, params, nd)
+
+        elif type == 'ACK':
+            self.cb.ack(self, type, tid, params, nd)
+        elif type == 'NAK':
+            self.cb.nak(self, type, tid, params, nd)
+        elif type == 'BYE':
+            self.cb.bye(self, type, tid, params, nd)
 
         elif type == 'MSG':
             params = tid + ' ' + params
                 errno = None
 
             if errno:
-                self.cb.err(self, errno, \
-                    str(tid) + ' ' + str(params))
+                self.cb.err(self, errno,
+                            str(tid) + ' ' + str(params))
             else:
                 # if we got this far, we have no idea
                 self.cb.unk(self, type, tid, params)
         return
 
-
-    def sendmsg(self, email, msg = '', sb = None):
+    def sendmsg(self, email, msg='', sb=None):
         """Sends a message to the user identified by 'email', either
         the one specified or flush the queue.
         Returns:
             sb.emails.append(email)
             sb.msgqueue.append(msg)
 
-            self.submit_sbd(sb)	# no need to connect it yet
+            self.submit_sbd(sb)  # no need to connect it yet
             # we set the orig_tid of the sbd to the next tid (that
             # is, the tid the XFR is going to have), in order to
             # be able to identify it later, in cb.cb_xfr()
                 m = header + m
                 msize = len(self.encode(m))
                 params = 'A ' + str(msize) + '\r\n' + m
-                self._send('MSG', params, sb, raw = 1)
+                self._send('MSG', params, sb, raw=1)
                 del(pend[0])
 
             return 2
-
-
-