Add util.pretty_quantity() convenience function
				
					
				
			This commit is contained in:
		
							parent
							
								
									9884772882
								
							
						
					
					
						commit
						ad98038239
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		|  | @ -127,6 +127,18 @@ def prettify(text): | |||
|     return ' '.join([x.capitalize() for x in words]) | ||||
| 
 | ||||
| 
 | ||||
| def pretty_quantity(value): | ||||
|     """ | ||||
|     Return a "pretty" version of the given value, as string.  This is meant primarily | ||||
|     for use with things like order quantities, so that e.g. 1.0000 => 1 | ||||
|     """ | ||||
|     if value is None: | ||||
|         return '' | ||||
|     if int(value) == value: | ||||
|         return unicode(int(value)) | ||||
|     return unicode(value) | ||||
| 
 | ||||
| 
 | ||||
| def progress_loop(func, items, factory, *args, **kwargs): | ||||
|     """ | ||||
|     This will iterate over ``items`` and call ``func`` for each.  If a progress | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar