ReFreSH.MobileSuit package

Subpackages

Submodules

ReFreSH.MobileSuit.IIOHub module

class ReFreSH.MobileSuit.IIOHub.IIOHub[source]

Bases: ABC

An entity, which serves the input/output of a mobile suit.

AppendWriteLinePrefix(prefix: str | Iterable = '\t') None[source]

Append a str to Prefix, usually used to increase indentation

Args:

self: IOHub to write to prefix: the output tuple to append

abstract AppendWriteLinePrefixPrimary(prefix: Iterable) None[source]

Append a str to Prefix, usually used to increase indentation

abstract ClearWriteLinePrefix() None[source]

Clear the prefix before writing line.

abstract property ColorSetting: IColorSetting

Color settings for this IOServer. (default DefaultColorSetting)

CreateReadLinePrompt(prompt: str, defaultValue: str | None, customPromptColor: Color | None) Iterable[Iterable][source]
abstract property ErrorStream: TextIOBase

Error stream (default stderr)

abstract property FormatPrompt: Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]]

Prompt server for the io server.

static GetLabel(otype: OutputType = OutputType.Default) str[source]

get label of given output type

abstract GetLinePrefix(otype: OutputType) List[Iterable][source]

Get the prefix before writing line.

abstract property Input: TextIOBase

Input stream (default stdin)

abstract property IsErrorRedirected: bool

Check if this IOServer’s error stream is redirected (NOT stderr)

abstract property IsInputRedirected: bool

Checks if this IOServer’s input stream is redirected (NOT stdin)

abstract property IsOutputRedirected: bool

Check if this IOServer’s output stream is redirected (NOT stdout)

abstract property Options: IOOptions

Disable Time marks which shows in Output-Redirected Environment.

abstract property Output: TextIOBase

Output stream (default stdout)

abstract Peek() <module 'pyasn1.type.char' from '/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pyasn1/type/char.py'>[source]

Reads the next character from input stream without changing the state of the reader or the character source.

Returns:

The next available character.

abstract Read() <module 'pyasn1.type.char' from '/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pyasn1/type/char.py'>[source]

Reads the next character from input stream.

Returns:

The next available character.

ReadLine(prompt: str = '', newLine: bool = False, customPromptColor: Color | None = None, defaultValue: str | None = None) str | None[source]

Reads a line from input stream, with prompt. Return something default if user input “”.

Args:

prompt: The prompt display(output to output stream) before user input. newLine: If the prompt will display in a single line customPromptColor: Optional. Prompt’s Color, ColorSetting.PromptColor as default. defaultValue: Default return value if user input “”

Returns:

Content from input stream, None if EOF, if user input “”, return defaultValue

abstract ReadLinePrimary() str | None[source]

Reads a line from input stream, with prompt.

Returns:

Content from input stream, None if EOF

abstract ReadToEnd() str[source]

Reads all characters from the current position to the end of the input stream and returns them as one string.

Returns:

All characters from the current position to the end.

abstract ResetError() None[source]

Reset this IOServer’s error stream to stderr

abstract ResetInput() None[source]

Reset this IOServer’s input stream to stdin

abstract ResetOutput() None[source]

Reset this IOServer’s output stream to stdout

abstract SubtractWriteLinePrefix() None[source]

Subtract a str from Prefix, usually used to decrease indentation

Write(content: str | Iterable[Iterable], otype: OutputType = OutputType.Default, custom_color: ConsoleColor | Color | None = None) None[source]

Writes some content to output stream. With certain color in console.

Args:

content: Content to output. otype: Optional. Type of this content, this decides how will it be like. custom_color: Optional. Customized color in console

WriteLine(content: str | Iterable[Iterable] = '', otype: OutputType = OutputType.Default, custom_color: ConsoleColor | Color | None = None) None[source]

Writes some content to output stream, with line break. With certain color in console.

Args:

content: Content to output. otype: Optional. Type of this content, this decides how will it be like. custom_color: Optional. Customized color in console

abstract WritePrimary(content: Iterable) None[source]

Writes some content to output stream, with line break. With certain Input/Output color.

class ReFreSH.MobileSuit.IIOHub.IOOptions(value)[source]

Bases: Flag

Featured Options of IOHub

DisableLinePrefix = 4

Suggests no Line prefix should be output to the stream

DisablePrompt = 1

Suggests no prompt should be output to the stream

DisableTag = 2

Suggests no type/time tag should be output to the stream

NoFlag = 0

No feature applied.

ReFreSH.MobileSuit.OutputType module

class ReFreSH.MobileSuit.OutputType.OutputType(value)[source]

Bases: Enum

Type of content that writes to the output stream.

Default = 0

Normal content.

Error = 2

Error content.

Info = 5

Normal information.

Ok = 3

All-Ok content.

Prompt = 1

Prompt content.

System = 6

Information provided by MobileSuit.

Title = 4

Title of a list.

Warning = 7

Warning content.

ReFreSH.MobileSuit.PrintUnit module

class ReFreSH.MobileSuit.PrintUnit.PrintUnit(Text: str, Foreground: Color | None = None, Background: Color | None = None)[source]

