obsolete/exp_anki.py
changeset 667 5f69f0776c37
parent 555 4a3188fc8951
child 668 e22ffba8ecc0
equal deleted inserted replaced
666:ef697459f88e 667:5f69f0776c37
       
     1 import sys
       
     2 import tempfile
       
     3 
     1 FONAME = "test.apkg"
     4 FONAME = "test.apkg"
     2 
     5 
     3 # Looks like anki libs change working directory to media directory of current deck
     6 # Looks like anki libs change working directory to media directory of current deck
     4 # Therefore absolute path should be stored before creating temporary deck
     7 # Therefore absolute path should be stored before creating temporary deck
     5 FONAME = os.path.abspath(FONAME)
     8 FONAME = os.path.abspath(FONAME)
     6 FBASENAME, _ = os.path.splitext(os.path.basename(FONAME))
     9 FBASENAME, _ = os.path.splitext(os.path.basename(FONAME))
     7 TMPDIR = tempfile.mkdtemp(dir = os.path.dirname(FONAME))
    10 TMPDIR = tempfile.mkdtemp(dir = os.path.dirname(FONAME))
     8 
    11 
       
    12 sys.path.append('/usr/share/anki')
     9 import anki
    13 import anki
    10 from anki.exporting import AnkiPackageExporter
    14 from anki.exporting import AnkiPackageExporter
    11 
    15 
    12 collection = anki.Collection(os.path.join(TMPDIR, 'collection.anki2'))
    16 collection = anki.Collection(os.path.join(TMPDIR, 'collection.anki2'))
    13 
    17