Aqara_localizable 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81a6dcb2ae02b0dd0a6770219c2b504066dbaf18230d3de3c1774ecf3d1bd09a
4
- data.tar.gz: c34677b5b73c122f71bb588ea32bff28f3750163ced5b095b640f79b29ae79c8
3
+ metadata.gz: 3e185047e44e6f2725b74df836dbe0b2de830e53dd5d85b1a6faef00a58875ef
4
+ data.tar.gz: cba3fa71759dc51d181472b7becc91f73b44b0c6fd16fc1076b75ae1186b9909
5
5
  SHA512:
6
- metadata.gz: 8fbb8cc1a89bf10fea55eff789b141bc776a35e4a4807c4be7df1d5fb0561469481dd31a903126a209efdf2a5eb8b63dbc9647ea21f918d93e582c926da5309b
7
- data.tar.gz: fec24ebc5ad4806b65fdcfaf1bec1cc98a5034e5abc74362bd5066bf99bf813a39581dde9ea7562e0df2faf63c3b80d4bb8969b727001b1bbc6a989f80848b66
6
+ metadata.gz: ecdc6009aee99d99997ad0f81de1c54c64d51aa13dd731e2ed06cffda39e7e291002ec1cc22b871892cdf91ad33f0c36602613f19bc1b1e99850f5a912fedfcc
7
+ data.tar.gz: 663a414aa2886f6cdaeee31f499cfbadd56180d13a7e77ddcfeae32c0afb440516aea2646847212100b740ff85fb0f308ab3c88d7d10379ba7ea200d4c8ece5a
@@ -28,7 +28,8 @@ module AqaraLocalizable
28
28
  def run
29
29
  puts '如果多语言脚本插件有问题可以找zxf看看'.green
30
30
  target_path = Pathname.new(File.dirname(__FILE__)).realpath.parent.parent
31
-
31
+ puts target_path
32
+ # system "pip3 install requests;pip3 install openpyxl"
32
33
  system "cd #{target_path}/script/ios_py_code;python3 ios_sp_str_generator.py #{@project_directory}"
33
34
  # system 'cd /lib/script/ios_py_code;python3 ios_sp_str_generator.py'
34
35
  end
@@ -1,3 +1,3 @@
1
1
  module AqaraLocalizable
2
- VERSION = '0.0.3'.freeze unless defined? AqaraLocalizable::VERSION
2
+ VERSION = '0.0.4'.freeze unless defined? AqaraLocalizable::VERSION
3
3
  end
@@ -34,26 +34,24 @@ def MakeHeader(headerText):
34
34
  s = {x.split(':', 1)[0].strip() :x.split(':', 1)[1].strip() for x in s}
35
35
  return s
36
36
 
37
- def DownLatestLocalizableSource():
37
+ def DownLatestLocalizableSource(targetPath):
38
38
  session = requests.Session()
39
39
  headers = MakeHeader(myheader)
40
40
  params = '{"projectIdList":[5],"langIds":[1,2,3,9,10,11,12,13,14,15],"fileTypeList":["excel"],"auditState":1,"valueState":0,"userId":"","value":"","tagIds":null,"bizUseTagIds":null,"pkeys":[]}'
41
41
  response = session.post("https://intl-lang.aqara.com/v1.0/lumi/language/file/export", headers = headers, data=params, timeout=3)
42
- with open("localizable" + ".zip","wb") as code:
42
+ with open(f'{targetPath}/localizable' + ".zip","wb") as code:
43
43
  # 将 response 保存成本地文件
44
44
  code.write(response.content)
45
45
  code.close()
46
46
 
47
- def Unzip():
48
- f = zipfile.ZipFile("./localizable.zip", 'r') # 压缩文件位置
47
+ def Unzip(targetPath):
48
+ f = zipfile.ZipFile(f'{targetPath}/localizable.zip', 'r') # 压缩文件位置
49
49
  for file in f.namelist():
50
- f.extract(file, "../") # 解压位置
50
+ f.extract(file, targetPath) # 解压位置
51
51
  f.close()
52
- os.remove('./localizable.zip')
52
+ os.remove(f'{targetPath}/localizable.zip')
53
53
 
54
- def UpdateSource_language():
55
- DownLatestLocalizableSource()
56
- Unzip()
57
- os.rename('../excel.xls', '../hit_all_str.xlsx')
58
- shutil.copy('../hit_all_str.xlsx', '../source_language/hit_all_str.xlsx')
59
- os.remove('../hit_all_str.xlsx')
54
+ def UpdateSource_language(targetPath):
55
+ DownLatestLocalizableSource(targetPath)
56
+ Unzip(targetPath)
57
+ os.rename(f'{targetPath}/excel.xls', f'{targetPath}/hit_all_str.xlsx')
@@ -86,9 +86,9 @@ def getfilter():
86
86
  if __name__ == '__main__':
87
87
 
88
88
  localizable_path = sys.argv[1]
89
-
90
- DownloadNewLanguage.UpdateSource_language()
91
- filepath = '../source_language/hit_all_str.xlsx'
89
+ target_path = f'{localizable_path}/AqaraHome'
90
+ DownloadNewLanguage.UpdateSource_language(target_path)
91
+ filepath = f'{target_path}/hit_all_str.xlsx'
92
92
 
93
93
  platformUniteStrDict = file_util.readXlsxFileToDict(filepath)
94
94
  print(len(platformUniteStrDict))
@@ -96,7 +96,7 @@ if __name__ == '__main__':
96
96
  if isIndexLan:
97
97
  addIndex(platformUniteStrDict)
98
98
 
99
- dirname = '../output_file/ios'
99
+ dirname = f'{target_path}/output_file/ios'
100
100
  iosStringListPath = string_repeat_filter.generateIOSStringPathList(dirname)
101
101
 
102
102
 
@@ -142,6 +142,12 @@ if __name__ == '__main__':
142
142
  if os.path.exists(codePath):
143
143
  copyLocalizedToDestPath(iosStringListPath,codePath)
144
144
 
145
+ os.remove(f'{target_path}/hit_all_str.xlsx')
146
+ if os.path.exists(os.path.dirname(f'{target_path}/output_file')):
147
+ shutil.rmtree(f'{target_path}/output_file')
148
+
149
+
150
+
145
151
 
146
152
 
147
153
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Aqara_localizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan