]> git.cworth.org Git - sup/commitdiff
fixed percent_done thing
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Thu, 4 Jan 2007 06:17:11 +0000 (06:17 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Thu, 4 Jan 2007 06:17:11 +0000 (06:17 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@172 5c8cc53c-5e98-4d25-b20a-d8db53a31250

bin/sup-import
lib/sup/imap.rb
lib/sup/mbox/loader.rb

index da344830f6743606bab495f9d33d5b2f99a42158..c7e52722a733ae7f1e644c74ad103f868a32d145 100644 (file)
@@ -49,6 +49,7 @@ the following options:
   --force-read:    any messages found will not be marked as new.
 
 The following options can also be specified:
+  --verbose:       print message ids as they're processed
   --the-usual:     import new messages from all usual sources
   --rebuild:       rebuild the index for the specified sources rather than
                    just adding new messages. Useful if the sources
@@ -62,6 +63,7 @@ The following options can also be specified:
 EOS
   exit
 end
+#' stupid ruby-mode
 
 ## for sources that require login information, prompt the user for
 ## that. also provide a list of previously-defined login info to
@@ -105,6 +107,7 @@ the_usual = ARGV.delete "--the-usual"
 rebuild = ARGV.delete "--rebuild"
 force_rebuild = ARGV.delete "--force-rebuild"
 optimize = ARGV.delete "--optimize"
+verbose = ARGV.delete "--verbose"
 start_at = # ok really need to use optparse or something now
   if(i = ARGV.index("--start-at"))
     raise "start-at requires a numeric argument: #{ARGV[i + 1].inspect}" unless ARGV.length > (i + 1) && ARGV[i + 1] =~ /\d/
@@ -179,7 +182,7 @@ begin
         end
 
         m.remove_label :unread if m.source_marked_read? unless force_read
-        puts "# message at #{offset}, labels: #{labels * ', '}" unless rebuild
+        puts "# message at #{offset}, labels: #{labels * ', '}" if verbose unless rebuild
         if (rebuild || force_rebuild) && 
             (docid, entry = index.load_entry_for_id(m.id)) && entry
           if force_rebuild || entry[:source_info].to_i != offset
index 5aeac178c62baf2d1b094872b4b8a82812960e2d..3136e0a03e949816709de9a9c11a8ae10b7c200c 100644 (file)
@@ -204,6 +204,8 @@ class IMAP < Source
     @mutex.synchronize { connect or raise SourceError, broken_msg }
     @ids.last
   end
+
+  def pct_done; 100.0 * (@ids.index(cur_offset) || 0).to_f / (@ids.length - 1).to_f; end
 end
 
 Redwood::register_yaml(IMAP, %w(uri username password cur_offset usual archived id))
index 4013d4d9f43b167c25920cbfb4668e4382921dec..68438ec1fc622c08823efbd9d87e6f1665f0ee2d 100644 (file)
@@ -29,7 +29,7 @@ class Loader < Source
 
   def start_offset; 0; end
   def end_offset; File.size @f; end
-  def total; end_offset; end
+  def pct_done; 100.0 * cur_offset.to_f / end_offset.to_f; end
 
   def load_header offset
     header = nil