METADATA 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. Metadata-Version: 2.4
  2. Name: python-bidi
  3. Version: 0.6.7
  4. Classifier: Development Status :: 4 - Beta
  5. Classifier: Intended Audience :: Developers
  6. Classifier: Operating System :: OS Independent
  7. Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
  8. Classifier: Topic :: Text Processing
  9. Classifier: Programming Language :: Python :: 3
  10. Classifier: Programming Language :: Python :: 3.9
  11. Classifier: Programming Language :: Python :: 3.10
  12. Classifier: Programming Language :: Python :: 3.11
  13. Classifier: Programming Language :: Python :: 3.12
  14. Classifier: Programming Language :: Python :: 3.13
  15. Classifier: Programming Language :: Python :: 3.14
  16. Requires-Dist: pytest ; extra == 'dev'
  17. Provides-Extra: dev
  18. License-File: LICENSE-THIRD-PARTY.yml
  19. License-File: COPYING
  20. License-File: COPYING.LESSER
  21. License-File: AUTHORS.rst
  22. Summary: Python Bidi layout wrapping the Rust crate unicode-bidi
  23. Keywords: bidi,unicode,layout
  24. Author-email: Meir Kriheli <mkriheli@gmail.com>
  25. Description-Content-Type: text/x-rst; charset=UTF-8
  26. Project-URL: Homepage, https://github.com/MeirKriheli/python-bidi
  27. Project-URL: Repository, https://github.com/MeirKriheli/python-bidi
  28. Project-URL: Documentation, https://python-bidi.readthedocs.io/en/latest/
  29. Project-URL: Issues, https://github.com/MeirKriheli/python-bidi/issues
  30. Project-URL: Changelog, https://github.com/MeirKriheli/python-bidi/blob/master/CHANGELOG.rst
  31. ===============================
  32. Python BiDi
  33. ===============================
  34. `Bi-directional`_ (BiDi) layout for Python providing 2 implementations:
  35. * V5 of the algorithm implemented with Python.
  36. * Wrapper the `unicode-bidi`_ Rust crate.
  37. `Package documentation`_
  38. .. _Bi-directional: http://en.wikipedia.org/wiki/Bi-directional_text
  39. .. _unicode-bidi: https://crates.io/crates/unicode-bidi
  40. .. _Package documentation: http://python-bidi.readthedocs.org/en/latest/
  41. For the python implementation, and compatible with previous versions, use::
  42. from bidi.algorithm import get_display
  43. For the newer Rust based one, which seems to implement higher version of
  44. the algorithm (albeit with some missing see #25), use the top level import::
  45. from bidi import get_display
  46. API
  47. ----
  48. The algorithm starts with a single entry point `get_display` (see above for selecting the implementaion).
  49. **Required arguments:**
  50. * ``str_or_bytes``: The string or bytes (i.e.: storage). If it's bytes
  51. use the optional argument ``encoding`` to specify it's encoding.
  52. **Optional arguments:**
  53. * ``encoding``: If unicode_or_str is a string, specifies the encoding. The
  54. algorithm uses unicodedata_ which requires unicode. This encoding will be
  55. used to decode and encode back to string before returning
  56. (default: "utf-8").
  57. * ``base_dir``: ``'L'`` or ``'R'``, override the calculated base_level.
  58. * ``debug``: ``True`` to display the Unicode levels as seen by the algorithm
  59. (default: ``False``).
  60. The Python implementaion adds one more optional argument:
  61. * ``upper_is_rtl``: True to treat upper case chars as strong 'R' for
  62. debugging (default: False).
  63. It returns the display layout, either as ``str`` or ``encoding`` encoded ``bytes``
  64. (depending on the type of ``str_or_bytes'``).
  65. .. _unicodedata: http://docs.python.org/library/unicodedata.html
  66. Example::
  67. >>> from bidi import get_display
  68. >>> # keep as list with char per line to prevent browsers from changing display order
  69. >>> HELLO_HEB = "".join([
  70. ... "ש",
  71. ... "ל",
  72. ... "ו",
  73. ... "ם"
  74. ... ])
  75. >>>
  76. >>> HELLO_HEB_DISPLAY = "".join([
  77. ... "ם",
  78. ... "ו",
  79. ... "ל",
  80. ... "ש",
  81. ... ])
  82. >>>
  83. >>> get_display(HELLO_HEB) == HELLO_HEB_DISPLAY
  84. True
  85. CLI
  86. ----
  87. ``pybidi`` is a command line utility (calling ``bidi.main``) for running the
  88. display algorithm. The script can get a string as a parameter or read text from
  89. `stdin`.
  90. Usage::
  91. $ pybidi -h
  92. usage: pybidi [-h] [-e ENCODING] [-u] [-d] [-b {L,R}] [-r] [-v]
  93. options:
  94. -h, --help show this help message and exit
  95. -e ENCODING, --encoding ENCODING
  96. Text encoding (default: utf-8)
  97. -u, --upper-is-rtl Treat upper case chars as strong 'R' for debugging (default: False), Ignored in Rust algo
  98. -d, --debug Output to stderr steps taken with the algorithm
  99. -b {L,R}, --base-dir {L,R}
  100. Override base direction [L|R]
  101. -r, --rust Use the Rust unicode-bidi implemention instead of the Python one
  102. -v, --version show program's version number and exit
  103. Examples::
  104. $ pybidi -u 'Your string here'
  105. $ cat ~/Documents/example.txt | pybidi
  106. Installation
  107. -------------
  108. At the command line (assuming you're using some virtualenv)::
  109. pip install python-bidi
  110. Running tests
  111. --------------
  112. To run the tests::
  113. pip install nox
  114. nox