Bases: object

A basic unit of output print, contains foreground, background and text.

classmethod ConsoleColorArrCast(origin: Iterable) Iterable[source]

Convert ConsoleColor to Color

static ConsoleColorCast(origin: ConsoleColor | None) Color | None[source]

Convert ConsoleColor to Color

classmethod FromIterable(tp: Iterable)[source]
classmethod FromIterables(tp: Iterable[Iterable])[source]

ReFreSH.MobileSuit.RequestStatus module

class ReFreSH.MobileSuit.RequestStatus.RequestStatus(value)[source]

Bases: IntEnum

An enumeration.

CommandNotFound = -3

Cannot find the member in the object referring to.

CommandParsingFailure = -5

Failed to parse an argument of a command.

Faulted = -4

Error in the application

Handled = 4

Command is Running. Set by the FinalMiddleware.

Interrupt = -2

Cannot find the object referring to.

NoRequest = 1

No Request is input by the user.

NotHandled = 2

No Request is input by the user.

Ok = 0

Everything is OK

OnExit = -1

The Progress is Exiting

Running = 3

Command is Running. Set by the FinalMiddleware.

ReFreSH.MobileSuit.Suit module

ReFreSH.MobileSuit.Suit.CreateBuilder(args: List[str] | None = None) SuitHostBuilder[source]

Get a builder to create host

ReFreSH.MobileSuit.Suit.QuickStart(T, args: List[str] = [])[source]

Quick start a mobilesuit on specific client class with default settings.

ReFreSH.MobileSuit.Suit.QuickStart4BitPowerLine(T, args: List[str] = [])[source]

Quick start a mobilesuit on specific client class with 4bit IO and PowerLine

ReFreSH.MobileSuit.Suit.QuickStartPowerLine(T, args: List[str] = [])[source]

Quick start a mobilesuit on specific client class with PowerLine

ReFreSH.MobileSuit.SuitConfig module

ReFreSH.MobileSuit.SuitHost module

class ReFreSH.MobileSuit.SuitHost.SuitHost(services: ServiceProvider, middleware: List[ISuitMiddleware], cancellationTasks: TaskRecorder)[source]

Bases: object

A entity, which serves the shell functions of a mobile-suit program.

static CreateMiddlewareInvocation(m: ISuitMiddleware, nxt: Callable[[SuitContext], Awaitable]) Callable[[SuitContext], Awaitable][source]
Dispose()[source]
async static EmptyMiddlewareInvocation(c: SuitContext)[source]
async HandleRequest(requestHandler: Callable[[SuitContext], Awaitable])[source]
Run()[source]
async RunAsync()[source]
Start()[source]
Stop()[source]

ReFreSH.MobileSuit.SuitHostBuilder module

class ReFreSH.MobileSuit.SuitHostBuilder.ISuitWorkFlow[source]

Bases: ABC

Describes the work flow of mobile suit.

abstract UseAppShell() ISuitWorkFlow[source]

Add AppShell middleware

abstract UseCustom(middlewareType: Type) ISuitWorkFlow[source]

Add a custom middleware

abstract UseFinalize() ISuitWorkFlow[source]

Add Finalize middleware

abstract UseHostShell() ISuitWorkFlow[source]

Add HostShell middleware

abstract UseInput() ISuitWorkFlow[source]

Add input middleware

abstract UsePrompt() ISuitWorkFlow[source]

Add suit prompt middleware

class ReFreSH.MobileSuit.SuitHostBuilder.SuitHostBuilder(args: List[str] = [])[source]

Bases: object

Builder to build a MobileSuit host.

AddClient(client: SuitShell)[source]

Add a client shell to mobile suit

Build() SuitHost[source]

Build a SuitHost.

ConfigureIO(configure: Callable[[IIOHub], None])[source]

config IO

HasName(name: str) SuitHostBuilder[source]

Use given PromptGenerator for the Host

MapClass(T, name: str = '') SuitHostBuilder[source]

Use given PromptGenerator for the Host

MapInstance(instance, name: str = '') SuitHostBuilder[source]

Use given PromptGenerator for the Host

MapMethod(name: str, method: Callable) SuitHostBuilder[source]

Use given PromptGenerator for the Host

Use4BitColorIO() SuitHostBuilder[source]

Use 4-bit color IO for the Host

UseCommandServer(serverType: Type)[source]

Add a client shell to mobile suit

UsePowerLine() SuitHostBuilder[source]

Use PowerLine PromptGenerator for the Host

UsePureTextIO() SuitHostBuilder[source]

Use Plain text IO for the Host

class ReFreSH.MobileSuit.SuitHostBuilder.SuitWorkFlow[source]

Bases: ISuitWorkFlow

Build(serviceProvider) List[ISuitMiddleware][source]
UseAppShell() ISuitWorkFlow[source]

Add AppShell middleware

UseCustom(middlewareType: Type) ISuitWorkFlow[source]

Add a custom middleware

UseFinalize() ISuitWorkFlow[source]

