- retabify (untabify for pysolv)
authorMichael Schroeder <mls@suse.de>
Thu, 25 Oct 2012 16:55:39 +0000 (18:55 +0200)
committerMichael Schroeder <mls@suse.de>
Thu, 25 Oct 2012 16:55:39 +0000 (18:55 +0200)
examples/p5solv
examples/pysolv
examples/rbsolv

index cda9a9c..94f5e7a 100755 (executable)
@@ -180,8 +180,8 @@ sub writecachedrepo {
     $f = solv::xfopen($tmpname);
     if ($f) {
       if (!$ext) {
-        $self->{'handle'}->empty();
-        die("internal error, cannot reload solv file\n") unless $self->{'handle'}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS);
+       $self->{'handle'}->empty();
+       die("internal error, cannot reload solv file\n") unless $self->{'handle'}->add_solv($f, $solv::Repo::SOLV_ADD_NO_STUBS);
       } else {
        $info->extend_to_repo();
        $info->add_solv($f, $solv::Repo::REPO_EXTEND_SOLVABLES);
@@ -434,10 +434,10 @@ sub load_if_changed {
       ($filename, $filechksum) = $self->find('packages.en.gz');
       ($filename, $filechksum) = $self->find('packages.en') unless $filename;
       if ($filename) {
-        $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
+       $f = $self->download("$descrdir/$filename", 1, $filechksum, 1);
        if ($f) {
-          $self->{'handle'}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::REPO_REUSE_REPODATA|$solv::Repo::REPO_EXTEND_SOLVABLES);
-          solv::xfclose($f);
+         $self->{'handle'}->add_susetags($f, $defvendorid, undef, $solv::Repo::REPO_NO_INTERNALIZE|$solv::Repo::REPO_REUSE_REPODATA|$solv::Repo::REPO_EXTEND_SOLVABLES);
+         solv::xfclose($f);
        }
       }
       $self->{'handle'}->internalize();
@@ -584,17 +584,17 @@ if ($cmd eq 'list' || $cmd eq 'info') {
   for my $job (@jobs) {
     for my $s ($job->solvables()) {
       if ($cmd eq 'info') {
-        printf "Name:        %s\n", $s->str();
-        printf "Repo:        %s\n", $s->{'repo'}->{'name'};
-        printf "Summary:     %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
+       printf "Name:        %s\n", $s->str();
+       printf "Repo:        %s\n", $s->{'repo'}->{'name'};
+       printf "Summary:     %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
        my $str = $s->lookup_str($solv::SOLVABLE_URL);
-        printf "Url:         %s\n", $str if $str;
+       printf "Url:         %s\n", $str if $str;
        $str = $s->lookup_str($solv::SOLVABLE_LICENSE);
-        printf "License:     %s\n", $str if $str;
-        printf "Description:\n%s\n", $s->lookup_str($solv::SOLVABLE_DESCRIPTION);
+       printf "License:     %s\n", $str if $str;
+       printf "Description:\n%s\n", $s->lookup_str($solv::SOLVABLE_DESCRIPTION);
       } else {
-        printf "  - %s [%s]\n", $s->str(), $s->{'repo'}->{'name'};
-        printf "    %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
+       printf "  - %s [%s]\n", $s->str(), $s->{'repo'}->{'name'};
+       printf "    %s\n", $s->lookup_str($solv::SOLVABLE_SUMMARY);
       }
     }
   }
@@ -606,18 +606,18 @@ if ($cmd eq 'install' || $cmd eq 'erase' || $cmd eq 'up' || $cmd eq 'dup' || $cm
   for my $job (@jobs) {
     if ($cmd eq 'up') {
       if ($job->{'how'} == $solv::Job::SOLVER_SOLVABLE_ALL || grep {$_->isinstalled()} $job->solvables()) {
-        $job->{'how'} |= $solv::Job::SOLVER_UPDATE;
+       $job->{'how'} |= $solv::Job::SOLVER_UPDATE;
       } else {
-        $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
+       $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
       }
     } elsif ($cmd eq 'install') {
-        $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
+       $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
     } elsif ($cmd eq 'erase') {
-        $job->{'how'} |= $solv::Job::SOLVER_ERASE;
+       $job->{'how'} |= $solv::Job::SOLVER_ERASE;
     } elsif ($cmd eq 'dup') {
-        $job->{'how'} |= $solv::Job::SOLVER_DISTUPGRADE;
+       $job->{'how'} |= $solv::Job::SOLVER_DISTUPGRADE;
     } elsif ($cmd eq 'verify') {
-        $job->{'how'} |= $solv::Job::SOLVER_VERIFY;
+       $job->{'how'} |= $solv::Job::SOLVER_VERIFY;
     }
   }
   my $solver;
@@ -637,8 +637,8 @@ if ($cmd eq 'install' || $cmd eq 'erase' || $cmd eq 'up' || $cmd eq 'dup' || $cm
        print "  Solution $solution->{'id'}:\n";
        for my $element ($solution->elements(1)) {
          print "  - ".$element->str()."\n";
-        }
-        print "\n";
+       }
+       print "\n";
       }
       my $sol;
       while (1) {
@@ -651,10 +651,10 @@ if ($cmd eq 'install' || $cmd eq 'erase' || $cmd eq 'up' || $cmd eq 'dup' || $cm
       exit(1) if $sol eq 'q';
       my $solution = $solutions[$sol - 1];
       for my $element ($solution->elements()) {
-        my $newjob = $element->Job();
-        if ($element->{'type'} == $solv::Solver::SOLVER_SOLUTION_JOB) {
+       my $newjob = $element->Job();
+       if ($element->{'type'} == $solv::Solver::SOLVER_SOLUTION_JOB) {
          $jobs[$element->{'jobidx'}] = $newjob;
-        } else {
+       } else {
          push @jobs, $newjob if $newjob && !grep {$_ == $newjob} @jobs;
        }
       }
index 40e8c7f..50c8cb1 100755 (executable)
@@ -345,7 +345,7 @@ class repo_repomd(repo_generic):
         di = self.handle.Dataiterator(solv.SOLVID_META, solv.REPOSITORY_REPOMD_TYPE, what, Dataiterator.SEARCH_STRING)
         di.prepend_keyname(solv.REPOSITORY_REPOMD)
         for d in di:
-           dp = d.parentpos()
+            dp = d.parentpos()
             filename = dp.lookup_str(solv.REPOSITORY_REPOMD_LOCATION)
             chksum = dp.lookup_checksum(solv.REPOSITORY_REPOMD_CHECKSUM)
             if filename and not chksum:
@@ -550,8 +550,8 @@ class repo_system(repo_generic):
             print "cached"
             return True
         print "reading"
-       if hasattr(self.handle.__class__, 'add_products'):
-           self.handle.add_products("/etc/products.d", Repo.REPO_NO_INTERNALIZE)
+        if hasattr(self.handle.__class__, 'add_products'):
+            self.handle.add_products("/etc/products.d", Repo.REPO_NO_INTERNALIZE)
         self.handle.add_rpmdb(None, Repo.REPO_REUSE_REPODATA)
         self.writecachedrepo(None)
         return True
@@ -633,15 +633,15 @@ for repo in repos:
 repolimiter = None
 if options.repos:
     for reponame in options.repos:
-       mrepos = [ repo for repo in repos if repo.name == reponame ]
-       if not mrepos:
-           print "no repository matches '%s'" % reponame
-           sys.exit(1)
-       repo = mrepos[0]
-       if hasattr(repo, 'handle'):
-           if not repolimiter:
-               repolimiter = pool.Selection()
-           repolimiter.addsimple(Job.SOLVER_SOLVABLE_REPO, repo.handle.id)
+        mrepos = [ repo for repo in repos if repo.name == reponame ]
+        if not mrepos:
+            print "no repository matches '%s'" % reponame
+            sys.exit(1)
+        repo = mrepos[0]
+        if hasattr(repo, 'handle'):
+            if not repolimiter:
+                repolimiter = pool.Selection()
+            repolimiter.addsimple(Job.SOLVER_SOLVABLE_REPO, repo.handle.id)
 
 if cmd == 'search':
     matches = {}
@@ -678,28 +678,28 @@ for arg in args:
     if cmdlinerepo and arg in cmdlinerepo['packages']:
         jobs.append(pool.Job(Job.SOLVER_SOLVABLE, cmdlinerepo['packages'][arg]))
     else:
-       flags = Selection.SELECTION_NAME|Selection.SELECTION_PROVIDES|Selection.SELECTION_GLOB
-       if len(arg) and arg[0] == '/':
-           flags |= Selection.SELECTION_FILELIST
-           if cmd == 'erase':
-               flags |= Selection.SELECTION_INSTALLED_ONLY
-       sel = pool.select(arg, flags)
-       if repolimiter:
-          sel.limit(repolimiter)
+        flags = Selection.SELECTION_NAME|Selection.SELECTION_PROVIDES|Selection.SELECTION_GLOB
+        if len(arg) and arg[0] == '/':
+            flags |= Selection.SELECTION_FILELIST
+            if cmd == 'erase':
+                flags |= Selection.SELECTION_INSTALLED_ONLY
+        sel = pool.select(arg, flags)
+        if repolimiter:
+           sel.limit(repolimiter)
         if sel.isempty():
-           sel = pool.select(arg, flags | Selection.SELECTION_NOCASE)
-           if repolimiter:
-              sel.limit(repolimiter)
-           if not sel.isempty():
-               print "[ignoring case for '%s']" % arg
+            sel = pool.select(arg, flags | Selection.SELECTION_NOCASE)
+            if repolimiter:
+               sel.limit(repolimiter)
+            if not sel.isempty():
+                print "[ignoring case for '%s']" % arg
         if sel.isempty():
-           print "nothing matches '%s'" % arg
+            print "nothing matches '%s'" % arg
             sys.exit(1)
-       if sel.flags() & Selection.SELECTION_FILELIST:
-           print "[using file list match for '%s']" % arg
-       if sel.flags() & Selection.SELECTION_PROVIDES:
-           print "[using capability match for '%s']" % arg
-       jobs += sel.jobs(0)
+        if sel.flags() & Selection.SELECTION_FILELIST:
+            print "[using file list match for '%s']" % arg
+        if sel.flags() & Selection.SELECTION_PROVIDES:
+            print "[using capability match for '%s']" % arg
+        jobs += sel.jobs(0)
 
 if not jobs and (cmd == 'up' or cmd == 'dup' or cmd == 'verify' or repolimiter):
     sel = pool.Selection()
@@ -733,8 +733,8 @@ if cmd == 'list' or cmd == 'info':
 
 if cmd == 'install' or cmd == 'erase' or cmd == 'up' or cmd == 'dup' or cmd == 'verify':
     if not jobs:
-       print "no package matched."
-       sys.exit(1)
+        print "no package matched."
+        sys.exit(1)
     for job in jobs:
         if cmd == 'up':
             # up magic: use install instead of update if no installed package matches
index 56b3370..333114b 100755 (executable)
@@ -51,8 +51,8 @@ class Repo_generic
     dorefresh = autorefresh?
     if dorefresh
       begin
-        s = File.stat(cachepath)
-        dorefresh = false if s && Time.now - s.mtime < @attribs['metadata_expire'].to_i
+       s = File.stat(cachepath)
+       dorefresh = false if s && Time.now - s.mtime < @attribs['metadata_expire'].to_i
       rescue SystemCallError
       end
     end
@@ -85,16 +85,16 @@ class Repo_generic
     return nil if f.stat.size == 0 && (st || !chksum)
     if !st
        puts "#{file}: download error #{$? >> 8}"
-        @incomplete = true if markincomplete
-        return nil
+       @incomplete = true if markincomplete
+       return nil
     end
     if chksum
       fchksum = Solv::Chksum.new(chksum.type)
       fchksum.add_fd(f.fileno)
       if !fchksum == chksum
        puts "#{file}: checksum error"
-        @incomplete = true if markincomplete
-        return nil
+       @incomplete = true if markincomplete
+       return nil
       end
     end
     if uncompress
@@ -120,24 +120,24 @@ class Repo_generic
       return false if fcookie.length != 32
       return false if cookie && fcookie != cookie
       if !ext && @type != 'system'
-        f.sysseek(-32 * 2, IO::SEEK_END)
-        fextcookie = f.sysread(32)
-        return false if fextcookie.length != 32
+       f.sysseek(-32 * 2, IO::SEEK_END)
+       fextcookie = f.sysread(32)
+       return false if fextcookie.length != 32
       end
       f.sysseek(0, IO::SEEK_SET)
       f = Solv::xfopen_dup('', f.fileno)
       flags = ext ? Solv::Repo::REPO_USE_LOADING|Solv::Repo::REPO_EXTEND_SOLVABLES : 0
       flags |= Solv::Repo::REPO_LOCALPOOL if ext && ext != 'DL'
       if ! @handle.add_solv(f, flags)
-        Solv::xfclose(f)
-        return false
+       Solv::xfclose(f)
+       return false
       end
       Solv::xfclose(f)
       @cookie = fcookie unless ext
       @extcookie = fextcookie if !ext && @type != 'system'
       now = Time.now
       begin
-        File::utime(now, now, repopath) if mark
+       File::utime(now, now, repopath) if mark
       rescue SystemCallError
       end
       return true
@@ -177,8 +177,8 @@ class Repo_generic
       Solv::xfclose(sf)
       f.sysseek(0, IO::SEEK_END)
       if @type != 'system' && !ext
-        genextcookie(f) unless @extcookie
-        f.syswrite(@extcookie)
+       genextcookie(f) unless @extcookie
+       f.syswrite(@extcookie)
       end
       f.syswrite(ext ? @extcookie : @cookie)
       f.close(false)
@@ -259,8 +259,8 @@ class Repo_rpmmd < Repo_generic
     if filename
       f = download(filename, true, filechksum, true)
       if f
-        @handle.add_rpmmd(f, nil, 0)
-        Solv::xfclose(f)
+       @handle.add_rpmmd(f, nil, 0)
+       Solv::xfclose(f)
       end
       return false if @incomplete
     end
@@ -268,8 +268,8 @@ class Repo_rpmmd < Repo_generic
     if filename
       f = download(filename, true, filechksum, true)
       if f
-        @handle.add_updateinfoxml(f, 0)
-        Solv::xfclose(f)
+       @handle.add_updateinfoxml(f, 0)
+       Solv::xfclose(f)
       end
     end
     add_exts()
@@ -374,17 +374,17 @@ class Repo_susetags < Repo_generic
     if filename
       f = download("#{descrdir}/#{filename}", true, filechksum, true)
       if f
-        @handle.add_susetags(f, defvendorid, nil, Solv::Repo::REPO_NO_INTERNALIZE|Solv::Repo::SUSETAGS_RECORD_SHARES)
-        Solv::xfclose(f)
+       @handle.add_susetags(f, defvendorid, nil, Solv::Repo::REPO_NO_INTERNALIZE|Solv::Repo::SUSETAGS_RECORD_SHARES)
+       Solv::xfclose(f)
        (filename, filechksum) = find('packages.en.gz')
        (filename, filechksum) = find('packages.en') unless filename
-        if filename
-          f = download("#{descrdir}/#{filename}", true, filechksum, true)
-          if f
-            @handle.add_susetags(f, defvendorid, nil, Solv::Repo::REPO_NO_INTERNALIZE|Solv::Repo::REPO_REUSE_REPODATA|Solv::Repo::REPO_EXTEND_SOLVABLES)
-            Solv::xfclose(f)
-          end
-        end
+       if filename
+         f = download("#{descrdir}/#{filename}", true, filechksum, true)
+         if f
+           @handle.add_susetags(f, defvendorid, nil, Solv::Repo::REPO_NO_INTERNALIZE|Solv::Repo::REPO_REUSE_REPODATA|Solv::Repo::REPO_EXTEND_SOLVABLES)
+           Solv::xfclose(f)
+         end
+       end
        @handle.internalize()
       end
     end
@@ -419,8 +419,8 @@ class Repo_susetags < Repo_generic
       repodata.add_idarray(h, Solv::REPOSITORY_KEYS, Solv::REPOKEY_TYPE_DIRSTRARRAY)
     else
       @@langtags.sort.each do |langid, langtype|
-        repodata.add_idarray(h, Solv::REPOSITORY_KEYS, @handle.pool.id2langid(langid, ext, true))
-        repodata.add_idarray(h, Solv::REPOSITORY_KEYS, langtype)
+       repodata.add_idarray(h, Solv::REPOSITORY_KEYS, @handle.pool.id2langid(langid, ext, true))
+       repodata.add_idarray(h, Solv::REPOSITORY_KEYS, langtype)
       end
     end
     repodata.add_flexarray(Solv::SOLVID_META, Solv::REPOSITORY_EXTERNAL, h)
@@ -520,11 +520,11 @@ for reposdir in reposdirs do
       repoattr = { 'alias' => ali, 'enabled' => 0, 'priority' => 99, 'autorefresh' => 1, 'type' => 'rpm-md', 'metadata_expire' => 900}
       repoattr.update(cfg[ali])
       if repoattr['type'] == 'rpm-md'
-        repo = Repo_rpmmd.new(ali, 'repomd', repoattr)
+       repo = Repo_rpmmd.new(ali, 'repomd', repoattr)
       elsif repoattr['type'] == 'yast2'
-        repo = Repo_susetags.new(ali, 'susetags', repoattr)
+       repo = Repo_susetags.new(ali, 'susetags', repoattr)
       else
-        repo = Repo_unknown.new(ali, 'unknown', repoattr)
+       repo = Repo_unknown.new(ali, 'unknown', repoattr)
       end
       repos.push(repo)
     end
@@ -595,20 +595,20 @@ if cmd == 'list' || cmd == 'info'
   abort("no package matched.") if jobs.empty?
     for job in jobs
       for s in job.solvables()
-        if cmd == 'info'
+       if cmd == 'info'
          puts "Name:        #{s.str}"
-          puts "Repo:        #{s.repo.name}"
-          puts "Summary:     #{s.lookup_str(Solv::SOLVABLE_SUMMARY)}"
-          str = s.lookup_str(Solv::SOLVABLE_URL)
-          puts "Url:         #{str}" if str
-          str = s.lookup_str(Solv::SOLVABLE_LICENSE)
-          puts "License:     #{str}" if str
-          puts "Description:\n#{s.lookup_str(Solv::SOLVABLE_DESCRIPTION)}"
-          puts
-        else
+         puts "Repo:        #{s.repo.name}"
+         puts "Summary:     #{s.lookup_str(Solv::SOLVABLE_SUMMARY)}"
+         str = s.lookup_str(Solv::SOLVABLE_URL)
+         puts "Url:         #{str}" if str
+         str = s.lookup_str(Solv::SOLVABLE_LICENSE)
+         puts "License:     #{str}" if str
+         puts "Description:\n#{s.lookup_str(Solv::SOLVABLE_DESCRIPTION)}"
+         puts
+       else
          puts "  - #{s.str} [#{s.repo.name}]"
          puts "    #{s.lookup_str(Solv::SOLVABLE_SUMMARY)}"
-        end
+       end
       end
     end
   exit
@@ -619,9 +619,9 @@ if cmd == 'install' || cmd == 'erase' || cmd == 'up' || cmd == 'dup' || cmd == '
   for job in jobs
     if cmd == 'up'
       if job.how == Solv::Job::SOLVER_SOLVABLE_ALL || job.solvables.any? {|s| s.isinstalled?}
-        job.how |= Solv::Job::SOLVER_UPDATE
+       job.how |= Solv::Job::SOLVER_UPDATE
       else
-        job.how |= Solv::Job::SOLVER_INSTALL
+       job.how |= Solv::Job::SOLVER_INSTALL
       end
     elsif cmd == 'install'
       job.how |= Solv::Job::SOLVER_INSTALL
@@ -656,21 +656,21 @@ if cmd == 'install' || cmd == 'erase' || cmd == 'up' || cmd == 'dup' || cmd == '
       end
       sol = nil
       while true
-        print "Please choose a solution: "
-        STDOUT.flush
-        sol = STDIN.gets.strip
-        break if sol == 's' || sol == 'q'
-        break if sol =~ /^\d+$/ && sol.to_i >= 1 && sol.to_i <= solutions.length
+       print "Please choose a solution: "
+       STDOUT.flush
+       sol = STDIN.gets.strip
+       break if sol == 's' || sol == 'q'
+       break if sol =~ /^\d+$/ && sol.to_i >= 1 && sol.to_i <= solutions.length
       end
       next if sol == 's'
       abort if sol == 'q'
       solution = solutions[sol.to_i - 1]
       for element in solution.elements
-        newjob = element.Job()
-        if element.type == Solv::Solver::SOLVER_SOLUTION_JOB
-          jobs[element.jobidx] = newjob
+       newjob = element.Job()
+       if element.type == Solv::Solver::SOLVER_SOLUTION_JOB
+         jobs[element.jobidx] = newjob
        else
-          jobs.push(newjob) if newjob && !jobs.include?(newjob)
+         jobs.push(newjob) if newjob && !jobs.include?(newjob)
        end
       end
     end