Return the version of by with regex intead of importing it
199285
def get_version(path="src/devpy/__init__.py"):
    
    init_content = open(path, "rt").read()
    pattern = r"^__version__ = ['\"]([^'\"]*)['\"]"
    return re.search(pattern, init_content, re.M).group(1)
996493
def _get_version():
    """"""
    with open("../waliki/__init__.py") as fh:
        for line in fh:
            if line.startswith("__version__ = "):
                return line.split("=")[-1].strip().strip("'").strip('"')
452545
def find_version(
        package_name: str, version_module_name: str = '_version',
        version_variable_name: str = 'VERSION') -> str:
    """"""
    version_module = importlib.import_module(
        '{}.{}'.format(package_name.replace('-', '_'), version_module_name))
    return getattr(version_module, version_variable_name)
170450
def parse_version_string(version_string):
    """"""
    string_parts =  version_string.split(".")
    version_parts = [
        int(re.match("([0-9]*)", string_parts[0]).group(0)),
        int(re.match("([0-9]*)", string_parts[1]).group(0)),
        int(re.match("([0-9]*)", string_parts[2]).group(0))
    ]
    return version_parts
1138696
def get_version_tuple(string):
    ''''''
    match = re.match(r'(\d+)\.(\d+)\.?(\d*)([abc]?)(\d*)', string)
    major = int(match.group(1))
    minor = int(match.group(2))
    patch = int(match.group(3) or 0)
    level = RELEASE_LEVEL_MAP.get(match.group(4), 'final')
    serial = int(match.group(5) or 0)

    return major, minor, patch, level, serial
1260861
def _split_version_specifier(spec):
    """"""
    m = re.search(r'([<>=]?=?)?\s*([0-9.a-zA-Z]+)', spec)
    return m.group(2), m.group(1)
915981
def get_imports(fname):
    
    txt = ''
    with open(fname, 'r') as f:
        for line in f:
            if line[0:6] == 'import':
                txt += '<PRE>' + strip_text_after_string(line[7:], ' as ') + '</PRE>\n'
    return txt + '<BR>'
537645
def match(self, other_version):
    
    major, minor, patch = _str_to_version(other_version, allow_wildcard=True)
    return (major in [self.major, "*"] and minor in [self.minor, "*"]
            and patch in [self.patch, "*"])
1106006
def get_version(version):
    """"""
    if len(version) > 2 and version[2] is not None:
        if isinstance(version[2], int):
            str_version = "%s.%s.%s" % version[:3]
        else:
            str_version = "%s.%s_%s" % version[:3]
    else:
        str_version = "%s.%s" % version[:2]

    return str_version
1326334
def _get_version_from_url(self, url):
        '''
        
        '''
        regex = re.compile(r"^https?:\/\/.*\/(v[0-9])(\.[0-9])?(\/)?$")
        try:
            ver = regex.match(url)
            if ver.group(1):
                retver = ver.group(1)
                if ver.group(2):
                    retver = retver + ver.group(2)
            return retver
        except AttributeError:
            return ''
1064141
def get_version(path):
    """"""

    with open(os.path.join(path, 'VERSION'), 'rb') as f:
        version = f.read().decode('ascii').strip()
    return version.strip()
223321
def version_by_import(self, module_name):  # type: (str) ->Dict[str,str]
        
        if not module_name:
            return {}
        try:
            module = __import__(module_name)
        except ModuleNotFoundError:
            # hypothetical module would have to be on python path or execution folder, I think.
            return {}
        except FileNotFoundError:
            return {}

        if hasattr(module, "__version__"):
            version = module.__version__
            return {"module import": version}
        return {}
66356
def extract_version(txt):
    """"""
    words = txt.replace(',', ' ').split()
    version = None
    for x in reversed(words):
        if len(x) > 2:
            if x[0].lower() == 'v':
                x = x[1:]
            if '.' in x and x[0].isdigit():
                version = x
                break
    return version
205179
def parse_version(cls, version_str):
        
        match = cls.VERSION_RE.match(version_str)
        if match:
            major = int(match.group('major'))
            minor = int(match.group('minor'))
            flags = set(match.group('flags') or '')
        else:
            major, minor, flags = None, None, set()
        return cls(major, minor, flags)
769396
def _get_version():
    '''
    
    '''
    version_string = __salt__['cmd.run'](
        [_check_xbps(), '--version'],
        output_loglevel='trace')
    if version_string is None:
        # Dunno why it would, but...
        return False

    VERSION_MATCH = re.compile(r'(?:XBPS:[\s]+)([\d.]+)(?:[\s]+.*)')
    version_match = VERSION_MATCH.search(version_string)
    if not version_match:
        return False

    return version_match.group(1).split('.')
1335326
def _construct_regex(cls, fmt):
        """"""
        return re.compile(fmt.format(**vars(cls)), flags=re.U)
417971
def get_version():
    """"""
    module_path = get_absolute_path('pip_save', '__init__.py')
    with open(module_path) as handle:
        for line in handle:
            match = re.match(r'^__version__\s*=\s*["\']([^"\']+)["\']$', line)
            if match:
                return match.group(1)
    raise Exception("Failed to extract version from %s!" % module_path)