ParseAIA Documentation
ParseAIA is a simple python library for extracting data from .aia files (App Inventor projects)
Simple explanation
The library works by extracting all of the data from an app inventor project. The one class you'll need is Project, it represents one app inventor project.
Quick Example:
from parseaia import Project
myProject = Project("ExampleApp.aia") # Initiate a Project with the filepath to the .aia
print(myProject.Screen1.UI.Properties.Components) # Printing out all the UI elements
This example prints out all the UI elements in the screen "Screen1" (The default screen name when you create an app in app inventor, most apps will have it)
Full Documentation
class Project
Description
Every Screen in the project is a property of this class, so if your project has a screen called "Screen1" then you can reference it with Project.Screen1
Properties
- screens:
[Screen]A list of screens, each holding its ownCodeandUI - images:
[PIL.Image.Image]A list of all the images extracted from the project, on top of all the properties from Pillow, they also havefilename, which is their original filename, as a string - audio:
[Audio]A list of all the audio files extracted from the project - assets:
{str:str}A dictionary of all the non-image assets, the keys are the filenames, and the values are the text in their files - parse_function:
functionUsed for extracting assets from the .aia, can be customised, see Custom Parsing
class main.Screen
Description
This is a screen from the Project, it has the screen's code and ui
Properties
class codeclasses.Code
Description
This is all of the code from a screen
Properties
- xmlns:
strXML... something? It's a url to W3Schools - yacodeblocks
baseclasses.BaseSome versions extracted from the .aia - blockslist
[Block]A list of all blocks in theScreen, without any hierarchy - gvars
[Block]A list of all global variable declarations - events
[Block]A list of all event handlers - procedures
[Block]A list of all procedure definitions - blocks
[Block]A list of the blocks in the top of the hierarchy (event handlers, global variable declarations, procedure definitions) - blocksdict
[str:[Block]}A dictionary of all blocks, the key is the type of block, and the value is a list of blocks of that type
class codeclasses.Block
Description
This is a block in the code of a screen
Properties
- type:
strType of block - id:
strUnique id of the block - x:
intX position of the block in the editor - y:
intY position of the block in the editor - statements
[Statement]A list of all statements in the block (if/else/for/etc...) - next:
BlockThe next block in the code, run after this one - values
[Value]List of values attached to this block - top
boolIf this block is at the top of the hierarchy
class codeclasses.Value
Description
This is a value in the code of a screen. It also contains the information for a block, since a value has both
Properties
- name:
strName of the value - type:
strType of block - id:
strUnique id of the block - x:
intX position of the block in the editor (reserved for top level blocks) - y:
intY position of the block in the editor (reserved for top level blocks) - statements
[Statement]A list of all statements in the block (if/else/for/etc...) - next:
BlockThe next block in the code, run after this one - values
[Value]List of values attached to this block - top
boolIf this block is at the top of the hierarchy
class codeclasses.Statement
Description
This is a statement in the code of a screen
Properties
- name:
strName of the statement - next:
BlockThe next block in the code, run after this statement
class uiclasses.UI
Description
Represents the screen UI element from a screen
Properties
- authURL:
[str]Authentication for something - YaVersion:
strA number for the version of some weird thing named Ya - Source:
strSome weird thing - Properties:
PropertiesProperties of the screen ui element, everything we want is here, including the list of all the other UI elements
class uiclasses.Properties
Description
Represents the properties of a screen UI element from a screen. Has many more potential properties than shown here, these are just the default ones, if for example the screen's background color is changed, there would be a property to represent that
Properties
- Name:
strName of the screen - Type:
strType of element, can only be "Form" - Version:
strI used to believe that App Inventor's code was actually good... - AppName:
strName of the app - Title:
strScreen's visible name (the one that shows up in that top bar thing) - Uuid:
strA number, the unique id of the screen - Components:
[Component]A list of all the UI elements in the screen
class uiclasses.Component
Description
Represents a Component of a screen UI element from a screen. Has many more potential properties than shown here, these are just the default ones, if for example the element's background color is changed, there would be a property to represent that
Properties
- Name:
strName of the ui element (IE: "Button1") - Type:
strType of ui element - Version
strWhy App Inventor? why? - Uuid:
strA number, the unique id of the element - Components:
[Component]A list of all the UI elements in the component (Not always present)
class Audio
Description
Contains info (and data) of one audio file.
Properties
- filename:
strName of the file, including extension - duration:
floatDuration of audio in seconds - channels:
intAmount of channels - samples:
intAmount of samples - sample_rate
intSampling rate
Custom Parsing
Explanation
If you have assets that can't be properly parsed just by reading or that aren't images,
then this might help with your problem. You can use the parse_function keyword argument
when creating a new project to set how every asset will be parsed.
Just create a parsing function, it can be called anything, and do anything as long as it has three arguments, those being:
- The project, the object you will modifiy to add the results from the parsing
- The base asset path, the path to where all the assets are kept
- The filename, the name of the file inside of the asset path you are currently parsing
Example
import parseaia
def myparsefunction(project, assetpath, filename): # Create a function for parsing
print(assetpath + filename) # This one just prints all the filepaths
myProject = parseaia.Project("Example.aia", parse_function=myparsefunction) # Use the function when creating a project