MCPcopy Index your code
hub / github.com/bpython/bpython / current_string

Method current_string

bpython/repl.py:562–591  ·  view source on GitHub ↗

If the line ends in a string get it, otherwise return

(self, concatenate=False)

Source from the content-addressed store, hash-verified

560 self.interp.runsource(source, filename, "exec")
561
562 def current_string(self, concatenate=False):
563 """If the line ends in a string get it, otherwise return ''"""
564 tokens = self.tokenize(self.current_line)
565 string_tokens = list(
566 takewhile(
567 token_is_any_of([Token.String, Token.Text]), reversed(tokens)
568 )
569 )
570 if not string_tokens:
571 return ""
572 opening = string_tokens.pop()[1]
573 string = list()
574 for token, value in reversed(string_tokens):
575 if token is Token.Text:
576 continue
577 elif opening is None:
578 opening = value
579 elif token is Token.String.Doc:
580 string.append(value[3:-3])
581 opening = None
582 elif value == opening:
583 opening = None
584 if not concatenate:
585 string = list()
586 else:
587 string.append(value)
588
589 if opening is None:
590 return ""
591 return "".join(string)
592
593 def get_object(self, name: str) -> Any:
594 attributes = name.split(".")

Callers 4

tabMethod · 0.80
matchesMethod · 0.80
locateMethod · 0.80
test_current_stringMethod · 0.80

Calls 3

tokenizeMethod · 0.95
token_is_any_ofFunction · 0.85
appendMethod · 0.80

Tested by 1

test_current_stringMethod · 0.64