diff options
author | Michael Schroeder <mls@suse.de> | 2012-11-02 14:32:27 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2012-11-02 14:32:27 +0100 |
commit | 85f694ba7aa2faf014b1f0ce9785133adc46e115 (patch) | |
tree | a4debb5c8740cc7d82fe52f51da97e481c505765 /examples | |
parent | 5839b7d92cb35c9169c0d7cca71f4216386c89ba (diff) | |
download | libsolv-85f694ba7aa2faf014b1f0ce9785133adc46e115.tar.gz libsolv-85f694ba7aa2faf014b1f0ce9785133adc46e115.tar.bz2 libsolv-85f694ba7aa2faf014b1f0ce9785133adc46e115.zip |
get rid of the ugly load_if_changed method
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/p5solv | 14 | ||||
-rwxr-xr-x | examples/pysolv | 25 | ||||
-rwxr-xr-x | examples/rbsolv | 12 |
3 files changed, 24 insertions, 27 deletions
diff --git a/examples/p5solv b/examples/p5solv index 103ee88..6cbe5dd 100755 --- a/examples/p5solv +++ b/examples/p5solv @@ -71,10 +71,6 @@ sub load { print "repo: '$self->{'alias'}' cached\n"; return 1; } - return $self->load_if_changed(); -} - -sub load_if_changed { return 0; } @@ -278,8 +274,9 @@ sub load_ext { return 1; } -sub load_if_changed { - my ($self) = @_; +sub load { + my ($self, $pool) = @_; + return 1 if $self->Repo::generic::load($pool); print "rpmmd repo '$self->{'alias'}': "; STDOUT->flush(); my $f = $self->download("repodata/repomd.xml"); @@ -407,8 +404,9 @@ sub load_ext { return 1; } -sub load_if_changed { - my ($self) = @_; +sub load { + my ($self, $pool) = @_; + return 1 if $self->Repo::generic::load($pool); print "susetags repo '$self->{'alias'}': "; STDOUT->flush(); my $f = $self->download("content"); diff --git a/examples/pysolv b/examples/pysolv index d4c7265..a9dc144 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -99,9 +99,6 @@ class repo_generic(dict): if not dorefresh and self.usecachedrepo(None): print "repo: '%s': cached" % self.name return True - return self.load_if_changed() - - def load_if_changed(self): return False def load_ext(self, repodata): @@ -198,10 +195,6 @@ class repo_generic(dict): return solv.xfopen_fd(None, os.dup(f.fileno())) def usecachedrepo(self, ext, mark=False): - if not ext: - cookie = self['cookie'] - else: - cookie = self['extcookie'] try: repopath = self.cachepath(ext) f = open(repopath, 'r') @@ -209,6 +202,10 @@ class repo_generic(dict): fcookie = f.read(32) if len(fcookie) != 32: return False + if not ext: + cookie = self['cookie'] + else: + cookie = self['extcookie'] if cookie and fcookie != cookie: return False if self.type != 'system' and not ext: @@ -239,7 +236,7 @@ class repo_generic(dict): def writecachedrepo(self, ext, info=None): if not ext and 'incomplete' in self: - return + return try: if not os.path.isdir("/var/cache/solv"): os.mkdir("/var/cache/solv", 0755) @@ -304,7 +301,9 @@ class repo_generic(dict): return '' class repo_repomd(repo_generic): - def load_if_changed(self): + def load(self, pool): + if super(repo_repomd, self).load(pool): + return True print "rpmmd repo '%s':" % self.name, sys.stdout.flush() f = self.download("repodata/repomd.xml", False, None, None) @@ -336,7 +335,7 @@ class repo_repomd(repo_generic): self.handle.add_updateinfoxml(f, 0) solv.xfclose(f) self.add_exts() - self.writecachedrepo(None) + self.writecachedrepo(None) # must be called after writing the repo self.handle.create_stubs() return True @@ -409,7 +408,9 @@ class repo_repomd(repo_generic): return True class repo_susetags(repo_generic): - def load_if_changed(self): + def load(self, pool): + if super(repo_susetags, self).load(pool): + return True print "susetags repo '%s':" % self.name, sys.stdout.flush() f = self.download("content", False, None, None) @@ -448,7 +449,7 @@ class repo_susetags(repo_generic): solv.xfclose(f) self.handle.internalize() self.add_exts() - self.writecachedrepo(None) + self.writecachedrepo(None) # must be called after writing the repo self.handle.create_stubs() return True diff --git a/examples/rbsolv b/examples/rbsolv index ba87aab..8ac3eca 100755 --- a/examples/rbsolv +++ b/examples/rbsolv @@ -72,14 +72,10 @@ class Repo_generic puts "repo: '#{@name}' cached" return true end - return load_if_changed() - end - - def load_ext(repodata) return false end - def load_if_changed + def load_ext(repodata) return false end @@ -233,7 +229,8 @@ class Repo_rpmmd < Repo_generic return nil, nil end - def load_if_changed + def load(pool) + return true if super(pool) print "rpmmd repo '#{@name}: " f = download("repodata/repomd.xml", false, nil, nil) if !f @@ -344,7 +341,8 @@ class Repo_susetags < Repo_generic return nil, nil end - def load_if_changed + def load(pool) + return true if super(pool) print "susetags repo '#{@name}: " f = download("content", false, nil, nil) if !f |