From: Riccardo Murri Date: Thu, 3 Jan 2008 03:15:11 +0000 (+0100) Subject: Add option '-f' for sync'ing only selected folders X-Git-Tag: last-darcs-commit~1 X-Git-Url: https://code.delx.au/offlineimap/commitdiff_plain/ec89c3eb5364b6f741f6138752ab8fd0f9ebbd96 Add option '-f' for sync'ing only selected folders --- diff --git a/offlineimap.sgml b/offlineimap.sgml index 1fc5bd6..c0498d1 100644 --- a/offlineimap.sgml +++ b/offlineimap.sgml @@ -373,6 +373,15 @@ cd offlineimap-x.y.z will debug the threading model. + -f foldername[,foldername] + Only sync the specified folders. The + foldernames are the + untranslated foldernames. This command-line option + overrides any folderfilter + and folderincludes options in the + configuration file. + + -k [section:]option=value Override configuration file option. If diff --git a/offlineimap/init.py b/offlineimap/init.py index d901864..ca09919 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -53,7 +53,7 @@ def startup(versionno): sys.stdout.write(version.getcmdhelp() + "\n") sys.exit(0) - for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:hk:')[0]: + for optlist in getopt(sys.argv[1:], 'P:1oqa:c:d:l:u:hk:f:')[0]: options[optlist[0]] = optlist[1] if options.has_key('-h'): @@ -115,6 +115,20 @@ def startup(versionno): for section in accounts.getaccountlist(config): config.set('Account ' + section, "quick", '-1') + if options.has_key('-f'): + foldernames = options['-f'].replace(" ", "").split(",") + folderfilter = "lambda f: f in %s" % foldernames + folderincludes = "[]" + for accountname in accounts.getaccountlist(config): + account_section = 'Account ' + accountname + remote_repo_section = 'Repository ' + \ + config.get(account_section, 'remoterepository') + local_repo_section = 'Repository ' + \ + config.get(account_section, 'localrepository') + for section in [remote_repo_section, local_repo_section]: + config.set(section, "folderfilter", folderfilter) + config.set(section, "folderincludes", folderincludes) + lock(config, ui) try: diff --git a/offlineimap/version.py b/offlineimap/version.py index 0a46dec..0713fad 100644 --- a/offlineimap/version.py +++ b/offlineimap/version.py @@ -94,6 +94,13 @@ def getcmdhelp(): one else. The maildir option will enable debugging for certain Maildir operations. + -f foldername[,foldername...] + Only sync the specified folders. The "foldername"s + are the *untranslated* foldernames. This + command-line option overrides any "folderfilter" + and "folderincludes" options in the configuration + file. + -k [section:]option=value Override configuration file option. If"section" is omitted, it defaults to "general". Any underscores