FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JSONFormat4Flutter/template_code.py at master · debuggerx01/JSONFormat4Flutter · GitHub
debuggerx01
/
JSONFormat4Flutter
Public
Notifications
You must be signed in to change notification settings
Fork
55
Star
433
Code
Issues
6
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JSONFormat4Flutter
/
template_code.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (38 loc) · 1.27 KB
Breadcrumbs
JSONFormat4Flutter
/
template_code.py
Copy path
File metadata and controls
52 lines (38 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Filename : code_top.py
# @Date : 18-1-30 下午2:37
# @Author : DebuggerX
template_dict
=
r"""
class ${type} {
${properties}
${type}.fromParams({${this.properties}});
${type}.fromJson(jsonRes) {
${construction}
}
@override
String toString() {
return '{${toString}}';
}
String toJson() => this.toString();
}
"""
template_list
=
r"""
${list_count}${class_type}${>count} ${name}${current_child} = ${name}${parent_items} == null ? null : [];
for (var ${name}${current_items} in ${name}${current_child} == null ? [] : ${name}${parent_items}){
${loop}
${name}${current_child}!.add(${name}${child_child});
}
"""
def
get_top_code_dict
(
t
):
return
template_dict
.
replace
(
'${type}'
,
t
)
def
get_list_code_loop
(
list_count
,
ct
,
ab_count
,
n
,
current_child
,
child_child
,
current_items
,
parent_items
):
return
template_list
\
.
replace
(
'${list_count}'
,
list_count
) \
.
replace
(
'${class_type}'
,
ct
) \
.
replace
(
'${>count}'
,
ab_count
) \
.
replace
(
'${name}'
,
n
) \
.
replace
(
'${current_child}'
,
current_child
) \
.
replace
(
'${child_child}'
,
child_child
) \
.
replace
(
'${current_items}'
,
current_items
) \
.
replace
(
'${parent_items}'
,
parent_items
)
Back
|
FazBrowse Home
|
New Git URL