Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser(prog=None,
            description="Convert Evernote.enex files to Markdown",
            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('enex_file', help="the path to the Evernote.enex file")
    parser.add_argument('-o', '--output',
            help="the path to the output file or directory, omit to output to the terminal (stdout)")
    parser.add_argument('-f', '--format',
            help="the output format, json, csv or a directory",
            choices=['json', 'csv', 'dir'], default='json')
    parser.add_argument('-m', '--metadata',
            help="For directory output only. Specify the metadata you\
            would like to add on top of the markdown file. Valid options are\
            'all', 'title', 'created', and 'keywords'. Default is 'all'. You can\
            specify this argument multiple times, by which you can also control\
            the order in which metadata lines are printed.\
            Metadata is printed in MultiMarkdown format.",
            choices=['all', 'title', 'date', 'keywords'],
            action='append')
    
    args = parser.parse_args()
    filepath = os.path.expanduser(args.enex_file)
    if not os.path.exists(filepath):
        print 'File does not exist: {}'.format(filepath)
        sys.exit(1)
    converter = EverConverter(filepath, args.output, args.format, args.metadata)
    converter.convert()
    sys.exit()
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser(
        prog=None,
        description="Convert Evernote.enex files to Markdown",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('enex-file', help="the path to the Evernote.enex file")
    parser.add_argument(
        '-o',
        '--output',
        help=
        "the path to the output file or directory, leave black to output to the terminal (stdout)"
    )
    parser.add_argument('-f',
                        '--format',
                        help="the output format, json, csv or a directory",
                        choices=['json', 'csv', 'dir'],
                        default='json')
    args = parser.parse_args()
    enex_file = vars(args)['enex-file']
    output = args.output
    fmt = args.format
    filepath = os.path.expanduser(enex_file)
    if not os.path.exists(filepath):
        print 'File does not exist: %s' % filepath
        sys.exit(1)
    converter = EverConverter(filepath, simple_filename=output, fmt=fmt)
    converter.convert()
    sys.exit()
Ejemplo n.º 3
0
def main():
    args = sys.argv[1:]
    if len(args) != 1:
        print 'Usage: ever2simple <enex_file>'
        sys.exit(1)
    filepath = os.path.expanduser(args[0])
    if not os.path.exists(filepath):
        print 'File does not exist: %s' % filepath
        sys.exit(1)
    converter = EverConverter(filepath)
    converter.convert()
    sys.exit()
Ejemplo n.º 4
0
def main():
    parser = argparse.ArgumentParser(prog=None, description="Convert Evernote.enex files to Markdown", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('enex-file', help="the path to the Evernote.enex file")
    parser.add_argument('-o', '--output', help="the path to the output file or directory, leave black to output to the terminal (stdout)")
    parser.add_argument('-f', '--format', help="the output format, json, csv or a directory", choices=['json', 'csv', 'dir'], default='json')
    args = parser.parse_args()
    enex_file = vars(args)['enex-file']
    output = args.output
    fmt = args.format
    filepath = os.path.expanduser(enex_file)
    if not os.path.exists(filepath):
        print 'File does not exist: %s' % filepath
        sys.exit(1)
    converter = EverConverter(filepath, simple_filename=output, fmt=fmt)
    converter.convert()
    sys.exit()
Ejemplo n.º 5
0
def main():
    parser = argparse.ArgumentParser(
        prog=None,
        description="Convert Evernote.enex files to Markdown",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('enex-file', help="the path to the Evernote.enex file")
    parser.add_argument(
        '-o',
        '--output',
        help=("the path to the output file or directory, leave blank to "
              "output to the terminal (stdout)"))
    parser.add_argument('-f',
                        '--format',
                        help="the output format, json, csv or a directory",
                        choices=['json', 'csv', 'dir'],
                        default='json')
    parser.add_argument('--preserve_title',
                        action="store_true",
                        help="Try to preserve the note title as the file name",
                        default=False)
    parser.add_argument('-v',
                        '--verbose',
                        action="store_true",
                        help="Increase output verbosity",
                        default=False)
    args = parser.parse_args()
    enex_file = vars(args)['enex-file']
    output = args.output
    fmt = args.format
    preserve_title = args.preserve_title
    verbose = args.verbose
    filepath = os.path.expanduser(enex_file)

    if not os.path.exists(filepath):
        print('File does not exist: {}'.format(filepath))
        sys.exit(1)
    converter = EverConverter(filepath,
                              simple_filename=output,
                              fmt=fmt,
                              preserve_title=preserve_title,
                              verbose=verbose)
    converter.convert()
    sys.exit()
Ejemplo n.º 6
0
def main():
    parser = argparse.ArgumentParser(
        prog=None,
        description="Convert Evernote.enex files to Markdown",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        'enex-file',
        help="the path to the Evernote.enex file")
    parser.add_argument(
        '-o', '--output',
        help=("the path to the output file or directory, leave blank to "
              "output to the terminal (stdout)"))
    parser.add_argument(
        '-f', '--format',
        help="the output format, json, csv or a directory",
        choices=['json', 'csv', 'dir'],
        default='json')
    parser.add_argument(
        '--preserve_title',
        action="store_true",
        help="Try to preserve the note title as the file name",
        default=False)
    parser.add_argument(
        '-v', '--verbose',
        action="store_true",
        help="Increase output verbosity",
        default=False)
    args = parser.parse_args()
    enex_file = vars(args)['enex-file']
    output = args.output
    fmt = args.format
    preserve_title = args.preserve_title
    verbose = args.verbose
    filepath = os.path.expanduser(enex_file)

    if not os.path.exists(filepath):
        print('File does not exist: {}'.format(filepath))
        sys.exit(1)
    converter = EverConverter(filepath, simple_filename=output, fmt=fmt,
                              preserve_title=preserve_title, verbose=verbose)
    converter.convert()
    sys.exit()
Ejemplo n.º 7
0
def import_simplenote(enex_filename, sn_username, sn_password):
    converter = EverConverter(enex_filename)

    with open(enex_filename) as enex_file:
        xml_tree = converter._load_xml(enex_file)
    ev_notes = converter.prepare_notes(xml_tree)

    sn = simplenote.Simplenote(sn_username, sn_password)
    
    for ev_note in ev_notes:
        sn_note = {}

        # Convert times to Unix timestamps
        sn_note['createdate'] = date_parser.parse(ev_note['createdate']).strftime('%s')
        sn_note['modifydate'] = date_parser.parse(ev_note['modifydate']).strftime('%s')

        # Encode as UTF-8 as that is what simplenote expects, it doesn't
        # like taking unicode strings in directly
        sn_note['content'] = ev_note['content'].encode('utf-8')
        sn_note['tags'] = ev_note['tags']

        sn.add_note(sn_note)