obspy.core.inventory.util.InventoryTextWrapper
- class InventoryTextWrapper(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, placeholder=' [...]')[source]
Bases:
TextWrapper
Attributes
Public Methods
Reformat the single paragraph in 'text' to fit in lines of no more than 'self.width' columns, and return a new string containing the entire wrapped paragraph. |
|
Reformat the single paragraph in 'text' so it fits in lines of no more than 'self.width' columns, and return a list of wrapped lines. |
Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
- InventoryTextWrapper._fix_sentence_endings(chunks: [string])
Correct for sentence endings buried in ‘chunks’. Eg. when the original text contains “… foo.nBar …”, munge_whitespace() and split() will convert that to […, “foo.”, “ “, “Bar”, …] which has one too few spaces; this method simply changes the one space to two.
- InventoryTextWrapper._handle_long_word(reversed_chunks, cur_line, cur_len, width)
- _handle_long_word(chunks[string],
cur_line : [string], cur_len : int, width : int)
Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line.
- InventoryTextWrapper._munge_whitespace(text: string) string
Munge whitespace in text: expand tabs and convert all other whitespace characters to spaces. Eg. “ footbarnnbaz” becomes “ foo bar baz”.
- InventoryTextWrapper._split(text: string) [string]
Split the text to wrap into indivisible chunks. Chunks are not quite the same as words; see _wrap_chunks() for full details. As an example, the text
Look, goof-ball – use the -b option!
- breaks into the following chunks:
‘Look,’, ‘ ‘, ‘goof-’, ‘ball’, ‘ ‘, ‘–’, ‘ ‘, ‘use’, ‘ ‘, ‘the’, ‘ ‘, ‘-b’, ‘ ‘, ‘option!’
- if break_on_hyphens is True, or in:
‘Look,’, ‘ ‘, ‘goof-ball’, ‘ ‘, ‘–’, ‘ ‘, ‘use’, ‘ ‘, ‘the’, ‘ ‘, ‘-b’, ‘ ‘, option!’
otherwise.
- InventoryTextWrapper._split_chunks(text)
Special Methods
- InventoryTextWrapper.__delattr__(name, /)
Implement delattr(self, name).
- InventoryTextWrapper.__dir__()
Default dir() implementation.
- InventoryTextWrapper.__eq__(value, /)
Return self==value.
- InventoryTextWrapper.__format__(format_spec, /)
Default object formatter.
- InventoryTextWrapper.__ge__(value, /)
Return self>=value.
- InventoryTextWrapper.__getattribute__(name, /)
Return getattr(self, name).
- InventoryTextWrapper.__gt__(value, /)
Return self>value.
- InventoryTextWrapper.__hash__()
Return hash(self).
- InventoryTextWrapper.__init__(width=70, initial_indent='', subsequent_indent='', expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True, drop_whitespace=True, break_on_hyphens=True, tabsize=8, *, max_lines=None, placeholder=' [...]')
- InventoryTextWrapper.__init_subclass__()
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- InventoryTextWrapper.__le__(value, /)
Return self<=value.
- InventoryTextWrapper.__lt__(value, /)
Return self<value.
- InventoryTextWrapper.__ne__(value, /)
Return self!=value.
- InventoryTextWrapper.__new__(**kwargs)
- InventoryTextWrapper.__reduce__()
Helper for pickle.
- InventoryTextWrapper.__reduce_ex__(protocol, /)
Helper for pickle.
- InventoryTextWrapper.__repr__()
Return repr(self).
- InventoryTextWrapper.__setattr__(name, value, /)
Implement setattr(self, name, value).
- InventoryTextWrapper.__sizeof__()
Size of object in memory, in bytes.
- InventoryTextWrapper.__str__()
Return str(self).
- InventoryTextWrapper.__subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).