MCPcopy Create free account
hub / github.com/secdev/scapy / _prepare_quote

Function _prepare_quote

scapy/main.py:541–565  ·  view source on GitHub ↗

This function processes a quote and returns a string that is ready to be used in the fancy banner.

(quote, author, max_len=78)

Source from the content-addressed store, hash-verified

539
540
541def _prepare_quote(quote, author, max_len=78):
542 # type: (str, str, int) -> List[str]
543 """This function processes a quote and returns a string that is ready
544to be used in the fancy banner.
545
546 """
547 _quote = quote.split(' ')
548 max_len -= 6
549 lines = []
550 cur_line = [] # type: List[str]
551
552 def _len(line):
553 # type: (List[str]) -> int
554 return sum(len(elt) for elt in line) + len(line) - 1
555 while _quote:
556 if not cur_line or (_len(cur_line) + len(_quote[0]) - 1 <= max_len):
557 cur_line.append(_quote.pop(0))
558 continue
559 lines.append(' | %s' % ' '.join(cur_line))
560 cur_line = []
561 if cur_line:
562 lines.append(' | %s' % ' '.join(cur_line))
563 cur_line = []
564 lines.append(' | %s-- %s' % (" " * (max_len - len(author) - 5), author))
565 return lines
566
567
568def get_fancy_banner(mini: Optional[bool] = None) -> str:

Callers 1

get_fancy_bannerFunction · 0.85

Calls 4

popMethod · 0.80
joinMethod · 0.80
_lenFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…