]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/fixes/fix_ws_comma.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / lib2to3 / fixes / fix_ws_comma.py
CommitLineData
4710c53d 1"""Fixer that changes 'a ,b' into 'a, b'.\r
2\r
3This also changes '{a :b}' into '{a: b}', but does not touch other\r
4uses of colons. It does not touch other uses of whitespace.\r
5\r
6"""\r
7\r
8from .. import pytree\r
9from ..pgen2 import token\r
10from .. import fixer_base\r
11\r
12class FixWsComma(fixer_base.BaseFix):\r
13\r
14 explicit = True # The user must ask for this fixers\r
15\r
16 PATTERN = """\r
17 any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]>\r
18 """\r
19\r
20 COMMA = pytree.Leaf(token.COMMA, u",")\r
21 COLON = pytree.Leaf(token.COLON, u":")\r
22 SEPS = (COMMA, COLON)\r
23\r
24 def transform(self, node, results):\r
25 new = node.clone()\r
26 comma = False\r
27 for child in new.children:\r
28 if child in self.SEPS:\r
29 prefix = child.prefix\r
30 if prefix.isspace() and u"\n" not in prefix:\r
31 child.prefix = u""\r
32 comma = True\r
33 else:\r
34 if comma:\r
35 prefix = child.prefix\r
36 if not prefix:\r
37 child.prefix = u" "\r
38 comma = False\r
39 return new\r