MCPcopy Create free account
hub / github.com/ipython/ipython / has_open_quotes

Function has_open_quotes

IPython/core/completer.py:212–230  ·  view source on GitHub ↗

Return whether a string has open quotes. This simply counts whether the number of quote characters of either type in the string is odd. Returns ------- If there is an open quote, the quote character is returned. Else, return False.

(s)

Source from the content-addressed store, hash-verified

210
211
212def has_open_quotes(s):
213 """Return whether a string has open quotes.
214
215 This simply counts whether the number of quote characters of either type in
216 the string is odd.
217
218 Returns
219 -------
220 If there is an open quote, the quote character is returned. Else, return
221 False.
222 """
223 # We check " first, then ', so complex cases with nested quotes will get
224 # the " to take precedence.
225 if s.count('"') % 2:
226 return '"'
227 elif s.count("'") % 2:
228 return "'"
229 else:
230 return False
231
232
233def protect_filename(s, protectables=PROTECTABLES):

Callers 1

file_matchesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected