python-bidi-0.4.2/0000755000175000017500000000000013507355325013665 5ustar meirmeir00000000000000python-bidi-0.4.2/AUTHORS.rst0000644000175000017500000000043213507355214015540 0ustar meirmeir00000000000000======= Credits ======= Development Lead ---------------- * Meir Kriheli Tests ------ Tests based on fribidi_. .. _fribidi: http://fribidi.org/ Contributors ------------ * Just van Rossum - https://github.com/justvanrossum * Jakub Wilk python-bidi-0.4.2/CHANGELOG.rst0000644000175000017500000000155413507355151015710 0ustar meirmeir00000000000000.. :changelog: 0.4.2 ----- * Type Fixes, thanks jwilk History ========= 0.4.1 ----- * Merged Fix for mixed RTL and numbers, Thanks Just van Rossum 0.4.0 ----- * Move to cookiecutter template * Python 3 support (py2.6, 2.7, 3.3, 3.4 and pypy) * Better docs * Travis integration * Tox tests * PEP8 cleanup 0.3.4 ------ * Remove extra newline in console script output 0.3.3 ------ * Implement overriding base paragraph direction * Allow overriding base direction in pybidi console script * Fix returning display in same encoding 0.3.2 ------ * Test for surrogate pairs * Fix indentation in documentations * Specify license in setup.py 0.3.1 ----- * Added missing description * docs/INSTALL.rst 0.3 --- * Apply bidi mirroring * Move to back function based implementation 0.2 --- * Move the algorithm to a class based implementation 0.1 --- * Initial release python-bidi-0.4.2/CONTRIBUTING.rst0000644000175000017500000000621412371451424016324 0ustar meirmeir00000000000000============ Contributing ============ Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: Types of Contributions ---------------------- Report Bugs ~~~~~~~~~~~ Report bugs at https://github.com/MeirKriheli/python-bidi/issues. If you are reporting a bug, please include: * Your operating system name and version. * Any details about your local setup that might be helpful in troubleshooting. * Detailed steps to reproduce the bug. Fix Bugs ~~~~~~~~ Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it. Implement Features ~~~~~~~~~~~~~~~~~~ Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it. Write Documentation ~~~~~~~~~~~~~~~~~~~ Python BiDi could always use more documentation, whether as part of the official Python BiDi docs, in docstrings, or even on the web in blog posts, articles, and such. Submit Feedback ~~~~~~~~~~~~~~~ The best way to send feedback is to file an issue at https://github.com/MeirKriheli/python-bidi/issues. If you are proposing a feature: * Explain in detail how it would work. * Keep the scope as narrow as possible, to make it easier to implement. * Remember that this is a volunteer-driven project, and that contributions are welcome :) Get Started! ------------ Ready to contribute? Here's how to set up `python-bidi` for local development. 1. Fork the `python-bidi` repo on GitHub. 2. Clone your fork locally:: $ git clone git@github.com:your_name_here/python-bidi.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: $ mkvirtualenv python-bidi $ cd python-bidi/ $ python setup.py develop 4. Create a branch for local development:: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:: $ flake8 python-bidi tests $ python setup.py test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub:: $ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. Pull Request Guidelines ----------------------- Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/MeirKriheli/python-bidi/pull_requests and make sure that the tests pass for all supported Python versions. Tips ---- To run a subset of tests:: $ python -m unittest tests.test_python-bidipython-bidi-0.4.2/COPYING0000644000175000017500000010451312371450235014716 0ustar meirmeir00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . python-bidi-0.4.2/COPYING.LESSER0000644000175000017500000001674312371450235015721 0ustar meirmeir00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. python-bidi-0.4.2/MANIFEST.in0000644000175000017500000000043612576063006015423 0ustar meirmeir00000000000000include AUTHORS.rst include CONTRIBUTING.rst include CHANGELOG.rst include COPYING include COPYING.LESSER include TODO.rst include README.rst recursive-include tests * recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat python-bidi-0.4.2/PKG-INFO0000644000175000017500000001351613507355325014770 0ustar meirmeir00000000000000Metadata-Version: 1.1 Name: python-bidi Version: 0.4.2 Summary: Pure python implementation of the BiDi layout algorithm Home-page: https://github.com/MeirKriheli/python-bidi Author: Meir Kriheli Author-email: mkriheli@gmail.com License: http://www.gnu.org/licenses/lgpl.html Description: =============================== Python BiDi =============================== .. image:: https://badge.fury.io/py/python-bidi.png :target: http://badge.fury.io/py/python-bidi .. image:: https://travis-ci.org/MeirKriheli/python-bidi.png?branch=master :target: https://travis-ci.org/MeirKriheli/python-bidi `Bi-directional`_ (BiDi) layout implementation in pure python `Package documentation`_ .. _Bi-directional: http://en.wikipedia.org/wiki/Bi-directional_text .. _Package documentation: http://python-bidi.readthedocs.org/en/latest/ API ---- The algorithm starts with a single entry point `bidi.algorithm.get_display`. **Required arguments:** * ``unicode_or_str``: The original unicode or string (i.e.: storage). If it's a string use the optional argument ``encoding`` to specify it's encoding. **Optional arguments:** * ``encoding``: If unicode_or_str is a string, specifies the encoding. The algorithm uses unicodedata_ which requires unicode. This encoding will be used to decode and encode back to string before returning (default: "utf-8"). * ``upper_is_rtl``: True to treat upper case chars as strong 'R' for debugging (default: False). * ``base_dir``: 'L' or 'R', override the calculated base_level. * ``debug``: True to display (using `sys.stderr`_) the steps taken with the algorithm (default: False). Returns the display layout, either as unicode or ``encoding`` encoded string (depending on the type of ``unicode_or_str'``). .. _unicodedata: http://docs.python.org/library/unicodedata.html .. _sys.stderr: http://docs.python.org/library/sys.html?highlight=sys.stderr#sys.stderr Example:: >>> from bidi.algorithm import get_display >>> get_display(u'car is THE CAR in arabic', upper_is_rtl=True) u'car is RAC EHT in arabic' CLI ---- ``pybidi`` is a command line utility (calling ``bidi.main``) for running the bidi algorithm. the script can get a string as a parameter or read text from `stdin`. Usage:: $ pybidi -h Usage: pybidi [options] Options: -h, --help show this help message and exit -e ENCODING, --encoding=ENCODING Text encoding (default: utf-8) -u, --upper-is-rtl treat upper case chars as strong 'R' for debugging (default: False). -d, --debug Output to stderr steps taken with the algorithm -b BASE_DIR, --base-dir=BASE_DIR Override base direction [L|R] Examples:: $ pybidi -u 'car is THE CAR in arabic' car is RAC EHT in arabic $ cat ~/Documents/example.txt | pybidi ... Installation ------------- See ``docs/INSTALL.rst`` Running tests -------------- To run the tests:: python setup.py test Some explicit tests are failing right now (see TODO) 0.4.2 ----- * Type Fixes, thanks jwilk History ========= 0.4.1 ----- * Merged Fix for mixed RTL and numbers, Thanks Just van Rossum 0.4.0 ----- * Move to cookiecutter template * Python 3 support (py2.6, 2.7, 3.3, 3.4 and pypy) * Better docs * Travis integration * Tox tests * PEP8 cleanup 0.3.4 ------ * Remove extra newline in console script output 0.3.3 ------ * Implement overriding base paragraph direction * Allow overriding base direction in pybidi console script * Fix returning display in same encoding 0.3.2 ------ * Test for surrogate pairs * Fix indentation in documentations * Specify license in setup.py 0.3.1 ----- * Added missing description * docs/INSTALL.rst 0.3 --- * Apply bidi mirroring * Move to back function based implementation 0.2 --- * Move the algorithm to a class based implementation 0.1 --- * Initial release Keywords: bidi unicode layout Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Topic :: Text Processing Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: PyPy python-bidi-0.4.2/README.rst0000644000175000017500000000537213507355043015360 0ustar meirmeir00000000000000=============================== Python BiDi =============================== .. image:: https://badge.fury.io/py/python-bidi.png :target: http://badge.fury.io/py/python-bidi .. image:: https://travis-ci.org/MeirKriheli/python-bidi.png?branch=master :target: https://travis-ci.org/MeirKriheli/python-bidi `Bi-directional`_ (BiDi) layout implementation in pure python `Package documentation`_ .. _Bi-directional: http://en.wikipedia.org/wiki/Bi-directional_text .. _Package documentation: http://python-bidi.readthedocs.org/en/latest/ API ---- The algorithm starts with a single entry point `bidi.algorithm.get_display`. **Required arguments:** * ``unicode_or_str``: The original unicode or string (i.e.: storage). If it's a string use the optional argument ``encoding`` to specify it's encoding. **Optional arguments:** * ``encoding``: If unicode_or_str is a string, specifies the encoding. The algorithm uses unicodedata_ which requires unicode. This encoding will be used to decode and encode back to string before returning (default: "utf-8"). * ``upper_is_rtl``: True to treat upper case chars as strong 'R' for debugging (default: False). * ``base_dir``: 'L' or 'R', override the calculated base_level. * ``debug``: True to display (using `sys.stderr`_) the steps taken with the algorithm (default: False). Returns the display layout, either as unicode or ``encoding`` encoded string (depending on the type of ``unicode_or_str'``). .. _unicodedata: http://docs.python.org/library/unicodedata.html .. _sys.stderr: http://docs.python.org/library/sys.html?highlight=sys.stderr#sys.stderr Example:: >>> from bidi.algorithm import get_display >>> get_display(u'car is THE CAR in arabic', upper_is_rtl=True) u'car is RAC EHT in arabic' CLI ---- ``pybidi`` is a command line utility (calling ``bidi.main``) for running the bidi algorithm. the script can get a string as a parameter or read text from `stdin`. Usage:: $ pybidi -h Usage: pybidi [options] Options: -h, --help show this help message and exit -e ENCODING, --encoding=ENCODING Text encoding (default: utf-8) -u, --upper-is-rtl treat upper case chars as strong 'R' for debugging (default: False). -d, --debug Output to stderr steps taken with the algorithm -b BASE_DIR, --base-dir=BASE_DIR Override base direction [L|R] Examples:: $ pybidi -u 'car is THE CAR in arabic' car is RAC EHT in arabic $ cat ~/Documents/example.txt | pybidi ... Installation ------------- See ``docs/INSTALL.rst`` Running tests -------------- To run the tests:: python setup.py test Some explicit tests are failing right now (see TODO) python-bidi-0.4.2/TODO.rst0000644000175000017500000000023412576064742015170 0ustar meirmeir00000000000000TODO ==== * Improve and organize the docs, add more examples * Upgrade algorithm to Unicode 7.0.0 * Fix failing explicit test (commented) * Arabic shaping python-bidi-0.4.2/bidi/0000755000175000017500000000000013507355325014574 5ustar meirmeir00000000000000python-bidi-0.4.2/bidi/__init__.py0000644000175000017500000000550613507355104016706 0ustar meirmeir00000000000000#!/usr/bin/env python # This file is part of python-bidi # # python-bidi is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # Copyright (C) 2008-2010 Yaacov Zamir , # Copyright (C) 2010-2015 Meir kriheli . """ Implementation of Unicode Bidirectional Algorithm http://www.unicode.org/unicode/reports/tr9/ """ VERSION = '0.4.2' def main(): """Will be used to create the console script""" import optparse import sys import codecs import locale import six from .algorithm import get_display parser = optparse.OptionParser() parser.add_option('-e', '--encoding', dest='encoding', default='utf-8', type='string', help='Text encoding (default: utf-8)') parser.add_option('-u', '--upper-is-rtl', dest='upper_is_rtl', default=False, action='store_true', help="Treat upper case chars as strong 'R' " 'for debugging (default: False).') parser.add_option('-d', '--debug', dest='debug', default=False, action='store_true', help="Output to stderr steps taken with the algorithm") parser.add_option('-b', '--base-dir', dest='base_dir', default=None, type='string', help="Override base direction [L|R]") options, rest = parser.parse_args() if options.base_dir and options.base_dir not in 'LR': parser.error('option -b can be L or R') # allow unicode in sys.stdout.write if six.PY2: sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout) if rest: lines = rest else: lines = sys.stdin for line in lines: display = get_display(line, options.encoding, options.upper_is_rtl, options.base_dir, options.debug) # adjust the encoding as unicode, to match the output encoding if not isinstance(display, six.text_type): display = display.decode(options.encoding) six.print_(display, end='') python-bidi-0.4.2/bidi/algorithm.py0000644000175000017500000005147713507355043017147 0ustar meirmeir00000000000000# This file is part of python-bidi # # python-bidi is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # Copyright (C) 2008-2010 Yaacov Zamir , # Copyright (C) 2010-2015 Meir kriheli . "bidirectional algorithm implementation" import sys import inspect from collections import deque from unicodedata import bidirectional, mirrored import six from .mirror import MIRRORED # Some definitions PARAGRAPH_LEVELS = {'L': 0, 'AL': 1, 'R': 1} EXPLICIT_LEVEL_LIMIT = 62 def _LEAST_GREATER_ODD(x): return (x + 1) | 1 def _LEAST_GREATER_EVEN(x): return (x + 2) & ~1 X2_X5_MAPPINGS = { 'RLE': (_LEAST_GREATER_ODD, 'N'), 'LRE': (_LEAST_GREATER_EVEN, 'N'), 'RLO': (_LEAST_GREATER_ODD, 'R'), 'LRO': (_LEAST_GREATER_EVEN, 'L'), } # Added 'B' so X6 won't execute in that case and X8 will run it's course X6_IGNORED = list(X2_X5_MAPPINGS.keys()) + ['BN', 'PDF', 'B'] X9_REMOVED = list(X2_X5_MAPPINGS.keys()) + ['BN', 'PDF'] def _embedding_direction(x): return ('L', 'R')[x % 2] _IS_UCS2 = sys.maxunicode == 65535 _SURROGATE_MIN, _SURROGATE_MAX = 55296, 56319 # D800, DBFF def debug_storage(storage, base_info=False, chars=True, runs=False): "Display debug information for the storage" import codecs import locale import sys if six.PY2: stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr) else: stderr = sys.stderr caller = inspect.stack()[1][3] stderr.write('in %s\n' % caller) if base_info: stderr.write(u' base level : %d\n' % storage['base_level']) stderr.write(u' base dir : %s\n' % storage['base_dir']) if runs: stderr.write(u' runs : %s\n' % list(storage['runs'])) if chars: output = u' Chars : ' for _ch in storage['chars']: if _ch != '\n': output += _ch['ch'] else: output += 'C' stderr.write(output + u'\n') output = u' Res. levels : %s\n' % u''.join( [six.text_type(_ch['level']) for _ch in storage['chars']]) stderr.write(output) _types = [_ch['type'].ljust(3) for _ch in storage['chars']] for i in range(3): if i: output = u' %s\n' else: output = u' Res. types : %s\n' stderr.write(output % u''.join([_t[i] for _t in _types])) def get_base_level(text, upper_is_rtl=False): """Get the paragraph base embedding level. Returns 0 for LTR, 1 for RTL. `text` a unicode object. Set `upper_is_rtl` to True to treat upper case chars as strong 'R' for debugging (default: False). """ base_level = None prev_surrogate = False # P2 for _ch in text: # surrogate in case of ucs2 if _IS_UCS2 and (_SURROGATE_MIN <= ord(_ch) <= _SURROGATE_MAX): prev_surrogate = _ch continue elif prev_surrogate: _ch = prev_surrogate + _ch prev_surrogate = False # treat upper as RTL ? if upper_is_rtl and _ch.isupper(): base_level = 1 break bidi_type = bidirectional(_ch) if bidi_type in ('AL', 'R'): base_level = 1 break elif bidi_type == 'L': base_level = 0 break # P3 if base_level is None: base_level = 0 return base_level def get_embedding_levels(text, storage, upper_is_rtl=False, debug=False): """Get the paragraph base embedding level and direction, set the storage to the array of chars""" prev_surrogate = False base_level = storage['base_level'] # preset the storage's chars for _ch in text: if _IS_UCS2 and (_SURROGATE_MIN <= ord(_ch) <= _SURROGATE_MAX): prev_surrogate = _ch continue elif prev_surrogate: _ch = prev_surrogate + _ch prev_surrogate = False if upper_is_rtl and _ch.isupper(): bidi_type = 'R' else: bidi_type = bidirectional(_ch) storage['chars'].append({ 'ch': _ch, 'level': base_level, 'type': bidi_type, 'orig': bidi_type }) if debug: debug_storage(storage, base_info=True) def explicit_embed_and_overrides(storage, debug=False): """Apply X1 to X9 rules of the unicode algorithm. See http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions """ overflow_counter = almost_overflow_counter = 0 directional_override = 'N' levels = deque() # X1 embedding_level = storage['base_level'] for _ch in storage['chars']: bidi_type = _ch['type'] level_func, override = X2_X5_MAPPINGS.get(bidi_type, (None, None)) if level_func: # So this is X2 to X5 # if we've past EXPLICIT_LEVEL_LIMIT, note it and do nothing if overflow_counter != 0: overflow_counter += 1 continue new_level = level_func(embedding_level) if new_level < EXPLICIT_LEVEL_LIMIT: levels.append((embedding_level, directional_override)) embedding_level, directional_override = new_level, override elif embedding_level == EXPLICIT_LEVEL_LIMIT - 2: # The new level is invalid, but a valid level can still be # achieved if this level is 60 and we encounter an RLE or # RLO further on. So record that we 'almost' overflowed. almost_overflow_counter += 1 else: overflow_counter += 1 else: # X6 if bidi_type not in X6_IGNORED: _ch['level'] = embedding_level if directional_override != 'N': _ch['type'] = directional_override # X7 elif bidi_type == 'PDF': if overflow_counter: overflow_counter -= 1 elif almost_overflow_counter and \ embedding_level != EXPLICIT_LEVEL_LIMIT - 1: almost_overflow_counter -= 1 elif levels: embedding_level, directional_override = levels.pop() # X8 elif bidi_type == 'B': levels.clear() overflow_counter = almost_overflow_counter = 0 embedding_level = _ch['level'] = storage['base_level'] directional_override = 'N' # Removes the explicit embeds and overrides of types # RLE, LRE, RLO, LRO, PDF, and BN. Adjusts extended chars # next and prev as well # Applies X9. See http://unicode.org/reports/tr9/#X9 storage['chars'] = [_ch for _ch in storage['chars'] if _ch['type'] not in X9_REMOVED] calc_level_runs(storage) if debug: debug_storage(storage, runs=True) def calc_level_runs(storage): """Split the storage to run of char types at the same level. Applies X10. See http://unicode.org/reports/tr9/#X10 """ # run level depends on the higher of the two levels on either side of # the boundary If the higher level is odd, the type is R; otherwise, # it is L storage['runs'].clear() chars = storage['chars'] # empty string ? if not chars: return def calc_level_run(b_l, b_r): return ['L', 'R'][max(b_l, b_r) % 2] first_char = chars[0] sor = calc_level_run(storage['base_level'], first_char['level']) eor = None run_start = run_length = 0 prev_level, prev_type = first_char['level'], first_char['type'] for _ch in chars: curr_level, curr_type = _ch['level'], _ch['type'] if curr_level == prev_level: run_length += 1 else: eor = calc_level_run(prev_level, curr_level) storage['runs'].append({'sor': sor, 'eor': eor, 'start': run_start, 'type': prev_type, 'length': run_length}) sor = eor run_start += run_length run_length = 1 prev_level, prev_type = curr_level, curr_type # for the last char/runlevel eor = calc_level_run(curr_level, storage['base_level']) storage['runs'].append({'sor': sor, 'eor': eor, 'start': run_start, 'type': curr_type, 'length': run_length}) def resolve_weak_types(storage, debug=False): """Resolve weak type rules W1 - W3. See: http://unicode.org/reports/tr9/#Resolving_Weak_Types """ for run in storage['runs']: prev_strong = prev_type = run['sor'] start, length = run['start'], run['length'] chars = storage['chars'][start:start+length] for _ch in chars: # W1. Examine each nonspacing mark (NSM) in the level run, and # change the type of the NSM to the type of the previous character. # If the NSM is at the start of the level run, it will get the type # of sor. bidi_type = _ch['type'] if bidi_type == 'NSM': _ch['type'] = bidi_type = prev_type # W2. Search backward from each instance of a European number until # the first strong type (R, L, AL, or sor) is found. If an AL is # found, change the type of the European number to Arabic number. if bidi_type == 'EN' and prev_strong == 'AL': _ch['type'] = 'AN' # update prev_strong if needed if bidi_type in ('R', 'L', 'AL'): prev_strong = bidi_type prev_type = _ch['type'] # W3. Change all ALs to R for _ch in chars: if _ch['type'] == 'AL': _ch['type'] = 'R' # W4. A single European separator between two European numbers changes # to a European number. A single common separator between two numbers of # the same type changes to that type. for idx in range(1, len(chars) - 1): bidi_type = chars[idx]['type'] prev_type = chars[idx-1]['type'] next_type = chars[idx+1]['type'] if bidi_type == 'ES' and (prev_type == next_type == 'EN'): chars[idx]['type'] = 'EN' if bidi_type == 'CS' and prev_type == next_type and \ prev_type in ('AN', 'EN'): chars[idx]['type'] = prev_type # W5. A sequence of European terminators adjacent to European numbers # changes to all European numbers. for idx in range(len(chars)): if chars[idx]['type'] == 'EN': for et_idx in range(idx-1, -1, -1): if chars[et_idx]['type'] == 'ET': chars[et_idx]['type'] = 'EN' else: break for et_idx in range(idx+1, len(chars)): if chars[et_idx]['type'] == 'ET': chars[et_idx]['type'] = 'EN' else: break # W6. Otherwise, separators and terminators change to Other Neutral. for _ch in chars: if _ch['type'] in ('ET', 'ES', 'CS'): _ch['type'] = 'ON' # W7. Search backward from each instance of a European number until the # first strong type (R, L, or sor) is found. If an L is found, then # change the type of the European number to L. prev_strong = run['sor'] for _ch in chars: if _ch['type'] == 'EN' and prev_strong == 'L': _ch['type'] = 'L' if _ch['type'] in ('L', 'R'): prev_strong = _ch['type'] if debug: debug_storage(storage, runs=True) def resolve_neutral_types(storage, debug): """Resolving neutral types. Implements N1 and N2 See: http://unicode.org/reports/tr9/#Resolving_Neutral_Types """ for run in storage['runs']: start, length = run['start'], run['length'] # use sor and eor chars = [{'type': run['sor']}] + storage['chars'][start:start+length] +\ [{'type': run['eor']}] total_chars = len(chars) seq_start = None for idx in range(total_chars): _ch = chars[idx] if _ch['type'] in ('B', 'S', 'WS', 'ON'): # N1. A sequence of neutrals takes the direction of the # surrounding strong text if the text on both sides has the same # direction. European and Arabic numbers act as if they were R # in terms of their influence on neutrals. Start-of-level-run # (sor) and end-of-level-run (eor) are used at level run # boundaries. if seq_start is None: seq_start = idx prev_bidi_type = chars[idx-1]['type'] else: if seq_start is not None: next_bidi_type = chars[idx]['type'] if prev_bidi_type in ('AN', 'EN'): prev_bidi_type = 'R' if next_bidi_type in ('AN', 'EN'): next_bidi_type = 'R' for seq_idx in range(seq_start, idx): if prev_bidi_type == next_bidi_type: chars[seq_idx]['type'] = prev_bidi_type else: # N2. Any remaining neutrals take the embedding # direction. The embedding direction for the given # neutral character is derived from its embedding # level: L if the character is set to an even level, # and R if the level is odd. chars[seq_idx]['type'] = \ _embedding_direction(chars[seq_idx]['level']) seq_start = None if debug: debug_storage(storage) def resolve_implicit_levels(storage, debug): """Resolving implicit levels (I1, I2) See: http://unicode.org/reports/tr9/#Resolving_Implicit_Levels """ for run in storage['runs']: start, length = run['start'], run['length'] chars = storage['chars'][start:start+length] for _ch in chars: # only those types are allowed at this stage assert _ch['type'] in ('L', 'R', 'EN', 'AN'),\ '%s not allowed here' % _ch['type'] if _embedding_direction(_ch['level']) == 'L': # I1. For all characters with an even (left-to-right) embedding # direction, those of type R go up one level and those of type # AN or EN go up two levels. if _ch['type'] == 'R': _ch['level'] += 1 elif _ch['type'] != 'L': _ch['level'] += 2 else: # I2. For all characters with an odd (right-to-left) embedding # direction, those of type L, EN or AN go up one level. if _ch['type'] != 'R': _ch['level'] += 1 if debug: debug_storage(storage, runs=True) def reverse_contiguous_sequence(chars, line_start, line_end, highest_level, lowest_odd_level): """L2. From the highest level found in the text to the lowest odd level on each line, including intermediate levels not actually present in the text, reverse any contiguous sequence of characters that are at that level or higher. """ for level in range(highest_level, lowest_odd_level-1, -1): _start = _end = None for run_idx in range(line_start, line_end+1): run_ch = chars[run_idx] if run_ch['level'] >= level: if _start is None: _start = _end = run_idx else: _end = run_idx else: if _end is not None: chars[_start:+_end+1] = \ reversed(chars[_start:+_end+1]) _start = _end = None # anything remaining ? if _start is not None: chars[_start:+_end+1] = \ reversed(chars[_start:+_end+1]) def reorder_resolved_levels(storage, debug): """L1 and L2 rules""" # Applies L1. should_reset = True chars = storage['chars'] for _ch in chars[::-1]: # L1. On each line, reset the embedding level of the following # characters to the paragraph embedding level: if _ch['orig'] in ('B', 'S'): # 1. Segment separators, # 2. Paragraph separators, _ch['level'] = storage['base_level'] should_reset = True elif should_reset and _ch['orig'] in ('BN', 'WS'): # 3. Any sequence of whitespace characters preceding a segment # separator or paragraph separator # 4. Any sequence of white space characters at the end of the # line. _ch['level'] = storage['base_level'] else: should_reset = False max_len = len(chars) # L2 should be per line # Calculates highest level and lowest odd level on the fly. line_start = line_end = 0 highest_level = 0 lowest_odd_level = EXPLICIT_LEVEL_LIMIT for idx in range(max_len): _ch = chars[idx] # calc the levels char_level = _ch['level'] if char_level > highest_level: highest_level = char_level if char_level % 2 and char_level < lowest_odd_level: lowest_odd_level = char_level if _ch['orig'] == 'B' or idx == max_len - 1: line_end = idx # omit line breaks if _ch['orig'] == 'B': line_end -= 1 reverse_contiguous_sequence(chars, line_start, line_end, highest_level, lowest_odd_level) # reset for next line run line_start = idx+1 highest_level = 0 lowest_odd_level = EXPLICIT_LEVEL_LIMIT if debug: debug_storage(storage) def apply_mirroring(storage, debug): """Applies L4: mirroring See: http://unicode.org/reports/tr9/#L4 """ # L4. A character is depicted by a mirrored glyph if and only if (a) the # resolved directionality of that character is R, and (b) the # Bidi_Mirrored property value of that character is true. for _ch in storage['chars']: unichar = _ch['ch'] if mirrored(unichar) and \ _embedding_direction(_ch['level']) == 'R': _ch['ch'] = MIRRORED.get(unichar, unichar) if debug: debug_storage(storage) def get_empty_storage(): """Return an empty storage skeleton, usable for testing""" return { 'base_level': None, 'base_dir': None, 'chars': [], 'runs': deque(), } def get_display(unicode_or_str, encoding='utf-8', upper_is_rtl=False, base_dir=None, debug=False): """Accepts unicode or string. In case it's a string, `encoding` is needed as it works on unicode ones (default:"utf-8"). Set `upper_is_rtl` to True to treat upper case chars as strong 'R' for debugging (default: False). Set `base_dir` to 'L' or 'R' to override the calculated base_level. Set `debug` to True to display (using sys.stderr) the steps taken with the algorithm. Returns the display layout, either as unicode or `encoding` encoded string. """ storage = get_empty_storage() # utf-8 ? we need unicode if isinstance(unicode_or_str, six.text_type): text = unicode_or_str decoded = False else: text = unicode_or_str.decode(encoding) decoded = True if base_dir is None: base_level = get_base_level(text, upper_is_rtl) else: base_level = PARAGRAPH_LEVELS[base_dir] storage['base_level'] = base_level storage['base_dir'] = ('L', 'R')[base_level] get_embedding_levels(text, storage, upper_is_rtl, debug) explicit_embed_and_overrides(storage, debug) resolve_weak_types(storage, debug) resolve_neutral_types(storage, debug) resolve_implicit_levels(storage, debug) reorder_resolved_levels(storage, debug) apply_mirroring(storage, debug) chars = storage['chars'] display = u''.join([_ch['ch'] for _ch in chars]) if decoded: return display.encode(encoding) else: return display python-bidi-0.4.2/bidi/mirror.py0000644000175000017500000005401612576051727016472 0ustar meirmeir00000000000000# This file is part of python-bidi # # python-bidi is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # Copyright (C) 2008-2010 Yaacov Zamir , # Copyright (C) 2010-2015 Meir kriheli . """Mirrored chars""" # Can't seem to get this data from python's unicode data, so this is imported # from http://www.unicode.org/Public/UNIDATA/BidiMirroring.txt MIRRORED = { u'\u0028': u'\u0029', # LEFT PARENTHESIS u'\u0029': u'\u0028', # RIGHT PARENTHESIS u'\u003C': u'\u003E', # LESS-THAN SIGN u'\u003E': u'\u003C', # GREATER-THAN SIGN u'\u005B': u'\u005D', # LEFT SQUARE BRACKET u'\u005D': u'\u005B', # RIGHT SQUARE BRACKET u'\u007B': u'\u007D', # LEFT CURLY BRACKET u'\u007D': u'\u007B', # RIGHT CURLY BRACKET u'\u00AB': u'\u00BB', # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u00BB': u'\u00AB', # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK u'\u0F3A': u'\u0F3B', # TIBETAN MARK GUG RTAGS GYON u'\u0F3B': u'\u0F3A', # TIBETAN MARK GUG RTAGS GYAS u'\u0F3C': u'\u0F3D', # TIBETAN MARK ANG KHANG GYON u'\u0F3D': u'\u0F3C', # TIBETAN MARK ANG KHANG GYAS u'\u169B': u'\u169C', # OGHAM FEATHER MARK u'\u169C': u'\u169B', # OGHAM REVERSED FEATHER MARK u'\u2039': u'\u203A', # SINGLE LEFT-POINTING ANGLE QUOTATION MARK u'\u203A': u'\u2039', # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK u'\u2045': u'\u2046', # LEFT SQUARE BRACKET WITH QUILL u'\u2046': u'\u2045', # RIGHT SQUARE BRACKET WITH QUILL u'\u207D': u'\u207E', # SUPERSCRIPT LEFT PARENTHESIS u'\u207E': u'\u207D', # SUPERSCRIPT RIGHT PARENTHESIS u'\u208D': u'\u208E', # SUBSCRIPT LEFT PARENTHESIS u'\u208E': u'\u208D', # SUBSCRIPT RIGHT PARENTHESIS u'\u2208': u'\u220B', # ELEMENT OF u'\u2209': u'\u220C', # NOT AN ELEMENT OF u'\u220A': u'\u220D', # SMALL ELEMENT OF u'\u220B': u'\u2208', # CONTAINS AS MEMBER u'\u220C': u'\u2209', # DOES NOT CONTAIN AS MEMBER u'\u220D': u'\u220A', # SMALL CONTAINS AS MEMBER u'\u2215': u'\u29F5', # DIVISION SLASH u'\u223C': u'\u223D', # TILDE OPERATOR u'\u223D': u'\u223C', # REVERSED TILDE u'\u2243': u'\u22CD', # ASYMPTOTICALLY EQUAL TO u'\u2252': u'\u2253', # APPROXIMATELY EQUAL TO OR THE IMAGE OF u'\u2253': u'\u2252', # IMAGE OF OR APPROXIMATELY EQUAL TO u'\u2254': u'\u2255', # COLON EQUALS u'\u2255': u'\u2254', # EQUALS COLON u'\u2264': u'\u2265', # LESS-THAN OR EQUAL TO u'\u2265': u'\u2264', # GREATER-THAN OR EQUAL TO u'\u2266': u'\u2267', # LESS-THAN OVER EQUAL TO u'\u2267': u'\u2266', # GREATER-THAN OVER EQUAL TO u'\u2268': u'\u2269', # [BEST FIT] LESS-THAN BUT NOT EQUAL TO u'\u2269': u'\u2268', # [BEST FIT] GREATER-THAN BUT NOT EQUAL TO u'\u226A': u'\u226B', # MUCH LESS-THAN u'\u226B': u'\u226A', # MUCH GREATER-THAN u'\u226E': u'\u226F', # [BEST FIT] NOT LESS-THAN u'\u226F': u'\u226E', # [BEST FIT] NOT GREATER-THAN u'\u2270': u'\u2271', # [BEST FIT] NEITHER LESS-THAN NOR EQUAL TO u'\u2271': u'\u2270', # [BEST FIT] NEITHER GREATER-THAN NOR EQUAL TO u'\u2272': u'\u2273', # [BEST FIT] LESS-THAN OR EQUIVALENT TO u'\u2273': u'\u2272', # [BEST FIT] GREATER-THAN OR EQUIVALENT TO u'\u2274': u'\u2275', # [BEST FIT] NEITHER LESS-THAN NOR EQUIVALENT TO u'\u2275': u'\u2274', # [BEST FIT] NEITHER GREATER-THAN NOR EQUIVALENT TO u'\u2276': u'\u2277', # LESS-THAN OR GREATER-THAN u'\u2277': u'\u2276', # GREATER-THAN OR LESS-THAN u'\u2278': u'\u2279', # [BEST FIT] NEITHER LESS-THAN NOR GREATER-THAN u'\u2279': u'\u2278', # [BEST FIT] NEITHER GREATER-THAN NOR LESS-THAN u'\u227A': u'\u227B', # PRECEDES u'\u227B': u'\u227A', # SUCCEEDS u'\u227C': u'\u227D', # PRECEDES OR EQUAL TO u'\u227D': u'\u227C', # SUCCEEDS OR EQUAL TO u'\u227E': u'\u227F', # [BEST FIT] PRECEDES OR EQUIVALENT TO u'\u227F': u'\u227E', # [BEST FIT] SUCCEEDS OR EQUIVALENT TO u'\u2280': u'\u2281', # [BEST FIT] DOES NOT PRECEDE u'\u2281': u'\u2280', # [BEST FIT] DOES NOT SUCCEED u'\u2282': u'\u2283', # SUBSET OF u'\u2283': u'\u2282', # SUPERSET OF u'\u2284': u'\u2285', # [BEST FIT] NOT A SUBSET OF u'\u2285': u'\u2284', # [BEST FIT] NOT A SUPERSET OF u'\u2286': u'\u2287', # SUBSET OF OR EQUAL TO u'\u2287': u'\u2286', # SUPERSET OF OR EQUAL TO u'\u2288': u'\u2289', # [BEST FIT] NEITHER A SUBSET OF NOR EQUAL TO u'\u2289': u'\u2288', # [BEST FIT] NEITHER A SUPERSET OF NOR EQUAL TO u'\u228A': u'\u228B', # [BEST FIT] SUBSET OF WITH NOT EQUAL TO u'\u228B': u'\u228A', # [BEST FIT] SUPERSET OF WITH NOT EQUAL TO u'\u228F': u'\u2290', # SQUARE IMAGE OF u'\u2290': u'\u228F', # SQUARE ORIGINAL OF u'\u2291': u'\u2292', # SQUARE IMAGE OF OR EQUAL TO u'\u2292': u'\u2291', # SQUARE ORIGINAL OF OR EQUAL TO u'\u2298': u'\u29B8', # CIRCLED DIVISION SLASH u'\u22A2': u'\u22A3', # RIGHT TACK u'\u22A3': u'\u22A2', # LEFT TACK u'\u22A6': u'\u2ADE', # ASSERTION u'\u22A8': u'\u2AE4', # TRUE u'\u22A9': u'\u2AE3', # FORCES u'\u22AB': u'\u2AE5', # DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE u'\u22B0': u'\u22B1', # PRECEDES UNDER RELATION u'\u22B1': u'\u22B0', # SUCCEEDS UNDER RELATION u'\u22B2': u'\u22B3', # NORMAL SUBGROUP OF u'\u22B3': u'\u22B2', # CONTAINS AS NORMAL SUBGROUP u'\u22B4': u'\u22B5', # NORMAL SUBGROUP OF OR EQUAL TO u'\u22B5': u'\u22B4', # CONTAINS AS NORMAL SUBGROUP OR EQUAL TO u'\u22B6': u'\u22B7', # ORIGINAL OF u'\u22B7': u'\u22B6', # IMAGE OF u'\u22C9': u'\u22CA', # LEFT NORMAL FACTOR SEMIDIRECT PRODUCT u'\u22CA': u'\u22C9', # RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT u'\u22CB': u'\u22CC', # LEFT SEMIDIRECT PRODUCT u'\u22CC': u'\u22CB', # RIGHT SEMIDIRECT PRODUCT u'\u22CD': u'\u2243', # REVERSED TILDE EQUALS u'\u22D0': u'\u22D1', # DOUBLE SUBSET u'\u22D1': u'\u22D0', # DOUBLE SUPERSET u'\u22D6': u'\u22D7', # LESS-THAN WITH DOT u'\u22D7': u'\u22D6', # GREATER-THAN WITH DOT u'\u22D8': u'\u22D9', # VERY MUCH LESS-THAN u'\u22D9': u'\u22D8', # VERY MUCH GREATER-THAN u'\u22DA': u'\u22DB', # LESS-THAN EQUAL TO OR GREATER-THAN u'\u22DB': u'\u22DA', # GREATER-THAN EQUAL TO OR LESS-THAN u'\u22DC': u'\u22DD', # EQUAL TO OR LESS-THAN u'\u22DD': u'\u22DC', # EQUAL TO OR GREATER-THAN u'\u22DE': u'\u22DF', # EQUAL TO OR PRECEDES u'\u22DF': u'\u22DE', # EQUAL TO OR SUCCEEDS u'\u22E0': u'\u22E1', # [BEST FIT] DOES NOT PRECEDE OR EQUAL u'\u22E1': u'\u22E0', # [BEST FIT] DOES NOT SUCCEED OR EQUAL u'\u22E2': u'\u22E3', # [BEST FIT] NOT SQUARE IMAGE OF OR EQUAL TO u'\u22E3': u'\u22E2', # [BEST FIT] NOT SQUARE ORIGINAL OF OR EQUAL TO u'\u22E4': u'\u22E5', # [BEST FIT] SQUARE IMAGE OF OR NOT EQUAL TO u'\u22E5': u'\u22E4', # [BEST FIT] SQUARE ORIGINAL OF OR NOT EQUAL TO u'\u22E6': u'\u22E7', # [BEST FIT] LESS-THAN BUT NOT EQUIVALENT TO u'\u22E7': u'\u22E6', # [BEST FIT] GREATER-THAN BUT NOT EQUIVALENT TO u'\u22E8': u'\u22E9', # [BEST FIT] PRECEDES BUT NOT EQUIVALENT TO u'\u22E9': u'\u22E8', # [BEST FIT] SUCCEEDS BUT NOT EQUIVALENT TO u'\u22EA': u'\u22EB', # [BEST FIT] NOT NORMAL SUBGROUP OF u'\u22EB': u'\u22EA', # [BEST FIT] DOES NOT CONTAIN AS NORMAL SUBGROUP u'\u22EC': u'\u22ED', # [BEST FIT] NOT NORMAL SUBGROUP OF OR EQUAL TO # [BEST FIT] DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL u'\u22ED': u'\u22EC', u'\u22F0': u'\u22F1', # UP RIGHT DIAGONAL ELLIPSIS u'\u22F1': u'\u22F0', # DOWN RIGHT DIAGONAL ELLIPSIS u'\u22F2': u'\u22FA', # ELEMENT OF WITH LONG HORIZONTAL STROKE u'\u22F3': u'\u22FB', # ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE u'\u22F4': u'\u22FC', # SMALL ELEMENT OF WITH VERTICAL BAR AT END OF HORIZONTAL STROKE u'\u22F6': u'\u22FD', # ELEMENT OF WITH OVERBAR u'\u22F7': u'\u22FE', # SMALL ELEMENT OF WITH OVERBAR u'\u22FA': u'\u22F2', # CONTAINS WITH LONG HORIZONTAL STROKE u'\u22FB': u'\u22F3', # CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE u'\u22FC': u'\u22F4', # SMALL CONTAINS WITH VERTICAL BAR AT END OF HORIZONTAL STROKE u'\u22FD': u'\u22F6', # CONTAINS WITH OVERBAR u'\u22FE': u'\u22F7', # SMALL CONTAINS WITH OVERBAR u'\u2308': u'\u2309', # LEFT CEILING u'\u2309': u'\u2308', # RIGHT CEILING u'\u230A': u'\u230B', # LEFT FLOOR u'\u230B': u'\u230A', # RIGHT FLOOR u'\u2329': u'\u232A', # LEFT-POINTING ANGLE BRACKET u'\u232A': u'\u2329', # RIGHT-POINTING ANGLE BRACKET u'\u2768': u'\u2769', # MEDIUM LEFT PARENTHESIS ORNAMENT u'\u2769': u'\u2768', # MEDIUM RIGHT PARENTHESIS ORNAMENT u'\u276A': u'\u276B', # MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT u'\u276B': u'\u276A', # MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT u'\u276C': u'\u276D', # MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT u'\u276D': u'\u276C', # MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT u'\u276E': u'\u276F', # HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT u'\u276F': u'\u276E', # HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT u'\u2770': u'\u2771', # HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT u'\u2771': u'\u2770', # HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT u'\u2772': u'\u2773', # LIGHT LEFT TORTOISE SHELL BRACKET u'\u2773': u'\u2772', # LIGHT RIGHT TORTOISE SHELL BRACKET u'\u2774': u'\u2775', # MEDIUM LEFT CURLY BRACKET ORNAMENT u'\u2775': u'\u2774', # MEDIUM RIGHT CURLY BRACKET ORNAMENT u'\u27C3': u'\u27C4', # OPEN SUBSET u'\u27C4': u'\u27C3', # OPEN SUPERSET u'\u27C5': u'\u27C6', # LEFT S-SHAPED BAG DELIMITER u'\u27C6': u'\u27C5', # RIGHT S-SHAPED BAG DELIMITER u'\u27C8': u'\u27C9', # REVERSE SOLIDUS PRECEDING SUBSET u'\u27C9': u'\u27C8', # SUPERSET PRECEDING SOLIDUS u'\u27D5': u'\u27D6', # LEFT OUTER JOIN u'\u27D6': u'\u27D5', # RIGHT OUTER JOIN u'\u27DD': u'\u27DE', # LONG RIGHT TACK u'\u27DE': u'\u27DD', # LONG LEFT TACK u'\u27E2': u'\u27E3', # WHITE CONCAVE-SIDED DIAMOND WITH LEFTWARDS TICK u'\u27E3': u'\u27E2', # WHITE CONCAVE-SIDED DIAMOND WITH RIGHTWARDS TICK u'\u27E4': u'\u27E5', # WHITE SQUARE WITH LEFTWARDS TICK u'\u27E5': u'\u27E4', # WHITE SQUARE WITH RIGHTWARDS TICK u'\u27E6': u'\u27E7', # MATHEMATICAL LEFT WHITE SQUARE BRACKET u'\u27E7': u'\u27E6', # MATHEMATICAL RIGHT WHITE SQUARE BRACKET u'\u27E8': u'\u27E9', # MATHEMATICAL LEFT ANGLE BRACKET u'\u27E9': u'\u27E8', # MATHEMATICAL RIGHT ANGLE BRACKET u'\u27EA': u'\u27EB', # MATHEMATICAL LEFT DOUBLE ANGLE BRACKET u'\u27EB': u'\u27EA', # MATHEMATICAL RIGHT DOUBLE ANGLE BRACKET u'\u27EC': u'\u27ED', # MATHEMATICAL LEFT WHITE TORTOISE SHELL BRACKET u'\u27ED': u'\u27EC', # MATHEMATICAL RIGHT WHITE TORTOISE SHELL BRACKET u'\u27EE': u'\u27EF', # MATHEMATICAL LEFT FLATTENED PARENTHESIS u'\u27EF': u'\u27EE', # MATHEMATICAL RIGHT FLATTENED PARENTHESIS u'\u2983': u'\u2984', # LEFT WHITE CURLY BRACKET u'\u2984': u'\u2983', # RIGHT WHITE CURLY BRACKET u'\u2985': u'\u2986', # LEFT WHITE PARENTHESIS u'\u2986': u'\u2985', # RIGHT WHITE PARENTHESIS u'\u2987': u'\u2988', # Z NOTATION LEFT IMAGE BRACKET u'\u2988': u'\u2987', # Z NOTATION RIGHT IMAGE BRACKET u'\u2989': u'\u298A', # Z NOTATION LEFT BINDING BRACKET u'\u298A': u'\u2989', # Z NOTATION RIGHT BINDING BRACKET u'\u298B': u'\u298C', # LEFT SQUARE BRACKET WITH UNDERBAR u'\u298C': u'\u298B', # RIGHT SQUARE BRACKET WITH UNDERBAR u'\u298D': u'\u2990', # LEFT SQUARE BRACKET WITH TICK IN TOP CORNER u'\u298E': u'\u298F', # RIGHT SQUARE BRACKET WITH TICK IN BOTTOM CORNER u'\u298F': u'\u298E', # LEFT SQUARE BRACKET WITH TICK IN BOTTOM CORNER u'\u2990': u'\u298D', # RIGHT SQUARE BRACKET WITH TICK IN TOP CORNER u'\u2991': u'\u2992', # LEFT ANGLE BRACKET WITH DOT u'\u2992': u'\u2991', # RIGHT ANGLE BRACKET WITH DOT u'\u2993': u'\u2994', # LEFT ARC LESS-THAN BRACKET u'\u2994': u'\u2993', # RIGHT ARC GREATER-THAN BRACKET u'\u2995': u'\u2996', # DOUBLE LEFT ARC GREATER-THAN BRACKET u'\u2996': u'\u2995', # DOUBLE RIGHT ARC LESS-THAN BRACKET u'\u2997': u'\u2998', # LEFT BLACK TORTOISE SHELL BRACKET u'\u2998': u'\u2997', # RIGHT BLACK TORTOISE SHELL BRACKET u'\u29B8': u'\u2298', # CIRCLED REVERSE SOLIDUS u'\u29C0': u'\u29C1', # CIRCLED LESS-THAN u'\u29C1': u'\u29C0', # CIRCLED GREATER-THAN u'\u29C4': u'\u29C5', # SQUARED RISING DIAGONAL SLASH u'\u29C5': u'\u29C4', # SQUARED FALLING DIAGONAL SLASH u'\u29CF': u'\u29D0', # LEFT TRIANGLE BESIDE VERTICAL BAR u'\u29D0': u'\u29CF', # VERTICAL BAR BESIDE RIGHT TRIANGLE u'\u29D1': u'\u29D2', # BOWTIE WITH LEFT HALF BLACK u'\u29D2': u'\u29D1', # BOWTIE WITH RIGHT HALF BLACK u'\u29D4': u'\u29D5', # TIMES WITH LEFT HALF BLACK u'\u29D5': u'\u29D4', # TIMES WITH RIGHT HALF BLACK u'\u29D8': u'\u29D9', # LEFT WIGGLY FENCE u'\u29D9': u'\u29D8', # RIGHT WIGGLY FENCE u'\u29DA': u'\u29DB', # LEFT DOUBLE WIGGLY FENCE u'\u29DB': u'\u29DA', # RIGHT DOUBLE WIGGLY FENCE u'\u29F5': u'\u2215', # REVERSE SOLIDUS OPERATOR u'\u29F8': u'\u29F9', # BIG SOLIDUS u'\u29F9': u'\u29F8', # BIG REVERSE SOLIDUS u'\u29FC': u'\u29FD', # LEFT-POINTING CURVED ANGLE BRACKET u'\u29FD': u'\u29FC', # RIGHT-POINTING CURVED ANGLE BRACKET u'\u2A2B': u'\u2A2C', # MINUS SIGN WITH FALLING DOTS u'\u2A2C': u'\u2A2B', # MINUS SIGN WITH RISING DOTS u'\u2A2D': u'\u2A2E', # PLUS SIGN IN LEFT HALF CIRCLE u'\u2A2E': u'\u2A2D', # PLUS SIGN IN RIGHT HALF CIRCLE u'\u2A34': u'\u2A35', # MULTIPLICATION SIGN IN LEFT HALF CIRCLE u'\u2A35': u'\u2A34', # MULTIPLICATION SIGN IN RIGHT HALF CIRCLE u'\u2A3C': u'\u2A3D', # INTERIOR PRODUCT u'\u2A3D': u'\u2A3C', # RIGHTHAND INTERIOR PRODUCT u'\u2A64': u'\u2A65', # Z NOTATION DOMAIN ANTIRESTRICTION u'\u2A65': u'\u2A64', # Z NOTATION RANGE ANTIRESTRICTION u'\u2A79': u'\u2A7A', # LESS-THAN WITH CIRCLE INSIDE u'\u2A7A': u'\u2A79', # GREATER-THAN WITH CIRCLE INSIDE u'\u2A7D': u'\u2A7E', # LESS-THAN OR SLANTED EQUAL TO u'\u2A7E': u'\u2A7D', # GREATER-THAN OR SLANTED EQUAL TO u'\u2A7F': u'\u2A80', # LESS-THAN OR SLANTED EQUAL TO WITH DOT INSIDE u'\u2A80': u'\u2A7F', # GREATER-THAN OR SLANTED EQUAL TO WITH DOT INSIDE u'\u2A81': u'\u2A82', # LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE u'\u2A82': u'\u2A81', # GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE u'\u2A83': u'\u2A84', # LESS-THAN OR SLANTED EQUAL TO WITH DOT ABOVE RIGHT u'\u2A84': u'\u2A83', # GREATER-THAN OR SLANTED EQUAL TO WITH DOT ABOVE LEFT u'\u2A8B': u'\u2A8C', # LESS-THAN ABOVE DOUBLE-LINE EQUAL ABOVE GREATER-THAN u'\u2A8C': u'\u2A8B', # GREATER-THAN ABOVE DOUBLE-LINE EQUAL ABOVE LESS-THAN u'\u2A91': u'\u2A92', # LESS-THAN ABOVE GREATER-THAN ABOVE DOUBLE-LINE EQUAL u'\u2A92': u'\u2A91', # GREATER-THAN ABOVE LESS-THAN ABOVE DOUBLE-LINE EQUAL # LESS-THAN ABOVE SLANTED EQUAL ABOVE GREATER-THAN ABOVE SLANTED EQUAL u'\u2A93': u'\u2A94', # GREATER-THAN ABOVE SLANTED EQUAL ABOVE LESS-THAN ABOVE SLANTED EQUAL u'\u2A94': u'\u2A93', u'\u2A95': u'\u2A96', # SLANTED EQUAL TO OR LESS-THAN u'\u2A96': u'\u2A95', # SLANTED EQUAL TO OR GREATER-THAN u'\u2A97': u'\u2A98', # SLANTED EQUAL TO OR LESS-THAN WITH DOT INSIDE u'\u2A98': u'\u2A97', # SLANTED EQUAL TO OR GREATER-THAN WITH DOT INSIDE u'\u2A99': u'\u2A9A', # DOUBLE-LINE EQUAL TO OR LESS-THAN u'\u2A9A': u'\u2A99', # DOUBLE-LINE EQUAL TO OR GREATER-THAN u'\u2A9B': u'\u2A9C', # DOUBLE-LINE SLANTED EQUAL TO OR LESS-THAN u'\u2A9C': u'\u2A9B', # DOUBLE-LINE SLANTED EQUAL TO OR GREATER-THAN u'\u2AA1': u'\u2AA2', # DOUBLE NESTED LESS-THAN u'\u2AA2': u'\u2AA1', # DOUBLE NESTED GREATER-THAN u'\u2AA6': u'\u2AA7', # LESS-THAN CLOSED BY CURVE u'\u2AA7': u'\u2AA6', # GREATER-THAN CLOSED BY CURVE u'\u2AA8': u'\u2AA9', # LESS-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL u'\u2AA9': u'\u2AA8', # GREATER-THAN CLOSED BY CURVE ABOVE SLANTED EQUAL u'\u2AAA': u'\u2AAB', # SMALLER THAN u'\u2AAB': u'\u2AAA', # LARGER THAN u'\u2AAC': u'\u2AAD', # SMALLER THAN OR EQUAL TO u'\u2AAD': u'\u2AAC', # LARGER THAN OR EQUAL TO u'\u2AAF': u'\u2AB0', # PRECEDES ABOVE SINGLE-LINE EQUALS SIGN u'\u2AB0': u'\u2AAF', # SUCCEEDS ABOVE SINGLE-LINE EQUALS SIGN u'\u2AB3': u'\u2AB4', # PRECEDES ABOVE EQUALS SIGN u'\u2AB4': u'\u2AB3', # SUCCEEDS ABOVE EQUALS SIGN u'\u2ABB': u'\u2ABC', # DOUBLE PRECEDES u'\u2ABC': u'\u2ABB', # DOUBLE SUCCEEDS u'\u2ABD': u'\u2ABE', # SUBSET WITH DOT u'\u2ABE': u'\u2ABD', # SUPERSET WITH DOT u'\u2ABF': u'\u2AC0', # SUBSET WITH PLUS SIGN BELOW u'\u2AC0': u'\u2ABF', # SUPERSET WITH PLUS SIGN BELOW u'\u2AC1': u'\u2AC2', # SUBSET WITH MULTIPLICATION SIGN BELOW u'\u2AC2': u'\u2AC1', # SUPERSET WITH MULTIPLICATION SIGN BELOW u'\u2AC3': u'\u2AC4', # SUBSET OF OR EQUAL TO WITH DOT ABOVE u'\u2AC4': u'\u2AC3', # SUPERSET OF OR EQUAL TO WITH DOT ABOVE u'\u2AC5': u'\u2AC6', # SUBSET OF ABOVE EQUALS SIGN u'\u2AC6': u'\u2AC5', # SUPERSET OF ABOVE EQUALS SIGN u'\u2ACD': u'\u2ACE', # SQUARE LEFT OPEN BOX OPERATOR u'\u2ACE': u'\u2ACD', # SQUARE RIGHT OPEN BOX OPERATOR u'\u2ACF': u'\u2AD0', # CLOSED SUBSET u'\u2AD0': u'\u2ACF', # CLOSED SUPERSET u'\u2AD1': u'\u2AD2', # CLOSED SUBSET OR EQUAL TO u'\u2AD2': u'\u2AD1', # CLOSED SUPERSET OR EQUAL TO u'\u2AD3': u'\u2AD4', # SUBSET ABOVE SUPERSET u'\u2AD4': u'\u2AD3', # SUPERSET ABOVE SUBSET u'\u2AD5': u'\u2AD6', # SUBSET ABOVE SUBSET u'\u2AD6': u'\u2AD5', # SUPERSET ABOVE SUPERSET u'\u2ADE': u'\u22A6', # SHORT LEFT TACK u'\u2AE3': u'\u22A9', # DOUBLE VERTICAL BAR LEFT TURNSTILE u'\u2AE4': u'\u22A8', # VERTICAL BAR DOUBLE LEFT TURNSTILE u'\u2AE5': u'\u22AB', # DOUBLE VERTICAL BAR DOUBLE LEFT TURNSTILE u'\u2AEC': u'\u2AED', # DOUBLE STROKE NOT SIGN u'\u2AED': u'\u2AEC', # REVERSED DOUBLE STROKE NOT SIGN u'\u2AF7': u'\u2AF8', # TRIPLE NESTED LESS-THAN u'\u2AF8': u'\u2AF7', # TRIPLE NESTED GREATER-THAN u'\u2AF9': u'\u2AFA', # DOUBLE-LINE SLANTED LESS-THAN OR EQUAL TO u'\u2AFA': u'\u2AF9', # DOUBLE-LINE SLANTED GREATER-THAN OR EQUAL TO u'\u2E02': u'\u2E03', # LEFT SUBSTITUTION BRACKET u'\u2E03': u'\u2E02', # RIGHT SUBSTITUTION BRACKET u'\u2E04': u'\u2E05', # LEFT DOTTED SUBSTITUTION BRACKET u'\u2E05': u'\u2E04', # RIGHT DOTTED SUBSTITUTION BRACKET u'\u2E09': u'\u2E0A', # LEFT TRANSPOSITION BRACKET u'\u2E0A': u'\u2E09', # RIGHT TRANSPOSITION BRACKET u'\u2E0C': u'\u2E0D', # LEFT RAISED OMISSION BRACKET u'\u2E0D': u'\u2E0C', # RIGHT RAISED OMISSION BRACKET u'\u2E1C': u'\u2E1D', # LEFT LOW PARAPHRASE BRACKET u'\u2E1D': u'\u2E1C', # RIGHT LOW PARAPHRASE BRACKET u'\u2E20': u'\u2E21', # LEFT VERTICAL BAR WITH QUILL u'\u2E21': u'\u2E20', # RIGHT VERTICAL BAR WITH QUILL u'\u2E22': u'\u2E23', # TOP LEFT HALF BRACKET u'\u2E23': u'\u2E22', # TOP RIGHT HALF BRACKET u'\u2E24': u'\u2E25', # BOTTOM LEFT HALF BRACKET u'\u2E25': u'\u2E24', # BOTTOM RIGHT HALF BRACKET u'\u2E26': u'\u2E27', # LEFT SIDEWAYS U BRACKET u'\u2E27': u'\u2E26', # RIGHT SIDEWAYS U BRACKET u'\u2E28': u'\u2E29', # LEFT DOUBLE PARENTHESIS u'\u2E29': u'\u2E28', # RIGHT DOUBLE PARENTHESIS u'\u3008': u'\u3009', # LEFT ANGLE BRACKET u'\u3009': u'\u3008', # RIGHT ANGLE BRACKET u'\u300A': u'\u300B', # LEFT DOUBLE ANGLE BRACKET u'\u300B': u'\u300A', # RIGHT DOUBLE ANGLE BRACKET u'\u300C': u'\u300D', # [BEST FIT] LEFT CORNER BRACKET u'\u300D': u'\u300C', # [BEST FIT] RIGHT CORNER BRACKET u'\u300E': u'\u300F', # [BEST FIT] LEFT WHITE CORNER BRACKET u'\u300F': u'\u300E', # [BEST FIT] RIGHT WHITE CORNER BRACKET u'\u3010': u'\u3011', # LEFT BLACK LENTICULAR BRACKET u'\u3011': u'\u3010', # RIGHT BLACK LENTICULAR BRACKET u'\u3014': u'\u3015', # LEFT TORTOISE SHELL BRACKET u'\u3015': u'\u3014', # RIGHT TORTOISE SHELL BRACKET u'\u3016': u'\u3017', # LEFT WHITE LENTICULAR BRACKET u'\u3017': u'\u3016', # RIGHT WHITE LENTICULAR BRACKET u'\u3018': u'\u3019', # LEFT WHITE TORTOISE SHELL BRACKET u'\u3019': u'\u3018', # RIGHT WHITE TORTOISE SHELL BRACKET u'\u301A': u'\u301B', # LEFT WHITE SQUARE BRACKET u'\u301B': u'\u301A', # RIGHT WHITE SQUARE BRACKET u'\uFE59': u'\uFE5A', # SMALL LEFT PARENTHESIS u'\uFE5A': u'\uFE59', # SMALL RIGHT PARENTHESIS u'\uFE5B': u'\uFE5C', # SMALL LEFT CURLY BRACKET u'\uFE5C': u'\uFE5B', # SMALL RIGHT CURLY BRACKET u'\uFE5D': u'\uFE5E', # SMALL LEFT TORTOISE SHELL BRACKET u'\uFE5E': u'\uFE5D', # SMALL RIGHT TORTOISE SHELL BRACKET u'\uFE64': u'\uFE65', # SMALL LESS-THAN SIGN u'\uFE65': u'\uFE64', # SMALL GREATER-THAN SIGN u'\uFF08': u'\uFF09', # FULLWIDTH LEFT PARENTHESIS u'\uFF09': u'\uFF08', # FULLWIDTH RIGHT PARENTHESIS u'\uFF1C': u'\uFF1E', # FULLWIDTH LESS-THAN SIGN u'\uFF1E': u'\uFF1C', # FULLWIDTH GREATER-THAN SIGN u'\uFF3B': u'\uFF3D', # FULLWIDTH LEFT SQUARE BRACKET u'\uFF3D': u'\uFF3B', # FULLWIDTH RIGHT SQUARE BRACKET u'\uFF5B': u'\uFF5D', # FULLWIDTH LEFT CURLY BRACKET u'\uFF5D': u'\uFF5B', # FULLWIDTH RIGHT CURLY BRACKET u'\uFF5F': u'\uFF60', # FULLWIDTH LEFT WHITE PARENTHESIS u'\uFF60': u'\uFF5F', # FULLWIDTH RIGHT WHITE PARENTHESIS u'\uFF62': u'\uFF63', # [BEST FIT] HALFWIDTH LEFT CORNER BRACKET u'\uFF63': u'\uFF62', # [BEST FIT] HALFWIDTH RIGHT CORNER BRACKET } python-bidi-0.4.2/docs/0000755000175000017500000000000013507355325014615 5ustar meirmeir00000000000000python-bidi-0.4.2/docs/Makefile0000644000175000017500000001517112371451424016255 0ustar meirmeir00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/complexity.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/complexity.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/complexity" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/complexity" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."python-bidi-0.4.2/docs/authors.rst0000644000175000017500000000003312371451424017023 0ustar meirmeir00000000000000.. include:: ../AUTHORS.rstpython-bidi-0.4.2/docs/conf.py0000755000175000017500000002033112576047006016115 0ustar meirmeir00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- # # complexity documentation build configuration file, created by # sphinx-quickstart on Tue Jul 9 22:26:36 2013. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory is # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # Get the project root dir, which is the parent dir of this cwd = os.getcwd() project_root = os.path.dirname(cwd) # Insert the project root dir as the first element in the PYTHONPATH. # This lets us ensure that the source package is imported, and that its # version is used. sys.path.insert(0, project_root) import bidi # -- General configuration --------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'Python BiDi' copyright = u'2014, Meir Kriheli' # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout # the built documents. # # The short X.Y version. version = bidi.VERSION # The full version, including alpha/beta/rc tags. release = bidi.VERSION # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to # some non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built # documents. #keep_warnings = False # -- Options for HTML output ------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a # theme further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as # html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the # top of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon # of the docs. This file should be a Windows icon file (.ico) being # 16x16 or 32x32 pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) # here, relative to this directory. They are copied after the builtin # static files, so a file named "default.css" will overwrite the builtin # "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names # to template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. # Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. # Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages # will contain a tag referring to it. The value of this option # must be the base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'python-bididoc' # -- Options for LaTeX output ------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ('index', 'python-bidi.tex', u'Python BiDi Documentation', u'Meir Kriheli', 'manual'), ] # The name of an image file (relative to this directory) to place at # the top of the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings # are parts, not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output ------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'python-bidi', u'Python BiDi Documentation', [u'Meir Kriheli'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ---------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'python-bidi', u'Python BiDi Documentation', u'Meir Kriheli', 'python-bidi', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False python-bidi-0.4.2/docs/contributing.rst0000644000175000017500000000004012371451424020043 0ustar meirmeir00000000000000.. include:: ../CONTRIBUTING.rstpython-bidi-0.4.2/docs/history.rst0000644000175000017500000000003612576062714017051 0ustar meirmeir00000000000000.. include:: ../CHANGELOG.rst python-bidi-0.4.2/docs/index.rst0000644000175000017500000000117012576064141016453 0ustar meirmeir00000000000000.. complexity documentation master file, created by sphinx-quickstart on Tue Jul 9 22:26:36 2013. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to Python BiDi's documentation! ======================================= `Bi-directional`_ (BiDi) layout implementation in pure python. .. _Bi-directional: http://en.wikipedia.org/wiki/Bi-directional_text Contents: .. toctree:: :maxdepth: 2 installation usage contributing authors history Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` python-bidi-0.4.2/docs/installation.rst0000644000175000017500000000031212371451424020037 0ustar meirmeir00000000000000============ Installation ============ At the command line:: $ easy_install python-bidi Or, if you have virtualenvwrapper installed:: $ mkvirtualenv python-bidi $ pip install python-bidipython-bidi-0.4.2/docs/make.bat0000644000175000017500000001450212371451424016217 0ustar meirmeir00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\complexity.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\complexity.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :endpython-bidi-0.4.2/docs/usage.rst0000644000175000017500000000031612576063552016456 0ustar meirmeir00000000000000======== Usage ======== To use Python BiDi in a project:: .. code-block:: python from bidi import algorithm some_string = 'your string goes here' result = algorithm.get_display(some_string) python-bidi-0.4.2/python_bidi.egg-info/0000755000175000017500000000000013507355325017667 5ustar meirmeir00000000000000python-bidi-0.4.2/python_bidi.egg-info/PKG-INFO0000644000175000017500000001351613507355325020772 0ustar meirmeir00000000000000Metadata-Version: 1.1 Name: python-bidi Version: 0.4.2 Summary: Pure python implementation of the BiDi layout algorithm Home-page: https://github.com/MeirKriheli/python-bidi Author: Meir Kriheli Author-email: mkriheli@gmail.com License: http://www.gnu.org/licenses/lgpl.html Description: =============================== Python BiDi =============================== .. image:: https://badge.fury.io/py/python-bidi.png :target: http://badge.fury.io/py/python-bidi .. image:: https://travis-ci.org/MeirKriheli/python-bidi.png?branch=master :target: https://travis-ci.org/MeirKriheli/python-bidi `Bi-directional`_ (BiDi) layout implementation in pure python `Package documentation`_ .. _Bi-directional: http://en.wikipedia.org/wiki/Bi-directional_text .. _Package documentation: http://python-bidi.readthedocs.org/en/latest/ API ---- The algorithm starts with a single entry point `bidi.algorithm.get_display`. **Required arguments:** * ``unicode_or_str``: The original unicode or string (i.e.: storage). If it's a string use the optional argument ``encoding`` to specify it's encoding. **Optional arguments:** * ``encoding``: If unicode_or_str is a string, specifies the encoding. The algorithm uses unicodedata_ which requires unicode. This encoding will be used to decode and encode back to string before returning (default: "utf-8"). * ``upper_is_rtl``: True to treat upper case chars as strong 'R' for debugging (default: False). * ``base_dir``: 'L' or 'R', override the calculated base_level. * ``debug``: True to display (using `sys.stderr`_) the steps taken with the algorithm (default: False). Returns the display layout, either as unicode or ``encoding`` encoded string (depending on the type of ``unicode_or_str'``). .. _unicodedata: http://docs.python.org/library/unicodedata.html .. _sys.stderr: http://docs.python.org/library/sys.html?highlight=sys.stderr#sys.stderr Example:: >>> from bidi.algorithm import get_display >>> get_display(u'car is THE CAR in arabic', upper_is_rtl=True) u'car is RAC EHT in arabic' CLI ---- ``pybidi`` is a command line utility (calling ``bidi.main``) for running the bidi algorithm. the script can get a string as a parameter or read text from `stdin`. Usage:: $ pybidi -h Usage: pybidi [options] Options: -h, --help show this help message and exit -e ENCODING, --encoding=ENCODING Text encoding (default: utf-8) -u, --upper-is-rtl treat upper case chars as strong 'R' for debugging (default: False). -d, --debug Output to stderr steps taken with the algorithm -b BASE_DIR, --base-dir=BASE_DIR Override base direction [L|R] Examples:: $ pybidi -u 'car is THE CAR in arabic' car is RAC EHT in arabic $ cat ~/Documents/example.txt | pybidi ... Installation ------------- See ``docs/INSTALL.rst`` Running tests -------------- To run the tests:: python setup.py test Some explicit tests are failing right now (see TODO) 0.4.2 ----- * Type Fixes, thanks jwilk History ========= 0.4.1 ----- * Merged Fix for mixed RTL and numbers, Thanks Just van Rossum 0.4.0 ----- * Move to cookiecutter template * Python 3 support (py2.6, 2.7, 3.3, 3.4 and pypy) * Better docs * Travis integration * Tox tests * PEP8 cleanup 0.3.4 ------ * Remove extra newline in console script output 0.3.3 ------ * Implement overriding base paragraph direction * Allow overriding base direction in pybidi console script * Fix returning display in same encoding 0.3.2 ------ * Test for surrogate pairs * Fix indentation in documentations * Specify license in setup.py 0.3.1 ----- * Added missing description * docs/INSTALL.rst 0.3 --- * Apply bidi mirroring * Move to back function based implementation 0.2 --- * Move the algorithm to a class based implementation 0.1 --- * Initial release Keywords: bidi unicode layout Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL) Classifier: Topic :: Text Processing Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: PyPy python-bidi-0.4.2/python_bidi.egg-info/SOURCES.txt0000644000175000017500000000112613507355325021553 0ustar meirmeir00000000000000AUTHORS.rst CHANGELOG.rst CONTRIBUTING.rst COPYING COPYING.LESSER MANIFEST.in README.rst TODO.rst setup.cfg setup.py bidi/__init__.py bidi/algorithm.py bidi/mirror.py docs/Makefile docs/authors.rst docs/conf.py docs/contributing.rst docs/history.rst docs/index.rst docs/installation.rst docs/make.bat docs/usage.rst python_bidi.egg-info/PKG-INFO python_bidi.egg-info/SOURCES.txt python_bidi.egg-info/dependency_links.txt python_bidi.egg-info/entry_points.txt python_bidi.egg-info/not-zip-safe python_bidi.egg-info/requires.txt python_bidi.egg-info/top_level.txt tests/__init__.py tests/test_bidi.pypython-bidi-0.4.2/python_bidi.egg-info/dependency_links.txt0000644000175000017500000000000113507355325023735 0ustar meirmeir00000000000000 python-bidi-0.4.2/python_bidi.egg-info/entry_points.txt0000644000175000017500000000004613507355325023165 0ustar meirmeir00000000000000[console_scripts] pybidi = bidi:main python-bidi-0.4.2/python_bidi.egg-info/not-zip-safe0000644000175000017500000000000112576066175022124 0ustar meirmeir00000000000000 python-bidi-0.4.2/python_bidi.egg-info/requires.txt0000644000175000017500000000000413507355325022261 0ustar meirmeir00000000000000six python-bidi-0.4.2/python_bidi.egg-info/top_level.txt0000644000175000017500000000000513507355325022414 0ustar meirmeir00000000000000bidi python-bidi-0.4.2/setup.cfg0000644000175000017500000000007513507355325015510 0ustar meirmeir00000000000000[wheel] universal = 1 [egg_info] tag_build = tag_date = 0 python-bidi-0.4.2/setup.py0000644000175000017500000000322413507355074015401 0ustar meirmeir00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- try: from setuptools import setup except ImportError: from distutils.core import setup readme = open('README.rst').read() history = open('CHANGELOG.rst').read().replace('.. :changelog:', '') requirements = [ 'six' ] test_requirements = [ # TODO: put package test requirements here ] setup( name="python-bidi", version="0.4.2", url='https://github.com/MeirKriheli/python-bidi', description='Pure python implementation of the BiDi layout algorithm', long_description=readme + '\n\n' + history, author='Meir Kriheli', author_email='mkriheli@gmail.com', packages=[ 'bidi', ], package_dir={ 'bidi': 'bidi' }, include_package_data=True, install_requires=requirements, entry_points={ 'console_scripts': 'pybidi = bidi:main' }, license='http://www.gnu.org/licenses/lgpl.html', zip_safe=False, keywords='bidi unicode layout', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', 'Topic :: Text Processing', "Programming Language :: Python :: 2", 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: Implementation :: PyPy', ], test_suite='tests', tests_require=test_requirements, ) python-bidi-0.4.2/tests/0000755000175000017500000000000013507355325015027 5ustar meirmeir00000000000000python-bidi-0.4.2/tests/__init__.py0000644000175000017500000000000012371455535017130 0ustar meirmeir00000000000000python-bidi-0.4.2/tests/test_bidi.py0000644000175000017500000001343113507355043017346 0ustar meirmeir00000000000000# This file is part of python-bidi # # python-bidi is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . # Copyright (C) 2008-2010 Yaacov Zamir , # Meir kriheli """BiDi algorithm unit tests""" import unittest import six from bidi.algorithm import get_display, get_empty_storage, get_embedding_levels class TestBidiAlgorithm(unittest.TestCase): "Tests the bidi algorithm (based on GNU fribidi ones)" def test_surrogate(self): """Test for storage and base levels in case of surrogate pairs""" storage = get_empty_storage() text = u'HELLO \U0001d7f612' get_embedding_levels(text, storage, upper_is_rtl=True) # should return 9, not 10 even in --with-unicode=ucs2 self.assertEqual(len(storage['chars']), 9) # Is the expected result ? should be EN _ch = storage['chars'][6] self.assertEqual(_ch['ch'], u'\U0001d7f6') self.assertEqual(_ch['type'], 'EN') display = get_display(text, upper_is_rtl=True) self.assertEqual(display, u'\U0001d7f612 OLLEH') def test_implict_with_upper_is_rtl(self): '''Implicit tests''' tests = ( (u'car is THE CAR in arabic', u'car is RAC EHT in arabic'), (u'CAR IS the car IN ENGLISH', u'HSILGNE NI the car SI RAC'), (u'he said "IT IS 123, 456, OK"', u'he said "KO ,456 ,123 SI TI"'), (u'he said "IT IS (123, 456), OK"', u'he said "KO ,(456 ,123) SI TI"'), (u'he said "IT IS 123,456, OK"', u'he said "KO ,123,456 SI TI"'), (u'he said "IT IS (123,456), OK"', u'he said "KO ,(123,456) SI TI"'), (u'HE SAID "it is 123, 456, ok"', u'"it is 123, 456, ok" DIAS EH'), (u'shalom', u'<123H/>shalom<123H>'), (u'SAALAM', u'MALAAS'), (u'HE SAID "it is a car!" AND RAN', u'NAR DNA "!it is a car" DIAS EH'), (u'HE SAID "it is a car!x" AND RAN', u'NAR DNA "it is a car!x" DIAS EH'), (u'SOLVE 1*5 1-5 1/5 1+5', u'1+5 1/5 1-5 5*1 EVLOS'), (u'THE RANGE IS 2.5..5', u'5..2.5 SI EGNAR EHT'), (u'-2 CELSIUS IS COLD', u'DLOC SI SUISLEC 2-'), ) for storage, display in tests: self.assertEqual(get_display(storage, upper_is_rtl=True), display) def test_override_base_dir(self): """Tests overriding the base paragraph direction""" # normally the display should be :MOLAHS be since we're overriding the # base dir the colon should be at the end of the display storage = u'SHALOM:' display = u'MOLAHS:' self.assertEqual(get_display(storage, upper_is_rtl=True, base_dir='L'), display) def test_output_encoding(self): """Make sure the display is in the same encoding as the incoming text""" storage = six.b('\xf9\xec\xe5\xed') # Hebrew word shalom in cp1255 display = six.b('\xed\xe5\xec\xf9') self.assertEqual(get_display(storage, encoding='cp1255'), display) def test_explicit_with_upper_is_rtl(self): """Explicit tests""" tests = ( (u'this is _LJUST_o', u'this is JUST'), (u'a _lsimple _RteST_o th_oat', u'a simple TSet that'), (u'HAS A _LPDF missing', u'PDF missing A SAH'), (u'AnD hOw_L AbOuT, 123,987 tHiS_o', u'w AbOuT, 123,987 tHiSOh DnA'), (u'a GOOD - _L_oTEST.', u'a TSET - DOOG.'), (u'here_L is_o_o_o _R a good one_o', u'here is eno doog a '), (u'THE _rbest _lONE and', u'best ENO and EHT'), (u'A REAL BIG_l_o BUG!', u'!GUB GIB LAER A'), (u'a _L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_L_Rbug', u'a gub'), # FIXME the following commented explicit test fails # (u'AN ARABIC _l_o 123-456 NICE ONE!', # u'!ENO ECIN 456-123 CIBARA NA'), (u'AN ARABIC _l _o 123-456 PAIR', u'RIAP 123-456 CIBARA NA'), (u'this bug 67_r_o89 caught!', u'this bug 6789 caught!'), ) # adopt fribidi's CapRtl encoding mappings = { u'_>': u"\u200E", # LRM u'_<': u"\u200F", # RLM u'_l': u"\u202A", # LRE u'_r': u"\u202B", # RLE u'_o': u"\u202C", # PDF u'_L': u"\u202D", # LRO u'_R': u"\u202E", # RLO u'__': '_', } for storage, display in tests: for key, val in mappings.items(): storage = storage.replace(key, val) self.assertEqual(get_display(storage, upper_is_rtl=True), display) def test_mixed_hebrew_numbers_issue10(self): """Test for the case reported in https://github.com/MeirKriheli/python-bidi/issues/10 """ tests = ( (u'1 2 3 \u05E0\u05D9\u05E1\u05D9\u05D5\u05DF', u'\u05DF\u05D5\u05D9\u05E1\u05D9\u05E0 3 2 1'), (u'1 2 3 123 \u05E0\u05D9\u05E1\u05D9\u05D5\u05DF', u'\u05DF\u05D5\u05D9\u05E1\u05D9\u05E0 123 3 2 1'), ) for storage, display in tests: self.assertEqual(get_display(storage), display) if __name__ == '__main__': unittest.main()