-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
syncx_local.py
63 lines (48 loc) · 1.68 KB
/
syncx_local.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
''' A test script.
@author: Jonathan Coombs, copyright sil.org 2012-2014
'''
#Force Python 3 syntax
from syncxml import local_launch
from syncxml import xml_util as X
from syncxml import syncxml as SX
from syncxml import logg as L
import os
def get_path(name):
f = SX.get_first_lift_file(os.path.join("..", "tests", name))
return f
def get_lift_paths():
L = os.listdir(os.path.join("..", "tests"))
L2 = [get_path(x) for x in L]
return L2
def count_ws():
pass
def tests():
"""Some quick and dirty tests on auto-configuring and reading some actual LIFT files.
Note: on my test machine, some of these have corresponding FLEx media folders, here:
C:\ProgramData\SIL\FieldWorks\Projects\Bambara flashcards\LinkedFiles
C:\ProgramData\SIL\FieldWorks\Projects\Moma-temp\LinkedFiles"""
L.init(SX.LOG_FP, L.VERBOSITY_DEBUG)
paths = get_lift_paths()
#expected = dict()
#expected['cgg'] =
from time import sleep
for p in paths:
""" WAS:
# analyze the WSes in this file
size = os.path.getsize(p)
L.debug("File {} is {} bytes".format(p, size))
lift_few = X.get_lift_subset(p, 30) # .tmp
langs = X.XmlLiftLangs(lift_few)
v = langs.vern_ws
n = langs.nat_ws
os.remove(lift_few)
"""
local_launch.main(p)
sleep(0.5) # give Notepad a chance to open
#count_ws()
L.close_file()
if (__name__ == '__main__'):
# If we're here, we're not running inside Anki, but we can still test/debug various pieces...
os.chdir('syncxml') # go down one level, so we're in the same relative position as the Anki add-on
tests()
local_launch.main()