uppaal2jetracer.versioncontrol package
Submodules
uppaal2jetracer.versioncontrol.config module
Config
This file provides all configuration settings required by the database and version control.
This file can be imported as a module and contains the following classes:
Config: Class for holding the configuration variables.
uppaal2jetracer.versioncontrol.database module
Database
This file provides the connection to a database used by the version control.
This file can be imported as a module and contains the following classes:
DatabaseConnection: Class for creating and managing a database connection.
- class DatabaseConnection(relative_path: str = None, name: str = None)[source]
Bases:
object
A class for holding a database connection.
- Variables:
_abs_path (str) – The absolute path of the database.
_engine (Engine) – The database engine.
_config (Config) – The config for the database.
_session (Session) – The session used for database queries.
- property abs_path: str
Get the absolute path to the database file.
- Returns:
The absolute path of the database.
- Return type:
str
- check_valid_name(name: str) bool [source]
Check if file name is valid.
- Parameters:
name (str) – Name of the file.
- Returns:
Whether the file name is valid or not.
- Return type:
bool
- check_valid_path(path: str) bool [source]
Check if relative path exists.
- Parameters:
path (str) – Given relative path.
- Returns:
Whether the path exists or not.
- Return type:
bool
- property config: Config
Get the config of the database.
- Returns:
The config of the database.
- Return type:
- property engine: Engine
Get the engine of the database connection.
- Returns:
The engine of the database.
- Return type:
Engine
- init_db(relative_path: str, name: str)[source]
Initialize the database.
- Parameters:
relative_path (str) – Relative Path of the database file.
name (str) – Name of the database file.
- property session: Session
Get the session of the database connection.
- Returns:
The session of the database.
- Return type:
Session
uppaal2jetracer.versioncontrol.models module
Models
This file provides all database models stored in the database.
This file can be imported as a module and contains the following classes:
Base: Base class which defines a database model.
Global: Model for representing a global user in the database.
Version: Model for representing a version in the database.
Project: Model for representing a project in the database.
- class Base(**kwargs: Any)[source]
Bases:
DeclarativeBase
A class for representing a standard database model.
- metadata: ClassVar[MetaData] = MetaData()
Refers to the
_schema.MetaData
collection that will be used for new_schema.Table
objects.See also
orm_declarative_metadata
- registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>
Refers to the
_orm.registry
in use where new_orm.Mapper
objects will be associated.
- type_annotation_map = {uppaal2jetracer.versioncontrol.models.pickle: PickleType()}
- class Global(**kwargs)[source]
Bases:
Base
A db model for representing the global user.
- Variables:
_g_id (int) – The id of the global model.
_version_max (int) – The version limit of all projects.
_c_id (int) – The id of the current project.
_current_project (Project) – The current project.
- property c_id: int
Get the current project id.
- Returns:
The current project id.
- Return type:
int
- property current_project: Project
Get the current project.
- Returns:
The project currently being used.
- Return type:
- property g_id: int
Get the id of the global model.
- Returns:
The id of the global model.
- Return type:
int
- get_model_protected() dict [source]
Get the main attributes of the model.
- Returns:
A dictionary with the attributes.
- Return type:
dict
- property version_max: int
Get the current version limit.
- Returns:
The version limit.
- Return type:
int
- class Project(**kwargs)[source]
Bases:
Base
A db model for representing a project.
- Variables:
- add_version(version: Version)[source]
Add a version to the project.
- Parameters:
version (Version) – The version to add.
- property current_user: Global
Get the current user of the project.
- Returns:
The current user of the project.
- Return type:
- property date: datetime
Get the date of the project.
- Returns:
The date of the project.
- Return type:
datetime
- get_model_protected() dict [source]
Get the main attributes of the model.
- Returns:
A dictionary with the attributes.
- Return type:
dict
- property name: str
Get the name of the project
- Returns:
The name of the project
- Return type:
str
- property p_id: int
Get the id of the project
- Returns:
The id of the project.
- Return type:
int
- class Version(**kwargs)[source]
Bases:
Base
A db model for representing a version.
- Variables:
_v_id (int) – The id of the version.
_name (str) – The name of the version.
_date (datetime) – The creation timestamp of the version.
_favorite (bool) – Whether the version is favorited or not.
_file (Pickle) – The file data as a pickled object.
_p_id (int) – The id of the version’s project.
_project (Project) – The version’s project.
- property date: datetime
Get the date of the version.
- Returns:
The date of the version.
- Return type:
datetime
- property favorite: bool
Get whether the version is favorited or not.
- Returns:
If the version is favorited.
- Return type:
bool
- property file: System
Get the file data of the version.
- Returns:
The System object of the pickled file.
- Return type:
- get_model_protected() dict [source]
Get the main attributes of the model.
- Returns:
A dictionary with the attributes.
- Return type:
dict
- property name: str
Get the name of the version.
- Returns:
The name of the version.
- Return type:
str
- property p_id: int
Get the project id of the version.
- Returns:
The project id of the version.
- Return type:
int
- property project: Project
Get the project of the version.
- Returns:
The project this version is inside of.
- Return type:
- property v_id: int
Get the id of the version.
- Returns:
The id of the version.
- Return type:
int
uppaal2jetracer.versioncontrol.versioncontrol module
Version control
This file provides both project and version managers for interacting with the database.
This file can be imported as a module and contains the following classes:
ResponseType: Enum for representing the status of a response from a manager.
ResponseObject: Holds the status and response data of a function from a manager.
VersionResponse: The data it holds is a Version from the database.
ProjectResponse: The data it holds is a Project from the database.
GlobalResponse: The data it holds is a Global from the database.
ProjectManager: The manager for executing project based functions in the database.
VersionManager: The manager for executing version based functions in the database.
- class GlobalResponse(r_type: ResponseType, payload: Global, message: str = None)[source]
Bases:
ResponseObject
A class to hold a response type and Global payload.
- class ProjectManager(db: DatabaseConnection)[source]
Bases:
object
Class for managing projects in the database.
- Variables:
_db (DatabaseConnection) – The database connection.
- add_project(name: str) ProjectResponse [source]
Add a new project to the database.
- Parameters:
name (str) – Name of the new project.
- Returns:
Response with status and new project or an error.
- Return type:
- change_version_limit(num: int) GlobalResponse [source]
Set a new version limit.
- Parameters:
num (int) – The number the limit should be set to.
- Returns:
Response with status and the updated global model or an error.
- Return type:
- property db: DatabaseConnection
The database connection of the manager.
- Returns:
The database connection of the manager.
- Return type:
- delete_project(name: str) ProjectResponse [source]
Delete an existing project.
- Parameters:
name (str) – Name of the project you wish to delete.
- Returns:
Response with status and the deleted project or an error.
- Return type:
- get_all_projects() List[ProjectResponse] [source]
Get all existing projects.
- Returns:
List of Responses, each with a status and one of the existing projects.
- Return type:
List[ProjectResponse]
- get_config() GlobalResponse [source]
Get all user configuration settings.
- Returns:
Response with status and the configurations.
- Return type:
- get_current_project() ProjectResponse [source]
Get the current project.
- Returns:
Response with status and the current project or an error.
- Return type:
- select_project(name: str) ProjectResponse [source]
Select a project to be the new current project.
- Parameters:
name (str) – Name of the project you wish to select.
- Returns:
Response with status and the new current project or an error.
- Return type:
- class ProjectResponse(r_type: ResponseType, payload: Project, message: str = None, versions: List[Version] = None)[source]
Bases:
ResponseObject
A class to hold a response type and Project payload.
- class ResponseObject(r_type: ResponseType, payload: object, message: str = None)[source]
Bases:
object
A class to hold a response type and payload.
- Variables:
_type (ResponseType) – The type of the response.
_payload (object) – The payload of the response.
_message (str) – The message of the response in case of an error.
- property message: str
The message of the response in case of an error.
- property payload: object
The payload of the response.
- property type: ResponseType
The type of the response. Either ‘ok’ or ‘error’.
- class ResponseType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
An Enum for representing the type of response.
- ERROR = -1
- OK = 1
- class VersionManager(db: DatabaseConnection)[source]
Bases:
object
Class for managing projects in the database.
- Variables:
_db (DatabaseConnection) – The database connection.
- add_version(name: str, data: object) List[VersionResponse] [source]
Add a new version to the database.
- Parameters:
name (str) – Name of the new version.
data (object) – File data of the version.
- Returns:
Response with status and the new version and possibly the deleted version or an error.
- Return type:
List[VersionResponse]
- property db: DatabaseConnection
The database connection of the manager.
- Returns:
The database connection of the manager.
- Return type:
- delete_version(v_id: int) VersionResponse [source]
Delete a specific version.
- Parameters:
v_id (int) – ID of the version you wish to delete.
- Returns:
Response with status and the deleted version or an error.
- Return type:
- favorite_version(v_id: int) VersionResponse [source]
Favorite a specific version.
- Parameters:
v_id (int) – ID of the version you wish to favorite.
- Returns:
Response with status and the updated version or an error.
- Return type:
- get_all_versions(p_id: int = None) List[VersionResponse] [source]
Get all existing versions.
- Parameters:
p_id (int, optional (retrieves versions of the current project if no id was provided)) – ID of a project you wish to retrieve the versions from, defaults to None.
- Returns:
List of Responses, each with a status and one of the existing versions or an error.
- Return type:
List[VersionResponse]
- get_version(v_id: int) VersionResponse [source]
Get a specific version.
- Parameters:
v_id (int) – ID of the version you wish to retrieve.
- Returns:
Response with status and the requested version or an error.
- Return type:
- class VersionResponse(r_type: ResponseType, payload: Version, message: str = None)[source]
Bases:
ResponseObject
A class to hold a response type and Version payload.