ReFreSH.MobileSuit.Core package

Subpackages

Submodules

ReFreSH.MobileSuit.Core.ColorSetting module

class ReFreSH.MobileSuit.Core.ColorSetting.ColorSetting(BackgroundColor: Color, DefaultColor: Color, PromptColor: Color, ErrorColor: Color, OkColor: Color, TitleColor: Color, InformationColor: Color, SystemColor: Color, WarningColor: Color)[source]

Bases: IColorSetting

Color settings of a Mobile Suit.

property BackgroundColor: Color
property DefaultColor: Color

Default color. For OutputType.Default

Equals(other: IColorSetting | None) bool[source]

Indicates whether this instance and a specified object are equal.

Parameters:

other – The object to compare with the current instance.

property ErrorColor: Color

Prompt Color. For OutputType.Error

property InformationColor: Color

Prompt Color. For OutputType.CustomInformation

property OkColor: Color

Prompt Color. For OutputType.AllOK

property PromptColor: Color

Prompt Color. For OutputType.Prompt

property SystemColor: Color

Prompt Color. For OutputType.Information

property TitleColor: Color

Prompt Color. For OutputType.ListTitle

property WarningColor: Color

Warning color. For OutputType.Warning

class ReFreSH.MobileSuit.Core.ColorSetting.IColorSetting[source]

Bases: ABC

Color settings of a Mobile Suit.

abstract property BackgroundColor: Color
abstract property DefaultColor: Color

Default color. For OutputType.Default

static DefaultColorSetting()[source]

Default color settings for IOServer.

abstract property ErrorColor: Color

Prompt Color. For OutputType.Error

abstract property InformationColor: Color

Prompt Color. For OutputType.Info

abstract property OkColor: Color

Prompt Color. For OutputType.OK

abstract property PromptColor: Color

Prompt Color. For OutputType.Prompt

static SelectColor(colorSetting, otype: OutputType = OutputType.Default, customColor: Color | None = None) Color[source]

select color for the output type from color setting

Parameters:
  • colorSetting – color setting

  • otype – output type

  • customColor – customized color

abstract property SystemColor: Color

Prompt Color. For OutputType.System

abstract property TitleColor: Color

Prompt Color. For OutputType.Title

abstract property WarningColor: Color

Prompt Color. For OutputType.System

ReFreSH.MobileSuit.Core.ISuitCommandServer module

class ReFreSH.MobileSuit.Core.ISuitCommandServer.ISuitCommandServer[source]

Bases: ABC

Built-In-Command Server’s Model.

abstract ChDir(path: str) str[source]

Set current directory

Parameters:

path – path to set as current directory

abstract async ClearCompleted() None[source]

Clear all Completed Tasks.

abstract Dir() str[source]

Get current directory

abstract ExitSuit() RequestStatus[source]

Exit MobileSuit

abstract async Join(index: int, context: SuitContext) str | None[source]

Join a Running task

Parameters:
  • index – index of the task to join

  • context – context of the request

abstract async ListCommands(args: list[str]) None[source]

Show Members of the Current SuitObject

Parameters:

args – command args

abstract async Stop(index: int) None[source]

Stop a Running task

Parameters:

index – index of the task to stop

abstract async SuitHelp(args: list[str]) None[source]

Show Help of MobileSuit

Parameters:

args – command args

abstract async Tasks() None[source]

Get All tasks

ReFreSH.MobileSuit.Core.ISuitMiddleware module

class ReFreSH.MobileSuit.Core.ISuitMiddleware.ISuitMiddleware[source]

Bases: ABC

A middleware of Mobile Suit.

abstract async InvokeAsync(context: SuitContext, nextStep: Callable[[SuitContext], Awaitable])[source]

To invoke the middleware

ReFreSH.MobileSuit.Core.SuitBuildUtils module

