remove dependency on sphinx app from members parsing code

Use the logging module to report warnings instead of requiring a
Sphinx Application instance as argument.

Change-Id: I9fcb635099e116905057c4a15465cf3280763937
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-10-08 19:17:45 -04:00
parent 6e7253899c
commit d387f3f8f6
2 changed files with 6 additions and 4 deletions

View File

@ -43,7 +43,6 @@ class MembersTable(tables.Table):
def run(self):
env = self.state.document.settings.env
app = env.app
# The required argument to the directive is the name of the
# file to parse.
@ -73,7 +72,7 @@ class MembersTable(tables.Table):
rel_filename, filename = env.relfn2path(datafile)
# Build the table node using the parsed file
data_iter = members.parse_members_file(app, filename)
data_iter = members.parse_members_file(filename)
table_node = self.build_table(
data_iter,
col_widths,

View File

@ -10,13 +10,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import logging
import re
LOG = logging.getLogger(__name__)
# Full name (IRC) <E-mail> [expires in] {role}
_PATTERN = re.compile('(?P<name>.*)\s+\((?P<irc>.*)\)\s+\<(?P<email>.*)\>\s+\[(?P<date>.*)\](\s+\{(?P<role>.*)\})?')
def parse_members_file(app, filename):
def parse_members_file(filename):
"""Load the members file and return each row as a dictionary.
"""
with open(filename, 'r') as f:
@ -26,7 +29,7 @@ def parse_members_file(app, filename):
continue
m = _PATTERN.match(line)
if not m:
app.warning('Could not parse line %d of %s: %r' %
LOG.warning('Could not parse line %d of %s: %r' %
(linum, filename, line))
continue
yield m.groupdict()