InitialSettings Module sw.initialsettings

Classes

class sw.initialsettings.InitialSettings(stdscr, kwargs)[source]

Initializing this class more or less handles every part of the initial settings menu. There are no other parts of it which needs to be called, as the initialize function will go through and call every function it needs in order. This function should be initialized with the wrapper for curses around it with the kwargs passed to our wrapper function included.

Initial settings presents the user with the default options used by the script and allows them to go through either individually change or review every one. If any special arguments were thrown into the script from the script converter, it will automatically load them in place of the defaults. At the end, the values are all validated.

Parameters:
  • stdscr – Provided by the curses wrapper, just the screen object that will be printed to.
  • kwargs – The keyword arguments provided to sw.wrapper.main()
Returns:

InitialSettings (self)

checkValues()[source]

Checks values after the user enters a blank character (they ask to begin). The primary function this serves is to check that the reporting server exists, if specified, by resolving the address, doing a handshake, and seeing what requirements, if any, the server has. Currently the only supported requirement is for the project field to not be blank.

Returns:None
error(msg=None, type='Error')[source]

Prints an error in a standard way above the user input field. The default type, Error, results in a red message, while any other value will print a yellow one.

Parameters:
  • msg – The message to print out as an error.
  • type – The type of error to print out, any value that’s not Error will be yellow. This type will prefix msg.
Returns:

None

handleInput()[source]

This method is a giant loop which calls most other functions. It waits for key presses, validates them, then loops through getting input for what was pressed, validating the input, then seeing if the user is ready to terminate... more or less.

Returns:None
processEntry(out, key, win)[source]

Called as part of handleInput(), this method checks for the type of the default value and transforms the input to that... unless the default is None, in which case it assumes String.

It will also check for specific kwargs, such as report, which upon entry it validates it as being a real URL.

Parameters:
  • out (String) – Input given from the user to fill the field specified by key.
  • key (String) – The letter the user entered, which points to a kwarg and its default value.
  • win – A curses window object for the area where the value was written. It is often written back over after the value is interpreted. For example, in a field where the default value for a kwarg is bool the field evaluates anything not /f(alse)?/i or /no?/i as True and writes “True” to the field.
Returns:

None

renderList()[source]

Renders all values prepared from setupDefaults() on the screen, but only once. This method is never called again, so it’s assumed all the values are kept pristine. In addition to printing all the titles and kwargs on screen, it adds into kwmap a 3rd index (kwmap[key][2]) which is a reference to the subwindow for that kwarg’s value. So, in the future, to modify f’s display value:

self.kwmap['f'][2].addstr( 'New Value' )
Returns:None
setupDefaults()[source]

This method loads into kwmap and kwarray the defaults for various kwargs as well as the titles to print in front of them on the display screen. It does nothing more than just loading the values up, renderList() does the dirty work.

Returns:None

Table Of Contents

Previous topic

Reporting Module sw.report

This Page