File: get-note-from-server.py

package info (click to toggle)
nvpy 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,208 kB
  • sloc: python: 3,185; makefile: 26; sh: 11
file content (33 lines) | stat: -rwxr-xr-x 716 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
# Usage:
#   ./get-note-from-server.py note_id

import json
import os
import sys
from configparser import ConfigParser

import simplenote

note_id = sys.argv[1]

home = os.path.abspath(os.path.expanduser('~'))
cfg_files = [
    # os.path.join(app_dir, 'nvpy.cfg'),
    os.path.join(home, 'nvpy.cfg'),
    os.path.join(home, '.nvpy.cfg'),
    os.path.join(home, '.nvpy'),
    os.path.join(home, '.nvpyrc'),
]

cp = ConfigParser()
cp.read(cfg_files)
user = cp.get('nvpy', 'sn_username', raw=True)
passwd = cp.get('nvpy', 'sn_password', raw=True)

sn = simplenote.Simplenote(user, passwd)
note, status = sn.get_note(note_id)
if status == 0:
    print(json.dumps(note))
else:
    print(str(note))