Did I find the right examples for you? yes no

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Create folders and subfolders on Gmail in order
to recreate the label hierarchy before to upload emails
Note that adding labels with +X-GM-LABELS create only nested labels
but not nested ones. This is why this trick must be used to 
recreate the label hierarchy

labels: list of labels to create

src/g/m/gmvault-HEAD/src/gmvault_tests.py   gmvault(Download)
        existing_folders = set()
 
        existing_folders = gimap.create_gmail_labels(labels_to_create, existing_folders)
 
        print("folders = %s\n" % (existing_folders))
        existing_folders = set()
 
        existing_folders = gimap.create_gmail_labels(labels_to_create, existing_folders)
 
        print("folders = %s\n" % (existing_folders))
        existing_folders = set()
 
        existing_folders = gimap.create_gmail_labels(labels_to_create, existing_folders)
 
        #get existing directories (or label parts)
        labels_to_create = [u'[RETEST]', u'[RETEST]/test', u'[RETEST]/Trash', u'[IMAP]/Trash', u'[IMAP]/Draft', u'[IMAP]/Sent', u'[IMAP]']
 
        existing_folders = gimap.create_gmail_labels(labels_to_create, existing_folders)
 
        folders = [ directory.lower() for directory in existing_folders ]