├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── aab ├── __init__.py ├── builder.py ├── cli.py ├── config.py ├── git.py ├── legacy.py ├── manifest.py ├── schema.json ├── ui.py └── utils.py ├── poetry.lock ├── pyproject.toml └── tests ├── __init__.py ├── data ├── project-with-no-forms │ ├── addon.json │ └── resources │ │ ├── icons.qrc │ │ └── icons │ │ ├── heart.svg │ │ ├── help.svg │ │ └── optional │ │ ├── coffee.svg │ │ └── email.svg └── sample-project │ ├── addon.json │ ├── designer │ └── dialog.ui │ └── resources │ ├── icons.qrc │ └── icons │ ├── heart.svg │ ├── help.svg │ └── optional │ ├── coffee.svg │ └── email.svg ├── test_legacy.py ├── test_ui.py └── util.py /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | 2 | patreon: glutanimate 3 | ko_fi: glutanimate 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | #### Problem description 11 | 12 | *Please describe the issue concisely in here. In case of an error: Walk us through the steps you took to get there. What happened? What did you expect to happen?* 13 | 14 | 15 | #### Checklist 16 | 17 | *Please replace the space inside the brackets with an **x** if the following items apply:* 18 | 19 | - [ ] I've verified that I use the latest version of aab 20 | - [ ] I've checked if anyone else reported this problem before by looking through the issue reports. I also checked to see if there is a section about known issues in the add-on description, documentation, or README. 21 | 22 | 23 | #### Information about your set-up 24 | 25 | Please run `aab -h` and paste the output below: 26 | 27 | ``` 28 | 29 | ``` 30 | 31 | *Please fill in details about your operating system and environment:* 32 | 33 | - OS: 34 | - Python version: 35 | - Anki version: 36 | 37 | 38 | #### Error message (if any) 39 | 40 | *If you've received an error message, please copy and paste it between the backticks below:* 41 | 42 | 43 | ```python 44 | 45 | ``` -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | #### Checklist 11 | 12 | *Please replace the space inside the brackets with an **x** if the following items apply:* 13 | 14 | - [ ] I've verified that I use the latest version of `aab` 15 | - [ ] I've checked if anyone else suggested this feature before by looking through the issue reports. 16 | 17 | #### Problem case 18 | 19 | *Is your feature request related to a problem? If so, please describe it here. E.g.: "My workflow is such and such, and this and that would help."* 20 | 21 | 22 | 23 | #### Solution 24 | 25 | *Concisely describe the solution you would like* 26 | 27 | 28 | *Concisely describe alternatives you've considered (if any)* 29 | 30 | 31 | 32 | #### More information 33 | 34 | *Additional context: Add any other context or screenshots about the feature request here.* 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question about this project 4 | title: '' 5 | labels: 'question' 6 | assignees: '' 7 | 8 | --- 9 | 10 | #### Checklist 11 | 12 | *Please replace the space inside the brackets with an **x** if the following items apply:* 13 | 14 | - [ ] I've verified that I use the latest version of `aab` 15 | - [ ] I've checked if anyone else asked this question before by looking through the issue reports. 16 | 17 | 18 | #### Your question 19 | 20 | *A clear and concise question about the project.* 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Description 2 | 3 | *Concisely describe what the pull request is trying to achieve. If pertinent, link to an existing issue report, or briefly explain the problem the PR is meant to solve. Feel free to attach screenshots or other media for UI-related changes.* 4 | 5 | 6 | #### Checklist: 7 | 8 | *Please replace the space inside the brackets with an **x** and fill out the ellipses if the following items apply:* 9 | 10 | - [ ] I've read and understood the [contribution guidelines](https://github.com/glutanimate/anki-addon-builder/blob/master/CONTRIBUTING.md) 11 | - [ ] I've tested my changes by building at least one of the [add-ons that use aab](https://github.com/glutanimate/anki-addon-builder/network/dependents?package_id=UGFja2FnZS00MDE1ODkwOTY%3D) for **Anki 2.1** 12 | - [ ] I've tested that the packages produced by my modified branch of aab work with the [latest version of Anki](https://apps.ankiweb.net#download) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | *.pyo 3 | *.pyc 4 | __pycache__/ 5 | # Python 6 | .python-version 7 | .mypy_cache/ 8 | .ropeproject 9 | .env 10 | .venv 11 | env/ 12 | venv/ 13 | ENV/ 14 | env.bak/ 15 | venv.bak/ 16 | *.egg-info 17 | dist 18 | # IDEs 19 | *.sublime-project 20 | *.sublime-workspace 21 | .sublime-backup/ 22 | .idea/ 23 | .vscode/ 24 | # Temp 25 | .gitold 26 | obsolete 27 | research 28 | # Linux FM 29 | .hidden 30 | .directory 31 | # Docs 32 | todo 33 | # GitHub 34 | labels.toml 35 | # Other 36 | .bumpversion.cfg 37 | install.sh 38 | .pytest_cache/ 39 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to Contribute to this Project 2 | 3 | The [common contribution guidelines](https://github.com/glutanimate/docs/blob/master/anki/add-ons/CONTRIBUTING.md#how-to-contribute-to-my-anki-add-ons) also apply here for the most part. Some additions that are specific to `aab`: 4 | 5 | - **Python version support**: In order to support Anki 2.0 builds, it's important that your changes maintain backwards compatibility with Python 2.7 6 | - **Coding style conventions**: Instead of the more idiosyncratic rules used by Anki add-ons, `aab` follows the guidelines employed by the [`black` project](https://github.com/psf/black) 7 | 8 | Thanks! -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This Program is licensed under the GNU Affero General Public License 2 | version 3, extended by a number of additional terms that follow at the 3 | very bottom of the AGPLv3 license text. 4 | 5 | If not otherwise noted, this license applies to all source code items 6 | included with this Program. Code and other resources that are subject 7 | to different licensing terms might also ship with this Program, but 8 | will be clearly marked as such in additional LICENSE* files. 9 | 10 | The AGPLv3 license and additional terms follow. 11 | 12 | 13 | GNU AFFERO GENERAL PUBLIC LICENSE 14 | Version 3, 19 November 2007 15 | 16 | Copyright (C) 2007 Free Software Foundation, Inc. 17 | Everyone is permitted to copy and distribute verbatim copies 18 | of this license document, but changing it is not allowed. 19 | 20 | Preamble 21 | 22 | The GNU Affero General Public License is a free, copyleft license for 23 | software and other kinds of works, specifically designed to ensure 24 | cooperation with the community in the case of network server software. 25 | 26 | The licenses for most software and other practical works are designed 27 | to take away your freedom to share and change the works. By contrast, 28 | our General Public Licenses are intended to guarantee your freedom to 29 | share and change all versions of a program--to make sure it remains free 30 | software for all its users. 31 | 32 | When we speak of free software, we are referring to freedom, not 33 | price. Our General Public Licenses are designed to make sure that you 34 | have the freedom to distribute copies of free software (and charge for 35 | them if you wish), that you receive source code or can get it if you 36 | want it, that you can change the software or use pieces of it in new 37 | free programs, and that you know you can do these things. 38 | 39 | Developers that use our General Public Licenses protect your rights 40 | with two steps: (1) assert copyright on the software, and (2) offer 41 | you this License which gives you legal permission to copy, distribute 42 | and/or modify the software. 43 | 44 | A secondary benefit of defending all users' freedom is that 45 | improvements made in alternate versions of the program, if they 46 | receive widespread use, become available for other developers to 47 | incorporate. Many developers of free software are heartened and 48 | encouraged by the resulting cooperation. However, in the case of 49 | software used on network servers, this result may fail to come about. 50 | The GNU General Public License permits making a modified version and 51 | letting the public access it on a server without ever releasing its 52 | source code to the public. 53 | 54 | The GNU Affero General Public License is designed specifically to 55 | ensure that, in such cases, the modified source code becomes available 56 | to the community. It requires the operator of a network server to 57 | provide the source code of the modified version running there to the 58 | users of that server. Therefore, public use of a modified version, on 59 | a publicly accessible server, gives the public access to the source 60 | code of the modified version. 61 | 62 | An older license, called the Affero General Public License and 63 | published by Affero, was designed to accomplish similar goals. This is 64 | a different license, not a version of the Affero GPL, but Affero has 65 | released a new version of the Affero GPL which permits relicensing under 66 | this license. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU Affero General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Remote Network Interaction; Use with the GNU General Public License. 553 | 554 | Notwithstanding any other provision of this License, if you modify the 555 | Program, your modified version must prominently offer all users 556 | interacting with it remotely through a computer network (if your version 557 | supports such interaction) an opportunity to receive the Corresponding 558 | Source of your version by providing access to the Corresponding Source 559 | from a network server at no charge, through some standard or customary 560 | means of facilitating copying of software. This Corresponding Source 561 | shall include the Corresponding Source for any work covered by version 3 562 | of the GNU General Public License that is incorporated pursuant to the 563 | following paragraph. 564 | 565 | Notwithstanding any other provision of this License, you have 566 | permission to link or combine any covered work with a work licensed 567 | under version 3 of the GNU General Public License into a single 568 | combined work, and to convey the resulting work. The terms of this 569 | License will continue to apply to the part which is the covered work, 570 | but the work with which it is combined will remain governed by version 571 | 3 of the GNU General Public License. 572 | 573 | 14. Revised Versions of this License. 574 | 575 | The Free Software Foundation may publish revised and/or new versions of 576 | the GNU Affero General Public License from time to time. Such new versions 577 | will be similar in spirit to the present version, but may differ in detail to 578 | address new problems or concerns. 579 | 580 | Each version is given a distinguishing version number. If the 581 | Program specifies that a certain numbered version of the GNU Affero General 582 | Public License "or any later version" applies to it, you have the 583 | option of following the terms and conditions either of that numbered 584 | version or of any later version published by the Free Software 585 | Foundation. If the Program does not specify a version number of the 586 | GNU Affero General Public License, you may choose any version ever published 587 | by the Free Software Foundation. 588 | 589 | If the Program specifies that a proxy can decide which future 590 | versions of the GNU Affero General Public License can be used, that proxy's 591 | public statement of acceptance of a version permanently authorizes you 592 | to choose that version for the Program. 593 | 594 | Later license versions may give you additional or different 595 | permissions. However, no additional obligations are imposed on any 596 | author or copyright holder as a result of your choosing to follow a 597 | later version. 598 | 599 | 15. Disclaimer of Warranty. 600 | 601 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 602 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 603 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 604 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 605 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 606 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 607 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 608 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 609 | 610 | 16. Limitation of Liability. 611 | 612 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 613 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 614 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 615 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 616 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 617 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 618 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 619 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 620 | SUCH DAMAGES. 621 | 622 | 17. Interpretation of Sections 15 and 16. 623 | 624 | If the disclaimer of warranty and limitation of liability provided 625 | above cannot be given local legal effect according to their terms, 626 | reviewing courts shall apply local law that most closely approximates 627 | an absolute waiver of all civil liability in connection with the 628 | Program, unless a warranty or assumption of liability accompanies a 629 | copy of the Program in return for a fee. 630 | 631 | END OF TERMS AND CONDITIONS 632 | 633 | =============================================================================== 634 | 635 | ADDITIONAL TERMS APPLICABLE TO THIS PROGRAM 636 | UNDER GNU AGPL VERSION 3 SECTION 7 637 | 638 | The following additional terms ("Additional Terms") supplement and modify the 639 | GNU Affero General Public License, Version 3 ("AGPL") applicable to the present 640 | Program. 641 | 642 | In addition to the terms and conditions of the AGPL, the present Program is 643 | subject to the further restrictions below: 644 | 645 | 1. Trademark and Publicity Rights. 646 | 647 | Except as expressly provided herein, no trademark or publicity rights are 648 | granted. This license does NOT give you any right, title or interest in the 649 | "Glutanimate" name or logo. 650 | 651 | 2. Origin of the Program. 652 | 653 | The origin of the Program must not be misrepresented; you must not claim 654 | that you wrote the original Program. Altered source versions must be plainly 655 | marked as such, and must not be misrepresented as being the original 656 | Program. 657 | 658 | 3. Legal Notices and Author Attributions. 659 | 660 | You must reproduce faithfully all trademark, copyright and other proprietary 661 | and legal notices on any copies of the Program or any other required author 662 | attributions. Legal notices or author attributions displayed as part of the 663 | user interface must be preserved as such. 664 | 665 | 4. Use of Names of Licensors or Authors for Publicity Purposes. 666 | 667 | Outside of the aforementioned legal notices and author attributions, neither 668 | the name of the copyright holder or its affiliates, any other party who 669 | modifies and/or conveys the Program, nor the names of the Program's 670 | sponsors/supporters/patrons may be used to endorse or promote products 671 | derived from this software without specific prior written permission. 672 | 673 | 5. Indemnification. 674 | 675 | IF YOU CONVEY A COVERED WORK AND AGREE WITH ANY RECIPIENT OF THAT COVERED 676 | WORK THAT YOU WILL ASSUME ANY LIABILITY FOR THAT COVERED WORK, YOU HEREBY 677 | AGREE TO INDEMNIFY, DEFEND AND HOLD HARMLESS THE OTHER LICENSORS AND AUTHORS 678 | OF THAT COVERED WORK FOR ANY DAMAGES, DEMANDS, CLAIMS, LOSSES, CAUSES OF 679 | ACTION, LAWSUITS, JUDGMENTS EXPENSES (INCLUDING WITHOUT LIMITATION 680 | REASONABLE ATTORNEYS' FEES AND EXPENSES) OR ANY OTHER LIABLITY ARISING FROM, 681 | RELATED TO OR IN CONNECTION WITH YOUR ASSUMPTIONS OF LIABILITY. 682 | 683 | 6. Preservation of Licensing Terms. 684 | 685 | Any covered work conveyed by you must include this license text in its 686 | entirety. 687 | 688 | ------------------------------------------------------------------------------- 689 | 690 | If you have any questions regarding this license, about any other legal 691 | details, or want to report an infringement of the aforementioned licensing 692 | terms, please feel free to contact me at: 693 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include README.md 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Anki Add-on Builder 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | An opinionated build tool for Anki add-ons. Used in most of my major Anki projects. 10 | 11 | - [Disclaimer](#disclaimer) 12 | - [Installation](#installation) 13 | - [Usage](#usage) 14 | - [Specifications](#specifications) 15 | - [License and Credits](#license-and-credits) 16 | 17 | ### Disclaimer 18 | 19 | #### Project State 20 | 21 | This is still very much a work-in-progress. Neither the API, nor the implementation are set in stone. At this point the project's main purpose lies in replacing the variety of different build scripts I am employing across all of my add-ons, making the build chain more standardized and maintainable. 22 | 23 | #### Platform Support 24 | 25 | `aab` has only been tested on Linux so far, but it might also work on other POSIX-compliant environments like macOS. 26 | 27 | ### Installation 28 | 29 | #### Installing the latest release 30 | 31 | pip install aab 32 | 33 | #### Installing from the master branch 34 | 35 | pip install --upgrade git+https://github.com/glutanimate/anki-addon-builder.git#egg=aab 36 | 37 | #### Installing with Qt support 38 | 39 | `aab` optionally supports building UI forms created with Qt designer. To make sure you have all the pre-requisites installed you can add `[qt5,qt6]` to the command above, i.e.: 40 | 41 | ``` 42 | pip install --upgrade git+https://github.com/glutanimate/anki-addon-builder.git#egg=aab[qt5,qt6] 43 | ``` 44 | 45 | This will enable aab to build Qt forms that are compatible with both Qt5 and Qt6 builds of Anki. If you are only targeting Qt5 or Qt6, you can adjust the command above to only install that particular Qt version. 46 | 47 | ### Usage 48 | 49 | You can get an overview of all supported actions by accessing the built-in help (options below reflect latest main branch state and might not be available in pypi builds, yet): 50 | 51 | ``` 52 | $ aab -h 53 | usage: aab [-h] [-v] {build,ui,manifest,clean,create_dist,build_dist,package_dist} ... 54 | 55 | positional arguments: 56 | {build,ui,manifest,clean,create_dist,build_dist,package_dist} 57 | build Build and package add-on for distribution 58 | ui Compile add-on user interface files 59 | manifest Generate manifest file from add-on properties in addon.json 60 | clean Clean leftover build files 61 | create_dist Prepare source tree distribution for building under build/dist. This is 62 | intended to be used in build scripts and should be run before `build_dist` 63 | and `package_dist`. 64 | build_dist Build add-on files from prepared source tree under build/dist. This step 65 | performs all source code post-processing handled by aab itself (e.g. 66 | building the Qt UI and writing the add-on manifest). As with `create_dist` 67 | and `package_dist`, this command is meant to be used in build scripts 68 | where it can provide an avenue for performing additional processing ahead 69 | of packaging the add-on. 70 | package_dist Package pre-built distribution of add-on files under build/dist into a 71 | distributable .ankiaddon package. This is inteded to be used in build 72 | scripts and called after both `create_dist` and `build_dist` have been 73 | run. 74 | 75 | optional arguments: 76 | -h, --help show this help message and exit 77 | -v, --verbose Enable verbose output 78 | ``` 79 | 80 | Each subcommand also comes with its own help screen, e.g.: 81 | 82 | ``` 83 | $ aab build -h 84 | usage: aab build [-h] [-t {qt6,qt5,all,anki21}] [-d {local,ankiweb,all}] [version] 85 | 86 | positional arguments: 87 | version Version to (pre-)build as a git reference (e.g. 'v1.2.0' or 'd338f6405'). 88 | Special keywords: 'dev' - working directory, 'current' – latest commit, 89 | 'release' – latest tag. Leave empty to build latest tag. 90 | 91 | optional arguments: 92 | -h, --help show this help message and exit 93 | -t {qt6,qt5,all,anki21}, --target {qt6,qt5,all,anki21} 94 | Anki release type to build for. Use 'all' (deprecated alias: 'anki21') to 95 | target both Qt5 and Qt6. 96 | -d {local,ankiweb,all}, --dist {local,ankiweb,all} 97 | Distribution channel to build for 98 | 99 | ``` 100 | 101 | #### Examples 102 | 103 | _Build latest tagged add-on release_ 104 | 105 | ``` 106 | aab build -d local -t all release 107 | ``` 108 | 109 | or simply 110 | 111 | ``` 112 | aab build 113 | ``` 114 | 115 | The output artifacts will be, by default, written into `./build/`. 116 | 117 | _Compile Qt UI forms and resources for Qt6 builds of Anki_ 118 | 119 | ```bash 120 | aab ui -t qt6 121 | ``` 122 | 123 | ### Specifications 124 | 125 | #### Project Structure 126 | 127 | In order for `aab` to work correctly, your project should generally follow the directory structure below: 128 | 129 | ``` 130 | project root 131 | ├── src [required] (contains add-on package) 132 | │ ├── {module_name} [required] (add-on package) 133 | ├── designer [optional] (contains Qt designer .ui files that aab should compile) 134 | ├── resources [optional] (contains Qt designer .qrc files that aab should compile) 135 | └── addon.json [required] (contains add-on meta information read by aab) 136 | ``` 137 | 138 | For a more detailed look at the entire directory tree please feel free to take a look at some of the [add-ons I've published recently](https://github.com/topics/anki-addon?o=desc&q=user%3Aglutanimate&s=updated). 139 | 140 | #### addon.json 141 | 142 | All of the metadata needed by `aab` to work correctly is stored in an `addon.json` file at the root of the project tree. For more information on its fields and their specifications please refer to the [schema file](https://github.com/glutanimate/anki-addon-builder/blob/master/aab/schema.json). 143 | 144 | #### Importing Qt Forms Compiled with `aab` 145 | 146 | `aab` creates a package under `src//gui/forms` that automatically takes care of choosing between forms for Qt5 builds of Anki and Qt6 builds. For instance, to import a UI form saved as `options.ui` in the `designer` folder, in your add-on `__init__.py` you would do: 147 | 148 | ```python 149 | from gui.forms.options import Ui_Dialog # or whichever class name you chose for the widget/dialog 150 | ``` 151 | 152 | #### Using Qt Resources Compiled with `aab` 153 | 154 | Starting with Qt6, PyQt no longer supports Qt resource files. To make the transition easier for add-on authors, `aab` will automatically try to convert any resource files found under `./resources` into a Qt6-supported file structure that is then registered as a `QDir` searchpath. 155 | 156 | Alongside creating the file structure as such, `aab` will also attempt to convert any references to the respective resources in your Qt forms to point to the `QDir` structure. That way icons and other resources embedded into designer forms via the Qt resource system should continue working. References in other parts of your source code will have to be updated manually. 157 | 158 | To utilize this feature, please do the following: 159 | 160 | Pre-supposing that you have generated the `gui` module using `aab ui` (during development) or `aab build` (for builds), initialize the `QDir` searchpath by adding the following to your add-on's `__init__.py`: 161 | 162 | ```python 163 | from .gui.resources import initialize_qt_resources 164 | 165 | initialize_qt_resources() 166 | ``` 167 | 168 | This only has to execute once at add-on initialization time. 169 | 170 | ### License and Credits 171 | 172 | *Anki Add-on Builder* is *Copyright © 2019-2022 [Aristotelis P.](https://glutanimate.com/) (Glutanimate)* 173 | 174 | With code contributions by the following awesome people: 175 | 176 | - [zjosua](https://github.com/zjosua) 177 | - [Rai](https://github.com/agentydragon) 178 | - [BlueGreenmagick](https://github.com/BlueGreenMagick) 179 | 180 | Anki Add-on Builder is free and open-source software. Its source-code is released under the GNU AGPLv3 license, extended by a number of additional terms. For more information please see the [license file](https://github.com/glutanimate/anki-addon-builder/blob/master/LICENSE) that accompanies this program. 181 | 182 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Please see the license file for more details. 183 | -------------------------------------------------------------------------------- /aab/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Handles build tasks for Anki add-ons, including packaging them 34 | to be distributed through AnkiWeb or other channels. 35 | 36 | This script presupposes that you have a proper development environment 37 | set up for the Anki version you are targeting, including having tools 38 | like pyrcc4 and pyuic4 (Anki 2.0) or pyrcc5 and pyuic5 (Anki 2.1) in 39 | your PATH. 40 | 41 | For instructions on how to set up a development environment for Anki 42 | please refer to Anki's documentation. 43 | """ 44 | 45 | from pathlib import Path 46 | 47 | # Meta 48 | 49 | __version__ = "1.0.0-dev.5" 50 | __author__ = "Aristotelis P. (Glutanimate)" 51 | __title__ = "Anki Add-on Builder" 52 | __homepage__ = "https://glutanimate.com" 53 | 54 | COPYRIGHT_MSG = """\ 55 | {title} v{version} 56 | 57 | Copyright (C) 2016-2022 {author} <{homepage}> 58 | 59 | This program comes with ABSOLUTELY NO WARRANTY; 60 | This is free software, and you are welcome to redistribute it 61 | under certain conditions; For details please see the LICENSE file. 62 | """.format( 63 | title=__title__, version=__version__, author=__author__, homepage=__homepage__ 64 | ) 65 | 66 | # Global variables 67 | 68 | # assuming that the cwd is the project root, which might not aloways be the case 69 | # TODO: optionally read project root from env 70 | PATH_PROJECT_ROOT = Path.cwd() 71 | PATH_DIST = PATH_PROJECT_ROOT / "build" / "dist" 72 | PATH_PACKAGE = Path(__file__).resolve().parent 73 | DIST_TYPES = ["local", "ankiweb"] 74 | -------------------------------------------------------------------------------- /aab/builder.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Main Add-on Builder 34 | """ 35 | 36 | import logging 37 | import os 38 | import shutil 39 | import sys 40 | import zipfile 41 | from typing import List 42 | 43 | from . import PATH_DIST, PATH_PROJECT_ROOT 44 | from .config import Config 45 | from .git import Git 46 | from .manifest import ManifestUtils 47 | from .ui import QtVersion, UIBuilder 48 | from .utils import call_shell, copy_recursively, purge 49 | 50 | _trash_patterns = ["*.pyc", "*.pyo", "__pycache__"] 51 | 52 | 53 | def clean_repo(): 54 | logging.info("Cleaning repository...") 55 | if PATH_DIST.exists(): 56 | shutil.rmtree(str(PATH_DIST)) 57 | purge(".", _trash_patterns, recursive=True) 58 | 59 | 60 | class AddonBuilder: 61 | 62 | _paths_licenses = [PATH_DIST, PATH_DIST / "resources"] 63 | _path_optional_icons = PATH_PROJECT_ROOT / "resources" / "icons" / "optional" 64 | _path_changelog = PATH_DIST / "CHANGELOG.md" 65 | 66 | def __init__(self, version=None, callback_archive=None): 67 | self._version = Git().parse_version(version) 68 | # git stash create comes up empty when no changes were made since the 69 | # last commit. Don't use 'dev' as version in these cases. 70 | git_status = call_shell("git status --porcelain") 71 | if self._version == "dev" and git_status == "": 72 | self._version = Git().parse_version("current") 73 | if not self._version: 74 | logging.error("Error: Version could not be determined through Git") 75 | sys.exit(1) 76 | self._callback_archive = callback_archive 77 | self._config = Config() 78 | self._path_dist_module = PATH_DIST / "src" / self._config["module_name"] 79 | 80 | def build(self, qt_versions: List[QtVersion], disttype="local", pyenv=None): 81 | logging.info( 82 | "\n--- Building %s %s for %s ---\n", 83 | self._config["display_name"], 84 | self._version, 85 | disttype, 86 | ) 87 | 88 | self.create_dist() 89 | self.build_dist(qt_versions=qt_versions, disttype=disttype, pyenv=pyenv) 90 | 91 | return self.package_dist(qt_versions=qt_versions, disttype=disttype) 92 | 93 | def create_dist(self): 94 | logging.info( 95 | "Preparing source tree for %s %s ...", 96 | self._config["display_name"], 97 | self._version, 98 | ) 99 | 100 | clean_repo() 101 | 102 | PATH_DIST.mkdir(parents=True) 103 | Git().archive(self._version, PATH_DIST) 104 | 105 | def build_dist(self, qt_versions: List[QtVersion], disttype="local", pyenv=None): 106 | self._copy_licenses() 107 | if self._path_changelog.exists(): 108 | self._copy_changelog() 109 | if self._path_optional_icons.exists(): 110 | self._copy_optional_icons() 111 | if self._callback_archive: 112 | self._callback_archive() 113 | 114 | self._write_manifest(disttype) 115 | 116 | ui_builder = UIBuilder(dist=PATH_DIST, config=self._config) 117 | 118 | should_create_qt_shim: bool = False 119 | for qt_version in qt_versions: 120 | if ui_builder.build(qt_version=qt_version, pyenv=pyenv): 121 | should_create_qt_shim = True 122 | 123 | if should_create_qt_shim: 124 | logging.info("Writing Qt compatibility shim...") 125 | ui_builder.create_qt_shim() 126 | logging.info("Done.") 127 | 128 | def package_dist(self, qt_versions: List[QtVersion], disttype="local"): 129 | return self._package(qt_versions, disttype) 130 | 131 | def _package(self, qt_versions: List[QtVersion], disttype): 132 | logging.info("Packaging add-on...") 133 | config = self._config 134 | 135 | to_zip = self._path_dist_module 136 | ext = "ankiaddon" 137 | 138 | qt_version_str = "+".join(version.name for version in qt_versions) 139 | 140 | out_name = "{repo_name}-{version}-{qt_version_str}{dist}.{ext}".format( 141 | repo_name=config["repo_name"], 142 | version=self._version, 143 | qt_version_str=qt_version_str, 144 | dist="" if disttype == "local" else "-" + disttype, 145 | ext=ext, 146 | ) 147 | 148 | out_path = PATH_PROJECT_ROOT / "build" / out_name 149 | 150 | if out_path.exists(): 151 | out_path.unlink() 152 | 153 | with zipfile.ZipFile(str(out_path), "w", zipfile.ZIP_DEFLATED) as myzip: 154 | rootlen = len(str(to_zip)) + 1 155 | for root, dirs, files in os.walk(str(to_zip)): 156 | for file in files: 157 | path = os.path.join(root, file) 158 | myzip.write(path, path[rootlen:]) 159 | 160 | logging.info("Package saved as {out_name}".format(out_name=out_name)) 161 | logging.info("Done.") 162 | 163 | return out_path 164 | 165 | def _write_manifest(self, disttype): 166 | ManifestUtils.generate_and_write_manifest( 167 | addon_properties=self._config, 168 | version=self._version, 169 | dist_type=disttype, 170 | target_dir=self._path_dist_module, 171 | ) 172 | 173 | def _copy_licenses(self): 174 | logging.info("Copying licenses...") 175 | for path in self._paths_licenses: 176 | if not path.is_dir(): 177 | continue 178 | for file in path.glob("LICENSE*"): 179 | target = self._path_dist_module / "{stem}.txt".format(stem=file.stem) 180 | shutil.copyfile(str(file), str(target)) 181 | 182 | def _copy_changelog(self): 183 | logging.info("Copying changelog...") 184 | target = self._path_dist_module / "CHANGELOG.md" 185 | shutil.copy(str(self._path_changelog), str(target)) 186 | 187 | def _copy_optional_icons(self): 188 | logging.info("Copying additional icons...") 189 | copy_recursively( 190 | self._path_optional_icons, PATH_DIST / "resources" / "icons" / "" 191 | ) 192 | -------------------------------------------------------------------------------- /aab/cli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Anki Add-on Builder 5 | # 6 | # Copyright (C) 2016-2021 Aristotelis P. 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU Affero General Public License as 10 | # published by the Free Software Foundation, either version 3 of the 11 | # License, or (at your option) any later version, with the additions 12 | # listed at the end of the license file that accompanied this program. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU Affero General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU Affero General Public License 20 | # along with this program. If not, see . 21 | # 22 | # NOTE: This program is subject to certain additional terms pursuant to 23 | # Section 7 of the GNU Affero General Public License. You should have 24 | # received a copy of these additional terms immediately following the 25 | # terms and conditions of the GNU Affero General Public License that 26 | # accompanied this program. 27 | # 28 | # If not, please request a copy through one of the means of contact 29 | # listed here: . 30 | # 31 | # Any modifications to this file must keep this entire header intact. 32 | 33 | import sys 34 | import logging 35 | import argparse 36 | from typing import List 37 | 38 | from . import PATH_PROJECT_ROOT, COPYRIGHT_MSG, DIST_TYPES 39 | from .config import Config, PATH_CONFIG 40 | from .builder import AddonBuilder, clean_repo 41 | from .ui import QtVersion, UIBuilder 42 | from .manifest import ManifestUtils 43 | from .git import Git 44 | 45 | 46 | # Checks 47 | ############################################################################## 48 | 49 | 50 | def validate_cwd(): 51 | required = (PATH_PROJECT_ROOT / "src", PATH_CONFIG) 52 | for path in required: 53 | if not path.exists(): 54 | print( 55 | "Error: {dir} not found. Please run this script from " 56 | "the project root.".format(dir=path.name) 57 | ) 58 | return False 59 | return True 60 | 61 | 62 | # Helpers 63 | ############################################################################## 64 | 65 | 66 | def get_qt_versions(args: argparse.Namespace) -> List[QtVersion]: 67 | targets = [args.target] if args.target != "all" else Config()["targets"] 68 | 69 | if "anki21" in targets: 70 | qt_versions = [QtVersion.qt5, QtVersion.qt6] 71 | else: 72 | qt_versions = [QtVersion[key] for key in targets] 73 | 74 | return qt_versions 75 | 76 | 77 | # Entry points 78 | ############################################################################## 79 | 80 | 81 | def build(args): 82 | qt_versions = get_qt_versions(args) 83 | 84 | dists = [args.dist] if args.dist != "all" else DIST_TYPES 85 | 86 | builder = AddonBuilder(version=args.version) 87 | 88 | cnt = 1 89 | total = len(dists) 90 | for dist in dists: 91 | logging.info("\n=== Build task %s/%s ===", cnt, total) 92 | builder.build(qt_versions=qt_versions, disttype=dist) 93 | cnt += 1 94 | 95 | 96 | def ui(args): 97 | qt_versions = get_qt_versions(args) 98 | 99 | builder = UIBuilder(dist=PATH_PROJECT_ROOT, config=Config()) 100 | 101 | cnt = 1 102 | total = len(qt_versions) 103 | for qt_version in qt_versions: 104 | logging.info("\n=== Build task %s/%s ===\n", cnt, total) 105 | builder.build(qt_version=qt_version) 106 | cnt += 1 107 | 108 | logging.info("\n=== Writing Qt compatibility shim ===") 109 | builder.create_qt_shim() 110 | logging.info("Done.") 111 | 112 | 113 | def manifest(args): 114 | version = Git().parse_version(vstring=args.version) 115 | addon_properties = Config() 116 | 117 | dist_type = args.dist 118 | 119 | if args.dist == "all": 120 | print("'all' is not supported as a dist_type value when building the manifest.") 121 | return False 122 | 123 | ManifestUtils.generate_and_write_manifest( 124 | addon_properties=addon_properties, 125 | version=version, 126 | dist_type=dist_type, 127 | target_dir=PATH_PROJECT_ROOT / "src" / addon_properties["module_name"], 128 | ) 129 | 130 | 131 | # TODO: Deal with all this repetition once we merge this into develop 132 | 133 | 134 | def create_dist(args): 135 | builder = AddonBuilder(version=args.version) 136 | builder.create_dist() 137 | 138 | 139 | def build_dist(args): 140 | qt_versions = get_qt_versions(args) 141 | dists = [args.dist] if args.dist != "all" else DIST_TYPES 142 | 143 | builder = AddonBuilder(version=args.version) 144 | 145 | cnt = 1 146 | total = len(dists) 147 | for dist in dists: 148 | logging.info("\n=== Build task %s/%s ===", cnt, total) 149 | builder.build_dist(qt_versions=qt_versions, disttype=dist) 150 | cnt += 1 151 | 152 | 153 | def package_dist(args): 154 | qt_versions = get_qt_versions(args) 155 | dists = [args.dist] if args.dist != "all" else DIST_TYPES 156 | 157 | builder = AddonBuilder(version=args.version) 158 | 159 | cnt = 1 160 | total = len(dists) 161 | for dist in dists: 162 | logging.info("\n=== Build task %s/%s ===", cnt, total) 163 | builder.package_dist(qt_versions=qt_versions, disttype=dist) 164 | cnt += 1 165 | 166 | 167 | def clean(args): 168 | return clean_repo() 169 | 170 | 171 | # Argument parsing 172 | ############################################################################## 173 | 174 | 175 | def construct_parser(): 176 | parser = argparse.ArgumentParser() 177 | parser.set_defaults(func=lambda x: parser.print_usage()) 178 | subparsers = parser.add_subparsers() 179 | 180 | parser.add_argument( 181 | "-v", 182 | "--verbose", 183 | help="Enable verbose output", 184 | required=False, 185 | action="store_true", 186 | ) 187 | 188 | target_parent = argparse.ArgumentParser(add_help=False) 189 | target_parent.add_argument( 190 | "-t", 191 | "--target", 192 | help="Anki release type to build for. Use 'all' (deprecated alias: 'anki21') to target both Qt5 and Qt6.", 193 | type=str, 194 | default="all", 195 | choices=["qt6", "qt5", "all", "anki21"], 196 | ) 197 | 198 | dist_parent = argparse.ArgumentParser(add_help=False) 199 | dist_parent.add_argument( 200 | "-d", 201 | "--dist", 202 | help="Distribution channel to build for", 203 | type=str, 204 | default="local", 205 | choices=["local", "ankiweb", "all"], 206 | ) 207 | 208 | build_parent = argparse.ArgumentParser(add_help=False) 209 | build_parent.add_argument( 210 | "version", 211 | nargs="?", 212 | help="Version to (pre-)build as a git reference " 213 | "(e.g. 'v1.2.0' or 'd338f6405'). " 214 | "Special keywords: 'dev' - working directory, " 215 | "'current' – latest commit, 'release' – latest tag. " 216 | "Leave empty to build latest tag.", 217 | ) 218 | 219 | build_group = subparsers.add_parser( 220 | "build", 221 | parents=[build_parent, target_parent, dist_parent], 222 | help="Build and package add-on for distribution", 223 | ) 224 | build_group.set_defaults(func=build) 225 | 226 | ui_group = subparsers.add_parser( 227 | "ui", parents=[target_parent], help="Compile add-on user interface files" 228 | ) 229 | ui_group.set_defaults(func=ui) 230 | 231 | manifest_group = subparsers.add_parser( 232 | "manifest", 233 | parents=[build_parent, dist_parent], 234 | help="Generate manifest file from add-on properties in addon.json", 235 | ) 236 | manifest_group.set_defaults(func=manifest) 237 | 238 | clean_group = subparsers.add_parser("clean", help="Clean leftover build files") 239 | clean_group.set_defaults(func=clean) 240 | 241 | create_dist_group = subparsers.add_parser( 242 | "create_dist", 243 | parents=[build_parent, target_parent, dist_parent], 244 | help="Prepare source tree distribution for building under build/dist. " 245 | "This is intended to be used in build scripts and should be run before " 246 | "`build_dist` and `package_dist`.", 247 | ) 248 | create_dist_group.set_defaults(func=create_dist) 249 | 250 | build_dist_group = subparsers.add_parser( 251 | "build_dist", 252 | parents=[build_parent, target_parent, dist_parent], 253 | help="Build add-on files from prepared source tree under build/dist. " 254 | "This step performs all source code post-processing handled by " 255 | "aab itself (e.g. building the Qt UI and writing the add-on manifest). " 256 | "As with `create_dist` and `package_dist`, this command is meant to be " 257 | "used in build scripts where it can provide an avenue for performing " 258 | "additional processing ahead of packaging the add-on.", 259 | ) 260 | build_dist_group.set_defaults(func=build_dist) 261 | 262 | package_dist_group = subparsers.add_parser( 263 | "package_dist", 264 | parents=[build_parent, target_parent, dist_parent], 265 | help="Package pre-built distribution of add-on files under build/dist into " 266 | "a distributable .ankiaddon package. This is inteded to be used in " 267 | "build scripts and called after both `create_dist` and `build_dist` " 268 | "have been run.", 269 | ) 270 | package_dist_group.set_defaults(func=package_dist) 271 | 272 | return parser 273 | 274 | 275 | # Main 276 | ############################################################################## 277 | 278 | 279 | def main(): 280 | print(COPYRIGHT_MSG) 281 | 282 | # Argument parsing 283 | 284 | parser = construct_parser() 285 | args = parser.parse_args() 286 | 287 | # Checks 288 | if not validate_cwd(): 289 | sys.exit(1) 290 | 291 | # Logging 292 | 293 | if args.verbose: 294 | level = logging.DEBUG 295 | else: 296 | level = logging.INFO 297 | 298 | logging.basicConfig(stream=sys.stdout, level=level, format="%(message)s") 299 | 300 | # Argument aliases 301 | 302 | if hasattr(args, "target") and args.target == "anki21": 303 | print( 304 | "WARNING: 'anki21' is deprecated as a target type. Please use 'all' instead " 305 | "if targeting both qt6 and qt5 Anki builds." 306 | ) 307 | args.target = "all" 308 | 309 | # Run 310 | args.func(args) 311 | 312 | 313 | if __name__ == "__main__": 314 | main() 315 | -------------------------------------------------------------------------------- /aab/config.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Project config parser 34 | """ 35 | 36 | import json 37 | import logging 38 | 39 | import jsonschema 40 | from jsonschema.exceptions import ValidationError 41 | 42 | from collections import UserDict 43 | 44 | from . import PATH_PACKAGE, PATH_PROJECT_ROOT 45 | 46 | PATH_CONFIG = PATH_PROJECT_ROOT / "addon.json" 47 | 48 | 49 | class Config(UserDict): 50 | 51 | """ 52 | Simple dictionary-like interface to the repository config file 53 | """ 54 | 55 | with (PATH_PACKAGE / "schema.json").open("r", encoding="utf-8") as f: 56 | _schema = json.loads(f.read()) 57 | 58 | def __init__(self, path=None): 59 | self._path = path or PATH_CONFIG 60 | try: 61 | with self._path.open(encoding="utf-8") as f: 62 | data = json.loads(f.read()) 63 | jsonschema.validate(data, self._schema) 64 | self.data = data 65 | except (IOError, OSError, ValueError, ValidationError): 66 | logging.error( 67 | "Error: Could not read '{}'. Traceback follows " 68 | "below:\n".format(self._path.name) 69 | ) 70 | raise 71 | 72 | def __setitem__(self, name, value): 73 | self.data[name] = value 74 | self._write(self.data) 75 | 76 | def _write(self, data): 77 | try: 78 | with self._path.open("w", encoding="utf-8") as f: 79 | json.dump(data, f, ensure_ascii=False, indent=4, sort_keys=False) 80 | except (IOError, OSError): 81 | logging.error( 82 | "Error: Could not write to '{}'. Traceback follows " 83 | "below:\n".format(self._path.name) 84 | ) 85 | raise 86 | -------------------------------------------------------------------------------- /aab/git.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Basic Git interface 34 | """ 35 | 36 | import logging 37 | 38 | from .utils import call_shell 39 | 40 | 41 | class Git(object): 42 | def parse_version(self, vstring=None): 43 | if vstring and vstring not in ("release", "current"): 44 | return vstring 45 | 46 | logging.info("Getting Git version info...") 47 | 48 | cmd = "git describe HEAD --tags" 49 | if vstring is None or vstring == "release": 50 | cmd += " --abbrev=0" 51 | 52 | version = call_shell(cmd, error_exit=False) 53 | 54 | if version is False: 55 | # Perhaps no tag has been set yet. Try to grab commit ID before 56 | # giving up and exiting 57 | version = call_shell("git rev-parse --short HEAD") 58 | 59 | return version 60 | 61 | def archive(self, version, outdir): 62 | logging.info("Exporting Git archive...") 63 | if not outdir or not version: 64 | return False 65 | if version == "dev": 66 | # https://stackoverflow.com/a/12010656 67 | cmd = ( 68 | "stash=`git stash create`; git archive --format tar $stash |" 69 | " tar -x -C {outdir}/".format(outdir=outdir) 70 | ) 71 | else: 72 | cmd = "git archive --format tar {vers} | tar -x -C {outdir}/".format( 73 | vers=version, outdir=outdir 74 | ) 75 | return call_shell(cmd) 76 | 77 | def modtime(self, version): 78 | if version == "dev": 79 | # Get timestamps of uncommitted changes and return the most recent. 80 | # https://stackoverflow.com/a/14142413 81 | cmd = ( 82 | "git status -s | while read mode file;" 83 | " do echo $(stat -c %Y $file); done" 84 | ) 85 | modtimes = call_shell(cmd).splitlines() 86 | # https://stackoverflow.com/a/12010656 87 | modtimes = [int(modtime) for modtime in modtimes] 88 | return max(modtimes) 89 | else: 90 | return int(call_shell("git log -1 -s --format=%ct {}".format(version))) 91 | -------------------------------------------------------------------------------- /aab/legacy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2022 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Limited support for porting legacy Qt5 features to Qt6 34 | """ 35 | 36 | import shutil 37 | import xml.etree.ElementTree as ElementTree 38 | from dataclasses import dataclass 39 | from pathlib import Path 40 | from typing import List, Optional, Set 41 | 42 | TAG_RCC = "RCC" 43 | TAG_RESOURCE = "qresource" 44 | TAG_FILE = "file" 45 | 46 | ATTRIBUTE_PREFIX = "prefix" 47 | ATTRIBUTE_ALIAS = "alias" 48 | 49 | 50 | @dataclass 51 | class QResourceFileDescriptor: 52 | relative_path: str 53 | alias: Optional[str] = None 54 | 55 | 56 | @dataclass 57 | class QResourceDescriptor: 58 | prefix: str 59 | parent_path: Path 60 | files: List[QResourceFileDescriptor] 61 | 62 | 63 | class QRCParseError(ElementTree.ParseError): 64 | pass 65 | 66 | 67 | class QRCParser: 68 | def __init__(self, qrc_path: Path): 69 | self._parent_path = qrc_path.parent 70 | 71 | try: 72 | self._root = ElementTree.parse(qrc_path).getroot() 73 | except Exception as e: 74 | raise e 75 | 76 | if self._root.tag != TAG_RCC: 77 | raise QRCParseError(f"Invalid qrc file: {TAG_RCC} tag not found at root") 78 | 79 | def get_qresources(self) -> List[QResourceDescriptor]: 80 | resources: List[QResourceDescriptor] = [] 81 | 82 | for resource in self._root.findall(TAG_RESOURCE): 83 | prefix = resource.get(ATTRIBUTE_PREFIX) 84 | if not prefix: 85 | raise QRCParseError( 86 | "qresource definitions without a prefix attribute are currently not" 87 | " supported" 88 | ) 89 | prefix = self._clean_prefix(prefix) 90 | 91 | files: List[QResourceFileDescriptor] = [] 92 | 93 | for file in resource.findall(TAG_FILE): 94 | relative_path = file.text 95 | if relative_path is None: 96 | raise QRCParseError("file path cannot be None") 97 | alias = file.get(ATTRIBUTE_ALIAS) 98 | files.append( 99 | QResourceFileDescriptor(relative_path=relative_path, alias=alias) 100 | ) 101 | 102 | resources.append( 103 | QResourceDescriptor( 104 | prefix=prefix, parent_path=self._parent_path, files=files 105 | ) 106 | ) 107 | 108 | return resources 109 | 110 | def _clean_prefix(self, prefix: str) -> str: 111 | if prefix.startswith("/"): 112 | prefix = prefix[1:] 113 | if prefix.endswith("/"): 114 | prefix = prefix[:-1] 115 | return prefix 116 | 117 | 118 | class QRCMigrator: 119 | 120 | _template_integration_snippet = """ 121 | from pathlib import Path 122 | from aqt.qt import QDir 123 | 124 | def initialize_qt_resources(): 125 | {qdir_addpath_block} 126 | 127 | initialize_qt_resources() 128 | """ 129 | 130 | resources_target_folder = "resources" 131 | 132 | def __init__(self, gui_path: Path): 133 | self._target_root_path = gui_path / self.resources_target_folder 134 | 135 | def migrate_resources(self, resources: List[QResourceDescriptor]) -> str: 136 | """returns QDir initialization command""" 137 | 138 | prefixes: Set[str] = set() 139 | 140 | for resource in resources: 141 | prefix = resource.prefix 142 | source_parent_path = resource.parent_path 143 | 144 | prefixes.add(prefix) 145 | 146 | for file in resource.files: 147 | source_relative_path = file.relative_path 148 | alias = file.alias 149 | 150 | target_relative_path = source_relative_path if not alias else alias 151 | 152 | source_path = source_parent_path / source_relative_path 153 | target_path = self._target_root_path / prefix / target_relative_path 154 | 155 | if target_path.exists(): 156 | target_path.unlink() 157 | 158 | is_dir = False 159 | if source_path.is_dir(): 160 | target_path.mkdir(parents=True, exist_ok=True) 161 | is_dir = True 162 | elif not target_path.parent.exists(): 163 | target_path.parent.mkdir(parents=True, exist_ok=True) 164 | 165 | if is_dir: 166 | shutil.copytree(source_path, target_path) 167 | else: 168 | shutil.copy(source_path, target_path) 169 | 170 | qdir_addpath_block = "\n".join( 171 | self._build_qdir_command(prefix) for prefix in prefixes 172 | ) 173 | 174 | integration_snippet = self._template_integration_snippet.format( 175 | qdir_addpath_block=qdir_addpath_block 176 | ) 177 | 178 | return integration_snippet 179 | 180 | def _build_qdir_command(self, prefix: str): 181 | return f""" QDir.addSearchPath("{prefix}", str(Path(__file__).parent / "{prefix}"))""" 182 | -------------------------------------------------------------------------------- /aab/manifest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | import json 33 | import logging 34 | from copy import deepcopy 35 | from pathlib import Path 36 | from typing import Any, Dict, Literal, Optional, Union 37 | 38 | from .config import Config 39 | from .git import Git 40 | 41 | DistType = Union[Literal["local"], Literal["ankiweb"]] 42 | 43 | 44 | class ManifestUtils: 45 | @classmethod 46 | def generate_and_write_manifest( 47 | cls, 48 | addon_properties: Config, 49 | version: str, 50 | dist_type: DistType, 51 | target_dir: Path, 52 | ): 53 | logging.info("Writing manifest...") 54 | manifest = cls.generate_manifest_from_properties( 55 | addon_properties=addon_properties, version=version, dist_type=dist_type 56 | ) 57 | cls.write_manifest(manifest=manifest, target_dir=target_dir) 58 | 59 | @classmethod 60 | def generate_manifest_from_properties( 61 | cls, 62 | addon_properties: Config, 63 | version: str, 64 | dist_type: DistType, 65 | ) -> Dict[str, Any]: 66 | manifest = { 67 | "name": addon_properties["display_name"], 68 | "package": addon_properties["module_name"], 69 | "ankiweb_id": addon_properties["ankiweb_id"], 70 | "author": addon_properties["author"], 71 | "version": version, 72 | "homepage": addon_properties.get("homepage", ""), 73 | "conflicts": deepcopy(addon_properties["conflicts"]), 74 | "mod": Git().modtime(version), 75 | } 76 | 77 | # Add version specifiers: 78 | 79 | min_anki_version = addon_properties.get("min_anki_version") 80 | max_anki_version = addon_properties.get("max_anki_version") 81 | tested_anki_version = addon_properties.get("tested_anki_version") 82 | 83 | if min_anki_version: 84 | manifest["min_point_version"] = cls._min_point_version(min_anki_version) 85 | 86 | if max_anki_version or tested_anki_version: 87 | manifest["max_point_version"] = cls._max_point_version( 88 | max_anki_version, tested_anki_version 89 | ) 90 | 91 | # Update values for distribution type 92 | if dist_type == "local": 93 | if ( 94 | addon_properties.get("local_conflicts_with_ankiweb", True) 95 | and addon_properties["ankiweb_id"] 96 | ): 97 | manifest["conflicts"].insert(0, addon_properties["ankiweb_id"]) 98 | elif dist_type == "ankiweb": 99 | if ( 100 | addon_properties.get("ankiweb_conflicts_with_local", True) 101 | and addon_properties["module_name"] 102 | ): 103 | manifest["conflicts"].insert(0, addon_properties["module_name"]) 104 | 105 | # This is inconsistent, but we can't do much else when 106 | # ankiweb_id is still unknown (i.e. first upload): 107 | manifest["package"] = ( 108 | addon_properties["ankiweb_id"] or addon_properties["module_name"] 109 | ) 110 | 111 | return manifest 112 | 113 | @classmethod 114 | def write_manifest(cls, manifest: Dict[str, Any], target_dir: Path): 115 | target_path = target_dir / "manifest.json" 116 | with target_path.open("w", encoding="utf-8") as manifest_file: 117 | manifest_file.write( 118 | json.dumps(manifest, indent=4, sort_keys=False, ensure_ascii=False) 119 | ) 120 | 121 | @classmethod 122 | def _anki_version_to_point_version(cls, version: str) -> int: 123 | return int(version.split(".")[-1]) 124 | 125 | @classmethod 126 | def _min_point_version(cls, min_anki_version: str) -> int: 127 | return cls._anki_version_to_point_version(min_anki_version) 128 | 129 | @classmethod 130 | def _max_point_version( 131 | cls, max_anki_version: Optional[str], tested_anki_version: Optional[str] 132 | ) -> Optional[int]: 133 | if max_anki_version: 134 | # -version in "max_point_version" specifies a definite max supported version 135 | return -1 * cls._anki_version_to_point_version(max_anki_version) 136 | elif tested_anki_version: 137 | # +version in "max_point_version" indicates version tested on 138 | return cls._anki_version_to_point_version(tested_anki_version) 139 | return None 140 | -------------------------------------------------------------------------------- /aab/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "display_name": { 5 | "type": "string" 6 | }, 7 | "module_name": { 8 | "type": "string" 9 | }, 10 | "repo_name": { 11 | "type": "string" 12 | }, 13 | "ankiweb_id": { 14 | "type": "string" 15 | }, 16 | "author": { 17 | "type": "string" 18 | }, 19 | "contact": { 20 | "type": "string" 21 | }, 22 | "homepage": { 23 | "type": "string" 24 | }, 25 | "tags": { 26 | "type": "string" 27 | }, 28 | "copyright_start": { 29 | "type": "number" 30 | }, 31 | "conflicts": { 32 | "type": "array", 33 | "items": { 34 | "type": "string" 35 | } 36 | }, 37 | "targets": { 38 | "type": "array", 39 | "items": { 40 | "type": "string", 41 | "enum": ["qt6", "qt5", "anki21"] 42 | } 43 | }, 44 | "min_anki_version": { 45 | "type": "string", 46 | "description": "SemVer version string describing the minimum required Anki version to run this add-on." 47 | }, 48 | "max_anki_version": { 49 | "type": "string", 50 | "description": "SemVer version string describing the maximum supported Anki version of this add-on" 51 | }, 52 | "tested_anki_version": { 53 | "type": "string", 54 | "description": "SemVer version string describing the latest Anki version this add-on was tested on." 55 | }, 56 | "ankiweb_conflicts_with_local": { 57 | "type": "boolean", 58 | "default": true 59 | }, 60 | "local_conflicts_with_ankiweb": { 61 | "type": "boolean", 62 | "default": true 63 | }, 64 | "qt_resource_migration_mode": { 65 | "type": "string", 66 | "enum": ["replace_prefixes_and_package_resources", "only_replace_prefixes", "disabled"], 67 | "default": "replace_prefixes_and_package_resources" 68 | } 69 | }, 70 | "required": [ 71 | "display_name", 72 | "module_name", 73 | "repo_name", 74 | "ankiweb_id", 75 | "author", 76 | "conflicts", 77 | "targets" 78 | ] 79 | } 80 | -------------------------------------------------------------------------------- /aab/ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | UI Compilation 34 | """ 35 | 36 | import logging 37 | import re 38 | import shutil 39 | from datetime import datetime 40 | from pathlib import Path 41 | from typing import List, Optional 42 | 43 | from whichcraft import which 44 | 45 | from . import __title__, __version__ 46 | from .config import Config 47 | from .legacy import QRCMigrator, QRCParser, QResourceDescriptor 48 | from .utils import call_shell 49 | 50 | QT_RESOURCES_FOLDER_NAME = "resources" 51 | QT_DESIGNER_FOLDER_NAME = "designer" 52 | FORMS_PACKAGE_NAME = "forms" 53 | RESOURCES_PACKAGE_NAME = "resources" 54 | 55 | _template_header = '''\ 56 | # -*- coding: utf-8 -*- 57 | # 58 | # {display_name} Add-on for Anki 59 | # Copyright (C) {years} {author}{contact} 60 | # 61 | # This file was automatically generated by {__title__} v{__version__} 62 | # It is subject to the same licensing terms as the rest of the program 63 | # (see the LICENSE file which accompanies this program). 64 | # 65 | # WARNING! All changes made in this file will be lost! 66 | 67 | """ 68 | Initializes generated Qt forms/resources 69 | """\ 70 | ''' 71 | 72 | _template_all = """\ 73 | __all__ = [ 74 | {} 75 | ]\ 76 | """ 77 | 78 | _template_qt_shim = '''\ 79 | # -*- coding: utf-8 -*- 80 | # 81 | # {display_name} Add-on for Anki 82 | # Copyright (C) {years} {author}{contact} 83 | # 84 | # This file was automatically generated by {__title__} v{__version__} 85 | # It is subject to the same licensing terms as the rest of the program 86 | # (see the LICENSE file which accompanies this program). 87 | # 88 | # WARNING! All changes made in this file will be lost! 89 | 90 | """ 91 | Shim that imports forms corresponding to runtime Qt version 92 | """ 93 | 94 | from typing import TYPE_CHECKING 95 | 96 | from aqt.qt import qtmajor 97 | 98 | if TYPE_CHECKING or qtmajor >= 6: 99 | from .qt6 import * # noqa: F401 100 | else: 101 | from .qt5 import * # noqa: F401 102 | ''' 103 | 104 | from enum import Enum 105 | 106 | 107 | class QtVersion(Enum): 108 | qt5 = 5 109 | qt6 = 6 110 | 111 | 112 | class UIBuilder: 113 | 114 | _re_munge = re.compile(r"^import .+?_rc(\n)?$", re.MULTILINE) 115 | _ui_file_glob = "*.ui" 116 | _ui_file_tool = "pyuic" 117 | 118 | def __init__(self, dist: Path, config: Config): 119 | self._dist = dist 120 | self._config = config 121 | 122 | self._gui_path: Path = self._dist / "src" / self._config["module_name"] / "gui" 123 | self._resources_source_path = self._dist / QT_RESOURCES_FOLDER_NAME 124 | self._resources_out_path = self._gui_path / RESOURCES_PACKAGE_NAME 125 | self._forms_source_path = self._dist / QT_DESIGNER_FOLDER_NAME 126 | self._forms_out_path = self._gui_path / FORMS_PACKAGE_NAME 127 | 128 | self._format_dict = self._get_format_dict() 129 | 130 | def build(self, qt_version: QtVersion, pyenv=None) -> bool: 131 | qt_version_key = qt_version.name 132 | 133 | logging.info("Starting UI build tasks for target %r...", qt_version_key) 134 | 135 | path_in = self._forms_source_path 136 | path_out = self._forms_out_path / qt_version_key 137 | 138 | if ( 139 | self._resources_source_path.exists() 140 | and self._config.get("qt_resource_migration_mode") != "disabled" 141 | ): 142 | resource_prefixes_to_replace = self._migrate_resources() 143 | else: 144 | resource_prefixes_to_replace = [] 145 | 146 | if not path_in.exists(): 147 | logging.warning( 148 | f"No Qt forms folder found under {self._forms_source_path}. Skipping" 149 | " build." 150 | ) 151 | return False 152 | 153 | ret = self._build( 154 | path_in=path_in, 155 | path_out=path_out, 156 | qt_version_number=qt_version.value, 157 | resource_prefixes_to_replace=resource_prefixes_to_replace, 158 | pyenv=pyenv, 159 | ) 160 | 161 | logging.info("Done with all UI build tasks.") 162 | 163 | return ret 164 | 165 | def create_qt_shim(self): 166 | if not self._forms_out_path.is_dir(): 167 | return False 168 | out_path = self._forms_out_path / "__init__.py" 169 | if out_path.exists(): 170 | out_path.unlink() 171 | format_dict = self._format_dict 172 | content = _template_qt_shim.format(**format_dict) 173 | with out_path.open("w", encoding="utf-8") as f: 174 | f.write(content) 175 | return True 176 | 177 | def _build( 178 | self, 179 | path_in: Path, 180 | path_out: Path, 181 | qt_version_number: int, 182 | resource_prefixes_to_replace: List[str], 183 | pyenv: Optional[str] = None, 184 | ) -> bool: 185 | tool = self._ui_file_tool 186 | 187 | # Basic checks 188 | 189 | ui_files = list(path_in.glob(self._ui_file_glob)) 190 | if not ui_files: 191 | logging.warning("No forms found in %s. Skipping %s build.", path_in, tool) 192 | return False 193 | 194 | tool = "{tool}{nr}".format(tool=tool, nr=qt_version_number) 195 | if which(tool) is None: 196 | logging.error( 197 | f"ERROR: {tool} not found. Please make sure PyQt{qt_version_number} is" 198 | " installed, or change the configuration to build the add-on for a" 199 | " different target Qt version.", 200 | ) 201 | return False 202 | 203 | logging.info( 204 | "Building files in '%s' to '%s' with '%s'", 205 | self._relative_to_cwd(path_in), 206 | self._relative_to_cwd(path_out), 207 | tool, 208 | ) 209 | 210 | # Cleanup 211 | 212 | logging.debug("Cleaning up old forms...") 213 | if path_out.exists(): 214 | shutil.rmtree(str(path_out)) 215 | path_out.mkdir(parents=True) 216 | 217 | # UI build loop 218 | 219 | modules = [] 220 | 221 | env = "" if not pyenv else self._pyenv_prefix(pyenv) 222 | 223 | for in_file in ui_files: 224 | stem = in_file.stem 225 | out_file = Path(path_out / stem).with_suffix(".py") 226 | 227 | logging.debug("Building element '%s'...", stem) 228 | # Use relative paths to improve readability of form header: 229 | cmd = "{env} {tool} {in_file} -o {out_file}".format( 230 | env=env, 231 | tool=tool, 232 | in_file=self._relative_to_cwd(in_file), 233 | out_file=self._relative_to_cwd(out_file), 234 | ) 235 | call_shell(cmd) 236 | 237 | self._munge_form(out_file, resource_prefixes_to_replace) 238 | 239 | modules.append(stem) 240 | 241 | # Last steps 242 | 243 | self._write_init_file(modules, path_out) 244 | 245 | logging.debug("Done with forms.") 246 | return True 247 | 248 | def _pyenv_prefix(self, pyenv): 249 | return ( 250 | '''eval "$(pyenv init -)"''' 251 | '''&& eval "$(pyenv virtualenv-init -)"''' 252 | """&& pyenv activate {pyenv} > /dev/null 2>&1 &&""".format(pyenv=pyenv) 253 | ) 254 | 255 | def _write_init_file(self, modules, path_out): 256 | logging.debug("Generating init file for %s", self._relative_to_cwd(path_out)) 257 | 258 | header = _template_header.format(**self._format_dict) 259 | all_str = self._generate_all_str(modules) 260 | import_str = self._generate_import_str(modules) 261 | 262 | init = "\n\n".join((header, all_str, import_str)) + "\n" 263 | 264 | with (path_out / "__init__.py").open("w", encoding="utf-8") as f: 265 | f.write(init) 266 | 267 | def _generate_all_str(self, modules): 268 | module_string = ",\n".join(' "{}"'.format(m) for m in modules) 269 | out = _template_all.format(module_string) 270 | return out 271 | 272 | def _generate_import_str(self, modules): 273 | out = "\n".join("from . import {}".format(m) for m in modules) 274 | return out 275 | 276 | def _munge_form(self, path: Path, resource_prefixes_to_replace: List[str]): 277 | """ 278 | Munge generated form to remove resource imports 279 | (I prefer to initialize these manually) 280 | """ 281 | logging.debug("Munging %s...", self._relative_to_cwd(path)) 282 | with path.open("r+", encoding="utf-8") as f: 283 | form = f.read() 284 | munged = self._re_munge.sub("", form) 285 | for prefix in resource_prefixes_to_replace: 286 | munged = munged.replace(f'":/{prefix}/', f'"{prefix}:') 287 | f.seek(0) 288 | f.write(munged) 289 | f.truncate() 290 | 291 | def _migrate_resources(self) -> List[str]: 292 | """Returns list of prefixes to replace in built UI forms""" 293 | logging.info("Qt resources folder found. Attempting to migrate...") 294 | 295 | resources: List[QResourceDescriptor] = [] 296 | 297 | for qrc_path in self._resources_source_path.glob("*.qrc"): 298 | parser = QRCParser(qrc_path=qrc_path) 299 | resources.extend(parser.get_qresources()) 300 | 301 | if not resources: 302 | return [] 303 | 304 | migrator = QRCMigrator(self._gui_path) 305 | integration_snippet = migrator.migrate_resources(resources=resources) 306 | 307 | content_init = ( 308 | _template_header.format(**self._format_dict) + "\n" + integration_snippet 309 | ) 310 | 311 | with (self._resources_out_path / "__init__.py").open( 312 | "w", encoding="utf-8" 313 | ) as f: 314 | f.write(content_init) 315 | 316 | prefixes = list(set(resource.prefix for resource in resources)) 317 | 318 | return prefixes 319 | 320 | def _get_format_dict(self): 321 | config = self._config 322 | start_year = config.get("copyright_start") 323 | now = datetime.now().year 324 | if start_year and start_year != now: 325 | years = "{start_year}-{now}".format(start_year=start_year, now=now) 326 | else: 327 | years = "{now}".format(now=now) 328 | 329 | contact = config.get("contact") 330 | 331 | format_dict = { 332 | "display_name": config["display_name"], 333 | "author": config["author"], 334 | "contact": "" if not contact else " <{}>".format(contact), 335 | "__title__": __title__, 336 | "__version__": __version__, 337 | "years": years, 338 | } 339 | 340 | return format_dict 341 | 342 | def _relative_to_cwd(self, path: Path): 343 | return path.relative_to(Path.cwd()) 344 | -------------------------------------------------------------------------------- /aab/utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2021 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | """ 33 | Utility functions 34 | """ 35 | 36 | import logging 37 | import subprocess 38 | import sys 39 | 40 | 41 | def call_shell(command, echo=False, error_exit=True, **kwargs): 42 | try: 43 | out = subprocess.check_output(command, shell=True, **kwargs) 44 | decoded = out.decode("utf-8").strip() 45 | if echo: 46 | logging.info(decoded) 47 | return decoded 48 | except subprocess.CalledProcessError as e: 49 | logging.error( 50 | "Error while running command: '{command}'".format(command=command) 51 | ) 52 | logging.error(e.output.decode("utf-8")) 53 | if error_exit: 54 | sys.exit(1) 55 | return False 56 | 57 | 58 | def purge(path, patterns, recursive=False): 59 | """Wrapper for GNU find that deletes files matching pattern 60 | 61 | Arguments: 62 | path {str} -- Path to look through 63 | patterns {list} -- List of patterns to delete 64 | 65 | Keyword Arguments: 66 | recursive {bool} -- Whether to search recursively (default: {False}) 67 | """ 68 | if not path or not patterns: 69 | return False 70 | pattern_string = " -o ".join("-name '{}'".format(p) for p in patterns) 71 | pattern_string = "\( {} \)".format(pattern_string) 72 | depth = "-maxdepth 1" if not recursive else "" 73 | cmd = 'find "{path}" {depth} {pattern_string} -delete'.format( 74 | path=path, depth=depth, pattern_string=pattern_string 75 | ) 76 | return call_shell(cmd) 77 | 78 | 79 | def copy_recursively(source, target): 80 | if not source or not target: 81 | return False 82 | return call_shell( 83 | 'cp -r "{source}" "{target}"'.format(source=source, target=target) 84 | ) 85 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "attrs" 3 | version = "21.4.0" 4 | description = "Classes Without Boilerplate" 5 | category = "main" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 8 | 9 | [package.extras] 10 | dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"] 11 | docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"] 12 | tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"] 13 | tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"] 14 | 15 | [[package]] 16 | name = "black" 17 | version = "22.1.0" 18 | description = "The uncompromising code formatter." 19 | category = "dev" 20 | optional = false 21 | python-versions = ">=3.6.2" 22 | 23 | [package.dependencies] 24 | click = ">=8.0.0" 25 | mypy-extensions = ">=0.4.3" 26 | pathspec = ">=0.9.0" 27 | platformdirs = ">=2" 28 | tomli = ">=1.1.0" 29 | typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} 30 | 31 | [package.extras] 32 | colorama = ["colorama (>=0.4.3)"] 33 | d = ["aiohttp (>=3.7.4)"] 34 | jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] 35 | uvloop = ["uvloop (>=0.15.2)"] 36 | 37 | [[package]] 38 | name = "bump2version" 39 | version = "1.0.1" 40 | description = "Version-bump your software with a single command!" 41 | category = "dev" 42 | optional = false 43 | python-versions = ">=3.5" 44 | 45 | [[package]] 46 | name = "click" 47 | version = "8.0.4" 48 | description = "Composable command line interface toolkit" 49 | category = "dev" 50 | optional = false 51 | python-versions = ">=3.6" 52 | 53 | [package.dependencies] 54 | colorama = {version = "*", markers = "platform_system == \"Windows\""} 55 | 56 | [[package]] 57 | name = "colorama" 58 | version = "0.4.4" 59 | description = "Cross-platform colored terminal text." 60 | category = "dev" 61 | optional = false 62 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 63 | 64 | [[package]] 65 | name = "importlib-resources" 66 | version = "5.4.0" 67 | description = "Read resources from Python packages" 68 | category = "main" 69 | optional = false 70 | python-versions = ">=3.6" 71 | 72 | [package.dependencies] 73 | zipp = {version = ">=3.1.0", markers = "python_version < \"3.10\""} 74 | 75 | [package.extras] 76 | docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] 77 | testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "pytest-black (>=0.3.7)", "pytest-mypy"] 78 | 79 | [[package]] 80 | name = "isort" 81 | version = "5.10.1" 82 | description = "A Python utility / library to sort Python imports." 83 | category = "dev" 84 | optional = false 85 | python-versions = ">=3.6.1,<4.0" 86 | 87 | [package.extras] 88 | pipfile_deprecated_finder = ["pipreqs", "requirementslib"] 89 | requirements_deprecated_finder = ["pipreqs", "pip-api"] 90 | colors = ["colorama (>=0.4.3,<0.5.0)"] 91 | plugins = ["setuptools"] 92 | 93 | [[package]] 94 | name = "jsonschema" 95 | version = "4.4.0" 96 | description = "An implementation of JSON Schema validation for Python" 97 | category = "main" 98 | optional = false 99 | python-versions = ">=3.7" 100 | 101 | [package.dependencies] 102 | attrs = ">=17.4.0" 103 | importlib-resources = {version = ">=1.4.0", markers = "python_version < \"3.9\""} 104 | pyrsistent = ">=0.14.0,<0.17.0 || >0.17.0,<0.17.1 || >0.17.1,<0.17.2 || >0.17.2" 105 | 106 | [package.extras] 107 | format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] 108 | format_nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"] 109 | 110 | [[package]] 111 | name = "mypy" 112 | version = "0.942" 113 | description = "Optional static typing for Python" 114 | category = "dev" 115 | optional = false 116 | python-versions = ">=3.6" 117 | 118 | [package.dependencies] 119 | mypy-extensions = ">=0.4.3" 120 | tomli = ">=1.1.0" 121 | typing-extensions = ">=3.10" 122 | 123 | [package.extras] 124 | dmypy = ["psutil (>=4.0)"] 125 | python2 = ["typed-ast (>=1.4.0,<2)"] 126 | reports = ["lxml"] 127 | 128 | [[package]] 129 | name = "mypy-extensions" 130 | version = "0.4.3" 131 | description = "Experimental type system extensions for programs checked with the mypy typechecker." 132 | category = "dev" 133 | optional = false 134 | python-versions = "*" 135 | 136 | [[package]] 137 | name = "pathspec" 138 | version = "0.9.0" 139 | description = "Utility library for gitignore style pattern matching of file paths." 140 | category = "dev" 141 | optional = false 142 | python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" 143 | 144 | [[package]] 145 | name = "platformdirs" 146 | version = "2.5.1" 147 | description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." 148 | category = "dev" 149 | optional = false 150 | python-versions = ">=3.7" 151 | 152 | [package.extras] 153 | docs = ["Sphinx (>=4)", "furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)"] 154 | test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)"] 155 | 156 | [[package]] 157 | name = "pyqt5" 158 | version = "5.15.6" 159 | description = "Python bindings for the Qt cross platform application toolkit" 160 | category = "main" 161 | optional = true 162 | python-versions = ">=3.6" 163 | 164 | [package.dependencies] 165 | PyQt5-Qt5 = ">=5.15.2" 166 | PyQt5-sip = ">=12.8,<13" 167 | 168 | [[package]] 169 | name = "pyqt5-qt5" 170 | version = "5.15.2" 171 | description = "The subset of a Qt installation needed by PyQt5." 172 | category = "main" 173 | optional = true 174 | python-versions = "*" 175 | 176 | [[package]] 177 | name = "pyqt5-sip" 178 | version = "12.9.1" 179 | description = "The sip module support for PyQt5" 180 | category = "main" 181 | optional = true 182 | python-versions = ">=3.5" 183 | 184 | [[package]] 185 | name = "pyqt6" 186 | version = "6.2.3" 187 | description = "Python bindings for the Qt cross platform application toolkit" 188 | category = "main" 189 | optional = true 190 | python-versions = ">=3.6.1" 191 | 192 | [package.dependencies] 193 | PyQt6-Qt6 = ">=6.2.3" 194 | PyQt6-sip = ">=13.2,<14" 195 | 196 | [[package]] 197 | name = "pyqt6-qt6" 198 | version = "6.2.4" 199 | description = "The subset of a Qt installation needed by PyQt6." 200 | category = "main" 201 | optional = true 202 | python-versions = "*" 203 | 204 | [[package]] 205 | name = "pyqt6-sip" 206 | version = "13.2.1" 207 | description = "The sip module support for PyQt6" 208 | category = "main" 209 | optional = true 210 | python-versions = ">=3.6" 211 | 212 | [[package]] 213 | name = "pyrsistent" 214 | version = "0.18.1" 215 | description = "Persistent/Functional/Immutable data structures" 216 | category = "main" 217 | optional = false 218 | python-versions = ">=3.7" 219 | 220 | [[package]] 221 | name = "tomli" 222 | version = "2.0.1" 223 | description = "A lil' TOML parser" 224 | category = "dev" 225 | optional = false 226 | python-versions = ">=3.7" 227 | 228 | [[package]] 229 | name = "typing-extensions" 230 | version = "4.1.1" 231 | description = "Backported and Experimental Type Hints for Python 3.6+" 232 | category = "dev" 233 | optional = false 234 | python-versions = ">=3.6" 235 | 236 | [[package]] 237 | name = "whichcraft" 238 | version = "0.6.1" 239 | description = "This package provides cross-platform cross-python shutil.which functionality." 240 | category = "main" 241 | optional = false 242 | python-versions = "*" 243 | 244 | [[package]] 245 | name = "zipp" 246 | version = "3.7.0" 247 | description = "Backport of pathlib-compatible object wrapper for zip files" 248 | category = "main" 249 | optional = false 250 | python-versions = ">=3.7" 251 | 252 | [package.extras] 253 | docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] 254 | testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] 255 | 256 | [extras] 257 | qt5 = ["PyQt5"] 258 | qt6 = ["PyQt6"] 259 | 260 | [metadata] 261 | lock-version = "1.1" 262 | python-versions = "^3.8" 263 | content-hash = "03d23ce5a6343061e19a26ebfee0c4224ffd6558eb9b05755d1e0bf671bff9ad" 264 | 265 | [metadata.files] 266 | attrs = [ 267 | {file = "attrs-21.4.0-py2.py3-none-any.whl", hash = "sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4"}, 268 | {file = "attrs-21.4.0.tar.gz", hash = "sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"}, 269 | ] 270 | black = [ 271 | {file = "black-22.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:1297c63b9e1b96a3d0da2d85d11cd9bf8664251fd69ddac068b98dc4f34f73b6"}, 272 | {file = "black-22.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2ff96450d3ad9ea499fc4c60e425a1439c2120cbbc1ab959ff20f7c76ec7e866"}, 273 | {file = "black-22.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:0e21e1f1efa65a50e3960edd068b6ae6d64ad6235bd8bfea116a03b21836af71"}, 274 | {file = "black-22.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2f69158a7d120fd641d1fa9a921d898e20d52e44a74a6fbbcc570a62a6bc8ab"}, 275 | {file = "black-22.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:228b5ae2c8e3d6227e4bde5920d2fc66cc3400fde7bcc74f480cb07ef0b570d5"}, 276 | {file = "black-22.1.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b1a5ed73ab4c482208d20434f700d514f66ffe2840f63a6252ecc43a9bc77e8a"}, 277 | {file = "black-22.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:35944b7100af4a985abfcaa860b06af15590deb1f392f06c8683b4381e8eeaf0"}, 278 | {file = "black-22.1.0-cp36-cp36m-win_amd64.whl", hash = "sha256:7835fee5238fc0a0baf6c9268fb816b5f5cd9b8793423a75e8cd663c48d073ba"}, 279 | {file = "black-22.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:dae63f2dbf82882fa3b2a3c49c32bffe144970a573cd68d247af6560fc493ae1"}, 280 | {file = "black-22.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fa1db02410b1924b6749c245ab38d30621564e658297484952f3d8a39fce7e8"}, 281 | {file = "black-22.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:c8226f50b8c34a14608b848dc23a46e5d08397d009446353dad45e04af0c8e28"}, 282 | {file = "black-22.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:2d6f331c02f0f40aa51a22e479c8209d37fcd520c77721c034517d44eecf5912"}, 283 | {file = "black-22.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:742ce9af3086e5bd07e58c8feb09dbb2b047b7f566eb5f5bc63fd455814979f3"}, 284 | {file = "black-22.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:fdb8754b453fb15fad3f72cd9cad3e16776f0964d67cf30ebcbf10327a3777a3"}, 285 | {file = "black-22.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5660feab44c2e3cb24b2419b998846cbb01c23c7fe645fee45087efa3da2d61"}, 286 | {file = "black-22.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:6f2f01381f91c1efb1451998bd65a129b3ed6f64f79663a55fe0e9b74a5f81fd"}, 287 | {file = "black-22.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:efbadd9b52c060a8fc3b9658744091cb33c31f830b3f074422ed27bad2b18e8f"}, 288 | {file = "black-22.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8871fcb4b447206904932b54b567923e5be802b9b19b744fdff092bd2f3118d0"}, 289 | {file = "black-22.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ccad888050f5393f0d6029deea2a33e5ae371fd182a697313bdbd835d3edaf9c"}, 290 | {file = "black-22.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07e5c049442d7ca1a2fc273c79d1aecbbf1bc858f62e8184abe1ad175c4f7cc2"}, 291 | {file = "black-22.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:373922fc66676133ddc3e754e4509196a8c392fec3f5ca4486673e685a421321"}, 292 | {file = "black-22.1.0-py3-none-any.whl", hash = "sha256:3524739d76b6b3ed1132422bf9d82123cd1705086723bc3e235ca39fd21c667d"}, 293 | {file = "black-22.1.0.tar.gz", hash = "sha256:a7c0192d35635f6fc1174be575cb7915e92e5dd629ee79fdaf0dcfa41a80afb5"}, 294 | ] 295 | bump2version = [ 296 | {file = "bump2version-1.0.1-py2.py3-none-any.whl", hash = "sha256:37f927ea17cde7ae2d7baf832f8e80ce3777624554a653006c9144f8017fe410"}, 297 | {file = "bump2version-1.0.1.tar.gz", hash = "sha256:762cb2bfad61f4ec8e2bdf452c7c267416f8c70dd9ecb1653fd0bbb01fa936e6"}, 298 | ] 299 | click = [ 300 | {file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"}, 301 | {file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"}, 302 | ] 303 | colorama = [ 304 | {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, 305 | {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, 306 | ] 307 | importlib-resources = [ 308 | {file = "importlib_resources-5.4.0-py3-none-any.whl", hash = "sha256:33a95faed5fc19b4bc16b29a6eeae248a3fe69dd55d4d229d2b480e23eeaad45"}, 309 | {file = "importlib_resources-5.4.0.tar.gz", hash = "sha256:d756e2f85dd4de2ba89be0b21dba2a3bbec2e871a42a3a16719258a11f87506b"}, 310 | ] 311 | isort = [ 312 | {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, 313 | {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, 314 | ] 315 | jsonschema = [ 316 | {file = "jsonschema-4.4.0-py3-none-any.whl", hash = "sha256:77281a1f71684953ee8b3d488371b162419767973789272434bbc3f29d9c8823"}, 317 | {file = "jsonschema-4.4.0.tar.gz", hash = "sha256:636694eb41b3535ed608fe04129f26542b59ed99808b4f688aa32dcf55317a83"}, 318 | ] 319 | mypy = [ 320 | {file = "mypy-0.942-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:5bf44840fb43ac4074636fd47ee476d73f0039f4f54e86d7265077dc199be24d"}, 321 | {file = "mypy-0.942-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dcd955f36e0180258a96f880348fbca54ce092b40fbb4b37372ae3b25a0b0a46"}, 322 | {file = "mypy-0.942-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6776e5fa22381cc761df53e7496a805801c1a751b27b99a9ff2f0ca848c7eca0"}, 323 | {file = "mypy-0.942-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:edf7237137a1a9330046dbb14796963d734dd740a98d5e144a3eb1d267f5f9ee"}, 324 | {file = "mypy-0.942-cp310-cp310-win_amd64.whl", hash = "sha256:64235137edc16bee6f095aba73be5334677d6f6bdb7fa03cfab90164fa294a17"}, 325 | {file = "mypy-0.942-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b840cfe89c4ab6386c40300689cd8645fc8d2d5f20101c7f8bd23d15fca14904"}, 326 | {file = "mypy-0.942-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2b184db8c618c43c3a31b32ff00cd28195d39e9c24e7c3b401f3db7f6e5767f5"}, 327 | {file = "mypy-0.942-cp36-cp36m-win_amd64.whl", hash = "sha256:1a0459c333f00e6a11cbf6b468b870c2b99a906cb72d6eadf3d1d95d38c9352c"}, 328 | {file = "mypy-0.942-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:4c3e497588afccfa4334a9986b56f703e75793133c4be3a02d06a3df16b67a58"}, 329 | {file = "mypy-0.942-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f6ad963172152e112b87cc7ec103ba0f2db2f1cd8997237827c052a3903eaa6"}, 330 | {file = "mypy-0.942-cp37-cp37m-win_amd64.whl", hash = "sha256:0e2dd88410937423fba18e57147dd07cd8381291b93d5b1984626f173a26543e"}, 331 | {file = "mypy-0.942-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:246e1aa127d5b78488a4a0594bd95f6d6fb9d63cf08a66dafbff8595d8891f67"}, 332 | {file = "mypy-0.942-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d8d3ba77e56b84cd47a8ee45b62c84b6d80d32383928fe2548c9a124ea0a725c"}, 333 | {file = "mypy-0.942-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:2bc249409a7168d37c658e062e1ab5173300984a2dada2589638568ddc1db02b"}, 334 | {file = "mypy-0.942-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:9521c1265ccaaa1791d2c13582f06facf815f426cd8b07c3a485f486a8ffc1f3"}, 335 | {file = "mypy-0.942-cp38-cp38-win_amd64.whl", hash = "sha256:e865fec858d75b78b4d63266c9aff770ecb6a39dfb6d6b56c47f7f8aba6baba8"}, 336 | {file = "mypy-0.942-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:6ce34a118d1a898f47def970a2042b8af6bdcc01546454726c7dd2171aa6dfca"}, 337 | {file = "mypy-0.942-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:10daab80bc40f84e3f087d896cdb53dc811a9f04eae4b3f95779c26edee89d16"}, 338 | {file = "mypy-0.942-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3841b5433ff936bff2f4dc8d54cf2cdbfea5d8e88cedfac45c161368e5770ba6"}, 339 | {file = "mypy-0.942-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:6f7106cbf9cc2f403693bf50ed7c9fa5bb3dfa9007b240db3c910929abe2a322"}, 340 | {file = "mypy-0.942-cp39-cp39-win_amd64.whl", hash = "sha256:7742d2c4e46bb5017b51c810283a6a389296cda03df805a4f7869a6f41246534"}, 341 | {file = "mypy-0.942-py3-none-any.whl", hash = "sha256:a1b383fe99678d7402754fe90448d4037f9512ce70c21f8aee3b8bf48ffc51db"}, 342 | {file = "mypy-0.942.tar.gz", hash = "sha256:17e44649fec92e9f82102b48a3bf7b4a5510ad0cd22fa21a104826b5db4903e2"}, 343 | ] 344 | mypy-extensions = [ 345 | {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, 346 | {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, 347 | ] 348 | pathspec = [ 349 | {file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"}, 350 | {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, 351 | ] 352 | platformdirs = [ 353 | {file = "platformdirs-2.5.1-py3-none-any.whl", hash = "sha256:bcae7cab893c2d310a711b70b24efb93334febe65f8de776ee320b517471e227"}, 354 | {file = "platformdirs-2.5.1.tar.gz", hash = "sha256:7535e70dfa32e84d4b34996ea99c5e432fa29a708d0f4e394bbcb2a8faa4f16d"}, 355 | ] 356 | pyqt5 = [ 357 | {file = "PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl", hash = "sha256:33ced1c876f6a26e7899615a5a4efef2167c263488837c7beed023a64cebd051"}, 358 | {file = "PyQt5-5.15.6-cp36-abi3-manylinux1_x86_64.whl", hash = "sha256:9d6efad0377aa78bf081a20ac752ce86096ded18f04c592d98f5b92dc879ad0a"}, 359 | {file = "PyQt5-5.15.6-cp36-abi3-win32.whl", hash = "sha256:9d2dcdaf82263ae56023410a7af15d1fd746c8e361733a7d0d1bd1f004ec2793"}, 360 | {file = "PyQt5-5.15.6-cp36-abi3-win_amd64.whl", hash = "sha256:f411ecda52e488e1d3c5cce7563e1b2ca9cf0b7531e3c25b03d9a7e56e07e7fc"}, 361 | {file = "PyQt5-5.15.6.tar.gz", hash = "sha256:80343bcab95ffba619f2ed2467fd828ffeb0a251ad7225be5fc06dcc333af452"}, 362 | ] 363 | pyqt5-qt5 = [ 364 | {file = "PyQt5_Qt5-5.15.2-py3-none-macosx_10_13_intel.whl", hash = "sha256:76980cd3d7ae87e3c7a33bfebfaee84448fd650bad6840471d6cae199b56e154"}, 365 | {file = "PyQt5_Qt5-5.15.2-py3-none-manylinux2014_x86_64.whl", hash = "sha256:1988f364ec8caf87a6ee5d5a3a5210d57539988bf8e84714c7d60972692e2f4a"}, 366 | {file = "PyQt5_Qt5-5.15.2-py3-none-win32.whl", hash = "sha256:9cc7a768b1921f4b982ebc00a318ccb38578e44e45316c7a4a850e953e1dd327"}, 367 | {file = "PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl", hash = "sha256:750b78e4dba6bdf1607febedc08738e318ea09e9b10aea9ff0d73073f11f6962"}, 368 | ] 369 | pyqt5-sip = [ 370 | {file = "PyQt5_sip-12.9.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:6b2e553e21b7ff124007a6b9168f8bb8c171fdf230d31ca0588df180f10bacbe"}, 371 | {file = "PyQt5_sip-12.9.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:5740a1770d6b92a5dca8bb0bda4620baf0d7a726beb864f69c667ddac91d6f64"}, 372 | {file = "PyQt5_sip-12.9.1-cp310-cp310-win32.whl", hash = "sha256:9699286fcdf4f75a4b91c7e4832c0f926af18d648c62a4ed72dd294c1a93705a"}, 373 | {file = "PyQt5_sip-12.9.1-cp310-cp310-win_amd64.whl", hash = "sha256:e2792af660da7479799f53028da88190ae8b4a0ad5acc2acbfd6c7bbfe110d58"}, 374 | {file = "PyQt5_sip-12.9.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:7ee08ad0ebf85b935f5d8d38306f8665fff9a6026c14fc0a7d780649e889c096"}, 375 | {file = "PyQt5_sip-12.9.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:2d21420b0739df2607864e2c80ca01994bc40cb116da6ad024ea8d9f407b0356"}, 376 | {file = "PyQt5_sip-12.9.1-cp36-cp36m-win32.whl", hash = "sha256:ffd25051962c593d1c3c30188b9fbd8589ba17acd23a0202dc987bd3552fa611"}, 377 | {file = "PyQt5_sip-12.9.1-cp36-cp36m-win_amd64.whl", hash = "sha256:78ef8f1f41819661aa8e3117d6c1cd76fa14aef265e5bfd515dbfc64d412416b"}, 378 | {file = "PyQt5_sip-12.9.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5e641182bfee0501267c55e687832e4efe05becdae9e555d3695d706009b6598"}, 379 | {file = "PyQt5_sip-12.9.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c9a977d2835a5fbf250b00d61267dc228bdec9e20c7420d4e8d54d6f20410f87"}, 380 | {file = "PyQt5_sip-12.9.1-cp37-cp37m-win32.whl", hash = "sha256:cec6ebf0b1163b18f09bc523160c467a9528b6dca129753827ac0bc432b332ae"}, 381 | {file = "PyQt5_sip-12.9.1-cp37-cp37m-win_amd64.whl", hash = "sha256:82c1b3080db7634fa318fddbb3cfaa30e63a67bca1001a76958c31f30b774a9d"}, 382 | {file = "PyQt5_sip-12.9.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cfaad4a773c18b963092589b1a98153d36624601de8597a4dc287e5a295d5625"}, 383 | {file = "PyQt5_sip-12.9.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:ce7a8b3af9db378c46b345d9809d481a74c4bfcd3129486c054fbdbc6a3503f9"}, 384 | {file = "PyQt5_sip-12.9.1-cp38-cp38-win32.whl", hash = "sha256:8fe5b3e4bbb8b472d05631cad21028d073f9f8eda770041449514cb3824a867f"}, 385 | {file = "PyQt5_sip-12.9.1-cp38-cp38-win_amd64.whl", hash = "sha256:5d59c4a5e856a35c41b47f5a23e1635b38cd1672f4f0122a68ebcb6889523ff2"}, 386 | {file = "PyQt5_sip-12.9.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b56aedf7b0a496e4a8bd6087566888cea448aa01c76126cdb8b140e3ff3f5d93"}, 387 | {file = "PyQt5_sip-12.9.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:53e23dcc0fc3857204abd47660e383b930941bd1aeaf3c78ed59c5c12dd48010"}, 388 | {file = "PyQt5_sip-12.9.1-cp39-cp39-win32.whl", hash = "sha256:ee188eac5fd94dfe8d9e04a9e7fbda65c3535d5709278d8b7367ebd54f00e27f"}, 389 | {file = "PyQt5_sip-12.9.1-cp39-cp39-win_amd64.whl", hash = "sha256:989d51c41456cc496cb96f0b341464932b957040d26561f0bb4cf5a0914d6b36"}, 390 | {file = "PyQt5_sip-12.9.1.tar.gz", hash = "sha256:2f24f299b44c511c23796aafbbb581bfdebf78d0905657b7cee2141b4982030e"}, 391 | ] 392 | pyqt6 = [ 393 | {file = "PyQt6-6.2.3-cp36-abi3-macosx_10_14_universal2.whl", hash = "sha256:577334c9d4518022a4cb6f9799dfbd1b996167eb31404b5a63d6c43d603e6418"}, 394 | {file = "PyQt6-6.2.3-cp36-abi3-manylinux1_x86_64.whl", hash = "sha256:8a2f357b86fec8598f52f16d5f93416931017ca1986d5f68679c9565bfc21fff"}, 395 | {file = "PyQt6-6.2.3-cp36-abi3-win_amd64.whl", hash = "sha256:11c039b07962b29246de2da0912f4f663786185fd74d48daac7a270a43c8d92a"}, 396 | {file = "PyQt6-6.2.3.tar.gz", hash = "sha256:a9bfcac198fe4b703706f809bb686c7cef5f60a7c802fc145c6b57929c7a6a34"}, 397 | ] 398 | pyqt6-qt6 = [ 399 | {file = "PyQt6_Qt6-6.2.4-py3-none-macosx_10_14_x86_64.whl", hash = "sha256:48bc5b7400d6bca13d8c0a145f82295a6da317952ee1a3f107f1cd7d078c8140"}, 400 | {file = "PyQt6_Qt6-6.2.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:0aa93581b92e01deaf2dcaad88ed6718996a6d84de59ee88316bcba143f008c9"}, 401 | {file = "PyQt6_Qt6-6.2.4-py3-none-manylinux_2_28_x86_64.whl", hash = "sha256:b68543e5d5a4f5d24c26b517569da3cd30b0fbe75390b841e142c160399b3c0a"}, 402 | {file = "PyQt6_Qt6-6.2.4-py3-none-win_amd64.whl", hash = "sha256:42c37475a50ec7e06e0445ac9ce39465f69a86af407ad9b28b183da178d401ee"}, 403 | ] 404 | pyqt6-sip = [ 405 | {file = "PyQt6_sip-13.2.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:226e9e349aa16dc1132f106ca01fa99cf7cb8e59daee29304c2fea5fa33212ec"}, 406 | {file = "PyQt6_sip-13.2.1-cp310-cp310-manylinux1_x86_64.whl", hash = "sha256:0314d011633bc697e99f3f9897b484720e81a5f4ba0eaa5f05c5811e2e74ea53"}, 407 | {file = "PyQt6_sip-13.2.1-cp310-cp310-win_amd64.whl", hash = "sha256:8b52d42e42e6e9f934ac7528cd154ac0210a532bb33fa1edfb4a8bbfb73ff88b"}, 408 | {file = "PyQt6_sip-13.2.1-cp36-cp36m-macosx_10_6_intel.whl", hash = "sha256:e2e6a3972169891dbc33d806f50ebf17eaa47a487ff6e4910fe2485c47cb6c2b"}, 409 | {file = "PyQt6_sip-13.2.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:a3d53fab72f959b45aeb954124255b585ff8d497a514a2582e0afd808fc2f3da"}, 410 | {file = "PyQt6_sip-13.2.1-cp36-cp36m-win_amd64.whl", hash = "sha256:082a80264699d4e2e919a7de8b6662886a353863d2b30a0047fe73d42e65c98e"}, 411 | {file = "PyQt6_sip-13.2.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c456d5ccc4478254052082e298db01bb9d0495471c1659046697bb5dc9d2506c"}, 412 | {file = "PyQt6_sip-13.2.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:65f5aee6195bd0e785bd74f75ee080a5d5fb840c03210956e4ccbdde481b487c"}, 413 | {file = "PyQt6_sip-13.2.1-cp37-cp37m-win_amd64.whl", hash = "sha256:43afd9c9fdbc5f6ed2e22cae0752a8b8d9545c6d85f314bd27b861e21d4a97fe"}, 414 | {file = "PyQt6_sip-13.2.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0a49f2d0bb49bc9d72665d62fb5ab6549c72dcf49e1e52dc2046edb8832a17a3"}, 415 | {file = "PyQt6_sip-13.2.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:0ede42e84a79871022e1a8e4d5c05f70821b2795910c4cd103e863ce62bc8d68"}, 416 | {file = "PyQt6_sip-13.2.1-cp38-cp38-win_amd64.whl", hash = "sha256:b0d92f4a21706b18ab80c088cded94cd64d32a0c48e1729a4cc53fe5ab93cc1a"}, 417 | {file = "PyQt6_sip-13.2.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:616b6bad827e9c6e7ce5179883ca0f44110a42dcb045344aa28a495c05e19795"}, 418 | {file = "PyQt6_sip-13.2.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f4226d4ab239d8655f94c42b397f23e6e85b246f614ff81162ef9321e47f7619"}, 419 | {file = "PyQt6_sip-13.2.1-cp39-cp39-win_amd64.whl", hash = "sha256:4b119a8fd880ece15a5bdff583edccd89dbc79d49de2e11cbbd6bba72713d1f3"}, 420 | {file = "PyQt6_sip-13.2.1.tar.gz", hash = "sha256:b7bce59900b2e0a04f70246de2ccf79ee7933036b6b9183cf039b62eeae2b858"}, 421 | ] 422 | pyrsistent = [ 423 | {file = "pyrsistent-0.18.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:df46c854f490f81210870e509818b729db4488e1f30f2a1ce1698b2295a878d1"}, 424 | {file = "pyrsistent-0.18.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5d45866ececf4a5fff8742c25722da6d4c9e180daa7b405dc0a2a2790d668c26"}, 425 | {file = "pyrsistent-0.18.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4ed6784ceac462a7d6fcb7e9b663e93b9a6fb373b7f43594f9ff68875788e01e"}, 426 | {file = "pyrsistent-0.18.1-cp310-cp310-win32.whl", hash = "sha256:e4f3149fd5eb9b285d6bfb54d2e5173f6a116fe19172686797c056672689daf6"}, 427 | {file = "pyrsistent-0.18.1-cp310-cp310-win_amd64.whl", hash = "sha256:636ce2dc235046ccd3d8c56a7ad54e99d5c1cd0ef07d9ae847306c91d11b5fec"}, 428 | {file = "pyrsistent-0.18.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e92a52c166426efbe0d1ec1332ee9119b6d32fc1f0bbfd55d5c1088070e7fc1b"}, 429 | {file = "pyrsistent-0.18.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7a096646eab884bf8bed965bad63ea327e0d0c38989fc83c5ea7b8a87037bfc"}, 430 | {file = "pyrsistent-0.18.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cdfd2c361b8a8e5d9499b9082b501c452ade8bbf42aef97ea04854f4a3f43b22"}, 431 | {file = "pyrsistent-0.18.1-cp37-cp37m-win32.whl", hash = "sha256:7ec335fc998faa4febe75cc5268a9eac0478b3f681602c1f27befaf2a1abe1d8"}, 432 | {file = "pyrsistent-0.18.1-cp37-cp37m-win_amd64.whl", hash = "sha256:6455fc599df93d1f60e1c5c4fe471499f08d190d57eca040c0ea182301321286"}, 433 | {file = "pyrsistent-0.18.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:fd8da6d0124efa2f67d86fa70c851022f87c98e205f0594e1fae044e7119a5a6"}, 434 | {file = "pyrsistent-0.18.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7bfe2388663fd18bd8ce7db2c91c7400bf3e1a9e8bd7d63bf7e77d39051b85ec"}, 435 | {file = "pyrsistent-0.18.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0e3e1fcc45199df76053026a51cc59ab2ea3fc7c094c6627e93b7b44cdae2c8c"}, 436 | {file = "pyrsistent-0.18.1-cp38-cp38-win32.whl", hash = "sha256:b568f35ad53a7b07ed9b1b2bae09eb15cdd671a5ba5d2c66caee40dbf91c68ca"}, 437 | {file = "pyrsistent-0.18.1-cp38-cp38-win_amd64.whl", hash = "sha256:d1b96547410f76078eaf66d282ddca2e4baae8964364abb4f4dcdde855cd123a"}, 438 | {file = "pyrsistent-0.18.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f87cc2863ef33c709e237d4b5f4502a62a00fab450c9e020892e8e2ede5847f5"}, 439 | {file = "pyrsistent-0.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bc66318fb7ee012071b2792024564973ecc80e9522842eb4e17743604b5e045"}, 440 | {file = "pyrsistent-0.18.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:914474c9f1d93080338ace89cb2acee74f4f666fb0424896fcfb8d86058bf17c"}, 441 | {file = "pyrsistent-0.18.1-cp39-cp39-win32.whl", hash = "sha256:1b34eedd6812bf4d33814fca1b66005805d3640ce53140ab8bbb1e2651b0d9bc"}, 442 | {file = "pyrsistent-0.18.1-cp39-cp39-win_amd64.whl", hash = "sha256:e24a828f57e0c337c8d8bb9f6b12f09dfdf0273da25fda9e314f0b684b415a07"}, 443 | {file = "pyrsistent-0.18.1.tar.gz", hash = "sha256:d4d61f8b993a7255ba714df3aca52700f8125289f84f704cf80916517c46eb96"}, 444 | ] 445 | tomli = [ 446 | {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, 447 | {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, 448 | ] 449 | typing-extensions = [ 450 | {file = "typing_extensions-4.1.1-py3-none-any.whl", hash = "sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"}, 451 | {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"}, 452 | ] 453 | whichcraft = [ 454 | {file = "whichcraft-0.6.1-py2.py3-none-any.whl", hash = "sha256:deda9266fbb22b8c64fd3ee45c050d61139cd87419765f588e37c8d23e236dd9"}, 455 | {file = "whichcraft-0.6.1.tar.gz", hash = "sha256:acdbb91b63d6a15efbd6430d1d7b2d36e44a71697e93e19b7ded477afd9fce87"}, 456 | ] 457 | zipp = [ 458 | {file = "zipp-3.7.0-py3-none-any.whl", hash = "sha256:b47250dd24f92b7dd6a0a8fc5244da14608f3ca90a5efcd37a3b1642fac9a375"}, 459 | {file = "zipp-3.7.0.tar.gz", hash = "sha256:9f50f446828eb9d45b267433fd3e9da8d801f614129124863f9c51ebceafb87d"}, 460 | ] 461 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "aab" 3 | version = "1.0.0-dev.5" 4 | description = "Anki Add-on Builder" 5 | authors = ["Aristotelis P. (Glutanimate)"] 6 | license = "AGPL-3.0-or-later" 7 | repository = "https://github.com/glutanimate/pytest-anki" 8 | homepage = "https://github.com/glutanimate/pytest-anki" 9 | readme = "README.md" 10 | keywords = ["anki", "development", "build-tools"] 11 | classifiers = [ 12 | "Development Status :: 3 - Alpha", 13 | "Intended Audience :: Developers", 14 | "Topic :: Software Development :: Build Tools", 15 | "License :: OSI Approved :: GNU Affero General Public License v3", 16 | "Programming Language :: Python :: 3.8", 17 | "Programming Language :: Python :: 3.9", 18 | "Programming Language :: Python :: 3.10", 19 | "Operating System :: POSIX", 20 | "Operating System :: MacOS", 21 | ] 22 | include = ["schema.json"] 23 | 24 | [tool.poetry.scripts] 25 | aab = 'aab.cli:main' 26 | 27 | [tool.poetry.dependencies] 28 | python = "^3.8" 29 | jsonschema = "^4.4.0" 30 | whichcraft = "^0.6.1" 31 | PyQt6 = {version = "^6.2.2", optional = true} 32 | PyQt5 = {version = "^5.12", optional = true} 33 | 34 | [tool.poetry.dev-dependencies] 35 | mypy = "^0.942" 36 | isort = "^5.10.1" 37 | black = "^22.1.0" 38 | bump2version = "^1.0.1" 39 | 40 | [tool.poetry.extras] 41 | qt6 = ["PyQt6"] 42 | qt5 = ["PyQt5"] 43 | 44 | [build-system] 45 | requires = ["poetry-core>=1.0.0"] 46 | build-backend = "poetry.core.masonry.api" 47 | 48 | [tool.mypy] 49 | show_error_codes = true 50 | ignore_missing_imports = true 51 | follow_imports = "silent" 52 | show_column_numbers = true 53 | 54 | [tool.isort] 55 | multi_line_output = 3 56 | include_trailing_comma = true 57 | line_length=88 58 | ensure_newline_before_comments=true 59 | 60 | [tool.black] 61 | experimental-string-processing = true 62 | 63 | [tool.pyright] 64 | include = ["aab"] 65 | enableTypeIgnoreComments = true 66 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2022 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | from pathlib import Path 33 | 34 | SAMPLE_PROJECTS_FOLDER = Path(__file__).parent / "data" 35 | SAMPLE_PROJECT_NAME = "sample-project" 36 | SAMPLE_PROJECT_ROOT = SAMPLE_PROJECTS_FOLDER / SAMPLE_PROJECT_NAME 37 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "display_name": "Sample Project", 3 | "module_name": "sample_project", 4 | "repo_name": "sample-project", 5 | "ankiweb_id": "999999999999", 6 | "author": "Glutanimate", 7 | "conflicts": [], 8 | "targets": ["qt6", "qt5"] 9 | } 10 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/resources/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/help.svg 4 | icons/heart.svg 5 | icons/optional/coffee.svg 6 | icons/optional/email.svg 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/resources/icons/heart.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/resources/icons/help.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/resources/icons/optional/coffee.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/project-with-no-forms/resources/icons/optional/email.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/sample-project/addon.json: -------------------------------------------------------------------------------- 1 | { 2 | "display_name": "Sample Project", 3 | "module_name": "sample_project", 4 | "repo_name": "sample-project", 5 | "ankiweb_id": "999999999999", 6 | "author": "Glutanimate", 7 | "conflicts": [], 8 | "targets": ["qt6", "qt5"] 9 | } 10 | -------------------------------------------------------------------------------- /tests/data/sample-project/designer/dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | :/sample-project/icons/help.svg 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | :/sample-project/icons/coffee.svg 34 | 35 | 36 | 37 | 38 | 39 | 40 | Qt::Horizontal 41 | 42 | 43 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | buttonBox 55 | accepted() 56 | Dialog 57 | accept() 58 | 59 | 60 | 248 61 | 254 62 | 63 | 64 | 157 65 | 274 66 | 67 | 68 | 69 | 70 | buttonBox 71 | rejected() 72 | Dialog 73 | reject() 74 | 75 | 76 | 316 77 | 260 78 | 79 | 80 | 286 81 | 274 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /tests/data/sample-project/resources/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/help.svg 4 | icons/heart.svg 5 | icons/optional/coffee.svg 6 | icons/optional/email.svg 7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/data/sample-project/resources/icons/heart.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/sample-project/resources/icons/help.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/sample-project/resources/icons/optional/coffee.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/data/sample-project/resources/icons/optional/email.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/test_legacy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2022 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | from pathlib import Path 33 | from shutil import copytree 34 | 35 | from aab.legacy import ( 36 | QRCMigrator, 37 | QRCParser, 38 | QResourceDescriptor, 39 | QResourceFileDescriptor, 40 | ) 41 | 42 | from . import SAMPLE_PROJECT_NAME, SAMPLE_PROJECT_ROOT 43 | from .util import list_files 44 | 45 | _qrc_sample_resources = [ 46 | QResourceDescriptor( 47 | prefix="sample-project", 48 | parent_path=(SAMPLE_PROJECT_ROOT / "resources").resolve(), 49 | files=[ 50 | QResourceFileDescriptor(relative_path="icons/help.svg", alias=None), 51 | QResourceFileDescriptor(relative_path="icons/heart.svg", alias=None), 52 | QResourceFileDescriptor( 53 | relative_path="icons/optional/coffee.svg", alias="icons/coffee.svg" 54 | ), 55 | QResourceFileDescriptor( 56 | relative_path="icons/optional/email.svg", alias="icons/email.svg" 57 | ), 58 | ], 59 | ) 60 | ] 61 | 62 | 63 | def test_qrc_parser(): 64 | qrc_path = SAMPLE_PROJECT_ROOT / "resources" / "icons.qrc" 65 | parser = QRCParser(qrc_path=qrc_path) 66 | 67 | expected = _qrc_sample_resources 68 | 69 | actual = parser.get_qresources() 70 | 71 | assert actual == expected 72 | 73 | 74 | def test_qrc_migrator(tmp_path: Path): 75 | test_project_root = tmp_path / SAMPLE_PROJECT_NAME 76 | copytree(SAMPLE_PROJECT_ROOT, test_project_root) 77 | 78 | gui_src_path = test_project_root / "src" / "sample_project" / "gui" 79 | 80 | migrator = QRCMigrator(gui_path=gui_src_path) 81 | 82 | expected_integration_snippet = """ 83 | from pathlib import Path 84 | from aqt.qt import QDir 85 | 86 | def initialize_qt_resources(): 87 | QDir.addSearchPath("sample-project", str(Path(__file__).parent / "sample-project")) 88 | 89 | initialize_qt_resources() 90 | """ 91 | 92 | actual_migration_snippet = migrator.migrate_resources( 93 | resources=_qrc_sample_resources 94 | ) 95 | 96 | assert actual_migration_snippet == expected_integration_snippet 97 | 98 | expected_file_structure = """\ 99 | gui/ 100 | resources/ 101 | sample-project/ 102 | icons/ 103 | coffee.svg 104 | heart.svg 105 | email.svg 106 | help.svg\ 107 | """ 108 | 109 | assert expected_file_structure == list_files(gui_src_path) 110 | -------------------------------------------------------------------------------- /tests/test_ui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2022 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | import contextlib 33 | import os 34 | from pathlib import Path 35 | from shutil import copytree 36 | from typing import Union 37 | 38 | from aab.config import Config 39 | from aab.ui import QtVersion, UIBuilder 40 | 41 | from . import SAMPLE_PROJECT_NAME, SAMPLE_PROJECT_ROOT, SAMPLE_PROJECTS_FOLDER 42 | from .util import list_files 43 | 44 | 45 | @contextlib.contextmanager 46 | def change_dir(path: Union[Path, str]): 47 | current = os.getcwd() 48 | os.chdir(str(path)) 49 | try: 50 | yield 51 | finally: 52 | os.chdir(current) 53 | 54 | 55 | def test_ui_builder(tmp_path: Path): 56 | test_project_root = tmp_path / SAMPLE_PROJECT_NAME 57 | copytree(SAMPLE_PROJECT_ROOT, test_project_root) 58 | 59 | gui_src_path = test_project_root / "src" / "sample_project" / "gui" 60 | 61 | expected_file_structure = """\ 62 | gui/ 63 | resources/ 64 | __init__.py 65 | sample-project/ 66 | icons/ 67 | coffee.svg 68 | heart.svg 69 | email.svg 70 | help.svg 71 | forms/ 72 | __init__.py 73 | qt6/ 74 | __init__.py 75 | dialog.py 76 | qt5/ 77 | __init__.py 78 | dialog.py\ 79 | """ 80 | 81 | config = Config(test_project_root / "addon.json") 82 | 83 | with change_dir(test_project_root): 84 | ui_builder = UIBuilder(dist=test_project_root, config=config) 85 | 86 | ui_builder.build(QtVersion.qt5) 87 | ui_builder.build(QtVersion.qt6) 88 | ui_builder.create_qt_shim() 89 | 90 | assert ( 91 | list_files(gui_src_path) == expected_file_structure 92 | ), "Issue with GUI file structure" 93 | 94 | with (gui_src_path / "forms" / "qt6" / "dialog.py").open("r") as f: 95 | qt6_form_contents = f.read() 96 | with (gui_src_path / "forms" / "qt5" / "dialog.py").open("r") as f: 97 | qt5_form_contents = f.read() 98 | 99 | assert ( 100 | '"sample-project:icons/help.svg"' in qt6_form_contents 101 | ), "Base icon not properly remapped" 102 | assert ( 103 | '"sample-project:icons/coffee.svg"' in qt6_form_contents 104 | ), "Optional icon not properly remapped" 105 | 106 | assert "icons_rc" not in qt5_form_contents 107 | 108 | expected_shim_snippet = """\ 109 | from typing import TYPE_CHECKING 110 | 111 | from aqt.qt import qtmajor 112 | 113 | if TYPE_CHECKING or qtmajor >= 6: 114 | from .qt6 import * # noqa: F401 115 | else: 116 | from .qt5 import * # noqa: F401\ 117 | """ 118 | 119 | with (gui_src_path / "forms" / "__init__.py").open("r") as f: 120 | shim_contents = f.read() 121 | 122 | assert expected_shim_snippet in shim_contents, "Qt shim not properly constructed" 123 | 124 | 125 | def test_resources_only_no_forms(tmp_path: Path): 126 | test_project_root = tmp_path / "project-with-no-forms" 127 | sample_project_root = SAMPLE_PROJECTS_FOLDER / "project-with-no-forms" 128 | copytree(sample_project_root, test_project_root) 129 | 130 | gui_src_path = test_project_root / "src" / "sample_project" / "gui" 131 | 132 | expected_file_structure = """\ 133 | gui/ 134 | resources/ 135 | __init__.py 136 | sample-project/ 137 | icons/ 138 | coffee.svg 139 | heart.svg 140 | email.svg 141 | help.svg\ 142 | """ 143 | 144 | config = Config(test_project_root / "addon.json") 145 | 146 | with change_dir(test_project_root): 147 | ui_builder = UIBuilder(dist=test_project_root, config=config) 148 | 149 | assert ui_builder.build(QtVersion.qt5) is False 150 | assert ui_builder.build(QtVersion.qt6) is False 151 | assert ui_builder.create_qt_shim() is False 152 | 153 | assert ( 154 | list_files(gui_src_path) == expected_file_structure 155 | ), "Issue with GUI file structure" 156 | -------------------------------------------------------------------------------- /tests/util.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Anki Add-on Builder 4 | # 5 | # Copyright (C) 2016-2022 Aristotelis P. 6 | # 7 | # This program is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Affero General Public License as 9 | # published by the Free Software Foundation, either version 3 of the 10 | # License, or (at your option) any later version, with the additions 11 | # listed at the end of the license file that accompanied this program. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Affero General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Affero General Public License 19 | # along with this program. If not, see . 20 | # 21 | # NOTE: This program is subject to certain additional terms pursuant to 22 | # Section 7 of the GNU Affero General Public License. You should have 23 | # received a copy of these additional terms immediately following the 24 | # terms and conditions of the GNU Affero General Public License that 25 | # accompanied this program. 26 | # 27 | # If not, please request a copy through one of the means of contact 28 | # listed here: . 29 | # 30 | # Any modifications to this file must keep this entire header intact. 31 | 32 | 33 | import os 34 | from pathlib import Path 35 | 36 | 37 | def list_files(startpath: Path): 38 | path = str(startpath) 39 | 40 | ret = [] 41 | 42 | for root, dirs, files in os.walk(path): 43 | level = root.replace(path, "").count(os.sep) 44 | indent = " " * 4 * (level) 45 | ret.append("{}{}/".format(indent, os.path.basename(root))) 46 | subindent = " " * 4 * (level + 1) 47 | for f in files: 48 | ret.append("{}{}".format(subindent, f)) 49 | 50 | return "\n".join(ret) 51 | --------------------------------------------------------------------------------