ReFreSH.MobileSuit.Core.Services package

Submodules

ReFreSH.MobileSuit.Core.Services.AppInfo module

class ReFreSH.MobileSuit.Core.Services.AppInfo.ISuitAppInfo[source]

Bases: ABC

provides basic info of App.

abstract property AppName: str

Name of application.

abstract property StartArgs: list[str]

Arguments for startup.

class ReFreSH.MobileSuit.Core.Services.AppInfo.SuitAppInfo[source]

Bases: ISuitAppInfo

provides basic info of App.

property AppName: str

Name of application.

property StartArgs: list[str]

Arguments for startup.

ReFreSH.MobileSuit.Core.Services.HistoryService module

class ReFreSH.MobileSuit.Core.Services.HistoryService.HistoryService[source]

Bases: IHistoryService

property Response: str | None

Response of last Request.

property Status: RequestStatus

Status of last Request.

class ReFreSH.MobileSuit.Core.Services.HistoryService.IHistoryService[source]

Bases: ABC

Provides request history.

abstract property Response: str | None

Response of last Request.

abstract property Status: RequestStatus

Status of last Request.

ReFreSH.MobileSuit.Core.Services.IOHub module

class ReFreSH.MobileSuit.Core.Services.IOHub.IOHub(promptFormatter: Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]], configurator: Callable[[IIOHub], None])[source]

Bases: IIOHub, ABC

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

static AppendTimeStamp(sb: List[str]) None[source]
AppendWriteLinePrefixInternal(prefix: PrintUnit) None[source]
AppendWriteLinePrefixPrimary(prefix: Iterable) None[source]

Append a str to Prefix, usually used to increase indentation

ClearWriteLinePrefix() None[source]

Clear the prefix before writing line.

property ColorSetting: IColorSetting

Color settings for this IOServer. (default DefaultColorSetting)

property ErrorStream: TextIO

Error stream (default stderr)

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

Prompt server for the io server.

GetLinePrefix(otype: OutputType) List[PrintUnit][source]

Get the prefix before writing line.

property Input: TextIO

Input stream (default stdin)

property IsErrorRedirected: bool

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

property IsInputRedirected: bool

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

property IsOutputRedirected: bool

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

property Options: IOOptions

Disable Time marks which shows in Output-Redirected Environment.

property Output: TextIO

Output stream (default stdout)

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.

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.

ReadLinePrimary() str[source]

Reads a line from input stream, with prompt.

Returns:

Content from input stream, None if EOF

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.

ResetError() None[source]

Reset this IOServer’s error stream to stderr

ResetInput() None[source]

Reset this IOServer’s input stream to stdin

ResetOutput() None[source]

Reset this IOServer’s output stream to stdout

SubtractWriteLinePrefix() None[source]

Subtract a str from Prefix, usually used to decrease indentation

WriteInternal(content: PrintUnit) None[source]
WritePrimary(content: Iterable) None[source]

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

class ReFreSH.MobileSuit.Core.Services.IOHub.IOHub4Bit(promptFormatter: Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]], configurator: Callable[[IIOHub], None])[source]

Bases: IOHub

IO hub using 4-bit color output.

static BackgroundCodeOf(c: Color) int[source]
static ConsoleColorOf(color: Color) ConsoleColor[source]
static ForegroundCodeOf(c: Color) int[source]
WriteInternal(content: PrintUnit) None[source]

Write content to the output stream.

class ReFreSH.MobileSuit.Core.Services.IOHub.PureTextIOHub(promptFormatter: Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]], configurator: Callable[[IIOHub], None])[source]

Bases: IOHub

IO hub with pure text output.

WritePrimary(content: Iterable) None[source]

Write content to the output stream.

ReFreSH.MobileSuit.Core.Services.ParsingService module

class ReFreSH.MobileSuit.Core.Services.ParsingService.IParsingService[source]

Bases: ABC

Get parsers for certain type.

abstract Add(_T, converter: Callable[[str], T], name: str = '') None[source]

Add a parser with certain name to parsing service.

Parameters:
  • _T

  • converter

  • name

abstract AddName(_T: Type, name: str = '') None[source]

Add a parser.

Parameters:
  • _T

  • name

abstract AddParser(parser: SuitParser[T]) None[source]

Add a parser.

Parameters:

parser

abstract Get(type: Type, name: str = '') Callable[[str], object][source]

Get a parser for certain type with certain name.

Parameters:
  • type – certain type

  • name – certain name

Returns:

class ReFreSH.MobileSuit.Core.Services.ParsingService.ParsingService[source]

Bases: IParsingService

Add(_T: Type, converter: Callable[[str], T], name: str = '') None[source]

Add a parser with certain name to parsing service.

Parameters:
  • _T

  • converter

  • name

AddName(_T: Type, name: str = '') None[source]

Add a parser.

Parameters:
  • _T

  • name

AddParser(parser: SuitParser[T]) None[source]

Add a parser.

Parameters:

parser

Get(type: Type, name: str = '') Callable[[str], object][source]

Get a parser for certain type with certain name.

Parameters:
  • type – certain type

  • name – certain name

Returns:

ReFreSH.MobileSuit.Core.Services.PromptFormatter module

