From afe91b5e68a61798cc507f62a64c7daadbb7d943 Mon Sep 17 00:00:00 2001
From: Pierre LALET <pierre.lalet@cea.fr>
Date: Thu, 31 Aug 2017 15:55:44 +0200
Subject: [PATCH] Add docstrings to _load() and load_*() (@guedou)

---
 scapy/arch/bpf/supersocket.py |  2 +-
 scapy/main.py                 | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/scapy/arch/bpf/supersocket.py b/scapy/arch/bpf/supersocket.py
index e0650020..3903fa45 100644
--- a/scapy/arch/bpf/supersocket.py
+++ b/scapy/arch/bpf/supersocket.py
@@ -108,7 +108,7 @@ class _L2bpfSocket(SuperSocket):
         try:
             fcntl.ioctl(self.ins, BIOCPROMISC, struct.pack('i', value))
         except IOError:
-            raise Scapy_Exception("Cannott set promiscuous mode on interface "
+            raise Scapy_Exception("Cannot set promiscuous mode on interface "
                                   "(%s)!" % self.iface)
 
     def __del__(self):
diff --git a/scapy/main.py b/scapy/main.py
index dc501ce2..fda7e968 100644
--- a/scapy/main.py
+++ b/scapy/main.py
@@ -69,6 +69,13 @@ from scapy.themes import DefaultTheme
 
 
 def _load(module, globals_dict=None, symb_list=None):
+    """Loads a Python module to make variables, objects and functions
+available globally.
+
+    The idea is to load the module using importlib, then copy the
+symbols to the global symbol table.
+
+    """
     if globals_dict is None:
         globals_dict = six.moves.builtins.__dict__
     try:
@@ -90,13 +97,28 @@ def _load(module, globals_dict=None, symb_list=None):
         log_interactive.error("Loading module %s", module, exc_info=True)
 
 def load_module(name):
+    """Loads a Scapy module to make variables, objects and functions
+    available globally.
+
+    """
     _load("scapy.modules."+name)
 
 def load_layer(name, globals_dict=None, symb_list=None):
+    """Loads a Scapy layer module to make variables, objects and functions
+    available globally.
+
+    """
     _load("scapy.layers." + LAYER_ALIASES.get(name, name),
           globals_dict=globals_dict, symb_list=symb_list)
 
 def load_contrib(name):
+    """Loads a Scapy contrib module to make variables, objects and
+    functions available globally.
+
+    If no contrib module can be found with the given name, try to find
+    a layer module, since a contrib module may become a layer module.
+
+    """
     try:
         importlib.import_module("scapy.contrib." + name)
         _load("scapy.contrib." + name)
-- 
GitLab