summaryrefslogtreecommitdiff
path: root/pygnulib/constants.py
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-07-29 16:35:28 +0200
committerBruno Haible <bruno@clisp.org>2022-07-29 16:35:28 +0200
commitf00ef30ee0a68bf91cfd081afc784cb8ffd00656 (patch)
tree4a03672a6e133c7a3bf309eeb2a676854222dece /pygnulib/constants.py
parent7d56b9e140fcabdbc944a65f18b9a0d5f6a4aabb (diff)
downloadgnulib-f00ef30ee0a68bf91cfd081afc784cb8ffd00656.tar.gz
gnulib-tool.py: Use mainstream coding style.
* gnulib-tool.py: Clarify the coding style. Fix some pycodestyle warnings. * pygnulib/constants.py: Likewise. * pygnulib/GLEmiter.py: Likewise. * pygnulib/GLImport.py: Likewise. * pygnulib/GLMakefileTable.py: Likewise.
Diffstat (limited to 'pygnulib/constants.py')
-rw-r--r--pygnulib/constants.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pygnulib/constants.py b/pygnulib/constants.py
index 39fe08f002..7b37a5241c 100644
--- a/pygnulib/constants.py
+++ b/pygnulib/constants.py
@@ -13,6 +13,7 @@ import sys
import platform
import tempfile
import subprocess as sp
+import __main__ as interpreter
#===============================================================================
@@ -68,7 +69,6 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
0123456789' # Alphanumeric characters
# Set ENCS dictionary
-import __main__ as interpreter
if not hasattr(interpreter, '__file__'):
if sys.stdout.encoding != None:
ENCS['default'] = sys.stdout.encoding
@@ -443,12 +443,14 @@ def remove_backslash_newline(text):
line to it.'''
return text.replace('\\\n', '')
+
def combine_lines(text):
'''Given a multiline string text, join lines by spaces:
When a line ends in a backslash, remove the backslash and join the next
line to it, inserting a space between them.'''
return text.replace('\\\n', ' ')
+
def combine_lines_matching(pattern, text):
'''Given a multiline string text, join lines by spaces, when the first
such line matches a given RegexObject pattern.
@@ -461,9 +463,9 @@ def combine_lines_matching(pattern, text):
while match:
(startpos, pos) = match.span()
# Look how far the continuation lines extend.
- pos = text.find('\n',pos)
- while pos > 0 and text[pos-1] == '\\':
- pos = text.find('\n',pos+1)
+ pos = text.find('\n', pos)
+ while pos > 0 and text[pos - 1] == '\\':
+ pos = text.find('\n', pos + 1)
if pos < 0:
pos = len(text)
# Perform a combine_lines throughout the continuation lines.