├── .github └── FUNDING.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pylintrc ├── ChangeLog.md ├── LICENSE ├── Makefile ├── Pipfile ├── Pipfile.lock ├── README.md ├── images ├── oshit-comments.png ├── oshit-index.png └── oshit-user-dialog.png ├── oshit ├── __init__.py ├── __main__.py ├── app │ ├── __init__.py │ ├── commands.py │ ├── data │ │ ├── __init__.py │ │ ├── config.py │ │ └── locations.py │ ├── oshit.py │ ├── screens │ │ ├── __init__.py │ │ ├── comments.py │ │ ├── config.py │ │ ├── help.py │ │ ├── links.py │ │ ├── main.py │ │ ├── search.py │ │ └── user.py │ └── widgets │ │ ├── __init__.py │ │ ├── article_text.py │ │ ├── comment_card.py │ │ ├── hacker_news.py │ │ └── items.py └── hn │ ├── __init__.py │ ├── client.py │ ├── item │ ├── __init__.py │ ├── article.py │ ├── base.py │ ├── comment.py │ ├── link.py │ ├── loader.py │ ├── poll.py │ └── unknown.py │ ├── text.py │ └── user.py ├── pyproject.toml └── setup.cfg /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | ko_fi: davepearson 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .venv/ 2 | .coverage 3 | .coverage_report/ 4 | .DS_Store 5 | *.egg-info/ 6 | build/ 7 | dist/ 8 | __pycache__ 9 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pycqa/isort 3 | rev: 5.12.0 4 | hooks: 5 | - id: isort 6 | name: isort (python) 7 | language_version: '3.12' 8 | args: ["--profile", "black", "--filter-files"] 9 | - repo: https://github.com/psf/black 10 | rev: 23.3.0 11 | hooks: 12 | - id: black 13 | language_version: python3.12 14 | -------------------------------------------------------------------------------- /.pylintrc: -------------------------------------------------------------------------------- 1 | [FORMAT] 2 | max-line-length=120 3 | good-names=ItemType, ArticleType 4 | 5 | [MESSAGES CONTROL] 6 | disable=fixme, too-many-instance-attributes, too-many-public-methods, too-few-public-methods, too-many-ancestors 7 | 8 | [SIMILARITIES] 9 | min-similarity-lines = 10 10 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # OSHit ChangeLog 2 | 3 | ## v0.12.4 4 | 5 | **Released: 2024-08-02** 6 | 7 | - Fixed a crash when the HackerNews API returns `null` for an otherwise 8 | valid and available story. 9 | 10 | ## v0.12.3 11 | 12 | **Released: 2024-07-24** 13 | 14 | - Fixed a crash when the HackerNews API returns `null` for an otherwise 15 | valid and available story. 16 | 17 | ## v0.12.2 18 | 19 | **Released: 2024-06-23** 20 | 21 | - Pinned Textual. 22 | 23 | ## v0.12.1 24 | 25 | **Released: 2024-06-16** 26 | 27 | - Added a configuration dialog for tweaking the story fetching concurrency 28 | values. 29 | 30 | ## v0.12.0 31 | 32 | **Released: 2024-06-09** 33 | 34 | - Unpinned Textual, fixed a couple of issues the recent versions have 35 | introduced, and attempted to undo questionable upstream cosmetic choices. 36 | 37 | ## v0.11.2 38 | 39 | **Released: 2024-05-24** 40 | 41 | - Pinned Textual to <=0.60.1 due to ongoing problems with later versions. 42 | 43 | ## v0.11.1 44 | 45 | **Released: 2024-03-10** 46 | 47 | - Distribution update to support installation with Homebrew. 48 | 49 | ## v0.11.0 50 | 51 | **Released: 2024-03-09** 52 | 53 | - Once the first viewed tab has loaded, other tabs will start to load in the 54 | background (one after the other) as the user reads the first. 55 | - Added a config option to turn off the above. 56 | - Fixed a non-awaited-coroutine warning that could happen when quitting 57 | while loading items. ([#26](https://github.com/davep/oshit/issues/26)) 58 | 59 | ## v0.10.0 60 | 61 | **Released: 2024-02-28** 62 | 63 | - Added option to search locally-loaded items and place the results in a 64 | search tab. 65 | - Allowed Python 3.12. 66 | 67 | ## v0.9.0 68 | 69 | **Released: 2024-02-09** 70 | 71 | - Article text and poll answers are no longer "sticky" 72 | ([#21](https://github.com/davep/oshit/issues/21)) 73 | 74 | ## v0.8.0 75 | 76 | **Released: 2024-02-04** 77 | 78 | - Added support for loading and viewing text associated with an item. 79 | ([#17](https://github.com/davep/oshit/issues/17)) 80 | 81 | ## v0.7.0 82 | 83 | **Released: 2024-01-25** 84 | 85 | - Added the option to turn off the title-bar-based updating display of the 86 | age of the items. 87 | - Fixed not being able to change tabs with left/right during a reload. 88 | 89 | ## v0.6.0 90 | 91 | **Released: 2024-01-23** 92 | 93 | - Simplified the header bar, disabling Textual's mouse toggle of the height, 94 | and removing the "icon" in the top left corner. 95 | 96 | ## v0.5.0 97 | 98 | **Released: 2024-01-17** 99 | 100 | - Added support for optional numbering of items in each list. 101 | ([#11](https://github.com/davep/oshit/issues/11)) 102 | - Added support for placing caps on the number of items to fetch in each 103 | list. ([#11](https://github.com/davep/oshit/issues/11)) 104 | 105 | ## v0.4.0 106 | 107 | **Released: 2024-01-16** 108 | 109 | - Added support for loading and displaying polls. 110 | 111 | ## v0.3.0 112 | 113 | **Released: 2024-01-15** 114 | 115 | - Added a quick way of visiting links within comments. 116 | 117 | ## v0.2.0 118 | 119 | **Released: 2023-01-07** 120 | 121 | - Tweaked the look of comment cards in the comments dialog. 122 | - Expanding the replies of a comment is now an open/close toggle. 123 | 124 | ## v0.1.1 125 | 126 | **Released: 2023-01-01** 127 | 128 | - Made the gathering of items from the API less greedy, limiting the number 129 | of concurrent connections (yes, 500+ connections all at once is kind of a 130 | bad idea who knew?). Default limit is 50. 131 | - Added a configuration option to the configuration file for the above. 132 | - Added a connection timeout setting to the configuration file; hopefully 133 | useful for folk who are on slower connections. 134 | 135 | ## v0.1.0 136 | 137 | **Released: 2023-01-01** 138 | 139 | - Initial release. 140 | 141 | [//]: # (ChangeLog.md ends here) 142 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 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 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. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Common make values. 3 | lib := oshit 4 | run := pipenv run 5 | python := $(run) python 6 | lint := $(run) pylint 7 | mypy := $(run) mypy 8 | twine := $(run) twine 9 | build := $(python) -m build 10 | black := $(run) black 11 | 12 | ############################################################################## 13 | # Run the app. 14 | .PHONY: run 15 | run: 16 | $(python) -m $(lib) 17 | 18 | .PHONY: debug 19 | debug: 20 | TEXTUAL=devtools make 21 | 22 | .PHONY: console 23 | console: 24 | $(run) textual console 25 | 26 | ############################################################################## 27 | # Setup/update packages the system requires. 28 | .PHONY: setup 29 | setup: # Install all dependencies 30 | pipenv sync --dev 31 | $(run) pre-commit install 32 | 33 | .PHONY: resetup 34 | resetup: # Recreate the virtual environment from scratch 35 | rm -rf $(shell pipenv --venv) 36 | pipenv sync --dev 37 | 38 | .PHONY: depsoutdated 39 | depsoutdated: # Show a list of outdated dependencies 40 | pipenv update --outdated 41 | 42 | .PHONY: depsupdate 43 | depsupdate: # Update all dependencies 44 | pipenv update --dev 45 | 46 | .PHONY: depsshow 47 | depsshow: # Show the dependency graph 48 | pipenv graph 49 | 50 | ############################################################################## 51 | # Checking/testing/linting/etc. 52 | .PHONY: lint 53 | lint: # Run Pylint over the library 54 | $(lint) $(lib) 55 | 56 | .PHONY: typecheck 57 | typecheck: # Perform static type checks with mypy 58 | $(mypy) --scripts-are-modules $(lib) 59 | 60 | .PHONY: stricttypecheck 61 | stricttypecheck: # Perform a strict static type checks with mypy 62 | $(mypy) --scripts-are-modules --strict $(lib) 63 | 64 | .PHONY: checkall 65 | checkall: lint stricttypecheck # Check all the things 66 | 67 | ############################################################################## 68 | # Package/publish. 69 | .PHONY: package 70 | package: # Package the library 71 | $(build) -w 72 | 73 | .PHONY: spackage 74 | spackage: # Create a source package for the library 75 | $(build) -s 76 | 77 | .PHONY: packagecheck 78 | packagecheck: package spackage # Check the packaging. 79 | $(twine) check dist/* 80 | 81 | .PHONY: testdist 82 | testdist: packagecheck # Perform a test distribution 83 | $(twine) upload --skip-existing --repository testpypi dist/* 84 | 85 | .PHONY: dist 86 | dist: packagecheck # Upload to pypi 87 | $(twine) upload --skip-existing dist/* 88 | 89 | ############################################################################## 90 | # Utility. 91 | .PHONY: ugly 92 | ugly: # Reformat the code with black. 93 | $(black) $(lib) 94 | 95 | .PHONY: repl 96 | repl: # Start a Python REPL 97 | $(python) 98 | 99 | .PHONY: clean 100 | clean: # Clean the build directories 101 | rm -rf build dist $(lib).egg-info 102 | 103 | .PHONY: help 104 | help: # Display this help 105 | @grep -Eh "^[a-z]+:.+# " $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.+# "}; {printf "%-20s %s\n", $$1, $$2}' 106 | 107 | ############################################################################## 108 | # Housekeeping tasks. 109 | .PHONY: housekeeping 110 | housekeeping: # Perform some git housekeeping 111 | git fsck 112 | git gc --aggressive 113 | git remote update --prune 114 | 115 | ### Makefile ends here 116 | -------------------------------------------------------------------------------- /Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | httpx = "*" 8 | textual = "*" 9 | humanize = "*" 10 | xdg-base-dirs = "*" 11 | 12 | [dev-packages] 13 | pre-commit = "*" 14 | black = "*" 15 | mypy = "*" 16 | build = "*" 17 | twine = "*" 18 | pylint = "*" 19 | isort = "*" 20 | 21 | [requires] 22 | python_version = "3.12" 23 | -------------------------------------------------------------------------------- /Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "378d4175ad2880cab47072befc485de1b8674cf848e9c3139553f82054002014" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3.12" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": { 19 | "anyio": { 20 | "hashes": [ 21 | "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94", 22 | "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7" 23 | ], 24 | "markers": "python_version >= '3.8'", 25 | "version": "==4.4.0" 26 | }, 27 | "certifi": { 28 | "hashes": [ 29 | "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516", 30 | "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56" 31 | ], 32 | "markers": "python_version >= '3.6'", 33 | "version": "==2024.6.2" 34 | }, 35 | "h11": { 36 | "hashes": [ 37 | "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", 38 | "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761" 39 | ], 40 | "markers": "python_version >= '3.7'", 41 | "version": "==0.14.0" 42 | }, 43 | "httpcore": { 44 | "hashes": [ 45 | "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61", 46 | "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5" 47 | ], 48 | "markers": "python_version >= '3.8'", 49 | "version": "==1.0.5" 50 | }, 51 | "httpx": { 52 | "hashes": [ 53 | "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5", 54 | "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5" 55 | ], 56 | "index": "pypi", 57 | "markers": "python_version >= '3.8'", 58 | "version": "==0.27.0" 59 | }, 60 | "humanize": { 61 | "hashes": [ 62 | "sha256:582a265c931c683a7e9b8ed9559089dea7edcf6cc95be39a3cbc2c5d5ac2bcfa", 63 | "sha256:ce284a76d5b1377fd8836733b983bfb0b76f1aa1c090de2566fcf008d7f6ab16" 64 | ], 65 | "index": "pypi", 66 | "markers": "python_version >= '3.8'", 67 | "version": "==4.9.0" 68 | }, 69 | "idna": { 70 | "hashes": [ 71 | "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc", 72 | "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0" 73 | ], 74 | "markers": "python_version >= '3.5'", 75 | "version": "==3.7" 76 | }, 77 | "linkify-it-py": { 78 | "hashes": [ 79 | "sha256:68cda27e162e9215c17d786649d1da0021a451bdc436ef9e0fa0ba5234b9b048", 80 | "sha256:6bcbc417b0ac14323382aef5c5192c0075bf8a9d6b41820a2b66371eac6b6d79" 81 | ], 82 | "version": "==2.0.3" 83 | }, 84 | "markdown-it-py": { 85 | "extras": [ 86 | "linkify", 87 | "plugins" 88 | ], 89 | "hashes": [ 90 | "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", 91 | "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" 92 | ], 93 | "markers": "python_version >= '3.8'", 94 | "version": "==3.0.0" 95 | }, 96 | "mdit-py-plugins": { 97 | "hashes": [ 98 | "sha256:1020dfe4e6bfc2c79fb49ae4e3f5b297f5ccd20f010187acc52af2921e27dc6a", 99 | "sha256:834b8ac23d1cd60cec703646ffd22ae97b7955a6d596eb1d304be1e251ae499c" 100 | ], 101 | "version": "==0.4.1" 102 | }, 103 | "mdurl": { 104 | "hashes": [ 105 | "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", 106 | "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" 107 | ], 108 | "markers": "python_version >= '3.7'", 109 | "version": "==0.1.2" 110 | }, 111 | "pygments": { 112 | "hashes": [ 113 | "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199", 114 | "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a" 115 | ], 116 | "markers": "python_version >= '3.8'", 117 | "version": "==2.18.0" 118 | }, 119 | "rich": { 120 | "hashes": [ 121 | "sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222", 122 | "sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432" 123 | ], 124 | "markers": "python_full_version >= '3.7.0'", 125 | "version": "==13.7.1" 126 | }, 127 | "sniffio": { 128 | "hashes": [ 129 | "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", 130 | "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc" 131 | ], 132 | "markers": "python_version >= '3.7'", 133 | "version": "==1.3.1" 134 | }, 135 | "textual": { 136 | "hashes": [ 137 | "sha256:774bf45782193760ca273b915fd685cada37d0836237d61dc57d5bcdbe2c7ddb", 138 | "sha256:9ca3f615b5cf442246325e40ef8255424c42b4241d3c62f9c0f96951bab82b1e" 139 | ], 140 | "index": "pypi", 141 | "markers": "python_version >= '3.8' and python_version < '4.0'", 142 | "version": "==0.70.0" 143 | }, 144 | "typing-extensions": { 145 | "hashes": [ 146 | "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", 147 | "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8" 148 | ], 149 | "markers": "python_version >= '3.8'", 150 | "version": "==4.12.2" 151 | }, 152 | "uc-micro-py": { 153 | "hashes": [ 154 | "sha256:d321b92cff673ec58027c04015fcaa8bb1e005478643ff4a500882eaab88c48a", 155 | "sha256:db1dffff340817673d7b466ec86114a9dc0e9d4d9b5ba229d9d60e5c12600cd5" 156 | ], 157 | "markers": "python_version >= '3.7'", 158 | "version": "==1.0.3" 159 | }, 160 | "xdg-base-dirs": { 161 | "hashes": [ 162 | "sha256:63f6ebc1721ced2e86c340856e004ef829501a30a37e17079c52cfaf0e1741b9", 163 | "sha256:b4c8f4ba72d1286018b25eea374ec6fbf4fddda3d4137edf50de95de53e195a6" 164 | ], 165 | "index": "pypi", 166 | "markers": "python_version >= '3.10' and python_version < '4.0'", 167 | "version": "==6.0.1" 168 | } 169 | }, 170 | "develop": { 171 | "astroid": { 172 | "hashes": [ 173 | "sha256:8ead48e31b92b2e217b6c9733a21afafe479d52d6e164dd25fb1a770c7c3cf94", 174 | "sha256:e8a0083b4bb28fcffb6207a3bfc9e5d0a68be951dd7e336d5dcf639c682388c0" 175 | ], 176 | "markers": "python_full_version >= '3.8.0'", 177 | "version": "==3.2.2" 178 | }, 179 | "black": { 180 | "hashes": [ 181 | "sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474", 182 | "sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1", 183 | "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0", 184 | "sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8", 185 | "sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96", 186 | "sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1", 187 | "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04", 188 | "sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021", 189 | "sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94", 190 | "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d", 191 | "sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c", 192 | "sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7", 193 | "sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c", 194 | "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc", 195 | "sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7", 196 | "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d", 197 | "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c", 198 | "sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741", 199 | "sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce", 200 | "sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb", 201 | "sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063", 202 | "sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e" 203 | ], 204 | "index": "pypi", 205 | "markers": "python_version >= '3.8'", 206 | "version": "==24.4.2" 207 | }, 208 | "build": { 209 | "hashes": [ 210 | "sha256:526263f4870c26f26c433545579475377b2b7588b6f1eac76a001e873ae3e19d", 211 | "sha256:75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4" 212 | ], 213 | "index": "pypi", 214 | "markers": "python_version >= '3.8'", 215 | "version": "==1.2.1" 216 | }, 217 | "certifi": { 218 | "hashes": [ 219 | "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516", 220 | "sha256:ddc6c8ce995e6987e7faf5e3f1b02b302836a0e5d98ece18392cb1a36c72ad56" 221 | ], 222 | "markers": "python_version >= '3.6'", 223 | "version": "==2024.6.2" 224 | }, 225 | "cfgv": { 226 | "hashes": [ 227 | "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9", 228 | "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560" 229 | ], 230 | "markers": "python_version >= '3.8'", 231 | "version": "==3.4.0" 232 | }, 233 | "charset-normalizer": { 234 | "hashes": [ 235 | "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027", 236 | "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087", 237 | "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786", 238 | "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8", 239 | "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09", 240 | "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185", 241 | "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574", 242 | "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e", 243 | "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519", 244 | "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898", 245 | "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269", 246 | "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3", 247 | "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f", 248 | "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6", 249 | "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8", 250 | "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a", 251 | "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73", 252 | "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc", 253 | "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714", 254 | "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2", 255 | "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc", 256 | "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce", 257 | "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d", 258 | "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e", 259 | "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6", 260 | "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269", 261 | "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96", 262 | "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d", 263 | "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a", 264 | "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4", 265 | "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77", 266 | "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d", 267 | "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0", 268 | "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed", 269 | "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068", 270 | "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac", 271 | "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25", 272 | "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8", 273 | "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab", 274 | "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26", 275 | "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2", 276 | "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db", 277 | "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f", 278 | "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5", 279 | "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99", 280 | "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c", 281 | "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d", 282 | "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811", 283 | "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa", 284 | "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a", 285 | "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03", 286 | "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b", 287 | "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04", 288 | "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c", 289 | "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001", 290 | "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458", 291 | "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389", 292 | "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99", 293 | "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985", 294 | "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537", 295 | "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238", 296 | "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f", 297 | "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d", 298 | "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796", 299 | "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a", 300 | "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143", 301 | "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8", 302 | "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c", 303 | "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5", 304 | "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5", 305 | "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711", 306 | "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4", 307 | "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6", 308 | "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c", 309 | "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7", 310 | "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4", 311 | "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b", 312 | "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae", 313 | "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12", 314 | "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c", 315 | "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae", 316 | "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8", 317 | "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887", 318 | "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b", 319 | "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4", 320 | "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f", 321 | "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5", 322 | "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33", 323 | "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519", 324 | "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561" 325 | ], 326 | "markers": "python_full_version >= '3.7.0'", 327 | "version": "==3.3.2" 328 | }, 329 | "click": { 330 | "hashes": [ 331 | "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28", 332 | "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de" 333 | ], 334 | "markers": "python_version >= '3.7'", 335 | "version": "==8.1.7" 336 | }, 337 | "dill": { 338 | "hashes": [ 339 | "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca", 340 | "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7" 341 | ], 342 | "markers": "python_version >= '3.11'", 343 | "version": "==0.3.8" 344 | }, 345 | "distlib": { 346 | "hashes": [ 347 | "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784", 348 | "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64" 349 | ], 350 | "version": "==0.3.8" 351 | }, 352 | "docutils": { 353 | "hashes": [ 354 | "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f", 355 | "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2" 356 | ], 357 | "markers": "python_version >= '3.9'", 358 | "version": "==0.21.2" 359 | }, 360 | "filelock": { 361 | "hashes": [ 362 | "sha256:2207938cbc1844345cb01a5a95524dae30f0ce089eba5b00378295a17e3e90cb", 363 | "sha256:6ca1fffae96225dab4c6eaf1c4f4f28cd2568d3ec2a44e15a08520504de468e7" 364 | ], 365 | "markers": "python_version >= '3.8'", 366 | "version": "==3.15.4" 367 | }, 368 | "identify": { 369 | "hashes": [ 370 | "sha256:37d93f380f4de590500d9dba7db359d0d3da95ffe7f9de1753faa159e71e7dfa", 371 | "sha256:e5e00f54165f9047fbebeb4a560f9acfb8af4c88232be60a488e9b68d122745d" 372 | ], 373 | "markers": "python_version >= '3.8'", 374 | "version": "==2.5.36" 375 | }, 376 | "idna": { 377 | "hashes": [ 378 | "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc", 379 | "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0" 380 | ], 381 | "markers": "python_version >= '3.5'", 382 | "version": "==3.7" 383 | }, 384 | "importlib-metadata": { 385 | "hashes": [ 386 | "sha256:509ecb2ab77071db5137c655e24ceb3eee66e7bbc6574165d0d114d9fc4bbe68", 387 | "sha256:ffef94b0b66046dd8ea2d619b701fe978d9264d38f3998bc4c27ec3b146a87c8" 388 | ], 389 | "markers": "python_version >= '3.8'", 390 | "version": "==7.2.1" 391 | }, 392 | "isort": { 393 | "hashes": [ 394 | "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109", 395 | "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6" 396 | ], 397 | "index": "pypi", 398 | "markers": "python_full_version >= '3.8.0'", 399 | "version": "==5.13.2" 400 | }, 401 | "jaraco.classes": { 402 | "hashes": [ 403 | "sha256:47a024b51d0239c0dd8c8540c6c7f484be3b8fcf0b2d85c13825780d3b3f3acd", 404 | "sha256:f662826b6bed8cace05e7ff873ce0f9283b5c924470fe664fff1c2f00f581790" 405 | ], 406 | "markers": "python_version >= '3.8'", 407 | "version": "==3.4.0" 408 | }, 409 | "jaraco.context": { 410 | "hashes": [ 411 | "sha256:3e16388f7da43d384a1a7cd3452e72e14732ac9fe459678773a3608a812bf266", 412 | "sha256:c2f67165ce1f9be20f32f650f25d8edfc1646a8aeee48ae06fb35f90763576d2" 413 | ], 414 | "markers": "python_version >= '3.8'", 415 | "version": "==5.3.0" 416 | }, 417 | "jaraco.functools": { 418 | "hashes": [ 419 | "sha256:3b24ccb921d6b593bdceb56ce14799204f473976e2a9d4b15b04d0f2c2326664", 420 | "sha256:d33fa765374c0611b52f8b3a795f8900869aa88c84769d4d1746cd68fb28c3e8" 421 | ], 422 | "markers": "python_version >= '3.8'", 423 | "version": "==4.0.1" 424 | }, 425 | "keyring": { 426 | "hashes": [ 427 | "sha256:2458681cdefc0dbc0b7eb6cf75d0b98e59f9ad9b2d4edd319d18f68bdca95e50", 428 | "sha256:daaffd42dbda25ddafb1ad5fec4024e5bbcfe424597ca1ca452b299861e49f1b" 429 | ], 430 | "markers": "python_version >= '3.8'", 431 | "version": "==25.2.1" 432 | }, 433 | "markdown-it-py": { 434 | "extras": [ 435 | "linkify", 436 | "plugins" 437 | ], 438 | "hashes": [ 439 | "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", 440 | "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" 441 | ], 442 | "markers": "python_version >= '3.8'", 443 | "version": "==3.0.0" 444 | }, 445 | "mccabe": { 446 | "hashes": [ 447 | "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", 448 | "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" 449 | ], 450 | "markers": "python_version >= '3.6'", 451 | "version": "==0.7.0" 452 | }, 453 | "mdurl": { 454 | "hashes": [ 455 | "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", 456 | "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" 457 | ], 458 | "markers": "python_version >= '3.7'", 459 | "version": "==0.1.2" 460 | }, 461 | "more-itertools": { 462 | "hashes": [ 463 | "sha256:e5d93ef411224fbcef366a6e8ddc4c5781bc6359d43412a65dd5964e46111463", 464 | "sha256:ea6a02e24a9161e51faad17a8782b92a0df82c12c1c8886fec7f0c3fa1a1b320" 465 | ], 466 | "markers": "python_version >= '3.8'", 467 | "version": "==10.3.0" 468 | }, 469 | "mypy": { 470 | "hashes": [ 471 | "sha256:075cbf81f3e134eadaf247de187bd604748171d6b79736fa9b6c9685b4083061", 472 | "sha256:12b6bfc1b1a66095ab413160a6e520e1dc076a28f3e22f7fb25ba3b000b4ef99", 473 | "sha256:1ec404a7cbe9fc0e92cb0e67f55ce0c025014e26d33e54d9e506a0f2d07fe5de", 474 | "sha256:28d0e038361b45f099cc086d9dd99c15ff14d0188f44ac883010e172ce86c38a", 475 | "sha256:2b0695d605ddcd3eb2f736cd8b4e388288c21e7de85001e9f85df9187f2b50f9", 476 | "sha256:3236a4c8f535a0631f85f5fcdffba71c7feeef76a6002fcba7c1a8e57c8be1ec", 477 | "sha256:3be66771aa5c97602f382230165b856c231d1277c511c9a8dd058be4784472e1", 478 | "sha256:3d087fcbec056c4ee34974da493a826ce316947485cef3901f511848e687c131", 479 | "sha256:3f298531bca95ff615b6e9f2fc0333aae27fa48052903a0ac90215021cdcfa4f", 480 | "sha256:4a2b5cdbb5dd35aa08ea9114436e0d79aceb2f38e32c21684dcf8e24e1e92821", 481 | "sha256:4cf18f9d0efa1b16478c4c129eabec36148032575391095f73cae2e722fcf9d5", 482 | "sha256:8b2cbaca148d0754a54d44121b5825ae71868c7592a53b7292eeb0f3fdae95ee", 483 | "sha256:8f55583b12156c399dce2df7d16f8a5095291354f1e839c252ec6c0611e86e2e", 484 | "sha256:92f93b21c0fe73dc00abf91022234c79d793318b8a96faac147cd579c1671746", 485 | "sha256:9e36fb078cce9904c7989b9693e41cb9711e0600139ce3970c6ef814b6ebc2b2", 486 | "sha256:9fd50226364cd2737351c79807775136b0abe084433b55b2e29181a4c3c878c0", 487 | "sha256:a781f6ad4bab20eef8b65174a57e5203f4be627b46291f4589879bf4e257b97b", 488 | "sha256:a87dbfa85971e8d59c9cc1fcf534efe664d8949e4c0b6b44e8ca548e746a8d53", 489 | "sha256:b808e12113505b97d9023b0b5e0c0705a90571c6feefc6f215c1df9381256e30", 490 | "sha256:bc6ac273b23c6b82da3bb25f4136c4fd42665f17f2cd850771cb600bdd2ebeda", 491 | "sha256:cd777b780312ddb135bceb9bc8722a73ec95e042f911cc279e2ec3c667076051", 492 | "sha256:da1cbf08fb3b851ab3b9523a884c232774008267b1f83371ace57f412fe308c2", 493 | "sha256:e22e1527dc3d4aa94311d246b59e47f6455b8729f4968765ac1eacf9a4760bc7", 494 | "sha256:f8c083976eb530019175aabadb60921e73b4f45736760826aa1689dda8208aee", 495 | "sha256:f90cff89eea89273727d8783fef5d4a934be2fdca11b47def50cf5d311aff727", 496 | "sha256:fa7ef5244615a2523b56c034becde4e9e3f9b034854c93639adb667ec9ec2976", 497 | "sha256:fcfc70599efde5c67862a07a1aaf50e55bce629ace26bb19dc17cece5dd31ca4" 498 | ], 499 | "index": "pypi", 500 | "markers": "python_version >= '3.8'", 501 | "version": "==1.10.0" 502 | }, 503 | "mypy-extensions": { 504 | "hashes": [ 505 | "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d", 506 | "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782" 507 | ], 508 | "markers": "python_version >= '3.5'", 509 | "version": "==1.0.0" 510 | }, 511 | "nh3": { 512 | "hashes": [ 513 | "sha256:0316c25b76289cf23be6b66c77d3608a4fdf537b35426280032f432f14291b9a", 514 | "sha256:1a814dd7bba1cb0aba5bcb9bebcc88fd801b63e21e2450ae6c52d3b3336bc911", 515 | "sha256:1aa52a7def528297f256de0844e8dd680ee279e79583c76d6fa73a978186ddfb", 516 | "sha256:22c26e20acbb253a5bdd33d432a326d18508a910e4dcf9a3316179860d53345a", 517 | "sha256:40015514022af31975c0b3bca4014634fa13cb5dc4dbcbc00570acc781316dcc", 518 | "sha256:40d0741a19c3d645e54efba71cb0d8c475b59135c1e3c580f879ad5514cbf028", 519 | "sha256:551672fd71d06cd828e282abdb810d1be24e1abb7ae2543a8fa36a71c1006fe9", 520 | "sha256:66f17d78826096291bd264f260213d2b3905e3c7fae6dfc5337d49429f1dc9f3", 521 | "sha256:85cdbcca8ef10733bd31f931956f7fbb85145a4d11ab9e6742bbf44d88b7e351", 522 | "sha256:a3f55fabe29164ba6026b5ad5c3151c314d136fd67415a17660b4aaddacf1b10", 523 | "sha256:b4427ef0d2dfdec10b641ed0bdaf17957eb625b2ec0ea9329b3d28806c153d71", 524 | "sha256:ba73a2f8d3a1b966e9cdba7b211779ad8a2561d2dba9674b8a19ed817923f65f", 525 | "sha256:c21bac1a7245cbd88c0b0e4a420221b7bfa838a2814ee5bb924e9c2f10a1120b", 526 | "sha256:c551eb2a3876e8ff2ac63dff1585236ed5dfec5ffd82216a7a174f7c5082a78a", 527 | "sha256:c790769152308421283679a142dbdb3d1c46c79c823008ecea8e8141db1a2062", 528 | "sha256:d7a25fd8c86657f5d9d576268e3b3767c5cd4f42867c9383618be8517f0f022a" 529 | ], 530 | "version": "==0.2.17" 531 | }, 532 | "nodeenv": { 533 | "hashes": [ 534 | "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f", 535 | "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9" 536 | ], 537 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'", 538 | "version": "==1.9.1" 539 | }, 540 | "packaging": { 541 | "hashes": [ 542 | "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", 543 | "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124" 544 | ], 545 | "markers": "python_version >= '3.8'", 546 | "version": "==24.1" 547 | }, 548 | "pathspec": { 549 | "hashes": [ 550 | "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", 551 | "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712" 552 | ], 553 | "markers": "python_version >= '3.8'", 554 | "version": "==0.12.1" 555 | }, 556 | "pkginfo": { 557 | "hashes": [ 558 | "sha256:2e0dca1cf4c8e39644eed32408ea9966ee15e0d324c62ba899a393b3c6b467aa", 559 | "sha256:bfa76a714fdfc18a045fcd684dbfc3816b603d9d075febef17cb6582bea29573" 560 | ], 561 | "markers": "python_version >= '3.8'", 562 | "version": "==1.11.1" 563 | }, 564 | "platformdirs": { 565 | "hashes": [ 566 | "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee", 567 | "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3" 568 | ], 569 | "markers": "python_version >= '3.8'", 570 | "version": "==4.2.2" 571 | }, 572 | "pre-commit": { 573 | "hashes": [ 574 | "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a", 575 | "sha256:fae36fd1d7ad7d6a5a1c0b0d5adb2ed1a3bda5a21bf6c3e5372073d7a11cd4c5" 576 | ], 577 | "index": "pypi", 578 | "markers": "python_version >= '3.9'", 579 | "version": "==3.7.1" 580 | }, 581 | "pygments": { 582 | "hashes": [ 583 | "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199", 584 | "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a" 585 | ], 586 | "markers": "python_version >= '3.8'", 587 | "version": "==2.18.0" 588 | }, 589 | "pylint": { 590 | "hashes": [ 591 | "sha256:02f6c562b215582386068d52a30f520d84fdbcf2a95fc7e855b816060d048b60", 592 | "sha256:b3d7d2708a3e04b4679e02d99e72329a8b7ee8afb8d04110682278781f889fa8" 593 | ], 594 | "index": "pypi", 595 | "markers": "python_full_version >= '3.8.0'", 596 | "version": "==3.2.3" 597 | }, 598 | "pyproject-hooks": { 599 | "hashes": [ 600 | "sha256:4b37730834edbd6bd37f26ece6b44802fb1c1ee2ece0e54ddff8bfc06db86965", 601 | "sha256:7ceeefe9aec63a1064c18d939bdc3adf2d8aa1988a510afec15151578b232aa2" 602 | ], 603 | "markers": "python_version >= '3.7'", 604 | "version": "==1.1.0" 605 | }, 606 | "pyyaml": { 607 | "hashes": [ 608 | "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5", 609 | "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc", 610 | "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df", 611 | "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741", 612 | "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206", 613 | "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27", 614 | "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595", 615 | "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62", 616 | "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98", 617 | "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696", 618 | "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290", 619 | "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9", 620 | "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d", 621 | "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6", 622 | "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867", 623 | "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47", 624 | "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486", 625 | "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6", 626 | "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3", 627 | "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007", 628 | "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938", 629 | "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0", 630 | "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c", 631 | "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735", 632 | "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d", 633 | "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28", 634 | "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4", 635 | "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba", 636 | "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8", 637 | "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef", 638 | "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5", 639 | "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd", 640 | "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3", 641 | "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0", 642 | "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515", 643 | "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c", 644 | "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c", 645 | "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924", 646 | "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34", 647 | "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43", 648 | "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859", 649 | "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673", 650 | "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54", 651 | "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a", 652 | "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b", 653 | "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab", 654 | "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa", 655 | "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c", 656 | "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585", 657 | "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d", 658 | "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f" 659 | ], 660 | "markers": "python_version >= '3.6'", 661 | "version": "==6.0.1" 662 | }, 663 | "readme-renderer": { 664 | "hashes": [ 665 | "sha256:1818dd28140813509eeed8d62687f7cd4f7bad90d4db586001c5dc09d4fde311", 666 | "sha256:19db308d86ecd60e5affa3b2a98f017af384678c63c88e5d4556a380e674f3f9" 667 | ], 668 | "markers": "python_version >= '3.8'", 669 | "version": "==43.0" 670 | }, 671 | "requests": { 672 | "hashes": [ 673 | "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760", 674 | "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6" 675 | ], 676 | "markers": "python_version >= '3.8'", 677 | "version": "==2.32.3" 678 | }, 679 | "requests-toolbelt": { 680 | "hashes": [ 681 | "sha256:7681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6", 682 | "sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06" 683 | ], 684 | "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", 685 | "version": "==1.0.0" 686 | }, 687 | "rfc3986": { 688 | "hashes": [ 689 | "sha256:50b1502b60e289cb37883f3dfd34532b8873c7de9f49bb546641ce9cbd256ebd", 690 | "sha256:97aacf9dbd4bfd829baad6e6309fa6573aaf1be3f6fa735c8ab05e46cecb261c" 691 | ], 692 | "markers": "python_version >= '3.7'", 693 | "version": "==2.0.0" 694 | }, 695 | "rich": { 696 | "hashes": [ 697 | "sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222", 698 | "sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432" 699 | ], 700 | "markers": "python_full_version >= '3.7.0'", 701 | "version": "==13.7.1" 702 | }, 703 | "tomlkit": { 704 | "hashes": [ 705 | "sha256:af914f5a9c59ed9d0762c7b64d3b5d5df007448eb9cd2edc8a46b1eafead172f", 706 | "sha256:eef34fba39834d4d6b73c9ba7f3e4d1c417a4e56f89a7e96e090dd0d24b8fb3c" 707 | ], 708 | "markers": "python_version >= '3.7'", 709 | "version": "==0.12.5" 710 | }, 711 | "twine": { 712 | "hashes": [ 713 | "sha256:4d74770c88c4fcaf8134d2a6a9d863e40f08255ff7d8e2acb3cbbd57d25f6e9d", 714 | "sha256:fe1d814395bfe50cfbe27783cb74efe93abeac3f66deaeb6c8390e4e92bacb43" 715 | ], 716 | "index": "pypi", 717 | "markers": "python_version >= '3.8'", 718 | "version": "==5.1.0" 719 | }, 720 | "typing-extensions": { 721 | "hashes": [ 722 | "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d", 723 | "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8" 724 | ], 725 | "markers": "python_version >= '3.8'", 726 | "version": "==4.12.2" 727 | }, 728 | "urllib3": { 729 | "hashes": [ 730 | "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472", 731 | "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168" 732 | ], 733 | "markers": "python_version >= '3.8'", 734 | "version": "==2.2.2" 735 | }, 736 | "virtualenv": { 737 | "hashes": [ 738 | "sha256:4c43a2a236279d9ea36a0d76f98d84bd6ca94ac4e0f4a3b9d46d05e10fea542a", 739 | "sha256:8cc4a31139e796e9a7de2cd5cf2489de1217193116a8fd42328f1bd65f434589" 740 | ], 741 | "markers": "python_version >= '3.7'", 742 | "version": "==20.26.3" 743 | }, 744 | "zipp": { 745 | "hashes": [ 746 | "sha256:bf1dcf6450f873a13e952a29504887c89e6de7506209e5b1bcc3460135d4de19", 747 | "sha256:f091755f667055f2d02b32c53771a7a6c8b47e1fdbc4b72a8b9072b3eef8015c" 748 | ], 749 | "markers": "python_version >= '3.8'", 750 | "version": "==3.19.2" 751 | } 752 | } 753 | } 754 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSHit -- Get your hit of the Orange Site in the terminal 2 | 3 | ## Introduction 4 | 5 | OSHit is a read-only terminal-based client for HackerNews. It provides the 6 | ability to view all the top/recent items in the major categories, as well as 7 | allowing viewing comments and user details. Where relevant, bindings are 8 | always available to open the relevant view on HackerNews itself in your web 9 | browser. 10 | 11 | Please note that this client *isn't* designed to allow reading any and all 12 | stories on HackerNews, it's about reading what's current "hot" or new, 13 | within the categories provided by [their 14 | API](https://github.com/HackerNews/API). 15 | 16 | ## Installing 17 | 18 | ### pipx 19 | 20 | The package can be installed using [`pipx`](https://pypa.github.io/pipx/): 21 | 22 | ```sh 23 | $ pipx install oshit 24 | ``` 25 | 26 | ### Homebrew 27 | 28 | The package can be installed using Homebrew. Use the following commands to 29 | install: 30 | 31 | ```sh 32 | $ brew tap davep/homebrew 33 | $ brew install oshit 34 | ``` 35 | 36 | ## Running 37 | 38 | Once installed run the `oshit` command. 39 | 40 | ## Main features 41 | 42 | When run up the opening display is a list of items, the initial list being 43 | the current top stories and jobs on HackerNews. Other lists available, via 44 | shortcut keys or via tabs at the top of the screen, are "New", "Best", 45 | "Ask", "Show" and "Jobs". 46 | 47 | ![The main index](https://raw.githubusercontent.com/davep/oshit/main/images/oshit-index.png) 48 | 49 | Pressing u when viewing a job or a comment will open a dialog 50 | that shows the details of the user who posted the item. 51 | 52 | ![Viewing user details](https://raw.githubusercontent.com/davep/oshit/main/images/oshit-user-dialog.png) 53 | 54 | When viewing a story or job and pressing c a dialog will open 55 | that will let you view and navigate its comments. 56 | 57 | ![Viewing comments](https://raw.githubusercontent.com/davep/oshit/main/images/oshit-comments.png) 58 | 59 | ## Tweaking 60 | 61 | Because of the nature of the HackerNews API there might be a need for you to 62 | dial in the ideal number of concurrent connections made to load up the data, 63 | and also the timeout for the connections. As of the time of writing the 64 | defaults are 50 concurrent connections and a timeout of 20 seconds. 65 | 66 | If you run into problems press F11 and tweak the maximum 67 | concurrency and connection timeout values to taste (or look in 68 | `~/.config/oshit/configuration.json` and change the `"maximum_concurrency"` 69 | and `"connection_timeout"` values). 70 | 71 | ## Getting help 72 | 73 | If you need help, or have any ideas, please feel free to [raise an 74 | issue](https://github.com/davep/oshit/issues) or [start a 75 | discussion](https://github.com/davep/oshit/discussions). 76 | 77 | ## TODO 78 | 79 | Things I'm considering adding or addressing: 80 | 81 | - [X] Chill out on item loading (see [#2](https://github.com/davep/oshit/issues/2)) 82 | - [ ] Add a configuration dialog for the connection value tweaks. 83 | - [ ] Some degree of caching of items to reduce API hits. 84 | - [ ] Expand the text-cleaning code to handle links, etc. 85 | - [ ] Look at some "markup" of comments, eg: make quoted text more obvious. 86 | - [ ] Add searching 87 | - [X] Amongst the current view 88 | - [ ] Amongst loaded comments within comment view 89 | - [ ] All of history ([`hn.algolia.com`](https://hn.algolia.com/api)) 90 | 91 | [//]: # (README.md ends here) 92 | -------------------------------------------------------------------------------- /images/oshit-comments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davep/oshit/e08e49c01ed6db8b7498f1ca4db987afd9f5c40b/images/oshit-comments.png -------------------------------------------------------------------------------- /images/oshit-index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davep/oshit/e08e49c01ed6db8b7498f1ca4db987afd9f5c40b/images/oshit-index.png -------------------------------------------------------------------------------- /images/oshit-user-dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davep/oshit/e08e49c01ed6db8b7498f1ca4db987afd9f5c40b/images/oshit-user-dialog.png -------------------------------------------------------------------------------- /oshit/__init__.py: -------------------------------------------------------------------------------- 1 | """A terminal-based HackerNews reader.""" 2 | 3 | ###################################################################### 4 | # Main app information. 5 | __author__ = "Dave Pearson" 6 | __copyright__ = "Copyright 2024, Dave Pearson" 7 | __credits__ = ["Dave Pearson"] 8 | __maintainer__ = "Dave Pearson" 9 | __email__ = "davep@davep.org" 10 | __version__ = "0.12.4" 11 | __licence__ = "GPLv3+" 12 | 13 | ############################################################################## 14 | # Public symbols. 15 | __all__: list[str] = [] 16 | 17 | ### __init__.py ends here 18 | -------------------------------------------------------------------------------- /oshit/__main__.py: -------------------------------------------------------------------------------- 1 | """The main entry point for the application.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .app import OSHit 6 | 7 | 8 | ############################################################################## 9 | def run() -> None: 10 | """Run the application.""" 11 | OSHit().run() 12 | 13 | 14 | ############################################################################## 15 | if __name__ == "__main__": 16 | run() 17 | 18 | ### __main__.py ends here 19 | -------------------------------------------------------------------------------- /oshit/app/__init__.py: -------------------------------------------------------------------------------- 1 | """Orange Site Hit. 2 | 3 | Get your HackerNews hit in the terminal. 4 | """ 5 | 6 | ############################################################################## 7 | # Local imports. 8 | from .oshit import OSHit 9 | 10 | ############################################################################## 11 | # Exports. 12 | __all__ = ["OSHit"] 13 | 14 | ### __init__.py ends here 15 | -------------------------------------------------------------------------------- /oshit/app/commands.py: -------------------------------------------------------------------------------- 1 | """Provides command messages for the application.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import dataclass 6 | 7 | ############################################################################## 8 | # Textual imports. 9 | from textual.message import Message 10 | 11 | ############################################################################## 12 | # Local imports. 13 | from ..hn.item import Article 14 | 15 | 16 | ############################################################################## 17 | @dataclass 18 | class ShowUser(Message): 19 | """Command message for requesting that a user's details be shown.""" 20 | 21 | user: str 22 | """The ID of the user to show.""" 23 | 24 | 25 | ############################################################################## 26 | @dataclass 27 | class ShowComments(Message): 28 | """Command message for requesting that an article's comments be shown.""" 29 | 30 | article: Article 31 | """The article to show the comments for.""" 32 | 33 | 34 | ### commands.py ends here 35 | -------------------------------------------------------------------------------- /oshit/app/data/__init__.py: -------------------------------------------------------------------------------- 1 | """Code relating to the data stored by the application.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .config import load_configuration, save_configuration 6 | 7 | ############################################################################## 8 | # Exports. 9 | __all__ = [ 10 | "load_configuration", 11 | "save_configuration", 12 | ] 13 | 14 | ### __init__.py ends here 15 | -------------------------------------------------------------------------------- /oshit/app/data/config.py: -------------------------------------------------------------------------------- 1 | """Code relating to the application's configuration file.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import asdict, dataclass 6 | from functools import lru_cache 7 | from json import dumps, loads 8 | from pathlib import Path 9 | 10 | ############################################################################## 11 | # Local imports. 12 | from .locations import config_dir 13 | 14 | 15 | ############################################################################## 16 | @dataclass 17 | class Configuration: 18 | """The configuration data for the application.""" 19 | 20 | dark_mode: bool = True 21 | """Should we run in dark mode?""" 22 | 23 | compact_mode: bool = True 24 | """Should the items display in compact mode?""" 25 | 26 | item_numbers: bool = False 27 | """Should we show numbers against items in the lists?""" 28 | 29 | show_data_age: bool = True 30 | """Should we show the age of the data in the lists?""" 31 | 32 | maximum_concurrency: int = 50 33 | """The maximum number of connections to use when getting items.""" 34 | 35 | connection_timeout: int | None = 20 36 | """The timeout (in seconds) to use when connecting to the HackerNews API.""" 37 | 38 | maximum_top: int = 500 39 | """The maximum number of top stories to show.""" 40 | 41 | maximum_new: int = 500 42 | """The maximum number of new stories to show.""" 43 | 44 | maximum_best: int = 200 45 | """The maximum number of best stories to show.""" 46 | 47 | maximum_ask: int = 200 48 | """The maximum number of AskHN stories to show.""" 49 | 50 | maximum_show: int = 200 51 | """The maximum number of ShowHN stories to show.""" 52 | 53 | maximum_jobs: int = 200 54 | """The maximum number of jobs to show.""" 55 | 56 | background_load_tabs: bool = True 57 | """Should the content of the tabs try and load in the background?""" 58 | 59 | 60 | ############################################################################## 61 | def configuration_file() -> Path: 62 | """The path to the file that holds the application configuration. 63 | 64 | Returns: 65 | The path to the configuration file. 66 | """ 67 | return config_dir() / "configuration.json" 68 | 69 | 70 | ############################################################################## 71 | def save_configuration(configuration: Configuration) -> Configuration: 72 | """Save the given configuration. 73 | 74 | Args: 75 | The configuration to store. 76 | 77 | Returns: 78 | The configuration. 79 | """ 80 | load_configuration.cache_clear() 81 | configuration_file().write_text( 82 | dumps(asdict(configuration), indent=4), encoding="utf-8" 83 | ) 84 | return load_configuration() 85 | 86 | 87 | ############################################################################## 88 | @lru_cache(maxsize=None) 89 | def load_configuration() -> Configuration: 90 | """Load the configuration. 91 | 92 | Returns: 93 | The configuration. 94 | 95 | Note: 96 | As a side-effect, if the configuration doesn't exist a default one 97 | will be saved to storage. 98 | 99 | This function is designed so that it's safe and low-cost to 100 | repeatedly call it. The configuration is cached and will only be 101 | loaded from storage when necessary. 102 | """ 103 | source = configuration_file() 104 | return ( 105 | Configuration(**loads(source.read_text(encoding="utf-8"))) 106 | if source.exists() 107 | else save_configuration(Configuration()) 108 | ) 109 | 110 | 111 | ### config.py ends here 112 | -------------------------------------------------------------------------------- /oshit/app/data/locations.py: -------------------------------------------------------------------------------- 1 | """Functions for getting the locations of data.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from pathlib import Path 6 | 7 | ############################################################################## 8 | # XDG imports. 9 | from xdg_base_dirs import xdg_config_home 10 | 11 | 12 | ############################################################################## 13 | def _oshit_dir(root: Path) -> Path: 14 | """Given a root, ensure and return the oshot directory within it.""" 15 | (save_to := root / "oshit").mkdir(parents=True, exist_ok=True) 16 | return save_to 17 | 18 | 19 | ############################################################################## 20 | def config_dir() -> Path: 21 | """The path to the configuration directory for the application. 22 | 23 | Returns: 24 | The path to the configuration directory for the application. 25 | 26 | Note: 27 | If the directory doesn't exist, it will be created as a side-effect 28 | of calling this function. 29 | """ 30 | return _oshit_dir(xdg_config_home()) 31 | 32 | 33 | ### locations.py ends here 34 | -------------------------------------------------------------------------------- /oshit/app/oshit.py: -------------------------------------------------------------------------------- 1 | """The main application class.""" 2 | 3 | ############################################################################## 4 | # Textual imports. 5 | from textual.app import App 6 | 7 | ############################################################################## 8 | # Local imports. 9 | from .data import load_configuration, save_configuration 10 | from .screens import Main 11 | 12 | 13 | ############################################################################## 14 | class OSHit(App[None]): 15 | """The Orange Site Hit application.""" 16 | 17 | ENABLE_COMMAND_PALETTE = False 18 | 19 | CSS = """ 20 | Header { 21 | HeaderIcon { 22 | visibility: hidden; 23 | } 24 | 25 | &.-tall { 26 | height: 1; 27 | } 28 | } 29 | 30 | Footer, Footer * { 31 | background: $primary; 32 | } 33 | 34 | FooterKey .footer-key--key { 35 | color: $text; 36 | } 37 | """ 38 | 39 | def __init__(self) -> None: 40 | """Initialise the application.""" 41 | super().__init__() 42 | self.dark = load_configuration().dark_mode 43 | 44 | def on_mount(self) -> None: 45 | """Get things going once the app is up and running.""" 46 | self.push_screen(Main()) 47 | 48 | def _watch_dark(self) -> None: 49 | """Save the light/dark mode configuration choice.""" 50 | configuration = load_configuration() 51 | configuration.dark_mode = self.dark 52 | save_configuration(configuration) 53 | 54 | 55 | ### oshit.py ends here 56 | -------------------------------------------------------------------------------- /oshit/app/screens/__init__.py: -------------------------------------------------------------------------------- 1 | """The screens for the application.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .main import Main 6 | 7 | ############################################################################## 8 | # Exports. 9 | __all__ = ["Main"] 10 | 11 | ### __init__.py ends here 12 | -------------------------------------------------------------------------------- /oshit/app/screens/comments.py: -------------------------------------------------------------------------------- 1 | """Provides a modal screen for showing the comments for an item.""" 2 | 3 | ############################################################################## 4 | # Humanize imports. 5 | from humanize import intcomma, naturaltime 6 | 7 | ############################################################################## 8 | # Textual imports. 9 | from textual import on, work 10 | from textual.app import ComposeResult 11 | from textual.containers import Horizontal, Vertical, VerticalScroll 12 | from textual.screen import ModalScreen 13 | from textual.widget import Widget 14 | from textual.widgets import Button, Footer, Label 15 | 16 | ############################################################################## 17 | # Local imports. 18 | from ...hn import HN 19 | from ...hn.item import Article, Comment, Poll, PollOption 20 | from ..widgets import ArticleText, CommentCard, CommentCardWithReplies 21 | 22 | 23 | ############################################################################## 24 | class PollOptionDisplay(Label): 25 | """Widget that displays a poll option.""" 26 | 27 | def __init__(self, option: PollOption) -> None: 28 | """Initialise the poll option display. 29 | 30 | Args: 31 | option: The option to display. 32 | """ 33 | super().__init__() 34 | self.update( 35 | f"[bold]{option.text}[/]\n[dim]{option.score} point{'' if option.score == 1 else 's'}[/]" 36 | ) 37 | 38 | 39 | ############################################################################## 40 | class Comments(ModalScreen[None]): 41 | """Dialog for navigating the comments of an item from HackerNews.""" 42 | 43 | DEFAULT_CSS = """ 44 | Comments { 45 | align: center middle; 46 | 47 | &> Vertical { 48 | width: 90%; 49 | height: 90%; 50 | background: $panel; 51 | border: panel $primary; 52 | border-title-color: $accent; 53 | } 54 | 55 | #info { 56 | padding: 1; 57 | background: $boost; 58 | height: auto; 59 | border-bottom: solid $primary; 60 | } 61 | 62 | ArticleText { 63 | padding: 1; 64 | margin-right: 1; 65 | border-bottom: solid $primary; 66 | background: $panel; 67 | 68 | &:focus { 69 | background: $boost; 70 | } 71 | } 72 | 73 | #poll-options { 74 | height: auto; 75 | padding: 1; 76 | background: $panel; 77 | height: auto; 78 | border-bottom: solid $primary; 79 | } 80 | 81 | #buttons { 82 | padding: 1 1 0 1; 83 | height: auto; 84 | border-top: solid $primary; 85 | align-horizontal: right; 86 | 87 | Button { 88 | margin-left: 1; 89 | } 90 | } 91 | 92 | VerticalScroll { 93 | height: 1fr; 94 | } 95 | 96 | #no-comments { 97 | margin-top: 1; 98 | width: 1fr; 99 | text-align: center; 100 | color: $text-muted; 101 | text-style: italic; 102 | } 103 | } 104 | """ 105 | 106 | BINDINGS = [("escape", "close")] 107 | 108 | def __init__(self, client: HN, article: Article) -> None: 109 | """Initialise the comments screen. 110 | 111 | Args: 112 | client: The HackerNews client object. 113 | article: The article to show the comments for. 114 | """ 115 | super().__init__() 116 | self._hn = client 117 | """The HackerNews client object.""" 118 | self._article = article 119 | """The article to show the comments for.""" 120 | 121 | def compose(self) -> ComposeResult: 122 | """Compose the comments screen.""" 123 | with Vertical() as dialog: 124 | dialog.border_title = f"Comments for article #{self._article.item_id}" 125 | with Vertical(id="info"): 126 | yield Label(self._article.title, markup=False) 127 | yield Label( 128 | f"{intcomma(self._article.score)} " 129 | f"point{'' if self._article.score == 1 else 's'} " 130 | f"by {self._article.by} {naturaltime(self._article.time)}, " 131 | f"{intcomma(self._article.descendants)} comment{'' if self._article.descendants == 1 else 's'}", 132 | ) 133 | with VerticalScroll() as body: 134 | body.can_focus = False 135 | if self._article.has_text: 136 | yield ArticleText(self._article) 137 | if isinstance(self._article, Poll): 138 | yield Vertical(id="poll-options") 139 | yield Label("No comments", id="no-comments") 140 | with Horizontal(id="buttons"): 141 | yield Button("Okay [dim]\\[Esc][/]", id="close") 142 | yield Footer() 143 | 144 | @work 145 | async def _load_comments(self, within: Widget, item: Article | Comment) -> None: 146 | """Load the given list of comments into the display. 147 | 148 | Args: 149 | within: The container to load the comments into. 150 | item: The item to load the comments for. 151 | """ 152 | await within.mount_all( 153 | (CommentCardWithReplies if comment.kids else CommentCard)( 154 | self._hn, item, comment 155 | ) 156 | for comment in await self._hn.comments(item) 157 | ) 158 | 159 | @work 160 | async def _load_poll_options(self, poll: Poll) -> None: 161 | options = await self._hn.poll_options(poll) 162 | self.notify(str(len(options))) 163 | self.query_one("#poll-options").mount_all( 164 | [PollOptionDisplay(option) for option in options] 165 | ) 166 | 167 | async def on_mount(self) -> None: 168 | """Start the comment loading process once the DOM is ready.""" 169 | if isinstance(self._article, Poll): 170 | self._load_poll_options(self._article) 171 | if self._article.kids: 172 | await self.query_one("#no-comments").remove() 173 | self._load_comments(self.query_one(VerticalScroll), self._article) 174 | 175 | @on(Button.Pressed, "#close") 176 | def action_close(self) -> None: 177 | """Close the dialog screen.""" 178 | self.dismiss(None) 179 | 180 | @on(CommentCardWithReplies.LoadReplies) 181 | def load_replies(self, event: CommentCardWithReplies.LoadReplies) -> None: 182 | """Load the replies for a comment. 183 | 184 | Args: 185 | event: The event to handle. 186 | """ 187 | self._load_comments(event.load_into, event.comment) 188 | 189 | 190 | ### comments.py ends here 191 | -------------------------------------------------------------------------------- /oshit/app/screens/config.py: -------------------------------------------------------------------------------- 1 | """Configuration dialog for the application.""" 2 | 3 | ############################################################################## 4 | # Textual imports. 5 | from textual import on 6 | from textual.app import ComposeResult 7 | from textual.containers import Grid, Horizontal, Vertical 8 | from textual.screen import ModalScreen 9 | from textual.validation import Number 10 | from textual.widgets import Button, Checkbox, Input, Label 11 | 12 | ############################################################################## 13 | # Local imports. 14 | from ..data import load_configuration, save_configuration 15 | 16 | 17 | ############################################################################## 18 | class ConfigurationDialog(ModalScreen[None]): 19 | """Configuration dialog for the OSHit settings.""" 20 | 21 | DEFAULT_CSS = """ 22 | ConfigurationDialog { 23 | 24 | align: center middle; 25 | 26 | & > Vertical { 27 | width: 60%; 28 | height: auto; 29 | background: $surface; 30 | border: panel $primary; 31 | border-title-color: $accent; 32 | padding: 1 2; 33 | 34 | Grid { 35 | grid-size: 3; 36 | grid-rows: auto; 37 | height: 12; 38 | 39 | Label { 40 | margin-left: 1; 41 | width: 1fr; 42 | } 43 | 44 | Input { 45 | width: 1fr; 46 | } 47 | } 48 | 49 | Checkbox { 50 | margin-top: 1; 51 | } 52 | } 53 | 54 | Horizontal { 55 | height: auto; 56 | align-horizontal: right; 57 | 58 | Button { 59 | margin-left: 1; 60 | } 61 | } 62 | } 63 | """ 64 | 65 | BINDINGS = [ 66 | ("f2", "save"), 67 | ("escape", "cancel"), 68 | ] 69 | 70 | def compose(self) -> ComposeResult: 71 | """Compose the layout of the dialog.""" 72 | config = load_configuration() 73 | with Vertical() as dialog: 74 | dialog.border_title = "OSHit Configuration" 75 | with Grid(): 76 | with Vertical(): 77 | yield Label("Maximum Concurrency:") 78 | yield Input( 79 | str(config.maximum_concurrency), 80 | id="max-con", 81 | type="integer", 82 | validators=[Number(minimum=1, maximum=500)], 83 | ) 84 | with Vertical(): 85 | yield Label("Connection Timeout:") 86 | yield Input( 87 | str(config.connection_timeout), 88 | id="timeout", 89 | type="integer", 90 | validators=[Number(minimum=1, maximum=60)], 91 | ) 92 | with Vertical(): 93 | yield Label("Maximum Top Items:") 94 | yield Input( 95 | str(config.maximum_top), 96 | id="max-top", 97 | type="integer", 98 | validators=[Number(minimum=1, maximum=500)], 99 | ) 100 | with Vertical(): 101 | yield Label("Maximum New Items:") 102 | yield Input( 103 | str(config.maximum_new), 104 | id="max-new", 105 | type="integer", 106 | validators=[Number(minimum=1, maximum=500)], 107 | ) 108 | with Vertical(): 109 | yield Label("Maximum Best Items:") 110 | yield Input( 111 | str(config.maximum_best), 112 | id="max-best", 113 | type="integer", 114 | validators=[Number(minimum=1, maximum=200)], 115 | ) 116 | with Vertical(): 117 | yield Label("Maximum Ask Items:") 118 | yield Input( 119 | str(config.maximum_ask), 120 | id="max-ask", 121 | type="integer", 122 | validators=[Number(minimum=1, maximum=200)], 123 | ) 124 | with Vertical(): 125 | yield Label("Maximum Show Items:") 126 | yield Input( 127 | str(config.maximum_show), 128 | id="max-show", 129 | type="integer", 130 | validators=[Number(minimum=1, maximum=200)], 131 | ) 132 | with Vertical(): 133 | yield Label("Maximum Jobs Items:") 134 | yield Input( 135 | str(config.maximum_jobs), 136 | id="max-jobs", 137 | type="integer", 138 | validators=[Number(minimum=1, maximum=200)], 139 | ) 140 | yield Checkbox("Load other tabs in background", config.background_load_tabs) 141 | with Horizontal(): 142 | yield Button("OK [dim]\\[F2][/]", id="ok") 143 | yield Button("Cancel [dim]\\[Esc][/]", id="cancel") 144 | 145 | @property 146 | def dialog_valid(self) -> bool: 147 | """Is the dialog as a whole valid?""" 148 | for field in self.query(Input).results(): 149 | if not field.is_valid: 150 | return False 151 | return True 152 | 153 | @on(Button.Pressed, "#ok") 154 | def action_save(self) -> None: 155 | """Save the configuration.""" 156 | if self.dialog_valid: 157 | config = load_configuration() 158 | config.maximum_concurrency = int(self.query_one("#max-con", Input).value) 159 | config.connection_timeout = int(self.query_one("#timeout", Input).value) 160 | config.maximum_top = int(self.query_one("#max-top", Input).value) 161 | config.maximum_new = int(self.query_one("#max-new", Input).value) 162 | config.maximum_best = int(self.query_one("#max-best", Input).value) 163 | config.maximum_ask = int(self.query_one("#max-ask", Input).value) 164 | config.maximum_show = int(self.query_one("#max-show", Input).value) 165 | config.maximum_jobs = int(self.query_one("#max-jobs", Input).value) 166 | config.background_load_tabs = self.query_one(Checkbox).value 167 | save_configuration(config) 168 | self.dismiss(None) 169 | 170 | @on(Button.Pressed, "#cancel") 171 | def action_cancel(self) -> None: 172 | """Cancel the editing of the configuration.""" 173 | self.dismiss(None) 174 | 175 | @on(Input.Changed) 176 | def allow_okay(self) -> None: 177 | """Enable or disable the OK button based on the dialog validity.""" 178 | self.query_one("#ok").disabled = not self.dialog_valid 179 | 180 | def on_mount(self) -> None: 181 | """Configure the dialog on mount.""" 182 | self.allow_okay() 183 | 184 | 185 | ### config.py ends here 186 | -------------------------------------------------------------------------------- /oshit/app/screens/help.py: -------------------------------------------------------------------------------- 1 | """The help screen for the application.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from inspect import cleandoc 6 | from typing import Any 7 | from webbrowser import open as open_url 8 | 9 | ############################################################################## 10 | # Textual imports. 11 | from textual import on 12 | from textual.app import ComposeResult 13 | from textual.containers import Center, Vertical, VerticalScroll 14 | from textual.screen import ModalScreen, Screen 15 | from textual.widgets import Button, Markdown 16 | 17 | ############################################################################## 18 | # Local imports. 19 | from ... import __version__ 20 | 21 | ############################################################################## 22 | # The help text. 23 | HELP = f"""\ 24 | # Orange Site Hit v{__version__} 25 | 26 | ## Introduction 27 | 28 | OSHit is a terminal-based read-only client for [HackerNews](https://news.ycombinator.com/). 29 | 30 | {{context_help}} 31 | 32 | ## About 33 | 34 | OSHit was created by and is maintained by [Dave 35 | Pearson](https://www.davep.org/); it is Free Software and can be [found on 36 | GitHub](https://github.com/davep/oshit). 37 | 38 | ## Licence 39 | 40 | OSHit - A terminal-based HackerNews reader.[EOL] 41 | Copyright (C) 2024 Dave Pearson 42 | 43 | This program is free software: you can redistribute it and/or modify it 44 | under the terms of the GNU General Public License as published by the Free 45 | Software Foundation, either version 3 of the License, or (at your option) 46 | any later version. 47 | 48 | This program is distributed in the hope that it will be useful, but WITHOUT 49 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 51 | more details. 52 | 53 | You should have received a copy of the GNU General Public License along with 54 | this program. If not, see . 55 | """ 56 | 57 | 58 | ############################################################################## 59 | class Help(ModalScreen[None]): 60 | """The help screen.""" 61 | 62 | DEFAULT_CSS = """ 63 | Help { 64 | align: center middle; 65 | 66 | Vertical { 67 | width: 75%; 68 | height: 90%; 69 | background: $surface; 70 | border: panel $primary; 71 | border-title-color: $accent; 72 | } 73 | 74 | VerticalScroll { 75 | scrollbar-gutter: stable; 76 | } 77 | 78 | Center { 79 | height: auto; 80 | width: 100%; 81 | border-top: solid $primary; 82 | padding-top: 1; 83 | } 84 | } 85 | """ 86 | 87 | BINDINGS = [("escape", "close")] 88 | 89 | def __init__(self, help_for: Screen[Any]) -> None: 90 | """Initialise the help screen. 91 | 92 | Args: 93 | help_for: The screen to show the help for. 94 | """ 95 | super().__init__() 96 | self._context_help = "\n\n".join( 97 | cleandoc(getattr(helper, "CONTEXT_HELP")) 98 | for helper in reversed( 99 | ( 100 | help_for.focused if help_for.focused is not None else help_for 101 | ).ancestors_with_self 102 | ) 103 | if hasattr(helper, "CONTEXT_HELP") 104 | ).strip() 105 | 106 | def compose(self) -> ComposeResult: 107 | """Compose the layout of the help screen.""" 108 | with Vertical() as help_screen: 109 | help_screen.border_title = "Help" 110 | with VerticalScroll(): 111 | yield Markdown( 112 | HELP.replace("[EOL]", " ").format(context_help=self._context_help) 113 | ) 114 | with Center(): 115 | yield Button("Okay [dim]\\[Esc]") 116 | 117 | @on(Button.Pressed) 118 | def action_close(self) -> None: 119 | """Close the help screen.""" 120 | self.dismiss(None) 121 | 122 | @on(Markdown.LinkClicked) 123 | def visit(self, event: Markdown.LinkClicked) -> None: 124 | """Visit any link clicked in the help.""" 125 | open_url(event.href) 126 | 127 | 128 | ### help.py ends here 129 | -------------------------------------------------------------------------------- /oshit/app/screens/links.py: -------------------------------------------------------------------------------- 1 | """Provides a dialog for viewing and visiting links.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from webbrowser import open as open_url 6 | 7 | ############################################################################## 8 | # Textual imports. 9 | from textual import on 10 | from textual.app import ComposeResult 11 | from textual.containers import Horizontal, Vertical 12 | from textual.screen import ModalScreen 13 | from textual.widgets import Button, OptionList 14 | 15 | 16 | ############################################################################## 17 | class Links(ModalScreen[None]): 18 | """Modal dialog for showing and visiting links.""" 19 | 20 | DEFAULT_CSS = """ 21 | Links { 22 | align: center middle; 23 | 24 | Vertical { 25 | padding: 1 2; 26 | height: auto; 27 | width: auto; 28 | max-width: 50%; 29 | background: $surface; 30 | border: panel $primary; 31 | border-title-color: $accent; 32 | } 33 | 34 | Horizontal { 35 | height: auto; 36 | width: 100%; 37 | align-horizontal: right; 38 | border-top: solid $primary; 39 | padding-top: 1; 40 | 41 | Button { 42 | margin-left: 1; 43 | } 44 | } 45 | } 46 | """ 47 | 48 | BINDINGS = [("escape", "close")] 49 | 50 | def __init__(self, links: list[str]) -> None: 51 | """Initialise the links dialog. 52 | 53 | Args: 54 | links: The links to show the user. 55 | """ 56 | super().__init__() 57 | self._links = links 58 | 59 | def compose(self) -> ComposeResult: 60 | """Compose the conent of the dialog.""" 61 | with Vertical() as dialog: 62 | dialog.border_title = "Available links" 63 | yield OptionList(*self._links) 64 | with Horizontal(): 65 | yield Button("Okay [dim]\\[Esc][/]", id="close") 66 | 67 | @on(OptionList.OptionSelected) 68 | def visit(self, event: OptionList.OptionSelected) -> None: 69 | """Visit the selected link.""" 70 | open_url(self._links[event.option_index]) 71 | 72 | @on(Button.Pressed, "#close") 73 | def action_close(self) -> None: 74 | """Close the dialog screen.""" 75 | self.dismiss() 76 | 77 | 78 | ### links.py ends here 79 | -------------------------------------------------------------------------------- /oshit/app/screens/main.py: -------------------------------------------------------------------------------- 1 | """The main screen for the application.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from functools import partial 6 | 7 | ############################################################################## 8 | # Textual imports. 9 | from textual import on, work 10 | from textual.app import ComposeResult 11 | from textual.binding import Binding 12 | from textual.css.query import NoMatches 13 | from textual.screen import Screen 14 | from textual.timer import Timer 15 | from textual.widgets import Footer, Header 16 | 17 | ############################################################################## 18 | # Local imports. 19 | from ... import __version__ 20 | from ...hn import HN 21 | from ...hn.item.article import Article 22 | from ..commands import ShowComments, ShowUser 23 | from ..data.config import load_configuration 24 | from ..widgets import HackerNews, Items 25 | from .comments import Comments 26 | from .config import ConfigurationDialog 27 | from .help import Help 28 | from .search import Search 29 | from .user import UserDetails 30 | 31 | 32 | ############################################################################## 33 | class Main(Screen[None]): 34 | """The main screen of the application.""" 35 | 36 | CONTEXT_HELP = """ 37 | ## Application keys 38 | 39 | | Key | Description | 40 | | - | - | 41 | | F1 | This help screen. | 42 | | F2 | Toggle compact/relaxed display. | 43 | | F3 | Toggle dark/light mode. | 44 | | F4 | Toggle numbers against items. | 45 | | F5 | Toggle showing age of data. | 46 | | F12 | Quit the application. | 47 | | / | Search* and open tab with results. | 48 | | t | View the top stories. | 49 | | n | View the new stories. | 50 | | b | View the best stories. | 51 | | a | View the AskHN stories. | 52 | | s | View the ShowHN stories. | 53 | | j | View the jobs. | 54 | 55 | \\* Note that the search only looks at already-downloaded items. 56 | """ 57 | 58 | CSS = """ 59 | TabbedContent, LoadingIndicator { 60 | background: $panel; 61 | } 62 | """ 63 | 64 | TITLE = f"Orange Site Hit v{__version__}" 65 | 66 | BINDINGS = [ 67 | Binding("f1", "help", "Help"), 68 | Binding("f2", "compact", "Compact/Relaxed"), 69 | Binding("f3", "app.toggle_dark"), 70 | Binding("f4", "numbered"), 71 | Binding("f5", "show_age"), 72 | Binding("f11", "config", "Configure"), 73 | Binding("f12", "app.quit", "Quit"), 74 | Binding("t", "go('top')"), 75 | Binding("n", "go('new')"), 76 | Binding("b", "go('best')"), 77 | Binding("a", "go('ask')"), 78 | Binding("s", "go('show')"), 79 | Binding("j", "go('jobs')"), 80 | Binding("r", "go('search')"), 81 | Binding("/", "local_search"), 82 | ] 83 | 84 | def __init__(self) -> None: 85 | """Initialise the screen.""" 86 | super().__init__() 87 | config = load_configuration() 88 | self._hn = HN( 89 | max_concurrency=config.maximum_concurrency, 90 | timeout=config.connection_timeout, 91 | ) 92 | """The HackerNews client object.""" 93 | self._title_interval: Timer | None = None 94 | 95 | def compose(self) -> ComposeResult: 96 | """Compose the main screen's layout.""" 97 | yield Header() 98 | with HackerNews(): 99 | config = load_configuration() 100 | yield Items("top", "t", partial(self._hn.top_stories, config.maximum_top)) 101 | yield Items("new", "n", partial(self._hn.new_stories, config.maximum_new)) 102 | yield Items( 103 | "best", "b", partial(self._hn.best_stories, config.maximum_best) 104 | ) 105 | yield Items( 106 | "ask", "a", partial(self._hn.latest_ask_stories, config.maximum_ask) 107 | ) 108 | yield Items( 109 | "show", "s", partial(self._hn.latest_show_stories, config.maximum_show) 110 | ) 111 | yield Items( 112 | "jobs", "j", partial(self._hn.latest_job_stories, config.maximum_jobs) 113 | ) 114 | yield Footer() 115 | 116 | @on(HackerNews.TabActivated) 117 | @on(Items.Loading) 118 | @on(Items.Loaded) 119 | def _refresh_subtitle(self) -> None: 120 | """Refresh the subtitle of the screen.""" 121 | try: 122 | self.sub_title = self.query_one(HackerNews).description 123 | except NoMatches: 124 | # There's a rare situation, it seems, where we can be on the way 125 | # out, the DOM is being pulled down, and we get a message being 126 | # processed too late that causes this method to fire. The result 127 | # is that the `Header` widget will be asked to update something 128 | # that doesn't exist any more. This guards against that. 129 | pass 130 | 131 | def _set_title_refresh(self, refresh: bool) -> None: 132 | """Set the state of the title refresh interval. 133 | 134 | Args: 135 | refresh: The state to set it to. 136 | """ 137 | if refresh: 138 | if self._title_interval is None: 139 | self._title_interval = self.set_interval(0.95, self._refresh_subtitle) 140 | else: 141 | if self._title_interval is not None: 142 | self._title_interval.stop() 143 | self._title_interval = None 144 | self._refresh_subtitle() 145 | 146 | def on_mount(self) -> None: 147 | """Configure things once the DOM is ready.""" 148 | self._set_title_refresh(load_configuration().show_data_age) 149 | 150 | def action_help(self) -> None: 151 | """Show the help screen.""" 152 | self.app.push_screen(Help(self)) 153 | 154 | def action_go(self, items: str) -> None: 155 | """Go to the given list of items. 156 | 157 | Args: 158 | items: The name of the list of items to go to. 159 | """ 160 | before = self.query_one(HackerNews).active 161 | try: 162 | self.query_one(HackerNews).active = items 163 | except ValueError: 164 | self.query_one(HackerNews).active = before 165 | return 166 | self.query_one(HackerNews).focus_active_pane() 167 | 168 | def action_compact(self) -> None: 169 | """Toggle the compact display.""" 170 | news = self.query_one(HackerNews) 171 | news.compact = not news.compact 172 | 173 | def action_numbered(self) -> None: 174 | """Toggle the numbers display.""" 175 | news = self.query_one(HackerNews) 176 | news.numbered = not news.numbered 177 | 178 | def action_show_age(self) -> None: 179 | """Toggle the display of the age of the data in the lists.""" 180 | news = self.query_one(HackerNews) 181 | news.show_age = not news.show_age 182 | self._set_title_refresh(news.show_age) 183 | 184 | async def _search(self, search_text: str) -> list[Article]: 185 | hits: dict[int, Article] = {} 186 | for item_list in self.query(Items).results(): 187 | for item in item_list.items: 188 | if search_text in item: 189 | hits[item.item_id] = item 190 | return list(hits.values()) 191 | 192 | @work 193 | async def action_local_search(self) -> None: 194 | """Perform a local search.""" 195 | if search_text := await self.app.push_screen_wait(Search()): 196 | await self.query_one(HackerNews).remove_pane("search") 197 | await self.query_one(HackerNews).add_pane( 198 | Items("search", "r", partial(self._search, search_text)) 199 | ) 200 | self.query_one(HackerNews).active = "search" 201 | 202 | def action_config(self) -> None: 203 | """Show the configuration dialog.""" 204 | self.app.push_screen(ConfigurationDialog()) 205 | 206 | @on(ShowUser) 207 | def show_user(self, event: ShowUser) -> None: 208 | """Handle a request to show the details of a user.""" 209 | self.app.push_screen(UserDetails(self._hn, event.user)) 210 | 211 | @on(ShowComments) 212 | def show_comments(self, event: ShowComments) -> None: 213 | """Handle a request to show the comments for an article.""" 214 | self.app.push_screen(Comments(self._hn, event.article)) 215 | 216 | 217 | ### main.py ends here 218 | -------------------------------------------------------------------------------- /oshit/app/screens/search.py: -------------------------------------------------------------------------------- 1 | """Provides a dialog for prompting for a search string.""" 2 | 3 | ############################################################################## 4 | # Backward compatibility 5 | from __future__ import annotations 6 | 7 | ############################################################################## 8 | # Textual imports. 9 | from textual import on 10 | from textual.app import ComposeResult 11 | from textual.screen import ModalScreen 12 | from textual.widgets import Input 13 | 14 | 15 | ############################################################################## 16 | class Search(ModalScreen[str | None]): 17 | """A modal dialog for getting a string to search for.""" 18 | 19 | DEFAULT_CSS = """ 20 | Search { 21 | align: center middle; 22 | } 23 | 24 | Search Input, Search Input:focus { 25 | border: round $accent; 26 | width: 60%; 27 | padding: 1; 28 | height: auto; 29 | } 30 | """ 31 | 32 | BINDINGS = [("escape", "escape")] 33 | 34 | def compose(self) -> ComposeResult: 35 | """Compose the content of the screen.""" 36 | yield Input(placeholder="Enter text to look for in locally-loaded items") 37 | 38 | @on(Input.Submitted) 39 | def search(self) -> None: 40 | """Perform the search.""" 41 | self.dismiss(self.query_one(Input).value.strip()) 42 | 43 | def action_escape(self) -> None: 44 | """Escape out without searching.""" 45 | self.dismiss(None) 46 | 47 | 48 | ### search.py ends here 49 | -------------------------------------------------------------------------------- /oshit/app/screens/user.py: -------------------------------------------------------------------------------- 1 | """Provides a modal screen for showing the details of a user.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from webbrowser import open as open_url 6 | 7 | ############################################################################## 8 | # Humanize imports. 9 | from humanize import intcomma, naturaltime 10 | 11 | ############################################################################## 12 | # Textual imports. 13 | from textual import on, work 14 | from textual.app import ComposeResult 15 | from textual.containers import Horizontal, Vertical, VerticalScroll 16 | from textual.screen import ModalScreen 17 | from textual.widgets import Button, Label 18 | 19 | ############################################################################## 20 | # Local imports. 21 | from ...hn import HN 22 | from ...hn.user import User 23 | 24 | 25 | ############################################################################## 26 | class Title(Label): 27 | """Widget for showing the title of some data.""" 28 | 29 | DEFAULT_CSS = """ 30 | Title { 31 | color: $accent; 32 | } 33 | """ 34 | 35 | 36 | ############################################################################## 37 | class Data(Label): 38 | """Widget for showing some data.""" 39 | 40 | DEFAULT_CSS = """ 41 | Data { 42 | margin-bottom: 1; 43 | } 44 | """ 45 | 46 | 47 | ############################################################################## 48 | class UserDetails(ModalScreen[None]): 49 | """Modal dialog for showing the details of a user.""" 50 | 51 | DEFAULT_CSS = """ 52 | UserDetails { 53 | align: center middle; 54 | 55 | Vertical { 56 | padding: 1 2; 57 | height: auto; 58 | width: auto; 59 | min-width: 40%; 60 | max-width: 80vw; 61 | background: $surface; 62 | border: panel $primary; 63 | border-title-color: $accent; 64 | } 65 | 66 | VerticalScroll { 67 | max-height: 20; 68 | height: auto; 69 | width: auto; 70 | } 71 | 72 | Data { 73 | max-width: 70vw; 74 | } 75 | 76 | Horizontal { 77 | height: auto; 78 | width: 100%; 79 | align-horizontal: right; 80 | border-top: solid $primary; 81 | padding-top: 1; 82 | } 83 | 84 | Button { 85 | margin-left: 1; 86 | } 87 | 88 | .hidden { 89 | display: none; 90 | } 91 | } 92 | """ 93 | 94 | BINDINGS = [("space", "visit"), ("escape", "close")] 95 | 96 | AUTO_FOCUS = "#close" 97 | 98 | def __init__(self, client: HN, user_id: str) -> None: 99 | """Initialise the user details dialog. 100 | 101 | Args: 102 | client: The HackerNews client object. 103 | user_id: The ID of the user to display. 104 | """ 105 | super().__init__() 106 | self._hn = client 107 | self._user = User(user_id) 108 | self._user_id = user_id 109 | 110 | def compose(self) -> ComposeResult: 111 | """Compose the dialog.""" 112 | with Vertical() as dialog: 113 | dialog.border_title = "User details" 114 | yield Title("User ID:") 115 | yield Data(self._user_id, id="user-id") 116 | yield Title("About:", classes="about hidden") 117 | with VerticalScroll(classes="about hidden"): 118 | yield Data(id="about", markup=False) 119 | yield Title("Karma:") 120 | yield Data(id="karma") 121 | yield Title("Account created:") 122 | yield Data(id="created") 123 | yield Title("Submission count:") 124 | yield Data(id="submissions") 125 | with Horizontal(): 126 | yield Button("Visit [dim]\\[Space][/]", id="visit") 127 | yield Button("Okay [dim]\\[Esc][/]", id="close") 128 | 129 | def _set(self, field: str, value: str) -> None: 130 | """Set the value of a field on the form. 131 | 132 | Args: 133 | field: The field to set. 134 | value: The value to set the field to. 135 | """ 136 | self.query_one(f"#{field}", Data).update(value) 137 | 138 | @work 139 | async def _load_user(self) -> None: 140 | """Load up the details for the user.""" 141 | self.query_one(Vertical).border_subtitle = "Loading..." 142 | try: 143 | self._user = await self._hn.user(self._user_id) 144 | except HN.RequestError as error: 145 | self.app.bell() 146 | self.notify( 147 | str(error), 148 | title=f"Error loading user data for '{self._user_id}'", 149 | timeout=8, 150 | severity="error", 151 | ) 152 | self._set("user-id", f"{self._user_id} [red italic](API error)[/]") 153 | except HN.NoSuchUser: 154 | self.notify( 155 | "No such user", 156 | title=f"There is no such user as '{self._user_id}'", 157 | severity="error", 158 | timeout=8, 159 | ) 160 | self._set("user-id", f"{self._user_id} [red italic](Unknown User)[/]") 161 | else: 162 | self._set("about", self._user.about) 163 | self._set("karma", intcomma(self._user.karma)) 164 | self._set( 165 | "created", 166 | f"{naturaltime(self._user.created)} [dim]({self._user.created})[/]", 167 | ) 168 | self._set("submissions", f"{intcomma(len(self._user.submitted))}") 169 | self.query(".about").set_class(not self._user.has_about, "hidden") 170 | finally: 171 | self.query_one(Vertical).border_subtitle = "" 172 | 173 | def on_mount(self) -> None: 174 | """Configure the dialog once the DOM is ready.""" 175 | self._load_user() 176 | 177 | @on(Button.Pressed, "#close") 178 | def action_close(self) -> None: 179 | """Close the dialog screen.""" 180 | self.dismiss(None) 181 | 182 | @on(Button.Pressed, "#visit") 183 | def action_visit(self) -> None: 184 | """Visit the page for the user.""" 185 | open_url(self._user.url) 186 | 187 | 188 | ### user.py ends here 189 | -------------------------------------------------------------------------------- /oshit/app/widgets/__init__.py: -------------------------------------------------------------------------------- 1 | """Custom widgets for the application.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .article_text import ArticleText 6 | from .comment_card import CommentCard, CommentCardWithReplies 7 | from .hacker_news import HackerNews 8 | from .items import Items 9 | 10 | ############################################################################## 11 | # Exports. 12 | __all__ = [ 13 | "ArticleText", 14 | "CommentCard", 15 | "CommentCardWithReplies", 16 | "HackerNews", 17 | "Items", 18 | ] 19 | 20 | ### __init__.py ends here 21 | -------------------------------------------------------------------------------- /oshit/app/widgets/article_text.py: -------------------------------------------------------------------------------- 1 | """A widget for showing the text of an article.""" 2 | 3 | ############################################################################## 4 | # Textual imports. 5 | from textual.widgets import Label 6 | 7 | ############################################################################## 8 | # Local imports. 9 | from ...hn.item import Article 10 | 11 | 12 | ############################################################################## 13 | class ArticleText(Label, can_focus=True): 14 | """A widget for showing the text of an article.""" 15 | 16 | DEFAULT_CSS = """ 17 | ArticleText { 18 | width: 1fr; 19 | } 20 | """ 21 | 22 | def __init__( 23 | self, 24 | article: Article, 25 | *, 26 | id: str | None = None, # pylint:disable=redefined-builtin 27 | classes: str | None = None, 28 | disabled: bool = False 29 | ) -> None: 30 | """Initialise the widget. 31 | 32 | Args: 33 | article: The article whose text should be displayed. 34 | id: The ID of the widget description in the DOM. 35 | classes: The CSS classes of the widget description. 36 | disabled: Whether the widget description is disabled or not. 37 | """ 38 | super().__init__( 39 | article.text, markup=False, id=id, classes=classes, disabled=disabled 40 | ) 41 | 42 | 43 | ### article_text.py ends here 44 | -------------------------------------------------------------------------------- /oshit/app/widgets/comment_card.py: -------------------------------------------------------------------------------- 1 | """Provides a card for displaying a HackerNews comment.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import dataclass 6 | from webbrowser import open as open_url 7 | 8 | ############################################################################## 9 | # Humanize imports. 10 | from humanize import naturaltime 11 | 12 | ############################################################################## 13 | # Textual imports. 14 | from textual import on 15 | from textual.app import ComposeResult 16 | from textual.binding import Binding 17 | from textual.containers import Vertical 18 | from textual.css.query import NoMatches 19 | from textual.events import Click 20 | from textual.message import Message 21 | from textual.widget import Widget 22 | from textual.widgets import Label 23 | 24 | ############################################################################## 25 | # Local imports. 26 | from ...hn import HN 27 | from ...hn.item import Article, Comment 28 | from ..screens.links import Links 29 | from ..screens.user import UserDetails 30 | 31 | 32 | ############################################################################## 33 | class CommentCard(Vertical, can_focus=True): 34 | """Widget that displays a comment.""" 35 | 36 | DEFAULT_CSS = """ 37 | $card-border: heavy; 38 | 39 | CommentCard { 40 | 41 | border-left: $card-border $primary; 42 | border-bottom: $card-border $primary; 43 | padding: 1 0 1 1; 44 | margin: 0 1 1 1; 45 | height: auto; 46 | color: $text 70%; 47 | 48 | CommentCard { 49 | padding: 1 0 1 1; 50 | margin: 0 0 1 0; 51 | } 52 | 53 | &:focus-within { 54 | border-left: $card-border $accent 50%; 55 | border-bottom: $card-border $accent 50%; 56 | background: $boost 50%; 57 | color: $text 80%; 58 | } 59 | 60 | &:focus { 61 | border-left: $card-border $accent; 62 | border-bottom: $card-border $accent; 63 | background: $boost; 64 | color: $text; 65 | } 66 | 67 | &.deleted { 68 | color: $error 50%; 69 | text-style: italic; 70 | border: dashed $error 20%; 71 | padding: 0; 72 | 73 | Label { 74 | text-align: center; 75 | } 76 | } 77 | 78 | Label { 79 | width: 1fr; 80 | padding-right: 1; 81 | } 82 | 83 | /* These two should be combined. https://github.com/Textualize/textual/issues/3969 */ 84 | &.flagged Label { 85 | color: $text-disabled; 86 | text-style: italic; 87 | } 88 | &.dead Label { 89 | color: $text-disabled; 90 | text-style: italic; 91 | } 92 | 93 | .byline { 94 | margin-top: 1; 95 | text-align: right; 96 | color: $text-muted; 97 | text-style: italic; 98 | } 99 | } 100 | """ 101 | 102 | BINDINGS = [ 103 | Binding("enter", "gndn"), 104 | Binding("l", "links", "Links"), 105 | Binding("s", "next(1)", "Next Sibling"), 106 | Binding("S", "next(-1)", "Prev Sibling", key_display="Sh+S"), 107 | Binding("p", "goto_parent", "Parent"), 108 | Binding("r", "goto_root", "Go Root"), 109 | Binding("u", "view_user", "View User"), 110 | Binding("v", "view_online", "View on HN"), 111 | ] 112 | 113 | def __init__( 114 | self, client: HN, parent_item: Article | Comment, comment: Comment 115 | ) -> None: 116 | """Initialise the comment card. 117 | 118 | Args: 119 | parent_item: The parent item of the comment. 120 | client: The HackerNews client object. 121 | comment: The comment display. 122 | """ 123 | super().__init__(id=f"comment-{comment.item_id}") 124 | self.border_subtitle = f"#{comment.item_id}" 125 | self._hn = client 126 | """The HackerNews client object.""" 127 | self.parent_item = parent_item 128 | """The item that is the parent of this comment.""" 129 | self.comment = comment 130 | """The comment to display.""" 131 | self.set_class(self.comment.deleted, "deleted") 132 | self.set_class(self.comment.flagged, "flagged") 133 | self.set_class(self.comment.dead, "dead") 134 | 135 | def compose(self) -> ComposeResult: 136 | """Compose the content of the comment card.""" 137 | if self.comment.deleted: 138 | self.can_focus = False 139 | yield Label("Deleted") 140 | return 141 | yield Label(self.comment.text, markup=False) 142 | yield Label( 143 | f"{self.comment.by}, {naturaltime(self.comment.time)}", classes="byline" 144 | ) 145 | 146 | def action_links(self) -> None: 147 | """Show the links in the comment to the user.""" 148 | links = self.comment.urls 149 | if not links: 150 | self.notify("No links found in the comment") 151 | elif len(links) == 1: 152 | open_url(links[0]) 153 | else: 154 | self.app.push_screen(Links(self.comment.urls)) 155 | 156 | def action_view_online(self) -> None: 157 | """View the comment on HackerNews.""" 158 | open_url(self.comment.orange_site_url) 159 | 160 | def action_view_user(self) -> None: 161 | """View the details of the user who wrote the comment.""" 162 | self.app.push_screen(UserDetails(self._hn, self.comment.by)) 163 | 164 | def action_goto_parent(self) -> None: 165 | """Go to the parent of the current comment.""" 166 | if isinstance(self.parent_item, Comment): 167 | self.screen.query_one(f"#comment-{self.comment.parent}").focus() 168 | else: 169 | self.notify("Already at the top level", severity="warning") 170 | 171 | def action_next(self, direction: int) -> None: 172 | """Move amongst sibling comments. 173 | 174 | Args: 175 | direction: The direction to move in. 176 | """ 177 | if self.parent is None: 178 | return 179 | children = [ 180 | child 181 | for child in self.parent.children 182 | if isinstance(child, CommentCard) and child.can_focus 183 | ] 184 | try: 185 | current = children.index(self) 186 | except ValueError: 187 | return 188 | candidate = current + direction 189 | if -1 < candidate < len(children): 190 | children[candidate].focus() 191 | 192 | def action_goto_root(self) -> None: 193 | """Navigate up to the root comment.""" 194 | candidate = self 195 | while True: 196 | try: 197 | candidate = self.screen.query_one( 198 | f"#comment-{candidate.comment.parent}", CommentCard 199 | ) 200 | except NoMatches: 201 | if candidate == self: 202 | self.notify("Already at the top level", severity="warning") 203 | else: 204 | candidate.focus() 205 | return 206 | 207 | def action_gndn(self) -> None: 208 | """Swallow up enter. 209 | 210 | This stops any press of enter bubbling up to any possible comment 211 | that does have replies. 212 | """ 213 | 214 | def on_click(self, event: Click) -> None: 215 | """Ensure we get focus when we're clicked within anywhere.""" 216 | self.focus() 217 | event.stop() 218 | 219 | 220 | ############################################################################## 221 | class RepliesLabel(Label): 222 | """A label for showing the replies. 223 | 224 | Mostly here to work around: 225 | https://github.com/Textualize/textual/issues/3690 226 | """ 227 | 228 | class LoadRequested(Message): 229 | """A message to say that the user requested a load.""" 230 | 231 | def action_load_replies(self) -> None: 232 | """Pass up the request to load.""" 233 | self.post_message(self.LoadRequested()) 234 | 235 | 236 | ############################################################################## 237 | class CommentCardWithReplies(CommentCard): 238 | """A comment card that also has replies.""" 239 | 240 | BINDINGS = [ 241 | ("enter", "load_replies", "Replies"), 242 | ] 243 | 244 | DEFAULT_CSS = """ 245 | CommentCardWithReplies { 246 | 247 | &> .replies { 248 | margin-top: 0; 249 | link-color: $text-muted; 250 | link-style: italic; 251 | } 252 | 253 | &> #replies { 254 | height: auto; 255 | margin-top: 1; 256 | display: none; 257 | 258 | &.loaded { 259 | display: block; 260 | } 261 | } 262 | } 263 | """ 264 | 265 | @dataclass 266 | class LoadReplies(Message): 267 | """Message to request that replies are loaded.""" 268 | 269 | load_into: Widget 270 | """The card to load the comments into.""" 271 | 272 | comment: Comment 273 | """The comment to load the replies for.""" 274 | 275 | def __init__( 276 | self, client: HN, parent_item: Article | Comment, comment: Comment 277 | ) -> None: 278 | """Initialise the comment card. 279 | 280 | Args: 281 | parent_item: The parent item of the comment. 282 | client: The HackerNews client object. 283 | comment: The comment display. 284 | """ 285 | super().__init__(client, parent_item, comment) 286 | self._replies_loaded = False 287 | """Have replies been loaded?""" 288 | 289 | def compose(self) -> ComposeResult: 290 | """Compose the content of the comment card.""" 291 | yield from super().compose() 292 | count = len(self.comment.kids) 293 | yield RepliesLabel( 294 | f"[@click=load_replies]{count} {'reply' if count == 1 else 'replies'}[/]", 295 | classes="byline replies", 296 | ) 297 | yield Vertical(id="replies") 298 | 299 | @on(RepliesLabel.LoadRequested) 300 | def action_load_replies( 301 | self, event: RepliesLabel.LoadRequested | None = None 302 | ) -> None: 303 | """Load the replies for this comment.""" 304 | if event is not None: 305 | event.stop() 306 | if self._replies_loaded: 307 | self.get_child_by_id("replies").toggle_class("loaded") 308 | else: 309 | self.post_message( 310 | self.LoadReplies(self.query_one("#replies"), self.comment) 311 | ) 312 | self._replies_loaded = True 313 | self.query_one("#replies").set_class(True, "loaded") 314 | 315 | 316 | ### comment_card.py ends here 317 | -------------------------------------------------------------------------------- /oshit/app/widgets/hacker_news.py: -------------------------------------------------------------------------------- 1 | """Widget that displays the HackerNews content.""" 2 | 3 | ############################################################################## 4 | # Textual imports. 5 | from textual import on 6 | from textual.await_complete import AwaitComplete 7 | from textual.reactive import var 8 | from textual.widgets import TabbedContent, TabPane, Tabs 9 | 10 | ############################################################################## 11 | # Local imports. 12 | from ...hn.item import Article 13 | from ..data import load_configuration, save_configuration 14 | from .items import Items 15 | 16 | 17 | ############################################################################## 18 | class HackerNews(TabbedContent): 19 | """The HackerNews content.""" 20 | 21 | BINDINGS = [ 22 | ("escape", "escape"), 23 | ("down, enter", "pane"), 24 | ("left", "previous"), 25 | ("right", "next"), 26 | ] 27 | 28 | compact: var[bool] = var(True) 29 | """Should we use a compact or relaxed display?""" 30 | 31 | numbered: var[bool] = var(False) 32 | """Should we show numbers against the items in the lists?""" 33 | 34 | show_age: var[bool] = var(True) 35 | """Should we show the age of the data in the lists?""" 36 | 37 | background_load: var[bool] = var(True) 38 | """Should the tabs try and load in the background. 39 | 40 | If set to `True`, once a tab has finished loading, the next unloaded tab 41 | will be asked to load, and so on, until all tabs have loaded their 42 | stories. This means that by the time the user has finished with their 43 | first tab, it's likely all the others will have loaded; thus making the 44 | rest of the reading experience way faster. 45 | """ 46 | 47 | def on_mount(self) -> None: 48 | """Configure the widget once the DOM is ready.""" 49 | config = load_configuration() 50 | self.compact = config.compact_mode 51 | self.numbered = config.item_numbers 52 | self.show_age = config.show_data_age 53 | self.background_load = config.background_load_tabs 54 | 55 | def add_pane( 56 | self, 57 | pane: TabPane, 58 | *, 59 | before: TabPane | str | None = None, 60 | after: TabPane | str | None = None, 61 | ) -> AwaitComplete: 62 | try: 63 | return super().add_pane(pane, before=before, after=after) 64 | finally: 65 | if isinstance(pane, Items): 66 | pane.compact = self.compact 67 | pane.numbered = self.numbered 68 | pane.show_age = False 69 | 70 | @property 71 | def active_items(self) -> Items[Article]: 72 | """The active items.""" 73 | assert isinstance(items := self.get_pane(self.active), Items) 74 | return items 75 | 76 | def focus_active_pane(self) -> None: 77 | """Give focus to the active pane.""" 78 | self.active_items.steal_focus() 79 | 80 | def action_escape(self) -> None: 81 | """Handle escape being pressed.""" 82 | if self.screen.focused == (tabs := self.query_one(Tabs)): 83 | self.app.exit() 84 | else: 85 | tabs.focus() 86 | 87 | def action_pane(self) -> None: 88 | """Focus on the current pane.""" 89 | if self.screen.focused == self.query_one(Tabs): 90 | self.focus_active_pane() 91 | 92 | def action_previous(self) -> None: 93 | """Move to the previous pane of items.""" 94 | if self.screen.focused != self.query_one(Tabs): 95 | self.query_one(Tabs).action_previous_tab() 96 | 97 | def action_next(self) -> None: 98 | """Move to the next pane of items.""" 99 | if self.screen.focused != self.query_one(Tabs): 100 | self.query_one(Tabs).action_next_tab() 101 | 102 | @on(TabbedContent.TabActivated) 103 | @on(Items.Loading) 104 | def _settle_focus(self) -> None: 105 | """Settle the focus in the best place possible when a tab is activated.""" 106 | if self.active_items.loaded: 107 | self.active_items.steal_focus() 108 | else: 109 | self.query_one(Tabs).focus() 110 | 111 | @on(Items.Loaded) 112 | def _load_next_unloaded_tab(self) -> None: 113 | """When a tab has finished loading, start a background load of another tab.""" 114 | if self.background_load: 115 | for tab in self.query(Items).results(): 116 | if tab.maybe_load(): 117 | return 118 | 119 | @property 120 | def description(self) -> str: 121 | """The description of the current display.""" 122 | return self.active_items.description 123 | 124 | def _watch_compact(self) -> None: 125 | """React to the compact value being changed.""" 126 | for pane in self.query(Items).results(): 127 | pane.compact = self.compact 128 | configuration = load_configuration() 129 | configuration.compact_mode = self.compact 130 | save_configuration(configuration) 131 | 132 | def _watch_numbered(self) -> None: 133 | """React to the numbers setting value being changed.""" 134 | for pane in self.query(Items).results(): 135 | pane.numbered = self.numbered 136 | configuration = load_configuration() 137 | configuration.item_numbers = self.numbered 138 | save_configuration(configuration) 139 | 140 | def _watch_show_age(self) -> None: 141 | """React to the age showing setting being changed.""" 142 | for pane in self.query(Items).results(): 143 | pane.show_age = self.show_age 144 | configuration = load_configuration() 145 | configuration.show_data_age = self.show_age 146 | save_configuration(configuration) 147 | 148 | 149 | ### hacker_news.py ends here 150 | -------------------------------------------------------------------------------- /oshit/app/widgets/items.py: -------------------------------------------------------------------------------- 1 | """Provides a tab pane for showing items from HackerNews.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from datetime import datetime 6 | from typing import Awaitable, Callable, Generic, TypeVar, cast 7 | from webbrowser import open as open_url 8 | 9 | ############################################################################## 10 | # Humanize imports. 11 | from humanize import intcomma, naturaltime 12 | 13 | ############################################################################## 14 | # Rich imports. 15 | from rich.console import Group 16 | from rich.table import Table 17 | 18 | ############################################################################## 19 | # Textual imports. 20 | from textual import on, work 21 | from textual.app import ComposeResult 22 | from textual.binding import Binding 23 | from textual.message import Message 24 | from textual.reactive import var 25 | from textual.widgets import OptionList, TabPane 26 | from textual.widgets.option_list import Option 27 | 28 | ############################################################################## 29 | # Local imports. 30 | from ...hn import HN 31 | from ...hn.item import Article, Job, Link 32 | from ..commands import ShowComments, ShowUser 33 | 34 | ############################################################################## 35 | ArticleType = TypeVar("ArticleType", bound=Article) 36 | """Generic type for the items pane.""" 37 | 38 | 39 | ############################################################################## 40 | class HackerNewsArticle(Option): 41 | """An article from HackerNews.""" 42 | 43 | def __init__( 44 | self, article: Article, compact: bool, number: int | None = None 45 | ) -> None: 46 | """Initialise the hacker news article. 47 | 48 | Args: 49 | article: The article to show. 50 | compact: Should we use a compact or relaxed display? 51 | """ 52 | self.article = article 53 | """The article being shown.""" 54 | self._compact = compact 55 | """Should we show a compact form?""" 56 | self._number = number 57 | """The number to show for this article, if at all.""" 58 | super().__init__(self.prompt, id=str(article.item_id)) 59 | 60 | @property 61 | def prompt(self) -> Group: 62 | """The prompt for the article.""" 63 | prefix = ( 64 | f"[dim italic{' green' if isinstance(self.article, Job) else ''}]" 65 | f"{self.article.__class__.__name__[0]}" 66 | "[/]" 67 | ) 68 | domain = "" 69 | if isinstance(self.article, Link): 70 | if domain := self.article.domain: 71 | domain = f" [dim italic]({domain})[/]" 72 | info = Table.grid(expand=True) 73 | info.add_column(no_wrap=True, ratio=1) 74 | info.add_column(no_wrap=True, justify="right", width=6) 75 | info.add_row( 76 | f"{' ' if self._compact else prefix} [dim italic]{intcomma(self.article.score)} " 77 | f"point{'' if self.article.score == 1 else 's'} " 78 | f"by {self.article.by} {naturaltime(self.article.time)}, " 79 | f"{intcomma(self.article.descendants)} comment{'' if self.article.descendants == 1 else 's'}[/]", 80 | "" if self._number is None else f" [dim italic]#{self._number}[/]", 81 | ) 82 | return Group( 83 | f"{prefix if self._compact else ' '} {self.article.title}{domain}", 84 | info, 85 | *([] if self._compact else [""]), 86 | ) 87 | 88 | 89 | ############################################################################## 90 | class ArticleList(OptionList): 91 | """Widget to show a list of articles.""" 92 | 93 | CONTEXT_HELP = """ 94 | ## Highlighted item keys 95 | 96 | | Key | Description | 97 | | - | - | 98 | | Enter | Open the URL for the item in your browser. | 99 | | c | View the comments for the item. | 100 | """ 101 | 102 | BINDINGS = [ 103 | Binding("c", "comments", "Comments"), 104 | Binding("v", "view_online", "View on HN"), 105 | Binding("u", "user", "View User"), 106 | ] 107 | 108 | def on_focus(self) -> None: 109 | """Ensure the first item is highlighted if nothing is until now.""" 110 | if self.highlighted is None and self.option_count: 111 | self.highlighted = 0 112 | 113 | def action_comments(self) -> None: 114 | """Visit the comments for the given""" 115 | if self.highlighted is not None: 116 | self.post_message( 117 | ShowComments( 118 | cast( 119 | HackerNewsArticle, self.get_option_at_index(self.highlighted) 120 | ).article 121 | ) 122 | ) 123 | 124 | def action_view_online(self) -> None: 125 | """View an article online.""" 126 | if self.highlighted is not None: 127 | open_url( 128 | cast( 129 | HackerNewsArticle, self.get_option_at_index(self.highlighted) 130 | ).article.orange_site_url 131 | ) 132 | 133 | def action_user(self) -> None: 134 | """Show the details of the user.""" 135 | if self.highlighted is not None: 136 | self.post_message( 137 | ShowUser( 138 | cast( 139 | HackerNewsArticle, self.get_option_at_index(self.highlighted) 140 | ).article.by 141 | ) 142 | ) 143 | 144 | 145 | ############################################################################## 146 | class Items(Generic[ArticleType], TabPane): 147 | """The pane that displays the top stories.""" 148 | 149 | CONTEXT_HELP = """ 150 | ## View keys 151 | 152 | | Key | Description | 153 | | - | - | 154 | | Ctrl+r | Reload. | 155 | """ 156 | 157 | DEFAULT_CSS = """ 158 | Items OptionList { 159 | height: 1fr; 160 | border: none; 161 | padding: 0; 162 | background: $panel; 163 | 164 | & > .option-list--option { 165 | padding: 0 1 0 0; 166 | } 167 | 168 | &:focus { 169 | border: none; 170 | background: $panel; 171 | } 172 | } 173 | """ 174 | 175 | BINDINGS = [ 176 | ("ctrl+r", "reload"), 177 | ] 178 | 179 | compact: var[bool] = var(True) 180 | """Should we use a compact display?""" 181 | 182 | numbered: var[bool] = var(False) 183 | """Should we show numbers against the items?""" 184 | 185 | show_age: var[bool] = var(True) 186 | """Should we show the age of the data?""" 187 | 188 | def __init__( 189 | self, title: str, key: str, source: Callable[[], Awaitable[list[ArticleType]]] 190 | ) -> None: 191 | """Initialise the pane. 192 | 193 | Args: 194 | title: The title for the pane. 195 | key: The key used to switch to this pane. 196 | source: The source of items for the pane. 197 | """ 198 | super().__init__(f"{title.capitalize()} [dim]\\[{key}][/]", id=title) 199 | self._description = title 200 | """The description of the pane.""" 201 | self._snarfed: datetime | None = None 202 | """The time when the data was snarfed.""" 203 | self._source = source 204 | """The source of items to show.""" 205 | self._items: list[ArticleType] = [] 206 | """The items to show.""" 207 | 208 | def compose(self) -> ComposeResult: 209 | """Compose the content of the pane.""" 210 | yield ArticleList() 211 | 212 | @property 213 | def description(self) -> str: 214 | """The description for this pane.""" 215 | suffix = "" 216 | if self._snarfed is None: 217 | suffix = " - Loading..." 218 | elif not self._items: 219 | suffix = " - Reloading..." 220 | elif self.show_age: 221 | suffix = f" - Updated {naturaltime(self._snarfed)}" 222 | return f"{self._description.capitalize()}{suffix}" 223 | 224 | def _redisplay(self) -> None: 225 | """Redisplay the items.""" 226 | display = self.query_one(OptionList) 227 | remember = display.highlighted 228 | display.clear_options().add_options( 229 | [ 230 | HackerNewsArticle(item, self.compact, number if self.numbered else None) 231 | for number, item in enumerate(self._items) 232 | if item.looks_valid 233 | ] 234 | ) 235 | display.highlighted = remember 236 | 237 | class Loading(Message): 238 | """Message sent when items start loading.""" 239 | 240 | class Loaded(Message): 241 | """Message sent when items are loaded.""" 242 | 243 | @work 244 | async def _load(self) -> None: 245 | """Load up the items and display them.""" 246 | display = self.query_one(OptionList) 247 | display.loading = True 248 | self.post_message(self.Loading()) 249 | try: 250 | self._items = await self._source() 251 | except HN.RequestError as error: 252 | self.app.bell() 253 | self.notify( 254 | str(error), 255 | title=f"Error loading items for '{self._description.capitalize()}'", 256 | timeout=8, 257 | severity="error", 258 | ) 259 | else: 260 | self._snarfed = datetime.now() 261 | self._redisplay() 262 | display.loading = False 263 | self.post_message(self.Loaded()) 264 | 265 | def maybe_load(self) -> bool: 266 | """Start loading the items if they're not loaded and aren't currently loading. 267 | 268 | Returns: 269 | `True` if it was decided to load the items, `False` if not. 270 | """ 271 | if not self.loaded and not self.query_one(OptionList).loading: 272 | self._load() 273 | return True 274 | return False 275 | 276 | @property 277 | def items(self) -> list[ArticleType]: 278 | """The items.""" 279 | return self._items 280 | 281 | @property 282 | def loaded(self) -> bool: 283 | """Has this tab loaded its items?""" 284 | return bool(self._items) 285 | 286 | def on_show(self) -> None: 287 | """Handle being shown.""" 288 | if not self.loaded: 289 | self._load() 290 | 291 | def steal_focus(self) -> None: 292 | """Steal focus for the item list within.""" 293 | self.query_one(ArticleList).focus() 294 | 295 | def _watch_compact(self) -> None: 296 | """React to the compact setting being changed.""" 297 | if self.loaded: 298 | self._redisplay() 299 | 300 | def _watch_numbered(self) -> None: 301 | """React to the numbered setting being changed.""" 302 | if self.loaded: 303 | self._redisplay() 304 | 305 | @on(OptionList.OptionSelected) 306 | def visit(self, event: OptionList.OptionSelected) -> None: 307 | """Handle an option list item being selected.""" 308 | assert isinstance(option := event.option, HackerNewsArticle) 309 | open_url(option.article.visitable_url) 310 | 311 | def action_reload(self) -> None: 312 | """Reload the items""" 313 | self._items = [] 314 | self._load() 315 | 316 | 317 | ### items.py ends here 318 | -------------------------------------------------------------------------------- /oshit/hn/__init__.py: -------------------------------------------------------------------------------- 1 | """Provides the client for the HackerNews API.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .client import HN 6 | 7 | ############################################################################## 8 | # Exports. 9 | __all__ = ["HN"] 10 | 11 | ### __init__.py ends here 12 | -------------------------------------------------------------------------------- /oshit/hn/client.py: -------------------------------------------------------------------------------- 1 | """The HackerNews API client.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from asyncio import Semaphore, gather 6 | from json import loads 7 | from ssl import SSLCertVerificationError 8 | from typing import Any, Final, cast 9 | 10 | ############################################################################## 11 | # HTTPX imports. 12 | from httpx import AsyncClient, HTTPStatusError, RequestError 13 | 14 | ############################################################################## 15 | # Local imports. 16 | from .item import ( 17 | Article, 18 | Comment, 19 | ItemType, 20 | Job, 21 | Loader, 22 | ParentItem, 23 | Poll, 24 | PollOption, 25 | Story, 26 | ) 27 | from .user import User 28 | 29 | 30 | ############################################################################## 31 | class HN: 32 | """HackerNews API client.""" 33 | 34 | AGENT: Final[str] = "Orange Site Hit (https://github.com/davep/oshit)" 35 | """The agent string to use when talking to the API.""" 36 | 37 | _BASE: Final[str] = "https://hacker-news.firebaseio.com/v0/" 38 | """The base of the URL for the API.""" 39 | 40 | class Error(Exception): 41 | """Base class for HackerNews errors.""" 42 | 43 | class RequestError(Error): 44 | """Exception raised if there was a problem making an API request.""" 45 | 46 | class NoSuchUser(Error): 47 | """Exception raised if no such user exists.""" 48 | 49 | def __init__(self, max_concurrency: int = 50, timeout: int | None = 5) -> None: 50 | """Initialise the API client object. 51 | 52 | Args: 53 | max_concurrency: The maximum number of concurrent connections to use. 54 | timeout: The timeout for an attempted connection. 55 | """ 56 | self._client_: AsyncClient | None = None 57 | """The HTTPX client.""" 58 | self._max_concurrency = max_concurrency 59 | """The maximum number of concurrent connections to use.""" 60 | self._timeout = timeout 61 | """The timeout to use on connections.""" 62 | 63 | @property 64 | def _client(self) -> AsyncClient: 65 | """The API client.""" 66 | if self._client_ is None: 67 | self._client_ = AsyncClient() 68 | return self._client_ 69 | 70 | def _api_url(self, *path: str) -> str: 71 | """Construct a URL for calling on the API. 72 | 73 | Args: 74 | *path: The path to the endpoint. 75 | 76 | Returns: 77 | The URL to use. 78 | """ 79 | return f"{self._BASE}{'/'.join(path)}" 80 | 81 | async def _call(self, *path: str, **params: str) -> str: 82 | """Call on the Pinboard API. 83 | 84 | Args: 85 | path: The path for the API call. 86 | params: The parameters for the call. 87 | 88 | Returns: 89 | The text returned from the call. 90 | """ 91 | try: 92 | response = await self._client.get( 93 | self._api_url(*path), 94 | params=params, 95 | headers={"user-agent": self.AGENT}, 96 | timeout=self._timeout, 97 | ) 98 | except (RequestError, SSLCertVerificationError) as error: 99 | raise self.RequestError(str(error)) 100 | 101 | try: 102 | response.raise_for_status() 103 | except HTTPStatusError as error: 104 | raise self.RequestError(str(error)) 105 | 106 | return response.text 107 | 108 | async def max_item_id(self) -> int: 109 | """Get the current maximum item ID. 110 | 111 | Returns: 112 | The ID of the maximum item on HackerNews. 113 | """ 114 | return int(loads(await self._call("maxitem.json"))) 115 | 116 | async def _raw_item(self, item_id: int) -> dict[str, Any]: 117 | """Get the raw data of an item from the API. 118 | 119 | Args: 120 | item_id: The ID of the item to get. 121 | 122 | Returns: 123 | The JSON data of that item as a `dict`. 124 | """ 125 | # TODO: Possibly cache this. 126 | return cast(dict[str, Any], loads(await self._call("item", f"{item_id}.json"))) 127 | 128 | async def item(self, item_type: type[ItemType], item_id: int) -> ItemType: 129 | """Get an item by its ID. 130 | 131 | Args: 132 | item_type: The type of the item to get from the API. 133 | item_id: The ID of the item to get. 134 | 135 | Returns: 136 | The item. 137 | """ 138 | # If we can get the item but it comes back with no data at all... 139 | if not (data := await self._raw_item(item_id)): 140 | # ...as https://hacker-news.firebaseio.com/v0/item/41050801.json 141 | # does for some reason, just make an empty version of the item. 142 | return item_type() 143 | if isinstance(item := Loader.load(data), item_type): 144 | return item 145 | raise ValueError( 146 | f"The item of ID '{item_id}' is of type '{item.item_type}', not {item_type.__name__}" 147 | ) 148 | 149 | async def _items_from_ids( 150 | self, item_type: type[ItemType], item_ids: list[int] 151 | ) -> list[ItemType]: 152 | """Turn a list of item IDs into a list of items. 153 | 154 | Args: 155 | item_type: The type of the item we'll be getting. 156 | item_ids: The IDs of the items to get. 157 | 158 | Returns: 159 | The list of items. 160 | """ 161 | concurrency_limit = Semaphore(self._max_concurrency) 162 | 163 | async def item(item_id: int) -> ItemType: 164 | """Get an item, with a limit on concurrent requests. 165 | 166 | Args: 167 | item_id: The ID of the item to get. 168 | 169 | Returns: 170 | The item. 171 | """ 172 | async with concurrency_limit: 173 | return await self.item(item_type, item_id) 174 | 175 | return await gather(*[item(item_id) for item_id in item_ids]) 176 | 177 | async def _id_list(self, list_type: str, max_count: int | None = None) -> list[int]: 178 | """Get a given ID list. 179 | 180 | Args: 181 | list_type: The type of list to get. 182 | max_count: Maximum number of IDs to fetch. 183 | 184 | Returns: 185 | The list of item IDs. 186 | """ 187 | return cast( 188 | list[int], loads(await self._call(f"{list_type}.json"))[0:max_count] 189 | ) 190 | 191 | async def top_story_ids(self, max_count: int | None = None) -> list[int]: 192 | """Get the list of top story IDs. 193 | 194 | Args: 195 | max_count: Maximum number of IDs to fetch. 196 | 197 | Returns: 198 | The list of the top story IDs. 199 | """ 200 | return await self._id_list("topstories", max_count) 201 | 202 | async def top_stories(self, max_count: int | None = None) -> list[Article]: 203 | """Get the top stories. 204 | 205 | Args: 206 | max_count: Maximum number of stories to fetch. 207 | 208 | Returns: 209 | The list of the top stories. 210 | """ 211 | return await self._items_from_ids(Article, await self.top_story_ids(max_count)) 212 | 213 | async def new_story_ids(self, max_count: int | None = None) -> list[int]: 214 | """Get the list of new story IDs. 215 | 216 | Args: 217 | max_count: Maximum number of story IDs to fetch. 218 | 219 | Returns: 220 | The list of the new story IDs. 221 | """ 222 | return await self._id_list("newstories", max_count) 223 | 224 | async def new_stories(self, max_count: int | None = None) -> list[Article]: 225 | """Get the new stories. 226 | 227 | Args: 228 | max_count: Maximum number of stories to fetch. 229 | 230 | Returns: 231 | The list of the new stories. 232 | """ 233 | return await self._items_from_ids(Article, await self.new_story_ids(max_count)) 234 | 235 | async def best_story_ids(self, max_count: int | None = None) -> list[int]: 236 | """Get the list of best story IDs. 237 | 238 | Args: 239 | max_count: Maximum number of story IDs to fetch. 240 | 241 | Returns: 242 | The list of the best story IDs. 243 | """ 244 | return await self._id_list("beststories", max_count) 245 | 246 | async def best_stories(self, max_count: int | None = None) -> list[Article]: 247 | """Get the best stories. 248 | 249 | Args: 250 | max_count: Maximum number of stories to fetch. 251 | 252 | Returns: 253 | The list of the best stories. 254 | """ 255 | return await self._items_from_ids(Article, await self.best_story_ids(max_count)) 256 | 257 | async def latest_ask_story_ids(self, max_count: int | None = None) -> list[int]: 258 | """Get the list of the latest ask story IDs. 259 | 260 | Args: 261 | max_count: Maximum number of story IDs to fetch. 262 | 263 | Returns: 264 | The list of the latest ask story IDs. 265 | """ 266 | return await self._id_list("askstories", max_count) 267 | 268 | async def latest_ask_stories(self, max_count: int | None = None) -> list[Story]: 269 | """Get the latest AskHN stories. 270 | 271 | Args: 272 | max_count: Maximum number of stories to fetch. 273 | 274 | Returns: 275 | The list of the latest AskHN stories. 276 | """ 277 | return await self._items_from_ids( 278 | Story, await self.latest_ask_story_ids(max_count) 279 | ) 280 | 281 | async def latest_show_story_ids(self, max_count: int | None = None) -> list[int]: 282 | """Get the list of the latest show story IDs. 283 | 284 | Args: 285 | max_count: Maximum number of story IDs to fetch. 286 | 287 | Returns: 288 | The list of the latest show story IDs. 289 | """ 290 | return await self._id_list("showstories", max_count) 291 | 292 | async def latest_show_stories(self, max_count: int | None = None) -> list[Story]: 293 | """Get the latest ShowHN stories. 294 | 295 | Args: 296 | max_count: Maximum number of stories to fetch. 297 | 298 | Returns: 299 | The list of the latest ShowHN stories. 300 | """ 301 | return await self._items_from_ids( 302 | Story, await self.latest_show_story_ids(max_count) 303 | ) 304 | 305 | async def latest_job_story_ids(self, max_count: int | None = None) -> list[int]: 306 | """Get the list of the latest job story IDs. 307 | 308 | Args: 309 | max_count: Maximum number of job IDs to fetch. 310 | 311 | Returns: 312 | The list of the latest job story IDs. 313 | """ 314 | return await self._id_list("jobstories", max_count) 315 | 316 | async def latest_job_stories(self, max_count: int | None = None) -> list[Job]: 317 | """Get the latest job stories. 318 | 319 | Args: 320 | max_count: Maximum number of jobs to fetch. 321 | 322 | Returns: 323 | The list of the latest job stories. 324 | """ 325 | return await self._items_from_ids( 326 | Job, await self.latest_job_story_ids(max_count) 327 | ) 328 | 329 | async def user(self, user_id: str) -> User: 330 | """Get the details of the given user. 331 | 332 | Args: 333 | user_id: The ID of the user. 334 | 335 | Returns: 336 | The details of the user. 337 | 338 | Raises: 339 | HN.NoSuchUser: If the user is not known. 340 | """ 341 | if user := loads(await self._call("user", f"{user_id}.json")): 342 | return User().populate_with(user) 343 | raise self.NoSuchUser(f"Unknown user: {user_id}") 344 | 345 | async def comments(self, item: ParentItem) -> list[Comment]: 346 | """Get the comments for the given item. 347 | 348 | Args: 349 | item: The item to get the comments for. 350 | 351 | Returns: 352 | The list of comments for the item. 353 | """ 354 | return await self._items_from_ids(Comment, item.kids) 355 | 356 | async def poll_options(self, poll: Poll) -> list[PollOption]: 357 | """Get the options for the given poll. 358 | 359 | Args: 360 | item: The poll to get the options for. 361 | 362 | Returns: 363 | The list of options for the poll. 364 | """ 365 | return await self._items_from_ids(PollOption, poll.parts) 366 | 367 | 368 | ### client.py ends here 369 | -------------------------------------------------------------------------------- /oshit/hn/item/__init__.py: -------------------------------------------------------------------------------- 1 | """HackerNews item-oriented classes.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .article import Article 6 | from .base import Item, ItemType, ParentItem 7 | from .comment import Comment 8 | from .link import Job, Link, Story 9 | from .loader import Loader 10 | from .poll import Poll, PollOption 11 | from .unknown import UnknownItem 12 | 13 | ############################################################################## 14 | # Exports. 15 | __all__ = [ 16 | "Article", 17 | "Comment", 18 | "Item", 19 | "ItemType", 20 | "Job", 21 | "Link", 22 | "Loader", 23 | "ParentItem", 24 | "Poll", 25 | "PollOption", 26 | "Story", 27 | "UnknownItem", 28 | ] 29 | 30 | ### __init__.py ends here 31 | -------------------------------------------------------------------------------- /oshit/hn/item/article.py: -------------------------------------------------------------------------------- 1 | """Class for holding an article pulled from HackerNews. 2 | 3 | An article is defined as something that has a title, a score and 4 | descendants. 5 | """ 6 | 7 | ############################################################################## 8 | # Python imports. 9 | from typing import Any 10 | 11 | from typing_extensions import Self 12 | 13 | ############################################################################## 14 | # Local imports. 15 | from .base import ParentItem 16 | 17 | 18 | ############################################################################## 19 | class Article(ParentItem): 20 | """Base class for all types of articles on HackerNews.""" 21 | 22 | descendants: int = 0 23 | """The number of descendants of the article.""" 24 | 25 | score: int = 0 26 | """The score of the article.""" 27 | 28 | title: str = "" 29 | """The title of the article.""" 30 | 31 | def populate_with(self, data: dict[str, Any]) -> Self: 32 | """Populate the item with the data from the given JSON value. 33 | 34 | Args: 35 | data: The data to populate from. 36 | 37 | Returns: 38 | Self 39 | """ 40 | self.descendants = data.get("descendants", 0) 41 | self.score = data["score"] 42 | self.title = data["title"] 43 | return super().populate_with(data) 44 | 45 | def __contains__(self, search_for: str) -> bool: 46 | return ( 47 | super().__contains__(search_for) 48 | or search_for.casefold() in self.title.casefold() 49 | ) 50 | 51 | 52 | ### article.py ends here 53 | -------------------------------------------------------------------------------- /oshit/hn/item/base.py: -------------------------------------------------------------------------------- 1 | """Base class for items pulled from HackerNews.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import dataclass, field 6 | from datetime import datetime 7 | from typing import Any, TypeVar 8 | 9 | ############################################################################## 10 | # Backward-compatible typing. 11 | from typing_extensions import Self 12 | 13 | ############################################################################## 14 | # Local imports. 15 | from ..text import tidy_text 16 | 17 | 18 | ############################################################################## 19 | @dataclass 20 | class Item: 21 | """Base class of an item found in the HackerNews API.""" 22 | 23 | item_id: int = 0 24 | """The ID of the item.""" 25 | 26 | by: str = "" 27 | """The author of the item.""" 28 | 29 | item_type: str = "" 30 | """The API's name for the type of the item.""" 31 | 32 | time: datetime = datetime(1970, 1, 1) 33 | """The time of the item.""" 34 | 35 | raw_text: str = "" 36 | """The raw text of the of the item, if it has text.""" 37 | 38 | def populate_with(self, data: dict[str, Any]) -> Self: 39 | """Populate the item with the data from the given JSON value. 40 | 41 | Args: 42 | data: The data to populate from. 43 | 44 | Returns: 45 | Self 46 | """ 47 | self.item_id = data["id"] 48 | self.by = data.get("by", "") 49 | self.item_type = data["type"] 50 | self.time = datetime.fromtimestamp(data["time"]) 51 | self.raw_text = data.get("text", "") 52 | return self 53 | 54 | @property 55 | def orange_site_url(self) -> str: 56 | """The URL of the item on HackerNews.""" 57 | return f"https://news.ycombinator.com/item?id={self.item_id}" 58 | 59 | @property 60 | def visitable_url(self) -> str: 61 | """A visitable URL for the item.""" 62 | return self.orange_site_url 63 | 64 | @property 65 | def text(self) -> str: 66 | """The text for the item, if it has text.""" 67 | return tidy_text(self.raw_text) 68 | 69 | @property 70 | def has_text(self) -> bool: 71 | """Does the item have any text?""" 72 | return bool(self.text.strip()) 73 | 74 | @property 75 | def looks_valid(self) -> bool: 76 | """Does the item look valid?""" 77 | return bool(self.item_id) and bool(self.item_type) 78 | 79 | def __contains__(self, search_for: str) -> bool: 80 | return ( 81 | search_for.casefold() in self.by.casefold() 82 | or search_for.casefold() in self.text 83 | ) 84 | 85 | 86 | ############################################################################## 87 | @dataclass 88 | class ParentItem(Item): 89 | """Base class for items that can have children.""" 90 | 91 | kids: list[int] = field(default_factory=list) 92 | """The children of the item.""" 93 | 94 | deleted: bool = False 95 | """Has this item been deleted?""" 96 | 97 | def populate_with(self, data: dict[str, Any]) -> Self: 98 | """Populate the item with the data from the given JSON value. 99 | 100 | Args: 101 | data: The data to populate from. 102 | 103 | Returns: 104 | Self 105 | """ 106 | self.kids = data.get("kids", []) 107 | self.deleted = data.get("deleted", False) 108 | return super().populate_with(data) 109 | 110 | 111 | ############################################################################## 112 | ItemType = TypeVar("ItemType", bound="Item") 113 | """Generic type for an item pulled from the API.""" 114 | 115 | ### base.py ends here 116 | -------------------------------------------------------------------------------- /oshit/hn/item/comment.py: -------------------------------------------------------------------------------- 1 | """Provides the class that holds details of a HackerNews comment.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from typing import Any 6 | 7 | from typing_extensions import Self 8 | 9 | ############################################################################## 10 | # Local imports. 11 | from ..text import text_urls 12 | from .base import ParentItem 13 | from .loader import Loader 14 | 15 | 16 | ############################################################################## 17 | @Loader.loads("comment") 18 | class Comment(ParentItem): 19 | """Class that holds the details of a HackerNews comment.""" 20 | 21 | parent: int = 0 22 | """The ID of the parent of the comment.""" 23 | 24 | def populate_with(self, data: dict[str, Any]) -> Self: 25 | """Populate the item with the data from the given JSON value. 26 | 27 | Args: 28 | data: The data to populate from. 29 | 30 | Returns: 31 | Self 32 | """ 33 | self.raw_text = data.get("text", "") 34 | self.parent = data["parent"] 35 | return super().populate_with(data) 36 | 37 | @property 38 | def urls(self) -> list[str]: 39 | """The URLs in the comment.""" 40 | return text_urls(self.raw_text) 41 | 42 | @property 43 | def flagged(self) -> bool: 44 | """Does the comment appear to be flagged?""" 45 | return self.raw_text == "[flagged]" 46 | 47 | @property 48 | def dead(self) -> bool: 49 | """Does the comment appear to be dead?""" 50 | return self.raw_text == "[dead]" 51 | 52 | 53 | ### comment.py ends here 54 | -------------------------------------------------------------------------------- /oshit/hn/item/link.py: -------------------------------------------------------------------------------- 1 | """The class that holds HackerNews items that are some sort of link.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from typing import Any 6 | from urllib.parse import urlparse 7 | 8 | from typing_extensions import Self 9 | 10 | ############################################################################## 11 | # Local imports. 12 | from .article import Article 13 | from .loader import Loader 14 | 15 | 16 | ############################################################################## 17 | class Link(Article): 18 | """Class for holding an article that potentially links to something.""" 19 | 20 | url: str = "" 21 | """The URL associated with the article.""" 22 | 23 | def populate_with(self, data: dict[str, Any]) -> Self: 24 | """Populate the item with the data from the given JSON value. 25 | 26 | Args: 27 | data: The data to populate from. 28 | 29 | Returns: 30 | Self 31 | """ 32 | self.url = data.get("url", "") 33 | return super().populate_with(data) 34 | 35 | @property 36 | def has_url(self) -> bool: 37 | """Does this article actually have a link. 38 | 39 | Some stories fall under the banner of being linkable, but don't 40 | really have a link. This can be used to test if there really is a 41 | link or not. 42 | """ 43 | return bool(self.url.strip()) 44 | 45 | @property 46 | def visitable_url(self) -> str: 47 | """A visitable URL for the item.""" 48 | return self.url if self.has_url else super().visitable_url 49 | 50 | @property 51 | def domain(self) -> str: 52 | """The domain from the URL, if there is one.""" 53 | return urlparse(self.url).hostname or "" 54 | 55 | def __contains__(self, search_for: str) -> bool: 56 | return ( 57 | super().__contains__(search_for) 58 | or search_for.casefold() in self.domain.casefold() 59 | ) 60 | 61 | 62 | ############################################################################## 63 | @Loader.loads("story") 64 | class Story(Link): 65 | """Class for holding a story.""" 66 | 67 | 68 | ############################################################################## 69 | @Loader.loads("job") 70 | class Job(Link): 71 | """Class for holding a job.""" 72 | 73 | 74 | ### link.py ends here 75 | -------------------------------------------------------------------------------- /oshit/hn/item/loader.py: -------------------------------------------------------------------------------- 1 | """Central item type to item class type matching code.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from typing import Any, Callable 6 | 7 | ############################################################################## 8 | # Local imports. 9 | from .base import Item, ItemType 10 | from .unknown import UnknownItem 11 | 12 | 13 | ############################################################################## 14 | class Loader: 15 | """Helper class for loading up HackerNews items.""" 16 | 17 | _map: dict[str, type[Item]] = {} 18 | """The map of type names to actual types.""" 19 | 20 | @classmethod 21 | def loads(cls, item_type: str) -> Callable[[type[ItemType]], type[ItemType]]: 22 | """Decorator for declaring that a class loads a particular item type. 23 | 24 | Args: 25 | item_type: The HackerNews item type string to associate with the class. 26 | """ 27 | 28 | def _register(handler: type[ItemType]) -> type[ItemType]: 29 | """Register the item class.""" 30 | cls._map[item_type] = handler 31 | return handler 32 | 33 | return _register 34 | 35 | @classmethod 36 | def load(cls, data: dict[str, Any]) -> Item: 37 | """Load the JSON data into the desired type. 38 | 39 | Args: 40 | data: The JSON data to load up. 41 | 42 | Returns: 43 | An instance of a item class, of the best-fit type. 44 | """ 45 | return cls._map.get(data["type"], UnknownItem)().populate_with(data) 46 | 47 | 48 | ### loader.py ends here 49 | -------------------------------------------------------------------------------- /oshit/hn/item/poll.py: -------------------------------------------------------------------------------- 1 | """Class for holding a poll pulled from HackerNews.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import dataclass, field 6 | from typing import Any 7 | 8 | ############################################################################## 9 | # Backward-compatible typing. 10 | from typing_extensions import Self 11 | 12 | ############################################################################## 13 | # Local imports. 14 | from .article import Article 15 | from .base import Item 16 | from .loader import Loader 17 | 18 | 19 | ############################################################################## 20 | @dataclass 21 | @Loader.loads("poll") 22 | class Poll(Article): 23 | """Class that holds the details of a HackerNews poll.""" 24 | 25 | parts: list[int] = field(default_factory=list) 26 | """The list of IDs for the parts of the poll.""" 27 | 28 | def populate_with(self, data: dict[str, Any]) -> Self: 29 | """Populate the item with the data from the given JSON value. 30 | 31 | Args: 32 | data: The data to populate from. 33 | 34 | Returns: 35 | Self 36 | """ 37 | self.parts = data.get("parts", []) 38 | return super().populate_with(data) 39 | 40 | 41 | ############################################################################## 42 | @dataclass 43 | @Loader.loads("pollopt") 44 | class PollOption(Item): 45 | """Class for holding the details of a poll option.""" 46 | 47 | poll: int = 0 48 | """The ID of the poll that the option belongs to.""" 49 | 50 | score: int = 0 51 | """The score of the poll option.""" 52 | 53 | text: str = "" 54 | """The text for the poll option.""" 55 | 56 | def populate_with(self, data: dict[str, Any]) -> Self: 57 | """Populate the item with the data from the given JSON value. 58 | 59 | Args: 60 | data: The data to populate from. 61 | 62 | Returns: 63 | Self 64 | """ 65 | self.poll = data.get("poll", 0) 66 | self.score = data.get("score", 0) 67 | self.text = data.get("text", "") 68 | return super().populate_with(data) 69 | 70 | 71 | ### poll.py ends here 72 | -------------------------------------------------------------------------------- /oshit/hn/item/unknown.py: -------------------------------------------------------------------------------- 1 | """Type of an unknown item.""" 2 | 3 | ############################################################################## 4 | # Local imports. 5 | from .base import Item 6 | 7 | 8 | ############################################################################## 9 | class UnknownItem(Item): 10 | """A fallback while I work on this. This will go away.""" 11 | 12 | 13 | ### unknown.py ends here 14 | -------------------------------------------------------------------------------- /oshit/hn/text.py: -------------------------------------------------------------------------------- 1 | """Utility code for working with text from HackerNews.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from html import unescape 6 | from re import compile as compile_re 7 | from re import sub 8 | from typing import Pattern 9 | 10 | ############################################################################## 11 | # Backward-compatible typing. 12 | from typing_extensions import Final 13 | 14 | ############################################################################## 15 | # TODO! Throw in some proper HTML parsing here. 16 | ############################################################################## 17 | 18 | 19 | ############################################################################## 20 | def tidy_text(text: str) -> str: 21 | """Tidy up some text from the HackerNews API. 22 | 23 | Args: 24 | text: The text to tidy up. 25 | 26 | Returns: 27 | The text tidied up for use in the terminal rather than on the web. 28 | """ 29 | return sub("<[^<]+?>", "", unescape(text.replace("

