Profile reference

class nusex.Profile(name='default')

A class in which to create, load, modify, and save profiles.

Keyword Arguments

name (str) – The name of the profile. If the profile does not exist, a new one is created, otherwise an existing one is loaded. Defaults to “default”.

path

The complete filepath to the profile.

Type

pathlib.Path

data

The data for the profile.

Type

dict[str, Any]

create_new(name)

Create a new profile.

Parameters

name (str) – The name of the profile.

Raises
classmethod current()

Create an instance for the currently selected profile.

Returns

The currently selected profile.

Return type

Profile

delete()

Delete this profile.

Raises

FileNotFoundError – The profile does not exist on disk.

property exists

Whether this profile exists on disk.

Returns

bool

classmethod from_legacy(name='default')

Create a profile from a 0.x spec user.nsc file.

Keyword Arguments

name (str) – The name of the profile. Defaults to “default”.

Returns

The newly created profile.

Return type

Profile

Raises

FileNotFoundError – No user.nsc file exists in the config directory.

property is_selected

Whether this profile is currently selected.

Returns

bool

load()

Load an existing profile. This should never need to be called as profiles are loaded automatically when necessary upon object creation.

Raises

FileNotFoundError – The profile does not exist on disk.

property name

The name of this profile.

Returns

str

rename(new_name)

Rename this profile.

Parameters

new_name (str) – The new name for the profile.

Raises
  • ProfileError – The new name for the profile is invalid.

  • AlreadyExists – The new name for the profile is already being used by a template.

  • FileNotFoundError – The profile does not exist on disk.

save()

Save this profile.

Raises

ProfileError – The profile data has been improperly modified.

select()

Select this profile. This will not error if the profile is already selected; use the is_selected property to check if this profile is already selected instead.

setup()

Set up this profile. You will be prompted to input some information.

Raises

ProfileError – An invalid value was provided to one of the inputs.

update(**kwargs)

Update this profile’s configuration. All options must be passed through as kwargs. Invalid configuration keys raise warnings, not errors.

Keyword Arguments
  • author_name (str) – An author name.

  • author_email (str) – An author email.

  • git_profile_url (str) – Your GitHub/Gitlab/BitBucket/etc. profile link.

  • starting_version (str) – The version to initialise project with.

  • default_description (str) – The description to initialise projects with.

  • preferred_license (str) – Your preferred license.