euscan: detect version type
In the formatted output display the version type (beta, alpha, rc, ...) Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
		@@ -131,11 +131,13 @@ class EuscanOutput(object):
 | 
			
		||||
            raise TypeError("Invalid output format")
 | 
			
		||||
 | 
			
		||||
    def result(self, cp, version, url, handler, confidence):
 | 
			
		||||
        from euscan.helpers import get_version_type
 | 
			
		||||
 | 
			
		||||
        if self.config['format']:
 | 
			
		||||
            _curr = self.queries[self.current_query]
 | 
			
		||||
            _curr["result"].append(
 | 
			
		||||
                {"version": version, "urls": [url], "handler": handler,
 | 
			
		||||
                 "confidence": confidence}
 | 
			
		||||
                 "confidence": confidence, "type": get_version_type(version)}
 | 
			
		||||
            )
 | 
			
		||||
        else:
 | 
			
		||||
            if not self.config['quiet']:
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,18 @@ _v_end = '((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)'
 | 
			
		||||
_v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(' + _v_end + '*))'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_version_type(version):
 | 
			
		||||
    types = []
 | 
			
		||||
    gentoo_types = ("alpha", "beta", "pre", "rc", "p")
 | 
			
		||||
 | 
			
		||||
    for token in re.findall("[\._-]([a-zA-Z]+)", version):
 | 
			
		||||
        if token in gentoo_types:
 | 
			
		||||
            types.append(token)
 | 
			
		||||
    if types:
 | 
			
		||||
        return types[0]
 | 
			
		||||
    return "release"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Stolen from g-pypi
 | 
			
		||||
def gentoo_mangle_version(up_pv):
 | 
			
		||||
    """Convert PV to MY_PV if needed
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user