-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --google-takeout-flagged-labels #51
Open
poldy79
wants to merge
1
commit into
rgladwell:master
Choose a base branch
from
poldy79:feature/spefify-flagged-labels
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,8 @@ def __init__(self): | |
help="Priority of labels, if --google-takeout-first-label is used") | ||
self.add_option("--google-takeout-language", | ||
help="[Use specific language. Supported languages: '%s'. " % (" ".join(self.google_takeout_supported_languages)) + "default: %default]" ) | ||
self.add_option("--google-takeout-flagged-labels", type="string", | ||
help="Mark Mails with given labels (comma separated) as flagged, by default the Important flag is used. Labels have to be specified according to the language of your export") | ||
self.add_option("--debug", action="store_true", | ||
help="Debug: Make some error messages more verbose.") | ||
self.add_option("--dry-run", action="store_true", | ||
|
@@ -119,7 +121,8 @@ def __init__(self): | |
google_takeout_first_label=False, | ||
google_takeout_label_priority="", | ||
google_takeout_language="en", | ||
debug=False, | ||
google_takeout_flagged_labels="", | ||
debug=False | ||
dry_run=False, | ||
) | ||
|
||
|
@@ -250,7 +253,7 @@ class Progress(): | |
"""Store and output progress information.""" | ||
|
||
def __init__(self, total_count, google_takeout=False, google_takeout_first_label=False, | ||
google_takeout_label_priority=None, google_takeout_language="en"): | ||
google_takeout_label_priority=None, google_takeout_language="en", google_takeout_flagged_labels=""): | ||
self.total_count = total_count | ||
self.ok_count = 0 | ||
self.count = 0 | ||
|
@@ -260,6 +263,7 @@ def __init__(self, total_count, google_takeout=False, google_takeout_first_label | |
self.google_takeout_first_label = google_takeout_first_label | ||
self.google_takeout_label_priority = google_takeout_label_priority | ||
self.google_takeout_language = google_takeout_language | ||
self.google_takeout_flagged_labels = google_takeout_flagged_labels.split(',') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about someone using:
Please check |
||
|
||
def begin(self, msg): | ||
"""Called when start proccessing of a new message.""" | ||
|
@@ -355,9 +359,13 @@ def begin(self, msg): | |
else: | ||
flags.append('\Seen') | ||
|
||
if labels.count(gmail_important_str) > 0: | ||
flags.append('\Flagged') | ||
labels.remove(gmail_important_str) | ||
if len(self.google_takeout_flagged_labels) == 0: | ||
self.google_takeout_flagged_labels = [gmail_important_str] | ||
|
||
for label in self.google_takeout_flagged_labels: | ||
if labels.count(label) > 0: | ||
flags.append('\Flagged') | ||
labels.remove(label) | ||
|
||
if ((labels.count(gmail_sent_str) > 0) and (len(labels) > 1)): | ||
labels.remove(gmail_sent_str) | ||
|
@@ -422,13 +430,14 @@ def endAll(self): | |
|
||
|
||
def upload(imap, box, src, err, time_fields, google_takeout=False, google_takeout_first_label=False, | ||
google_takeout_label_priority=None, google_takeout_box_as_base_folder=False, google_takeout_language="en", | ||
debug=False): | ||
google_takeout_label_priority=None, google_takeout_box_as_base_folder=False, google_takeout_language="en", | ||
google_takeout_flagged_labels="", debug=False): | ||
print("Uploading to {}...".format(box)) | ||
print("Counting the mailbox (it could take a while for the large one).") | ||
p = Progress(len(src), google_takeout=google_takeout, google_takeout_first_label=google_takeout_first_label, | ||
google_takeout_label_priority=google_takeout_label_priority, | ||
google_takeout_language=google_takeout_language) | ||
google_takeout_language=google_takeout_language, | ||
google_takeout_flagged_labels=google_takeout_flagged_labels) | ||
for i, msg in src.iteritems(): | ||
try: | ||
p.begin(msg) | ||
|
@@ -717,6 +726,7 @@ def main(args=None): | |
google_takeout_first_label = options.pop("google_takeout_first_label") | ||
google_takeout_label_priority = options.pop("google_takeout_label_priority").split(",") | ||
google_takeout_language = options.pop("google_takeout_language") | ||
google_takeout_flagged_labels = options.pop("google_takeout_flagged_labels") | ||
debug = options.pop("debug") | ||
|
||
|
||
|
@@ -741,7 +751,8 @@ def main(args=None): | |
if err: | ||
err = mailbox.mbox(err) | ||
upload(uploader, options["box"], src, err, time_fields, google_takeout, google_takeout_first_label, | ||
google_takeout_label_priority, google_takeout_box_as_base_folder, google_takeout_language, debug) | ||
google_takeout_label_priority, google_takeout_box_as_base_folder, google_takeout_language, | ||
google_takeout_flagged_labels, debug) | ||
else: | ||
recursive_upload(uploader, "", src, err, time_fields, email_only_folders, separator) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this even run?
Shouldn't
debug=False
bedebug=False,
(with a comma) as it's not the latest parametre?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry - had to rebase and did not test... will fix that..