Docstring cleanups

This commit is contained in:
Jonathan Springer 2015-09-08 15:13:59 -04:00
parent 46d4105cb1
commit eaf1e7a049
29 changed files with 153 additions and 141 deletions

View File

@ -83,7 +83,7 @@ def get_text_file_string(text_file):
None.
:param text_file: The name of the file.
:return The file as a single string
:return: The file as a single string
"""
if not os.path.isfile(text_file):
return False
@ -108,7 +108,7 @@ def str_to_bool(string_value):
Convert a string version of a boolean into a real boolean.
:param string_value: The string value to examine and convert to a boolean type.
:return The correct boolean value
:return: The correct boolean value
"""
if isinstance(string_value, bool):
return string_value
@ -123,7 +123,7 @@ def build_icon(icon):
:param icon:
The icon to build. This can be a QIcon, a resource string in the form ``:/resource/file.png``, or a file
location like ``/path/to/file.png``. However, the **recommended** way is to specify a resource string.
:return The build icon.
:return: The build icon.
"""
button_icon = QtGui.QIcon()
if isinstance(icon, QtGui.QIcon):
@ -168,7 +168,7 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None):
:param return_icon: States if an icon should be build and returned from the thumb. Defaults to ``True``.
:param size: Allows to state a own size (QtCore.QSize) to use. Defaults to ``None``, which means that a default
height of 88 is used.
:return The final icon.
:return: The final icon.
"""
ext = os.path.splitext(thumb_path)[1].lower()
reader = QtGui.QImageReader(image_path)
@ -194,7 +194,7 @@ def validate_thumb(file_path, thumb_path):
:param file_path: The path to the file. The file **must** exist!
:param thumb_path: The path to the thumb.
:return True, False if the image has changed since the thumb was created.
:return: True, False if the image has changed since the thumb was created.
"""
if not os.path.exists(thumb_path):
return False

View File

@ -25,7 +25,9 @@
See PJLink Class 1 Specifications for details.
http://pjlink.jbmia.or.jp/english/dl.html
Section 5-1 PJLink Specifications
Section 5-5 Guidelines for Input Terminals
NOTE:

View File

@ -142,7 +142,9 @@ class ScreenList(object):
"""
Add a screen to the list of known screens.
:param screen: A dict with the screen properties::
:param screen: A dict with the screen properties:
::
{
'primary': True,

View File

@ -44,6 +44,8 @@ def source_group(inputs, source_text):
Return a dictionary where key is source[0] and values are inputs
grouped by source[0].
::
source_text = dict{"key1": "key1-text",
"key2": "key2-text",
...}
@ -81,13 +83,15 @@ def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
Create the radio button page for a tab.
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
::
source_key: {"groupkey1": {"key11": "key11-text",
"key12": "key12-text",
...
},
"groupkey2": {"key21": "key21-text",
"key22": "key22-text",
....
...
},
...
}

View File

@ -480,7 +480,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
"""
Create the initial service array with the base items to be saved.
:return service array
:return: service array
"""
service = []
core = {'lite-service': self._save_lite,

View File

@ -503,7 +503,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
Returns a theme object from an XML file
:param theme_name: Name of the theme to load from file
:return The theme object.
:return: The theme object.
"""
self.log_debug('get theme data for theme %s' % theme_name)
xml_file = os.path.join(self.path, str(theme_name), str(theme_name) + '.xml')
@ -519,7 +519,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
Display a warning box to the user that a theme already exists
:param theme_name: Name of the theme.
:return Confirm if the theme is to be overwritten.
:return: Confirm if the theme is to be overwritten.
"""
ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'),
translate('OpenLP.ThemeManager',
@ -607,7 +607,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
Check if theme already exists and displays error message
:param theme_name: Name of the Theme to test
:return True or False if theme exists
:return: True or False if theme exists
"""
theme_dir = os.path.join(self.path, theme_name)
if os.path.exists(theme_dir):
@ -718,7 +718,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
:param theme_xml: The Theme data object.
:param image_path: Where the theme image is stored
:return Theme data.
:return: Theme data.
"""
theme = ThemeXML()
theme.parse(theme_xml)
@ -734,7 +734,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R
:param confirm_text: Confirm message text to be displayed.
:param test_plugin: Do we check the plugins for theme usage.
:param confirm: Do we display a confirm box before run checks.
:return True or False depending on the validity.
:return: True or False depending on the validity.
"""
self.global_theme = Settings().value(self.settings_section + '/global theme')
if check_item_selected(self.theme_list_widget, select_text):

View File

@ -228,6 +228,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
:param listbox: A listbox (QListWidget).
:param filters: The file extension filters. It should contain the file descriptions as well as the file
extensions. For example::
'SongBeamer Files (*.sng)'
"""
if filters:

View File

@ -173,6 +173,7 @@ def init_schema(url):
Setup the songs database connection and initialise the database schema.
:param url: The database to setup
The song database contains the following tables:
* authors

View File

@ -36,7 +36,7 @@ class EasySlidesImport(SongImport):
Import songs exported from EasySlides
The format example is here:
http://wiki.openlp.org/Development:EasySlides_-_Song_Data_Format
http://wiki.openlp.org/Development:EasySlides\_-_Song_Data_Format
"""
def __init__(self, manager, **kwargs):
"""

View File

@ -71,7 +71,7 @@ class PowerSongImport(SongImport):
"""
Checks if source is a PowerSong 1.0 folder:
* is a directory
* contains at least one *.song file
* contains at least one \*.song file
"""
if os.path.isdir(import_source):
for file in os.listdir(import_source):

View File

@ -36,30 +36,30 @@ class SongProImport(SongImport):
**SongPro Song File Format:**
SongPro has the option to export under its File menu
This produces files containing single or multiple songs
The file is text with lines tagged with # followed by an identifier.
This is documented here: http://creationsoftware.com/ImportIdentifiers.php
An example here: http://creationsoftware.com/ExampleImportingManySongs.txt
#A - next line is the Song Author
#B - the lines following until next tagged line are the "Bridge" words
(can be in rtf or plain text) which we map as B1
#C - the lines following until next tagged line are the chorus words
(can be in rtf or plain text)
which we map as C1
#D - the lines following until next tagged line are the "Ending" words
(can be in rtf or plain text) which we map as E1
#E - this song ends here, so we process the song -
and start again at the next line
#G - next line is the Group
#M - next line is the Song Number
#N - next line are Notes
#R - next line is the SongCopyright
#O - next line is the Verse Sequence
#T - next line is the Song Title
#1 - #7 the lines following until next tagged line are the verse x words
(can be in rtf or plain text)
| SongPro has the option to export under its File menu
| This produces files containing single or multiple songs
| The file is text with lines tagged with # followed by an identifier.
| This is documented here: http://creationsoftware.com/ImportIdentifiers.php
| An example here: http://creationsoftware.com/ExampleImportingManySongs.txt
|
| #A - next line is the Song Author
| #B - the lines following until next tagged line are the "Bridge" words
| (can be in rtf or plain text) which we map as B1
| #C - the lines following until next tagged line are the chorus words
| (can be in rtf or plain text)
| which we map as C1
| #D - the lines following until next tagged line are the "Ending" words
| (can be in rtf or plain text) which we map as E1
| #E - this song ends here, so we process the song -
| and start again at the next line
| #G - next line is the Group
| #M - next line is the Song Number
| #N - next line are Notes
| #R - next line is the SongCopyright
| #O - next line is the Verse Sequence
| #T - next line is the Song Title
| #1 - #7 the lines following until next tagged line are the verse x words
| (can be in rtf or plain text)
"""
def __init__(self, manager, **kwargs):
"""

View File

@ -60,16 +60,16 @@ class SongShowPlusImport(SongImport):
* Each piece of data in the song file has some information that precedes it.
* The general format of this data is as follows:
4 Bytes, forming a 32 bit number, a key if you will, this describes what the data is (see blockKey below)
4 Bytes, forming a 32 bit number, which is the number of bytes until the next block starts
1 Byte, which tells how many bytes follows
1 or 4 Bytes, describes how long the string is, if its 1 byte, the string is less than 255
The next bytes are the actual data.
The next block of data follows on.
| 4 Bytes, forming a 32 bit number, a key if you will, this describes what the data is (see blockKey below)
| 4 Bytes, forming a 32 bit number, which is the number of bytes until the next block starts
| 1 Byte, which tells how many bytes follows
| 1 or 4 Bytes, describes how long the string is, if its 1 byte, the string is less than 255
| The next bytes are the actual data.
| The next block of data follows on.
This description does differ for verses. Which includes extra bytes stating the verse type or number. In some cases
a "custom" verse is used, in that case, this block will in include 2 strings, with the associated string length
descriptors. The first string is the name of the verse, the second is the verse content.
This description does differ for verses. Which includes extra bytes stating the verse type or number. In some
cases a "custom" verse is used, in that case, this block will in include 2 strings, with the associated string
length descriptors. The first string is the name of the verse, the second is the verse content.
The file is ended with four null bytes.

View File

@ -113,6 +113,7 @@ class SongXML(object):
Iterates through the verses in the XML and returns a list of verses and their attributes.
:param xml: The XML of the song to be parsed.
The returned list has the following format::
[[{'type': 'v', 'label': '1'}, u"optional slide split 1[---]optional slide split 2"],

View File

@ -21,14 +21,15 @@
###############################################################################
"""
The :mod:`songcompare` module provides functionality to search for
duplicate songs. It has one single :function:`songs_probably_equal`.
duplicate songs. It has one single :func:`songs_probably_equal`.
The algorithm is based on the diff algorithm.
First a diffset is calculated for two songs.
To compensate for typos all differences that are smaller than a
| The algorithm is based on the diff algorithm.
| First a diffset is calculated for two songs.
| To compensate for typos all differences that are smaller than a
limit (<max_typo_size) and are surrounded by larger equal blocks
(>min_fragment_size) are removed and the surrounding equal parts are merged.
Finally two conditions can qualify a song tuple to be a duplicate:
| Finally two conditions can qualify a song tuple to be a duplicate:
1. There is a block of equal content that is at least min_block_size large.
This condition should hit for all larger songs that have a long enough
equal part. Even if only one verse is equal this condition should still hit.