1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 A 2to3 fixer that converts all string literals to use single quotes.
8 Strings that contain single quotes will not be modified. Prefixed string
9 literals will also not be modified. This affect double-quoted strings but
10 not triple-double-quote strings.
14 from lib2to3.fixer_base import BaseFix
15 from lib2to3.pgen2 import token
18 class FixSingleQuoteStrings(BaseFix):
21 _accept_type = token.STRING
23 def match(self, node):
24 res = node.value.startswith('"') and not node.value.startswith('"""') and "'" not in node.value[1:-1]
27 def transform(self, node, results):
28 node.value = node.value.replace('"', "'")