diff options
Diffstat (limited to 'lib/cnucnu/helper.py')
-rw-r--r-- | lib/cnucnu/helper.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/cnucnu/helper.py b/lib/cnucnu/helper.py new file mode 100644 index 0000000..94263df --- /dev/null +++ b/lib/cnucnu/helper.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +# vim: fileencoding=utf8 foldmethod=marker +#{{{ License header: GPLv2+ +# This file is part of cnucnu. +# +# Cnucnu is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# Cnucnu is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cnucnu. If not, see <http://www.gnu.org/licenses/>. +#}}} + +def get_html(url): + import urllib + res = urllib.urlopen(url) + return res.read() + +def rpm_cmp(v1, v2): + import rpm + return rpm.labelCompare((None, v1, None), (None, v2, None)) + +def rpm_max(list): + list.sort(cmp=rpm_cmp) + return list[-1] |