MCPcopy Create free account
hub / github.com/sqlmapproject/sqlmap / NavigableString

Class NavigableString

thirdparty/beautifulsoup/beautifulsoup.py:461–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459
460
461class NavigableString(text_type, PageElement):
462
463 def __new__(cls, value):
464 """Create a new NavigableString.
465
466 When unpickling a NavigableString, this method is called with
467 the string in DEFAULT_OUTPUT_ENCODING. That encoding needs to be
468 passed in to the superclass's __new__ or the superclass won't know
469 how to handle non-ASCII characters.
470 """
471 if isinstance(value, text_type):
472 return text_type.__new__(cls, value)
473 return text_type.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)
474
475 def __getnewargs__(self):
476 return (NavigableString.__str__(self),)
477
478 def __getattr__(self, attr):
479 """text.string gives you text. This is for backwards
480 compatibility for Navigable*String, but for CData* it lets you
481 get the string without the CData wrapper."""
482 if attr == 'string':
483 return self
484 else:
485 raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, attr))
486
487 def __unicode__(self):
488 return str(self).decode(DEFAULT_OUTPUT_ENCODING)
489
490 def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING):
491 # Substitute outgoing XML entities.
492 data = self.BARE_AMPERSAND_OR_BRACKET.sub(self._sub_entity, self)
493 if encoding:
494 return data.encode(encoding)
495 else:
496 return data
497
498class CData(NavigableString):
499

Callers 1

insertMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…