1 Star 0 Fork 0

yzjia/lxml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
versioninfo.py 2.16 KB
一键复制 编辑 原始数据 按行查看 历史
import io
import os
import re
import sys
__LXML_VERSION = None
def version():
global __LXML_VERSION
if __LXML_VERSION is None:
with open(os.path.join(get_base_dir(), 'src', 'lxml', '__init__.py')) as f:
__LXML_VERSION = re.search(r'__version__\s*=\s*"([^"]+)"', f.read(250)).group(1)
assert __LXML_VERSION
return __LXML_VERSION
def branch_version():
return version()[:3]
def is_pre_release():
version_string = version()
return "a" in version_string or "b" in version_string
def dev_status():
_version = version()
if 'a' in _version:
return 'Development Status :: 3 - Alpha'
elif 'b' in _version or 'c' in _version:
return 'Development Status :: 4 - Beta'
else:
return 'Development Status :: 5 - Production/Stable'
def changes():
"""Extract part of changelog pertaining to version.
"""
_version = version()
with io.open(os.path.join(get_base_dir(), "CHANGES.txt"), 'r', encoding='utf8') as f:
lines = []
for line in f:
if line.startswith('====='):
if len(lines) > 1:
break
if lines:
lines.append(line)
elif line.startswith(_version):
lines.append(line)
return ''.join(lines[:-1])
def create_version_h():
"""Create lxml-version.h
"""
lxml_version = version()
# make sure we have a triple part version number
parts = lxml_version.split('-')
while parts[0].count('.') < 2:
parts[0] += '.0'
lxml_version = '-'.join(parts).replace('a', '.alpha').replace('b', '.beta')
file_path = os.path.join(get_base_dir(), 'src', 'lxml', 'includes', 'lxml-version.h')
# Avoid changing file timestamp if content didn't change.
if os.path.isfile(file_path):
with open(file_path, 'r') as version_h:
if ('"%s"' % lxml_version) in version_h.read(100):
return
with open(file_path, 'w') as version_h:
version_h.write('''\
#ifndef LXML_VERSION_STRING
#define LXML_VERSION_STRING "%s"
#endif
''' % lxml_version)
def get_base_dir():
return os.path.abspath(os.path.dirname(sys.argv[0]))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yzjia0827/lxml.git
git@gitee.com:yzjia0827/lxml.git
yzjia0827
lxml
lxml
master

搜索帮助