def _init_spell_checker(self):
"""
Initialize spell checker dictionary
"""
default_dict = "en_US"
spell_dict = None
jargonfile = self.params.get('jargonfile')
if not jargonfile:
jargonfile = os.environ.get('JARGONFILE')
if jargonfile is not None:
try:
jargonfile = str(jargonfile)
spell_dict = DictWithPWL(default_dict, jargonfile)
except:
self.error(
"Could not initialize dictionary using %s file" % jargonfile)
if not spell_dict:
try:
spell_dict = DictWithPWL(default_dict)
except:
self.error(
"Could not initialize spell checker with dictionary %s" % default_dict)
#Check if there is jargonfile on module repo
url = ("https://src.fedoraproject.org/cgit/modules/%s.git/plain/jargon.txt" %
self.mmd.name)
resp = requests.get(url)
if resp.status_code >= 200 and resp.status_code < 300:
for w in resp.content.split("\n"):
if w != '':
spell_dict.add_to_session(w)
#add words from module name as jargon
for w in self.mmd.name.split('-'):
spell_dict.add_to_session(w)
try:
chkr = SpellChecker(spell_dict)
except:
self.error("Could not initialize spell checker")
return chkr
check_modulemd.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录