~twom/conn-check/port-not-none

« back to all changes in this revision

Viewing changes to conn_check/patterns.py

  • Committer: Ubuntu One Auto Copilot
  • Author(s): Tom Wardill
  • Date: 2018-01-29 17:50:39 UTC
  • mfrom: (136.1.13 lp-conn-check)
  • Revision ID: otto-copilot@canonical.com-20180129175039-8o50r3s02ib2knne
Port to python3 using futurize. Refactor to allow import and use as a library.

Merged from https://code.launchpad.net/~tom-howrandom/conn-check/py3k/+merge/336597

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from builtins import map
 
2
from builtins import object
1
3
import re
2
4
 
3
5
 
66
68
            end = "".join([")?" for c in chars])
67
69
            return (begin, end, end)
68
70
 
69
 
    subexprs = map(token_to_re, tokens)
 
71
    subexprs = list(map(token_to_re, tokens))
70
72
    if len(subexprs) > 0:
71
73
        # subexpressions like (.*)? aren't accepted, so we may have to use
72
74
        # an alternate closing form for the last (innermost) subexpression
87
89
        else:
88
90
            return re.escape(token)
89
91
 
90
 
    return re.compile("".join(map(token_to_re, tokens) + [r'\Z']))
 
92
    return re.compile("".join(list(map(token_to_re, tokens)) + [r'\Z']))
91
93
 
92
94
 
93
95
class SimplePattern(Pattern):