Commits

spirit  committed 9883b67

USE_ENCHANT changeable at runtime

  • Participants
  • Parent commits c927440

Comments (0)

Files changed (2)

File guess_language/__init__.py

     return UNKNOWN
 
 
-def check(words, langs, use_enchant=USE_ENCHANT):
+def check(words, langs, use_enchant=None):
     """Check what is the best match.
     """
+    if use_enchant is None:
+        use_enchant = USE_ENCHANT
+
     if use_enchant:
         tag = check_with_enchant(words, langs)
         if tag:

File guess_language/__main__.py

     parser = argparse.ArgumentParser(
         description=guess_language.__doc__.strip())
     parser.add_argument("--encoding", dest="encoding")
+    parser.add_argument("--no-enchant", dest="use_enchant",
+                        action="store_false")
     return parser.parse_args()
 
 
                 else sys.stdin.encoding if sys.stdin.isatty() else "utf-8")
     with open(sys.stdin.fileno(), encoding=encoding) as f:
         text = "\n".join(f.readlines())
+    guess_language.USE_ENCHANT = args.use_enchant
     print(guess_language.guess_language(text))