python有手机上的版本吗_如何比较python中的Rpm版本
基于Owen的出色回答,我整理了一个片段,它使用系统RPM绑定(如果可用),但返回到基于正则表达式的仿真:try:
from rpm import labelCompare as _compare_rpm_labels
except ImportError:
# Emulate RPM field comparisons
#
# * Search each string for alphabetic fields [a-zA-Z]+ and
# numeric fields [0-9]+ separated by junk [^a-zA-Z0-9]*.
# * Successive fields in each string are compared to each other.
# * Alphabetic sections are compared lexicographically, and the
# numeric sections are compared numerically.
# * In the case of a mismatch where one field is numeric and one is
# alphabetic, the numeric field is always considered greater (newer).
# * In the case where one string runs out of fields, the other is always
# considered greater (newer).
import warnings
warnings.warn("Failed to import 'rpm', emulating RPM label comparisons")
try:
from itertools import zip_longest
except ImportError:
from itertools import izip_longest as zip_longest
_subfield_pattern = re.compile(
r'(?P[^a-zA-Z0-9]*)((?P[a-zA-Z]+)|(?P[0-9]+))'
)
def _iter_rpm_subfields(field):
"""Yield subfields as 2-tuples that sort in the desired order
Text subfields are yielded as (0, text_value)
Numeric subfields are yielded as (1, int_value)
"""
for subfield in _subfield_pattern.finditer(field):
text = subfield.group('text')
if text is not None:
yield (0, text)
else:
yield (1, int(subfield.group('num')))
def _compare_rpm_field(lhs, rhs):
# Short circuit for exact matches (including both being None)
if lhs == rhs:
return 0
# Otherwise assume both inputs are strings
lhs_subfields = _iter_rpm_subfields(lhs)
rhs_subfields = _iter_rpm_subfields(rhs)
for lhs_sf, rhs_sf in zip_longest(lhs_subfields, rhs_subfields):
if lhs_sf == rhs_sf:
# When both subfields are the same, move to next subfield
continue
if lhs_sf is None:
# Fewer subfields in LHS, so it's less than/older than RHS
return -1
if rhs_sf is None:
# More subfields in LHS, so it's greater than/newer than RHS
return 1
# Found a differing subfield, so it determines the relative order
return -1 if lhs_sf < rhs_sf else 1
# No relevant differences found between LHS and RHS
return 0
def _compare_rpm_labels(lhs, rhs):
lhs_epoch, lhs_version, lhs_release = lhs
rhs_epoch, rhs_version, rhs_release = rhs
result = _compare_rpm_field(lhs_epoch, rhs_epoch)
if result:
return result
result = _compare_rpm_field(lhs_version, rhs_version)
if result:
return result
return _compare_rpm_field(lhs_release, rhs_release)
请注意,我还没有对这个与C级实现的一致性进行过广泛的测试——我只是将它用作一个后备实现,它至少足以让Anitya的测试套件在系统RPM绑定不可用的环境中通过。
python有手机上的版本吗_如何比较python中的Rpm版本相关推荐
- python升级版本命令_如何在python中安装和配置kivy库
kivy是python的UI开发工具包,主要关注用户界面显示效果,可以在Android.IOS.Linux.OS X和Windows上运行.如果python开发中使用kivy,需要安装和配置相关文件和 ...
- python在mac上打不来_我可以打开jupyter笔记本,但无法在Mac上运行带有python脚本的笔记本...
我已经将jupyter以及Atom与python一起使用了一年多了.我目前在macOS 10.14上使用Python 3.7.2.从终端运行Python没问题,这是在运行sys.path之后获得的PA ...
- python 下载网页文件_『如何用python把网页上的文本内容保存下来』python爬取网页内容教程...
python爬虫:如何爬网页数据并将其放在文本 用requests库 r=r.requests.get(url) r.concent 保存到文件里就行了 如何用python把网页上的文本内容保存下来 ...
- python编辑器手机版-QPython,一个在手机上运行Python的神器
之前安利过一款手机上运行Python的神器Termux,不过Termux的使用比较重,它实际是一款linux系统模拟器,安装好Termux后还要再安装python,并且是全命令行操作,一些读者使用起来 ...
- python基础语法花多长时间_怎么自学python,大概要多久?
2020年最后一天,还有一个多小时就是2021年了,先祝愿大家2021年都能够健康平安发大财! 自学Python的方法因人而异,而大概需要多久就更是各说各话了,但是自学Python的路径都是一致的:先 ...
- python 抓取微博评论破亿_如果利用Python分析14亿条数据!资深程序员手把手教你!过亿级!...
挑战 1-gram 的数据集在硬盘上可以展开成为 27 Gb 的数据,这在读入 python 时是一个很大的数据量级.Python可以轻易地一次性地处理千兆的数据,但是当数据是损坏的和已加工的,速度就 ...
- python爬取微信群聊内容_再不学Python 你就被同龄人甩开了吗?
原创: 潘懿锟 唐佩瑶 清华大学(分数线,专业设置)清新时报 记者 | 潘懿锟 唐佩瑶 "会Python的人,工作都不会太差.追上同龄人,就趁现在!" 或许你已经对微信的广告推送感 ...
- 用python可以做哪些有趣的事_可以用 Python 来干些什么有趣的事?
下载视频?我用Python:玩跳一跳?我用Python跳到4999分:撩妹子?依然用Python:抢红包抢火车票?没错还是Python:就算是整理文件,我也还是用Python-- 下面就详细跟大家分享 ...
- python实训总结和心得体会_《用Python做HTTP接口测试》学习感悟
机缘巧合之下,报名参加了阿奎老师发布在"好班长"的课程<用Python做HTTP接口测试>,报名费:15rmb,不到一杯咖啡钱,目前为止的状态:坚定不移的跟下去,自学+ ...
- python 监控文件夹存入的文件_文件夹 python
Python如何搜索模块 在引入模块时,把库文件和应用文件放在同一文件夹下,当在该文件夹下运行程序时,Python会自动在当前文件夹下搜索它想要引入的模块. 但Python还会到其它地方寻找库: (1 ...
最新文章
- 注意!你的 Navicat 可能被投毒了...
- 检查单 2014-06-20-01
- 由parseInt 引发的问题---想到浮点运算精度丢失---看透js number 的 encoded
- 悼念512汶川大地震遇难同胞——老人是真饿了
- RAILS 学习日记 --扩展
- Apache 分割日志
- manjaro Linux下使用腾讯会议
- 程序设计导引及在线实践--读书笔记一
- jflash合并bin文件及hex文件
- HDFS常用命令总结
- 中国农业机械融资租赁市场预测与投资战略报告(2023版)
- Polkadot + DeFi | 透明公平、高效交易的去中心化金融未来可期
- 大数据揭秘区块链人才大迁徙:那个你身边悄悄离职的人去哪儿了?
- 微信美化版qu水印小程序源码分享 附接口
- html给文字添加下划线
- 论文的研究方法实验方案技术路线
- web之HTML入门02
- 日语助词-接续助词总结
- 蒂姆·库克:乔布斯背后的天才
- SDHC(高容量SD存储卡)
热门文章
- 代码重构/坏味道详解
- python与会计的论文_python计算与编程实践论文范文 有关西安交通大学软件学院软件工程硕士研究生毕业论文写作资料...
- 阿里浪时代,新浪微博开放平台何去何从?
- 如何使用4EVERLAND-BUCKET在zkSync上Mint一个NFT
- leo-水电收费管理系统
- 麒麟子Cocos Creator 3D研究笔记三:角色换装(无动画)
- 微信小程序头像和昵称无法显示
- Vue文件报错vue.runtime.esm.js?2b0e:619和1888 Error: [ElementForm]unpected width两个错误
- 黑苦荞茶真的有那么好吗
- Driver.js - 开源无依赖的 web 新手交互引导工具库,功能强大、高度可定制