Skip to content

yex.parse.StringSource

yex.parse.StringSource(string, name=None) #

Bases: yex.parse.source.Source

A source based on a string. We split the string into lines at linebreaks, which are whatever Python's str.splitlines() thinks they are. We replace them with a single carriage return (ASCII 13) at the end of each line, including the last line.

Attributes:

Name Type Description
string str

a string of characters.

Source code in yex/parse/source.py
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
def __init__(self,
        string,
        name = None):

    if name is None:
        name = string[:self._EXCERPT_LENGTH]
        if len(string)>self._EXCERPT_LENGTH:
            name += '…'
        name = repr(name.
                    replace('\n', '␊').
                    replace('\r', '␤')
                    )

    super().__init__(
            name = name,
            )
    self.string = string
    logger.debug("%s: string is: %s",
            self, string)