forked from fikovnik/omnigraffle-export
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TODO.taskpaper
70 lines (67 loc) · 7.32 KB
/
TODO.taskpaper
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
64
65
66
67
68
69
70
Features:
- replace colors in update_colors_and_fonts
- plugin: update_colors_and_fonts is unfinished
Translations:
✔ build translations: extract text from attribute runs, not from text!!! @done (17-11-19 19:25)
✔ infer name of PO-file from source file if not specified @done (17-11-20 13:48)
✔ translate full folder if specified @done (17-11-20 13:48)
✔ refactor open copy of document to target and source filename @done (17-11-20 13:48)
Refactorings:
- try py-applescript instead of py-appscript: https://pypi.org/project/py-applescript/
- refactor data model (and Item.walk()) so that it tries all possible child elements with each element). That may lead to even more elements being properly accessed. the ID cache should prevent the script from taking too long.
Known Bugs:
- Item.walk() does not find all elements, e.g. ogtranslate does not find texts shared layers, most likely because of problems in pyappscript (see below)
> "It doesn’t look like there’s a simple way to convert layers, no. But I suspect the solution is simply to access the graphics of the layers of the canvases, rather than accessing the graphics of the canvases. (At least, that’s how you’d solve it in straight AppleScript:<graphics of first canvas> doesn’t include graphics from shared layers, but<graphics of layers of first canvas> does.)"
✔ Item.walk() does not process groups and/or subgraphs @done (17-11-20 13:48)
- ogtranslate apparently does not translate line labels
Notes on shared layers problem:
item.walk bugfix:
Observations:
Dumping texts from S3 Delegation Canvas (and S3 Org canvas):
all section titles were missing from the text (shared layer)
each text from layer "box text" was duplicated (two canvases had that layer, so we had each text 4 times)
more info, license and version layers were ignored entirely
Dumping texts from S3 Team Canvas:
first canvas: all texts from header text, section titles, box text (in that order, then repeated)
second canvas: header text, section titles (again in that order, and repeated)
third canvas: header text, section titles, box text, header text (all then repeated again)
Fiddling around with the debugger and data model:
some elements are not referenced properly, accessing id() or class() results in a appscript.reference.CommandError.
it appears that all these elements are all in shared layers
Traceback (most recent call last):
File "/Users/beb/dev/.virtualenvs/omnigraffle-export/bin/ogtool", line 11, in <module>
load_entry_point('ogtool', 'console_scripts', 'ogtool')()
File "/Users/beb/dev/omnigraffle-export/ogtools/ogtool.py", line 218, in main
ogtool.args.func(ogtool)
File "/Users/beb/dev/omnigraffle-export/ogtools/ogtool.py", line 140, in cmd_run_plugin
plugin.main(self.doc, config, self.args.canvas, self.args.verbose)
File "/Users/beb/dev/omnigraffle-export/ogplugins/list_nodes.py", line 33, in main
d.walk(partial(list_nodes, nodes))
File "/Users/beb/dev/omnigraffle-export/omnigraffle/data_model.py", line 50, in walk
debug('::::', self.item_info())
File "/Users/beb/dev/omnigraffle-export/omnigraffle/data_model.py", line 70, in item_info
return "(%s) %s == %s (%s...)" % (self.id, self.class_, self.name, self.text[:20])
File "/Users/beb/dev/omnigraffle-export/omnigraffle/data_model.py", line 95, in id
return self.item.id()
File "build/bdist.macosx-10.11-x86_64/egg/appscript/reference.py", line 642, in __call__
File "build/bdist.macosx-10.11-x86_64/egg/appscript/reference.py", line 498, in __call__
appscript.reference.CommandError: Command failed:
OSERROR: -1728
MESSAGE: Can't get reference.
OFFENDING OBJECT: app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-list_nodes.graffle'].id
COMMAND: app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-list_nodes.graffle'].id.get()
Layers():
[app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[1], app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[u'section titles'], app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[u'title'], app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[u'license'], app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[u'version'], app(u'/Applications/images/OmniGraffle.app').documents[u's3-dg-test-debug.graffle'].canvases.ID(6).layers[u'more-info']]
Graphics() in a shared layer:
[app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1047)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1045)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1043)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1040)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1039)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1037)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1035)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1033)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1032)), app(u'/Applications/images/OmniGraffle.app').AS_newreference(app.elements('docu').byname(u's3-dg-test-debug.graffle').elements('\x00\x00\x00\x00').byid(10).elements('OGGr').byid(1029))]
Conclusion:
after eliminating bugs some small bugs and streamlining the code it appears that the problem is in the way appscript treats shared layers. Until that is fixed, it's best to avoid shared layers in any documents, or maybe write an apple script that converts shared layers to "real" layers.
Fixes:
- fix erroneous skipping of visible layers @done(2017-08-22)
- create a debug plugin that drops into debugger for each canvas @done(2017-08-23)
- fix command error for layers @done(2017-08-23)
- move layer to first position in canvas @done(2017-08-23)
- check if having only layers in canvas changes number of items and numbers of visits! @done(2017-08-23)
- skip duplicates when walking @done(2017-08-23)
Documentation:
- make a better readme, create separate files for each command?