@@ -152,7 +152,34 @@ def format_options(self, ctx, formatter):
152152 formatter .write_dl (sorted_records )
153153
154154
155- class EnhancedProgressBar (ProgressBar ):
155+ # overriden and copied from Click to work around Click woes for
156+ # https://github.com/nexB/scancode-toolkit/issues/2583
157+ class DebuggedProgressBar (ProgressBar ):
158+
159+ # overriden and copied from Click to work around Click woes for
160+ # https://github.com/nexB/scancode-toolkit/issues/2583
161+ def make_step (self , n_steps ):
162+ # always increment
163+ self .pos += n_steps or 1
164+ super (DebuggedProgressBar , self ).make_step (n_steps )
165+
166+ # overriden and copied from Click to work around Click woes for
167+ # https://github.com/nexB/scancode-toolkit/issues/2583
168+ def generator (self ):
169+ if self .is_hidden :
170+ yield from self .iter
171+ else :
172+ for rv in self .iter :
173+ self .current_item = rv
174+ self .update (1 )
175+ self .render_progress ()
176+ yield rv
177+
178+ self .finish ()
179+ self .render_progress ()
180+
181+
182+ class EnhancedProgressBar (DebuggedProgressBar ):
156183 """
157184 Enhanced progressbar ensuring that nothing is displayed when the bar is hidden.
158185 """
@@ -205,17 +232,29 @@ def render_finish(self):
205232BAR_SEP_LEN = len (' ' )
206233
207234
208- def progressmanager (iterable = None , length = None , label = None , show_eta = True ,
209- show_percent = None , show_pos = True , item_show_func = None ,
210- fill_char = '#' , empty_char = '-' , bar_template = None ,
211- info_sep = ' ' , width = BAR_WIDTH , file = None , color = None , # NOQA
212- verbose = False ):
213-
235+ def progressmanager (
236+ iterable = None ,
237+ length = None ,
238+ fill_char = '#' ,
239+ empty_char = '-' ,
240+ bar_template = None ,
241+ info_sep = ' ' ,
242+ show_eta = False ,
243+ show_percent = False ,
244+ show_pos = True ,
245+ item_show_func = None ,
246+ label = None ,
247+ file = None ,
248+ color = None , # NOQA
249+ update_min_steps = 0 ,
250+ width = BAR_WIDTH ,
251+ verbose = False ,
252+ ):
214253 """
215254 Return an iterable context manager showing progress as a progress bar
216255 (default) or item-by-item log (if verbose is True) while iterating.
217256
218- Its arguments are similar to Click.termui.progressbar with these new
257+ It's arguments are similar to Click.termui.progressbar with these new
219258 arguments added at the end of the signature:
220259
221260 :param verbose: if True, display a progress log. Otherwise, a progress bar.
@@ -224,14 +263,27 @@ def progressmanager(iterable=None, length=None, label=None, show_eta=True,
224263 progress_class = ProgressLogger
225264 else :
226265 progress_class = EnhancedProgressBar
227- bar_template = ('[%(bar)s]' + ' ' + '%(info)s'
228- if bar_template is None else bar_template )
229-
230- return progress_class (iterable = iterable , length = length ,
231- show_eta = show_eta , show_percent = show_percent , show_pos = show_pos ,
232- item_show_func = item_show_func , fill_char = fill_char ,
233- empty_char = empty_char , bar_template = bar_template , info_sep = info_sep ,
234- file = file , label = label , width = width , color = color )
266+ bar_template = (
267+ '[%(bar)s]' + ' ' + '%(info)s'
268+ if bar_template is None else bar_template
269+ )
270+ return progress_class (
271+ iterable = iterable ,
272+ length = length ,
273+ fill_char = fill_char ,
274+ empty_char = empty_char ,
275+ bar_template = bar_template ,
276+ info_sep = info_sep ,
277+ show_eta = show_eta ,
278+ show_percent = show_percent ,
279+ show_pos = show_pos ,
280+ item_show_func = item_show_func ,
281+ label = label ,
282+ file = file ,
283+ color = color ,
284+ update_min_steps = update_min_steps ,
285+ width = width ,
286+ )
235287
236288
237289def fixed_width_file_name (path , max_length = 25 ):
@@ -416,7 +468,6 @@ def get_help_record(self, ctx):
416468 return click .Option .get_help_record (self , ctx )
417469
418470
419-
420471def validate_option_dependencies (ctx ):
421472 """
422473 Validate all PluggableCommandLineOption dependencies in the `ctx` Click
0 commit comments