Esempio n. 1
0
    def export(self):
        '''
        Export the readings for mass as HTML.
        '''

        for mass in itertools.chain(
                lectionary.getLectionary().allSundayMasses,
                lectionary.getLectionary().allSpecialMasses,
                lectionary.getLectionary().allWeekdayMasses):
            self._exportMass(mass)
Esempio n. 2
0
 def _writeIndexBody(self, outputFile):
     self._writeIndexOfSomeMasses(
         outputFile, 'Sunday Lectionary',
         lectionary.getLectionary().allSundayMasses)
     self._writeIndexOfSomeMasses(
         outputFile, 'Special Lectionary',
         lectionary.getLectionary().allSpecialMasses)
     self._writeIndexOfWeekdayMasses(
         outputFile,
         lectionary.getLectionary().allWeekdayMasses)
Esempio n. 3
0
    def _writeIndexOfWeekdayMassesInSeason(self, outputFile, seasonid):
        outputFile.write('''\
    <h3>%s</h3>
''' % masses._seasonLongDisplayName(seasonid))

        for weekid in lectionary.getLectionary().weekdayMassWeekIDs(seasonid):
            self._writeIndexOfWeekdayMassesInWeek(outputFile, seasonid, weekid)
Esempio n. 4
0
    def _writeIndexOfWeekdayMasses(self, outputFile, masses_):
        outputFile.write('''\
    <h2>Weekday Lectionary</h2>
''')

        for seasonid in lectionary.getLectionary().weekdayMassSeasonIDs:
            self._writeIndexOfWeekdayMassesInSeason(outputFile, seasonid)
Esempio n. 5
0
    def test_parseSpecialCitations(self):
        readingCount = 0
        for mass in lectionary.getLectionary()._allSpecialMasses:
            for reading in mass.allReadings:
                readingCount += 1
                citations.parse(reading.citation)

        # $ grep --count /reading special-lectionary.xml
        self.assertEqual(84, readingCount)
Esempio n. 6
0
    def test_parseWeekdayCitations(self):
        readingCount = 0
        for mass in lectionary.getLectionary()._allWeekdayMasses:
            for reading in mass.allReadings:
                readingCount += 1
                # TODO: Here is one we cannot parse yet!
                if reading.citation == 'Est C:12,14-16,23-25':
                    continue
                citations.parse(reading.citation)

        # $ grep --count /reading weekday-lectionary.xml
        self.assertEqual(863, readingCount)
Esempio n. 7
0
    def _writeIndexOfWeekdayMassesInWeek(self, outputFile, seasonid, weekid):
        if weekid is not None:
            outputFile.write('''\
    <h4>%s</h4>
''' % masses._weekAndSeasonDisplayName(seasonid, weekid))

        masses_ = lectionary.getLectionary().weekdayMassesInWeek(
            seasonid, weekid)
        outputFile.write('''\
    <ul>
''')
        for mass in masses_:
            self._writeShortIndexEntryForMass(outputFile, mass)
        outputFile.write('''
    </ul>
''')
Esempio n. 8
0
    def test_parseSundayCitations(self):
        '''
        Prove that the number of readings we find in the Sunday
        Lectionary by invoking ``grep`` on the XML equals the number
        of readings we find in our object representation of the Sunday
        Lectionary.  Furthermore, prove that we can parse every one of
        the citations.
        '''

        readingCount = 0
        for mass in lectionary.getLectionary().allSundayMasses:
            for reading in mass.allReadings:
                readingCount += 1
                citations.parse(reading.citation)

        # $ grep --count /reading sunday-lectionary.xml
        self.assertEqual(535, readingCount)
Esempio n. 9
0
 def _findMass(self, massID):
     return lectionary.getLectionary().findMass(massID)
Esempio n. 10
0
 def test_weekdayMassesInWeek(self):
     lectionary.getLectionary().weekdayMassesInWeek(None, 'week-1')
Esempio n. 11
0
def main(args=None):
    '''
    The command-line interface.
    '''

    # Create the command-line parser.
    exampleText = '''\
Examples:

    lectionaryviews.py trinity-sunday
    lectionaryviews.py 2017-10-17
    lectionaryviews.py today

By default, only the cycle-applicable readings are included.  To see
all readings, append '#' to the name of the mass (or date).  For
example:

    lectionaryviews.py trinity-sunday#
    lectionaryviews.py 2017-10-17#
    lectionaryviews.py today#

To see only the readings for a particular cycle, append '#' and the
name of the cycle to the name of the mass (or date).  For example:

    lectionaryviews.py trinity-sunday#C
    lectionaryviews.py 2017-10-17#A
    lectionaryviews.py today#A
'''
    parser = argparse.ArgumentParser(
        description='''\
Provide the name of a mass (or a date) and we will write its readings
to stdout.''',
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=exampleText)

    parser.add_argument('--list-all-ids',
                        action='store_true',
                        dest='listAllIDs',
                        help='list all mass ids (and exit)')
    parser.add_argument('--list-weekday-ids',
                        action='store_true',
                        dest='listWeekdayIDs',
                        help='list weekday mass ids (and exit)')
    parser.add_argument('--list-sunday-ids',
                        action='store_true',
                        dest='listSundayIDs',
                        help='list weekday mass ids (and exit)')
    parser.add_argument('--list-special-ids',
                        action='store_true',
                        dest='listSpecialIDs',
                        help='list special mass ids (and exit)')
    parser.add_argument('--export',
                        dest='exportFolderPath',
                        default=None,
                        help='export the whole lectionary')

    parser.add_argument('query',
                        metavar='QUERY',
                        nargs='?',
                        help='the id of mass (or a date)')

    # Parse the command-line and handle the list options (if present).
    options = parser.parse_args(args)
    if options.listAllIDs:
        sys.stderr.write('%s\n' % (lectionary.getLectionary().allIDsFormatted))
        raise SystemExit(1)
    if options.listWeekdayIDs:
        sys.stderr.write('%s\n' %
                         (lectionary.getLectionary().weekdayIDsFormatted))
        raise SystemExit(1)
    if options.listSundayIDs:
        sys.stderr.write('%s\n' %
                         (lectionary.getLectionary().sundayIDsFormatted))
        raise SystemExit(1)
    if options.listSpecialIDs:
        sys.stderr.write('%s\n' %
                         (lectionary.getLectionary().specialIDsFormatted))
        raise SystemExit(1)

    if options.exportFolderPath is not None:
        exportLectionaryAsHTML(options.exportFolderPath)
        return

    # If no query was provided, print help and exit.
    if options.query is None:
        parser.print_help()
        raise SystemExit(1)

    # Parse the query.
    try:
        massTitle, readings = lectionary.getReadings(options.query)
    except lectionary.NonSingularResultsError as e:
        sys.stderr.write('%s\n' % e.message)
        raise SystemExit(-1)

    # Write all the readings for the mass to stdout.
    writeReadingsAsText(massTitle, readings, options)