ReFreSH.MobileSuit.Core.Services.PromptFormatter.PromptFormatter

represents a generator provides prompt output.

alias of Callable[[Iterable[PrintUnit]], Iterable[PrintUnit]]

class ReFreSH.MobileSuit.Core.Services.PromptFormatter.PromptFormatters[source]

Bases: object

Default prompt formatters.

static BasicPromptFormatter(origin: Iterable[PrintUnit]) Iterable[PrintUnit][source]

A basic prompt formatter for Mobile Suit.

Cross = '⨯'

a cross ⨯ char

Lightning = '⚡'

a lightning ⚡ char

static PowerLineFormatter(origin: Iterable[PrintUnit]) Iterable[PrintUnit][source]

A PowerLine themed prompt generator

RightArrow = '\ue0b1'

a right arrow  char

RightTriangle = '\ue0b0'

a right triangle  char

ReFreSH.MobileSuit.Core.Services.SuitAppShell module

class ReFreSH.MobileSuit.Core.Services.SuitAppShell.SuitAppShell[source]

Bases: SuitShell, ISuitShellCollection

SuitShell for Client App.

async Execute(context: SuitContext) None[source]

Inherited from base class.

classmethod FromClients(clients: Iterable[SuitShell]) SuitAppShell[source]
MayExecute(request: List[str]) bool[source]

Inherited from base class.

property MemberCount: int

Inherited from base class.

Members() Iterable[SuitShell][source]

Ordered members of this

ReFreSH.MobileSuit.Core.Services.SuitCommandServer module

class ReFreSH.MobileSuit.Core.Services.SuitCommandServer.SuitCommandServer(io: IIOHub, app: SuitAppShell, host: SuitHostShell, taskService: ITaskService)[source]

Bases: ISuitCommandServer

Built-In-Command Server. May be Override if necessary.

ChDir(path: str) str[source]

Inherited from base class.

async ClearCompleted() None[source]

Inherited from base class.

Dir() str[source]

Inherited from base class.

ExitSuit() RequestStatus[source]

Inherited from base class.

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

Inherited from base class.

async ListCommands(args: List[str]) None[source]

Inherited from base class.

async ListMembersAsync(suitObject: ISuitShellCollection) None[source]

List members of a SuitObject

async Stop(index: int) None[source]

Inherited from base class.

async SuitHelp() None[source]

Inherited from base class.

async Tasks() None[source]

Inherited from base class.

ReFreSH.MobileSuit.Core.Services.SuitExceptionHandler module

class ReFreSH.MobileSuit.Core.Services.SuitExceptionHandler.ISuitExceptionHandler[source]

Bases: ABC

The handler

abstract async InvokeAsync(context: SuitContext)[source]

To invoke the middleware

Args:

context: Context of the request.

class ReFreSH.MobileSuit.Core.Services.SuitExceptionHandler.SuitExceptionHandler(history: IHistoryService, io: IIOHub)[source]

Bases: ISuitExceptionHandler

async InvokeAsync(context: SuitContext)[source]

To invoke the middleware

Args:

context: Context of the request.

ReFreSH.MobileSuit.Core.Services.SuitHostShell module

class ReFreSH.MobileSuit.Core.Services.SuitHostShell.SuitHostShell(otype: Type, factory: Callable[[SuitContext], Any], info: str)[source]

Bases: SuitObjectShell

A SuitShell over SuitServer

classmethod FromCommandServer(serverType: Type) SuitHostShell[source]

Create a Host shell from command server.

ReFreSH.MobileSuit.Core.Services.TaskService module

class ReFreSH.MobileSuit.Core.Services.TaskService.ITaskService[source]

Bases: ABC

Provides task system.

AddTask(task: Task, context: SuitContext) None[source]

Add a task to Task Collection

ClearCompleted() None[source]

Remove the completed tasks.

GetTasks() Iterable[TaskInfo][source]

Get All tasks in Collection.

HasTask(index: int) bool[source]

Has a task with given index

async Join(index: int, newContext: SuitContext) None[source]

Join the task with certain index.

async RunTaskImmediately(task: Task) None[source]

Run some task immediately

property RunningCount: int

Number of Tasks that are running.

Stop(index: int) None[source]

Stop the task with certain index.

class ReFreSH.MobileSuit.Core.Services.TaskService.TaskInfo[source]

Bases: object

Information of Suit Task

class ReFreSH.MobileSuit.Core.Services.TaskService.TaskRecorder[source]

Bases: Iterable

Add(task: Task) bool[source]
Remove(task: Task) bool[source]
class ReFreSH.MobileSuit.Core.Services.TaskService.TaskService(cancelTasks: TaskRecorder)[source]

Bases: ITaskService

AddTask(task: Task, context: SuitContext) None[source]

Add a task to Task Collection

ClearCompleted() None[source]

Remove the completed tasks.

GetTasks() Iterable[TaskInfo][source]

Get All tasks in Collection.

HasTask(index: int) bool[source]

Has a task with given index

async Join(index: int, newContext: SuitContext) None[source]

Join the task with certain index.

async RunTaskImmediately(task: Task) None[source]

Run some task immediately

property RunningCount: int

Number of Tasks that are running.

Stop(index: int) None[source]

Stop the task with certain index.

Module contents