<commit_before>'''
    Gmvault: a tool to backup and restore your gmail account.
    Copyright (C) <2011-2012>  <<NAME> (<EMAIL> dot <EMAIL> at gmail do com)>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import socket
import sys
import datetime
import os

import argparse
import log_utils
import imaplib
import gmvault_utils
import gmvault

from cmdline_utils  import CmdLineParser
from credential_utils import CredentialHelper

GMVAULT_VERSION="1.6-beta"

GLOBAL_HELP_EPILOGUE="""Examples:

a) Get help for each of the individual commands

#> gmvault sync -h
#> gmvault restore --help

"""

REST_HELP_EPILOGUE = """Examples:

a) Complete restore of your gmail account (backed up in ~/gmvault-db) into <EMAIL> 

#> gmvault restore -d ~/gmvault-db <EMAIL>

b) Quick restore (restore only the last 2 months to make regular updates) of your gmail account into <EMAIL> 

#> gmvault restore --type quick -d ~/gmvault-db <EMAIL>

c) Restart a restore after a previous error (Gmail can cut the connection if it is too long)

#> gmvault restore -d ~/gmvault-db <EMAIL> --resume

d) Add label to all restored emails

#> gmvault restore --label '20120422-gmvault-restore' -d ~/gmvault-db <EMAIL>
"""

SYNC_HELP_EPILOGUE = """Examples:

a) Full synchronisation with email and oauth login in ./gmvault-db

#> gmvault sync <EMAIL>

b) Quick daily synchronisation (only the last 2 months are scanned)

#> gmvault sync --type quick <EMAIL>

c) Custom synchronisation with an IMAP request for advance users

#> gmvault sync --type custom --imap-req 'Since 1-Nov-2011 Before 10-Nov-2011' '<EMAIL>'

d) Custom synchronisation with an Gmail request for advance users

#> gmvault sync --type custom --gmail-req 'in:inbox from:foo' '<EMAIL>'

e) Resume Full synchronisation  from where it failed to not go through your mailbox again

#> gmvault sync '<EMAIL>' --resume



"""

LOG = log_utils.LoggerFactory.get_logger('gmv')

class NotSeenAction(argparse.Action):
    """
       to differenciate between a seen and non seen command
    """
    def __call__(self, parser, namespace, values, option_string=None):
        if values:
            setattr(namespace, self.dest, 'empty')
        else:
            setattr(namespace, self.dest, values)

class GMVaultLauncher(object):
    <commit_msg>change single quote in double quotes<commit_after>'''
    Gmvault: a tool to backup and restore your gmail account.
    Copyright (C) <2011-2012>  <<NAME> (guillaume dot aubert at gmail do com)>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''

import socket
import sys
import datetime
import os

import argparse
import log_utils
import imaplib
import gmvault_utils
import gmvault

from cmdline_utils  import CmdLineParser
from credential_utils import CredentialHelper

GMVAULT_VERSION="1.6-beta"

GLOBAL_HELP_EPILOGUE="""Examples:

a) Get help for each of the individual commands

#> gmvault sync -h
#> gmvault restore --help

"""

REST_HELP_EPILOGUE = """Examples:

a) Complete restore of your gmail account (backed up in ~/gmvault-db) into <EMAIL> 

#> gmvault restore -d ~/gmvault-db <EMAIL>

b) Quick restore (restore only the last 2 months to make regular updates) of your gmail account into <EMAIL> 

#> gmvault restore --type quick -d ~/gmvault-db <EMAIL>

c) Restart a restore after a previous error (Gmail can cut the connection if it is too long)

#> gmvault restore -d ~/gmvault-db <EMAIL> --resume

d) Add label to all restored emails

#> gmvault restore --label "20120422-gmvault-restore" -d ~/gmvault-db <EMAIL>
"""

SYNC_HELP_EPILOGUE = """Examples:

a) Full synchronisation with email and oauth login in ./gmvault-db

#> gmvault sync <EMAIL>

b) Quick daily synchronisation (only the last 2 months are scanned)

#> gmvault sync --type quick <EMAIL>

c) Custom synchronisation with an IMAP request for advance users

#> gmvault sync --type custom --imap-req "Since 1-Nov-2011 Before 10-Nov-2011" <EMAIL>

d) Custom synchronisation with an Gmail request for advance users

#> gmvault sync --type custom --gmail-req "in:inbox from:foo" <EMAIL>

e) Resume Full synchronisation  from where it failed to not go through your mailbox again

#> gmvault sync <EMAIL> --resume



"""

LOG = log_utils.LoggerFactory.get_logger('gmv')

class NotSeenAction(argparse.Action):
    """
       to differenciate between a seen and non seen command
    """
    def __call__(self, parser, namespace, values, option_string=None):
        if values:
            setattr(namespace, self.dest, 'empty')
        else:
            setattr(namespace, self.dest, values)

class GMVaultLauncher(object):
    
{'fraction_non_alphanumeric': 0.08362128541810643, 'fraction_numerical': 0.0110573600552868, 'mean_word_length': 3.737315875613748, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3580092', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1753, 'n_words': 737}