-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating documentation for Python 3 #544
Comments
Thanks @dwysocki ! Honestly, we are thinking of dropping 2.7 support in next release, so I'm not sure there is value in writting examples that are cross-compatible. If you can just send a PR to migrate them to Py3, that would be great! |
Here is a task list with every object that has a docstring containing code examples, with line numbers inserted as comments
>>> msgtree.remove(lambda k: k > 3) # line: 5
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> msgtree.remove(lambda k: k > 3) # line: 5
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> task = task_self() # line: 13
>>> task = Task() # line: 17
>>> task = Task(thread=thr) # line: 22
>>> task.shell("/bin/hostname") # line: 26
>>> task.shell("/bin/hostname", nodes="tiger[1-20]") # line: 30
>>> task.shell("uname -r", nodes="node[1-9]", handler=MyEventHandler()) # line: 39
>>> task.resume() # line: 44
>>> task.run() # line: 48
>>> task.run("hostname", nodes="tiger[1-20]", handler=MyEventHandler()) # line: 53
>>> task.run("check_network.sh", nodes="tiger[1-20]", timeout=30) # line: 61
>>> for buffer, nodelist in task.iter_buffers(): # line: 10
... print NodeSet.fromlist(nodelist)
... print buffer
>>> task.run("hostname", nodes="foo") # line: 5
>>> task.shell("hostname", nodes="foo") # line: 10
>>> task.shell("hostname", nodes="bar") # line: 11
>>> task.run() # line: 12
>>> task = task_self() # line: 7
>>> worker = WorkerSsh("node[2-3]", None, 10, command="/bin/ls") # line: 8
>>> task.schedule(worker) # line: 9
>>> task.resume() # line: 10
>>> task.set_info('fanout', 128) # line: 7
>>> task.set_info('debug', True) # line: 10
>>> task = task_self() # line: 37
>>> task.shell("/bin/date", nodes="node[1-2345]") # line: 38
>>> task.resume() # line: 39
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> rset = RangeSet() # empty RangeSet # line: 8
>>> rset = RangeSet("5,10-42") # contains '5', '10' to '42' # line: 9
>>> rset = RangeSet("0-10/2") # contains '0', '2', '4', '6', '8', '10' # line: 10
>>> rset = RangeSet("00-10/2") # contains '00', '02', '04', '06', '08', '10' # line: 11
>>> RangeSet([3, 6, 8, 7, 1]) # line: 15
>>> rset2 = RangeSet(rset) # line: 17
>>> RangeSet("1-5").split(3) # line: 6
>>> from ClusterShell.Defaults import DEFAULTS # line: 33
>>> from ClusterShell.Task import task_self # line: 34
>>> # Change default distant worker to rsh (WorkerRsh) # line: 35
... DEFAULTS.distant_workername = 'rsh'
>>> task = task_self() # line: 37
>>> task.run("uname -r", nodes="cs[01-03]") # line: 38
>>> list((str(msg), nodes) for msg, nodes in task.iter_buffers()) # line: 40
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> worker.set_reader('stream1', fd1) # line: 8
>>> worker.set_writer('stream2', fd2) # line: 9
>>> msgtree.remove(lambda k: k > 3) # line: 5
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> nsb = NodeSetBase('node%s-ipmi', RangeSet('1-5,7'), False) # line: 12
>>> str(nsb) # line: 13
>>> nsb = NodeSetBase('node%s-ib%s', RangeSetND([['1-5,7', '1-2']]), False) # line: 15
>>> str(nsb) # line: 16
>>> rset = RangeSet() # empty RangeSet # line: 8
>>> rset = RangeSet("5,10-42") # contains '5', '10' to '42' # line: 9
>>> rset = RangeSet("0-10/2") # contains '0', '2', '4', '6', '8', '10' # line: 10
>>> rset = RangeSet("00-10/2") # contains '00', '02', '04', '06', '08', '10' # line: 11
>>> RangeSet([3, 6, 8, 7, 1]) # line: 15
>>> rset2 = RangeSet(rset) # line: 17
>>> RangeSet("1-5").split(3) # line: 6
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> rset = RangeSet() # empty RangeSet # line: 8
>>> rset = RangeSet("5,10-42") # contains '5', '10' to '42' # line: 9
>>> rset = RangeSet("0-10/2") # contains '0', '2', '4', '6', '8', '10' # line: 10
>>> rset = RangeSet("00-10/2") # contains '00', '02', '04', '06', '08', '10' # line: 11
>>> RangeSet([3, 6, 8, 7, 1]) # line: 15
>>> rset2 = RangeSet(rset) # line: 17
>>> RangeSet("1-5").split(3) # line: 6
>>> msgtree.remove(lambda k: k > 3) # line: 5
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> task = task_self() # line: 13
>>> task = Task() # line: 17
>>> task = Task(thread=thr) # line: 22
>>> task.shell("/bin/hostname") # line: 26
>>> task.shell("/bin/hostname", nodes="tiger[1-20]") # line: 30
>>> task.shell("uname -r", nodes="node[1-9]", handler=MyEventHandler()) # line: 39
>>> task.resume() # line: 44
>>> task.run() # line: 48
>>> task.run("hostname", nodes="tiger[1-20]", handler=MyEventHandler()) # line: 53
>>> task.run("check_network.sh", nodes="tiger[1-20]", timeout=30) # line: 61
>>> for buffer, nodelist in task.iter_buffers(): # line: 10
... print NodeSet.fromlist(nodelist)
... print buffer
>>> task.run("hostname", nodes="foo") # line: 5
>>> task.shell("hostname", nodes="foo") # line: 10
>>> task.shell("hostname", nodes="bar") # line: 11
>>> task.run() # line: 12
>>> task = task_self() # line: 7
>>> worker = WorkerSsh("node[2-3]", None, 10, command="/bin/ls") # line: 8
>>> task.schedule(worker) # line: 9
>>> task.resume() # line: 10
>>> task.set_info('fanout', 128) # line: 7
>>> task.set_info('debug', True) # line: 10
>>> task = task_self() # line: 37
>>> task.shell("/bin/date", nodes="node[1-2345]") # line: 38
>>> task.resume() # line: 39
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> worker = WorkerPopen("/bin/uname", key="mykernel") # line: 6
>>> task.schedule(worker) # schedule worker # line: 7
>>> task.resume() # run task # line: 8
>>> worker.retcode() # get return code # line: 9
>>> worker.read() # read command output # line: 11
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> worker = WorkerPdsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerPdsh(nodeset, handler=MyEventHandler(), # line: 10
... timeout=30, source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = WorkerPdsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerPdsh(nodeset, handler=MyEventHandler(), # line: 10
... timeout=30, source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> worker = WorkerRsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerRsh(nodeset, handler=MyEventHandler(), # line: 10
... source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = WorkerRsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerRsh(nodeset, handler=MyEventHandler(), # line: 10
... source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> worker = WorkerSsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerSsh(nodeset, handler=MyEventHandler(), # line: 10
... timeout=30, source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = WorkerSsh(nodeset, handler=MyEventHandler(), # line: 4
... timeout=30, command="/bin/hostname")
>>> task.schedule(worker) # schedule worker for execution # line: 6
>>> task.resume() # run # line: 7
>>> worker = WorkerSsh(nodeset, handler=MyEventHandler(), # line: 10
... timeout=30, source="/etc/my.conf",
... dest="/etc/my.conf")
>>> task.schedule(worker) # schedule worker for execution # line: 13
>>> task.resume() # run # line: 14
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 9
... timeout=30, command="/bin/uptime")
>>> task.schedule(worker) # schedule worker for execution # line: 11
>>> task.run() # run # line: 12
>>> worker = ExecWorker(nodeset, handler=MyEventHandler(), # line: 16
... source="/etc/my.cnf",
... dest="/etc/my.cnf.bak")
>>> task.schedule(worker) # schedule worker for execution # line: 19
>>> task.run() # run # line: 20
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> tempfile.mkstemp() # line: 11
>>> tempfile.mkdtemp(suffix=b'') # line: 13
>>> nodeset = NodeSet() # empty NodeSet # line: 5
>>> nodeset = NodeSet("cluster3") # contains only cluster3 # line: 6
>>> nodeset = NodeSet("cluster[5,10-42]") # line: 7
>>> nodeset = NodeSet("cluster[0-10/2]") # line: 8
>>> nodeset = NodeSet("cluster[0-10/2],othername[7-9,120-300]") # line: 9
>>> nodeset = NodeSet("blue[1-50]") # line: 18
>>> nodeset.remove("blue[36-40]") # line: 19
>>> print nodeset # line: 20
>>> nodeset = NodeSet("node[0-10],node[14-16]") # union # line: 31
>>> nodeset = NodeSet("node[0-10]!node[8-10]") # difference # line: 32
>>> nodeset = NodeSet("node[0-10]&node[5-13]") # intersection # line: 33
>>> nodeset = NodeSet("node[0-10]^node[5-13]") # xor # line: 34
>>> for nodeset in NodeSet("foo[1-5]").split(3): # line: 5
... print nodeset
>>> worker.set_reader('stream1', fd1) # line: 8
>>> worker.set_writer('stream2', fd2) # line: 9
>>> from ClusterShell.Event import EventHandler # line: 18
>>> class MyOutputHandler(EventHandler): # line: 19
... def ev_read(self, worker, node, sname, msg):
... print "%s: %s" % (node, line) |
For future reference, this is the script I wrote to generate that list, in case it's useful to anybody (credit to Bing AI for writing the initial draft) import doctest
import inspect
import importlib
import pkgutil
import ClusterShell
def get_docstrings(module):
result = {}
def store(name, val):
if val:
result[name] = val
for name, obj in inspect.getmembers(module):
if inspect.isclass(obj) or inspect.isfunction(obj) or inspect.ismodule(obj):
store(f"{module.__name__}.{name}", get_examples(module.__name__, name, obj.__doc__))
if inspect.isclass(obj):
for method_name, method_obj in inspect.getmembers(obj):
if inspect.isfunction(method_obj):
store(f"{module.__name__}.{name}.{method_name}", get_examples(module.__name__, f'{name}.{method_name}', method_obj.__doc__))
if hasattr(module, '__path__'):
for _, submodule_name, _ in pkgutil.iter_modules(module.__path__):
result.update(get_docstrings(importlib.import_module(f'{module.__name__}.{submodule_name}')))
return result
def get_examples(module_name, obj_name, docstring):
if docstring:
return doctest.DocTestParser().get_examples(docstring)
def print_examples(examples):
source_width = max(max(len(line) for line in ex.source.splitlines())
for ex in examples)
for ex in examples:
for i, line in enumerate(ex.source.splitlines()):
if i == 0:
print(">>>", line.ljust(source_width), "# line:", ex.lineno)
else:
print("...", line)
def main():
docstrings = get_docstrings(ClusterShell)
for name, examples in docstrings.items():
print(f"- [ ] `{name}`")
print("```python")
print_examples(examples)
print("```")
if __name__ == "__main__":
main() |
There are a lot of Python 2 code examples in the docs. A search for
"print "
(note the trailing space) finds 29 matching files, some of which are not offenders, but many are, includingREADME.md
. Presumably there are other issues as well, but that's the easy one to search.I can make a pull request with fixes, but I need some info. I see Python 2.7 is still listed as supported, so presumably the examples should be Python 2/3 cross-compatible? Are there any other requirements?
The text was updated successfully, but these errors were encountered: