-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
61 lines (44 loc) · 1.67 KB
/
main.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
# by lei
# coding: utf-8
import os
import parseSketch
import globalData
import utils
import parseConfig
import layout.autoLayout
import layout.checkFlex
import layout.getCode
import layout.initConfig
# sketchFile = './res/storyInfo.sketch'
# unzipDir = './res/storyInfo'
sketchFile = './res/' + parseConfig.getConfig('fileName') + '.sketch'
unzipDir = './res/' + parseConfig.getConfig('fileName')
os.system('unzip -o ' + sketchFile + ' -d ' + unzipDir)
jsonFiles = utils.getJsonFile(unzipDir + '/pages/')
print(jsonFiles)
# 配置
layout.initConfig.init(parseConfig.getConfig('screenScale'))
outputPagesStr = parseConfig.getConfig('outputPage', 'output')
outputPages = outputPagesStr.split(',')
def dealJson(jsonFile):
res = parseSketch.parseSketch(unzipDir + '/pages/' + jsonFile, outputPages)
if (not res):
return
print(globalData.elemData)
# 得到ID to frame 结构的数据
elemData = utils.getFrameData(globalData.elemData)
# 布局有关的
layoutTree = layout.autoLayout.autoLayout(elemData)
layout.autoLayout.addElemData(layoutTree, globalData.elemData)
layoutElemData = layout.autoLayout.getLayoutElemData()
flexData = layout.checkFlex.getFlexData(layoutTree, layoutElemData)
print(flexData)
print(globalData.elemData)
pageName = globalData.getPageName()[:1].upper() + globalData.getPageName()[1:]
layout.getCode.getCode(layoutTree, globalData.elemData, flexData, {'name': pageName})
print('finish ' + globalData.getPageName())
print(jsonFile)
for jsonFile in jsonFiles:
dealJson(jsonFile)
# dealJson('ECE8E072-7784-4777-9443-3D8DE8467CFC.json')
# dealJson('717DCAB4-B4A1-4AEC-B14B-4453D1FB51F9.json')