Here is an overview of the multiple files that compound turses, each of them with a comment explaining their goal.
turses
├── requirements
│ ├── base.txt
│ └── dev.txt
├── setup.py
└── turses
├── api
│ ├── base.py # definition of an interface to the Twitter API
│ ├── backends.py # Twitter API implementations
│ ├── debug.py # mock API implementation for debugging
│ └── __init__.py
├── cli.py # logic for launching `turses`
├── config.py # configuration management
├── core.py # core logic: controller and event handling
├── __init__.py
├── meta.py # decorators and abstract base classes
├── models.py # data structures
├── ui.py # UI widgets
└── utils.py # misc funcions that don't fit elsewhere
Handle the invocation of turses from the command line.
Generate and parse configuration files. When instantiated, it loads the defaults.
Calling Configuration.parse_args() with an argparse.ArgumentParser instance will modify the instance to match the options provided by the command line arguments.
Calling turses.config.Configuration.load() on this class’ instances reads the preferences from the user configuration files. If no configuration or token files are found, this class will take care of creating them.
Offers backwards compatibility with the Tyrs configuration.
This module contains the controller and key handling logic of turses.
Maps key bindings from configuration to calls to Controller functions.
The Controller.
This module contains abstract classes and decorators.
The abstract base classes can be understood as interfaces, they define a set of methods and properties that their subclasses must implement. They provide very general pieces of functionality.
A list that contains an active element.
This abstract class implements some functions but the subclasses must define the turses.meta.ActiveList.active property, as well as turses.meta.ActiveList.is_valid_index() and turses.meta.ActiveList.activate_last(). methods.
A ActiveList in which the active element can be shifted position by position, to the begging and to the end.
All the methods that this class contains are abstract.
An implementation of the observer pattern.
Zero or more observers can subscribe to the changes in the instances of this class. When the instance changes, it will call its notify method, which loops through the observers and calls update() on them.
An abstract class that for making a class updatable.
The constructor takes update function and arguments used to update the subclasses of Updatable.
When update() is executed, update_callback() is called passing it the result.
An implementation of the observer pattern.
Zero or more observers can subscribe to the changes in the instances of this class. When the instance changes, it will call its notify method, which loops through the observers and calls update() on them.
An abstract class that can subscribe to updates in Observable instances.
This module contains the data structures that power turses and the Twitter entities represented into it.
The model on which turses is based is TimelineList, a list of Timeline objects. This model is mapped into the list of buffers that appear on the user interface.
A list of Timeline instances that implements the UnsortedActiveList interface, thus having an active element and a group of adjacent visible timelines.
The Twitter entities represented on turses are the following:
List of Twitter statuses ordered reversely by date, optionally with a name and a function that updates the current timeline and its arguments.
Its Updatable and implements the ActiveList interface.
A Twitter user.
A Twitter status.
This module contains the curses UI widgets.
Creates a curses interface for the program, providing functions to draw all the components of the UI.
Provides a facade API to draw the representation of the TimelineList, help HelpBuffer and intro Banner screens.
Note
The list of widgets presented here is not complete.
turses make heavy usage of the urwid.WidgetWrap class to compose custom widgets.
ScrollableWidgetWrap helps to make widgets that implement the Scrollable interface, thus are navigable with the motion commands up, down, scroll_to_top and scroll_to_bottom.
This module contains functions used across different modules.