", "\n\n"))) 30 | 31 | 32 | HREF: Final[Pattern[str]] = compile_re(r'href="([^"]+)"') 33 | """Regular expression for finding links in some text.""" 34 | 35 | 36 | ############################################################################## 37 | def text_urls(text: str) -> list[str]: 38 | """Find any links in the given text. 39 | 40 | Args: 41 | text: The text to look in. 42 | 43 | Returns: 44 | The list of links found in the text. 45 | """ 46 | return HREF.findall(unescape(text)) 47 | 48 | 49 | ### text.py ends here 50 | -------------------------------------------------------------------------------- /oshit/hn/user.py: -------------------------------------------------------------------------------- 1 | """Class that holds the details of a HackerNews user.""" 2 | 3 | ############################################################################## 4 | # Python imports. 5 | from dataclasses import dataclass, field 6 | from datetime import datetime 7 | from typing import Any 8 | 9 | ############################################################################## 10 | # Backward-compatible typing. 11 | from typing_extensions import Self 12 | 13 | ############################################################################## 14 | # Local imports. 15 | from .text import tidy_text 16 | 17 | 18 | ############################################################################## 19 | @dataclass 20 | class User: 21 | """Details of a HackerNews user.""" 22 | 23 | user_id: str = "" 24 | """The ID of the user.""" 25 | 26 | raw_about: str = "" 27 | """The raw version of the user's about text.""" 28 | 29 | karma: int = 0 30 | """The user's karma.""" 31 | 32 | created: datetime = datetime(1970, 1, 1) 33 | """The time the user was created.""" 34 | 35 | submitted: list[int] = field(default_factory=list) 36 | """The stories, polls and comments the user has submitted.""" 37 | 38 | def populate_with(self, data: dict[str, Any]) -> Self: 39 | """Populate the user with details from the given data. 40 | 41 | Args: 42 | data: The data to populate from. 43 | 44 | Returns: 45 | Self. 46 | """ 47 | self.user_id = data["id"] 48 | self.raw_about = data.get("about", "").strip() 49 | self.karma = data["karma"] 50 | self.created = datetime.fromtimestamp(data["created"]) 51 | self.submitted = data.get("submitted", []) 52 | return self 53 | 54 | @property 55 | def has_about(self) -> bool: 56 | """Does the user have an about text?""" 57 | return bool(self.raw_about) 58 | 59 | @property 60 | def about(self) -> str: 61 | """A clean version of the about text for the user.""" 62 | return tidy_text(self.raw_about) 63 | 64 | @property 65 | def url(self) -> str: 66 | """The HackerNews URL for the user.""" 67 | return f"https://news.ycombinator.com/user?id={self.user_id}" 68 | 69 | 70 | ### user.py ends here 71 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | ### pyproject.toml ends here 6 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = oshit 3 | description = A terminal-based HackerNews reader 4 | version = attr: oshit.__version__ 5 | long_description = file: README.md 6 | long_description_content_type = text/markdown 7 | url = https://github.com/davep/oshit 8 | author = Dave Pearson 9 | author_email = davep@davep.org 10 | maintainer = Dave Pearson 11 | maintainer_email = davep@davep.org 12 | license = License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) 13 | license_files = LICENCE 14 | keywords = terminal 15 | classifiers = 16 | License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) 17 | Environment :: Console 18 | Development Status :: 4 - Beta 19 | Intended Audience :: End Users/Desktop 20 | Natural Language :: English 21 | Operating System :: OS Independent 22 | Programming Language :: Python :: 3.10 23 | Programming Language :: Python :: 3.11 24 | Programming Language :: Python :: 3.12 25 | Topic :: Internet 26 | Topic :: Terminals 27 | Typing :: Typed 28 | project_urls = 29 | Documentation = https://github.com/davep/oshit/blob/main/README.md 30 | Source = https://github.com/davep/oshit 31 | Issues = https://github.com/davep/oshit/issues 32 | Discussions = https://github.com/davep/oshit/discussions 33 | 34 | [options] 35 | packages = find: 36 | platforms = any 37 | include_package_data = True 38 | python_requires = >=3.10,<3.13 39 | install_requires = 40 | textual==0.70.0 41 | humanize>=4.8.0 42 | xdg-base-dirs>=6.0.0 43 | httpx 44 | 45 | [options.entry_points] 46 | console_scripts = 47 | oshit = oshit.__main__:run 48 | 49 | ### setup.cfg ends here 50 | --------------------------------------------------------------------------------