This file contains various helper functions and utilities that the program uses.
CreateConfigDir | Creates the user config directory its default sub |
FilterFiles | Filters a list of paths and returns a list of paths |
GetAllEncodings | Get all encodings found on the system |
GetClipboardText | Get the primary selection from the clipboard if there is one |
GetFileReader | Returns a file stream reader object for reading the |
GetFileType | Get what the type of the file is as Editra sees it |
GetFileWriter | Returns a file stream writer object for reading the |
GetProxyOpener | Get a urlopener for use with a proxy |
GetResourceFiles | Gets a list of resource files from a directory and trims the |
GetResources | Returns a list of resource directories from a given toplevel config dir |
GetUserConfigBase | Get the base user configuration directory path |
HasConfigDir | Checks if the user has a config directory and returns True if the config directory exists or False if it does not. |
Log | Push the message to the apps log |
MakeConfigDir | Makes a user config directory |
RepairConfigState | Repair the state of profile path, updating and creating it |
ResolvConfigDir | Checks for a user config directory and if it is not |
SetClipboardText | Copies text to the clipboard |
SetWindowIcon | Sets the given windows icon to be the programs |
DropTargetFT | Drop target capable of accepting dropped files and text |
EdClipboard | Local clipboard object |
IntValidator | A Generic integer validator |
Creates the user config directory its default sub directories and any of the default config files.
Postcondition : | all default configuration files/folders are created |
---|
Filters a list of paths and returns a list of paths that can probably be opened in the editor.
Parameters: | file_list – list of files/folders to filter for good files in |
---|
Get all encodings found on the system
Returns: | list of strings |
---|
Get the primary selection from the clipboard if there is one
Returns: | str or None |
---|
Returns a file stream reader object for reading the supplied file name. It returns a file reader using the encoding (enc) which defaults to utf-8. If lookup of the reader fails on the host system it will return an ascii reader. If there is an error in creating the file reader the function will return a negative number.
Parameters: |
|
---|---|
Returns: | file reader, or int if error. |
Get what the type of the file is as Editra sees it in a formatted string.
Parameters: | fname – file path |
---|---|
Returns: | string (formatted/translated filetype) |
Returns a file stream writer object for reading the supplied file name. It returns a file writer in the supplied encoding if the host system supports it other wise it will return an ascii reader. The default will try and return a utf-8 reader. If there is an error in creating the file reader the function will return a negative number.
Parameters: |
|
---|
Get a urlopener for use with a proxy
Parameters: | proxy_set – proxy settings to use |
---|
Gets a list of resource files from a directory and trims the file extentions from the names if trim is set to True (default). If the get_all parameter is set to True the function will return a set of unique items by looking up both the user and system level files and combining them, the default behavior returns the user level files if they exist or the system level files if the user ones do not exist.
Parameters: |
|
---|
Returns a list of resource directories from a given toplevel config dir
Parameters: | resource – config directory name |
---|---|
Returns: | list of resource directory that exist under the given resource path |
Get the base user configuration directory path
Checks if the user has a config directory and returns True if the config directory exists or False if it does not.
Returns: | whether config dir in question exists on an expected path |
---|
Push the message to the apps log
Parameters: | msg – message string to log |
---|
Makes a user config directory
Parameters: | name – name of config directory to make in user config dir |
---|
Repair the state of profile path, updating and creating it it does not exist.
Parameters: | path – path of profile |
---|
Checks for a user config directory and if it is not found it then resolves the absolute path of the executables directory from the relative execution path. This is then used to find the location of the specified directory as it relates to the executable directory, and returns that path as a string.
Parameters: |
|
---|
Note
This method is probably much more complex than it needs to be but the code has proven itself.
Copies text to the clipboard
Parameters: |
|
---|
Sets the given windows icon to be the programs application icon.
Parameters: | window – window to set app icon for |
---|