@@ -65,7 +65,7 @@ def extract_from_dir(dirname=None, method_map=DEFAULT_MAPPING,
65
65
"""Extract messages from any source files found in the given directory.
66
66
67
67
This function generates tuples of the form ``(filename, lineno, message,
68
- comments, context)``.
68
+ comments, context, flags )``.
69
69
70
70
Which extraction method is used per file is determined by the `method_map`
71
71
parameter, which maps extended glob patterns to extraction method names.
@@ -154,23 +154,23 @@ def extract_from_dir(dirname=None, method_map=DEFAULT_MAPPING,
154
154
options = odict
155
155
if callback :
156
156
callback (filename , method , options )
157
- for lineno , message , comments , context in \
157
+ for lineno , message , comments , context , flags in \
158
158
extract_from_file (method , filepath ,
159
159
keywords = keywords ,
160
160
comment_tags = comment_tags ,
161
161
options = options ,
162
162
strip_comment_tags =
163
163
strip_comment_tags ):
164
- yield filename , lineno , message , comments , context
164
+ yield filename , lineno , message , comments , context , flags
165
165
break
166
166
167
167
168
168
def extract_from_file (method , filename , keywords = DEFAULT_KEYWORDS ,
169
169
comment_tags = (), options = None , strip_comment_tags = False ):
170
170
"""Extract messages from a specific file.
171
171
172
- This function returns a list of tuples of the form ``(lineno, funcname,
173
- message )``.
172
+ This function returns a list of tuples of the form
173
+ ``(lineno, messages, comments, context, flags )``.
174
174
175
175
:param filename: the path to the file to extract messages from
176
176
:param method: a string specifying the extraction method (.e.g. "python")
@@ -197,7 +197,8 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
197
197
"""Extract messages from the given file-like object using the specified
198
198
extraction method.
199
199
200
- This function returns tuples of the form ``(lineno, message, comments)``.
200
+ This generator function yields tuples of the form
201
+ ``(lineno, messages, comments, context, flags)``.
201
202
202
203
The implementation dispatches the actual extraction to plugins, based on the
203
204
value of the ``method`` parameter.
@@ -210,7 +211,7 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
210
211
>>> from StringIO import StringIO
211
212
>>> for message in extract('python', StringIO(source)):
212
213
... print message
213
- (3, u'Hello, world!', [], None)
214
+ (3, u'Hello, world!', [], None, () )
214
215
215
216
:param method: a string specifying the extraction method (.e.g. "python");
216
217
if this is a simple name, the extraction function will be
@@ -261,10 +262,17 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
261
262
if func is None :
262
263
raise ValueError ('Unknown extraction method %r' % method )
263
264
264
- results = func (fileobj , keywords .keys (), comment_tags ,
265
- options = options or {})
265
+ for result in func (fileobj , keywords .keys (), comment_tags ,
266
+ options = options or {}):
267
+ flags = ()
268
+ if len (result ) == 4 :
269
+ lineno , funcname , messages , comments = result
270
+ elif len (result ) == 5 :
271
+ lineno , funcname , messages , comments , flags = result
272
+ else :
273
+ raise ValueError (
274
+ 'Extraction function must yield tuples with 4 or 5 values' )
266
275
267
- for lineno , funcname , messages , comments in results :
268
276
if funcname :
269
277
spec = keywords [funcname ] or (1 ,)
270
278
else :
@@ -315,7 +323,7 @@ def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
315
323
316
324
if strip_comment_tags :
317
325
_strip_comment_tags (comments , comment_tags )
318
- yield lineno , messages , comments , context
326
+ yield lineno , messages , comments , context , flags
319
327
320
328
321
329
def extract_nothing (fileobj , keywords , comment_tags , options ):
@@ -408,7 +416,7 @@ def extract_python(fileobj, keywords, comment_tags, options):
408
416
translator_comments = []
409
417
410
418
yield (message_lineno , funcname , messages ,
411
- [comment [1 ] for comment in translator_comments ])
419
+ [comment [1 ] for comment in translator_comments ], () )
412
420
413
421
funcname = lineno = message_lineno = None
414
422
call_stack = - 1
0 commit comments