diff options
| -rw-r--r-- | libmproxy/console.py | 4 | ||||
| -rw-r--r-- | libmproxy/contrib/pyparsing.py | 44 | ||||
| -rw-r--r-- | libmproxy/filt.py | 6 | ||||
| -rw-r--r-- | libmproxy/flow.py | 6 | ||||
| -rw-r--r-- | libmproxy/utils.py | 4 | ||||
| -rw-r--r-- | libmproxy/version.py | 2 | 
6 files changed, 33 insertions, 33 deletions
| diff --git a/libmproxy/console.py b/libmproxy/console.py index c3a2831c..052ed61e 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -347,7 +347,7 @@ class ConnectionView(WWrap):              return self.master._cached_conn_text(                          e,                          conn.content, -                        tuple([tuple(i) for i in conn.headers.lst]), +                        tuple(tuple(i) for i in conn.headers.lst),                          viewmode                      )          else: @@ -1542,7 +1542,7 @@ class ConsoleMaster(flow.FlowMaster):                  mkup.append(",")          prompt.extend(mkup)          prompt.append(")? ") -        self.onekey = "".join([i[1] for i in keys]) +        self.onekey = "".join(i[1] for i in keys)          self.prompt(prompt, "", callback, *args)      def prompt_done(self): diff --git a/libmproxy/contrib/pyparsing.py b/libmproxy/contrib/pyparsing.py index 06b11d98..e0457f15 100644 --- a/libmproxy/contrib/pyparsing.py +++ b/libmproxy/contrib/pyparsing.py @@ -137,7 +137,7 @@ else:  if not _PY3K:
  	def _str2dict(strg):
 -	    return dict( [(c,0) for c in strg] )
 +	    return dict((c,0) for c in strg)
  else:
  	_str2dict = set
 @@ -162,7 +162,7 @@ nums       = string.digits  hexnums    = nums + "ABCDEFabcdef"
  alphanums  = alphas + nums
  _bslash = chr(92)
 -printables = "".join( [ c for c in string.printable if c not in string.whitespace ] )
 +printables = "".join(c for c in string.printable if c not in string.whitespace)
  class ParseBaseException(Exception):
      """base exception class for all parsing runtime exceptions"""
 @@ -205,8 +205,8 @@ class ParseBaseException(Exception):          line_str = self.line
          line_column = self.column - 1
          if markerString:
 -            line_str = "".join( [line_str[:line_column],
 -                                markerString, line_str[line_column:]])
 +            line_str = "".join(line_str[:line_column],
 +                                markerString, line_str[line_column:])
          return line_str.strip()
      def __dir__(self):
          return "loc msg pstr parserElement lineno col line " \
 @@ -488,8 +488,8 @@ class ParseResults(object):          """Returns the parse results as XML. Tags are created for tokens and lists that have defined results names."""
          nl = "\n"
          out = []
 -        namedItems = dict( [ (v[1],k) for (k,vlist) in self.__tokdict.items()
 -                                                            for v in vlist ] )
 +        namedItems = dict((v[1],k) for (k,vlist) in self.__tokdict.items()
 +                                                            for v in vlist)
          nextLevelIndent = indent + "  "
          # collapse out indents if formatting is not desired
 @@ -1848,9 +1848,9 @@ class QuotedString(Token):                    (escChar is not None and _escapeRegexRangeChars(escChar) or '') )
          if len(self.endQuoteChar) > 1:
              self.pattern += (
 -                '|(?:' + ')|(?:'.join(["%s[^%s]" % (re.escape(self.endQuoteChar[:i]),
 +                '|(?:' + ')|(?:'.join("%s[^%s]" % (re.escape(self.endQuoteChar[:i]),
                                                 _escapeRegexRangeChars(self.endQuoteChar[i]))
 -                                    for i in range(len(self.endQuoteChar)-1,0,-1)]) + ')'
 +                                    for i in range(len(self.endQuoteChar)-1,0,-1)) + ')'
                  )
          if escQuote:
              self.pattern += (r'|(?:%s)' % re.escape(escQuote))
 @@ -1999,9 +1999,9 @@ class White(Token):      def __init__(self, ws=" \t\r\n", min=1, max=0, exact=0):
          super(White,self).__init__()
          self.matchWhite = ws
 -        self.setWhitespaceChars( "".join([c for c in self.whiteChars if c not in self.matchWhite]) )
 +        self.setWhitespaceChars( "".join(c for c in self.whiteChars if c not in self.matchWhite) )
          #~ self.leaveWhitespace()
 -        self.name = ("".join([White.whiteStrs[c] for c in self.matchWhite]))
 +        self.name = ("".join(White.whiteStrs[c] for c in self.matchWhite))
          self.mayReturnEmpty = True
          self.errmsg = "Expected " + self.name
          #self.myException.msg = self.errmsg
 @@ -2371,7 +2371,7 @@ class And(ParseExpression):              return self.name
          if self.strRepr is None:
 -            self.strRepr = "{" + " ".join( [ _ustr(e) for e in self.exprs ] ) + "}"
 +            self.strRepr = "{" + " ".join(_ustr(e) for e in self.exprs) + "}"
          return self.strRepr
 @@ -2427,7 +2427,7 @@ class Or(ParseExpression):              return self.name
          if self.strRepr is None:
 -            self.strRepr = "{" + " ^ ".join( [ _ustr(e) for e in self.exprs ] ) + "}"
 +            self.strRepr = "{" + " ^ ".join(_ustr(e) for e in self.exprs) + "}"
          return self.strRepr
 @@ -2486,7 +2486,7 @@ class MatchFirst(ParseExpression):              return self.name
          if self.strRepr is None:
 -            self.strRepr = "{" + " | ".join( [ _ustr(e) for e in self.exprs ] ) + "}"
 +            self.strRepr = "{" + " | ".join(_ustr(e) for e in self.exprs) + "}"
          return self.strRepr
 @@ -2543,7 +2543,7 @@ class Each(ParseExpression):                  keepMatching = False
          if tmpReqd:
 -            missing = ", ".join( [ _ustr(e) for e in tmpReqd ] )
 +            missing = ", ".join(_ustr(e) for e in tmpReqd)
              raise ParseException(instring,loc,"Missing one or more required elements (%s)" % missing )
          # add any unmatched Optionals, in case they have default values defined
 @@ -2572,7 +2572,7 @@ class Each(ParseExpression):              return self.name
          if self.strRepr is None:
 -            self.strRepr = "{" + " & ".join( [ _ustr(e) for e in self.exprs ] ) + "}"
 +            self.strRepr = "{" + " & ".join(_ustr(e) for e in self.exprs) + "}"
          return self.strRepr
 @@ -3242,9 +3242,9 @@ def oneOf( strs, caseless=False, useRegex=True ):          #~ print (strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in symbols] ))
          try:
              if len(symbols)==len("".join(symbols)):
 -                return Regex( "[%s]" % "".join( [ _escapeRegexRangeChars(sym) for sym in symbols] ) )
 +                return Regex( "[%s]" % "".join(_escapeRegexRangeChars(sym) for sym in symbols) )
              else:
 -                return Regex( "|".join( [ re.escape(sym) for sym in symbols] ) )
 +                return Regex( "|".join(re.escape(sym) for sym in symbols) )
          except:
              warnings.warn("Exception creating Regex for oneOf, building MatchFirst",
                      SyntaxWarning, stacklevel=2)
 @@ -3298,14 +3298,14 @@ stringStart = StringStart().setName("stringStart")  stringEnd   = StringEnd().setName("stringEnd")
  _escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1])
 -_printables_less_backslash = "".join([ c for c in printables if c not in  r"\]" ])
 +_printables_less_backslash = "".join(c for c in printables if c not in  r"\]")
  _escapedHexChar = Combine( Suppress(_bslash + "0x") + Word(hexnums) ).setParseAction(lambda s,l,t:unichr(int(t[0],16)))
  _escapedOctChar = Combine( Suppress(_bslash) + Word("0","01234567") ).setParseAction(lambda s,l,t:unichr(int(t[0],8)))
  _singleChar = _escapedPunc | _escapedHexChar | _escapedOctChar | Word(_printables_less_backslash,exact=1)
  _charRange = Group(_singleChar + Suppress("-") + _singleChar)
  _reBracketExpr = Literal("[") + Optional("^").setResultsName("negate") + Group( OneOrMore( _charRange | _singleChar ) ).setResultsName("body") + "]"
 -_expanded = lambda p: (isinstance(p,ParseResults) and ''.join([ unichr(c) for c in range(ord(p[0]),ord(p[1])+1) ]) or p)
 +_expanded = lambda p: (isinstance(p,ParseResults) and ''.join(unichr(c) for c in range(ord(p[0]),ord(p[1])+1)) or p)
  def srange(s):
      r"""Helper to easily define string ranges for use in Word construction.  Borrows
 @@ -3324,7 +3324,7 @@ def srange(s):            any combination of the above ('aeiouy', 'a-zA-Z0-9_$', etc.)
      """
      try:
 -        return "".join([_expanded(part) for part in _reBracketExpr.parseString(s).body])
 +        return "".join(_expanded(part) for part in _reBracketExpr.parseString(s).body)
      except:
          return ""
 @@ -3402,7 +3402,7 @@ def _makeTags(tagStr, xml):                  Dict(ZeroOrMore(Group( tagAttrName + Suppress("=") + tagAttrValue ))) + \
                  Optional("/",default=[False]).setResultsName("empty").setParseAction(lambda s,l,t:t[0]=='/') + Suppress(">")
      else:
 -        printablesLessRAbrack = "".join( [ c for c in printables if c not in ">" ] )
 +        printablesLessRAbrack = "".join(c for c in printables if c not in ">")
          tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printablesLessRAbrack)
          openTag = Suppress("<") + tagStr + \
                  Dict(ZeroOrMore(Group( tagAttrName.setParseAction(downcaseTokens) + \
 @@ -3656,7 +3656,7 @@ cppStyleComment = Regex(r"/(?:\*(?:[^*]*\*+)+?/|/[^\n]*(?:\n[^\n]*)*?(?:(?<!\\)|  javaStyleComment = cppStyleComment
  pythonStyleComment = Regex(r"#.*").setName("Python style comment")
 -_noncomma = "".join( [ c for c in printables if c != "," ] )
 +_noncomma = "".join(c for c in printables if c != ",")
  _commasepitem = Combine(OneOrMore(Word(_noncomma) +
                                    Optional( Word(" \t") +
                                              ~Literal(",") + ~LineEnd() ) ) ).streamline().setName("commaItem")
 diff --git a/libmproxy/filt.py b/libmproxy/filt.py index d4efaf05..bf7d20c1 100644 --- a/libmproxy/filt.py +++ b/libmproxy/filt.py @@ -222,7 +222,7 @@ class FAnd(_Token):              i.dump(indent+1, fp)      def __call__(self, o): -        return all([i(o) for i in self.lst]) +        return all(i(o) for i in self.lst)  class FOr(_Token): @@ -235,7 +235,7 @@ class FOr(_Token):              i.dump(indent+1, fp)      def __call__(self, o): -        return any([i(o) for i in self.lst]) +        return any(i(o) for i in self.lst)  class FNot(_Token): @@ -277,7 +277,7 @@ def _make():          f.setParseAction(klass.make)          parts.append(f) -    simplerex = "".join([c for c in pp.printables if c not in  "()~'\""]) +    simplerex = "".join(c for c in pp.printables if c not in  "()~'\"")      rex = pp.Word(simplerex) |\            pp.QuotedString("\"", escChar='\\') |\            pp.QuotedString("'", escChar='\\') diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 23a88cba..214ce8f9 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -234,9 +234,9 @@ class Request(HTTPMsg):              decode appropriately.          """          if self.headers["accept-encoding"]: -            self.headers["accept-encoding"] = [', '.join([ +            self.headers["accept-encoding"] = [', '.join(                  e for e in encoding.ENCODINGS if e in self.headers["accept-encoding"][0] -            ])] +            )]      def _set_replay(self):          self.client_conn = None @@ -704,7 +704,7 @@ class ServerPlaybackState:                  l.append(i)      def count(self): -        return sum([len(i) for i in self.fmap.values()]) +        return sum(len(i) for i in self.fmap.values())      def _hash(self, flow):          """ diff --git a/libmproxy/utils.py b/libmproxy/utils.py index 1c34b2fb..ecf77263 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -135,10 +135,10 @@ def hexdump(s):      for i in range(0, len(s), 16):          o = "%.10x"%i          part = s[i:i+16] -        x = " ".join(["%.2x"%ord(i) for i in part]) +        x = " ".join("%.2x"%ord(i) for i in part)          if len(part) < 16:              x += " " -            x += " ".join(["  " for i in range(16-len(part))]) +            x += " ".join("  " for i in range(16 - len(part)))          parts.append(              (o, x, cleanBin(part))          ) diff --git a/libmproxy/version.py b/libmproxy/version.py index 5a87f339..95a48b67 100644 --- a/libmproxy/version.py +++ b/libmproxy/version.py @@ -1,2 +1,2 @@  IVERSION = (0, 6) -VERSION = ".".join([str(i) for i in IVERSION]) +VERSION = ".".join(str(i) for i in IVERSION) | 
