Merge "Update sphinx extension logging"

This commit is contained in:
Zuul 2019-11-18 15:33:18 +00:00 committed by Gerrit Code Review
commit 3a27133f24
2 changed files with 12 additions and 8 deletions

View File

@ -18,6 +18,9 @@ import re
from docutils import nodes from docutils import nodes
from docutils.parsers.rst.directives.tables import Table from docutils.parsers.rst.directives.tables import Table
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
from sphinx.util import logging
LOG = logging.getLogger(__name__)
# Full name (IRC nickname) [expires in] {role} # Full name (IRC nickname) [expires in] {role}
_PATTERN = re.compile('(?P<name>.*)\s+\((?P<irc>.*)\)\s+\[(?P<date>.*)\](\s+\{(?P<role>.*)\})?') _PATTERN = re.compile('(?P<name>.*)\s+\((?P<irc>.*)\)\s+\[(?P<date>.*)\](\s+\{(?P<role>.*)\})?')
@ -33,7 +36,7 @@ def _parse_members_file(app, filename):
continue continue
m = _PATTERN.match(line) m = _PATTERN.match(line)
if not m: 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)) (linum, filename, line))
continue continue
yield m.groupdict() yield m.groupdict()
@ -150,5 +153,5 @@ class MembersTable(Table):
return table return table
def setup(app): def setup(app):
app.info('loading members extension') LOG.info('loading members extension')
app.add_directive('memberstable', MembersTable) app.add_directive('memberstable', MembersTable)

View File

@ -12,14 +12,16 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Build a table of the current teams """Build a table of the current teams"""
"""
import yaml
from docutils import nodes from docutils import nodes
from docutils.parsers.rst.directives.tables import Table from docutils.parsers.rst.directives.tables import Table
from docutils.parsers.rst import directives from docutils.parsers.rst import directives
from sphinx.util import logging
import yaml LOG = logging.getLogger(__name__)
class TeamTable(Table): class TeamTable(Table):
@ -34,7 +36,6 @@ class TeamTable(Table):
} }
def run(self): def run(self):
env = self.state.document.settings.env env = self.state.document.settings.env
app = env.app
if self.options.get('headers') is not None: if self.options.get('headers') is not None:
self.HEADERS = self.options.get('headers').split(",") self.HEADERS = self.options.get('headers').split(",")
@ -68,8 +69,8 @@ class TeamTable(Table):
# Now find the real path to the file, relative to where we are. # Now find the real path to the file, relative to where we are.
rel_filename, filename = env.relfn2path(datafile) rel_filename, filename = env.relfn2path(datafile)
app.info('loading teamtable') LOG.info('loading teamtable')
app.info('reading %s' % filename) LOG.info('reading %s' % filename)
with open(filename, 'r') as f: with open(filename, 'r') as f:
_teams_yaml = yaml.load(f.read()) _teams_yaml = yaml.load(f.read())