Better error messages for extension()
This commit is contained in:
		@@ -61,13 +61,15 @@ def strip_extension(path):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def extension(path):
 | 
					def extension(path):
 | 
				
			||||||
    """Get the archive extension for a path."""
 | 
					    """Get the archive extension for a path."""
 | 
				
			||||||
 | 
					    if path is None:
 | 
				
			||||||
 | 
					        raise ValueError("Can't call extension() on None")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Strip sourceforge suffix.
 | 
					    # Strip sourceforge suffix.
 | 
				
			||||||
    if re.search(r'((?:sourceforge.net|sf.net)/.*)/download$', path):
 | 
					    if re.search(r'((?:sourceforge.net|sf.net)/.*)/download$', path):
 | 
				
			||||||
        path = os.path.dirname(path)
 | 
					        path = os.path.dirname(path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for type in ALLOWED_ARCHIVE_TYPES:
 | 
					    for t in ALLOWED_ARCHIVE_TYPES:
 | 
				
			||||||
        suffix = r'\.%s$' % type
 | 
					        suffix = r'\.%s$' % t
 | 
				
			||||||
        if re.search(suffix, path):
 | 
					        if re.search(suffix, path):
 | 
				
			||||||
            return type
 | 
					            return t
 | 
				
			||||||
    return None
 | 
					    return None
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user