Advertisement
FichteFoll

Code Indentation is srs business

Jun 3rd, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. # compile regexps
  2. compile_tuple = ('match', 'test')
  3. reg_count = 0
  4. for reg in regs:
  5.     for key in compile_tuple:
  6.         if key in reg:
  7.             try:
  8.                 reg[key] = re.compile(reg[key])
  9.             except re.error as e:
  10.                 print(("\t[Error] regs[%d]%s:\n" +
  11.                        "\t        Unable to compile %r:\n" +
  12.                        "\t        [Errstr]: %s\n" +
  13.                        "\t        Removing...")
  14.                       % (reg_count
  15.                         , 'match' in reg
  16.                             and (
  17.                                 isinstance(reg['match'], str)
  18.                                     and " = `%s`" % reg['match']
  19.                                 or " = `%s`" % reg['match'].pattern
  20.                           ) or ''
  21.                         , key
  22.                         , e)
  23.                 )
  24.                 regs.remove(reg)
  25.                 reg_count_removed += 1
  26.     reg_count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement