Skip to content

Commit

Permalink
refactor: fix flake errors ambitiously
Browse files Browse the repository at this point in the history
  • Loading branch information
asdofindia committed May 23, 2020
1 parent 8336408 commit a5f2c34
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ test:
coverage run --source=libindic -m unittest discover -s libindic

flake:
flake8 --max-complexity 10 --ignore F401,E402 libindic/payyans
flake8 --max-complexity 10 libindic

travis: test flake

clean:
find . -iname "*.pyc" -exec rm -vf {} \;
find . -iname "__pycache__" -delete
Expand Down
1 change: 1 addition & 0 deletions libindic/payyans/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
__all__ = ["Payyans", "getInstance"]
from .core import Payyans, getInstance
28 changes: 15 additions & 13 deletions libindic/payyans/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
അമേരിക്കാ-ഇറാഖ് യുദ്ധം താഴെപ്പറയും വിധമാകുന്നു.
'''

'''ആവശ്യത്തിനുള്ള കോപ്പുകള്‍ കൂട്ടുക '''
import sys # കുന്തം
# ആവശ്യത്തിനുള്ള കോപ്പുകള്‍ കൂട്ടുക
import codecs # കൊടച്ചക്രം
import os # ശീലക്കുട
from libindic.normalizer import Normalizer
Expand Down Expand Up @@ -132,14 +131,18 @@ def ASCII2Unicode(self, ascii_text, font):
if self.isPostbase(next_ucode_letter):
postbase_letter = next_ucode_letter
index = index + 1
if ((unicode_letter.encode('utf-8') == "എ") |
(unicode_letter.encode('utf-8') == "ഒ")):
unicode_text = unicode_text + postbase_letter + \
self.getVowelSign(prebase_letter,
unicode_letter)
if ((unicode_letter.encode('utf-8') == "എ")
| (unicode_letter.encode('utf-8') == "ഒ")):
vowel_sign = self.getVowelSign(prebase_letter,
unicode_letter)
unicode_text = (unicode_text
+ postbase_letter
+ vowel_sign)
else:
unicode_text = unicode_text + unicode_letter + \
postbase_letter + prebase_letter
unicode_text = (unicode_text
+ unicode_letter
+ postbase_letter
+ prebase_letter)
prebase_letter = ""
postbase_letter = ""
index = index + charNo
Expand Down Expand Up @@ -175,10 +178,8 @@ def isPrebase(self, letter):
എന്നു പയ്യന്റെ ഗുരു പയ്യഗുരു പയ്യെ മൊഴിഞ്ഞിട്ടുണ്ടു്.
'''
unicode_letter = letter.encode('utf-8')
if ((unicode_letter == "േ") |
(unicode_letter == "ൈ") | (unicode_letter == "ൊ") |
(unicode_letter == "ോ") | (unicode_letter == "ൌ") |
(unicode_letter == "്ര") | (unicode_letter == "െ")):
prebase_letters = ["േ", "ൈ", "ൊ", "ോ", "ൌ", "്ര", "െ"]
if (unicode_letter in prebase_letters):
return True # "ഇതു സത്യം... അ...സത്യം.... അസത്യം...!"
else:
return False
Expand Down Expand Up @@ -251,6 +252,7 @@ def LoadRules(self):
rules_dict[lhs] = rhs
else:
rules_dict[rhs] = lhs
rules_file.close()
return rules_dict

def get_module_name(self):
Expand Down

0 comments on commit a5f2c34

Please sign in to comment.