Vocab-Apps / python-pinyin-jyutping-sentence

Convert a Chinese sentence to Pinyin or Jyutping
GNU General Public License v3.0
55 stars 5 forks source link

Avoid printing to stdout and use the standard logging module instead #7

Closed dahlia closed 3 years ago

dahlia commented 3 years ago

The previous behavior of the module made CLI programs to be consumed by other programs through pipe cannot use it, because its print() calls pollute programs' stdout. For example, if a program purposes to write a valid JSON into stdout and be consumed by other program which reads a valid JSON through stdin (e.g., jq), the consumer program fails to parse it because its input is not a valid JSON due to the module's log messages.

Rather than printing these log messages into stdout, I changed it to use logging module instead. The standard logging module can be handled by a client code and silences log messages by default.

luc-vocab commented 3 years ago

Merged, thank you ! Please definitely get in touch and let me know how you are using the module, i'm very interested.

dahlia commented 3 years ago

Thank you for merging my patch! When would you make a new release?

Please definitely get in touch and let me know how you are using the module, i'm very interested.

I use this module in my small command-line program to generate HTML code. As my project consists of polyglot scripts and they are glued using Makefile, all these programs communicate each other through pipe. This module's previous behavior mixed its own logging messages with HTML code, and it leads the browser to render unwanted result.

luc-vocab commented 3 years ago

@dahlia I just pushed v0.9 : https://pypi.org/project/pinyin_jyutping_sentence/#history

dahlia commented 3 years ago

Thank you!