diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-07-31 20:21:11 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-07-31 20:21:11 -0300 |
commit | ca1f4122331e27fc7bba3700c85e2366fdd6a946 (patch) | |
tree | 1991c939184f2d7ac8e9723eeb716b59b1166bfe | |
parent | moved RESTRICT="mirror" to the eclass (diff) | |
download | g-octave-ca1f4122331e27fc7bba3700c85e2366fdd6a946.tar.gz g-octave-ca1f4122331e27fc7bba3700c85e2366fdd6a946.tar.bz2 g-octave-ca1f4122331e27fc7bba3700c85e2366fdd6a946.zip |
fixes to the python3 stuff
-rw-r--r-- | g_octave/description.py | 4 | ||||
-rw-r--r-- | g_octave/description_tree.py | 24 | ||||
-rw-r--r-- | g_octave/fetch.py | 6 |
3 files changed, 27 insertions, 7 deletions
diff --git a/g_octave/description.py b/g_octave/description.py index f1ec6f1..c951a1c 100644 --- a/g_octave/description.py +++ b/g_octave/description.py @@ -31,7 +31,7 @@ from contextlib import closing from .config import Config from .exception import ConfigException, DescriptionException -from .compat import open, py3k +from .compat import py3k if py3k: import urllib.request as urllib @@ -67,7 +67,7 @@ class Description(object): # current key key = None - with open(file, 'r', encoding='iso-8859-1') as fp: + with open(file, 'r') as fp: for line in fp: line_splited = line.split(':') diff --git a/g_octave/description_tree.py b/g_octave/description_tree.py index 168c15f..a2a59cf 100644 --- a/g_octave/description_tree.py +++ b/g_octave/description_tree.py @@ -34,6 +34,26 @@ except ImportError: from .log import Log log = Log('g_octave.description_tree') +# from http://wiki.python.org/moin/HowTo/Sorting/ +def cmp_to_key(mycmp): + 'Convert a cmp= function into a key= function' + class K(object): + def __init__(self, obj, *args): + self.obj = obj + def __lt__(self, other): + return mycmp(self.obj, other.obj) < 0 + def __gt__(self, other): + return mycmp(self.obj, other.obj) > 0 + def __eq__(self, other): + return mycmp(self.obj, other.obj) == 0 + def __le__(self, other): + return mycmp(self.obj, other.obj) <= 0 + def __ge__(self, other): + return mycmp(self.obj, other.obj) >= 0 + def __ne__(self, other): + return mycmp(self.obj, other.obj) != 0 + return K + class DescriptionTree(object): def __init__(self, conf=None, parse_sysreq=True): @@ -116,7 +136,7 @@ class DescriptionTree(object): if pkg['name'] == pkgname: tmp.append(pkg['version']) - tmp.sort(vercmp) + tmp.sort(key=cmp_to_key(vercmp)) return tmp @@ -129,7 +149,7 @@ class DescriptionTree(object): def version_compare(self, versions): tmp = list(versions[:]) - tmp.sort(vercmp) + tmp.sort(key=cmp_to_key(vercmp)) return tmp[-1] diff --git a/g_octave/fetch.py b/g_octave/fetch.py index 4883442..c67af1c 100644 --- a/g_octave/fetch.py +++ b/g_octave/fetch.py @@ -54,15 +54,15 @@ class GitHub: def __init__(self, user, repo): self.user = user self.repo = repo - self.api_url = u'http://github.com/api/v2/json' - self.url = u'http://github.com' + self.api_url = 'http://github.com/api/v2/json' + self.url = 'http://github.com' def need_update(self): return not os.path.exists(os.path.join( conf.db, 'cache', 'commit_id' )) - def get_commits(self, branch=u'master'): + def get_commits(self, branch='master'): url = '%s/commits/list/%s/%s/%s/' % ( self.api_url, self.user, |