python:les_modules
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
python:les_modules [2014/01/30 20:45] – [Fabric] root | python:les_modules [2024/12/20 12:41] (Version actuelle) – [Fabric] admin | ||
---|---|---|---|
Ligne 237: | Ligne 237: | ||
env.roledefs = { | env.roledefs = { | ||
- | | + | |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
} | } | ||
Ligne 401: | Ligne 401: | ||
os.system(' | os.system(' | ||
</ | </ | ||
+ | |||
+ | ===== readline ===== | ||
+ | |||
+ | <code python readline.py> | ||
+ | import readline, signal | ||
+ | prompt = 'GigiX > ' | ||
+ | |||
+ | def signal_handler(signal, | ||
+ | |||
+ | input(prompt) | ||
+ | return | ||
+ | |||
+ | signal.signal(signal.SIGINT, | ||
+ | readline.parse_and_bind(" | ||
+ | |||
+ | class completer: | ||
+ | def __init__(self, | ||
+ | self.tree = tree | ||
+ | |||
+ | def _parser(self, | ||
+ | if (search is None) or (callable(search) == True): | ||
+ | return [] | ||
+ | elif len(line) == 0: | ||
+ | return [x for x in search] | ||
+ | elif len(line) == 1 and readline.get_line_buffer()[-1] != ' ': | ||
+ | return ['%s ' % x for x in search if x.startswith(line[0])] | ||
+ | else: | ||
+ | return self._parser(line[1: | ||
+ | return [] | ||
+ | |||
+ | def complete(self, | ||
+ | line = readline.get_line_buffer().split() | ||
+ | results = self._parser(line, | ||
+ | return results[state] | ||
+ | |||
+ | def linux_sles_12(): | ||
+ | print(' | ||
+ | |||
+ | tree = { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | }, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | }, | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | readline.set_completer(completer(tree).complete) | ||
+ | l = '' | ||
+ | while l != (' | ||
+ | try: | ||
+ | l = input(prompt) | ||
+ | eval(" | ||
+ | except EOFError: | ||
+ | print(' | ||
+ | break | ||
+ | except: | ||
+ | continue | ||
+ | </ | ||
+ | |||
===== Twisted ===== | ===== Twisted ===== | ||
Ligne 428: | Ligne 527: | ||
import ctypes, ctypes.util | import ctypes, ctypes.util | ||
- | ctypes.cdll.LoadLibrary(ctypes.util.find_library(' | + | libc=ctypes.cdll.LoadLibrary(ctypes.util.find_library(' |
libc.printf(" | libc.printf(" | ||
</ | </ |
python/les_modules.1391114751.txt.gz · Dernière modification : 2014/01/30 20:45 de root