strparse: Fix default limit argument in split functions.
The underlying string methods don't accept None.
This commit is contained in:
		
							parent
							
								
									0f4f83e079
								
							
						
					
					
						commit
						11eccb60dd
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -48,14 +48,14 @@ def currency_decimal(s, locale='en_US_POSIX'):
 | 
			
		|||
def date(date_s, date_fmt):
 | 
			
		||||
    return datetime.datetime.strptime(date_s, date_fmt).date()
 | 
			
		||||
 | 
			
		||||
def _rejoin_slice_words(method_name, source, wordslice, sep=None, limit=None, joiner=None):
 | 
			
		||||
def _rejoin_slice_words(method_name, source, wordslice, sep=None, limit=-1, joiner=None):
 | 
			
		||||
    if joiner is None:
 | 
			
		||||
        joiner = ' ' if sep is None else sep
 | 
			
		||||
    return joiner.join(_slice_words(method_name, source, wordslice, sep, limit))
 | 
			
		||||
rejoin_slice_words = functools.partial(_rejoin_slice_words, 'split')
 | 
			
		||||
rejoin_rslice_words = functools.partial(_rejoin_slice_words, 'rsplit')
 | 
			
		||||
 | 
			
		||||
def _slice_words(method_name, source, wordslice, sep=None, limit=None):
 | 
			
		||||
def _slice_words(method_name, source, wordslice, sep=None, limit=-1):
 | 
			
		||||
    return getattr(source, method_name)(sep, limit)[wordslice]
 | 
			
		||||
slice_words = functools.partial(_slice_words, 'split')
 | 
			
		||||
rslice_words = functools.partial(_slice_words, 'rsplit')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue