rmayormartins commited on
Commit
9980355
1 Parent(s): 701098c

atualizando app.py permite varios aia

Browse files
Files changed (2) hide show
  1. README.md +22 -4
  2. app.py +24 -26
README.md CHANGED
@@ -12,16 +12,34 @@ license: ecl-2.0
12
 
13
  ## AIA-Scope
14
 
15
- Análise do arquivo .aia gerado pelo MIT App Inventor
16
 
17
- Confira a referência de configuração em [Hugging Face Spaces Config Reference](https://huggingface.co/docs/hub/spaces-config-reference).
18
 
19
- ## Desenvolvedor
20
 
21
- Desenvolvido por Ramon Mayor Martins (2023)
22
 
23
  - E-mail: [rmayormartins@gmail.com](mailto:rmayormartins@gmail.com)
24
  - Homepage: [https://rmayormartins.github.io/](https://rmayormartins.github.io/)
25
  - Twitter: [@rmayormartins](https://twitter.com/rmayormartins)
26
  - GitHub: [https://github.com/rmayormartins](https://github.com/rmayormartins)
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  ## AIA-Scope
14
 
15
+ Analysis of the .aia file generated by MIT App Inventor
16
 
 
17
 
18
+ ## Developer
19
 
20
+ Developed by Ramon Mayor Martins (2023)
21
 
22
  - E-mail: [rmayormartins@gmail.com](mailto:rmayormartins@gmail.com)
23
  - Homepage: [https://rmayormartins.github.io/](https://rmayormartins.github.io/)
24
  - Twitter: [@rmayormartins](https://twitter.com/rmayormartins)
25
  - GitHub: [https://github.com/rmayormartins](https://github.com/rmayormartins)
26
 
27
+ ## Description
28
+
29
+ **AIA-Scope** is an advanced analytical tool designed to dissect and examine the components of `.aia` files, which are project files created with MIT App Inventor. This tool provides an overview of AI components, media files, user interface elements and more. It is intended for educators, researchers and developers who want to understand the complexities of App Inventor projects or analyze the construction of various applications in an educational or research environment.
30
+
31
+ ## How to Use
32
+
33
+ 1. **Starting the Application:** Launch AIA-Scope by running the script.
34
+ 2. **Uploading Files:** Click on the 'Upload .aia Files' button to select the `.aia` files you wish to analyze. You can choose multiple files at once for a batch analysis.
35
+ 3. **Analyzing the Files:** After selecting the files, click on the 'Submit' button. The tool will process each file, extracting and analyzing various components like AI patterns, media files, and UI elements.
36
+ 4. **Viewing the Results:** Once the analysis is complete, the results will be displayed on the screen. The output includes detailed information such as the count of different components, types of AI elements used, media files included, and other specific characteristics of each project.
37
+ 5. **Interpreting the Data:** The results are presented in a clear, tabular format for easy interpretation. You can review the data to gain insights into the structure and components of each App Inventor project.
38
+ 6. **Error Handling:** In case of any errors, such as corrupt files or unsupported formats, the tool will display an error message, allowing you to make necessary adjustments.
39
+
40
+ Feel free to experiment with different `.aia` files to explore the capabilities of AIA-Scope and understand the architecture of App Inventor projects more deeply.
41
+
42
+ Contact me if you have any questions!
43
+
44
+ ## other
45
+ Confira a referência de configuração em [Hugging Face Spaces Config Reference](https://huggingface.co/docs/hub/spaces-config-reference).
app.py CHANGED
@@ -264,38 +264,36 @@ output_style = """
264
  </style>
265
  """
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
- def analyze_aia(uploaded_file):
269
- try:
270
-
271
- file_path = uploaded_file.name if hasattr(uploaded_file, 'name') else None
272
-
273
- if file_path and os.path.exists(file_path):
274
- with ZipFile(file_path, 'r') as zip_ref:
275
- with tempfile.TemporaryDirectory() as temp_dir:
276
- zip_ref.extractall(temp_dir)
277
- results_df = list_components_in_aia_file(file_path)
278
-
279
- html_result = results_df.to_html(escape=False, classes="output-html")
280
- return output_style + f'<div class="output-container">{html_result}</div>'
281
-
282
-
283
- else:
284
- return output_style + "Não foi possível localizar o arquivo .aia."
285
-
286
- except BadZipFile:
287
- return output_style + "Falha ao abrir o arquivo .aia como um arquivo zip. Ele pode estar corrompido ou não é um arquivo .aia válido."
288
-
289
- except Exception as e:
290
- return output_style + f"Erro ao processar o arquivo: {str(e)}"
291
 
292
  iface = gr.Interface(
293
  fn=analyze_aia,
294
- inputs=gr.File(),
295
  outputs=gr.HTML(),
296
  title="AIA-Scope",
297
- description="Upload an .aia file to analyze its components.",
298
- live=False
299
  )
300
 
301
  if __name__ == "__main__":
 
264
  </style>
265
  """
266
 
267
+ def analyze_aia(uploaded_files):
268
+ all_results = []
269
+ for uploaded_file in uploaded_files:
270
+ try:
271
+ file_path = uploaded_file.name if hasattr(uploaded_file, 'name') else None
272
+ if file_path and os.path.exists(file_path):
273
+ with ZipFile(file_path, 'r') as zip_ref:
274
+ with tempfile.TemporaryDirectory() as temp_dir:
275
+ zip_ref.extractall(temp_dir)
276
+ results_df = list_components_in_aia_file(file_path)
277
+ all_results.append(results_df)
278
+ else:
279
+ all_results.append(f"Não foi possível localizar o arquivo {file_path}.")
280
+ except BadZipFile:
281
+ all_results.append("Falha ao abrir o arquivo .aia como um arquivo zip.")
282
+ except Exception as e:
283
+ all_results.append(f"Erro ao processar o arquivo {file_path}: {str(e)}")
284
 
285
+ #
286
+ combined_results_df = pd.concat(all_results, ignore_index=True)
287
+ html_result = combined_results_df.to_html(escape=False, classes="output-html")
288
+ return output_style + f'<div class="output-container">{html_result}</div>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
 
290
  iface = gr.Interface(
291
  fn=analyze_aia,
292
+ inputs=gr.Files(label="Upload .aia Files"),
293
  outputs=gr.HTML(),
294
  title="AIA-Scope",
295
+ description="Upload .aia (or multiples .aia) files to analyze/dissect their components.",
296
+ live=False
297
  )
298
 
299
  if __name__ == "__main__":