mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-24 03:29:28 +01:00
wrapArguments: add a max_args_per_line option (#253)
This commit is contained in:
parent
4147af6546
commit
702ba84956
4
utils.py
4
utils.py
@ -480,7 +480,7 @@ def unregisterService(name):
|
|||||||
|
|
||||||
del world.services[name]
|
del world.services[name]
|
||||||
|
|
||||||
def wrapArguments(prefix, args, length, separator=' '):
|
def wrapArguments(prefix, args, length, separator=' ', max_args_per_line=0):
|
||||||
"""
|
"""
|
||||||
Takes a static prefix and a list of arguments, and returns a list of strings
|
Takes a static prefix and a list of arguments, and returns a list of strings
|
||||||
with the arguments wrapped across multiple lines. This is useful for breaking up
|
with the arguments wrapped across multiple lines. This is useful for breaking up
|
||||||
@ -499,7 +499,7 @@ def wrapArguments(prefix, args, length, separator=' '):
|
|||||||
"wrapArguments: Argument %r is too long for the given length %s" % (args[0], length)
|
"wrapArguments: Argument %r is too long for the given length %s" % (args[0], length)
|
||||||
|
|
||||||
# Add arguments until our buffer is up to the length limit.
|
# Add arguments until our buffer is up to the length limit.
|
||||||
if (len(buf + args[0]) + 1) <= length:
|
if (len(buf + args[0]) + 1) <= length and ((not max_args_per_line) or len(buf.split(' ')) < max_args_per_line):
|
||||||
if buf != prefix: # Only add a separator if this isn't the first argument of a line
|
if buf != prefix: # Only add a separator if this isn't the first argument of a line
|
||||||
buf += separator
|
buf += separator
|
||||||
buf += args.pop(0)
|
buf += args.pop(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user