diff options
author | Miro Hron?ok <miro@hroncok.cz> | 2018-07-04 18:31:40 +0200 |
---|---|---|
committer | Miro Hron?ok <miro@hroncok.cz> | 2018-07-04 18:31:40 +0200 |
commit | b909c279a4cf4a93c5244e2c3046d769ba737dc0 (patch) | |
tree | f50663695ed1746a6e1d704e92e805f2c760c0f1 /pygments/lexers/sql.py | |
parent | 5927c118d3556f19199fe502c0ffcc8584652518 (diff) | |
download | pygments-b909c279a4cf4a93c5244e2c3046d769ba737dc0.tar.gz |
Be more Pythonic, use a for instead of while 1: try: next
Diffstat (limited to 'pygments/lexers/sql.py')
-rw-r--r-- | pygments/lexers/sql.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/pygments/lexers/sql.py b/pygments/lexers/sql.py index 05af51ba..3f7dfdb8 100644 --- a/pygments/lexers/sql.py +++ b/pygments/lexers/sql.py @@ -308,14 +308,7 @@ class PostgresConsoleLexer(Lexer): # and continue until the end of command is detected curcode = '' insertions = [] - while 1: - try: - line = next(lines) - except StopIteration: - # allow the emission of partially collected items - # the repl loop will be broken below - break - + for line in lines: # Identify a shell prompt in case of psql commandline example if line.startswith('$') and not curcode: lexer = get_lexer_by_name('console', **self.options) @@ -346,11 +339,7 @@ class PostgresConsoleLexer(Lexer): # Emit the output lines out_token = Generic.Output - while 1: - try: - line = next(lines) - except StopIteration: - return + for line in lines: mprompt = re_prompt.match(line) if mprompt is not None: # push the line back to have it processed by the prompt @@ -366,6 +355,8 @@ class PostgresConsoleLexer(Lexer): yield (mmsg.start(2), out_token, mmsg.group(2)) else: yield (0, out_token, line) + else: + return class SqlLexer(RegexLexer): |