[
  {
    "path": ".gitignore",
    "content": ".DS_Store\n\n### Python ###\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nenv/\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\n*.egg-info/\n.installed.cfg\n*.egg\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*,cover\n.hypothesis/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\nlocal_settings.py\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Scrapy stuff:\n.scrapy\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# IPython Notebook\n.ipynb_checkpoints\n\n# pyenv\n.python-version\n\n# celery beat schedule file\ncelerybeat-schedule\n\n# dotenv\n.env\n\n# virtualenv\n.venv/\nvenv/\nENV/\n\n# Spyder project settings\n.spyderproject\n\n# Rope project settings\n.ropeproject\n\nMANIFEST\n\n.idea\n.vscode\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "### GNU GENERAL PUBLIC LICENSE\n\nVersion 3, 29 June 2007\n\nCopyright (C) 2007 Free Software Foundation, Inc.\n<http://fsf.org/>\n\nEveryone is permitted to copy and distribute verbatim copies of this\nlicense document, but changing it is not allowed.\n\n### Preamble\n\nThe GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\nThe licenses for most software and other practical works are designed\nto take away your freedom to share and change the works. By contrast,\nthe GNU General Public License is intended to guarantee your freedom\nto share and change all versions of a program--to make sure it remains\nfree software for all its users. We, the Free Software Foundation, use\nthe GNU General Public License for most of our software; it applies\nalso to any other work released this way by its authors. You can apply\nit to your programs, too.\n\nWhen we speak of free software, we are referring to freedom, not\nprice. Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\nTo protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights. Therefore, you\nhave certain responsibilities if you distribute copies of the\nsoftware, or if you modify it: responsibilities to respect the freedom\nof others.\n\nFor example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received. You must make sure that they, too, receive\nor can get the source code. And you must show them these terms so they\nknow their rights.\n\nDevelopers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\nFor the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software. For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\nSome devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the\nmanufacturer can do so. This is fundamentally incompatible with the\naim of protecting users' freedom to change the software. The\nsystematic pattern of such abuse occurs in the area of products for\nindividuals to use, which is precisely where it is most unacceptable.\nTherefore, we have designed this version of the GPL to prohibit the\npractice for those products. If such problems arise substantially in\nother domains, we stand ready to extend this provision to those\ndomains in future versions of the GPL, as needed to protect the\nfreedom of users.\n\nFinally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish\nto avoid the special danger that patents applied to a free program\ncould make it effectively proprietary. To prevent this, the GPL\nassures that patents cannot be used to render the program non-free.\n\nThe precise terms and conditions for copying, distribution and\nmodification follow.\n\n### TERMS AND CONDITIONS\n\n#### 0. Definitions.\n\n\"This License\" refers to version 3 of the GNU General Public License.\n\n\"Copyright\" also means copyright-like laws that apply to other kinds\nof works, such as semiconductor masks.\n\n\"The Program\" refers to any copyrightable work licensed under this\nLicense. Each licensee is addressed as \"you\". \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\nTo \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of\nan exact copy. The resulting work is called a \"modified version\" of\nthe earlier work or a work \"based on\" the earlier work.\n\nA \"covered work\" means either the unmodified Program or a work based\non the Program.\n\nTo \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy. Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\nTo \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies. Mere interaction with a user\nthrough a computer network, with no transfer of a copy, is not\nconveying.\n\nAn interactive user interface displays \"Appropriate Legal Notices\" to\nthe extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License. If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n#### 1. Source Code.\n\nThe \"source code\" for a work means the preferred form of the work for\nmaking modifications to it. \"Object code\" means any non-source form of\na work.\n\nA \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\nThe \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form. A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\nThe \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities. However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work. For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\nThe Corresponding Source need not include anything that users can\nregenerate automatically from other parts of the Corresponding Source.\n\nThe Corresponding Source for a work in source code form is that same\nwork.\n\n#### 2. Basic Permissions.\n\nAll rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met. This License explicitly affirms your unlimited\npermission to run the unmodified Program. The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work. This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\nYou may make, run and propagate covered works that you do not convey,\nwithout conditions so long as your license otherwise remains in force.\nYou may convey covered works to others for the sole purpose of having\nthem make modifications exclusively for you, or provide you with\nfacilities for running those works, provided that you comply with the\nterms of this License in conveying all material for which you do not\ncontrol copyright. Those thus making or running the covered works for\nyou must do so exclusively on your behalf, under your direction and\ncontrol, on terms that prohibit them from making any copies of your\ncopyrighted material outside their relationship with you.\n\nConveying under any other circumstances is permitted solely under the\nconditions stated below. Sublicensing is not allowed; section 10 makes\nit unnecessary.\n\n#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\nNo covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\nWhen you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such\ncircumvention is effected by exercising rights under this License with\nrespect to the covered work, and you disclaim any intention to limit\noperation or modification of the work as a means of enforcing, against\nthe work's users, your or third parties' legal rights to forbid\ncircumvention of technological measures.\n\n#### 4. Conveying Verbatim Copies.\n\nYou may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\nYou may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n#### 5. Conveying Modified Source Versions.\n\nYou may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these\nconditions:\n\n-   a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n-   b) The work must carry prominent notices stating that it is\n      released under this License and any conditions added under\n      section 7. This requirement modifies the requirement in section 4\n      to \"keep intact all notices\".\n-   c) You must license the entire work, as a whole, under this\n      License to anyone who comes into possession of a copy. This\n      License will therefore apply, along with any applicable section 7\n      additional terms, to the whole of the work, and all its parts,\n      regardless of how they are packaged. This License gives no\n      permission to license the work in any other way, but it does not\n      invalidate such permission if you have separately received it.\n-   d) If the work has interactive user interfaces, each must display\n      Appropriate Legal Notices; however, if the Program has interactive\n      interfaces that do not display Appropriate Legal Notices, your\n      work need not make them do so.\n\nA compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit. Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n#### 6. Conveying Non-Source Forms.\n\nYou may convey a covered work in object code form under the terms of\nsections 4 and 5, provided that you also convey the machine-readable\nCorresponding Source under the terms of this License, in one of these\nways:\n\n-   a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n-   b) Convey the object code in, or embodied in, a physical product\n      (including a physical distribution medium), accompanied by a\n      written offer, valid for at least three years and valid for as\n      long as you offer spare parts or customer support for that product\n      model, to give anyone who possesses the object code either (1) a\n      copy of the Corresponding Source for all the software in the\n      product that is covered by this License, on a durable physical\n      medium customarily used for software interchange, for a price no\n      more than your reasonable cost of physically performing this\n      conveying of source, or (2) access to copy the Corresponding\n      Source from a network server at no charge.\n-   c) Convey individual copies of the object code with a copy of the\n      written offer to provide the Corresponding Source. This\n      alternative is allowed only occasionally and noncommercially, and\n      only if you received the object code with such an offer, in accord\n      with subsection 6b.\n-   d) Convey the object code by offering access from a designated\n      place (gratis or for a charge), and offer equivalent access to the\n      Corresponding Source in the same way through the same place at no\n      further charge. You need not require recipients to copy the\n      Corresponding Source along with the object code. If the place to\n      copy the object code is a network server, the Corresponding Source\n      may be on a different server (operated by you or a third party)\n      that supports equivalent copying facilities, provided you maintain\n      clear directions next to the object code saying where to find the\n      Corresponding Source. Regardless of what server hosts the\n      Corresponding Source, you remain obligated to ensure that it is\n      available for as long as needed to satisfy these requirements.\n-   e) Convey the object code using peer-to-peer transmission,\n      provided you inform other peers where the object code and\n      Corresponding Source of the work are being offered to the general\n      public at no charge under subsection 6d.\n\nA separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\nA \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal,\nfamily, or household purposes, or (2) anything designed or sold for\nincorporation into a dwelling. In determining whether a product is a\nconsumer product, doubtful cases shall be resolved in favor of\ncoverage. For a particular product received by a particular user,\n\"normally used\" refers to a typical or common use of that class of\nproduct, regardless of the status of the particular user or of the way\nin which the particular user actually uses, or expects or is expected\nto use, the product. A product is a consumer product regardless of\nwhether the product has substantial commercial, industrial or\nnon-consumer uses, unless such uses represent the only significant\nmode of use of the product.\n\n\"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to\ninstall and execute modified versions of a covered work in that User\nProduct from a modified version of its Corresponding Source. The\ninformation must suffice to ensure that the continued functioning of\nthe modified object code is in no case prevented or interfered with\nsolely because modification has been made.\n\nIf you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information. But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\nThe requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or\nupdates for a work that has been modified or installed by the\nrecipient, or for the User Product in which it has been modified or\ninstalled. Access to a network may be denied when the modification\nitself materially and adversely affects the operation of the network\nor violates the rules and protocols for communication across the\nnetwork.\n\nCorresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n#### 7. Additional Terms.\n\n\"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law. If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\nWhen you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit. (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.) You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\nNotwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders\nof that material) supplement the terms of this License with terms:\n\n-   a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n-   b) Requiring preservation of specified reasonable legal notices or\n      author attributions in that material or in the Appropriate Legal\n      Notices displayed by works containing it; or\n-   c) Prohibiting misrepresentation of the origin of that material,\n      or requiring that modified versions of such material be marked in\n      reasonable ways as different from the original version; or\n-   d) Limiting the use for publicity purposes of names of licensors\n      or authors of the material; or\n-   e) Declining to grant rights under trademark law for use of some\n      trade names, trademarks, or service marks; or\n-   f) Requiring indemnification of licensors and authors of that\n      material by anyone who conveys the material (or modified versions\n      of it) with contractual assumptions of liability to the recipient,\n      for any liability that these contractual assumptions directly\n      impose on those licensors and authors.\n\nAll other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10. If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term. If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\nIf you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\nAdditional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions; the\nabove requirements apply either way.\n\n#### 8. Termination.\n\nYou may not propagate or modify a covered work except as expressly\nprovided under this License. Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\nHowever, if you cease all violation of this License, then your license\nfrom a particular copyright holder is reinstated (a) provisionally,\nunless and until the copyright holder explicitly and finally\nterminates your license, and (b) permanently, if the copyright holder\nfails to notify you of the violation by some reasonable means prior to\n60 days after the cessation.\n\nMoreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\nTermination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License. If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n#### 9. Acceptance Not Required for Having Copies.\n\nYou are not required to accept this License in order to receive or run\na copy of the Program. Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance. However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work. These actions infringe copyright if you do\nnot accept this License. Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n#### 10. Automatic Licensing of Downstream Recipients.\n\nEach time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License. You are not responsible\nfor enforcing compliance by third parties with this License.\n\nAn \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations. If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\nYou may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License. For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n#### 11. Patents.\n\nA \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based. The\nwork thus licensed is called the contributor's \"contributor version\".\n\nA contributor's \"essential patent claims\" are all patent claims owned\nor controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version. For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\nEach contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\nIn the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement). To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\nIf you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients. \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\nIf, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\nA patent license is \"discriminatory\" if it does not include within the\nscope of its coverage, prohibits the exercise of, or is conditioned on\nthe non-exercise of one or more of the rights that are specifically\ngranted under this License. You may not convey a covered work if you\nare a party to an arrangement with a third party that is in the\nbusiness of distributing software, under which you make payment to the\nthird party based on the extent of your activity of conveying the\nwork, and under which the third party grants, to any of the parties\nwho would receive the covered work from you, a discriminatory patent\nlicense (a) in connection with copies of the covered work conveyed by\nyou (or copies made from those copies), or (b) primarily for and in\nconnection with specific products or compilations that contain the\ncovered work, unless you entered into that arrangement, or that patent\nlicense was granted, prior to 28 March 2007.\n\nNothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n#### 12. No Surrender of Others' Freedom.\n\nIf conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License. If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under\nthis License and any other pertinent obligations, then as a\nconsequence you may not convey it at all. For example, if you agree to\nterms that obligate you to collect a royalty for further conveying\nfrom those to whom you convey the Program, the only way you could\nsatisfy both those terms and this License would be to refrain entirely\nfrom conveying the Program.\n\n#### 13. Use with the GNU Affero General Public License.\n\nNotwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work. The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n#### 14. Revised Versions of this License.\n\nThe Free Software Foundation may publish revised and/or new versions\nof the GNU General Public License from time to time. Such new versions\nwill be similar in spirit to the present version, but may differ in\ndetail to address new problems or concerns.\n\nEach version is given a distinguishing version number. If the Program\nspecifies that a certain numbered version of the GNU General Public\nLicense \"or any later version\" applies to it, you have the option of\nfollowing the terms and conditions either of that numbered version or\nof any later version published by the Free Software Foundation. If the\nProgram does not specify a version number of the GNU General Public\nLicense, you may choose any version ever published by the Free\nSoftware Foundation.\n\nIf the Program specifies that a proxy can decide which future versions\nof the GNU General Public License can be used, that proxy's public\nstatement of acceptance of a version permanently authorizes you to\nchoose that version for the Program.\n\nLater license versions may give you additional or different\npermissions. However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n#### 15. Disclaimer of Warranty.\n\nTHERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT\nWARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND\nPERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE\nDEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR\nCORRECTION.\n\n#### 16. Limitation of Liability.\n\nIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR\nCONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES\nARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT\nNOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR\nLOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM\nTO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER\nPARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n\n#### 17. Interpretation of Sections 15 and 16.\n\nIf the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\nEND OF TERMS AND CONDITIONS\n\n### How to Apply These Terms to Your New Programs\n\nIf you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these\nterms.\n\nTo do so, attach the following notices to the program. It is safest to\nattach them to the start of each source file to most effectively state\nthe exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n        <one line to give the program's name and a brief idea of what it does.>\n        Copyright (C) <year>  <name of author>\n    \n        This program is free software: you can redistribute it and/or modify\n        it under the terms of the GNU General Public License as published by\n        the Free Software Foundation, either version 3 of the License, or\n        (at your option) any later version.\n    \n        This program is distributed in the hope that it will be useful,\n        but WITHOUT ANY WARRANTY; without even the implied warranty of\n        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n        GNU General Public License for more details.\n    \n        You should have received a copy of the GNU General Public License\n        along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper\nmail.\n\nIf the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n        <program>  Copyright (C) <year>  <name of author>\n        This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n        This is free software, and you are welcome to redistribute it\n        under certain conditions; type `show c' for details.\n\nThe hypothetical commands \\`show w' and \\`show c' should show the\nappropriate parts of the General Public License. Of course, your\nprogram's commands might be different; for a GUI interface, you would\nuse an \"about box\".\n\nYou should also get your employer (if you work as a programmer) or\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary. For more information on this, and how to apply and follow\nthe GNU GPL, see <http://www.gnu.org/licenses/>.\n\nThe GNU General Public License does not permit incorporating your\nprogram into proprietary programs. If your program is a subroutine\nlibrary, you may consider it more useful to permit linking proprietary\napplications with the library. If this is what you want to do, use the\nGNU Lesser General Public License instead of this License. But first,\nplease read <http://www.gnu.org/philosophy/why-not-lgpl.html>."
  },
  {
    "path": "README-cn.md",
    "content": "# Amazing-QR\n\n[![former name](https://img.shields.io/badge/old%20name-MyQR-yellow)](https://pypi.org/project/myqr/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/myqr?label=downloads@myqr)](https://pypi.org/project/myqr/) [![](https://img.shields.io/badge/language-Python-blue)](https://www.python.org/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/amzqr?logo=python&logoColor=ffffff&label=Python&labelColor=blue&color=ffffff) [![PyPI](https://img.shields.io/pypi/v/amzqr?logo=pypi&logoColor=ffffff&label=PyPI&labelColor=blue)](https://pypi.org/project/amzqr/) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/amzqr) [![PyPI - Downloads](https://img.shields.io/pypi/dm/amzqr)](https://pypi.org/project/amzqr/) [![PyPI - License](https://img.shields.io/pypi/l/amzqr)](https://github.com/x-hw/amazing-qr/blob/master/LICENSE.md) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/x-hw/amazing-qr) ![macos](https://img.shields.io/badge/-macOS-black?logo=macos) ![linux](https://img.shields.io/badge/-Linux-yellow?logo=linux) ![windows](https://img.shields.io/badge/-Windows-blue?logo=windows)\n\n[![](https://img.shields.io/badge/GitHub-x.hw-blue?logo=github)](https://github.com/x-hw) [![sponsor](https://img.shields.io/badge/sponsor--pink?logo=github-sponsors&labelColor=pink)](#打赏杯咖啡)\n\n[*back to English*](https://github.com/x-hw/amazing-qr/blob/master/README.md)\n\n## 概述\n\n**Python 二维码生成器**\n\n可生成*普通二维码*、*带图片的艺术二维码（黑白与彩色）*、*动态二维码（黑白与彩色）*。\n\n## Contents 目录\n\n* [Amazing-QR](#amazing-qr)\n  * [概述](#概述)\n  * [目录](#目录)\n  * [示例](#示例)\n  * [安装](#安装)\n  * [使用方法](#使用方法)\n    * [命令行方式](#命令行方式)\n    * [作为导入文件](#作为导入文件)\n  * [使用提示](#使用提示)\n  * [可用字符](#可用字符)\n  * [环境](#环境)\n  * [协议](#协议)\n  * [打赏杯咖啡☕️](#打赏杯咖啡)\n\n## 示例\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs0.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs1.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs2.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/c_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode.gif)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/zootopia_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode0.gif)\n\n\n## 安装\n\n```python\npip install amzqr\n```\n\n## 使用方法\n\n### 命令行方式\n\n*（**提示**：如果你尚未安装 [**amzqr**](https://pypi.python.org/pypi/amzqr) ，以下内容请使用`python(3) amzqr.py` 而非`amzqr` 。）*\n\n```python\n# 概括\namzqr  Words\n      [-v {1,2,3,...,40}]\n      [-l {L,M,Q,H}]\n      [-n output-filename]\n      [-d output-directory]\n      [-p picture_file]\n      [-c]\n      [-con contrast]\n      [-bri brightness]\n```\n\n- [普通二维码](#普通二维码) 介绍了 `Words`, `-v`, `-l`, `-n`, `-d` \n- [艺术二维码](#艺术二维码) 介绍了  `-p`, `-c`, `-con`, `-bri`\n- [动态GIF二维码](#动态gif二维码) 介绍了动态的生成方法和注意点\n\n#### 普通二维码\n\n![](https://github.com/x-hw/amzqr/blob/master/example/0.png)\n\n```markdown\n#1 Words\namzqr https://github.com\n```\n\n* 在命令后输入链接或者句子作为参数，然后在程序的当前目录中产生相应的二维码图片文件，默认命名为” qrcode.png“。\n\n```markdown\n#2 -v, -l\namzqr https://github.com -v 10 -l Q\n```\n\n* **默认边长**是取决于你输入的信息的长度和使用的纠错等级；\n\n  而**默认纠错等级**是最高级的H。\n\n* **自定义**：如果想要控制边长和纠错水平就使用 `-v` 和 `-l` 参数。\n\n   `-v` 控制边长，范围是**1至40**，数字越大边长越大；\n\n   `-l` 控制纠错水平，范围是**L、M、Q、H**，从左到右依次升高。\n\n```markdown\n#3 -n, -d\namzqr https://github.com -n github_qr.jpg  -d .../paths/\n```\n\n- **默认输出文件名**是“ qrcode.png \"，而**默认存储位置**是当前目录。\n\n- 自定义：可以自己定义输出名称和位置。**注意**同名文件会覆盖旧的。\n\n  `-n` 控制文件名，格式可以是 `.jpg`， `.png` ，`.bmp` ，`.gif` ；\n\n  `-d` 控制位置。\n\n  #### 艺术二维码\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/1.png)![](https://github.com/x-hw/amazing-qr/blob/master/example/2.png)\n\n```markdown\n#1 -p\namzqr https://github.com -p github.jpg\n```\n\n* 参数`-p` 用来将QR二维码图像与一张同目录下的图片相结合，产生一张**黑白**图片。\n\n```markdown\n#2 -c\namzqr https://github.com -p github.jpg -c\n```\n\n* 加上参数 `-c` 可以使产生的图片由黑白变为**彩色**的。\n\n```markdown\n#3 -con, -bri\namzqr https://github.com -p github.jpg [-c] -con 1.5 -bri 1.6\n```\n\n* 参数`-con` 用以调节图片的**对比度**，1.0 表示原始图片，更小的值表示更低对比度，更大反之。**默认为1.0**。\n\n* 参数 `-bri` 用来调节图片的**亮度**，其余用法和取值与 `-con` 相同。\n\n#### 动态GIF二维码\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode0.gif)\n\n动态二维码与上述的带图片的二维码的生成方法没什么区别，你只要采用 `.gif` 格式的图片即可生成黑白或者彩色的动态二维码。但**注意**如果使用了 `-n` 参数自定义输出的文件名，切记其格式也必须是 `.gif` 格式。\n\n### 作为导入文件\n\n```python\n# 安装模块后\nfrom amzqr import amzqr\nversion, level, qr_name = amzqr.run(\n    words,\n    version=1,\n    level='H',\n    picture=None,\n    colorized=False,\n    contrast=1.0,\n    brightness=1.0,\n    save_name=None,\n    save_dir=os.getcwd()\n)\n```\n\n*以下各个参数已经在[上文](#命令行方式)有所介绍*\n\n```python\n# help(amzqr)\nPositional parameter\n   words: str\n\nOptional parameters\n   version: int, from 1 to 40\n   level: str, just one of ('L','M','Q','H')\n   picutre: str, a filename of a image\n   colorized: bool\n   constrast: float\n   brightness: float\n   save_name: str, the output filename like 'example.png'\n   save_dir: str, the output directory\n```\n## 使用提示\n\n* 请采用**正方形**或近似正方形的图片\n\n* 建议在图片尺寸大的时候使用 `-v` 的值也应该**适当**变大。\n\n* 如果图片有透明无色部分，最终效果是：![](https://github.com/x-hw/amazing-qr/blob/master/example/aa.png)\n\n  你可以将透明部分修改成白色，最终效果会变成![](https://github.com/x-hw/amazing-qr/blob/master/example/a0.png)\n\n## 可用字符\n\n* 数字 0 到 9\n\n* 大小写的英文字母\n\n* 常用**英文标点符号**和空格\n\n  ```console\n  · , . : ; + - * / \\ ~ ! @ # $ % ^ & ` ' = < > [ ] ( ) ? _ { } | and  (space)\n  ```\n\n## 环境\n\n- Python 3\n\n## 协议\n\n* GPLv3\n\n## 打赏杯咖啡\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/x-hw?logo=github-sponsors&labelColor=pink&color=white)](https://github.com/sponsors#regions)\n\n*GitHub Sponsors 还用不了...*\n\n![wechatpay](https://img.shields.io/badge/-微信打赏-brightgreen?labelColor=brightgreen&logo=data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAGa0aABmtGg4ZrRoOGa0aABmtGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmtGgAZrRpGGa0arBmtGkEZrRobGa0aOBmtGkwZrRpNGa0aORmtGhoZrRoDGa0aAAAAAAAAAAAAAAAAAAAAAAAZrRoAGa0aKBmtGucZrRrwGa0a3BmtGvIZrRr6Ga0a+xmtGvMZrRrYGa0alxmtGjcZrRoCGa0aAAAAAAAZrRoAGa0aBhmtGnMZrRr1Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRroGa0adBmtGgkZrRoAGa0aAhmtGnEZrRr2Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGvgZrRp5Ga0aAxmtGkEZrRrmGa0a/xmtGv8ZrRr+Ga0a8RmtGvsZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a6hmtGkkZrRqlGa0a/xmtGv8ZrRr/Ga0a5RmtGkwZrRpzGa0a3hmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRqvGa0a3xmtGv8ZrRr/Ga0a/xmtGpkZrRoDGa0aABmtGicZrRqWGa0a7hmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a5xmtGusZrRr/Ga0a/xmtGu0ZrRo9Ga0aPBmtGmcZrRohGa0aAxmtGj8ZrRq0Ga0a+BmtGv8ZrRr/Ga0a/xmtGvIZrRrQGa0a/xmtGv8ZrRrLGa0agRmtGukZrRr+Ga0a3RmtGosZrRowGa0aEBmtGlsZrRrNGa0a/RmtGv8ZrRrYGa0agxmtGv0ZrRr/Ga0a+hmtGvsZrRr/Ga0a/xmtGv8ZrRr/Ga0a6hmtGqIZrRpDGa0aJRmtGnsZrRrhGa0ajBmtGiAZrRrHGa0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a9BmtGrcZrRpdGa0aOxmtGhoZrRoAGa0aPBmtGtcZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a1BmtGiwZrRoAGa0aABmtGgAZrRowGa0arRmtGvQZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr2Ga0asRmtGjQZrRoAGa0aAAAAAAAZrRoAGa0aABmtGgsZrRpFGa0ajRmtGrsZrRrPGa0azxmtGr0ZrRqQGa0aSBmtGgwZrRoAGa0aAAAAAAAAAAAAAAAAAAAAAAAAAAAAGa0aABmtGgEZrRoKGa0aFBmtGhUZrRoKGa0aARmtGgAAAAAAAAAAAAAAAAAAAAAAz/8AAMAPAADAAwAAgAEAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAgAEAAMADAADgBwAA+B8AAA==)\n\n<img src=\"https://github.com/x-hw/amazing-qr/blob/master/example/wechatpay.jpg\" width = \"124\" height = \"116\" alt=\"wechatpay\" align=center />\n\n![alipay](https://img.shields.io/badge/-支付宝打赏-blue?logo=alipay&logoColor=ffffff&labelColor=blue)\n\n<img src=\"https://github.com/x-hw/amazing-qr/blob/master/example/alipay.gif\" width = \"132\" height = \"132\" alt=\"alipay\" align=center />\n\n🎉🎉🎉 感谢你的支持 🎉🎉🎉\n"
  },
  {
    "path": "README.md",
    "content": "# Amazing-QR\n\n[![former name](https://img.shields.io/badge/old%20name-MyQR-yellow)](https://pypi.org/project/myqr/) [![PyPI - Downloads](https://img.shields.io/pypi/dm/myqr?label=downloads@myqr)](https://pypi.org/project/myqr/) [![](https://img.shields.io/badge/language-Python-blue)](https://www.python.org/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/amzqr?logo=python&logoColor=ffffff&label=Python&labelColor=blue&color=ffffff) [![PyPI](https://img.shields.io/pypi/v/amzqr?logo=pypi&logoColor=ffffff&label=PyPI&labelColor=blue)](https://pypi.org/project/amzqr/) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/amzqr) [![PyPI - Downloads](https://img.shields.io/pypi/dm/amzqr)](https://pypi.org/project/amzqr/) [![PyPI - License](https://img.shields.io/pypi/l/amzqr)](https://github.com/x-hw/amazing-qr/blob/master/LICENSE.md) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/x-hw/amazing-qr) ![macos](https://img.shields.io/badge/-macOS-black?logo=macos) ![linux](https://img.shields.io/badge/-Linux-yellow?logo=linux) ![windows](https://img.shields.io/badge/-Windows-blue?logo=windows)\n\n[![](https://img.shields.io/badge/GitHub-x.hw-blue?logo=github)](https://github.com/x-hw) [![sponsor](https://img.shields.io/badge/sponsor--pink?logo=github-sponsors&labelColor=pink)](#buy-me-a-coffee)\n\n[*转到中文版*](https://github.com/x-hw/amazing-qr/blob/master/README-cn.md)\n\n## Overview\n\n**Python QR Code Generator**\n\nGenerate *common qr-code*,  *artistic qr-code (black & white or colorized)*,  *animated qr-code (black & white or colorized)*.\n\n## Contents\n\n* [Amazing-QR](#amazing-qr)\n  * [Overview](#overview)\n  * [Contents](#contents)\n  * [Examples](#examples)\n  * [Install](#install)\n  * [Usage](#usage)\n    * [Terminal Way](#terminal-way)\n    * [Import Way](#import-way)\n  * [Tips](#tips)\n  * [Supported Characters](#supported-characters)\n  * [Environment](#environment)\n  * [License](#license)\n  * [Buy me a coffee ☕️](#buy-me-a-coffee)\n\n## Examples\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs0.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs1.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/qrs2.jpg)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/c_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode.gif)\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/zootopia_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode0.gif)\n\n## Install\n\n```python\n# via pip\npip install amzqr\n```\n\n## Usage\n\n### Terminal Way  \n\n*(**TIPS**: If you haven't install [**amzqr**](https://pypi.python.org/pypi/amzqr), you should  `python(3) amzqr.py` instead of `amzqr` blow.)*\n\n```sh\n# summary\namzqr Words\n      [-v {1,2,3,...,40}]\n      [-l {L,M,Q,H}]\n      [-n output-filename]\n      [-d output-directory]\n      [-p picture_file]\n      [-c]\n      [-con contrast]\n      [-bri brightness]\n```\n\n- see [Common QR-Code](#common-qr-code) for `Words`, `-v`, `-l`, `-n`, `-d`\n- see [Artistic QR-Code](#artistic-qr-code) for `-p`, `-c`, `-con`, `-bri`\n- see [Animated GIF QR-Code](#animated-gif-qr-code) about GIF\n\n#### Common QR-Code\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/0.png)\n\n```markdown\n#1 Words\namzqr https://github.com\n```\n\n* Just input a URL or a sentence, then get your QR-Code named 'qrcode.png' in the current directory.\n\n\n```markdown\n#2 -v, -l\namzqr https://github.com -v 10 -l Q\n```\n\n* The **default** size of QR-Code depends both on the numbers of words you input and the level, while the **default** level (Error Correction Level) is **H** (the highest).\n\n* **Customize**: If you want to control the size and the error-correction-level, use the `-v` and `-l` arguments. \n\n   `-v`  representing the length is from a minimum of **1** to a maximum of **40**. \n\n   `-l` representing the error correction level is one of **L, M, Q and H**, where L is the lowest level and H is the highest.\n\n\n\n\n```markdown\n#3 -n, -d\namzqr https://github.com   -n github_qr.jpg   -d .../paths/\n```\n\n* The **default** output-filename is 'qrcode.png', while the **default** output-directory is current directory.\n\n* **Customize**: You can name the output-file and decide the output-directory. **Notice** that if the name is as same as a existing file, the old one will be deleted.\n\n  `-n` representing the output-filename could be in the format one of `.jpg`， `.png` ，`.bmp` ，`.gif` .\n\n  `-d` means directory.\n\n\n#### Artistic QR-Code\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/1.png)![](https://github.com/x-hw/amazing-qr/blob/master/example/2.png)\n\n\n```markdown\n#1 -p\namzqr https://github.com -p github.jpg\n```\n\n* The `-p` is to combine the QR-Code with the following picture which is in the same directory as the program. The resulting picture is **black and white** by default.\n\n\n```markdown\n#2 -c\namzqr https://github.com -p github.jpg -c\n```\n\n* The `-c` is to make the resulting picture **colorized**.\n\n\n\n```markdown\n#3 -con, -bri\namzqr https://github.com -p github.jpg [-c] -con 1.5 -bri 1.6\n```\n\n* The `-con` flag changes the **contrast** of the picture - a low number corresponds to low contrast and a high number to high contrast. **Default: 1.0**.\n\n* The `-bri` flag changes the **brightness** and the parameter values work the same as those for `-con`. **Default: 1.0**.\n\n\n\n\n\n#### Animated GIF QR-Code\n\n![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode.gif)![](https://github.com/x-hw/amazing-qr/blob/master/example/daftpunktocat-guy_qrcode0.gif)\n\nThe only difference from Artistic QR-Code mentioned above is that you should input an image file in the `.gif` format. The you can get your black-and-white or colorful qr-code. Remember that when you use `-n` to customize the output-filename, then the output-filename must end by `.gif`.\n\n### Import Way\n\n```python\nfrom amzqr import amzqr\n\nversion, level, qr_name = amzqr.run(\n    words,\n    version=1,\n    level='H',\n    picture=None,\n    colorized=False,\n    contrast=1.0,\n    brightness=1.0,\n    save_name=None,\n    save_dir=os.getcwd()\n)\n```\n\n*details about each parameter are as mentioned [above](#terminal-way)*\n\n```python\n# help(amzqr)\nPositional parameter\n   words: str\n\nOptional parameters\n   version: int, from 1 to 40\n   level: str, just one of ('L','M','Q','H')\n   picutre: str, a filename of a image\n   colorized: bool\n   constrast: float\n   brightness: float\n   save_name: str, the output filename like 'example.png'\n   save_dir: str, the output directory\n```\n\n## Tips\n\n* Use a nearly **square** picture instead of a rectangle one.\n\n* If the size of the picture is large, you should also choose a **rightly** large `-v` instead of using the default one.\n\n* If part of the picture is transparent, the qr code will look like: ![](https://github.com/x-hw/amazing-qr/blob/master/example/aa.png)\n\n  You can change the transparent layer to white, and then it will look like: ![](https://github.com/x-hw/amazing-qr/blob/master/example/a0.png)\n\n## Supported Characters\n\n* Numbers:  `0~9`\n\n* Letters:  `a~z, A~Z`\n\n* Common punctuations:\n\n  ```console\n  · , . : ; + - * / \\ ~ ! @ # $ % ^ & ` ' = < > [ ] ( ) ? _ { } | and  (space)\n  ```\n\n## Environment\n\n- Python 3\n\n## License\n\n* GPLv3\n\n## Buy me a coffee\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/x-hw?logo=github-sponsors&labelColor=pink&color=white)](https://github.com/sponsors#regions)\n\n*Since the GitHub Sponsors is unavailable in China yet...*\n\n![wechatpay](https://img.shields.io/badge/-wechat_pay-brightgreen?labelColor=brightgreen&logo=data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAAAAAAAGa0aABmtGg4ZrRoOGa0aABmtGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmtGgAZrRpGGa0arBmtGkEZrRobGa0aOBmtGkwZrRpNGa0aORmtGhoZrRoDGa0aAAAAAAAAAAAAAAAAAAAAAAAZrRoAGa0aKBmtGucZrRrwGa0a3BmtGvIZrRr6Ga0a+xmtGvMZrRrYGa0alxmtGjcZrRoCGa0aAAAAAAAZrRoAGa0aBhmtGnMZrRr1Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRroGa0adBmtGgkZrRoAGa0aAhmtGnEZrRr2Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGvgZrRp5Ga0aAxmtGkEZrRrmGa0a/xmtGv8ZrRr+Ga0a8RmtGvsZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a6hmtGkkZrRqlGa0a/xmtGv8ZrRr/Ga0a5RmtGkwZrRpzGa0a3hmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRqvGa0a3xmtGv8ZrRr/Ga0a/xmtGpkZrRoDGa0aABmtGicZrRqWGa0a7hmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a5xmtGusZrRr/Ga0a/xmtGu0ZrRo9Ga0aPBmtGmcZrRohGa0aAxmtGj8ZrRq0Ga0a+BmtGv8ZrRr/Ga0a/xmtGvIZrRrQGa0a/xmtGv8ZrRrLGa0agRmtGukZrRr+Ga0a3RmtGosZrRowGa0aEBmtGlsZrRrNGa0a/RmtGv8ZrRrYGa0agxmtGv0ZrRr/Ga0a+hmtGvsZrRr/Ga0a/xmtGv8ZrRr/Ga0a6hmtGqIZrRpDGa0aJRmtGnsZrRrhGa0ajBmtGiAZrRrHGa0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a9BmtGrcZrRpdGa0aOxmtGhoZrRoAGa0aPBmtGtcZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr/Ga0a1BmtGiwZrRoAGa0aABmtGgAZrRowGa0arRmtGvQZrRr/Ga0a/xmtGv8ZrRr/Ga0a/xmtGv8ZrRr2Ga0asRmtGjQZrRoAGa0aAAAAAAAZrRoAGa0aABmtGgsZrRpFGa0ajRmtGrsZrRrPGa0azxmtGr0ZrRqQGa0aSBmtGgwZrRoAGa0aAAAAAAAAAAAAAAAAAAAAAAAAAAAAGa0aABmtGgEZrRoKGa0aFBmtGhUZrRoKGa0aARmtGgAAAAAAAAAAAAAAAAAAAAAAz/8AAMAPAADAAwAAgAEAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAgAEAAMADAADgBwAA+B8AAA==)\n\n<img src=\"https://github.com/x-hw/amazing-qr/blob/master/example/wechatpay.jpg\" width = \"124\" height = \"116\" alt=\"wechatpay\" align=center />\n\n![alipay](https://img.shields.io/badge/-alipay-blue?logo=alipay&logoColor=ffffff&labelColor=blue)\n\n<img src=\"https://github.com/x-hw/amazing-qr/blob/master/example/alipay.gif\" width = \"132\" height = \"132\" alt=\"alipay\" align=center />\n\n🎉🎉🎉 Thanks for your support. 🎉🎉🎉\n"
  },
  {
    "path": "amzqr/__init__.py",
    "content": ""
  },
  {
    "path": "amzqr/amzqr.py",
    "content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport os\nfrom amzqr.mylibs import theqrmodule\nfrom PIL import Image\n   \n# Positional parameters\n#   words: str\n#\n# Optional parameters\n#   version: int, from 1 to 40\n#   level: str, just one of ('L','M','Q','H')\n#   picutre: str, a filename of a image\n#   colorized: bool\n#   constrast: float\n#   brightness: float\n#   save_name: str, the output filename like 'example.png'\n#   save_dir: str, the output directory\n#\n# See [https://github.com/hwxhw/amazing-qr] for more details!\ndef run(words, version=1, level='H', picture=None, colorized=False, contrast=1.0, brightness=1.0, save_name=None, save_dir=os.getcwd()):\n\n    supported_chars = r\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ··,.:;+-*/\\~!@#$%^&`'=<>[]()?_{}|\"\n\n\n    # check every parameter\n    if not isinstance(words, str) or any(i not in supported_chars for i in words):\n        raise ValueError('Wrong words! Make sure the characters are supported!')\n    if not isinstance(version, int) or version not in range(1, 41):\n        raise ValueError('Wrong version! Please choose a int-type value from 1 to 40!')\n    if not isinstance(level, str) or len(level)>1 or level not in 'LMQH':\n        raise ValueError(\"Wrong level! Please choose a str-type level from {'L','M','Q','H'}!\")\n    if picture:\n        if not isinstance(picture, str) or not os.path.isfile(picture) or picture[-4:] not in ('.jpg','.png','.bmp','.gif'):\n            raise ValueError(\"Wrong picture! Input a filename that exists and be tailed with one of {'.jpg', '.png', '.bmp', '.gif'}!\")\n        if picture[-4:] == '.gif' and save_name and save_name[-4:] != '.gif':\n            raise ValueError('Wrong save_name! If the picuter is .gif format, the output filename should be .gif format, too!')\n        if not isinstance(colorized, bool):\n            raise ValueError('Wrong colorized! Input a bool-type value!')\n        if not isinstance(contrast, float):\n            raise ValueError('Wrong contrast! Input a float-type value!')\n        if not isinstance(brightness, float):\n            raise ValueError('Wrong brightness! Input a float-type value!')\n    if save_name and (not isinstance(save_name, str) or save_name[-4:] not in ('.jpg','.png','.bmp','.gif')):\n        raise ValueError(\"Wrong save_name! Input a filename tailed with one of {'.jpg', '.png', '.bmp', '.gif'}!\")\n    if not os.path.isdir(save_dir):\n        raise ValueError('Wrong save_dir! Input a existing-directory!')\n    \n        \n    def combine(ver, qr_name, bg_name, colorized, contrast, brightness, save_dir, save_name=None):\n        from amzqr.mylibs.constant import alig_location\n        from PIL import ImageEnhance, ImageFilter\n        \n        qr = Image.open(qr_name)\n        qr = qr.convert('RGBA') if colorized else qr\n        \n        bg0 = Image.open(bg_name).convert('RGBA')\n        bg0 = ImageEnhance.Contrast(bg0).enhance(contrast)\n        bg0 = ImageEnhance.Brightness(bg0).enhance(brightness)\n\n        if bg0.size[0] < bg0.size[1]:\n            bg0 = bg0.resize((qr.size[0]-24, (qr.size[0]-24)*int(bg0.size[1]/bg0.size[0])))\n        else:\n            bg0 = bg0.resize(((qr.size[1]-24)*int(bg0.size[0]/bg0.size[1]), qr.size[1]-24))    \n            \n        bg = bg0 if colorized else bg0.convert('1')\n        \n        aligs = []\n        if ver > 1:\n            aloc = alig_location[ver-2]\n            for a in range(len(aloc)):\n                for b in range(len(aloc)):\n                    if not ((a==b==0) or (a==len(aloc)-1 and b==0) or (a==0 and b==len(aloc)-1)):\n                        for i in range(3*(aloc[a]-2), 3*(aloc[a]+3)):\n                            for j in range(3*(aloc[b]-2), 3*(aloc[b]+3)):\n                                aligs.append((i,j))\n\n        for i in range(qr.size[0]-24):\n            for j in range(qr.size[1]-24):\n                if not ((i in (18,19,20)) or (j in (18,19,20)) or (i<24 and j<24) or (i<24 and j>qr.size[1]-49) or (i>qr.size[0]-49 and j<24) or ((i,j) in aligs) or (i%3==1 and j%3==1) or (bg0.getpixel((i,j))[3]==0)):\n                    qr.putpixel((i+12,j+12), bg.getpixel((i,j)))\n        \n        qr_name = os.path.join(save_dir, os.path.splitext(os.path.basename(bg_name))[0] + '_qrcode.png') if not save_name else os.path.join(save_dir, save_name)\n        qr.resize((qr.size[0]*3, qr.size[1]*3)).save(qr_name)\n        return qr_name\n\n    tempdir = os.path.join(os.path.expanduser('~'), '.myqr')\n    \n    try:\n        if not os.path.exists(tempdir):\n            os.makedirs(tempdir)\n\n        ver, qr_name = theqrmodule.get_qrcode(version, level, words, tempdir)\n\n        if picture and picture[-4:]=='.gif':\n            import imageio\n             \n            im = Image.open(picture)\n            duration = im.info.get('duration', 0)\n            im.save(os.path.join(tempdir, '0.png'))\n            while True:\n                try:\n                    seq = im.tell()\n                    im.seek(seq + 1)\n                    im.save(os.path.join(tempdir, '%s.png' %(seq+1)))\n                except EOFError:\n                    break\n            \n            imsname = []\n            for s in range(seq+1):\n                bg_name = os.path.join(tempdir, '%s.png' % s)\n                imsname.append(combine(ver, qr_name, bg_name, colorized, contrast, brightness, tempdir))\n            \n            ims = [imageio.imread(pic) for pic in imsname]\n            qr_name = os.path.join(save_dir, os.path.splitext(os.path.basename(picture))[0] + '_qrcode.gif') if not save_name else os.path.join(save_dir, save_name)\n            imageio.mimwrite(qr_name, ims, '.gif', **{ 'duration': duration/1000 })\n        elif picture:\n            qr_name = combine(ver, qr_name, picture, colorized, contrast, brightness, save_dir, save_name)\n        elif qr_name:\n            qr = Image.open(qr_name)\n            qr_name = os.path.join(save_dir, os.path.basename(qr_name)) if not save_name else os.path.join(save_dir, save_name)\n            qr.resize((qr.size[0]*3, qr.size[1]*3)).save(qr_name)\n          \n        return ver, level, qr_name\n        \n    except:\n        raise\n    finally:\n        import shutil\n        if os.path.exists(tempdir):\n            shutil.rmtree(tempdir) "
  },
  {
    "path": "amzqr/mylibs/ECC.py",
    "content": "# -*- coding: utf-8 -*-\n\nfrom amzqr.mylibs.constant import GP_list, ecc_num_per_block, lindex, po2, log\n \n#ecc: Error Correction Codewords\ndef encode(ver, ecl, data_codewords):\n    en = ecc_num_per_block[ver-1][lindex[ecl]]\n    ecc = []\n    for dc in data_codewords:\n        ecc.append(get_ecc(dc, en))\n    return ecc\n\ndef get_ecc(dc, ecc_num):\n    gp = GP_list[ecc_num]\n    remainder = dc\n    for i in range(len(dc)):\n        remainder = divide(remainder, *gp)\n    return remainder\n    \ndef divide(MP, *GP):\n    if MP[0]:\n        GP = list(GP)\n        for i in range(len(GP)):\n            GP[i] += log[MP[0]]\n            if GP[i] > 255:\n                GP[i] %= 255\n            GP[i] = po2[GP[i]]\n        return XOR(GP, *MP)\n    else:\n        return XOR([0]*len(GP), *MP)\n    \n    \ndef XOR(GP, *MP):\n    MP = list(MP)\n    a = len(MP) - len(GP)\n    if a < 0:\n        MP += [0] * (-a)\n    elif a > 0:\n        GP += [0] * a\n    \n    remainder = []\n    for i in range(1, len(MP)):\n        remainder.append(MP[i]^GP[i])\n    return remainder"
  },
  {
    "path": "amzqr/mylibs/__init__.py",
    "content": "# -*- coding: utf-8 -*-\n"
  },
  {
    "path": "amzqr/mylibs/constant.py",
    "content": "# -*- coding: utf-8 -*-\n\"\"\"\n***** for data.py *******\n\"\"\"\n# character capacities\n# {level1: [version1(mode1,mode2,mode3,mode4), version2(..,..,..,..), ...],\n#   level2: [version1(mode1,mode2,mode3,mode4), version2(..,..,..,..),...],\n#   ...}\nchar_cap = {\n        'L': [(41, 25, 17, 10), (77, 47, 32, 20), (127, 77, 53, 32), (187, 114, 78, 48), (255, 154, 106, 65), (322, 195, 134, 82), (370, 224, 154, 95), (461, 279, 192, 118), (552, 335, 230, 141), (652, 395, 271, 167), (772, 468, 321, 198), (883, 535, 367, 226), (1022, 619, 425, 262), (1101, 667, 458, 282), (1250, 758, 520, 320), (1408, 854, 586, 361), (1548, 938, 644, 397), (1725, 1046, 718, 442), (1903, 1153, 792, 488), (2061, 1249, 858, 528), (2232, 1352, 929, 572), (2409, 1460, 1003, 618), (2620, 1588, 1091, 672), (2812, 1704, 1171, 721), (3057, 1853, 1273, 784), (3283, 1990, 1367, 842), (3517, 2132, 1465, 902), (3669, 2223, 1528, 940), (3909, 2369, 1628, 1002), (4158, 2520, 1732, 1066), (4417, 2677, 1840, 1132), (4686, 2840, 1952, 1201), (4965, 3009, 2068, 1273), (5253, 3183, 2188, 1347), (5529, 3351, 2303, 1417), (5836, 3537, 2431, 1496), (6153, 3729, 2563, 1577), (6479, 3927, 2699, 1661), (6743, 4087, 2809, 1729), (7089, 4296, 2953, 1817)],\n        'M': [(34, 20, 14, 8), (63, 38, 26, 16), (101, 61, 42, 26), (149, 90, 62, 38), (202, 122, 84, 52), (255, 154, 106, 65), (293, 178, 122, 75), (365, 221, 152, 93), (432, 262, 180, 111), (513, 311, 213, 131), (604, 366, 251, 155), (691, 419, 287, 177), (796, 483, 331, 204), (871, 528, 362, 223), (991, 600, 412, 254), (1082, 656, 450, 277), (1212, 734, 504, 310), (1346, 816, 560, 345), (1500, 909, 624, 384), (1600, 970, 666, 410), (1708, 1035, 711, 438), (1872, 1134, 779, 480), (2059, 1248, 857, 528), (2188, 1326, 911, 561), (2395, 1451, 997, 614), (2544, 1542, 1059, 652), (2701, 1637, 1125, 692), (2857, 1732, 1190, 732), (3035, 1839, 1264, 778), (3289, 1994, 1370, 843), (3486, 2113, 1452, 894), (3693, 2238, 1538, 947), (3909, 2369, 1628, 1002), (4134, 2506, 1722, 1060), (4343, 2632, 1809, 1113), (4588, 2780, 1911, 1176), (4775, 2894, 1989, 1224), (5039, 3054, 2099, 1292), (5313, 3220, 2213, 1362), (5596, 3391, 2331, 1435)],\n        'Q': [(27, 16, 11, 7), (48, 29, 20, 12), (77, 47, 32, 20), (111, 67, 46, 28), (144, 87, 60, 37), (178, 108, 74, 45), (207, 125, 86, 53), (259, 157, 108, 66), (312, 189, 130, 80), (364, 221, 151, 93), (427, 259, 177, 109), (489, 296, 203, 125), (580, 352, 241, 149), (621, 376, 258, 159), (703, 426, 292, 180), (775, 470, 322, 198), (876, 531, 364, 224), (948, 574, 394, 243), (1063, 644, 442, 272), (1159, 702, 482, 297), (1224, 742, 509, 314), (1358, 823, 565, 348), (1468, 890, 611, 376), (1588, 963, 661, 407), (1718, 1041, 715, 440), (1804, 1094, 751, 462), (1933, 1172, 805, 496), (2085, 1263, 868, 534), (2181, 1322, 908, 559), (2358, 1429, 982, 604), (2473, 1499, 1030, 634), (2670, 1618, 1112, 684), (2805, 1700, 1168, 719), (2949, 1787, 1228, 756), (3081, 1867, 1283, 790), (3244, 1966, 1351, 832), (3417, 2071, 1423, 876), (3599, 2181, 1499, 923), (3791, 2298, 1579, 972), (3993, 2420, 1663, 1024)],\n        'H': [(17, 10, 7, 4), (34, 20, 14, 8), (58, 35, 24, 15), (82, 50, 34, 21), (106, 64, 44, 27), (139, 84, 58, 36), (154, 93, 64, 39), (202, 122, 84, 52), (235, 143, 98, 60), (288, 174, 119, 74), (331, 200, 137, 85), (374, 227, 155, 96), (427, 259, 177, 109), (468, 283, 194, 120), (530, 321, 220, 136), (602, 365, 250, 154), (674, 408, 280, 173), (746, 452, 310, 191), (813, 493, 338, 208), (919, 557, 382, 235), (969, 587, 403, 248), (1056, 640, 439, 270), (1108, 672, 461, 284), (1228, 744, 511, 315), (1286, 779, 535, 330), (1425, 864, 593, 365), (1501, 910, 625, 385), (1581, 958, 658, 405), (1677, 1016, 698, 430), (1782, 1080, 742, 457), (1897, 1150, 790, 486), (2022, 1226, 842, 518), (2157, 1307, 898, 553), (2301, 1394, 958, 590), (2361, 1431, 983, 605), (2524, 1530, 1051, 647), (2625, 1591, 1093, 673), (2735, 1658, 1139, 701), (2927, 1774, 1219, 750), (3057, 1852, 1273, 784)]\n        }\n\nmindex = {'numeric':0, 'alphanumeric':1, 'byte':2, 'kanji':3}\n\n# [\n# version1[level1,level2,level3,level4], \n# version2[..,..,..,..],\n# ...\n#   ]\nrequired_bytes = [\n        [19, 16, 13, 9], [34, 28, 22, 16], [55, 44, 34, 26], [80, 64, 48, 36], [108, 86, 62, 46], [136, 108, 76, 60], [156, 124, 88, 66], [194, 154, 110, 86], [232, 182, 132, 100], [274, 216, 154, 122], [324, 254, 180, 140], [370, 290, 206, 158], [428, 334, 244, 180], [461, 365, 261, 197], [523, 415, 295, 223], [589, 453, 325, 253], [647, 507, 367, 283], [721, 563, 397, 313], [795, 627, 445, 341], [861, 669, 485, 385], [932, 714, 512, 406], [1006, 782, 568, 442], [1094, 860, 614, 464], [1174, 914, 664, 514], [1276, 1000, 718, 538], [1370, 1062, 754, 596], [1468, 1128, 808, 628], [1531, 1193, 871, 661], [1631, 1267, 911, 701], [1735, 1373, 985, 745], [1843, 1455, 1033, 793], [1955, 1541, 1115, 845], [2071, 1631, 1171, 901], [2191, 1725, 1231, 961], [2306, 1812, 1286, 986], [2434, 1914, 1354, 1054], [2566, 1992, 1426, 1096], [2702, 2102, 1502, 1142], [2812, 2216, 1582, 1222], [2956, 2334, 1666, 1276]\n        ]\n\nnum_list = '0123456789'\nalphanum_list = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n\n# [\n# version1[\n#       level1(num_of_group_1_blocks, DC_per_group_1_block, num_of_group_2_blocks, DC_per_group_2_block),\n#       level2(..,..,..,..),\n#       level3(..,..,..,..),\n#       level4(..,..,..,..)\n#       ], \n# version2[level1(..), level2(..), level3(..), level4(..)],\n# ...\n#   ]\ngrouping_list = [\n    [(1, 19, 0, 0), (1, 16, 0, 0), (1, 13, 0, 0), (1, 9, 0, 0)], [(1, 34, 0, 0), (1, 28, 0, 0), (1, 22, 0, 0), (1, 16, 0, 0)], [(1, 55, 0, 0), (1, 44, 0, 0), (2, 17, 0, 0), (2, 13, 0, 0)], [(1, 80, 0, 0), (2, 32, 0, 0), (2, 24, 0, 0), (4, 9, 0, 0)], [(1, 108, 0, 0), (2, 43, 0, 0), (2, 15, 2, 16), (2, 11, 2, 12)], [(2, 68, 0, 0), (4, 27, 0, 0), (4, 19, 0, 0), (4, 15, 0, 0)], [(2, 78, 0, 0), (4, 31, 0, 0), (2, 14, 4, 15), (4, 13, 1, 14)], [(2, 97, 0, 0), (2, 38, 2, 39), (4, 18, 2, 19), (4, 14, 2, 15)], [(2, 116, 0, 0), (3, 36, 2, 37), (4, 16, 4, 17), (4, 12, 4, 13)], [(2, 68, 2, 69), (4, 43, 1, 44), (6, 19, 2, 20), (6, 15, 2, 16)], [(4, 81, 0, 0), (1, 50, 4, 51), (4, 22, 4, 23), (3, 12, 8, 13)], [(2, 92, 2, 93), (6, 36, 2, 37), (4, 20, 6, 21), (7, 14, 4, 15)], [(4, 107, 0, 0), (8, 37, 1, 38), (8, 20, 4, 21), (12, 11, 4, 12)], [(3, 115, 1, 116), (4, 40, 5, 41), (11, 16, 5, 17), (11, 12, 5, 13)], [(5, 87, 1, 88), (5, 41, 5, 42), (5, 24, 7, 25), (11, 12, 7, 13)], [(5, 98, 1, 99), (7, 45, 3, 46), (15, 19, 2, 20), (3, 15, 13, 16)], [(1, 107, 5, 108), (10, 46, 1, 47), (1, 22, 15, 23), (2, 14, 17, 15)], [(5, 120, 1, 121), (9, 43, 4, 44), (17, 22, 1, 23), (2, 14, 19, 15)], [(3, 113, 4, 114), (3, 44, 11, 45), (17, 21, 4, 22), (9, 13, 16, 14)], [(3, 107, 5, 108), (3, 41, 13, 42), (15, 24, 5, 25), (15, 15, 10, 16)], [(4, 116, 4, 117), (17, 42, 0, 0), (17, 22, 6, 23), (19, 16, 6, 17)], [(2, 111, 7, 112), (17, 46, 0, 0), (7, 24, 16, 25), (34, 13, 0, 0)], [(4, 121, 5, 122), (4, 47, 14, 48), (11, 24, 14, 25), (16, 15, 14, 16)], [(6, 117, 4, 118), (6, 45, 14, 46), (11, 24, 16, 25), (30, 16, 2, 17)], [(8, 106, 4, 107), (8, 47, 13, 48), (7, 24, 22, 25), (22, 15, 13, 16)], [(10, 114, 2, 115), (19, 46, 4, 47), (28, 22, 6, 23), (33, 16, 4, 17)], [(8, 122, 4, 123), (22, 45, 3, 46), (8, 23, 26, 24), (12, 15, 28, 16)], [(3, 117, 10, 118), (3, 45, 23, 46), (4, 24, 31, 25), (11, 15, 31, 16)], [(7, 116, 7, 117), (21, 45, 7, 46), (1, 23, 37, 24), (19, 15, 26, 16)], [(5, 115, 10, 116), (19, 47, 10, 48), (15, 24, 25, 25), (23, 15, 25, 16)], [(13, 115, 3, 116), (2, 46, 29, 47), (42, 24, 1, 25), (23, 15, 28, 16)], [(17, 115, 0, 0), (10, 46, 23, 47), (10, 24, 35, 25), (19, 15, 35, 16)], [(17, 115, 1, 116), (14, 46, 21, 47), (29, 24, 19, 25), (11, 15, 46, 16)], [(13, 115, 6, 116), (14, 46, 23, 47), (44, 24, 7, 25), (59, 16, 1, 17)], [(12, 121, 7, 122), (12, 47, 26, 48), (39, 24, 14, 25), (22, 15, 41, 16)], [(6, 121, 14, 122), (6, 47, 34, 48), (46, 24, 10, 25), (2, 15, 64, 16)], [(17, 122, 4, 123), (29, 46, 14, 47), (49, 24, 10, 25), (24, 15, 46, 16)], [(4, 122, 18, 123), (13, 46, 32, 47), (48, 24, 14, 25), (42, 15, 32, 16)], [(20, 117, 4, 118), (40, 47, 7, 48), (43, 24, 22, 25), (10, 15, 67, 16)], [(19, 118, 6, 119), (18, 47, 31, 48), (34, 24, 34, 25), (20, 15, 61, 16)]\n    ]\n\nmode_indicator = {'numeric': '0001', 'alphanumeric': '0010', 'byte': '0100', 'kanji': '1000'}\n\n\n\n\"\"\"\n******  for ECC.py  *******\n\"\"\"\n#GP: Generator Polynomial, MP: Message Polynomial\nGP_list = {\n        7: [0, 87, 229, 146, 149, 238, 102, 21],\n        10: [0, 251, 67, 46, 61, 118, 70, 64, 94, 32, 45],\n        13: [0, 74, 152, 176, 100, 86, 100, 106, 104, 130, 218, 206, 140, 78],\n        15: [0, 8, 183, 61, 91, 202, 37, 51, 58, 58, 237, 140, 124, 5, 99, 105],\n        16: [0, 120, 104, 107, 109, 102, 161, 76, 3, 91, 191, 147, 169, 182, 194, 225, 120],\n        17: [0, 43, 139, 206, 78, 43, 239, 123, 206, 214, 147, 24, 99, 150, 39, 243, 163, 136],\n        18: [0, 215, 234, 158, 94, 184, 97, 118, 170, 79, 187, 152, 148, 252, 179, 5, 98, 96, 153],\n        20: [0, 17, 60, 79, 50, 61, 163, 26, 187, 202, 180, 221, 225, 83, 239, 156, 164, 212, 212, 188, 190],\n        22: [0, 210, 171, 247, 242, 93, 230, 14, 109, 221, 53, 200, 74, 8, 172, 98, 80, 219, 134, 160, 105, 165, 231],\n        24: [0, 229, 121, 135, 48, 211, 117, 251, 126, 159, 180, 169, 152, 192, 226, 228, 218, 111, 0, 117, 232, 87, 96, 227, 21],\n        26: [0, 173, 125, 158, 2, 103, 182, 118, 17, 145, 201, 111, 28, 165, 53, 161, 21, 245, 142, 13, 102, 48, 227, 153, 145, 218, 70],\n        28: [0, 168, 223, 200, 104, 224, 234, 108, 180, 110, 190, 195, 147, 205, 27, 232, 201, 21, 43, 245, 87, 42, 195, 212, 119, 242, 37, 9, 123],\n        30: [0, 41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193, 224, 130, 156, 37, 251, 216, 238, 40, 192, 180]\n        }\n\n# Error Correction Codewords per block\n# [version1(level1,level2,level3,level4),\n#  version2(..,..,..,..),\n#   ....]\necc_num_per_block = [\n    (7, 10, 13, 17), (10, 16, 22, 28), (15, 26, 18, 22), (20, 18, 26, 16), (26, 24, 18, 22), (18, 16, 24, 28), (20, 18, 18, 26), (24, 22, 22, 26), (30, 22, 20, 24), (18, 26, 24, 28), (20, 30, 28, 24), (24, 22, 26, 28), (26, 22, 24, 22), (30, 24, 20, 24), (22, 24, 30, 24), (24, 28, 24, 30), (28, 28, 28, 28), (30, 26, 28, 28), (28, 26, 26, 26), (28, 26, 30, 28), (28, 26, 28, 30), (28, 28, 30, 24), (30, 28, 30, 30), (30, 28, 30, 30), (26, 28, 30, 30), (28, 28, 28, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30), (30, 28, 30, 30)\n    ]\n        \n\n# powers of 2 list  \npo2 = [\n    1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143, 3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80, 160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231, 211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208, 189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169, 79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99, 198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87, 174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195, 155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125, 250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142, 1\n    ]\n    \n# log list\nlog = [\n    None, 0, 1, 25, 2, 50, 26, 198, 3, 223, 51, 238, 27, 104, 199, 75, 4, 100, 224, 14, 52, 141, 239, 129, 28, 193, 105, 248, 200, 8, 76, 113, 5, 138, 101, 47, 225, 36, 15, 33, 53, 147, 142, 218, 240, 18, 130, 69, 29, 181, 194, 125, 106, 39, 249, 185, 201, 154, 9, 120, 77, 228, 114, 166, 6, 191, 139, 98, 102, 221, 48, 253, 226, 152, 37, 179, 16, 145, 34, 136, 54, 208, 148, 206, 143, 150, 219, 189, 241, 210, 19, 92, 131, 56, 70, 64, 30, 66, 182, 163, 195, 72, 126, 110, 107, 58, 40, 84, 250, 133, 186, 61, 202, 94, 155, 159, 10, 21, 121, 43, 78, 212, 229, 172, 115, 243, 167, 87, 7, 112, 192, 247, 140, 128, 99, 13, 103, 74, 222, 237, 49, 197, 254, 24, 227, 165, 153, 119, 38, 184, 180, 124, 17, 68, 146, 217, 35, 32, 137, 46, 55, 63, 209, 91, 149, 188, 207, 205, 144, 135, 151, 178, 220, 252, 190, 97, 242, 86, 211, 171, 20, 42, 93, 158, 132, 60, 57, 83, 71, 109, 65, 162, 31, 45, 67, 216, 183, 123, 164, 118, 196, 23, 73, 236, 127, 12, 111, 246, 108, 161, 59, 82, 41, 157, 85, 170, 251, 96, 134, 177, 187, 204, 62, 90, 203, 89, 95, 176, 156, 169, 160, 81, 11, 245, 22, 235, 122, 117, 44, 215, 79, 174, 213, 233, 230, 231, 173, 232, 116, 214, 244, 234, 168, 80, 88, 175\n    ]\n\n\"\"\"\n******  for data.py + ECC.py + structure.py + matrix.py  *******\n\"\"\"\nlindex = {'L':0, 'M':1, 'Q':2, 'H':3}\n    \n\"\"\"\n******  for structure.py  *******\n\"\"\"    \nrequired_remainder_bits = (0,7,7,7,7,7,0,0,0,0,0,0,0,3,3,3,3,3,3,3,4,4,4,4,4,4,4,3,3,3,3,3,3,3,0,0,0,0,0,0)\n\n# [\n# version1[\n#       level1(num_of_group_1_blocks, DC_per_group_1_block, num_of_group_2_blocks, DC_per_group_2_block),\n#       level2(..,..,..,..),\n#       level3(..,..,..,..),\n#       level4(..,..,..,..)\n#       ], \n# version2[level1(..), level2(..), level3(..), level4(..)],\n# ...\n#   ]\ngrouping_list = [\n    [(1, 19, 0, 0), (1, 16, 0, 0), (1, 13, 0, 0), (1, 9, 0, 0)], [(1, 34, 0, 0), (1, 28, 0, 0), (1, 22, 0, 0), (1, 16, 0, 0)], [(1, 55, 0, 0), (1, 44, 0, 0), (2, 17, 0, 0), (2, 13, 0, 0)], [(1, 80, 0, 0), (2, 32, 0, 0), (2, 24, 0, 0), (4, 9, 0, 0)], [(1, 108, 0, 0), (2, 43, 0, 0), (2, 15, 2, 16), (2, 11, 2, 12)], [(2, 68, 0, 0), (4, 27, 0, 0), (4, 19, 0, 0), (4, 15, 0, 0)], [(2, 78, 0, 0), (4, 31, 0, 0), (2, 14, 4, 15), (4, 13, 1, 14)], [(2, 97, 0, 0), (2, 38, 2, 39), (4, 18, 2, 19), (4, 14, 2, 15)], [(2, 116, 0, 0), (3, 36, 2, 37), (4, 16, 4, 17), (4, 12, 4, 13)], [(2, 68, 2, 69), (4, 43, 1, 44), (6, 19, 2, 20), (6, 15, 2, 16)], [(4, 81, 0, 0), (1, 50, 4, 51), (4, 22, 4, 23), (3, 12, 8, 13)], [(2, 92, 2, 93), (6, 36, 2, 37), (4, 20, 6, 21), (7, 14, 4, 15)], [(4, 107, 0, 0), (8, 37, 1, 38), (8, 20, 4, 21), (12, 11, 4, 12)], [(3, 115, 1, 116), (4, 40, 5, 41), (11, 16, 5, 17), (11, 12, 5, 13)], [(5, 87, 1, 88), (5, 41, 5, 42), (5, 24, 7, 25), (11, 12, 7, 13)], [(5, 98, 1, 99), (7, 45, 3, 46), (15, 19, 2, 20), (3, 15, 13, 16)], [(1, 107, 5, 108), (10, 46, 1, 47), (1, 22, 15, 23), (2, 14, 17, 15)], [(5, 120, 1, 121), (9, 43, 4, 44), (17, 22, 1, 23), (2, 14, 19, 15)], [(3, 113, 4, 114), (3, 44, 11, 45), (17, 21, 4, 22), (9, 13, 16, 14)], [(3, 107, 5, 108), (3, 41, 13, 42), (15, 24, 5, 25), (15, 15, 10, 16)], [(4, 116, 4, 117), (17, 42, 0, 0), (17, 22, 6, 23), (19, 16, 6, 17)], [(2, 111, 7, 112), (17, 46, 0, 0), (7, 24, 16, 25), (34, 13, 0, 0)], [(4, 121, 5, 122), (4, 47, 14, 48), (11, 24, 14, 25), (16, 15, 14, 16)], [(6, 117, 4, 118), (6, 45, 14, 46), (11, 24, 16, 25), (30, 16, 2, 17)], [(8, 106, 4, 107), (8, 47, 13, 48), (7, 24, 22, 25), (22, 15, 13, 16)], [(10, 114, 2, 115), (19, 46, 4, 47), (28, 22, 6, 23), (33, 16, 4, 17)], [(8, 122, 4, 123), (22, 45, 3, 46), (8, 23, 26, 24), (12, 15, 28, 16)], [(3, 117, 10, 118), (3, 45, 23, 46), (4, 24, 31, 25), (11, 15, 31, 16)], [(7, 116, 7, 117), (21, 45, 7, 46), (1, 23, 37, 24), (19, 15, 26, 16)], [(5, 115, 10, 116), (19, 47, 10, 48), (15, 24, 25, 25), (23, 15, 25, 16)], [(13, 115, 3, 116), (2, 46, 29, 47), (42, 24, 1, 25), (23, 15, 28, 16)], [(17, 115, 0, 0), (10, 46, 23, 47), (10, 24, 35, 25), (19, 15, 35, 16)], [(17, 115, 1, 116), (14, 46, 21, 47), (29, 24, 19, 25), (11, 15, 46, 16)], [(13, 115, 6, 116), (14, 46, 23, 47), (44, 24, 7, 25), (59, 16, 1, 17)], [(12, 121, 7, 122), (12, 47, 26, 48), (39, 24, 14, 25), (22, 15, 41, 16)], [(6, 121, 14, 122), (6, 47, 34, 48), (46, 24, 10, 25), (2, 15, 64, 16)], [(17, 122, 4, 123), (29, 46, 14, 47), (49, 24, 10, 25), (24, 15, 46, 16)], [(4, 122, 18, 123), (13, 46, 32, 47), (48, 24, 14, 25), (42, 15, 32, 16)], [(20, 117, 4, 118), (40, 47, 7, 48), (43, 24, 22, 25), (10, 15, 67, 16)], [(19, 118, 6, 119), (18, 47, 31, 48), (34, 24, 34, 25), (20, 15, 61, 16)]\n    ]\n\n\n\n\"\"\"\n******  for matrix.py  *******\n\"\"\"\n# Alignment Pattern Locations\nalig_location = [\n    (6, 18), (6, 22), (6, 26), (6, 30), (6, 34), (6, 22, 38), (6, 24, 42), (6, 26, 46), (6, 28, 50), (6, 30, 54), (6, 32, 58), (6, 34, 62), (6, 26, 46, 66), (6, 26, 48, 70), (6, 26, 50, 74), (6, 30, 54, 78), (6, 30, 56, 82), (6, 30, 58, 86), (6, 34, 62, 90), (6, 28, 50, 72, 94), (6, 26, 50, 74, 98), (6, 30, 54, 78, 102), (6, 28, 54, 80, 106), (6, 32, 58, 84, 110), (6, 30, 58, 86, 114), (6, 34, 62, 90, 118), (6, 26, 50, 74, 98, 122), (6, 30, 54, 78, 102, 126), (6, 26, 52, 78, 104, 130), (6, 30, 56, 82, 108, 134), (6, 34, 60, 86, 112, 138), (6, 30, 58, 86, 114, 142), (6, 34, 62, 90, 118, 146), (6, 30, 54, 78, 102, 126, 150), (6, 24, 50, 76, 102, 128, 154), (6, 28, 54, 80, 106, 132, 158), (6, 32, 58, 84, 110, 136, 162), (6, 26, 54, 82, 110, 138, 166), (6, 30, 58, 86, 114, 142, 170)\n    ]\n\n# List of all Format Information Strings\n# [\n#   level1[mask_pattern0, mask_pattern1, mask_...3,...], \n#   level2[...], \n#   level3[...], \n#   level4[...]\n#   ]    \nformat_info_str = [\n    ['111011111000100', '111001011110011', '111110110101010', '111100010011101', '110011000101111', '110001100011000', '110110001000001', '110100101110110'], ['101010000010010', '101000100100101', '101111001111100', '101101101001011', '100010111111001', '100000011001110', '100111110010111', '100101010100000'], ['011010101011111', '011000001101000', '011111100110001', '011101000000110', '010010010110100', '010000110000011', '010111011011010', '010101111101101'], ['001011010001001', '001001110111110', '001110011100111', '001100111010000', '000011101100010', '000001001010101', '000110100001100', '000100000111011']\n    ]\n\n# Version Information Strings\nversion_info_str = [\n    '000111110010010100', '001000010110111100', '001001101010011001', '001010010011010011', '001011101111110110', '001100011101100010', '001101100001000111', '001110011000001101', '001111100100101000', '010000101101111000', '010001010001011101', '010010101000010111', '010011010100110010', '010100100110100110', '010101011010000011', '010110100011001001', '010111011111101100', '011000111011000100', '011001000111100001', '011010111110101011', '011011000010001110', '011100110000011010', '011101001100111111', '011110110101110101', '011111001001010000', '100000100111010101', '100001011011110000', '100010100010111010', '100011011110011111', '100100101100001011', '100101010000101110', '100110101001100100', '100111010101000001', '101000110001101001'\n    ]\n"
  },
  {
    "path": "amzqr/mylibs/data.py",
    "content": "# -*- coding: utf-8 -*-\n\nfrom amzqr.mylibs.constant import char_cap, required_bytes, mindex, lindex, num_list, alphanum_list, grouping_list, mode_indicator\n       \n# ecl: Error Correction Level(L,M,Q,H)\ndef encode(ver, ecl, str):\n    mode_encoding = {\n            'numeric': numeric_encoding,\n            'alphanumeric': alphanumeric_encoding,\n            'byte': byte_encoding,\n            'kanji': kanji_encoding\n            }\n          \n    ver, mode = analyse(ver, ecl, str)\n    \n    print('line 16: mode:', mode)\n    \n    code = mode_indicator[mode] + get_cci(ver, mode, str) + mode_encoding[mode](str)\n    \n    # Add a Terminator\n    rqbits = 8 * required_bytes[ver-1][lindex[ecl]]\n    b = rqbits - len(code)\n    code += '0000' if b >= 4 else '0' * b\n    \n    # Make the Length a Multiple of 8\n    while len(code) % 8 != 0:\n        code += '0'\n    \n    # Add Pad Bytes if the String is Still too Short\n    while len(code) < rqbits:    \n        code += '1110110000010001' if rqbits - len(code) >= 16 else '11101100'\n        \n    data_code = [code[i:i+8] for i in range(len(code)) if i%8 == 0]\n    data_code = [int(i,2) for i in data_code]\n\n    g = grouping_list[ver-1][lindex[ecl]]\n    data_codewords, i = [], 0\n    for n in range(g[0]):\n        data_codewords.append(data_code[i:i+g[1]])\n        i += g[1]\n    for n in range(g[2]):\n        data_codewords.append(data_code[i:i+g[3]])\n        i += g[3]\n    \n    return ver, data_codewords\n    \ndef analyse(ver, ecl, str):\n    if all(i in num_list for i in str):\n        mode = 'numeric'\n    elif all(i in alphanum_list for i in str):\n        mode = 'alphanumeric'\n    else:\n        mode = 'byte'\n    \n    m = mindex[mode]\n    l = len(str)\n    for i in range(40):\n        if char_cap[ecl][i][m] > l:\n            ver = i + 1 if i+1 > ver else ver\n            break\n \n    return ver, mode\n\ndef numeric_encoding(str):   \n    str_list = [str[i:i+3] for i in range(0,len(str),3)]\n    code = ''\n    for i in str_list:\n        rqbin_len = 10\n        if len(i) == 1: \n            rqbin_len = 4\n        elif len(i) == 2:\n            rqbin_len = 7\n        code_temp = bin(int(i))[2:]\n        code += ('0'*(rqbin_len - len(code_temp)) + code_temp)\n    return code\n    \ndef alphanumeric_encoding(str):\n    code_list = [alphanum_list.index(i) for i in str]\n    code = ''\n    for i in range(1, len(code_list), 2):\n        c = bin(code_list[i-1] * 45 + code_list[i])[2:]\n        c = '0'*(11-len(c)) + c\n        code += c\n    if i != len(code_list) - 1:\n        c = bin(code_list[-1])[2:]\n        c = '0'*(6-len(c)) + c\n        code += c\n    \n    return code\n    \ndef byte_encoding(str):\n    code = ''\n    for i in str:\n        c = bin(ord(i.encode('iso-8859-1')))[2:]\n        c = '0'*(8-len(c)) + c\n        code += c\n    return code\n    \ndef kanji_encoding(str):\n    pass\n    \n# cci: character count indicator  \ndef get_cci(ver, mode, str):\n    if 1 <= ver <= 9:\n        cci_len = (10, 9, 8, 8)[mindex[mode]]\n    elif 10 <= ver <= 26:\n        cci_len = (12, 11, 16, 10)[mindex[mode]]\n    else:\n        cci_len = (14, 13, 16, 12)[mindex[mode]]\n        \n    cci = bin(len(str))[2:]\n    cci = '0' * (cci_len - len(cci)) + cci\n    return cci\n    \nif __name__ == '__main__':\n    s = '123456789'\n    v, datacode = encode(1, 'H', s)\n    print(v, datacode)"
  },
  {
    "path": "amzqr/mylibs/draw.py",
    "content": "# -*- coding: utf-8 -*-\n\nfrom PIL import Image\nimport os\n\ndef draw_qrcode(abspath, qrmatrix):\n    unit_len = 3\n    x = y = 4*unit_len\n    pic = Image.new('1', [(len(qrmatrix)+8)*unit_len]*2, 'white')\n    \n    for line in qrmatrix:\n        for module in line:\n            if module:\n                draw_a_black_unit(pic, x, y, unit_len)\n            x += unit_len\n        x, y = 4*unit_len, y+unit_len\n\n    saving = os.path.join(abspath, 'qrcode.png')\n    pic.save(saving)\n    return saving\n    \ndef draw_a_black_unit(p, x, y, ul):\n    for i in range(ul):\n        for j in range(ul):\n            p.putpixel((x+i, y+j), 0)"
  },
  {
    "path": "amzqr/mylibs/matrix.py",
    "content": "# -*- coding: utf-8 -*-\n     \nfrom amzqr.mylibs.constant import alig_location, format_info_str, version_info_str, lindex\n    \ndef get_qrmatrix(ver, ecl, bits):\n    num = (ver - 1) * 4 + 21\n    qrmatrix = [[None] * num for i in range(num)]\n    #  [([None] * num * num)[i:i+num] for i in range(num * num) if i % num == 0] \n\n    # Add the Finder Patterns & Add the Separators\n    add_finder_and_separator(qrmatrix)\n    \n    # Add the Alignment Patterns\n    add_alignment(ver, qrmatrix)\n    \n    # Add the Timing Patterns\n    add_timing(qrmatrix)\n    \n    # Add the Dark Module and Reserved Areas\n    add_dark_and_reserving(ver, qrmatrix)\n    \n    maskmatrix = [i[:] for i in qrmatrix]\n    \n    # Place the Data Bits\n    place_bits(bits, qrmatrix)\n    \n    # Data Masking\n    mask_num, qrmatrix = mask(maskmatrix, qrmatrix)\n    \n    # Format Information\n    add_format_and_version_string(ver, ecl, mask_num, qrmatrix)\n\n    return qrmatrix\n\ndef add_finder_and_separator(m):             \n    for i in range(8):\n        for j in range(8):\n            if i in (0, 6):\n                m[i][j] = m[-i-1][j] = m[i][-j-1] = 0 if j == 7 else 1\n            elif i in (1, 5):\n                m[i][j] = m[-i-1][j] = m[i][-j-1] = 1 if j in (0, 6) else 0  \n            elif i == 7:\n                m[i][j] = m[-i-1][j] = m[i][-j-1] = 0\n            else:\n                m[i][j] = m[-i-1][j] = m[i][-j-1] = 0 if j in (1, 5, 7) else 1\n    \ndef add_alignment(ver, m):\n    if ver > 1:\n        coordinates = alig_location[ver-2]\n        for i in coordinates:\n            for j in coordinates:\n                if m[i][j] is None:\n                    add_an_alignment(i, j, m)\n            \ndef add_an_alignment(row, column, m):\n    for i in range(row-2, row+3):\n        for j in range(column-2, column+3):\n            m[i][j] = 1 if i in (row-2, row+2) or j in (column-2, column+2) else 0\n    m[row][column] = 1\n    \ndef add_timing(m):\n    for i in range(8, len(m)-8):\n        m[i][6] = m[6][i] = 1 if i % 2 ==0 else 0\n    \ndef add_dark_and_reserving(ver, m):\n    for j in range(8):\n        m[8][j] = m[8][-j-1] = m[j][8] = m[-j-1][8] = 0\n    m[8][8] = 0\n    m[8][6] = m[6][8] = m[-8][8] = 1\n    \n    if ver > 6:\n        for i in range(6):\n            for j in (-9, -10, -11):\n                m[i][j] = m[j][i] = 0\n                \ndef place_bits(bits, m):\n    bit = (int(i) for i in bits)\n\n    up = True\n    for a in range(len(m)-1, 0, -2):\n        a = a-1 if a <= 6 else a\n        irange = range(len(m)-1, -1, -1) if up else range(len(m))\n        for i in irange:\n            for j in (a, a-1):\n                if m[i][j] is None:\n                    m[i][j] = next(bit)\n        up = not up\n  \ndef mask(mm, m):\n    mps = get_mask_patterns(mm)\n    scores = []\n    for mp in mps:\n        for i in range(len(mp)):\n            for j in range(len(mp)):\n                mp[i][j] = mp[i][j] ^ m[i][j]\n        scores.append(compute_score(mp))\n    best = scores.index(min(scores))\n    return best, mps[best]\n    \ndef get_mask_patterns(mm):\n    def formula(i, row, column):\n        if i == 0:\n            return (row + column) % 2 == 0\n        elif i == 1:\n            return row % 2 == 0\n        elif i == 2:\n            return column % 3 == 0\n        elif i == 3:\n            return (row + column) % 3 == 0\n        elif i == 4:\n            return (row // 2 + column // 3) % 2 == 0\n        elif i == 5:\n            return ((row * column) % 2) + ((row * column) % 3) == 0\n        elif i == 6:\n            return (((row * column) % 2) + ((row * column) % 3)) % 2 == 0\n        elif i == 7:\n            return \t(((row + column) % 2) + ((row * column) % 3)) % 2 == 0\n\n    mm[-8][8] = None\n    for i in range(len(mm)):\n        for j in range(len(mm)):\n            mm[i][j] = 0 if mm[i][j] is not None else mm[i][j]\n    mps = []\n    for i in range(8):\n        mp = [ii[:] for ii in mm]\n        for row in range(len(mp)):\n            for column in range(len(mp)):\n                mp[row][column] = 1 if mp[row][column] is None and formula(i, row, column) else 0\n        mps.append(mp)\n        \n    return mps\n            \ndef compute_score(m):\n    def evaluation1(m):\n        def ev1(ma):\n            sc = 0\n            for mi in ma:\n                j = 0\n                while j < len(mi)-4:\n                    n = 4\n                    while mi[j:j+n+1] in [[1]*(n+1), [0]*(n+1)]:\n                        n += 1\n                    (sc, j) = (sc+n-2, j+n) if n > 4 else (sc, j+1)\n            return sc\n        return ev1(m) + ev1(list(map(list, zip(*m))))\n        \n    def evaluation2(m):\n        sc = 0\n        for i in range(len(m)-1):\n            for j in range(len(m)-1):\n                sc += 3 if m[i][j] == m[i+1][j] == m[i][j+1] == m[i+1][j+1] else 0\n        return sc\n        \n    def evaluation3(m):\n        def ev3(ma):\n            sc = 0\n            for mi in ma:\n                j = 0\n                while j < len(mi)-10:\n                    if mi[j:j+11] == [1,0,1,1,1,0,1,0,0,0,0]:\n                        sc += 40\n                        j += 7\n                    elif mi[j:j+11] == [0,0,0,0,1,0,1,1,1,0,1]:\n                        sc += 40\n                        j += 4\n                    else:\n                        j += 1\n            return sc\n        return ev3(m) + ev3(list(map(list, zip(*m))))\n        \n    def evaluation4(m):\n        darknum = 0\n        for i in m:\n            darknum += sum(i)\n        percent = darknum  / (len(m)**2) * 100\n        s = int((50 - percent) / 5) * 5\n        return 2*s if s >=0 else -2*s\n\n    score = evaluation1(m) + evaluation2(m)+ evaluation3(m) + evaluation4(m)\n    return score\n    \ndef add_format_and_version_string(ver, ecl, mask_num, m):\n    fs = [int(i) for i in format_info_str[lindex[ecl]][mask_num]]\n    for j in range(6):\n        m[8][j] = m[-j-1][8] = fs[j]\n        m[8][-j-1] = m[j][8] = fs[-j-1]\n    m[8][7] = m[-7][8] = fs[6]\n    m[8][8] = m[8][-8] = fs[7]\n    m[7][8] = m[8][-7] = fs[8]\n    \n    if ver > 6:\n        vs = (int(i) for i in version_info_str[ver-7])\n        for j in range(5, -1, -1):\n            for i in (-9, -10, -11):\n                m[i][j] = m[j][i] = next(vs)"
  },
  {
    "path": "amzqr/mylibs/structure.py",
    "content": "# -*- coding: utf-8 -*-\n\nfrom amzqr.mylibs.constant import required_remainder_bits, lindex, grouping_list\n\ndef structure_final_bits(ver, ecl, data_codewords, ecc):\n    final_message = interleave_dc(ver, ecl, data_codewords) + interleave_ecc(ecc)\n    \n    # convert to binary & Add Remainder Bits if Necessary\n    final_bits = ''.join(['0'*(8-len(i))+i for i in [bin(i)[2:] for i in final_message]]) + '0' * required_remainder_bits[ver-1]\n    \n    return final_bits\n\ndef interleave_dc(ver, ecl, data_codewords):\n    id = []\n    for t in zip(*data_codewords):\n        id += list(t)\n    g = grouping_list[ver-1][lindex[ecl]]\n    if g[3]:\n        for i in range(g[2]):\n            id.append(data_codewords[i-g[2]][-1])\n    return id\n    \ndef interleave_ecc(ecc):\n    ie = []\n    for t in zip(*ecc):\n        ie += list(t)\n    return ie"
  },
  {
    "path": "amzqr/mylibs/theqrmodule.py",
    "content": "# -*- coding: utf-8 -*-\n\nfrom amzqr.mylibs import data, ECC, structure, matrix, draw\n\n# ver: Version from 1 to 40\n# ecl: Error Correction Level (L,M,Q,H)\n# get a qrcode picture of 3*3 pixels per module\ndef get_qrcode(ver, ecl, str, save_place):\n    # Data Coding\n    ver, data_codewords = data.encode(ver, ecl, str)\n\n    # Error Correction Coding\n    ecc = ECC.encode(ver, ecl, data_codewords)\n    \n    # Structure final bits\n    final_bits = structure.structure_final_bits(ver, ecl, data_codewords, ecc)\n    \n    # Get the QR Matrix\n    qrmatrix = matrix.get_qrmatrix(ver, ecl, final_bits)\n        \n    # Draw the picture and Save it, then return the real ver and the absolute name\n    return ver, draw.draw_qrcode(save_place, qrmatrix)\n"
  },
  {
    "path": "amzqr/terminal.py",
    "content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nfrom amzqr.amzqr import run\nimport os\n\ndef main():\n    import argparse\n    argparser = argparse.ArgumentParser()\n    argparser.add_argument('Words', help = 'The words to produce you QR-code picture, like a URL or a sentence. Please read the README file for the supported characters.')\n    argparser.add_argument('-v', '--version', type = int, choices = range(1,41), default = 1, help = 'The version means the length of a side of the QR-Code picture. From little size to large is 1 to 40.')\n    argparser.add_argument('-l', '--level', choices = list('LMQH'), default = 'H', help = 'Use this argument to choose an Error-Correction-Level: L(Low), M(Medium) or Q(Quartile), H(High). Otherwise, just use the default one: H')\n    argparser.add_argument('-p', '--picture', help = 'the picture  e.g. example.jpg')\n    argparser.add_argument('-c', '--colorized', action = 'store_true', help = \"Produce a colorized QR-Code with your picture. Just works when there is a correct '-p' or '--picture'.\")\n    argparser.add_argument('-con', '--contrast', type = float, default = 1.0, help = 'A floating point value controlling the enhancement of contrast. Factor 1.0 always returns a copy of the original image, lower factors mean less color (brightness, contrast, etc), and higher values more. There are no restrictions on this value. Default: 1.0')\n    argparser.add_argument('-bri', '--brightness', type = float, default = 1.0, help = 'A floating point value controlling the enhancement of brightness. Factor 1.0 always returns a copy of the original image, lower factors mean less color (brightness, contrast, etc), and higher values more. There are no restrictions on this value. Default: 1.0')\n    argparser.add_argument('-n', '--name', help = \"The filename of output tailed with one of {'.jpg', '.png', '.bmp', '.gif'}. eg. exampl.png\")\n    argparser.add_argument('-d', '--directory', default = os.getcwd(), help = 'The directory of output.')\n    args = argparser.parse_args()\n    \n    if args.picture and args.picture[-4:]=='.gif':\n        print('It may take a while, please wait for minutes...')\n    \n    try:\n        ver, ecl, qr_name = run(\n            args.Words,\n            args.version,\n            args.level,\n            args.picture,\n            args.colorized,\n            args.contrast,\n            args.brightness,\n            args.name,\n            args.directory\n            )   \n        print('Succeed! \\nCheck out your', str(ver) + '-' + str(ecl), 'QR-code:', qr_name)\n    except:\n        raise"
  },
  {
    "path": "amzqr.py",
    "content": "# -*- coding: utf-8 -*-\n\n# To be used just when amzqr is not installed\n\nfrom amzqr.terminal import main\n\nmain()\n"
  },
  {
    "path": "requirements.txt",
    "content": "imageio==1.5\nnumpy==1.11.1\nPillow==8.1.1\n"
  },
  {
    "path": "setup.py",
    "content": "# -*- coding: utf-8 -*-\r\nimport setuptools\r\n\r\nwith open(\"README.md\", \"r\", encoding=\"utf-8\") as fh:\r\n    long_description = fh.read()\r\n\r\nsetuptools.setup(\r\n    name='amzqr',\r\n    version='0.0.2',\r\n    keywords='qr qrcode amazing artistic animated gif colorized',\r\n    description='Generater for amazing QR Codes. Including Common, Artistic and Animated QR Codes.',\r\n    long_description=long_description,\r\n    long_description_content_type=\"text/markdown\",\r\n    author='hw',\r\n    author_email='xhaowen.xu@gmail.com',\r\n    url='https://github.com/hwxhw/amazing-qr',\r\n    download_url='https://github.com/hwxhw/amazing-qr',\r\n    project_urls={\r\n        \"Bug Tracker\": \"https://github.com/hwxhw/amazing-qr/issues\",\r\n    },\r\n    install_requires=[\r\n        'imageio >= 1.5',\r\n        'numpy >= 1.11.1',\r\n        'Pillow>=3.3.1'\r\n    ],\r\n    packages=['amzqr', 'amzqr.mylibs'],\r\n    license='GPLv3',\r\n    classifiers=[\r\n        'Programming Language :: Python :: 3',\r\n        'Operating System :: MacOS',\r\n        'Operating System :: POSIX :: Linux',\r\n        'Operating System :: Microsoft :: Windows',\r\n        'License :: OSI Approved :: GNU General Public License v3 (GPLv3)'\r\n    ],\r\n    entry_points={\r\n        'console_scripts': [\r\n            'amzqr=amzqr.terminal:main',\r\n        ],\r\n    },\r\n    python_requires=\">=3\",\r\n)\r\n"
  }
]