-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.py
executable file
·209 lines (196 loc) · 7.48 KB
/
data.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env python3
import codecs
import os
from functools import lru_cache
import strictyaml as sy
ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
DATA_PATH = os.path.join(ROOT_PATH, 'data')
LABS_FILENAME = 'labs.yaml'
PROJECTS_FILENAME = 'projects.yaml'
LABS_SCHEMA = sy.Map({"labs":
sy.MapPattern(sy.Str(),
sy.Map({
"name": sy.Str(),
"prof": sy.Map({
"name": sy.Seq(sy.Str()),
"email": sy.Email(),
}),
"description": sy.Str(),
"url": sy.Url(),
sy.Optional("contacts"): sy.Seq(
sy.Map({
"name": sy.Str(),
sy.Optional("email"): sy.Email(),
}),
),
sy.Optional("notes"): sy.Str(),
sy.Optional("information"): sy.Seq(
sy.Map({
"title": sy.Str(),
"url": sy.Url(),
sy.Optional("notes"): sy.Seq(
sy.Map({
sy.Optional("label"): sy.Str(),
"text": sy.Str(),
sy.Optional("url"): sy.Url(),
}),
),
}),
),
}),
)
})
PROJECTS_SCHEMA = sy.Map({"projects":
sy.MapPattern(sy.Str(),
sy.Map({
"name": sy.Str(),
"description": sy.Str(),
"type": sy.CommaSeparated(sy.Enum([
"Application", # Stand-alone code with useful functionality outside of the paper
"Library", # Code to be included in other projects outside of the paper
"Framework", # A set of concepts and best practices for a given task
"Toolset", # Various stand-alone applications for a given task
"Simulation", # Generic code that can be used to run simulations described in the paper
"Experiments", # Code that produces figures and graphs of the paper
])),
"categories": sy.Seq(sy.Enum([
"Privacy",
"Blockchain",
"Verification",
"Security",
"Learning",
"Other"
])),
"applications": sy.Seq(sy.Enum([
"Finance",
"Health",
"Gov",
"Infra",
"Info",
"Other"
])),
"tags": sy.Seq(sy.Enum([
"Access Control", "Adversarial", "Anonymity", "Attack",
"Benchmark", "Binary", "Bluetooth", "Byzantine Resilience",
"Cloud", "Code Analysis", "Computer Vision", "Concurrency", "Consensus", "CrowdSource",
"Data Structures", "Database", "Debug", "Decentralized", "Deep Neural Networks",
"Development", "Distributed Learning",
"Encryption", "Exploit",
"Failure", "Features", "Federated Learning", "Fuzzing",
"Homomorphic Encryption",
"Image Classification", "Images", "Inductive Bias", "Internet of Things",
"Locking", "Low-Level",
"Machine Learning", "Mobile App",
"Natural Language", "Network",
"Optimization",
"Predictor", "Protection", "Protocol", "PyTorch",
"Secure Multi-Party Computation", "Server", "Simulator", "Static Analysis", "Survey",
"TensorFlow", "Tor",
"Zero-Knowledge Proofs"
])),
"date_added": sy.Datetime(),
sy.Optional("layman_desc"): sy.Str(),
sy.Optional("tech_desc"): sy.Str(),
sy.Optional("notes"): sy.Str(),
sy.Optional("url"): sy.Url(),
sy.Optional("contacts"): sy.Seq(
sy.Map({
"name": sy.Str(),
sy.Optional("email"): sy.Email(),
sy.Optional("url"): sy.Url(),
}),
),
sy.Optional("code"): sy.Map({
"type": sy.Str(),
sy.Optional("url"): sy.Url(),
sy.Optional("date_last_commit"): sy.Datetime(),
}),
sy.Optional("doc"): sy.Url(),
sy.Optional("lines_of_code"): sy.Str(),
sy.Optional(
"c4dt_contact",
default={"name": "C4DT team", "email": "[email protected]"}
): sy.Map({
"name": sy.Str(),
"email": sy.Email(),
}),
sy.Optional("language"): sy.Str(),
sy.Optional("license"): sy.CommaSeparated(sy.Enum([
"AGPL-3.0",
"GPL-2.0", "GPL-3.0",
"GPL-2.0+", "GPL-3.0+",
"LGPL-3.0",
"MPL-2.0", "MPL-2.0+",
"MIT",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"BSD-3-Clause Clear",
"CeCILL-B",
"CloudSuite",
"CC BY 4.0",
"SOLDERPAD HARDWARE LICENSE",
"commercial",
"non-commercial",
"other",
"various"
])),
sy.Optional("information"): sy.Seq(
sy.Map({
"type": sy.Str(),
"url": sy.Url(),
"title": sy.Str(),
sy.Optional("notes"): sy.Seq(
sy.Map({
sy.Optional("label"): sy.Str(),
"text": sy.Str(),
sy.Optional("url"): sy.Url(),
}),
),
}),
),
sy.Optional("maturity"): sy.Int(),
sy.Optional("incubator"): sy.Map({
"work": sy.Str(),
sy.Optional("type", default="incubated"): sy.Enum([
"incubated",
"incubated_market",
"retired",
"retired_archived",
]),
sy.Optional("products"): sy.Seq(
sy.Map({
"type": sy.Enum(["Demo", "Demo-Code", "Hands-on", "Pilot", "App", "Library", "OSS-participation", "Archive"]),
"url": sy.Url(),
"title": sy.Str(),
}),
)
}),
sy.Optional("date_updated"): sy.Datetime()
| sy.EmptyList(),
}),
)
})
@lru_cache(maxsize=1)
def load():
with codecs.open(os.path.join(DATA_PATH, LABS_FILENAME),
encoding='utf-8') as f:
labs_yaml = sy.load(f.read(), LABS_SCHEMA, label=f.name)
labs = labs_yaml['labs'].data
for lab_id, lab in labs.items():
project_file = os.path.join(DATA_PATH, lab_id, PROJECTS_FILENAME)
if not os.path.exists(project_file):
continue
with codecs.open(project_file,
encoding='utf-8') as f:
projects_yaml = sy.load(f.read(), PROJECTS_SCHEMA, label=f.name)
lab['projects'] = projects_yaml['projects'].data
return labs
if __name__ == '__main__':
import sys, os
data = load()
if len(sys.argv) != 2:
print("\n".join(data.keys()))
sys.exit(0)
if sys.argv[1] in data:
print("\n".join(data[sys.argv[1]]['projects'].keys()))