Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: third_party/coverage-3.7.1/coverage/config.py

Issue 225633007: Upgrade to coverage 3.7.1 and have it auto-build itself on first use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: sigh our imports are a mess Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 """Config file for coverage.py""" 1 """Config file for coverage.py"""
2 2
3 import os, re, sys 3 import os, re, sys
4 from coverage.backward import string_class, iitems 4 from coverage.backward import string_class, iitems
5 5
6 # In py3, # ConfigParser was renamed to the more-standard configparser 6 # In py3, # ConfigParser was renamed to the more-standard configparser
7 try: 7 try:
8 import configparser # pylint: disable=F0401 8 import configparser # pylint: disable=F0401
9 except ImportError: 9 except ImportError:
10 import ConfigParser as configparser 10 import ConfigParser as configparser
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 self.attempted_config_files = [] 104 self.attempted_config_files = []
105 self.config_files = [] 105 self.config_files = []
106 106
107 # Defaults for [run] 107 # Defaults for [run]
108 self.branch = False 108 self.branch = False
109 self.cover_pylib = False 109 self.cover_pylib = False
110 self.data_file = ".coverage" 110 self.data_file = ".coverage"
111 self.parallel = False 111 self.parallel = False
112 self.timid = False 112 self.timid = False
113 self.source = None 113 self.source = None
114 self.debug = []
114 115
115 # Defaults for [report] 116 # Defaults for [report]
116 self.exclude_list = DEFAULT_EXCLUDE[:] 117 self.exclude_list = DEFAULT_EXCLUDE[:]
117 self.ignore_errors = False 118 self.ignore_errors = False
118 self.include = None 119 self.include = None
119 self.omit = None 120 self.omit = None
120 self.partial_list = DEFAULT_PARTIAL[:] 121 self.partial_list = DEFAULT_PARTIAL[:]
121 self.partial_always_list = DEFAULT_PARTIAL_ALWAYS[:] 122 self.partial_always_list = DEFAULT_PARTIAL_ALWAYS[:]
122 self.precision = 0 123 self.precision = 0
123 self.show_missing = False 124 self.show_missing = False
(...skipping 11 matching lines...) Expand all
135 136
136 def from_environment(self, env_var): 137 def from_environment(self, env_var):
137 """Read configuration from the `env_var` environment variable.""" 138 """Read configuration from the `env_var` environment variable."""
138 # Timidity: for nose users, read an environment variable. This is a 139 # Timidity: for nose users, read an environment variable. This is a
139 # cheap hack, since the rest of the command line arguments aren't 140 # cheap hack, since the rest of the command line arguments aren't
140 # recognized, but it solves some users' problems. 141 # recognized, but it solves some users' problems.
141 env = os.environ.get(env_var, '') 142 env = os.environ.get(env_var, '')
142 if env: 143 if env:
143 self.timid = ('--timid' in env) 144 self.timid = ('--timid' in env)
144 145
145 MUST_BE_LIST = ["omit", "include"] 146 MUST_BE_LIST = ["omit", "include", "debug"]
146 147
147 def from_args(self, **kwargs): 148 def from_args(self, **kwargs):
148 """Read config values from `kwargs`.""" 149 """Read config values from `kwargs`."""
149 for k, v in iitems(kwargs): 150 for k, v in iitems(kwargs):
150 if v is not None: 151 if v is not None:
151 if k in self.MUST_BE_LIST and isinstance(v, string_class): 152 if k in self.MUST_BE_LIST and isinstance(v, string_class):
152 v = [v] 153 v = [v]
153 setattr(self, k, v) 154 setattr(self, k, v)
154 155
155 def from_file(self, filename): 156 def from_file(self, filename):
(...skipping 15 matching lines...) Expand all
171 # [paths] is special 172 # [paths] is special
172 if cp.has_section('paths'): 173 if cp.has_section('paths'):
173 for option in cp.options('paths'): 174 for option in cp.options('paths'):
174 self.paths[option] = cp.getlist('paths', option) 175 self.paths[option] = cp.getlist('paths', option)
175 176
176 CONFIG_FILE_OPTIONS = [ 177 CONFIG_FILE_OPTIONS = [
177 # [run] 178 # [run]
178 ('branch', 'run:branch', 'boolean'), 179 ('branch', 'run:branch', 'boolean'),
179 ('cover_pylib', 'run:cover_pylib', 'boolean'), 180 ('cover_pylib', 'run:cover_pylib', 'boolean'),
180 ('data_file', 'run:data_file'), 181 ('data_file', 'run:data_file'),
182 ('debug', 'run:debug', 'list'),
181 ('include', 'run:include', 'list'), 183 ('include', 'run:include', 'list'),
182 ('omit', 'run:omit', 'list'), 184 ('omit', 'run:omit', 'list'),
183 ('parallel', 'run:parallel', 'boolean'), 185 ('parallel', 'run:parallel', 'boolean'),
184 ('source', 'run:source', 'list'), 186 ('source', 'run:source', 'list'),
185 ('timid', 'run:timid', 'boolean'), 187 ('timid', 'run:timid', 'boolean'),
186 188
187 # [report] 189 # [report]
188 ('exclude_list', 'report:exclude_lines', 'linelist'), 190 ('exclude_list', 'report:exclude_lines', 'linelist'),
189 ('ignore_errors', 'report:ignore_errors', 'boolean'), 191 ('ignore_errors', 'report:ignore_errors', 'boolean'),
190 ('include', 'report:include', 'list'), 192 ('include', 'report:include', 'list'),
(...skipping 11 matching lines...) Expand all
202 # [xml] 204 # [xml]
203 ('xml_output', 'xml:output'), 205 ('xml_output', 'xml:output'),
204 ] 206 ]
205 207
206 def set_attr_from_config_option(self, cp, attr, where, type_=''): 208 def set_attr_from_config_option(self, cp, attr, where, type_=''):
207 """Set an attribute on self if it exists in the ConfigParser.""" 209 """Set an attribute on self if it exists in the ConfigParser."""
208 section, option = where.split(":") 210 section, option = where.split(":")
209 if cp.has_option(section, option): 211 if cp.has_option(section, option):
210 method = getattr(cp, 'get'+type_) 212 method = getattr(cp, 'get'+type_)
211 setattr(self, attr, method(section, option)) 213 setattr(self, attr, method(section, option))
OLDNEW
« no previous file with comments | « third_party/coverage-3.7.1/coverage/collector.py ('k') | third_party/coverage-3.7.1/coverage/control.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698