pax_global_header00006660000000000000000000000064133500117170014510gustar00rootroot0000000000000052 comment=2bf63a8e40bc4c16a8e729aa582a37ceaac31337 transliterate-1.10.2/000077500000000000000000000000001335001171700144525ustar00rootroot00000000000000transliterate-1.10.2/.coveragerc000066400000000000000000000000531335001171700165710ustar00rootroot00000000000000[run] omit = src/transliterate/tests/* transliterate-1.10.2/.gitignore000066400000000000000000000003761335001171700164500ustar00rootroot00000000000000*.py[cod] /.hgignore~ /.gitignore~ /.travis.yml~ /.hg/ /.hgtags /.tox /.coverage /htmlcov/ *.py,cover /.cache/ /.idea/ /example/db/ /example/tmp/ /build/ /builddocs/ /builddocs.zip /dist/ /src/transliterate.egg-info /.eggs/ /jupyter/.ipynb_checkpoints/ transliterate-1.10.2/.hgignore000066400000000000000000000004061335001171700162550ustar00rootroot00000000000000syntax: regexp \.pyc$ \.hgignore~ \.git/ \.gitignore~ \.travis.yml~ \.tox \.coverage \.cache/ ^htmlcov/ \.py,cover \.idea/ ^example/db/ ^example/tmp/ ^build/ ^builddocs/ ^builddocs.zip ^dist/ ^src/transliterate\.egg-info ^\.eggs/ ^\jupyter/\.ipynb_checkpoints/ transliterate-1.10.2/.pylintrc000066400000000000000000000000471335001171700163200ustar00rootroot00000000000000[MASTER] ignore= disable=C, F, I, R, W transliterate-1.10.2/.travis.yml000066400000000000000000000026401335001171700165650ustar00rootroot00000000000000language: python # Python versions python: - "2.6" - "2.7" - "3.3" # Environments env: - SIXMIN=true - SIXMIN=false # Command to install dependencies install: - python setup.py install - if [[ $TRAVIS_PYTHON_VERSION == '2.6' && $SIXMIN == true ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' && $SIXMIN == true ]]; then pip install six==1.1.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' && $SIXMIN == false ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.6' && $SIXMIN == false ]]; then pip install six==1.4.1; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $SIXMIN == true ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $SIXMIN == true ]]; then pip install six==1.1.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $SIXMIN == false ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '2.7' && $SIXMIN == false ]]; then pip install six==1.4.1; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' && $SIXMIN == true ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' && $SIXMIN == true ]]; then pip install six==1.1.0; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' && $SIXMIN == false ]]; then pip uninstall six -y; fi - if [[ $TRAVIS_PYTHON_VERSION == '3.3' && $SIXMIN == false ]]; then pip install six==1.4.1; fi # Command to run tests script: - python src/transliterate/tests/__init__.py transliterate-1.10.2/CHANGELOG.rst000066400000000000000000000054521335001171700165010ustar00rootroot00000000000000=============== Release history =============== 1.10.2 ------ 2018-09-17 - Add ``get_translit_function`` for speed-ups when looping through a large set of strings. 1.10.1 ------ 2018-05-02 - Fixes and improvements in Georgian language pack. Removed historical asomtavruli (an old Georgian script which is no longer used) support. - Improvements in Serbian language pack. 1.10 ---- 2017-07-07 - Added Serbian language pack. - Drop Python 2.6 support. 1.9 --- 2016-12-27 - Dropping Python 3.2 and Python 3.3 support. - Clean up. - pep8 fixes. - Minor fixes in Greek language pack. - Dedicated shell in example project. - Tested again PyPy. 1.8.1 ----- 2016-07-11 - Fixes in Mongolia language pack. 1.8 --- 2016-07-09 - Added Macedonian language pack. - Added Mongolian language pack. - Drop support for Python 3.2. 1.7.6 ----- 2016-01-29 - Fixes in language detection. 1.7.5 ----- 2015-11-11 - Fixes in Greek language. 1.7.4 ----- 2015-10-24 - Python wheels support added. 1.7.3 ----- 2014-07-30 - Added Bulgarian language pack. 1.7.2 ----- 2014-06-18 - Refactored Python 3.2 support approach. 1.7.1 ----- 2014-06-17 - Refactored tests. 1.7 --- 2014-06-17 - Added Python 3.2 support. 1.6.1 ----- 2014-05-21 - Fixes in Russian language pack. 1.6 --- 2014-03-12 - Ukrainian language pack added. - Each language pack got an extra properly ``detectable``, which is set to False by default. Language packs with that properly set to False are excluded from language auto-detection. - Improved tests. 1.5 --- 2013-10-15 - Lowering ``six`` package requirement to 1.1.0. - Minor documentation improvements. 1.4 --- 2013-10-11 - Added a fallback lorem ipsum generator for Python 3. 1.3 --- 2013-10-01 - Fixed reversed translation of some chars in Russian language pack. - Improved tests. - Minor API improvements. 1.2 --- 2013-09-08 - Python 3 support added. 1.1 --- 2013-09-08 - Allow language packs to be unregistered when not forced. - Minor documentation improvements. 1.0 --- 2013-08-04 - Auto transliterate when reversed added - Better exception handling. 0.9 --- 2013-08-03 - Greek language pack status changed to beta. - Improvements of slugify and language detection of Greek language. 0.8 --- 2013-08-03 - Greek language support added. - Minor fixes in Georgian language pack. 0.7 --- 2013-08-03 - Georgian language support added. 0.6 --- 2013-08-03 - Minor fixes. 0.5 --- 2013-07-31 - Configurable settings added. - Minor fixes. - Better debugging. - Minor documentation improvements. 0.4 --- 2013-07-17 - Python 2.6 support added. - Minor documentation improvements. 0.3 --- 2013-07-14 - Slugify feature added. - Language auto detection from given text added. - Minor fixes. 0.2 --- 2013-07-12 - Lorem ipsum generator added. - Minor documentation improvements. 0.1 --- 2013-07-11 - Initial. transliterate-1.10.2/CREDITS.rst000066400000000000000000000030711335001171700163020ustar00rootroot00000000000000Credits ======= Authors ------- - Artur Barseghyan Contributors ------------ - `Nodar Okroshiashvili `_ for his contributions to the Georgian language pack. - `kelsa-pi `_ for his contributions to the Serbian language pack. - Timofey Pchelintsev for making the Ukrainian language pack. - hajdbo for idea of lowering the six version requirement by avoiding usage of ``PY2`` imports. - Giorgos Georgiadis for pointing to a lack of documentation for registering custom language packs and a nice example of using `transliterate` to get rid of accented characters in Greek, having other characters left intact (see example/example/foo/greekunaccented.py). - `Petar Chakarov `_ for Bulgarian language pack. - `George Karakostas `_ for fixes in Greek language pack. - Sergey Kovalev for fixes in language detection. - `Enkhbold Bataa `_ for Mongolian language pack. - `Igor Stamatovski `_ for Macedonian language pack. Bug reporters ~~~~~~~~~~~~~ The following people contributed to the project by reportings bugs. - Malinich : reported a bug with reversed translation of ъ and ь characters. transliterate-1.10.2/LICENSE_GPL2.0.txt000066400000000000000000000432401335001171700172220ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. 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 convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. transliterate - Bi-directional transliterator for Python. Copyright (C) 2013-2018 Artur Barseghyan 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This 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. transliterate-1.10.2/LICENSE_LGPL_2.1.txt000066400000000000000000000636261335001171700175100ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. 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 not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the 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 specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. transliterate - Bi-directional transliterator for Python. Copyright (C) 2013-2018 Artur Barseghyan This library 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 2.1 of the License, or (at your option) any later version. This library 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 library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! transliterate-1.10.2/MANIFEST.in000066400000000000000000000001121335001171700162020ustar00rootroot00000000000000include README.rst include LICENSE_GPL2.0.txt include LICENSE_LGPL_2.1.txttransliterate-1.10.2/README.rst000066400000000000000000000316661335001171700161550ustar00rootroot00000000000000============= transliterate ============= Bi-directional transliterator for Python. Transliterates (unicode) strings according to the rules specified in the language packs (source script <-> target script). Comes with language packs for the following languages (listed in alphabetical order): - Armenian - Bulgarian (beta) - Georgian - Greek - Macedonian (alpha) - Mongolian (alpha) - Russian - Serbian (alpha) - Ukrainian (beta) There are also a number of useful tools included, such as: - Simple lorem ipsum generator, which allows lorem ipsum generation in the language chosen. - Language detection for the text (if appropriate language pack is available). - Slugify function for non-latin texts. Prerequisites ============= - Python >=2.7, >=3.4, PyPy Installation ============ Install with latest stable version from PyPI. .. code-block:: sh pip install transliterate or install the latest stable version from BitBucket: .. code-block:: sh pip install https://bitbucket.org/barseghyanartur/transliterate/get/stable.tar.gz or install the latest stable version from GitHub: .. code-block:: sh pip install https://github.com/barseghyanartur/transliterate/archive/stable.tar.gz That's all. See the `Usage and examples`_ section for more. Usage and examples ================== Simple usage ------------ Required imports .. code-block:: python from transliterate import translit, get_available_language_codes Original text .. code-block:: python text = "Lorem ipsum dolor sit amet" Transliteration to Armenian .. code-block:: python print(translit(text, 'hy')) # Լօրեմ իպսում դօլօր սիտ ամետ Transliteration to Georgian .. code-block:: python print(translit(text, 'ka')) # ლორემ იპსუმ დოლორ სით ამეთ Transliteration to Greek .. code-block:: python print(translit(text, 'el')) # Λορεμ ιψθμ δολορ σιτ αμετ Transliteration to Russian .. code-block:: python print(translit(text, 'ru')) # Лорем ипсум долор сит амет List of available (registered) languages .. code-block:: python print(get_available_language_codes()) # ['el', 'hy', 'ka', 'ru'] Reversed transliterations are transliterations made from target language to source language (in terms they are defined in language packs). In case of reversed transliterations, you may leave out the ``language_code`` attribute, although if you know it on beforehand, specify it since it works faster that way. Reversed transliteration from Armenian .. code-block:: python print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", 'hy', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Armenian with ``language_code`` argument left out .. code-block:: python print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Georgian .. code-block:: python print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", 'ka', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Georgian with ``language_code`` argument left out .. code-block:: python print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Greek .. code-block:: python print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", 'el', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Greek with ``language_code`` argument left out .. code-block:: python print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Russian (Cyrillic) .. code-block:: python print(translit(u"Лорем ипсум долор сит амет", 'ru', reversed=True)) # Lorеm ipsum dolor sit amеt Reversed transliteration from Russian (Cyrillic) with ``language_code`` argument left out .. code-block:: python print(translit(u"Лорем ипсум долор сит амет", reversed=True)) # Lorem ipsum dolor sit amet Testing the decorator .. code-block:: python from transliterate.decorators import transliterate_function @transliterate_function(language_code='hy') def decorator_test(text): return text print(decorator_test(u"Lorem ipsum dolor sit amet")) # Լօրեմ իպսում դօլօր սիտ ամետ Working with large amounts of data ---------------------------------- If you know which language pack shall be used for transliteration, especially when working with large amounts of data, it makes sense to get the transliteration function in the following way: .. code-block:: python from transliterate import get_translit_function translit_hy = get_translit_function('hy') print(translit_hy(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True)) # Lorem ipsum dolor sit amet print(translit_hy(u"Lorem ipsum dolor sit amet")) # Լօրեմ իպսում դօլօր սիտ ամետ Registering a custom language pack ---------------------------------- Basics ~~~~~~ Make sure to call the ``autodiscover`` function before registering your own language packs if you want to use the bundled language packs along with your own custom ones. .. code-block:: python from transliterate.discover import autodiscover autodiscover() Then the custom language pack part comes. .. code-block:: python from transliterate.base import TranslitLanguagePack, registry class ExampleLanguagePack(TranslitLanguagePack): language_code = "example" language_name = "Example" mapping = ( u"abcdefghij", u"1234567890", ) registry.register(ExampleLanguagePack) print(get_available_language_codes()) # ['el', 'hy', 'ka', 'ru', 'example'] print(translit(text, 'example')) # Lor5m 9psum 4olor s9t 1m5t It's possible to replace existing language packs with your own ones. By default, existing language packs are not force-installed. To force install a language pack, set the ``force`` argument to True when registering a language pack. In that case, if a language pack with same language code has already been registered, it will be replaced; otherwise, if language pack didn't exist in the registry, it will be just registered. .. code-block:: python registry.register(ExampleLanguagePack, force=True) Forced language packs can't be replaced or unregistered. API in depth ~~~~~~~~~~~~ There are 7 class properties that you could/should be using in your language pack, of which 4 are various sorts of mappings. Mappings ++++++++ - ``mapping`` (tuple): A tuple of two strings, that simply represent the mapping of characters from the source language to the target language. For example, if your source language is Latin and you want to convert "a", "b", "c", "d" and "e" characters to appropriate characters in Russian Cyrillic, your mapping would look as follows: .. code-block:: python mapping = (u"abcde", u"абцде") Example (taken from the Greek language pack). .. code-block:: python mapping = ( u"abgdezhiklmnxoprstyfwuABGDEZHIKLMNXOPRSTYFWU", u"αβγδεζηικλμνξοπρστυφωθΑΒΓΔΕΖΗΙΚΛΜΝΞΟΠΡΣΤΥΦΩΘ", ) - ``reversed_specific_mapping`` (tuple): When making reversed translations, the ``mapping`` property is still used, but in some cases you need to provide additional rules. This property (``reversed_specific_mapping``) is meant for such cases. Further, is alike the ``mapping``. Example (taken from the Greek language pack). .. code-block:: python reversed_specific_mapping = ( u"θΘ", u"uU" ) - ``pre_processor_mapping`` (dict): A dictionary of mapping from source language to target language. Use this only in cases if a single character in source language shall be represented by more than one character in the target language. Example (taken from the Greek language pack). .. code-block:: python pre_processor_mapping = { u"th": u"θ", u"ch": u"χ", u"ps": u"ψ", u"TH": u"Θ", u"CH": u"Χ", u"PS": u"Ψ", } - ``reversed_specific_pre_processor_mapping``: Same as ``pre_processor_mapping``, but used in reversed translations. Example (taken from the Armenian language pack) .. code-block:: python reversed_specific_pre_processor_mapping = { u"ու": u"u", u"Ու": u"U" } Additional ++++++++++ - ``character_ranges`` (tuple): A tuple of character ranges (unicode table). Used in language detection. Works only if ``detectable`` property is set to True. Be aware, that language (or shall I better be saying - script) detection is very basic and is based on characters only. - ``detectable`` (bool): If set to True, language pack would be used for automatic language detection. Using the lorem ipsum generator ------------------------------- Note, that due to incompatibility of the original `lorem-ipsum-generator` package with Python 3, when used with Python 3 `transliterate` uses its' own simplified fallback lorem ipsum generator (which still does the job). Required imports .. code-block:: python from transliterate.contrib.apps.translipsum import TranslipsumGenerator Generating paragraphs in Armenian .. code-block:: python g_am = TranslipsumGenerator(language_code='hy') print(g_am.generate_paragraph()) # Մագնա տրիստիքուե ֆաուցիբուս ֆամես նետուս նետուս օրցի մաուրիս, # սուսցիպիտ. Դապիբուս րիսուս սեդ ադիպիսցինգ դիցտում. Ֆերմենտում ուրնա # նատօքուե ատ. Uլտրիցես եգետ, տացիտի. Լիտօրա ցլասս ցօնուբիա պօսուերե # մալեսուադա ին իպսում իդ պեր վե. Generating sentense in Georgian .. code-block:: python g_ka = TranslipsumGenerator(language_code='ka') print(g_ka.generate_sentence()) # გგეთ ყუამ არსუ ვულფუთათე რუთრუმ აუთორ. Generating sentense in Greek .. code-block:: python g_el = TranslipsumGenerator(language_code='el') print(g_el.generate_sentence()) # Νεc cρασ αμετ, ελιτ vεστιβθλθμ εθ, αενεαν ναμ, τελλθσ vαριθσ. Generating sentense in Russian (Cyrillic) .. code-block:: python g_ru = TranslipsumGenerator(language_code='ru') print(g_ru.generate_sentence()) # Рисус cонсеcтетуер, фусcе qуис лаореет ат ерос пэдэ фелис магна. Language detection ------------------ Required imports .. code-block:: python from transliterate import detect_language Detect Armenian text .. code-block:: python detect_language(u'Լօրեմ իպսում դօլօր սիտ ամետ') # hy Detect Georgian text .. code-block:: python detect_language(u'ლორემ იპსუმ დოლორ სით ამეთ') # ka Detect Greek text .. code-block:: python detect_language(u'Λορεμ ιψθμ δολορ σιτ αμετ') # el Detect Russian (Cyrillic) text .. code-block:: python detect_language(u'Лорем ипсум долор сит амет') # ru Slugify ------- Required imports .. code-block:: python from transliterate import slugify Slugify Armenian text .. code-block:: python slugify(u'Լօրեմ իպսում դօլօր սիտ ամետ') # lorem-ipsum-dolor-sit-amet Slugify Georgian text .. code-block:: python slugify(u'ლორემ იპსუმ დოლორ სით ამეთ') # lorem-ipsum-dolor-sit-amet Slugify Greek text .. code-block:: python slugify(u'Λορεμ ιψθμ δολορ σιτ αμετ') # lorem-ipsum-dolor-sit-amet Slugify Russian (Cyrillic) text .. code-block:: python slugify(u'Лорем ипсум долор сит амет') # lorem-ipsum-dolor-sit-amet Missing a language pack? ======================== Missing a language pack for your own language? Contribute to the project by making one and it will appear in a new version (which will be released very quickly). Writing documentation ===================== Keep the following hierarchy. .. code-block:: text ===== title ===== header ====== sub-header ---------- sub-sub-header ~~~~~~~~~~~~~~ sub-sub-sub-header ^^^^^^^^^^^^^^^^^^ sub-sub-sub-sub-header ++++++++++++++++++++++ sub-sub-sub-sub-sub-header ************************** License ======= GPL 2.0/LGPL 2.1 Support ======= For any issues contact me at the e-mail given in the `Author`_ section. Author ====== Artur Barseghyan transliterate-1.10.2/TODOS.rst000066400000000000000000000023711335001171700160770ustar00rootroot00000000000000TODOs ===== Based on MoSCoW principle Must haves ---------- - Prediction/auto-suggest feature. - Make the API documentation really obvious. Explain in detail what is ``mapping``, ``pre_processor_mapping`` and ``reversed_specific_mapping``, as well as other properties and methods, which are possible to tweak/override. Explain more about ``detectable`` property of the language pack and on the example of Ukrainian language pack, explain what to do with languages that do have same scripts (use same unicode characters). Add examples on Ukrainian language pack into the main readme. - Command line tool for transliterating files (source language, target language, source file, target file). - Implement stripping out of the symbols. - Check and make appropriate fixes (if necessary) to the Greek pack. Quote """ I also find an error in your "el" Greek file. Both "y" and "u" should go to upsilon "υ", not "u" into theta "θ", and "w" doesn't really go to anything, although "υ" would be the closest. It does not work to always transliterate "ps" into "ψ", because in a word like "ipsum" their roots dictate "υπσυμ" would be better. Should haves ------------ - Japanese support. Could haves ----------- Would haves ----------- transliterate-1.10.2/docs/000077500000000000000000000000001335001171700154025ustar00rootroot00000000000000transliterate-1.10.2/docs/Makefile000066400000000000000000000202421335001171700170420ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = python -msphinx PAPER = BUILDDIR = _build # Internal variables. PAPEROPT_a4 = -D latex_elements.papersize=a4 PAPEROPT_letter = -D latex_elements.papersize=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 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 an HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " applehelp to make an Apple Help Book" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " epub3 to make an epub3" @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 " lualatexpdf to make LaTeX files and run them through lualatex" @echo " xelatexpdf to make LaTeX files and run them through xelatex" @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)" @echo " coverage to run coverage check of the documentation (if enabled)" @echo " dummy to check syntax errors of document sources" .PHONY: clean clean: rm -rf $(BUILDDIR)/* .PHONY: html html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." .PHONY: dirhtml dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." .PHONY: singlehtml singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." .PHONY: pickle pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." .PHONY: json json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." .PHONY: htmlhelp 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." .PHONY: qthelp 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/transliterate.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/transliterate.qhc" .PHONY: applehelp applehelp: $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp @echo @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." @echo "N.B. You won't be able to view it unless you put it in" \ "~/Library/Documentation/Help or install it in your application" \ "bundle." .PHONY: devhelp devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/transliterate" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/transliterate" @echo "# devhelp" .PHONY: epub epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." .PHONY: epub3 epub3: $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 @echo @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." .PHONY: latex 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)." .PHONY: latexpdf 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." .PHONY: latexpdfja 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." .PHONY: lualatexpdf lualatexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through lualatex..." $(MAKE) PDFLATEX=lualatex -C $(BUILDDIR)/latex all-pdf @echo "lualatex finished; the PDF files are in $(BUILDDIR)/latex." .PHONY: xelatexpdf xelatexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through xelatex..." $(MAKE) PDFLATEX=xelatex -C $(BUILDDIR)/latex all-pdf @echo "xelatex finished; the PDF files are in $(BUILDDIR)/latex." .PHONY: text text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." .PHONY: man man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." .PHONY: texinfo 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)." .PHONY: info 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." .PHONY: gettext gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." .PHONY: changes changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." .PHONY: linkcheck 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." .PHONY: doctest doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." .PHONY: coverage coverage: $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage @echo "Testing of coverage in the sources finished, look at the " \ "results in $(BUILDDIR)/coverage/python.txt." .PHONY: xml xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." .PHONY: pseudoxml pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." .PHONY: dummy dummy: $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy @echo @echo "Build finished. Dummy builder generates no files." transliterate-1.10.2/docs/changelog.rst000066400000000000000000000054521335001171700200710ustar00rootroot00000000000000=============== Release history =============== 1.10.2 ------ 2018-09-17 - Add ``get_translit_function`` for speed-ups when looping through a large set of strings. 1.10.1 ------ 2018-05-02 - Fixes and improvements in Georgian language pack. Removed historical asomtavruli (an old Georgian script which is no longer used) support. - Improvements in Serbian language pack. 1.10 ---- 2017-07-07 - Added Serbian language pack. - Drop Python 2.6 support. 1.9 --- 2016-12-27 - Dropping Python 3.2 and Python 3.3 support. - Clean up. - pep8 fixes. - Minor fixes in Greek language pack. - Dedicated shell in example project. - Tested again PyPy. 1.8.1 ----- 2016-07-11 - Fixes in Mongolia language pack. 1.8 --- 2016-07-09 - Added Macedonian language pack. - Added Mongolian language pack. - Drop support for Python 3.2. 1.7.6 ----- 2016-01-29 - Fixes in language detection. 1.7.5 ----- 2015-11-11 - Fixes in Greek language. 1.7.4 ----- 2015-10-24 - Python wheels support added. 1.7.3 ----- 2014-07-30 - Added Bulgarian language pack. 1.7.2 ----- 2014-06-18 - Refactored Python 3.2 support approach. 1.7.1 ----- 2014-06-17 - Refactored tests. 1.7 --- 2014-06-17 - Added Python 3.2 support. 1.6.1 ----- 2014-05-21 - Fixes in Russian language pack. 1.6 --- 2014-03-12 - Ukrainian language pack added. - Each language pack got an extra properly ``detectable``, which is set to False by default. Language packs with that properly set to False are excluded from language auto-detection. - Improved tests. 1.5 --- 2013-10-15 - Lowering ``six`` package requirement to 1.1.0. - Minor documentation improvements. 1.4 --- 2013-10-11 - Added a fallback lorem ipsum generator for Python 3. 1.3 --- 2013-10-01 - Fixed reversed translation of some chars in Russian language pack. - Improved tests. - Minor API improvements. 1.2 --- 2013-09-08 - Python 3 support added. 1.1 --- 2013-09-08 - Allow language packs to be unregistered when not forced. - Minor documentation improvements. 1.0 --- 2013-08-04 - Auto transliterate when reversed added - Better exception handling. 0.9 --- 2013-08-03 - Greek language pack status changed to beta. - Improvements of slugify and language detection of Greek language. 0.8 --- 2013-08-03 - Greek language support added. - Minor fixes in Georgian language pack. 0.7 --- 2013-08-03 - Georgian language support added. 0.6 --- 2013-08-03 - Minor fixes. 0.5 --- 2013-07-31 - Configurable settings added. - Minor fixes. - Better debugging. - Minor documentation improvements. 0.4 --- 2013-07-17 - Python 2.6 support added. - Minor documentation improvements. 0.3 --- 2013-07-14 - Slugify feature added. - Language auto detection from given text added. - Minor fixes. 0.2 --- 2013-07-12 - Lorem ipsum generator added. - Minor documentation improvements. 0.1 --- 2013-07-11 - Initial. transliterate-1.10.2/docs/conf.distrib000066400000000000000000000240321335001171700177120ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # transliterate documentation build configuration file, created by # sphinx-quickstart on Thu Jul 11 00:21:18 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, 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('.')) sys.path.insert(0, os.path.abspath('../src')) try: import transliterate release = version = transliterate.__version__ project = transliterate.__title__ copyright = transliterate.__copyright__ except Exception as e: release = version = '0.1' project = u'transliterate' copyright = u'2013-2014, Artur Barseghyan ' # -- 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'transliterate' #copyright = u'2013, Artur Barseghyan ' # 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 = '1.6' # The full version, including alpha/beta/rc tags. #release = '1.6' # 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 = 'transliteratedoc' # -- 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', 'transliterate.tex', u'transliterate Documentation', u'Artur Barseghyan \\textless{}artur.barseghyan@gmail.com\\textgreater{}', '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', 'transliterate', u'transliterate Documentation', [u'Artur Barseghyan '], 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', 'transliterate', u'transliterate Documentation', u'Artur Barseghyan ', 'transliterate', '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 # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project #u'transliterate' epub_author = u'Artur Barseghyan ' epub_publisher = u'Artur Barseghyan ' epub_copyright = u'2013-2014, Artur Barseghyan ' # The language of the text. It defaults to the language option # or en if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # A tuple containing the cover image and cover page html template filenames. #epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. #epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. #epub_exclude_files = [] # The depth of the table of contents in toc.ncx. #epub_tocdepth = 3 # Allow duplicate toc entries. #epub_tocdup = True # Fix unsupported image types using the PIL. #epub_fix_images = False # Scale large images. #epub_max_image_width = 0 # If 'no', URL addresses will not be shown. #epub_show_urls = 'inline' # If false, no index is generated. #epub_use_index = True transliterate-1.10.2/docs/conf.py000066400000000000000000000240321335001171700167020ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # transliterate documentation build configuration file, created by # sphinx-quickstart on Thu Jul 11 00:21:18 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, 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('.')) sys.path.insert(0, os.path.abspath('../src')) try: import transliterate release = version = transliterate.__version__ project = transliterate.__title__ copyright = transliterate.__copyright__ except Exception as e: release = version = '0.1' project = u'transliterate' copyright = u'2013-2014, Artur Barseghyan ' # -- 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'transliterate' #copyright = u'2013, Artur Barseghyan ' # 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 = '1.6' # The full version, including alpha/beta/rc tags. #release = '1.6' # 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 = 'transliteratedoc' # -- 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', 'transliterate.tex', u'transliterate Documentation', u'Artur Barseghyan \\textless{}artur.barseghyan@gmail.com\\textgreater{}', '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', 'transliterate', u'transliterate Documentation', [u'Artur Barseghyan '], 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', 'transliterate', u'transliterate Documentation', u'Artur Barseghyan ', 'transliterate', '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 # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project #u'transliterate' epub_author = u'Artur Barseghyan ' epub_publisher = u'Artur Barseghyan ' epub_copyright = u'2013-2014, Artur Barseghyan ' # The language of the text. It defaults to the language option # or en if the language is not set. #epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. #epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. #epub_identifier = '' # A unique identification for the text. #epub_uid = '' # A tuple containing the cover image and cover page html template filenames. #epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. #epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. #epub_post_files = [] # A list of files that should not be packed into the epub file. #epub_exclude_files = [] # The depth of the table of contents in toc.ncx. #epub_tocdepth = 3 # Allow duplicate toc entries. #epub_tocdup = True # Fix unsupported image types using the PIL. #epub_fix_images = False # Scale large images. #epub_max_image_width = 0 # If 'no', URL addresses will not be shown. #epub_show_urls = 'inline' # If false, no index is generated. #epub_use_index = True transliterate-1.10.2/docs/documentation.rst.distrib000066400000000000000000000003121335001171700224400ustar00rootroot00000000000000 Documentation ============= Contents: .. toctree:: :maxdepth: 20 index transliterate changelog Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` transliterate-1.10.2/docs/index.rst000066400000000000000000000322001335001171700172400ustar00rootroot00000000000000============= transliterate ============= Bi-directional transliterator for Python. Transliterates (unicode) strings according to the rules specified in the language packs (source script <-> target script). Comes with language packs for the following languages (listed in alphabetical order): - Armenian - Bulgarian (beta) - Georgian - Greek - Macedonian (alpha) - Mongolian (alpha) - Russian - Serbian (alpha) - Ukrainian (beta) There are also a number of useful tools included, such as: - Simple lorem ipsum generator, which allows lorem ipsum generation in the language chosen. - Language detection for the text (if appropriate language pack is available). - Slugify function for non-latin texts. Prerequisites ============= - Python >=2.7, >=3.4, PyPy Installation ============ Install with latest stable version from PyPI. .. code-block:: sh pip install transliterate or install the latest stable version from BitBucket: .. code-block:: sh pip install https://bitbucket.org/barseghyanartur/transliterate/get/stable.tar.gz or install the latest stable version from GitHub: .. code-block:: sh pip install https://github.com/barseghyanartur/transliterate/archive/stable.tar.gz That's all. See the `Usage and examples`_ section for more. Usage and examples ================== Simple usage ------------ Required imports .. code-block:: python from transliterate import translit, get_available_language_codes Original text .. code-block:: python text = "Lorem ipsum dolor sit amet" Transliteration to Armenian .. code-block:: python print(translit(text, 'hy')) # Լօրեմ իպսում դօլօր սիտ ամետ Transliteration to Georgian .. code-block:: python print(translit(text, 'ka')) # ლორემ იპსუმ დოლორ სით ამეთ Transliteration to Greek .. code-block:: python print(translit(text, 'el')) # Λορεμ ιψθμ δολορ σιτ αμετ Transliteration to Russian .. code-block:: python print(translit(text, 'ru')) # Лорем ипсум долор сит амет List of available (registered) languages .. code-block:: python print(get_available_language_codes()) # ['el', 'hy', 'ka', 'ru'] Reversed transliterations are transliterations made from target language to source language (in terms they are defined in language packs). In case of reversed transliterations, you may leave out the ``language_code`` attribute, although if you know it on beforehand, specify it since it works faster that way. Reversed transliteration from Armenian .. code-block:: python print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", 'hy', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Armenian with ``language_code`` argument left out .. code-block:: python print(translit(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Georgian .. code-block:: python print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", 'ka', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Georgian with ``language_code`` argument left out .. code-block:: python print(translit(u"ლორემ იპსუმ დოლორ სით ამეთ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Greek .. code-block:: python print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", 'el', reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Greek with ``language_code`` argument left out .. code-block:: python print(translit(u"Λορεμ ιψθμ δολορ σιτ αμετ", reversed=True)) # Lorem ipsum dolor sit amet Reversed transliteration from Russian (Cyrillic) .. code-block:: python print(translit(u"Лорем ипсум долор сит амет", 'ru', reversed=True)) # Lorеm ipsum dolor sit amеt Reversed transliteration from Russian (Cyrillic) with ``language_code`` argument left out .. code-block:: python print(translit(u"Лорем ипсум долор сит амет", reversed=True)) # Lorem ipsum dolor sit amet Testing the decorator .. code-block:: python from transliterate.decorators import transliterate_function @transliterate_function(language_code='hy') def decorator_test(text): return text print(decorator_test(u"Lorem ipsum dolor sit amet")) # Լօրեմ իպսում դօլօր սիտ ամետ Working with large amounts of data ---------------------------------- If you know which language pack shall be used for transliteration, especially when working with large amounts of data, it makes sense to get the transliteration function in the following way: .. code-block:: python from transliterate import get_translit_function translit_hy = get_translit_function('hy') print(translit_hy(u"Լօրեմ իպսում դօլօր սիտ ամետ", reversed=True)) # Lorem ipsum dolor sit amet print(translit_hy(u"Lorem ipsum dolor sit amet")) # Լօրեմ իպսում դօլօր սիտ ամետ Registering a custom language pack ---------------------------------- Basics ~~~~~~ Make sure to call the ``autodiscover`` function before registering your own language packs if you want to use the bundled language packs along with your own custom ones. .. code-block:: python from transliterate.discover import autodiscover autodiscover() Then the custom language pack part comes. .. code-block:: python from transliterate.base import TranslitLanguagePack, registry class ExampleLanguagePack(TranslitLanguagePack): language_code = "example" language_name = "Example" mapping = ( u"abcdefghij", u"1234567890", ) registry.register(ExampleLanguagePack) print(get_available_language_codes()) # ['el', 'hy', 'ka', 'ru', 'example'] print(translit(text, 'example')) # Lor5m 9psum 4olor s9t 1m5t It's possible to replace existing language packs with your own ones. By default, existing language packs are not force-installed. To force install a language pack, set the ``force`` argument to True when registering a language pack. In that case, if a language pack with same language code has already been registered, it will be replaced; otherwise, if language pack didn't exist in the registry, it will be just registered. .. code-block:: python registry.register(ExampleLanguagePack, force=True) Forced language packs can't be replaced or unregistered. API in depth ~~~~~~~~~~~~ There are 7 class properties that you could/should be using in your language pack, of which 4 are various sorts of mappings. Mappings ++++++++ - ``mapping`` (tuple): A tuple of two strings, that simply represent the mapping of characters from the source language to the target language. For example, if your source language is Latin and you want to convert "a", "b", "c", "d" and "e" characters to appropriate characters in Russian Cyrillic, your mapping would look as follows: .. code-block:: python mapping = (u"abcde", u"абцде") Example (taken from the Greek language pack). .. code-block:: python mapping = ( u"abgdezhiklmnxoprstyfwuABGDEZHIKLMNXOPRSTYFWU", u"αβγδεζηικλμνξοπρστυφωθΑΒΓΔΕΖΗΙΚΛΜΝΞΟΠΡΣΤΥΦΩΘ", ) - ``reversed_specific_mapping`` (tuple): When making reversed translations, the ``mapping`` property is still used, but in some cases you need to provide additional rules. This property (``reversed_specific_mapping``) is meant for such cases. Further, is alike the ``mapping``. Example (taken from the Greek language pack). .. code-block:: python reversed_specific_mapping = ( u"θΘ", u"uU" ) - ``pre_processor_mapping`` (dict): A dictionary of mapping from source language to target language. Use this only in cases if a single character in source language shall be represented by more than one character in the target language. Example (taken from the Greek language pack). .. code-block:: python pre_processor_mapping = { u"th": u"θ", u"ch": u"χ", u"ps": u"ψ", u"TH": u"Θ", u"CH": u"Χ", u"PS": u"Ψ", } - ``reversed_specific_pre_processor_mapping``: Same as ``pre_processor_mapping``, but used in reversed translations. Example (taken from the Armenian language pack) .. code-block:: python reversed_specific_pre_processor_mapping = { u"ու": u"u", u"Ու": u"U" } Additional ++++++++++ - ``character_ranges`` (tuple): A tuple of character ranges (unicode table). Used in language detection. Works only if ``detectable`` property is set to True. Be aware, that language (or shall I better be saying - script) detection is very basic and is based on characters only. - ``detectable`` (bool): If set to True, language pack would be used for automatic language detection. Using the lorem ipsum generator ------------------------------- Note, that due to incompatibility of the original `lorem-ipsum-generator` package with Python 3, when used with Python 3 `transliterate` uses its' own simplified fallback lorem ipsum generator (which still does the job). Required imports .. code-block:: python from transliterate.contrib.apps.translipsum import TranslipsumGenerator Generating paragraphs in Armenian .. code-block:: python g_am = TranslipsumGenerator(language_code='hy') print(g_am.generate_paragraph()) # Մագնա տրիստիքուե ֆաուցիբուս ֆամես նետուս նետուս օրցի մաուրիս, # սուսցիպիտ. Դապիբուս րիսուս սեդ ադիպիսցինգ դիցտում. Ֆերմենտում ուրնա # նատօքուե ատ. Uլտրիցես եգետ, տացիտի. Լիտօրա ցլասս ցօնուբիա պօսուերե # մալեսուադա ին իպսում իդ պեր վե. Generating sentense in Georgian .. code-block:: python g_ka = TranslipsumGenerator(language_code='ka') print(g_ka.generate_sentence()) # გგეთ ყუამ არსუ ვულფუთათე რუთრუმ აუთორ. Generating sentense in Greek .. code-block:: python g_el = TranslipsumGenerator(language_code='el') print(g_el.generate_sentence()) # Νεc cρασ αμετ, ελιτ vεστιβθλθμ εθ, αενεαν ναμ, τελλθσ vαριθσ. Generating sentense in Russian (Cyrillic) .. code-block:: python g_ru = TranslipsumGenerator(language_code='ru') print(g_ru.generate_sentence()) # Рисус cонсеcтетуер, фусcе qуис лаореет ат ерос пэдэ фелис магна. Language detection ------------------ Required imports .. code-block:: python from transliterate import detect_language Detect Armenian text .. code-block:: python detect_language(u'Լօրեմ իպսում դօլօր սիտ ամետ') # hy Detect Georgian text .. code-block:: python detect_language(u'ლორემ იპსუმ დოლორ სით ამეთ') # ka Detect Greek text .. code-block:: python detect_language(u'Λορεμ ιψθμ δολορ σιτ αμετ') # el Detect Russian (Cyrillic) text .. code-block:: python detect_language(u'Лорем ипсум долор сит амет') # ru Slugify ------- Required imports .. code-block:: python from transliterate import slugify Slugify Armenian text .. code-block:: python slugify(u'Լօրեմ իպսում դօլօր սիտ ամետ') # lorem-ipsum-dolor-sit-amet Slugify Georgian text .. code-block:: python slugify(u'ლორემ იპსუმ დოლორ სით ამეთ') # lorem-ipsum-dolor-sit-amet Slugify Greek text .. code-block:: python slugify(u'Λορεμ ιψθμ δολορ σιτ αμετ') # lorem-ipsum-dolor-sit-amet Slugify Russian (Cyrillic) text .. code-block:: python slugify(u'Лорем ипсум долор сит амет') # lorem-ipsum-dolor-sit-amet Missing a language pack? ======================== Missing a language pack for your own language? Contribute to the project by making one and it will appear in a new version (which will be released very quickly). Writing documentation ===================== Keep the following hierarchy. .. code-block:: text ===== title ===== header ====== sub-header ---------- sub-sub-header ~~~~~~~~~~~~~~ sub-sub-sub-header ^^^^^^^^^^^^^^^^^^ sub-sub-sub-sub-header ++++++++++++++++++++++ sub-sub-sub-sub-sub-header ************************** License ======= GPL 2.0/LGPL 2.1 Support ======= For any issues contact me at the e-mail given in the `Author`_ section. Author ====== Artur Barseghyan Documentation ============= Contents: .. toctree:: :maxdepth: 20 index transliterate changelog Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` transliterate-1.10.2/docs/make.bat000066400000000000000000000166371335001171700170240ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation pushd %~dp0 if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=python -msphinx ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_elements.papersize=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_elements.papersize=%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 an 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. epub3 to make an epub3 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 echo. coverage to run coverage check of the documentation if enabled echo. dummy to check syntax errors of document sources goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) REM Check if sphinx-build is available %SPHINXBUILD% 1>NUL 2>NUL if errorlevel 1 ( echo. echo.The Sphinx module was not found. Make sure you have Sphinx installed, echo.then set the SPHINXBUILD environment variable to point to the full echo.path of the 'sphinx-build' executable. Alternatively you may add the echo.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\transliterate.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\transliterate.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" == "epub3" ( %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. 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 %~dp0 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 %~dp0 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" == "coverage" ( %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage if errorlevel 1 exit /b 1 echo. echo.Testing of coverage in the sources finished, look at the ^ results in %BUILDDIR%/coverage/python.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 ) if "%1" == "dummy" ( %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy if errorlevel 1 exit /b 1 echo. echo.Build finished. Dummy builder generates no files. goto end ) :end popd transliterate-1.10.2/docs/transliterate.contrib.apps.rst000066400000000000000000000004431335001171700234170ustar00rootroot00000000000000transliterate\.contrib\.apps package ==================================== Subpackages ----------- .. toctree:: transliterate.contrib.apps.translipsum Module contents --------------- .. automodule:: transliterate.contrib.apps :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.apps.translipsum.rst000066400000000000000000000007661335001171700260070ustar00rootroot00000000000000transliterate\.contrib\.apps\.translipsum package ================================================= Submodules ---------- transliterate\.contrib\.apps\.translipsum\.utils module ------------------------------------------------------- .. automodule:: transliterate.contrib.apps.translipsum.utils :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.apps.translipsum :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.bg.data.rst000066400000000000000000000010061335001171700257150ustar00rootroot00000000000000transliterate\.contrib\.languages\.bg\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.bg\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.bg.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.bg.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.bg.rst000066400000000000000000000011511335001171700250060ustar00rootroot00000000000000transliterate\.contrib\.languages\.bg package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.bg.data Submodules ---------- transliterate\.contrib\.languages\.bg\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.bg.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.bg :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.el.data.rst000066400000000000000000000010061335001171700257250ustar00rootroot00000000000000transliterate\.contrib\.languages\.el\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.el\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.el.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.el.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.el.rst000066400000000000000000000011511335001171700250160ustar00rootroot00000000000000transliterate\.contrib\.languages\.el package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.el.data Submodules ---------- transliterate\.contrib\.languages\.el\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.el.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.el :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.he.rst000066400000000000000000000010251335001171700250120ustar00rootroot00000000000000transliterate\.contrib\.languages\.he package ============================================= Submodules ---------- transliterate\.contrib\.languages\.he\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.he.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.he :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.hi.rst000066400000000000000000000010251335001171700250160ustar00rootroot00000000000000transliterate\.contrib\.languages\.hi package ============================================= Submodules ---------- transliterate\.contrib\.languages\.hi\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.hi.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.hi :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.hy.data.rst000066400000000000000000000010061335001171700257450ustar00rootroot00000000000000transliterate\.contrib\.languages\.hy\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.hy\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.hy.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.hy.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.hy.rst000066400000000000000000000011511335001171700250360ustar00rootroot00000000000000transliterate\.contrib\.languages\.hy package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.hy.data Submodules ---------- transliterate\.contrib\.languages\.hy\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.hy.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.hy :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.ka.data.rst000066400000000000000000000010061335001171700257200ustar00rootroot00000000000000transliterate\.contrib\.languages\.ka\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.ka\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.ka.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.ka.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.ka.rst000066400000000000000000000011511335001171700250110ustar00rootroot00000000000000transliterate\.contrib\.languages\.ka package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.ka.data Submodules ---------- transliterate\.contrib\.languages\.ka\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.ka.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.ka :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.l1.data.rst000066400000000000000000000010061335001171700256410ustar00rootroot00000000000000transliterate\.contrib\.languages\.l1\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.l1\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.l1.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.l1.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.l1.rst000066400000000000000000000011511335001171700247320ustar00rootroot00000000000000transliterate\.contrib\.languages\.l1 package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.l1.data Submodules ---------- transliterate\.contrib\.languages\.l1\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.l1.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.l1 :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.mk.data.rst000066400000000000000000000010061335001171700257340ustar00rootroot00000000000000transliterate\.contrib\.languages\.mk\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.mk\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.mk.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.mk.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.mk.rst000066400000000000000000000011511335001171700250250ustar00rootroot00000000000000transliterate\.contrib\.languages\.mk package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.mk.data Submodules ---------- transliterate\.contrib\.languages\.mk\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.mk.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.mk :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.mn.data.rst000066400000000000000000000010061335001171700257370ustar00rootroot00000000000000transliterate\.contrib\.languages\.mn\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.mn\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.mn.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.mn.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.mn.rst000066400000000000000000000011511335001171700250300ustar00rootroot00000000000000transliterate\.contrib\.languages\.mn package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.mn.data Submodules ---------- transliterate\.contrib\.languages\.mn\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.mn.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.mn :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.rst000066400000000000000000000013331335001171700244210ustar00rootroot00000000000000transliterate\.contrib\.languages package ========================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.bg transliterate.contrib.languages.el transliterate.contrib.languages.he transliterate.contrib.languages.hi transliterate.contrib.languages.hy transliterate.contrib.languages.ka transliterate.contrib.languages.l1 transliterate.contrib.languages.mk transliterate.contrib.languages.mn transliterate.contrib.languages.ru transliterate.contrib.languages.sr transliterate.contrib.languages.uk Module contents --------------- .. automodule:: transliterate.contrib.languages :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.ru.data.rst000066400000000000000000000010061335001171700257530ustar00rootroot00000000000000transliterate\.contrib\.languages\.ru\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.ru\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.ru.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.ru.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.ru.rst000066400000000000000000000011511335001171700250440ustar00rootroot00000000000000transliterate\.contrib\.languages\.ru package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.ru.data Submodules ---------- transliterate\.contrib\.languages\.ru\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.ru.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.ru :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.sr.data.rst000066400000000000000000000010061335001171700257510ustar00rootroot00000000000000transliterate\.contrib\.languages\.sr\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.sr\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.sr.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.sr.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.sr.rst000066400000000000000000000011511335001171700250420ustar00rootroot00000000000000transliterate\.contrib\.languages\.sr package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.sr.data Submodules ---------- transliterate\.contrib\.languages\.sr\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.sr.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.sr :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.uk.data.rst000066400000000000000000000010061335001171700257440ustar00rootroot00000000000000transliterate\.contrib\.languages\.uk\.data package =================================================== Submodules ---------- transliterate\.contrib\.languages\.uk\.data\.default module ----------------------------------------------------------- .. automodule:: transliterate.contrib.languages.uk.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.uk.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.languages.uk.rst000066400000000000000000000011511335001171700250350ustar00rootroot00000000000000transliterate\.contrib\.languages\.uk package ============================================= Subpackages ----------- .. toctree:: transliterate.contrib.languages.uk.data Submodules ---------- transliterate\.contrib\.languages\.uk\.translit\_language\_pack module ---------------------------------------------------------------------- .. automodule:: transliterate.contrib.languages.uk.translit_language_pack :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.contrib.languages.uk :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.contrib.rst000066400000000000000000000004521335001171700224550ustar00rootroot00000000000000transliterate\.contrib package ============================== Subpackages ----------- .. toctree:: transliterate.contrib.apps transliterate.contrib.languages Module contents --------------- .. automodule:: transliterate.contrib :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.rst000066400000000000000000000027771335001171700210320ustar00rootroot00000000000000transliterate package ===================== Subpackages ----------- .. toctree:: transliterate.contrib transliterate.tests Submodules ---------- transliterate\.base module -------------------------- .. automodule:: transliterate.base :members: :undoc-members: :show-inheritance: transliterate\.conf module -------------------------- .. automodule:: transliterate.conf :members: :undoc-members: :show-inheritance: transliterate\.decorators module -------------------------------- .. automodule:: transliterate.decorators :members: :undoc-members: :show-inheritance: transliterate\.defaults module ------------------------------ .. automodule:: transliterate.defaults :members: :undoc-members: :show-inheritance: transliterate\.discover module ------------------------------ .. automodule:: transliterate.discover :members: :undoc-members: :show-inheritance: transliterate\.exceptions module -------------------------------- .. automodule:: transliterate.exceptions :members: :undoc-members: :show-inheritance: transliterate\.helpers module ----------------------------- .. automodule:: transliterate.helpers :members: :undoc-members: :show-inheritance: transliterate\.utils module --------------------------- .. automodule:: transliterate.utils :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.tests.data.rst000066400000000000000000000006441335001171700230720ustar00rootroot00000000000000transliterate\.tests\.data package ================================== Submodules ---------- transliterate\.tests\.data\.default module ------------------------------------------ .. automodule:: transliterate.tests.data.default :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.tests.data :members: :undoc-members: :show-inheritance: transliterate-1.10.2/docs/transliterate.tests.rst000066400000000000000000000017671335001171700221710ustar00rootroot00000000000000transliterate\.tests package ============================ Subpackages ----------- .. toctree:: transliterate.tests.data Submodules ---------- transliterate\.tests\.base module --------------------------------- .. automodule:: transliterate.tests.base :members: :undoc-members: :show-inheritance: transliterate\.tests\.defaults module ------------------------------------- .. automodule:: transliterate.tests.defaults :members: :undoc-members: :show-inheritance: transliterate\.tests\.helpers module ------------------------------------ .. automodule:: transliterate.tests.helpers :members: :undoc-members: :show-inheritance: transliterate\.tests\.test\_transliterate module ------------------------------------------------ .. automodule:: transliterate.tests.test_transliterate :members: :undoc-members: :show-inheritance: Module contents --------------- .. automodule:: transliterate.tests :members: :undoc-members: :show-inheritance: transliterate-1.10.2/example/000077500000000000000000000000001335001171700161055ustar00rootroot00000000000000transliterate-1.10.2/example/README.rst000066400000000000000000000000551335001171700175740ustar00rootroot00000000000000Example transliterate usage. See the foo app.transliterate-1.10.2/example/example/000077500000000000000000000000001335001171700175405ustar00rootroot00000000000000transliterate-1.10.2/example/example/__init__.py000066400000000000000000000000001335001171700216370ustar00rootroot00000000000000transliterate-1.10.2/example/example/foo/000077500000000000000000000000001335001171700203235ustar00rootroot00000000000000transliterate-1.10.2/example/example/foo/__init__.py000066400000000000000000000000001335001171700224220ustar00rootroot00000000000000transliterate-1.10.2/example/example/foo/greekunaccented.py000066400000000000000000000020551335001171700240260ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ This module was kindly provided by Giorgos Georgiadis , who used `transliterate` to get rid of accented characters in Greek but leave other characters intact. :example: >>> from foo.greekunaccented import * >>> from transliterate import translit >>> print translit(u'άέήίϊΐόύϋΰώΆΈΉΊΪΌΎΫΏ', 'el2') αεηιιιουυυωΑΕΗΙΙΟΥΥΩ """ from transliterate import translit from transliterate.discover import autodiscover from transliterate.base import TranslitLanguagePack, registry # First autodicover bundled language packs. autodiscover() class GreekUnaccentedLanguagePack(TranslitLanguagePack): """ Custom language pack which gets rid of accented characters in Greek but leaves other characters intact. """ language_code = "el2" language_name = "Greek without accented characters" mapping = ( u"άέήίϊΐόύϋΰώΆΈΉΊΪΌΎΫΏ", u"αεηιιιουυυωΑΕΗΙΙΟΥΥΩ", ) # Register registry.register(GreekUnaccentedLanguagePack) transliterate-1.10.2/example/example/foo/latin_to_latin.py000066400000000000000000000015301335001171700236740ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ Latin to Latin example. """ from transliterate import translit from transliterate.discover import autodiscover from transliterate.base import TranslitLanguagePack, registry # First autodicover bundled language packs. autodiscover() class LatinToLatinLanguagePack(TranslitLanguagePack): """ Custom language pack which gets rid of accented characters in Greek but leaves other characters intact. """ language_code = "l2l" language_name = "Latin to Latin" mapping = ( u"abgdezilxkhmjnpsvtrcqw&ofABGDEZILXKHMJNPSVTRCQOFW", u"zbgdeailxkhnjmpswtrcqv&ofZBGDEAILXKHNJMPSWTRCQOFV", ) characters = u"abgdezilxkhmjnpsvtrcqw&ofABGDEZILXKHMJNPSVTRCQOFW" reversed_characters = u"abgdezilxkhmjnpsvtrcqw&ofABGDEZILXKHMJNPSVTRCQOFW" # Register registry.register(LatinToLatinLanguagePack) transliterate-1.10.2/example/example/foo/samples.py000066400000000000000000000102401335001171700223360ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.discover import autodiscover from transliterate.conf import set_setting from transliterate import get_available_language_codes, translit set_setting('DEBUG', True) # Autodiscover available language packs #autodiscover() print '\nOriginal text\n---------------------------------------' text = "Lorem ipsum dolor sit amet" print text print '\nTransliteration to Armenian\n---------------------------------------' print translit(text, 'hy') print '\nTransliteration to Russian\n---------------------------------------' print translit(text, 'ru') print '\nList of available (registered) languages\n---------------------------------------' print get_available_language_codes() print '\nReversed transliteration from Armenian\n---------------------------------------' print translit(u'Լօրեմ իպսում դoլoր սիտ ամետ', 'hy', reversed=True) print '\nReversed transliteration from Russian\n---------------------------------------' print translit(u'Лорем ипсум долор сит амет', 'ru', reversed=True) print '\nTesting the function decorator\n---------------------------------------' from transliterate.decorators import transliterate_function @transliterate_function(language_code='hy') def decorator_test_armenian(text): return text print decorator_test_armenian(u"Lorem ipsum dolor sit amet") print '\nTesting the method decorator\n---------------------------------------' from transliterate.decorators import transliterate_method class DecoratorTest(object): @transliterate_method(language_code='ru') def decorator_test_russian(self, text): return text print DecoratorTest().decorator_test_russian(u"Lorem ipsum dolor sit amet") print '\nTesting the decorator in reversed mode\n---------------------------------------' @transliterate_function(language_code='hy', reversed=True) def decorator_test_armenian_reversed(text): return text print decorator_test_armenian(u"Լօրեմ իպսում դoլoր սիտ ամետ") print '\nRegistering custom language pack\n---------------------------------------' from transliterate.base import TranslitLanguagePack, registry class ExampleLanguagePack(TranslitLanguagePack): """ Example language pack. """ language_code = "example" language_name = "Example" mapping = ( u"abcdefghij", u"1234567890", ) registry.register(ExampleLanguagePack) print '\nList of available (registered) languages after registering a new language pack \n---------------------------------------' print get_available_language_codes() print '\nTransliteration to Example\n---------------------------------------' print translit(text, 'example') print '\nTransliterated lorem ipsum generator \n---------------------------------------' from transliterate.contrib.apps.translipsum import TranslipsumGenerator g_am = TranslipsumGenerator(language_code='hy') print 'Generating paragraphs' print g_am.generate_paragraph() g_ru = TranslipsumGenerator(language_code='ru') print '\nGenerating sentenses' print g_ru.generate_sentence() print '\nLanguage detection\n---------------------------------------' from transliterate.utils import detect_language print detect_language(u'Լօրեմ իպսում դօլօր սիտ ամետ') print detect_language(u'Лорем ипсум долор сит амет') print '\nSlugify\n---------------------------------------' from transliterate.utils import slugify print slugify(u'Լօրեմ իպսում դօլօր սիտ ամետ') print slugify(u'Лорем ипсум долор сит амет') print slugify(u'Lorem ipsum dolor sit amet') print '\nGeneral testing\n---------------------------------------' from transliterate.utils import get_available_language_packs for language_pack in get_available_language_packs(): print 'Testing language pack %s %s' % (language_pack.language_code, language_pack.language_name) print 'Reversed test:' for letter in language_pack.mapping[1]: print letter, ' --> ', translit(letter, language_pack.language_code, reversed=True) print 'Normal test:' for letter in language_pack.mapping[0]: print letter, ' --> ', translit(letter, language_pack.language_code) transliterate-1.10.2/example/example/settings.py000066400000000000000000000000001335001171700217400ustar00rootroot00000000000000transliterate-1.10.2/example/requirements.txt000066400000000000000000000000301335001171700213620ustar00rootroot00000000000000-r requirements/dev.txt transliterate-1.10.2/example/requirements/000077500000000000000000000000001335001171700206305ustar00rootroot00000000000000transliterate-1.10.2/example/requirements/code_style.txt000066400000000000000000000000231335001171700235160ustar00rootroot00000000000000pycodestyle pylint transliterate-1.10.2/example/requirements/common.txt000066400000000000000000000000001335001171700226470ustar00rootroot00000000000000transliterate-1.10.2/example/requirements/dev.txt000066400000000000000000000000701335001171700221440ustar00rootroot00000000000000-r code_style.txt -r common.txt -r docs.txt -r test.txt transliterate-1.10.2/example/requirements/docs.txt000066400000000000000000000001021335001171700223120ustar00rootroot00000000000000-r common.txt docutils Jinja2 MarkupSafe Sphinx sphinx-rtd-theme transliterate-1.10.2/example/requirements/test.txt000066400000000000000000000001221335001171700223430ustar00rootroot00000000000000factory_boy==2.7.0 fake-factory==0.7.2 pytest==3.0.2 pytest-cov==2.2.1 tox==2.1.1 transliterate-1.10.2/jupyter/000077500000000000000000000000001335001171700161545ustar00rootroot00000000000000transliterate-1.10.2/jupyter/README.rst000066400000000000000000000001761335001171700176470ustar00rootroot00000000000000Installation ============ .. code-block:: sh pip install jupyter Usage ===== .. code-block:: sh jupyter notebook transliterate-1.10.2/jupyter/transliterate.ipynb000066400000000000000000000052221335001171700221010ustar00rootroot00000000000000{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# `transliterate` workbook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "*Before you can start, you should make `transliterate` available, if you don't yet have it installed in your virtualenv*" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import os\n", "import sys\n", "\n", "sys.path.insert(0, os.path.abspath(os.path.join('..', 'src')))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Usage examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Simple usage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Import `translit` and `get_available_language_codes`" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from transliterate import translit, get_available_language_codes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Get the TLD name as string from the URL given" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "text = \"Lorem ipsum dolor sit amet\"\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Transliteration to Armenian" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Լօրեմ իպսում դօլօր սիտ ամետ\n" ] } ], "source": [ "print(translit(text, 'hy'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Transliteration to Georgian" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ლორემ იპსუმ დოლორ სით ამეთ\n" ] } ], "source": [ "print(translit(text, 'ka'))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" } }, "nbformat": 4, "nbformat_minor": 2 } transliterate-1.10.2/pytest.ini000066400000000000000000000004651335001171700165100ustar00rootroot00000000000000[pytest] norecursedirs= *.egg .git .tox .env _sass build dist migrations python_files = test_*.py tests.py addopts= --cov=transliterate --ignore=.tox --ignore=requirements --ignore=release --cov-report=html --cov-report=term --cov-report=annotate transliterate-1.10.2/requirements.txt000066400000000000000000000001401335001171700177310ustar00rootroot00000000000000factory_boy==2.7.0 fake-factory==0.7.2 Pillow==3.4.2 pytest==3.0.2 pytest-cov==2.2.1 tox==2.1.1 transliterate-1.10.2/runtests.py000077500000000000000000000003021335001171700167110ustar00rootroot00000000000000#!/usr/bin/env python import os import sys import pytest def main(): sys.path.insert(0, os.path.abspath('src')) return pytest.main() if __name__ == '__main__': sys.exit(main()) transliterate-1.10.2/scripts/000077500000000000000000000000001335001171700161415ustar00rootroot00000000000000transliterate-1.10.2/scripts/build_docs.sh000077500000000000000000000002231335001171700206040ustar00rootroot00000000000000#!/usr/bin/env bash ./scripts/prepare_docs.sh sphinx-build -n -a -b html docs builddocs cd builddocs && zip -r ../builddocs.zip . -x ".*" && cd ..transliterate-1.10.2/scripts/clean_up.sh000077500000000000000000000004301335001171700202630ustar00rootroot00000000000000find . -name "*.pyc" -exec rm -rf {} \; find . -name "__pycache__" -exec rm -rf {} \; find . -name "*.orig" -exec rm -rf {} \; find . -name "*.py,cover" -exec rm -rf {} \; rm -rf build/ rm -rf dist/ rm -rf .cache/ rm -rf htmlcov/ rm src/transliterate.egg-info -rf rm builddocs.ziptransliterate-1.10.2/scripts/install.sh000077500000000000000000000000301335001171700201370ustar00rootroot00000000000000python setup.py develop transliterate-1.10.2/scripts/make_release.sh000077500000000000000000000001561335001171700211170ustar00rootroot00000000000000./scripts/uninstall.sh ./scripts/clean_up.sh python setup.py register python setup.py sdist bdist_wheel uploadtransliterate-1.10.2/scripts/prepare_docs.sh000077500000000000000000000001721335001171700211460ustar00rootroot00000000000000#!/usr/bin/env bash cat README.rst docs/documentation.rst.distrib > docs/index.rst cat CHANGELOG.rst > docs/changelog.rst transliterate-1.10.2/scripts/pycodestyle.sh000077500000000000000000000000451335001171700210430ustar00rootroot00000000000000reset pycodestyle src/transliterate/ transliterate-1.10.2/scripts/pylint.sh000077500000000000000000000000401335001171700200110ustar00rootroot00000000000000reset pylint src/transliterate/ transliterate-1.10.2/scripts/rebuild_docs.sh000077500000000000000000000003671335001171700211440ustar00rootroot00000000000000#./scripts/uninstall.sh #./scripts/install.sh rm docs/*.rst rm -rf builddocs/ sphinx-apidoc src/transliterate --full -o docs -H 'transliterate' -A 'Artur Barseghyan ' -V '0.1' -f -d 20 cp docs/conf.distrib docs/conf.py transliterate-1.10.2/scripts/reinstall.sh000077500000000000000000000000611335001171700204720ustar00rootroot00000000000000reset ./scripts/uninstall.sh ./scripts/install.shtransliterate-1.10.2/scripts/test.sh000077500000000000000000000001471335001171700174610ustar00rootroot00000000000000#./scripts/uninstall.sh #reset #./scripts/install.sh #reset python src/transliterate/tests/__init__.py transliterate-1.10.2/scripts/uninstall.sh000077500000000000000000000001321335001171700205050ustar00rootroot00000000000000pip uninstall transliterate -y rm build -rf rm dist -rf rm src/transliterate.egg-info -rf transliterate-1.10.2/setup.cfg000066400000000000000000000000331335001171700162670ustar00rootroot00000000000000[bdist_wheel] universal = 1transliterate-1.10.2/setup.py000066400000000000000000000035431335001171700161710ustar00rootroot00000000000000import sys import os from setuptools import setup, find_packages try: readme = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read() except: readme = '' version = '1.10.2' install_requires = [ 'six>=1.1.0' ] tests_require = [ 'factory_boy', 'fake-factory', 'pytest', 'pytest-django', 'pytest-cov', 'tox' ] try: PY2 = sys.version_info[0] == 2 PY3 = sys.version_info[0] == 3 if PY2: install_requires.append('lorem-ipsum-generator==0.3') except: pass setup( name='transliterate', version=version, description="Bi-directional transliterator for Python", long_description=readme, classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy", "Intended Audience :: Developers", "Operating System :: OS Independent", "Development Status :: 4 - Beta", # "Natural Language :: Armenian", # "Natural Language :: Georgian", "Natural Language :: Bulgarian", "Natural Language :: Greek", "Natural Language :: Macedonian", "Natural Language :: Russian", "Natural Language :: Serbian", "Natural Language :: Ukrainian", ], keywords='translit, transliteration', author='Artur Barseghyan', author_email='artur.barseghyan@gmail.com', url='https://github.com/barseghyanartur/transliterate', package_dir={'': 'src'}, packages=find_packages(where='./src'), license='GPL 2.0/LGPL 2.1', install_requires=install_requires, tests_require=tests_require, include_package_data=True, ) transliterate-1.10.2/shell.py000077500000000000000000000003331335001171700161350ustar00rootroot00000000000000#!/usr/bin/env python import os import sys def main(): sys.path.insert(0, os.path.abspath('src')) from IPython import start_ipython start_ipython(argv=[]) if __name__ == '__main__': sys.exit(main()) transliterate-1.10.2/src/000077500000000000000000000000001335001171700152415ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/000077500000000000000000000000001335001171700201225ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/__init__.py000066400000000000000000000007611335001171700222370ustar00rootroot00000000000000from .utils import ( detect_language, get_available_language_codes, get_available_language_packs, get_translit_function, slugify, translit, ) __title__ = 'transliterate' __version__ = '1.10.2' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'detect_language', 'get_available_language_codes', 'get_available_language_packs', 'get_translit_function', 'slugify', 'translit', ) transliterate-1.10.2/src/transliterate/base.py000066400000000000000000000310701335001171700214070ustar00rootroot00000000000000# -*- coding: utf-8 -*- import re import unicodedata import six from .exceptions import ( ImproperlyConfigured, InvalidRegistryItemType ) __title__ = 'transliterate.base' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'registry', 'TranslitLanguagePack', ) class TranslitLanguagePack(object): """Base language pack. The attributes below shall be defined in every language pack. ``language_code``: Language code (obligatory). Example value: 'hy', 'ru'. ``language_name``: Language name (obligatory). Example value: 'Armenian', 'Russian'. ``character_ranges``: Character ranges that are specific to the language. When making a pack, check `this `_ page for the ranges. ``mapping``: Mapping (obligatory). A tuple, consisting of two strings (source and target). Example value: (u'abc', u'աբց'). ``reversed_specific_mapping``: Specific mapping (one direction only) used when transliterating from target script to source script (reversed transliteration). ՝՝pre_processor_mapping՝՝: Pre processor mapping (optional). A dictionary mapping for letters that can't be represented by a single latin letter. ՝՝reversed_specific_pre_processor_mapping՝՝: Pre processor mapping ( optional). A dictionary mapping for letters that can't be represented by a single latin letter (reversed transliteration). :example: >>> class ArmenianLanguagePack(TranslitLanguagePack): >>> language_code = "hy" >>> language_name = "Armenian" >>> character_ranges = ((0x0530, 0x058F), (0xFB10, 0xFB1F)) >>> mapping = ( >>> u"abgdezilxkhmjnpsvtrcq&ofABGDEZILXKHMJNPSVTRCQOF", # Source script >>> u"աբգդեզիլխկհմյնպսվտրցքևօֆԱԲԳԴԵԶԻԼԽԿՀՄՅՆՊՍՎՏՐՑՔՕՖ", # Target script >>> ) >>> reversed_specific_mapping = ( >>> u"ռՌ", >>> u"rR" >>> ) >>> pre_processor_mapping = { >>> # lowercase >>> u"e'": u"է", >>> u"y": u"ը", >>> u"th": u"թ", >>> u"jh": u"ժ", >>> u"ts": u"ծ", >>> u"dz": u"ձ", >>> u"gh": u"ղ", >>> u"tch": u"ճ", >>> u"sh": u"շ", >>> u"vo": u"ո", >>> u"ch": u"չ", >>> u"dj": u"ջ", >>> u"ph": u"փ", >>> u"u": u"ու", >>> >>> # uppercase >>> u"E'": u"Է", >>> u"Y": u"Ը", >>> u"Th": u"Թ", >>> u"Jh": u"Ժ", >>> u"Ts": u"Ծ", >>> u"Dz": u"Ձ", >>> u"Gh": u"Ղ", >>> u"Tch": u"Ճ", >>> u"Sh": u"Շ", >>> u"Vo": u"Ո", >>> u"Ch": u"Չ", >>> u"Dj": u"Ջ", >>> u"Ph": u"Փ", >>> u"U": u"Ու" >>> } >>> reversed_specific_pre_processor_mapping = { >>> u"ու": u"u", >>> u"Ու": u"U" >>> } Note, that in Python 3 you won't be using u prefix before the strings. """ language_code = None language_name = None character_ranges = None mapping = None reversed_specific_mapping = None reversed_pre_processor_mapping_keys = [] reversed_specific_pre_processor_mapping = None reversed_specific_pre_processor_mapping_keys = [] pre_processor_mapping = None pre_processor_mapping_keys = [] detectable = False characters = None reversed_characters = None def __init__(self): try: assert self.language_code is not None assert self.language_name is not None assert self.mapping except AssertionError: raise ImproperlyConfigured( "You should define ``language_code``, ``language_name`` and " "``mapping`` properties in your subclassed " "``TranslitLanguagePack`` class." ) super(TranslitLanguagePack, self).__init__() # Creating a translation table from the mapping set. self.translation_table = {} for key, val in zip(*self.mapping): self.translation_table.update({ord(key): ord(val)}) # Creating a reversed translation table. self.reversed_translation_table = dict( zip(self.translation_table.values(), self.translation_table.keys()) ) # If any pre-processor rules defined, reversing them for later use. if self.pre_processor_mapping: self.reversed_pre_processor_mapping = dict( zip( self.pre_processor_mapping.values(), self.pre_processor_mapping.keys()) ) self.pre_processor_mapping_keys = self.pre_processor_mapping.keys() self.reversed_pre_processor_mapping_keys = \ self.pre_processor_mapping.values() else: self.reversed_pre_processor_mapping = None if self.reversed_specific_mapping: self.reversed_specific_translation_table = {} for key, val in zip(*self.reversed_specific_mapping): self.reversed_specific_translation_table.update( {ord(key): ord(val)} ) if self.reversed_specific_pre_processor_mapping: self.reversed_specific_pre_processor_mapping_keys = \ self.reversed_specific_pre_processor_mapping.keys() self._characters = '[^]' if self.characters is not None: self._characters = '[^{0}]'.format( '\\'.join(list(self.characters)) ) self._reversed_characters = '[^]' if self.reversed_characters is not None: self._reversed_characters = \ '[^{0}]'.format('\\'.join(list(self.characters))) def translit(self, value, reversed=False, strict=False, fail_silently=True): """Transliterate the given value according to the rules. Rules are set in the transliteration pack. :param str value: :param bool reversed: :param bool strict: :param bool fail_silently: :return str: """ if not six.PY3: value = unicode(value) if reversed: # Handling reversed specific translations (one side only). if self.reversed_specific_mapping: value = value.translate( self.reversed_specific_translation_table ) if self.reversed_specific_pre_processor_mapping: for rule in self.reversed_specific_pre_processor_mapping_keys: value = value.replace( rule, self.reversed_specific_pre_processor_mapping[rule] ) # Handling pre-processor mappings. if self.reversed_pre_processor_mapping: for rule in self.reversed_pre_processor_mapping_keys: value = value.replace( rule, self.reversed_pre_processor_mapping[rule] ) return value.translate(self.reversed_translation_table) if self.pre_processor_mapping: for rule in self.pre_processor_mapping_keys: value = value.replace(rule, self.pre_processor_mapping[rule]) res = value.translate(self.translation_table) if strict: res = self._make_strict(value=res, reversed=reversed, fail_silently=fail_silently) return res def _make_strict(self, value, reversed=False, fail_silently=True): """Strip out unnecessary characters from the string. :param string value: :param bool reversed: :param bool fail_silently: :return string: """ try: return self.make_strict(value, reversed) except Exception as err: if fail_silently: return value else: raise err def make_strict(self, value, reversed=False): """Strip out unnecessary characters from the string. :param string value: :param bool reversed: :return string: """ if reversed: if self.reversed_characters: # Make strict based on the ``reversed_characters``. value = re.sub(self._reversed_characters, '', value) else: # Make strict based on the ``character_ranges`` specified. pass else: if self.characters: # Make strict based on the ``characters``. value = re.sub(self._characters, '', value) else: # Make strict based on the ``character_ranges`` specified. pass return value @classmethod def contains(cls, character): """Check if given character belongs to the language pack. :return bool: """ if cls.character_ranges: char_num = unicodedata.normalize('NFC', character) char_num = ord(char_num) for character_range in cls.character_ranges: range_lower = character_range[0] range_upper = character_range[1] if char_num >= range_lower and char_num <= range_upper: return True return False @classmethod def suggest(value, reversed=False, limit=None): """Suggest possible variants (some sort of auto-complete). :param str value: :param int limit: Limit number of suggested variants. :return list: """ # TODO @classmethod def detect(text, num_words=None): """Detect the language. Heavy language detection, which is activated for languages that are harder detect (like Russian Cyrillic and Ukrainian Cyrillic). :param unicode value: Input string. :param int num_words: Number of words to base decision on. :return bool: True if detected and False otherwise. """ # TODO class TranslitRegistry(object): """Language pack registry.""" def __init__(self): self._registry = {} self._forced = [] @property def registry(self): """Registry.""" return self._registry def register(self, cls, force=False): """Register the language pack in the registry. :param transliterate.base.LanguagePack cls: Subclass of ``transliterate.base.LanguagePack``. :param bool force: If set to True, item stays forced. It's not possible to un-register a forced item. :return bool: True if registered and False otherwise. """ if not issubclass(cls, TranslitLanguagePack): raise InvalidRegistryItemType( "Invalid item type `%s` for registry `%s`", cls, self.__class__ ) # If item has not been forced yet, add/replace its' value in the # registry. if force: if cls.language_code not in self._forced: self._registry[cls.language_code] = cls self._forced.append(cls.language_code) return True else: return False else: if cls.language_code in self._registry: return False else: self._registry[cls.language_code] = cls return True def unregister(self, cls): """Un-registers an item from registry. :param transliterate.base.LanguagePack cls: Subclass of ``transliterate.base.LanguagePack``. :return bool: True if unregistered and False otherwise. """ if not issubclass(cls, TranslitLanguagePack): raise InvalidRegistryItemType( "Invalid item type `%s` for registry `%s`", cls, self.__class__ ) # Only non-forced items are allowed to be unregistered. if cls.language_code in self._registry \ and cls.language_code not in self._forced: self._registry.pop(cls.language_code) return True else: return False def get(self, language_code, default=None): """Get the given language pack from the registry. :param str language_code: :return transliterate.base.LanguagePack: Subclass of ``transliterate.base.LanguagePack``. """ return self._registry.get(language_code, default) # Register languages by calling registry.register() registry = TranslitRegistry() transliterate-1.10.2/src/transliterate/conf.py000066400000000000000000000023001335001171700214140ustar00rootroot00000000000000from transliterate import defaults __title__ = 'transliterate.conf' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'get_setting', 'reset_to_defaults_settings', 'set_setting', 'settings', ) class Settings(object): """Settings registry.""" def __init__(self): self._settings = {} def set(self, name, value): """Override default settings. :param str name: :param mixed value: """ self._settings[name] = value def get(self, name, default=None): """Get a variable from local settings. :param str name: :param mixed default: Default value. :return mixed: """ if name in self._settings: return self._settings.get(name, default) elif hasattr(defaults, name): return getattr(defaults, name, default) else: return default def reset_to_defaults(self): """Reset settings to defaults.""" self._settings = {} settings = Settings() get_setting = settings.get set_setting = settings.set reset_to_defaults_settings = settings.reset_to_defaults transliterate-1.10.2/src/transliterate/contrib/000077500000000000000000000000001335001171700215625ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/__init__.py000066400000000000000000000000001335001171700236610ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/apps/000077500000000000000000000000001335001171700225255ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/apps/__init__.py000066400000000000000000000000001335001171700246240ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/apps/translipsum/000077500000000000000000000000001335001171700251065ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/apps/translipsum/README.rst000066400000000000000000000000331335001171700265710ustar00rootroot00000000000000Transliterated lorem ipsum.transliterate-1.10.2/src/transliterate/contrib/apps/translipsum/__init__.py000066400000000000000000000025021335001171700272160ustar00rootroot00000000000000from six import PY3 from transliterate.utils import translit if PY3: from transliterate.contrib.apps.translipsum.utils import Generator else: from lipsum import Generator __title__ = 'transliterate.contrib.apps.translipsum.__init__' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('TranslipsumGenerator',) class TranslipsumGenerator(Generator): """Lorem ipsum generator.""" def __init__(self, language_code, reversed=False, *args, **kwargs): self._language_code = language_code self._reversed = reversed super(TranslipsumGenerator, self).__init__(*args, **kwargs) def generate_sentence(self, *args, **kwargs): """Generate sentence.""" value = super(TranslipsumGenerator, self).generate_sentence( *args, **kwargs ) return translit(value, language_code=self._language_code, reversed=self._reversed) def generate_paragraph(self, *args, **kwargs): """Generate paragraph.""" value = super(TranslipsumGenerator, self).generate_paragraph( *args, **kwargs ) return translit(value, language_code=self._language_code, reversed=self._reversed) transliterate-1.10.2/src/transliterate/contrib/apps/translipsum/utils.py000066400000000000000000000246121335001171700266250ustar00rootroot00000000000000import random import re from six import PY3, text_type if not PY3: from string import translate, maketrans, punctuation else: from string import punctuation __title__ = 'transliterate.contrib.apps.translipsum.utils' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('Generator',) FACTORY = """ Sed dictum in tellus non iaculis. Aenean ac interdum ipsum. Etiam tempor quis ante vel rhoncus. Nulla facilisi. Curabitur iaculis consequat odio ut imperdiet? Integer accumsan; nisl vitae fermentum malesuada, sapien nulla sodales orci, et elementum lacus purus vel purus! Nullam orci neque, tristique in porta id, pretium ac sem. Fusce non est risus. Fusce convallis tellus augue, quis volutpat tellus dapibus sagittis. Integer lacinia commodo risus vel cursus. Etiam vitae dui in dolor porta luctus sed id elit. Nulla et est nec magna facilisis sagittis. Praesent tincidunt dictum lectus, sed aliquam eros. Donec placerat tortor ut lorem facilisis congue. Quisque ac risus nibh. Etiam ultrices nibh justo; sed mollis ipsum dapibus vitae. Ut vitae molestie erat. Mauris ac justo quis ante posuere vehicula. Vivamus accumsan mi volutpat diam lacinia, vitae semper lectus pharetra. Cras ultrices arcu nec viverra consectetur. Cras placerat ante quis dui consequat cursus. Nulla at enim dictum, consectetur ligula eget, vehicula nisi. Suspendisse eu ligula vitae est tristique accumsan nec adipiscing risus. Donec tempus dui eget mollis fringilla. Fusce eleifend lacus lectus, vel ornare felis lacinia ut. Morbi vel adipiscing augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras mattis pulvinar lacus, vitae pulvinar magna egestas non. Aliquam in urna quis leo feugiat faucibus. Aliquam erat volutpat. Maecenas non mauris libero. Suspendisse nisi lorem, cursus a tristique a, porttitor in nisl. Mauris pellentesque gravida mi non mattis. Cras mauris ligula, interdum semper tincidunt sed, ornare a ipsum. Nulla ultrices tempus tortor vitae vehicula. Etiam at augue suscipit, vehicula sapien sit amet; eleifend orci. Etiam venenatis leo nec cursus mattis. Nulla suscipit nec lorem et lobortis. Donec interdum vehicula massa sed aliquam. Praesent eleifend mi sed mi pretium pellentesque. In in nisi tincidunt, commodo lorem quis; tincidunt nisl. In suscipit quam a vehicula tincidunt! Fusce vitae varius nunc. Proin at ipsum ac tellus hendrerit ultricies. Phasellus auctor hendrerit sapien viverra facilisis. Suspendisse lacus erat, cursus at dolor in, vulputate convallis sapien. Etiam augue nunc, lobortis vel viverra sit amet, pretium et lacus. Pellentesque elementum lectus eget massa tempus elementum? Nulla nec auctor dolor. Aliquam congue purus quis libero fermentum cursus. Etiam quis massa ac nisl accumsan convallis vitae ac augue. Mauris neque est, posuere quis dolor non, volutpat gravida tortor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus ullamcorper, urna at ultrices aliquam, orci libero gravida ligula, non pulvinar sem magna sed tortor. Sed elementum leo viverra ipsum aliquet convallis. Suspendisse scelerisque auctor sapien. Mauris enim nisl, sollicitudin at rhoncus vitae, convallis nec mauris. Phasellus sollicitudin dui ut luctus consectetur. Vivamus placerat, neque id sagittis porttitor, nunc quam varius dolor, sit amet egestas nulla risus eu odio. Mauris gravida eleifend laoreet. Aenean a nulla nisl. Integer pharetra magna adipiscing, imperdiet augue ac, blandit felis. Cras id aliquam neque, vel consequat sapien.Duis eget vulputate ligula. Aliquam ornare dui non nunc laoreet, non viverra dolor semper. Aenean ullamcorper velit sit amet dignissim fermentum! Aenean urna leo, rutrum volutpat mauris nec, facilisis molestie tortor. In convallis pellentesque lorem, a lobortis erat molestie et! Ut sed sem a odio aliquam elementum. Morbi pretium velit libero, adipiscing consequat leo dignissim eu. Mauris vestibulum feugiat risus; quis pharetra purus tincidunt quis. Morbi semper tincidunt lorem id iaculis. Quisque non pulvinar magna. Morbi consequat eleifend neque et iaculis. Fusce non laoreet urna. Donec ut nunc ultrices, fringilla nunc ut, tempor elit. Phasellus semper sapien augue, in gravida neque egestas at. Integer dapibus lacus vitae luctus sagittis! Suspendisse imperdiet tortor eget mattis consectetur. Aliquam viverra purus a quam lacinia euismod. Nunc non consequat mi; ac vehicula lacus. Pellentesque accumsan ac diam in fermentum! Maecenas quis nibh sed dolor adipiscing facilisis. Aenean vel arcu eu est fermentum egestas vulputate eget purus. Sed fermentum rhoncus dapibus. Quisque molestie magna eu accumsan lobortis. Vestibulum cursus euismod posuere. Aliquam eu dapibus urna. Nulla id accumsan justo. Vivamus vitae ullamcorper tellus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.Donec pulvinar tempus lectus vitae ultricies. Vestibulum sagittis orci quis risus ultricies feugiat. Nunc feugiat velit est, at aliquam massa tristique eu. Aenean quis enim vel leo vestibulum volutpat in non elit. Quisque molestie tincidunt purus; ac lacinia mauris rhoncus in. Nullam id arcu at mauris varius viverra ut vitae massa. In ac nunc ipsum. Proin consectetur urna sit amet mattis vulputate. Nullam lacinia pretium tempus. Aenean quis ornare metus, tempus volutpat neque. Mauris volutpat scelerisque augue; at lobortis nulla rhoncus vitae. Mauris at lobortis turpis. Vivamus et ultrices lacus. Donec fermentum neque in eros cursus, ac tincidunt sapien consequat. Curabitur varius commodo rutrum. Nulla facilisi. Ut feugiat dui nec turpis sodales aliquam. Quisque auctor vestibulum condimentum. Quisque nec eros lorem. Curabitur et felis nec diam dictum ultrices vestibulum ac eros! Quisque eu pretium lacus. Morbi bibendum sagittis rutrum. Nam eget tellus quam. Nullam pharetra vestibulum justo. Donec molestie urna et scelerisque laoreet? Sed consectetur pretium hendrerit. Quisque erat nulla, elementum sit amet nibh vel, posuere pulvinar nulla. Donec elementum adipiscing dictum! Nam euismod semper nisi, eu lacinia felis placerat vel! Praesent eget dapibus turpis, et fringilla elit. Maecenas quis nunc cursus felis fringilla consequat! Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed ullamcorper libero quis nisl sollicitudin, ut pulvinar arcu consectetur. Donec nisi nibh, condimentum et lectus non, accumsan imperdiet ipsum. Maecenas vitae massa eget lorem ornare dignissim. Nullam condimentum mauris id quam tincidunt venenatis. Aenean mattis viverra sem, vitae luctus velit rhoncus non. Vestibulum leo justo, rhoncus at aliquam et, iaculis sed dolor. Integer bibendum vitae urna in ornare! Cras accumsan nulla eu libero tempus, in dignissim augue imperdiet. Vivamus a lacinia odio. Curabitur id egestas eros. Integer non rutrum est. In nibh sem, tempus ac dignissim vel, ornare ac mi. Nulla congue scelerisque est nec commodo. Phasellus turpis lorem, sodales quis sem id, facilisis commodo massa. Vestibulum ultrices dolor eget purus semper euismod? Fusce id congue leo. Quisque dui magna, ullamcorper et leo eget, commodo facilisis ipsum. Curabitur congue vitae risus nec posuere. Phasellus tempor ligula in nisl pellentesque mattis. Sed nunc turpis, pharetra vel leo ac, lacinia cursus risus. Quisque congue aliquet volutpat. Integer dictum est quis semper tristique. Donec feugiat vestibulum tortor, id fringilla nisi lobortis eu. Nam hendrerit egestas sem, non mollis tortor iaculis quis. Phasellus id aliquet erat. Nunc facilisis nisi dolor, quis semper dui euismod vel. Cras convallis bibendum tortor malesuada tincidunt. Sed urna quam, pellentesque eget eleifend ac, consequat bibendum urna. Sed fringilla elit hendrerit leo blandit laoreet eget quis quam! Morbi eu leo a dolor aliquet dictum. Suspendisse condimentum mauris non ipsum rhoncus, sit amet hendrerit augue gravida. Quisque facilisis pharetra felis faucibus gravida. In arcu neque, gravida ut fermentum ut, placerat eu quam. Nullam aliquet lectus mauris, quis dignissim est mollis sed. Ut vestibulum laoreet eros quis cursus. Proin commodo eros in mollis mollis. Mauris bibendum cursus nibh, sit amet eleifend mauris luctus vitae. Sed aliquet pretium tristique. Morbi ultricies augue a lacinia porta. Nullam mollis erat non imperdiet imperdiet. Etiam tincidunt fringilla ligula, in adipiscing libero viverra eu. Nunc gravida hendrerit massa, in pellentesque nunc dictum id. """ # Splits words if not PY3: def split_words(f): """Split words.""" return list( set( translate( f.lower(), maketrans(punctuation, ' ' * len(punctuation)) ).split() ) ) else: def split_words(f): """Split words.""" return list( set( f.lower().translate(str.maketrans("", "", punctuation)).split() ) ) def split(delimiters, value, max_split=0): """Split the value given by delimiters provided. :param str delimiters: :param str value: :param int max_split: :return list: """ value = re.sub(r'\s+', ' ', value) pattern = '|'.join(map(re.escape, delimiters)) return re.split(pattern, value, max_split) def split_sentences(f): """Split sentences.""" return split('!;?.', f) WORDS = split_words(FACTORY) SENTENCES = split_sentences(FACTORY) class Generator(object): """Fallback lorem ipsum generator for Python 3.""" def __init__(self, *args, **kwargs): pass def generate_word(self): """Generate word.""" return WORDS[random.randint(0, len(WORDS) - 1)] def generate_sentence(self): """Generate sentence.""" return text_type( SENTENCES[random.randint(0, len(SENTENCES) - 1)] + '.' ) def generate_paragraph(self, num_sentences=4): """Generate paragraph.""" _buffer = [] for val in range(0, 4): _buffer.append(self.generate_sentence()) return ''.join(_buffer) transliterate-1.10.2/src/transliterate/contrib/languages/000077500000000000000000000000001335001171700235305ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/__init__.py000066400000000000000000000000001335001171700256270ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/bg/000077500000000000000000000000001335001171700241205ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/bg/__init__.py000066400000000000000000000000001335001171700262170ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/bg/data/000077500000000000000000000000001335001171700250315ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/bg/data/__init__.py000066400000000000000000000000271335001171700271410ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/bg/data/default.py000066400000000000000000000010141335001171700270230ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvgdeziyklmnoprstufhABVGDEZIYKLMNOPRSTUFH", u"абвгдезийклмнопрстуфхАБВГДЕЗИЙКЛМНОПРСТУФХ", ) reversed_specific_mapping = ( u"ьъЪ", u"yaA" ) pre_processor_mapping = { u"zh": u"ж", u"ts": u"ц", u"ch": u"ч", u"sh": u"ш", u"sht": u"щ", u"yu": u"ю", u"ya": u"я", u"Zh": u"Ж", u"Ts": u"Ц", u"Ch": u"Ч", u"Sh": u"Ш", u"Sht": u"Щ", u"Yu": u"Ю", u"Ya": u"Я" } transliterate-1.10.2/src/transliterate/contrib/languages/bg/translit_language_pack.py000066400000000000000000000015421335001171700311750ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.bg import data __title__ = 'transliterate.contrib.languages.bg.translit_language_pack' __author__ = 'Petar Chakarov' __copyright__ = '2014-2015 Petar Chakarov' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('BulgarianLanguagePack',) class BulgarianLanguagePack(TranslitLanguagePack): """Language pack for Bulgarian language. See http://en.wikipedia.org/wiki/Romanization_of_Bulgarian for details. """ language_code = "bg" language_name = "Bulgarian" character_ranges = ((0x0400, 0x04FF), (0x0500, 0x052F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = False registry.register(BulgarianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/el/000077500000000000000000000000001335001171700241305ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/el/README.rst000066400000000000000000000032731335001171700256240ustar00rootroot00000000000000================================== transliterate.contrib.languages.el ================================== Transliterate language pack for Greek language. See `Greek alphabet `_ and `Romanization of Greek `_ for details. Useful to know ============== Excerpt from a `github issue `_: .. code-block:: text The 'ϑ' (the Greek theta symbol, http://unicode-table.com/en/03D1/) is not really used as a letter (as in I haven't seen a text containing it in prose in my whole life) in Modern Greek, at least in non handwritten text (handwritten text is so subjective, we probably should totally avoid discussing). The letter used in everyday text is 'θ' (http://unicode-table.com/en/03B8/). The most probable reason for this (and one that is semantically correct) is that Greek keyboard layouts will not emit 'ϑ' in any easy way but will emit 'θ'. Writing the symbol form requires either copy pasting, knowing the keyboard unicode key sequence or using a specialized program. 'ϑ' is used as a mathematical symbol. While using the letter form ('θ') in mathematics is acceptable, some mathematics professors encourage students to distinguish between 'ϑ' and 'θ' (even in handwriting) without however strongly enforcing the distinction (as in penalizing students for not using the correct form). So, your comment is correct with the caveat that if this library is ever used to transliterate a text (like a mathematical one or even this comment) conveying meaning via the use of the symbol, that meaning will be lost. Which is practically fine, I think. transliterate-1.10.2/src/transliterate/contrib/languages/el/__init__.py000066400000000000000000000000001335001171700262270ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/el/data/000077500000000000000000000000001335001171700250415ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/el/data/__init__.py000066400000000000000000000000271335001171700271510ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/el/data/default.py000066400000000000000000000021221335001171700270340ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"avgdeziklmnxoprstyfAVGDEZIKLMNXOPRSTYF", u"αβγδεζικλμνξοπρστυφΑΒΓΔΕΖΙΚΛΜΝΞΟΠΡΣΤΥΦ", ) reversed_specific_mapping = ( u"ςάέήίύόώϊϋΐΰωΩηΗϵϱ", u"saeiiyooiyiyooiier" ) pre_processor_mapping = { u"th": u"θ", u"Th": u"Θ", u"ch": u"χ", u"Ch": u"Χ", u"ps": u"ψ", u"Ps": u"Ψ", u"Gk": u"Γκ", u"gk": u"γκ", u"gx": u"γξ", u"nx": u"γξ", u"nch": u"γξ", u"gch": u"γξ", u"B": u"Μπ", u"Ev": u"Ευ", u"Ef": u"Ευ", u"Ey": u"Ευ", u"ev": u"ευ", u"ef": u"ευ", u"ey": u"ευ", u"Iv": u"Ηυ", u"If": u"Ηυ", u"Iy": u"Ηυ", u"iv": u"ηυ", u"if": u"ηυ", u"iy": u"ηυ", u"b": u"μπ", u"Au": u"Αυ", u"au": u"αυ", u"Eu": u"Ευ", u"eu": u"ευ", u"Ou": u"Ου", u"ou": u"ου", u"Oy": u"Ου", u"oy": u"ου", u"U": u"Υ", u"u": u"υ", u"Yi": u"Υι", u"yi": u"υι", u"Oi": u"Οι", u"oi": u"οι", u"ng": u"γγ", } transliterate-1.10.2/src/transliterate/contrib/languages/el/translit_language_pack.py000066400000000000000000000016271335001171700312110ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.el import data __title__ = 'transliterate.contrib.languages.el.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('GreekLanguagePack',) class GreekLanguagePack(TranslitLanguagePack): """Language pack for Greek language. See `http://en.wikipedia.org/wiki/Greek_alphabet` and `https://en.wikipedia.org/wiki/Romanization_of_Greek#Modern_Greek` for details. """ language_code = "el" language_name = "Greek" character_ranges = ((0x0370, 0x03FF), (0x1F00, 0x1FFF)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = True registry.register(GreekLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/he/000077500000000000000000000000001335001171700241245ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/he/__init__.py000066400000000000000000000000001335001171700262230ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/he/csv/000077500000000000000000000000001335001171700247175ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/he/csv/mapping.csv000066400000000000000000000004721335001171700270720ustar00rootroot00000000000000mapping ================================== a,א b,ב g,ג d,ד h,ה v,ו z,ז h,ח t,ט y,י k,ך m,ם n,ן s,ס p,ף q,ק r,ר t,ת u,ו o,וֹ reversed_specific_mapping ================================== k,כ l,ל m,מ n,נ p,פ pre_processor_mapping ================================== 'e,ע ts,ץ ts,צ sh,שtransliterate-1.10.2/src/transliterate/contrib/languages/he/translit_language_pack.py000066400000000000000000000030161335001171700311770ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry __title__ = 'transliterate.contrib.languages.he.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('HebrewLanguagePack',) class HebrewLanguagePack(TranslitLanguagePack): """Language pack for Hebrew language. See http://en.wikipedia.org/wiki/Hebrew_alphabet for details. See the http://en.wikipedia.org/wiki/Romanization_of_Hebrew#When_to_transliterate for transliteration details. Note, that this language pack implements the new standards (2006) of Hebrew Academy. Confirmed a אּ v ב b בּּּ ּg ג gg ג ּd ד dd דּ h ה h הּ v ו vv וּ z ז zz זּ """ language_code = "he" language_name = "Hebrew" character_ranges = ((0x0530, 0x058F), (0xFB10, 0xFB1F)) mapping = ( u"abgdvzhilmnsfckrt", # trkcfsnmlihzvdgbа u"אבגדוזחילמנספצקרת", ) reversed_specific_mapping = ( u"פ", # p u"p" ) pre_processor_mapping = { # lowercase u"ha'": u"ה", u"tt": u"ט", u"ka": u"כ", u"aa": u"ע", u"sh": u"ש", u"fs": u"ף", u"cs": u"ץ", u"ms": u"ם", u"ns": u"ן", u"ks": u"ך", } detectable = True # registry.register(HebrewLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/hi/000077500000000000000000000000001335001171700241305ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/hi/__init__.py000066400000000000000000000000001335001171700262270ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/hi/translit_language_pack.py000066400000000000000000000025531335001171700312100ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry __title__ = 'transliterate.contrib.languages.hi.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('HindiLanguagePack',) class HindiLanguagePack(TranslitLanguagePack): """Language pack for Hindi language. See `http://en.wikipedia.org/wiki/Hindi` for details. """ language_code = "hi" language_name = "Hindi" character_ranges = ((0x0900, 0x097f),) # Fill this in mapping = ( u"aeof", # AEOF u"अइओफ", # ae of ) # reversed_specific_mapping = ( # u"θΘ", # u"uU" # ) pre_processor_mapping = { u"b": u"बी", u"g": u"जी", u"d": u"डी", u"z": u"जड़", u"h": u"एच", u"i": u"आई", u"l": u"अल", u"m": u"ऍम", u"n": u"अन", u"x": u"अक्स", u"k": u"के", u"p": u"पी", u"r": u"आर", u"s": u"एस", u"t": u"टी", u"y": u"वाय", u"w": u"डब्लू", u"u": u"यू", u"c": u"सी", u"j": u"जे", u"q": u"क्यू", } detectable = True # registry.register(HindiLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/hy/000077500000000000000000000000001335001171700241505ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/hy/__init__.py000066400000000000000000000000001335001171700262470ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/hy/data/000077500000000000000000000000001335001171700250615ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/hy/data/__init__.py000066400000000000000000000003421335001171700271710ustar00rootroot00000000000000from .default import * __title__ = 'transliterate.contrib.languages.hy.data' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' # __all__ = ('ArmenianLanguagePack',) transliterate-1.10.2/src/transliterate/contrib/languages/hy/data/default.py000066400000000000000000000022751335001171700270650ustar00rootroot00000000000000# -*- coding: utf-8 -*- __title__ = 'transliterate.contrib.languages.hy.data.default' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'mapping', 'reversed_specific_mapping', 'reversed_specific_pre_processor_mapping', 'pre_processor_mapping', ) mapping = ( u"abgdezilxkhmjnpsvtrcq&ofABGDEZILXKHMJNPSVTRCQOF", u"աբգդեզիլխկհմյնպսվտրցքևօֆԱԲԳԴԵԶԻԼԽԿՀՄՅՆՊՍՎՏՐՑՔՕՖ", ) reversed_specific_mapping = ( u"ռՌ", u"rR" ) reversed_specific_pre_processor_mapping = { u"ու": u"u", u"Ու": u"U" } pre_processor_mapping = { # lowercase u"e'": u"է", u"y": u"ը", u"th": u"թ", u"jh": u"ժ", u"ts": u"ծ", u"dz": u"ձ", u"gh": u"ղ", u"tch": u"ճ", u"sh": u"շ", u"vo": u"ո", u"ch": u"չ", u"dj": u"ջ", u"ph": u"փ", u"u": u"ու", # uppercase u"E'": u"Է", u"Y": u"Ը", u"Th": u"Թ", u"Jh": u"Ժ", u"Ts": u"Ծ", u"Dz": u"Ձ", u"Gh": u"Ղ", u"Tch": u"Ճ", u"Sh": u"Շ", u"Vo": u"Ո", u"Ch": u"Չ", u"Dj": u"Ջ", u"Ph": u"Փ", u"U": u"Ու" } transliterate-1.10.2/src/transliterate/contrib/languages/hy/translit_language_pack.py000066400000000000000000000017001335001171700312210ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.hy import data __title__ = 'transliterate.contrib.languages.hy.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('ArmenianLanguagePack',) class ArmenianLanguagePack(TranslitLanguagePack): """Language pack for Armenian language. See `https://en.wikipedia.org/wiki/Armenian_alphabet` for details. """ language_code = "hy" language_name = "Armenian" character_ranges = ((0x0530, 0x058F), (0xFB10, 0xFB1F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping reversed_specific_pre_processor_mapping = \ data.reversed_specific_pre_processor_mapping pre_processor_mapping = data.pre_processor_mapping detectable = True registry.register(ArmenianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/ka/000077500000000000000000000000001335001171700241235ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ka/__init__.py000066400000000000000000000000001335001171700262220ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ka/data/000077500000000000000000000000001335001171700250345ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ka/data/__init__.py000066400000000000000000000000271335001171700271440ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/ka/data/default.py000066400000000000000000000007001335001171700270270ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"ABGDEVZTIKLMNOPJRSTUFQYCXHabgdevztiklmnoprsufqycxjhw", u"აბგდევზთიკლმნოპჟრსტუფქყცხჰაბგდევზთიკლმნოპრსუფქყცხჯჰწ", ) pre_processor_mapping = { u"zh": u"ჟ", u"gh": u"ღ", u"sh": u"შ", u"ch": u"ჩ", u"ch'": u"ჭ", u"dz": u"ძ", u"ts": u"წ", u"kh": u"ხ", } transliterate-1.10.2/src/transliterate/contrib/languages/ka/translit_language_pack.py000066400000000000000000000024561335001171700312050ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.ka import data __title__ = 'transliterate.contrib.languages.ka.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2015 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('GeorgianLanguagePack',) class GeorgianLanguagePack(TranslitLanguagePack): """Language pack for Georgian language. See `http://en.wikipedia.org/wiki/Georgian_alphabet for details. """ language_code = "ka" language_name = "Georgian" character_ranges = ((0x10A0, 0x10C5), (0x10D0, 0x10FC), (0x2D00, 0x2D25)) mapping = data.mapping pre_processor_mapping = data.pre_processor_mapping detectable = True def translit(self, value, reversed=False, strict=False, fail_silently=True): # Georgian language knows no capitals. Therefore, we convert # everything to lowercase. value = value.lower() # Continue the standard way return super(GeorgianLanguagePack, self).translit( value=value, reversed=reversed, strict=strict, fail_silently=fail_silently ) registry.register(GeorgianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/l1/000077500000000000000000000000001335001171700240445ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/l1/__init__.py000066400000000000000000000000001335001171700261430ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/l1/data/000077500000000000000000000000001335001171700247555ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/l1/data/__init__.py000066400000000000000000000000271335001171700270650ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/l1/data/default.py000066400000000000000000000013211335001171700267500ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abcdefghijklmnopqrstuvwxyzABCDEFGHILJKMNOPQRSTUVWXYZ", u"abcdefghijklmnopqrstuvwxyzABCDEFGHILJKMNOPQRSTUVWXYZ", ) reversed_specific_mapping = ( u"àÀáÁâÂãÃèÈéÉêÊëËìÌíÍîÎïÏðÐñÑòÒóÓôÔõÕùÙúÚûÛýÝÿŸ", u"aAaAaAaAeEeEeEeEiIiIiIiIdDnNoOoOoOaOuUuUuUyYyY", ) reversed_specific_pre_processor_mapping = { u"å": u"aa", u"Å": u"Aa", u"ä": u"ae", u"Ä": u"Ae", u"æ": u"ae", u"Æ": u"Ae", u"Ç": u"Ts", u"ç": u"ts", u"ð": u"dh", u"ö": u"oe", u"Ö": u"Oe", u"ø": u"oe", u"Ø": u"Oe", u"ü": u"ue", u"Ü": u"Ue", u"þ": u"th", u"Þ": u"Th", u"ß": u"ss", } transliterate-1.10.2/src/transliterate/contrib/languages/l1/translit_language_pack.py000066400000000000000000000020461335001171700311210ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.l1 import data __title__ = 'transliterate.contrib.languages.l1.translit_language_pack' __author__ = 'Marco Pattaro' __copyright__ = '2016-2017 Marco Pattaro' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('Latin1SupplementLanguagePack',) class Latin1SupplementLanguagePack(TranslitLanguagePack): """Language pack for Latin1 Supplement. Though not exactly a language, it's a set of commonly found unicode characters. See `http://en.wikipedia.org/wiki/Latin-1_Supplement_%28Unicode_block%29` for details. """ language_code = "l1" language_name = "Latin1 Supplement" character_ranges = ((0x00C0, 0x00D6), (0x00D8, 0x00F6), (0x00F8, 0x00FF)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping reversed_specific_pre_processor_mapping = \ data.reversed_specific_pre_processor_mapping detectable = True registry.register(Latin1SupplementLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/mk/000077500000000000000000000000001335001171700241375ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mk/__init__.py000066400000000000000000000000001335001171700262360ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mk/data/000077500000000000000000000000001335001171700250505ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mk/data/__init__.py000066400000000000000000000000271335001171700271600ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/mk/data/default.py000066400000000000000000000011241335001171700270440ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvgdezijklmnoprstufhcABVGDEZIJKLMNOPRSTUFHC", u"абвгдезијклмнопрстуфхцАБВГДЕЗИЈКЛМНОПРСТУФХЦ", ) reversed_specific_mapping = ( u"", u"" ) pre_processor_mapping = { u"gj": u"ѓ", u"zh": u"ж", u"dz": u"ѕ", u"lj": u"љ", u"nj": u"њ", u"кј": u"ќ", u"ch": u"ч", u"dzh": u"џ", u"sh": u"ш", u"Gj": u"Ѓ", u"Zh": u"Ж", u"Dz": u"Ѕ", u"Lj": u"Љ", u"Nj": u"Њ", u"Kj": u"Ќ", u"Ch": u"Ч", u"Dzh": u"Џ", u"Sh": u"Ш", } transliterate-1.10.2/src/transliterate/contrib/languages/mk/translit_language_pack.py000066400000000000000000000015471335001171700312210ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.mk import data __title__ = 'transliterate.contrib.languages.mk.translit_language_pack' __author__ = 'Igor Stamatovski' __copyright__ = '2016 Igor Stamatovski' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MacedonianLanguagePack',) class MacedonianLanguagePack(TranslitLanguagePack): """Language pack for Macedonian language. See http://en.wikipedia.org/wiki/Romanization_of_Macedonian for details. """ language_code = "mk" language_name = "Macedonian" character_ranges = ((0x0400, 0x04FF), (0x0500, 0x052F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = False registry.register(MacedonianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/mn/000077500000000000000000000000001335001171700241425ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mn/__init__.py000066400000000000000000000000001335001171700262410ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mn/data/000077500000000000000000000000001335001171700250535ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/mn/data/__init__.py000066400000000000000000000000271335001171700271630ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/mn/data/default.py000066400000000000000000000021401335001171700270460ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvgdjziklmnoprstuufhewABVGDJZIKLMNOPRSTUUFHEW", u"абвгджзиклмнопрстуүфхэвАБВГДЖЗИКЛМНОПРСТУҮФХЭВ", ) reversed_specific_mapping = ( u"ъьЪЬйЙөӨуУүҮ", u"iiIIiIoOuUuU" ) pre_processor_mapping = { u"ii": u"ы", u"II": u"Ы", u"ye": u"е", u"YE": u"Е", u"yo": u"ё", u"Yo": u"Ё", u"YO": u"Ё", u"ts": u"ц", u"TS": u"Ц", u"ch": u"ч", u"CH": u"Ч", u"sh": u"ш", u"SH": u"Ш", u"yu": u"ю", u"Yu": u"Юу", u"YU": u"Ю", u"ya": u"я", u"YA": u"Я", u"ai": u"ай", u"Ai": u"Ай", u"AI": u"АЙ", u"ei": u"эй", u"Ei": u"Эй", u"EI": u"ЭЙ", u"ii": u"ий", u"Ii": u"Ий", u"II": u"ИЙ", u"oi": u"ой", u"Oi": u"Ой", u"OI": u"ОЙ", u"ui": u"уй", u"Ui": u"Уй", u"UI": u"УЙ", u"KH": u"Х", u"kh": u"х" } reversed_specific_pre_processor_mapping = { u"щ": u"sh", u"Щ": u"SH", u"ю": u"yu", u"Ю": u"Yu", u"Ч": u"Ch", u"x": u"h" } transliterate-1.10.2/src/transliterate/contrib/languages/mn/translit_language_pack.py000066400000000000000000000015461335001171700312230ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.mn import data __title__ = 'transliterate.contrib.languages.mn.translit_language_pack' __author__ = 'Enkhbold Bataa' __copyright__ = '2016 Enkhbold Bataa' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('MongolianLanguagePack',) class MongolianLanguagePack(TranslitLanguagePack): """Language pack for Mongolian language. See `https://en.wikipedia.org/wiki/Mongolian_Cyrillic_alphabet` for details. """ language_code = "mn" language_name = "Mongolian" character_ranges = ((0x0400, 0x04FF), (0x0500, 0x052F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = False registry.register(MongolianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/ru/000077500000000000000000000000001335001171700241565ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/__init__.py000066400000000000000000000000001335001171700262550ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/000077500000000000000000000000001335001171700250675ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/__init__.py000066400000000000000000000000271335001171700271770ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/ala-lc.py000066400000000000000000000000001335001171700265600ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/default.py000066400000000000000000000010631335001171700270650ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvgdezijklmnoprstufhcC'y'ABVGDEZIJKLMNOPRSTUFH'Y'", u"абвгдезийклмнопрстуфхцЦъыьАБВГДЕЗИЙКЛМНОПРСТУФХЪЫЬ", ) reversed_specific_mapping = ( u"ёэЁЭъьЪЬ", u"eeEE''''" ) pre_processor_mapping = { u"zh": u"ж", u"ts": u"ц", u"ch": u"ч", u"sh": u"ш", u"sch": u"щ", u"ju": u"ю", u"ja": u"я", u"Zh": u"Ж", u"Ts": u"Ц", u"Ch": u"Ч", u"Sh": u"Ш", u"Sch": u"Щ", u"Ju": u"Ю", u"Ja": u"Я" } transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/gost_16876_71.py000066400000000000000000000000001335001171700274650ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/gost_52535_1_2006.py000066400000000000000000000000001335001171700300350ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/gost_7_79.py000066400000000000000000000000001335001171700271500ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/data/iso9.py000066400000000000000000000000001335001171700263120ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/ru/translit_language_pack.py000066400000000000000000000015241335001171700312330ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.ru import data __title__ = 'transliterate.contrib.languages.ru.translit_language_pack' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2015 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('RussianLanguagePack',) class RussianLanguagePack(TranslitLanguagePack): """Language pack for Russian language. See `http://en.wikipedia.org/wiki/Russian_alphabet` for details. """ language_code = "ru" language_name = "Russian" character_ranges = ((0x0400, 0x04FF), (0x0500, 0x052F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = True registry.register(RussianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/sr/000077500000000000000000000000001335001171700241545ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/sr/__init__.py000066400000000000000000000000001335001171700262530ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/sr/data/000077500000000000000000000000001335001171700250655ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/sr/data/__init__.py000066400000000000000000000000271335001171700271750ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/sr/data/default.py000066400000000000000000000006321335001171700270640ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvgdđežzijklmnoprstćufhcčšABVGDĐEŽZIJKLMNOPRSTĆUFHCČŠ", u"абвгдђежзијклмнопрстћуфхцчшАБВГДЂЕЖЗИЈКЛМНОПРСТЋУФХЦЧШ", ) reversed_specific_mapping = ( u"", ) pre_processor_mapping = { u"lj": u"љ", u"nj": u"њ", u"dž": u"џ", u"Lj": u"Љ", u"Nj": u"Њ", u"Dž": u"Џ", } transliterate-1.10.2/src/transliterate/contrib/languages/sr/translit_language_pack.py000066400000000000000000000015301335001171700312260ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.sr import data __title__ = 'transliterate.contrib.languages.sr.translit_language_pack' __author__ = 'Saša Kelečević' __copyright__ = '2017 Saša Kelečević' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('SerbianLanguagePack',) class SerbianLanguagePack(TranslitLanguagePack): """Language pack for Serbian language. See https://en.wikipedia.org/wiki/Romanization_of_Serbian for details. """ language_code = "sr" language_name = "Serbian" character_ranges = ((0x0408, 0x04F0), (0x0000, 0x017F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping detectable = False registry.register(SerbianLanguagePack) transliterate-1.10.2/src/transliterate/contrib/languages/uk/000077500000000000000000000000001335001171700241475ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/uk/__init__.py000066400000000000000000000000001335001171700262460ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/uk/data/000077500000000000000000000000001335001171700250605ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/contrib/languages/uk/data/__init__.py000066400000000000000000000000271335001171700271700ustar00rootroot00000000000000from .default import * transliterate-1.10.2/src/transliterate/contrib/languages/uk/data/default.py000066400000000000000000000012011335001171700270500ustar00rootroot00000000000000# -*- coding: utf-8 -*- mapping = ( u"abvhgdezyijklmnoprstuf'ABVHGDEZYIJKLMNOPRSTUF'", u"абвгґдезиійклмнопрстуфьАБВГҐДЕЗИІЙКЛМНОПРСТУФЬ", ) reversed_specific_mapping = ( u"ьЬ", u"''" ) pre_processor_mapping = { u"ye": u"є", u"zh": u"ж", u"yi": u"ї", u"kh": u"х", u"ts": u"ц", u"ch": u"ч", u"sh": u"ш", u"shch": u"щ", u"ju": u"ю", u"ja": u"я", u"Ye": u"Є", u"Zh": u"Ж", u"Yi": u"Ї", u"Kh": u"Х", u"Ts": u"Ц", u"Ch": u"Ч", u"Sh": u"Ш", u"Shch": u"Щ", u"Ju": u"Ю", u"Ja": u"Я" } transliterate-1.10.2/src/transliterate/contrib/languages/uk/translit_language_pack.py000066400000000000000000000015201335001171700312200ustar00rootroot00000000000000# -*- coding: utf-8 -*- from transliterate.base import TranslitLanguagePack, registry from transliterate.contrib.languages.uk import data __title__ = 'transliterate.contrib.languages.uk.translit_language_pack' __author__ = 'Timofey Pchelintsev' __copyright__ = '2014-2015 Timofey Pchelintsev' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('UkrainianLanguagePack',) class UkrainianLanguagePack(TranslitLanguagePack): """Language pack for Ukrainian language. See `http://en.wikipedia.org/wiki/Ukrainian_alphabet` for details. """ language_code = "uk" language_name = "Ukrainian" character_ranges = ((0x0400, 0x04FF), (0x0500, 0x052F)) mapping = data.mapping reversed_specific_mapping = data.reversed_specific_mapping pre_processor_mapping = data.pre_processor_mapping registry.register(UkrainianLanguagePack) transliterate-1.10.2/src/transliterate/decorators.py000066400000000000000000000030061335001171700226400ustar00rootroot00000000000000import six from .utils import translit __title__ = 'transliterate.decorators' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'transliterate_function', 'transliterate_method', ) class TransliterateFunction(object): """Function decorator.""" def __init__(self, language_code, reversed=False): self.language_code = language_code self.reversed = reversed def __call__(self, func): def inner(*args, **kwargs): if not six.PY3: value = unicode(func(*args, **kwargs)) else: value = func(*args, **kwargs) return translit(value, language_code=self.language_code, reversed=self.reversed) return inner transliterate_function = TransliterateFunction class TransliterateMethod(object): """Method decorator.""" def __init__(self, language_code, reversed=False): self.language_code = language_code self.reversed = reversed def __call__(self, func): def inner(this, *args, **kwargs): if not six.PY3: value = unicode(func(this, *args, **kwargs)) else: value = func(this, *args, **kwargs) return translit(value, language_code=self.language_code, reversed=self.reversed) return inner transliterate_method = TransliterateMethod transliterate-1.10.2/src/transliterate/defaults.py000066400000000000000000000007341335001171700223070ustar00rootroot00000000000000__title__ = 'transliterate.defaults' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'CONTRIB_DIR', 'DEBUG', 'LANGUAGE_DETECTION_MAX_NUM_KEYWORDS', 'LANGUAGE_PACK_MODULE_NAME', 'LANGUAGES_DIR', ) LANGUAGES_DIR = ('contrib', 'languages') CONTRIB_DIR = ('contrib', 'apps') LANGUAGE_PACK_MODULE_NAME = 'translit_language_pack' LANGUAGE_DETECTION_MAX_NUM_KEYWORDS = 16 DEBUG = False transliterate-1.10.2/src/transliterate/discover.py000066400000000000000000000024321335001171700223130ustar00rootroot00000000000000import os from six import print_ try: from importlib import import_module except ImportError: import_module = __import__ from .conf import get_setting from .helpers import PROJECT_DIR __title__ = 'transliterate.discover' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('autodiscover',) def autodiscover(): """Auto-discover the language packs in contrib/apps.""" languages_dir = get_setting('LANGUAGES_DIR') language_pack_module_name = get_setting('LANGUAGE_PACK_MODULE_NAME') debug = get_setting('DEBUG') for app_path in os.listdir(PROJECT_DIR(languages_dir)): full_app_path = list(languages_dir) full_app_path.append(app_path) if os.path.isdir(PROJECT_DIR(full_app_path)): try: import_module( "transliterate.{0}.{1}.{2}".format( '.'.join(languages_dir), app_path, language_pack_module_name ) ) except ImportError as err: if debug: print_(err) except Exception as err: if debug: print_(err) else: pass transliterate-1.10.2/src/transliterate/exceptions.py000066400000000000000000000021761335001171700226630ustar00rootroot00000000000000__title__ = 'transliterate.exceptions' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'ImproperlyConfigured', 'InvalidRegistryItemType', 'LanguageCodeError', 'LanguageDetectionError', 'LanguagePackNotFound', ) class LanguageCodeError(Exception): """Exception raised when language code is empty or has incorrect value.""" class ImproperlyConfigured(Exception): """Exception raised when developer didn't configure the code properly.""" class LanguagePackNotFound(Exception): """Exception raised when language pack is not found. Exception raised when language pack is not found for the language code given.""" class LanguageDetectionError(Exception): """Exception raised when language can't be detected. Exception raised when language can't be detected for the text given. """ class InvalidRegistryItemType(ValueError): """Raised when an attempt is made to register an item in the registry. Raised when an attempt is made to register an item in the registry which does not have a proper type. """ transliterate-1.10.2/src/transliterate/helpers.py000066400000000000000000000011621335001171700221360ustar00rootroot00000000000000import os import sys __title__ = 'transliterate.helpers' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'PROJECT_DIR', 'project_dir', 'PY32', ) try: PY32 = (sys.version_info[0] == 3 and sys.version_info[1] == 2) except Exception as err: PY32 = False def project_dir(base): """Project dir.""" return os.path.abspath( os.path.join( os.path.dirname(__file__), (os.path.join(*base) if isinstance(base, (list, tuple)) else base) ).replace('\\', '/') ) PROJECT_DIR = project_dir transliterate-1.10.2/src/transliterate/tests/000077500000000000000000000000001335001171700212645ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/tests/__init__.py000066400000000000000000000002061335001171700233730ustar00rootroot00000000000000import unittest from transliterate.tests.test_transliterate import TransliterateTest if __name__ == '__main__': unittest.main() transliterate-1.10.2/src/transliterate/tests/base.py000066400000000000000000000002251335001171700225470ustar00rootroot00000000000000__title__ = 'transliterate.tests.base' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' transliterate-1.10.2/src/transliterate/tests/data/000077500000000000000000000000001335001171700221755ustar00rootroot00000000000000transliterate-1.10.2/src/transliterate/tests/data/__init__.py000066400000000000000000000002551335001171700243100ustar00rootroot00000000000000from .default import * __title__ = 'transliterate.tests.data' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' transliterate-1.10.2/src/transliterate/tests/data/default.py000066400000000000000000000035701335001171700242000ustar00rootroot00000000000000# -*- coding: utf-8 -*- __title__ = 'transliterate.tests.data.default' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' latin_text = u"Lorem ipsum dolor sit amet" armenian_text = u'Լօրեմ իպսում դօլօր սիտ ամետ' cyrillic_text = u'Лорем ипсум долор сит амет' ukrainian_cyrillic_text = u'Лорем іпсум долор сіт амет' bulgarian_cyrillic_text = u'Лорем ипсум долор сит амет' georgian_text = u'ლორემ იპსუმ დოლორ სით ამეთ' greek_text = u'Λορεμ ιψυμ δολορ σιτ αμετ' hebrew_text = u'Lורeמ יpסuמ דולור סית אמeת' mongolian_cyrillic_text = u'Лорэм ипсүм долор сит амэт' serbian_cyrillic_text = u'Лорем ипсум долор сит амет' pangram_serbian_cyrillic_text = u'Фијуче ветар у шибљу, леди пасаже и куће ' \ u'иза њих и гунђа у оџацима' pangram_serbian_latin_text = u'Fijuče vetar u šiblju, ledi pasaže i kuće ' \ u'iza njih i gunđa u odžacima' test_15_register_custom_language_pack_mapping = ( u"abcdefghij", u"1234567890", ) test_33_register_unregister_mapping = ( u"abcdefghij", u"1234567890", ) test_34_latin_to_latin_mapping = ( u"abgdezilxkhmjnpsvtrcqw&ofABGDEZILXKHMJNPSVTRCQOFW", u"zbgdeailxkhnjmpswtrcqv&ofZBGDEAILXKHNJMPSWTRCQOFV", ) test_34_latin_to_latin_characters = u"abgdezilxkhmjnpsvtrcqw&of" \ u"ABGDEZILXKHMJNPSVTRCQOFW" test_34_latin_to_latin_reversed_characters = u"abgdezilxkhmjnpsvtrcqw&of" \ u"ABGDEZILXKHMJNPSVTRCQOFW" test_34_latin_to_latin_text = u"Lorem ipsum dolor sit amet 123453254593485938" transliterate-1.10.2/src/transliterate/tests/defaults.py000066400000000000000000000003021335001171700234400ustar00rootroot00000000000000__title__ = 'transliterate.tests.defaults' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('LOG_INFO',) LOG_INFO = True transliterate-1.10.2/src/transliterate/tests/helpers.py000066400000000000000000000020421335001171700232760ustar00rootroot00000000000000import logging import six from .defaults import LOG_INFO __title__ = 'transliterate.tests.helpers' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'log_info', 'py2only', ) LOGGER = logging.getLogger(__name__) def log_info(func): """Print some useful info.""" if not LOG_INFO: return func def inner(self, *args, **kwargs): result = func(self, *args, **kwargs) LOGGER.debug('\n%s', func.__name__) LOGGER.debug('============================') LOGGER.debug('""" %s """', func.__doc__.strip()) LOGGER.debug('----------------------------') if result is not None: try: LOGGER.debug(result) except Exception: LOGGER.debug(result.encode('utf8')) return result return inner def py2only(func): """Skip the test on Python 3.""" if not six.PY3: return func def dummy(self, *args, **kwargs): pass return dummy transliterate-1.10.2/src/transliterate/tests/test_transliterate.py000066400000000000000000000524541335001171700255700ustar00rootroot00000000000000# -*- coding: utf-8 -*- from __future__ import absolute_import import logging import unittest from .. import ( defaults, detect_language, get_available_language_codes, get_available_language_packs, get_translit_function, slugify, translit, ) from ..base import TranslitLanguagePack, registry from ..conf import ( get_setting, reset_to_defaults_settings, set_setting, ) from ..contrib.apps.translipsum import TranslipsumGenerator from ..decorators import ( transliterate_function, transliterate_method, ) from ..discover import autodiscover from . import data from .helpers import log_info __title__ = 'transliterate.tests.test_transliterate' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ('TransliterateTest',) LOGGER = logging.getLogger(__name__) class TransliterateTest(unittest.TestCase): """Test ``transliterate.utils.translit``.""" def setUp(self): """Set up.""" self.latin_text = data.latin_text self.armenian_text = data.armenian_text self.cyrillic_text = data.cyrillic_text self.ukrainian_cyrillic_text = data.ukrainian_cyrillic_text self.bulgarian_cyrillic_text = data.bulgarian_cyrillic_text self.georgian_text = data.georgian_text self.greek_text = data.greek_text self.hebrew_text = data.hebrew_text self.mongolian_cyrillic_text = data.mongolian_cyrillic_text self.serbian_cyrillic_text = data.serbian_cyrillic_text self.pangram_serbian_cyrillic_text = data.pangram_serbian_cyrillic_text self.pangram_serbian_latin_text = data.pangram_serbian_latin_text # reset_to_defaults_settings() @log_info def test_01_get_available_language_codes(self): """Test ``autodiscover`` and ``get_available_language_codes``.""" res = get_available_language_codes() res.sort() c = [ 'bg', 'el', 'hy', 'ka', 'l1', 'mk', 'mn', 'ru', 'sr', 'uk', ] c.sort() self.assertEqual(res, c) return res @log_info def test_02_translit_latin_to_armenian(self): """Test transliteration from Latin to Armenian.""" res = translit(self.latin_text, 'hy') self.assertEqual(res, self.armenian_text) return res @log_info def test_03_translit_latin_to_georgian(self): """Test transliteration from Latin to Georgian.""" res = translit(self.latin_text, 'ka') self.assertEqual(res, self.georgian_text) return res @log_info def test_04_translit_latin_to_greek(self): """Test transliteration from Latin to Greek.""" res = translit(self.latin_text, 'el') self.assertEqual(res, self.greek_text) return res @log_info def __test_05_translit_latin_to_hebrew(self): """Test transliteration from Latin to Hebrew.""" res = translit(self.latin_text, 'he') self.assertEqual(res, self.hebrew_text) return res @log_info def test_06_translit_latin_to_cyrillic(self): """Test transliteration from Latin to Cyrillic.""" res = translit(self.latin_text, 'ru') self.assertEqual(res, self.cyrillic_text) return res @log_info def test_06_translit_latin_to_ukrainian_cyrillic(self): """Test transliteration from Latin to Ukrainian Cyrillic.""" res = translit(self.latin_text, 'uk') self.assertEqual(res, self.ukrainian_cyrillic_text) return res @log_info def test_06_translit_latin_to_bulgarian_cyrillic(self): """Test transliteration from Latin to Bulgarian Cyrillic.""" res = translit(self.latin_text, 'bg') self.assertEqual(res, self.bulgarian_cyrillic_text) return res @log_info def test_06_translit_latin_to_mongolian_cyrillic(self): """Test transliteration from Latin to Mongolian Cyrillic.""" res = translit(self.latin_text, 'mn') self.assertEqual(res, self.mongolian_cyrillic_text) return res @log_info def test_06_translit_latin_to_serbian_cyrillic(self): """Test transliteration from Latin to Serbian Cyrillic.""" res = translit(self.latin_text, 'sr') self.assertEqual(res, self.serbian_cyrillic_text) return res @log_info def test_07_translit_armenian_to_latin(self): """Test transliteration from Armenian to Latin.""" res = translit(self.armenian_text, 'hy', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_08_translit_georgian_to_latin(self): """Test transliteration from Georgian to Latin.""" res = translit(self.georgian_text, 'ka', reversed=True) self.assertEqual(res.capitalize(), self.latin_text) return res @log_info def test_09_translit_greek_to_latin(self): """Test transliteration from Greek to Latin.""" res = translit(self.greek_text, 'el', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def __test_10_translit_hebrew_to_latin(self): """Test transliteration from Hebrew to Latin.""" res = translit(self.hebrew_text, 'he', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_11_translit_cyrillic_to_latin(self): """Test transliteration from Cyrillic to Latin.""" res = translit(self.cyrillic_text, 'ru', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_11_translit_ukrainian_cyrillic_to_latin(self): """Test transliteration from Ukrainian Cyrillic to Latin.""" res = translit(self.ukrainian_cyrillic_text, 'uk', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_11_translit_bulgarian_cyrillic_to_latin(self): """Test transliteration from Bulgarian Cyrillic to Latin.""" res = translit(self.bulgarian_cyrillic_text, 'bg', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_11_translit_mongolian_cyrillic_to_latin(self): """Test transliteration from Mongolian Cyrillic to Latin.""" res = translit(self.mongolian_cyrillic_text, 'mn', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_11_translit_serbian_cyrillic_to_latin(self): """Test transliteration from Serbian Cyrillic to Latin.""" res = translit(self.serbian_cyrillic_text, 'sr', reversed=True) self.assertEqual(res, self.latin_text) return res @log_info def test_12_function_decorator(self): """Test the function decorator from Latin to Armenian.""" @transliterate_function(language_code='hy') def decorator_test_armenian(text): return text res = decorator_test_armenian(self.latin_text) self.assertEqual(res, self.armenian_text) @log_info def test_13_method_decorator(self): """Test the method decorator from Latin to Cyrillic.""" class DecoratorTest(object): @transliterate_method(language_code='ru') def decorator_test_russian(self, text): return text res = DecoratorTest().decorator_test_russian(self.latin_text) self.assertEqual(res, self.cyrillic_text) return res @log_info def test_14_function_decorator(self): """Test the function decorator (reversed) from Armenian to Latin.""" @transliterate_function(language_code='hy', reversed=True) def decorator_test_armenian_reversed(text): return text res = decorator_test_armenian_reversed(self.armenian_text) self.assertEqual(res, self.latin_text) return res @log_info def test_15_register_custom_language_pack(self): """Test registering of a custom language pack.""" class ExampleLanguagePack(TranslitLanguagePack): """Example language pack.""" language_code = "example" language_name = "Example" mapping = data.test_15_register_custom_language_pack_mapping registry.register(ExampleLanguagePack) assert 'example' in get_available_language_codes() res = translit(self.latin_text, 'example') self.assertEqual(res, 'Lor5m 9psum 4olor s9t 1m5t') return res @log_info def test_16_translipsum_generator_armenian(self): """Test the translipsum generator. Generating lorem ipsum paragraphs in Armenian. """ g_am = TranslipsumGenerator(language_code='hy') res = g_am.generate_paragraph() assert res return res @log_info def test_17_translipsum_generator_georgian(self): """Test the translipsum generator. Generating lorem ipsum sentence in Georgian. """ g_ge = TranslipsumGenerator(language_code='ka') res = g_ge.generate_sentence() assert res return res @log_info def test_18_translipsum_generator_greek(self): """Test the translipsum generator Generating lorem ipsum sentence in Greek. """ g_el = TranslipsumGenerator(language_code='el') res = g_el.generate_sentence() assert res return res @log_info def __test_19_translipsum_generator_hebrew(self): """Test the translipsum generator. Generating lorem ipsum sentence in Hebrew. """ g_he = TranslipsumGenerator(language_code='he') res = g_he.generate_sentence() assert res return res @log_info def test_20_translipsum_generator_cyrillic(self): """Test the translipsum generator. Generating lorem ipsum sentence in Cyrillic. """ g_ru = TranslipsumGenerator(language_code='ru') res = g_ru.generate_sentence() assert res return res @log_info def test_20_translipsum_generator_ukrainian_cyrillic(self): """Test the translipsum generator. Generating lorem ipsum sentence in Ukrainian Cyrillic. """ g_uk = TranslipsumGenerator(language_code='uk') res = g_uk.generate_sentence() assert res return res @log_info def test_20_translipsum_generator_bulgarian_cyrillic(self): """Test the translipsum generator. Generating lorem ipsum sentence in Bulgarian Cyrillic. """ g_bg = TranslipsumGenerator(language_code='bg') res = g_bg.generate_sentence() assert res return res @log_info def test_20_translipsum_generator_mongolian_cyrillic(self): """Test the translipsum generator. Generating lorem ipsum sentence in Mongolian Cyrillic. """ g_bg = TranslipsumGenerator(language_code='mn') res = g_bg.generate_sentence() assert res return res @log_info def test_20_translipsum_generator_serbian_cyrillic(self): """Test the translipsum generator. Generating lorem ipsum sentence in Serbian Cyrillic. """ g_bg = TranslipsumGenerator(language_code='sr') res = g_bg.generate_sentence() assert res return res @log_info def test_21_language_detection_armenian(self): """Test language detection. Detecting Armenian.""" res = detect_language(self.armenian_text) self.assertEqual(res, 'hy') return res @log_info def test_22_language_detection_georgian(self): """Test language detection. Detecting Georgian. """ res = detect_language(self.georgian_text) self.assertEqual(res, 'ka') return res @log_info def test_23_language_detection_greek(self): """Test language detection. Detecting Greek. """ res = detect_language(self.greek_text) self.assertEqual(res, 'el') return res @log_info def __test_24_language_detection_hebrew(self): """Test language detection. Detecting Hebrew. """ res = detect_language(self.hebrew_text) self.assertEqual(res, 'he') return res @log_info def test_25_language_detection_cyrillic(self): """Test language detection. Detecting Russian (Cyrillic). """ res = detect_language(self.cyrillic_text) self.assertEqual(res, 'ru') return res @log_info def test_25_false_language_detection_cyrillic(self): """Test language detection. Detecting is not Russian (Cyrillic). """ res = detect_language(self.latin_text) self.assertNotEqual(res, 'ru') return res @log_info def __test_25_language_detection_ukrainian_cyrillic(self): """Testing language detection. Detecting Ukrainian (Cyrillic).""" res = detect_language(self.ukrainian_cyrillic_text) self.assertEqual(res, 'uk') return res @log_info def __test_25_language_detection_bulgarian_cyrillic(self): """Test language detection. Detecting Bulgarian (Cyrillic).""" res = detect_language(self.bulgarian_cyrillic_text) self.assertEqual(res, 'bg') return res @log_info def __test_25_language_detection_mongolian_cyrillic(self): """Test language detection. Detecting Mongolian (Cyrillic). """ res = detect_language(self.mongolian_cyrillic_text) self.assertEqual(res, 'mn') return res @log_info def __test_25_language_detection_serbian_cyrillic(self): """Test language detection. Detecting Serbian (Cyrillic). """ res = detect_language(self.serbian_cyrillic_text) self.assertEqual(res, 'sr') return res @log_info def test_26_slugify_armenian(self): """Test slugify from Armenian.""" res = slugify(self.armenian_text) self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_27_slugify_georgian(self): """Test slugify from Georgian.""" res = slugify(self.georgian_text) self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_28_slugify_greek(self): """Test slugify from Greek.""" res = slugify(self.greek_text) self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def __test_29_slugify_hebrew(self): """Test slugify from Hebrew.""" res = slugify(self.hebrew_text) self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_30_slugify_cyrillic(self): """Test slugify from Cyrillic.""" res = slugify(self.cyrillic_text) self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_30_slugify_ukrainian_cyrillic(self): """Test slugify from Ukrainian Cyrillic.""" res = slugify(self.ukrainian_cyrillic_text, language_code='uk') self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_30_slugify_bulgarian_cyrillic(self): """Test slugify from Bulgarian Cyrillic.""" res = slugify(self.bulgarian_cyrillic_text, language_code='bg') self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_30_slugify_mongolian_cyrillic(self): """Test slugify from Mongolian Cyrillic.""" res = slugify(self.mongolian_cyrillic_text, language_code='mn') self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_30_slugify_serbian_cyrillic(self): """Test slugify from Serbian Cyrillic.""" res = slugify(self.serbian_cyrillic_text, language_code='sr') self.assertEqual(res, 'lorem-ipsum-dolor-sit-amet') return res @log_info def test_31b_get_translit_function(self): """Test transliteration using get_translit_function.""" translit_function = get_translit_function('hy') # Test Latin to Armenian res = translit_function(self.latin_text) self.assertEqual(res, self.armenian_text) # Test Armenian to Latin res = translit_function(self.armenian_text, reversed=True) self.assertEqual(res, self.latin_text) @log_info def test_31_override_settings(self): """Testing settings override.""" def override_settings(): return get_setting('LANGUAGE_DETECTION_MAX_NUM_KEYWORDS') self.assertEqual(defaults.LANGUAGE_DETECTION_MAX_NUM_KEYWORDS, override_settings()) set_setting('LANGUAGE_DETECTION_MAX_NUM_KEYWORDS', 10) self.assertEqual(10, override_settings()) return override_settings() @log_info def test_32_auto_translit_reversed(self): """Test automatic reversed translit. Test automatic reversed translit (from target script to source script) for Armenian, Georgian, Greek, Russian (Cyrillic) and Serbian (Cyrillic). """ res = [] texts = [ self.armenian_text, self.georgian_text, self.greek_text, self.cyrillic_text, self.serbian_cyrillic_text ] for text in texts: r = translit(text, reversed=True) self.assertEqual(r.capitalize(), self.latin_text) res.append(r) return res @log_info def test_33_register_unregister(self): """Testing register/un-register.""" from transliterate.contrib.languages.hy.translit_language_pack import ( ArmenianLanguagePack ) class A(TranslitLanguagePack): """Test class.""" language_code = "ru" language_name = "Example" mapping = data.test_33_register_unregister_mapping # Since key `ru` already exists in the registry it can't be replaced # (without force-register). res = registry.register(A) self.assertTrue(not res) # Now with force-register it can. res = registry.register(A, force=True) self.assertTrue(res) # Once we have it there and it's forced, we can't register another. res = registry.register(A, force=True) self.assertTrue(not res) # Un-register non-forced language pack. res = registry.unregister(ArmenianLanguagePack) self.assertTrue( res and ArmenianLanguagePack.language_code not in get_available_language_codes() ) res = registry.unregister(A) self.assertTrue( not res and A.language_code in get_available_language_codes() ) @log_info def __test_34_latin_to_latin(self): """Test latin to latin.""" class LatinToLatinLanguagePack(TranslitLanguagePack): """ Custom language pack which gets rid of accented characters in Greek but leaves other characters intact. """ language_code = "l2l" language_name = "Latin to Latin" mapping = data.test_34_latin_to_latin_mapping characters = data.test_34_latin_to_latin_characters reversed_characters = \ data.test_34_latin_to_latin_reversed_characters res = registry.register(LatinToLatinLanguagePack) self.assertTrue(res) text = data.test_34_latin_to_latin_text pack = LatinToLatinLanguagePack() res = pack.translit(text, strict=True, fail_silently=False) @log_info def __test_29_mappings(self): """Test mappings.""" for language_pack in get_available_language_packs(): LOGGER.debug( 'Testing language pack %s %s', language_pack.language_code, language_pack.language_name ) LOGGER.debug('Reversed test:') for letter in language_pack.mapping[1]: LOGGER.debug( ( letter, ' --> ', translit( letter, language_pack.language_code, reversed=True ) ) ) LOGGER.debug('Normal test:') for letter in language_pack.mapping[0]: LOGGER.debug( ( letter, ' --> ', translit(letter, language_pack.language_code) ) ) @log_info def test_35_translit_serbian_latin_to_serbian_cyrillic(self): """Test transliteration from Serbian Latin to Serbian Cyrillic.""" res = translit(self.pangram_serbian_latin_text, 'sr') self.assertEqual(res, self.pangram_serbian_cyrillic_text) return res @log_info def test_35_translit_serbian_cyrillic_to_serbian_latin(self): """Test transliteration from Serbian Cyrillic to Serbian Latin.""" res = translit(self.pangram_serbian_cyrillic_text, 'sr', reversed=True) self.assertEqual(res, self.pangram_serbian_latin_text) return res if __name__ == '__main__': unittest.main() transliterate-1.10.2/src/transliterate/utils.py000066400000000000000000000152471335001171700216450ustar00rootroot00000000000000from collections import Counter import logging import re import unicodedata from .base import registry from .conf import get_setting from .discover import autodiscover from .exceptions import ( LanguageCodeError, LanguageDetectionError, LanguagePackNotFound, ) LOGGER = logging.getLogger(__name__) __title__ = 'transliterate.utils' __author__ = 'Artur Barseghyan' __copyright__ = '2013-2018 Artur Barseghyan' __license__ = 'GPL 2.0/LGPL 2.1' __all__ = ( 'detect_language', 'get_available_language_codes', 'get_available_language_packs', 'get_translit_function', 'slugify', 'suggest', 'translit', ) def _(val): """Fake translation wrapper.""" return val def ensure_autodiscover(): """Ensure autodiscover.""" # Running autodiscover if registry is empty if not registry.registry: autodiscover() def get_translit_function(language_code): """Return translit function for the language given. :param str language_code: :return callable: """ ensure_autodiscover() cls = registry.get(language_code) if cls is None: raise LanguagePackNotFound( _("Language pack for code %s is not found." % language_code) ) language_pack = cls() return language_pack.translit def translit(value, language_code=None, reversed=False, strict=False): """Transliterate the text for the language given. Language code is optional in case of reversed translations (from some script to latin). :param str value: :param str language_code: :param bool reversed: If set to True, reversed translation is made. :param bool strict: If given, all that are not found in the transliteration pack, are simply stripped out. :return str: """ ensure_autodiscover() if language_code is None and reversed is False: raise LanguageCodeError( _("``language_code`` is optional with ``reversed`` set to True " "only.") ) if language_code is None: language_code = detect_language(value, fail_silently=False) cls = registry.get(language_code) if cls is None: raise LanguagePackNotFound( _("Language pack for code %s is not found." % language_code) ) language_pack = cls() return language_pack.translit(value, reversed=reversed, strict=strict) def suggest(value, language_code=None, reversed=False, limit=None): """Suggest possible variants. :param str value: :param str language_code: :param bool reversed: If set to True, reversed translation is made. :param int limit: Limit number of suggested variants. :return list: """ ensure_autodiscover() if language_code is None and reversed is False: raise LanguageCodeError( _("``language_code`` is optional with ``reversed`` set to True " "only.") ) cls = registry.get(language_code) if cls is None: raise LanguagePackNotFound( _("Language pack for code %s is not found." % language_code) ) language_pack = cls() return language_pack.suggest(value, reversed=reversed, limit=limit) def get_available_language_codes(): """Get list of language codes for registered language packs. :return list: """ ensure_autodiscover() return [key for (key, val) in registry.registry.items()] def get_available_language_packs(): """Get list of registered language packs. :return list: """ ensure_autodiscover() return [val for (key, val) in registry.registry.items()] def get_language_pack(language_code): """Get registered language pack by language code given. :param str language_code: :return transliterate.base.TranslitLanguagePack: Returns None on failure. """ ensure_autodiscover() return registry.registry.get(language_code, None) # Strips numbers from unicode string. def strip_numbers(text): """Strip numbers from text.""" return ''.join(filter(lambda u: not u.isdigit(), text)) def extract_most_common_words(text, num_words=None): """Extract most common words. :param unicode text: :param int num_words: :return list: """ if num_words is None: num_words = get_setting('LANGUAGE_DETECTION_MAX_NUM_KEYWORDS') text = strip_numbers(text) counter = Counter() for word in text.split(' '): if len(word) > 1: counter[word] += 1 return counter.most_common(num_words) def detect_language(text, num_words=None, fail_silently=True, heavy_check=False): """Detect the language from the value given. Detect the language from the value given based on ranges defined in active language packs. :param unicode value: Input string. :param int num_words: Number of words to base decision on. :param bool fail_silently: :param bool heavy_check: If given, heavy checks would be applied when simple checks don't give any results. Heavy checks are language specific and do not apply to a common logic. Heavy language detection is defined in the ``detect`` method of each language pack. :return str: Language code. """ ensure_autodiscover() if num_words is None: num_words = get_setting('LANGUAGE_DETECTION_MAX_NUM_KEYWORDS') most_common_words = extract_most_common_words(text, num_words=num_words) counter = Counter() available_language_packs = get_available_language_packs() for word, occurrences in most_common_words: for letter in word: for language_pack in available_language_packs: if language_pack.detectable and language_pack.contains(letter): counter[language_pack.language_code] += 1 continue try: return counter.most_common(1)[0][0] except Exception as err: if get_setting('DEBUG'): LOGGER.debug(str(err)) if not fail_silently: raise LanguageDetectionError( _("""Can't detect language for the text "%s" given.""") % text ) def slugify(text, language_code=None): """Slugify the given text. If no ``language_code`` is given, auto-detect the language code from text given. :param str text: :param str language_code: :return str: """ if not language_code: language_code = detect_language(text) if language_code: transliterated_text = translit(text, language_code, reversed=True) slug = unicodedata.normalize('NFKD', transliterated_text) \ .encode('ascii', 'ignore') \ .decode('ascii') slug = re.sub(r'[^\w\s-]', '', slug).strip().lower() return re.sub(r'[-\s]+', '-', slug) transliterate-1.10.2/tox.ini000066400000000000000000000004561335001171700157720ustar00rootroot00000000000000[tox] envlist = #py{26,27,33,34,35,py}-{six110,six141,six} py{27,34,35,py} [testenv] passenv = * deps = # six110: six==1.1.0 # six141: six==1.4.1 # six: six -r{toxinidir}/requirements.txt commands= # {envpython} src/transliterate/tests/__init__.py {envpython} runtests.py