Add Finalize middleware

UseHostShell() ISuitWorkFlow[source]

Add HostShell middleware

UseInput() ISuitWorkFlow[source]

Add input middleware

UsePrompt() ISuitWorkFlow[source]

Add suit prompt middleware

Module contents

class ReFreSH.MobileSuit.IIOHub[source]

Bases: ABC

An entity, which serves the input/output of a mobile suit.

AppendWriteLinePrefix(prefix: str | Iterable = '\t') None[source]

Append a str to Prefix, usually used to increase indentation

Args:

self: IOHub to write to prefix: the output tuple to append

abstract AppendWriteLinePrefixPrimary(prefix: Iterable) None[source]

Append a str to Prefix, usually used to increase indentation

abstract ClearWriteLinePrefix() None[source]

Clear the prefix before writing line.

abstract property ColorSetting: IColorSetting

Color settings for this IOServer. (default DefaultColorSetting)

CreateReadLinePrompt(prompt: str, defaultValue: str | None, customPromptColor: Color | None) Iterable[Iterable][source]
abstract property ErrorStream: TextIOBase

Error stream (default stderr)

abstract property FormatPrompt: Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]]

Prompt server for the io server.

static GetLabel(otype: OutputType = OutputType.Default) str[source]

get label of given output type

abstract GetLinePrefix(otype: OutputType) List[Iterable][source]

Get the prefix before writing line.

abstract property Input: TextIOBase

Input stream (default stdin)

abstract property IsErrorRedirected: bool

Check if this IOServer’s error stream is redirected (NOT stderr)

abstract property IsInputRedirected: bool

Checks if this IOServer’s input stream is redirected (NOT stdin)

abstract property IsOutputRedirected: bool

Check if this IOServer’s output stream is redirected (NOT stdout)

abstract property Options: IOOptions

Disable Time marks which shows in Output-Redirected Environment.

abstract property Output: TextIOBase

Output stream (default stdout)

abstract Peek() <module 'pyasn1.type.char' from '/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pyasn1/type/char.py'>[source]

Reads the next character from input stream without changing the state of the reader or the character source.

Returns:

The next available character.

abstract Read() <module 'pyasn1.type.char' from '/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pyasn1/type/char.py'>[source]

Reads the next character from input stream.

Returns:

The next available character.

ReadLine(prompt: str = '', newLine: bool = False, customPromptColor: Color | None = None, defaultValue: str | None = None) str | None[source]

Reads a line from input stream, with prompt. Return something default if user input “”.

Args:

prompt: The prompt display(output to output stream) before user input. newLine: If the prompt will display in a single line customPromptColor: Optional. Prompt’s Color, ColorSetting.PromptColor as default. defaultValue: Default return value if user input “”

Returns:

Content from input stream, None if EOF, if user input “”, return defaultValue

abstract ReadLinePrimary() str | None[source]

Reads a line from input stream, with prompt.

Returns:

Content from input stream, None if EOF

abstract ReadToEnd() str[source]

Reads all characters from the current position to the end of the input stream and returns them as one string.

Returns:

All characters from the current position to the end.

abstract ResetError() None[source]

Reset this IOServer’s error stream to stderr

abstract ResetInput() None[source]

Reset this IOServer’s input stream to stdin

abstract ResetOutput() None[source]

Reset this IOServer’s output stream to stdout

abstract SubtractWriteLinePrefix() None[source]

Subtract a str from Prefix, usually used to decrease indentation

Write(content: str | Iterable[Iterable], otype: OutputType = OutputType.Default, custom_color: ConsoleColor | Color | None = None) None[source]

Writes some content to output stream. With certain color in console.

Args:

content: Content to output. otype: Optional. Type of this content, this decides how will it be like. custom_color: Optional. Customized color in console

WriteLine(content: str | Iterable[Iterable] = '', otype: OutputType = OutputType.Default, custom_color: ConsoleColor | Color | None = None) None[source]

Writes some content to output stream, with line break. With certain color in console.

Args:

content: Content to output. otype: Optional. Type of this content, this decides how will it be like. custom_color: Optional. Customized color in console

abstract WritePrimary(content: Iterable) None[source]

Writes some content to output stream, with line break. With certain Input/Output color.

ReFreSH.MobileSuit.SuitAlias(alias: str)[source]

Alias for a SuitObject’s member

Parameters:

alias – Alias for a SuitObject’s member

ReFreSH.MobileSuit.SuitArgInjected(arg_name: str)[source]

Indicate that Mobile Suit should Inject to this argument.

Parameters:

arg_name – The name of the argument to inject.

ReFreSH.MobileSuit.SuitArgParser(arg_name: str, parser_name: str = '', TTarget=None, TConverter=None)[source]

Select the parser used for the certain argument

ReFreSH.MobileSuit.SuitIgnore(func)[source]

Represents that this member should be ignored by Mobile Suit.

ReFreSH.MobileSuit.SuitInfo(expr: str, resObj=None)[source]

Stores the information of a member to be displayed.

Parameters:
  • resObj – Resource class

  • expr – The information.