Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 43 lines (30 sloc) 1.28 KB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from gwiriwr import gwirio_llinell, agor_geiriadur, cadw_geiriadur, input
if __name__ == '__main__':
geiriadur_personol = agor_geiriadur()
if len(sys.argv) > 1:
ffeil = sys.argv[1]
with open(ffeil, 'rb') as f:
testun = f.read().decode('utf-8')
else:
testun = ""
while not testun.strip():
testun = input(u"Ysgrifennwch testun i'w gwirio:\n")
if sys.version_info[0] == 2:
testun = testun.decode('utf-8')
# cadw pob llinell testun mewn list
llinellau = testun.split(u"\n")
llinellau_wedi_gwirio = []
for llinell in llinellau:
llinell_wedi_gwirio = None
while True:
# Rhaid ail-gwirio brawddegau tad nad oes unrhywbeth wedi newid o fewn y brawddeg
llinell_wedi_gwirio, gwiriadau = gwirio_llinell(llinell_wedi_gwirio or llinell, geiriadur_personol)
if len(gwiriadau) == 0:
break
llinellau_wedi_gwirio.append(llinell_wedi_gwirio)
print(u'\n===================\nTestun wedi gwirio:\n===================\n\n{}'.format(u'\n'.join(llinellau_wedi_gwirio)))
# Cadw unrhyw newidiadau i'r 'geiriadur personol'
cadw_geiriadur(geiriadur_personol)