default_profile.util.machine

Generate a Platform class that can be used to identify varying characteristics of a user’s device.

Aims to clearly identify OS, CPU architecture and in the future may work to identify varying shells and terminals.

The Platform class in this module can be easily initialized with.:

>>> from default_profile.util.machine import Platform
>>> users_machine = Platform()
>>> users_machine.update_env()
>>> assert users_machine  is not None

See Also

default_profile.startup.20_aliases

Shows an example use case

Platform Specific Abstractions

class Platform[source][source]

Abstract away platform differences.

After toying with the initial implementation, I realized I could simply bind the pathlib.Path() instance directly to Platform during initialization.

This allows for a user to check the sys.platform instance, and then act in an appropriate manner without knowing what the pathlib.Path actually initialized to.

__init__(shell, user_env)[source][source]

Initialize a user specific object.

shellInteractiveShell, optional

Global IPython instance.

user_envdict, optional

Environment variables to add to the instance.

LOGGER : :class:`logging.Logger`

Class attribute. Logger for the class

_sys_platform[source]

Value returned by sys.platform

Sphinx Autogenerated Docs for machine

class Platform(shell=None, env=None, **kwargs)[source][source]

Bases: object

__init__(shell=None, env=None, **kwargs)[source][source]
property is_windows[source][source]
property uname[source][source]
property is_conemu[source][source]
property is_win_vt100[source][source]

True when we are using Windows, but with VT100 esc sequences.

Import needs to be inline. Windows libraries are not always available.

property is_linux[source][source]

True when sys.platform() returns linux.

static get_env()[source][source]
Returns

env – The user’s environment variables.

Return type

dict

update_env(env=None, **kwargs)[source][source]

Add more arguments to the environment.

Parameters
  • env (dict) – Current environment variables.

  • kwargs (dict) – Extra arguments to the env.

class Shell(shell=None, env=None, **kwargs)[source][source]

Bases: default_profile.util.machine.Platform

Subclass Platform to gain information about the user’s shell.

property is_cmd[source][source]

Unsure of how to implement this. TODO:

property is_powershell[source][source]
property is_pwsh[source][source]