The function replace all spaces in the input variable line which are surrounded with quotation marks, with the triplet "@_@". For instance, for the input "a 'b c'" the function returns "a 'b@_@c'" Parameters ---------- line : str Returns ------- str
(line)
| 1619 | |
| 1620 | |
| 1621 | def markinnerspaces(line): |
| 1622 | """ |
| 1623 | The function replace all spaces in the input variable line which are |
| 1624 | surrounded with quotation marks, with the triplet "@_@". |
| 1625 | |
| 1626 | For instance, for the input "a 'b c'" the function returns "a 'b@_@c'" |
| 1627 | |
| 1628 | Parameters |
| 1629 | ---------- |
| 1630 | line : str |
| 1631 | |
| 1632 | Returns |
| 1633 | ------- |
| 1634 | str |
| 1635 | |
| 1636 | """ |
| 1637 | fragment = '' |
| 1638 | inside = False |
| 1639 | current_quote = None |
| 1640 | escaped = '' |
| 1641 | for c in line: |
| 1642 | if escaped == '\\' and c in ['\\', '\'', '"']: |
| 1643 | fragment += c |
| 1644 | escaped = c |
| 1645 | continue |
| 1646 | if not inside and c in ['\'', '"']: |
| 1647 | current_quote = c |
| 1648 | if c == current_quote: |
| 1649 | inside = not inside |
| 1650 | elif c == ' ' and inside: |
| 1651 | fragment += '@_@' |
| 1652 | continue |
| 1653 | fragment += c |
| 1654 | escaped = c # reset to non-backslash |
| 1655 | return fragment |
| 1656 | |
| 1657 | |
| 1658 | def updatevars(typespec, selector, attrspec, entitydecl): |
no outgoing calls
searching dependent graphs…