ReFreSH.MobileSuit.Core.SuitBuildUtils.CreateConverterFactory(T, parserInfo: SuitArgParserInfo) Callable[[SuitContext], Callable[[str], object | None]][source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.CreateInstance(otype, s: SuitContext) Any | None[source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.CreateInstanceWithProvider(otype, s: ServiceProvider) Any | None[source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.GetArg(parameter: Parameter, function: Callable, arg: str | None, context: SuitContext) tuple[object, int][source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.GetArgs(func: Callable, args: List[str], context: SuitContext) List[Any | None] | None[source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.GetArgsInternal(func: Callable, parameterInfo: SuitMethodParameterInfo, args: List[str], context: SuitContext) List[Any | None] | None[source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.GetArrayArg(parameter: Parameter, function: Callable, argArray: list[str], context: SuitContext) object[source]
ReFreSH.MobileSuit.Core.SuitBuildUtils.GetMethodParameterInfo(func: Callable) SuitMethodParameterInfo[source]

ReFreSH.MobileSuit.Core.SuitContext module

class ReFreSH.MobileSuit.Core.SuitContext.SuitContext(sp: ServiceProvider)[source]

Bases: object

Context through the lifetime of a SuitRequest(A Command)

Dispose()[source]
Exception: Exception | None

The exception caught in the execution.

GetRequiredService(T) Any[source]
GetService(T) Any | None[source]
Properties: dict[str, object]

Properties of current request.

Request: list[str]

A command from input stream

RequestStatus: RequestStatus

The execution status of current request.

Response: str | None

Output to the output stream

ServiceProvider

The ServiceProvider who provides services through whole request.

ReFreSH.MobileSuit.Core.SuitMethodParameterInfo module

class ReFreSH.MobileSuit.Core.SuitMethodParameterInfo.SuitMethodParameterInfo[source]

Bases: object

Parameter information of a method in MobileSuit

MaxParameterCount: int

Number of the parameters which can be passed at least.

MinParameterCount: int

Number of the parameters which can be passed at most.

NonArrayParameterCount: int

Number of the parameters which are neither array nor DynamicParameter

TailParameterType: TailParameterType

Type of the last parameter

class ReFreSH.MobileSuit.Core.SuitMethodParameterInfo.TailParameterType(value)[source]

Bases: IntEnum

Represents type of the last parameter of a method

Array = 1

Last parameter is an array.

NoParameter = -1

Last parameter does not exist.

Normal = 0

Last parameter exists, and is quite normal.

ReFreSH.MobileSuit.Core.SuitMethodShell module

class ReFreSH.MobileSuit.Core.SuitMethodShell.SuitMethodShell(method: Callable, factory: Callable[[SuitContext], Any], absoluteName=None)[source]

Bases: SuitShell

Object’s Member which may be a method.

CanFitTo(argumentCount: int) bool[source]
async Execute(context: SuitContext)[source]

Execute this object.

Parameters:

context – The arguments for execution.

Returns:

The result of executing this object

classmethod FromDelegate(methodName, delegate: Callable)[source]
classmethod FromInstance(method: Callable, factory: Callable[[SuitContext], Any])[source]
MayExecute(request: List[str]) bool[source]

Detect whether this IExecutable may execute the command.

property MemberCount

ReFreSH.MobileSuit.Core.SuitObjectShell module

class ReFreSH.MobileSuit.Core.SuitObjectShell.ISuitShellCollection[source]

Bases: ABC

A collection contains ordered suit shell members.

abstract Members() Iterable[SuitShell][source]

Ordered members of this

class ReFreSH.MobileSuit.Core.SuitObjectShell.SuitObjectShell(typedef, factory: Callable[[SuitContext], Any], info, name)[source]

Bases: SuitShell, ISuitShellCollection

Represents an object in Mobile Suit.

AddMethod(method)[source]
AddProperty(name: str, prop: property)[source]
async Execute(context: SuitContext)[source]

Execute this object.

Parameters:

context – The arguments for execution.

Returns:

The result of executing this object

classmethod FromInstance(typedef, instanceFactory, name='')[source]
classmethod FromInstanceProperty(name, prop, instanceFactory) Optional[source]
classmethod FromType(typedef, name='')[source]
static GetMemberInfo(sh) str[source]
MayExecute(request: List[str]) bool[source]

Detect whether this IExecutable may execute the command.

property MemberCount
Members()[source]

Ordered members of this

ReFreSH.MobileSuit.Core.SuitParser module

class ReFreSH.MobileSuit.Core.SuitParser.SuitParser(name: str, parser: Callable[[str], T | None])[source]

Bases: Generic[T]

A data parser of MobileSuit

classmethod FromConverter(_T, converter: Callable[[str], T | None], name='')[source]

Create a mobile suit parser from a converter

Parameters:
  • _T

  • converter – The converter method

  • name – Name of the parser, if set empty, the parser will be default.

classmethod FromName(_T, name)[source]

Create a mobile suit parser from a func and given type

Parameters:

name – Name of the parser, if set empty, the parser will be default.

Name

Name of the Parser

Parser

The parser which convert string argument to certain type.

property TargetType: Type

ReFreSH.MobileSuit.Core.SuitShell module

class ReFreSH.MobileSuit.Core.SuitShell.MemberType(value)[source]

Bases: IntEnum

Type of member

FieldWithInfo = 1

A Field/Property with customized information

FieldWithoutInfo = -2

A Field/Property without customized information

MethodWithInfo = 0

A Method with customized information

MethodWithoutInfo = -1

A Method without customized information

class ReFreSH.MobileSuit.Core.SuitShell.SuitShell(member, instance_factory: Callable[[SuitContext], Any], absoluteName=None)[source]

Bases: ABC

A SuitObject’s member.

AbsoluteName

Absolute name of this member.

Aliases

Aliases of this member.

abstract async Execute(context: SuitContext)[source]

Execute this object.

Parameters:

context – The arguments for execution.

Returns:

The result of executing this object

FriendlyNames

Absolute name, and aliases.

GetInstance(context: SuitContext) Any[source]

Instance which contains this member.

property Information: str

Information of this member, customized or generated by Mobile Suit.

abstract MayExecute(request: List[str]) bool[source]

Detect whether this IExecutable may execute the command.

Type: MemberType

Type of the member

ReFreSH.MobileSuit.Core.TestSuitMethodShell2 module

class ReFreSH.MobileSuit.Core.TestSuitMethodShell2.TestSuitMethodShell(methodName='runTest')[source]

Bases: TestCase

async execute_method_async()[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

test_execute_method()[source]
test_may_execute()[source]
test_member_count()[source]

Module contents

class ReFreSH.MobileSuit.Core.RequestStatus[source]

Bases: object