thundra.profiler package

Module contents

class thundra.profiler.Env(workspace, env)[source]

Bases: object

env: Path
workspace: Path
exception thundra.profiler.EnvNotExist[source]

Bases: Exception

class thundra.profiler.Profile(workspace, phonenumber, pushname, duplicate_count=0)[source]

Bases: object

Represents a user profile.

This class stores information about a user’s workspace, phone number, push name, and duplicate count. It provides methods to retrieve profile details and check the existence of a database associated with the profile.

Example usage:

`python profile = Profile(workspace="my_workspace", phonenumber="123456789", pushname="John Doe") print(profile.get_id())  # Output: John_Doe print(profile.get_name())  # Output: My_Profile `

db_exist()[source]

Check if the database exists.

This method checks whether the database associated with the profile exists in the workspace.

Returns:

True if the database exists, False otherwise.

Return type:

bool

db_path()[source]

Get the path to the database.

This method returns the path to the database associated with the profile.

Returns:

Path to the database.

Return type:

str

duplicate_count: int = 0
get_id()[source]

Get the profile ID.

This method constructs the profile ID based on the push name and duplicate count.

Returns:

Profile ID.

Return type:

str

get_name()[source]

Get the profile name.

This method retrieves the profile name from the Thundra configuration.

Returns:

Profile name.

Return type:

str

phonenumber: str
pushname: str
workspace: str
exception thundra.profiler.ProfileNotExist[source]

Bases: Exception

class thundra.profiler.Profiler(iterable=(), /)[source]

Bases: List[Profile]

Represents a list of user profiles.

This class provides methods to add, save, retrieve, and delete user profiles.

Example usage:

`python profiler = Profiler.get_profiler() profiler.add_profile(Profile(workspace="my_workspace", phonenumber="123456789", pushname="John Doe")) profiler.save() `

classmethod add_profile(profile)[source]

Add a new profile.

This method adds a new profile to the profiler and saves it to the profile file.

Parameters:

profile (Profile) – Profile to be added.

delete_profile(*alias)[source]

Delete profiles.

This method deletes profiles from the profiler and saves the changes.

Parameters:

alias (str) – Aliases of profiles to be deleted.

dir_path = PosixPath('/home/runner/.local/share/thundra')
get_profile(alias)[source]

Get a profile by alias.

This method retrieves a profile from the profiler by its alias.

Parameters:

alias (str) – Alias of the profile.

Raises:

ProfileNotExist – If the profile does not exist.

Returns:

Retrieved profile.

Return type:

Profile

classmethod get_profiler()[source]

Get the profiler.

This method retrieves the profiler from the profile file.

Returns:

Profiler containing user profiles.

Return type:

Profiler

path = PosixPath('/home/runner/.local/share/thundra/profile.json')
save()[source]

Save the profiles to the profile file.

This method saves the profiles to the profile file.

class thundra.profiler.VirtualEnv[source]

Bases: Dict[str, str]

Represents a virtual environment configuration.

This class extends a dictionary to store virtual environment configurations. It provides methods for saving, loading, and activating virtual environments.

Example usage:

`python env = VirtualEnv.get_env() env.activate(workspace="my_workspace") `

activate(workspace, autocreate=True, load_plugin=True)[source]

Activate a virtual environment.

This method activates a virtual environment based on the provided workspace. If the virtual environment does not exist, it can be automatically created.

Parameters:
  • workspace (str) – Name of the workspace.

  • autocreate (bool, optional) – Whether to create the virtual environment if it does not exist, defaults to True

  • load_plugin (bool, optional) – Whether to load plugins in the virtual environment, defaults to True

Raises:

EnvNotExist – If the virtual environment does not exist and autocreate is False.

Returns:

Activated virtual environment.

Return type:

Env

classmethod get_env()[source]

Get the virtual environment configuration.

This method loads the virtual environment configuration from a file.

Returns:

Virtual environment configuration.

Return type:

VirtualEnv

save()[source]

Save the virtual environment configuration to a file.

This method saves the virtual environment configuration to a JSON file.