@@ -90,7 +90,7 @@ def generate_files(repo: Repo, out_folder, repo_name: str):
90
90
print ("Files where collected for" , repo_path )
91
91
92
92
93
- def process_file (path : str , out : str ):
93
+ def identify_task (path : str , out : str , full_log : bool = False ):
94
94
95
95
repo_name = path [path .rfind ("/" ) + 1 : path .rfind ("." )]
96
96
refactoring_file = path [: path .rfind ("." )] + "_refactoring.json"
@@ -147,25 +147,38 @@ def process_file(path: str, out: str):
147
147
else :
148
148
scores ["UNKNOWN" ] += 1
149
149
150
- for k in scores :
151
- if k in debug .CLASS_MASK :
152
- continue
153
- safe_name : str = k .lower ().replace (" " , "_" )
150
+ if full_log :
151
+ for k in scores :
152
+ if k in debug .CLASS_MASK :
153
+ continue
154
+ safe_name : str = k .lower ().replace (" " , "_" )
155
+ dump (
156
+ safe_name ,
157
+ out ,
158
+ statements ,
159
+ lambda x : "task" in x .context .extensions
160
+ and x .context .extensions ["task" ]["id" ] == k ,
161
+ )
154
162
dump (
155
- safe_name ,
163
+ "unknown" ,
156
164
out ,
157
165
statements ,
158
- lambda x : "task" in x .context .extensions
159
- and x .context .extensions ["task" ]["id" ] == k ,
166
+ lambda x : not "task" in x .context .extensions ,
160
167
)
161
- dump (
162
- "unknown" ,
163
- out ,
164
- statements ,
165
- lambda x : not "task" in x .context .extensions ,
166
- )
167
168
168
- dump (repo_name + "_processed" , out , statements , lambda x : True )
169
+ if full_log :
170
+ dump (repo_name + "_task" , out , statements , lambda x : True )
171
+
172
+ with open (out + repo_name + "_compressed.json" , "w" ) as f :
173
+ f .write (
174
+ json .dumps (
175
+ [
176
+ (dict (stmt .context .extensions ) | {"id" : stmt .object .id })
177
+ for stmt in statements
178
+ ],
179
+ indent = 2 ,
180
+ )
181
+ )
169
182
170
183
scores = [(k , scores [k ]) for k in scores ]
171
184
scores .sort (key = lambda v : - v [1 ])
@@ -195,12 +208,16 @@ def process_file(path: str, out: str):
195
208
"--generate" , "-g" , action = argparse .BooleanOptionalAction , default = False
196
209
)
197
210
parser .add_argument ("-o" , "--out" , default = "" )
211
+ parser .add_argument (
212
+ "-l" , "--log" , action = argparse .BooleanOptionalAction , default = False
213
+ )
198
214
199
215
args = parser .parse_args ()
200
216
201
217
filename = args .filename
202
218
generate = args .generate
203
219
out_folder = args .out
220
+ log = args .log
204
221
205
222
if out_folder != "" and out_folder [- 1 ] != "/" :
206
223
out_folder += "/"
@@ -217,4 +234,4 @@ def process_file(path: str, out: str):
217
234
repo = Repo (filename )
218
235
generate_files (repo , out_folder , filename )
219
236
else :
220
- process_file (filename , out_folder )
237
+ identify_task (filename , out_folder , full_log = log )
0 commit comments