├── COPYING.txt ├── README.html ├── README.md ├── ikog.css ├── ikog.pdf └── ikog.py /COPYING.txt: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 |

Acknowledgements

2 |

This software was written by Steve Butler, called "iKog".

3 |

Project homepage: https://sites.google.com/site/henspace/ikog

4 |

Author blog: http://cuckooswearblack.blogspot.com/

5 |

Author twitter: http://twitter.com/henspace

6 |

Welcome to the iKog program. This is a very simple utility designed to make the management of your to-do lists quick and easy. The emphasis is on speed and portability. The program is a text-only utility with no graphical user-interface but it does include some features specifically designed to help with techniques such as Getting Things Done (GTD). If you're looking for fancy menus and windows, then iKog is not for you. If you're comfortable with text-based applications, then perhaps you'll find it useful. Anyway its free, so you've got nothing to lose.

7 |

Getting started

8 |
    9 |
  • 10 |

    Add a task

    11 |
    >>>+ Learn how to use this program.
     12 | 
    13 |
  • 14 |
  • 15 |

    Add another task

    16 |
    >>>+ Read that book on web design.
     17 | 
    18 |
  • 19 |
  • 20 |

    Add another task but this time with a priority of 8. i.e quite important.

    21 |
    >>>+ Buy tin or red paint for the bathroom #8
     22 | 
    23 |
  • 24 |
  • 25 |

    Add another task, priority 7 and put it in a project called Bathroom

    26 |
    >>>+ Buy ceramic tiles #7 :pBathroom
     27 | 
    28 |
  • 29 |
  • 30 |

    Add a task that I want to put in a context list of jobs I can do at the computer.

    31 |
    >>>+ Search the web for a pasta recipe @computer
     32 | 
    33 |
  • 34 |
  • 35 |

    Add another task that I can do at the computer but use the abbreviated form.

    36 |
    >>>+ Buy a book from Amazon @c
     37 | 
    38 |
  • 39 |
  • 40 |

    Add a task that must be done on 30th August 2006

    41 |
    >>>+ Take the cat to the vets :d2006-08-30
     42 | 
    43 |
  • 44 |
  • 45 |

    List all of my tasks.

    46 |
    >>>list
     47 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     48 | [00] Buy tin of read paint for the bathroom #8 @Anywhere [2006-08-17]
     49 | [01] Buy ceramic tiles #7 @Anywhere Projects: Bathroom [2006-08-17]
     50 | [02] Learn how to use this program #5 @Anywhere [2006-08-17]
     51 | [03] Read that book on web design #5 @Anywhere [2006-08-17]
     52 | [04] Search the web for a pasta recipe #5 @Computer [2006-08-17]
     53 | [05] Buy a book from Amazon #5 @Computer [2006-08-17]
     54 | [06] @Date 2006-08-30 Take the cat to the vets #5 @Anywhere [2006-08-17
     55 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     56 | 
    57 |
  • 58 |
  • 59 |

    List only the tasks that I can do at the computer.

    60 |
    >>>list @c
     61 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     62 | Filter = @Computer
     63 | [04] Search the web for a pasta recipe #5 @Computer [2006-08-17]
     64 | [05] Buy a book from Amazon #5 @Computer [2006-08-17]
     65 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     66 | 
    67 |
  • 68 |
  • 69 |

    Produce a list, grouped by context

    70 |
    >>>@
     71 | 
    72 |
  • 73 |
  • 74 |

    Produce a list, grouped by context, saved in %prog.html and open in a browser

    75 |
    >>>@>
     76 | 
    77 |
  • 78 |
  • 79 |

    Okay, I've bought that book from Amazon, lets get rid of it.

    80 |
    >>>kill 5
     81 | 
    82 |
  • 83 |
  • 84 |

    I want to put task 4, searching the web, into an @Internet context instead of the @Computer context.

    85 |
    >>>mod 4 @internet
     86 | 
    87 |
  • 88 |
  • 89 |

    Go to the next task in my list.

    90 |
    >>>next
     91 | 
    92 |
  • 93 |
  • 94 |

    Get help.

    95 |
    >>>help
     96 | 
    97 |
  • 98 |
99 |

General commands

100 |

101 | ?                  : displays a quick reference card
102 | HELP/H             : displays this help.
103 | VERSION/VER        : display the version.
104 | WEB                : Go to the website for more information
105 | CLEARSCREEN/CLS    : Clear the screen
106 | COLOR/COLOUR/C [N] : Use colour display (not Windows) N=1 for no background
107 | MONOCHROME/MONO    : Use monochrome display
108 | EXPORT             : Export the tasks only to filename.tasks.txt
109 | IMPORT file        : Import tasks from the file
110 | REVIEW/REV ON|OFF  : If on, hitting enter moves to the next task
111 |                    : If off, enter re-displays the current task
112 | V0                 : Same as REVIEW OFF
113 | V1                 : Same as REVIEW ON
114 | SAVE/S             : Save the tasks
115 | O/OPEN file        : Open a new data file.
116 | NEW file           : Create a new data file.
117 | AUTOSAVE/AS ON|OFF : Switch autosave on or off
118 | SYS ON|OFF         : Allow the program to use system calls.
119 | !CMD  command      : Run a system command.
120 | 2                  : Start a two minute timer (for GTD)
121 | QUIT/Q             : quit the program
122 | 

123 |

Task entry and editing commands

124 |

125 | For the editing commands that require a task number, you can
126 | replace N by '^' or 'this' to refer to the current task.
127 | ADD/A/+ the task   : add a task to the bottom of the list.
128 |                    : Entering any line that does not begin with
129 |                    : a valid command and which is greater than 10
130 |                    : characters long is also assumed to be an addition.
131 | EDIT/ED [N]        : Create task, or edit task N, using external editor.
132 | SUB/SU N /s1/s2/   : Replace text s1 with s2 in task N. Use \/ if you
133 |                    : need to include the / character.
134 | NOTE/NOTES text    : shorthand for ADD #0 @Notes text
135 | IMMEDIATE/I/++     : add a task to the top of the list to do today.
136 | REP/R N [text]     : replace task N
137 | MOD/M N [text]     : modify task N.
138 | EXTEND/E N [text]  : add more text to task N
139 | FIRST/F N          : move task N to the top.
140 | DOWN/D/ N          : move task N down the queue
141 | UP/U/ N            : move task N up the queue
142 | 

143 |

Task removal commands

144 |

145 | KILL/K/X/- N       : kill (delete) task N. You must define N
146 | DONE N [text]      : Remove task N and move to an archive file
147 | ARCHIVE N [text]   : Same as DONE
148 | CLEAR              : Remove all tasks
149 | 

150 |

Display commands

151 |

152 | SHOW N             : display encrypted text for task N
153 | FILTER/FI [filter] : set a filter.  Applies to all displays
154 |                    : See list for details of the filter
155 |                    : Setting the filter to nothing clears it.
156 | TOP/T [N]          : Go to top, list N tasks, and display the top task
157 | NEXT/N             : display the next task. Same as just hitting enter
158 | PREV/P             : display previous task
159 | GO/G N             : display task N
160 | LIST/L [filter]    : list tasks. Filter = context, project, priority, date
161 |                    : or word. Contexts begin with @ and projects with :p
162 |                    : Dates begin with :d, anything else is a search word.
163 |                    : Precede term with - to exclude e.g.  -@Computer
164 |                    : e.g LIST @computer or LIST #5
165 | @                  : sorted list by Context.
166 | :D                 : sorted list by Dates
167 | :P                 : sorted list by Projects
168 | LIST>/L> [filter]  : standard list sent to an HTML report
169 | @>                 : sorted list by Context sent to an HTML report
170 | :D>                : sorted list by Dates sent to an HTML report
171 | :P>                : sorted list by Projects sent to an HTML report
172 |                    : The HTML reports are sent to todoFilename.html
173 | 

174 |

Advanced options

175 |

176 | The SETEDxxx commands allow you to use an external editor.
177 | Note the editor you pick should be a simple text editor.  If you pick
178 | something that doesn't work, try the defaults again.
179 | Because some systems may have different editors installed, you can set
180 | more than one by separating the editors usng commas.  The program will
181 | use the first one it finds.
182 | For Windows the default is edit, which works quite well in the terminal
183 | but you could change it to notepad.
184 | For Linux, the default is nano,pico,vim,emacs.
185 | To use external editors you must switch on system calls using the SYS ON
186 | command
187 | SETEDNT command    : Set the external editor for Windows (NT).
188 | SETEDPOSIX command : Set the editor for posix systems.
189 |                    : e.g. SETEDNT edit
190 |                    :      SETEDPOSIX nano,vim
191 | SHORTCUT/SC ?      : list shortcuts
192 | SHORTCUT/SC N cmd  : Set shortcut N to command cmd
193 | =N                 : Run shortcut N
194 | ABBREV/AB @x @full : Create new abbreviation. @x expands to @full
195 | ABBREV/AB ?        : List context abbreviations.
196 | PAB :px :pfull     : Project abbreviation. :px expands to :pfull
197 | PAB ?              : List project abbreviations.
198 | 

199 |

Contexts

200 |

201 | Any word preceded by @ will be used as a context.  Contexts are like
202 | sub-categories or sub-lists.  There are a number of pre-defined
203 | abbreviations that you can use as well. The recognised abbreviations
204 | are:
205 | @A = @Anywhere (this is the default)
206 | @C = @Computer
207 | @D = @Desk
208 | @E = @Errands
209 | @H = @Home
210 | @I = @Internet
211 | @L = @Lunch
212 | @M = @Meeting
213 | @N = @Next
214 | @O = @Other
215 | @P = @Phone
216 | @PW= @Password
217 | @S = @Someday/maybe
218 | @W4= @Waiting_for
219 | @W = @Work
220 | 

221 |

Entering dates

222 |

223 | An @Date context is created if you embed a date in the task.
224 | Dates are embedded using the :dDATE format.
225 | Valid DATE formats are yyyy-mm-dd, mm-dd or dd
226 | You can also use : or / as the separators.  So, for example:
227 | :d2006/12/22 or :d2006-11-7 or :d9/28 are all valid entries.

228 |

If you set a date, then until that date is reached, the task is given 229 | an effective priority of 0. Once the date is reached, the task's 230 | priority is increased by 11, moving it to the of the list.

231 |

A date entry of :d0 can be used to clear a date entry. 232 | A date entry of :d+X can be used to create a date entry of today + X days. 233 | So :d+1 is tomorrow and :d+0 is today. 234 |

-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Acknowledgements 2 | ================ 3 | This software was written by Steve Butler, called "iKog". 4 | 5 | Project homepage: https://sites.google.com/site/henspace/ikog 6 | 7 | Author blog: http://cuckooswearblack.blogspot.com/ 8 | 9 | Author twitter: http://twitter.com/henspace 10 | 11 | About 12 | ----- 13 | Welcome to the iKog program. This is a very simple utility designed to make the management of your to-do lists quick and easy. The emphasis is on speed and portability. The program is a text-only utility with no graphical user-interface but it does include some features specifically designed to help with techniques such as Getting Things Done (GTD). If you're looking for fancy menus and windows, then iKog is not for you. If you're comfortable with text-based applications, then perhaps you'll find it useful. Anyway its free, so you've got nothing to lose. 14 | 15 | Getting started 16 | --------------- 17 | - Add a task 18 | 19 | >>>+ Learn how to use this program. 20 | 21 | - Add another task 22 | 23 | >>>+ Read that book on web design. 24 | 25 | - Add another task but this time with a priority of 8. i.e quite important. 26 | 27 | >>>+ Buy tin or red paint for the bathroom #8 28 | 29 | - Add another task, priority 7 and put it in a project called Bathroom 30 | 31 | >>>+ Buy ceramic tiles #7 :pBathroom 32 | 33 | - Add a task that I want to put in a context list of jobs I can do at the computer. 34 | 35 | >>>+ Search the web for a pasta recipe @computer 36 | 37 | - Add another task that I can do at the computer but use the abbreviated form. 38 | 39 | >>>+ Buy a book from Amazon @c 40 | 41 | - Add a task that must be done on 30th August 2006 42 | 43 | >>>+ Take the cat to the vets :d2006-08-30 44 | 45 | - List all of my tasks. 46 | 47 | >>>list 48 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 49 | [00] Buy tin of read paint for the bathroom #8 @Anywhere [2006-08-17] 50 | [01] Buy ceramic tiles #7 @Anywhere Projects: Bathroom [2006-08-17] 51 | [02] Learn how to use this program #5 @Anywhere [2006-08-17] 52 | [03] Read that book on web design #5 @Anywhere [2006-08-17] 53 | [04] Search the web for a pasta recipe #5 @Computer [2006-08-17] 54 | [05] Buy a book from Amazon #5 @Computer [2006-08-17] 55 | [06] @Date 2006-08-30 Take the cat to the vets #5 @Anywhere [2006-08-17 56 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | 58 | - List only the tasks that I can do at the computer. 59 | 60 | >>>list @c 61 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 | Filter = @Computer 63 | [04] Search the web for a pasta recipe #5 @Computer [2006-08-17] 64 | [05] Buy a book from Amazon #5 @Computer [2006-08-17] 65 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 | 67 | - Produce a list, grouped by context 68 | 69 | >>>@ 70 | 71 | - Produce a list, grouped by context, saved in %prog.html and open in a browser 72 | 73 | >>>@> 74 | 75 | - Okay, I've bought that book from Amazon, lets get rid of it. 76 | 77 | >>>kill 5 78 | 79 | - I want to put task 4, searching the web, into an @Internet context instead of the @Computer context. 80 | 81 | >>>mod 4 @internet 82 | 83 | - Go to the next task in my list. 84 | 85 | >>>next 86 | 87 | - Get help. 88 | 89 | >>>help 90 | 91 | General commands 92 | ---------------- 93 |
 94 | ?                  : displays a quick reference card
 95 | HELP/H             : displays this help.
 96 | VERSION/VER        : display the version.
 97 | WEB                : Go to the website for more information
 98 | CLEARSCREEN/CLS    : Clear the screen
 99 | COLOR/COLOUR/C [N] : Use colour display (not Windows) N=1 for no background
100 | MONOCHROME/MONO    : Use monochrome display
101 | EXPORT             : Export the tasks only to filename.tasks.txt
102 | IMPORT file        : Import tasks from the file
103 | REVIEW/REV ON|OFF  : If on, hitting enter moves to the next task
104 |                    : If off, enter re-displays the current task
105 | V0                 : Same as REVIEW OFF
106 | V1                 : Same as REVIEW ON
107 | SAVE/S             : Save the tasks
108 | O/OPEN file        : Open a new data file.
109 | NEW file           : Create a new data file.
110 | AUTOSAVE/AS ON|OFF : Switch autosave on or off
111 | SYS ON|OFF         : Allow the program to use system calls.
112 | !CMD  command      : Run a system command.
113 | 2                  : Start a two minute timer (for GTD)
114 | QUIT/Q             : quit the program
115 | 
116 | 117 | Task entry and editing commands 118 | ------------------------------- 119 |
120 | For the editing commands that require a task number, you can
121 | replace N by '^' or 'this' to refer to the current task.
122 | ADD/A/+ the task   : add a task to the bottom of the list.
123 |                    : Entering any line that does not begin with
124 |                    : a valid command and which is greater than 10
125 |                    : characters long is also assumed to be an addition.
126 | EDIT/ED [N]        : Create task, or edit task N, using external editor.
127 | SUB/SU N /s1/s2/   : Replace text s1 with s2 in task N. Use \/ if you
128 |                    : need to include the / character.
129 | NOTE/NOTES text    : shorthand for ADD #0 @Notes text
130 | IMMEDIATE/I/++     : add a task to the top of the list to do today.
131 | REP/R N [text]     : replace task N
132 | MOD/M N [text]     : modify task N.
133 | EXTEND/E N [text]  : add more text to task N
134 | FIRST/F N          : move task N to the top.
135 | DOWN/D/ N          : move task N down the queue
136 | UP/U/ N            : move task N up the queue
137 | 
138 | 139 | Task removal commands 140 | --------------------- 141 |
142 | KILL/K/X/- N       : kill (delete) task N. You must define N
143 | DONE N [text]      : Remove task N and move to an archive file
144 | ARCHIVE N [text]   : Same as DONE
145 | CLEAR              : Remove all tasks
146 | 
147 | 148 | Display commands 149 | ---------------- 150 |
151 | SHOW N             : display encrypted text for task N
152 | FILTER/FI [filter] : set a filter.  Applies to all displays
153 |                    : See list for details of the filter
154 |                    : Setting the filter to nothing clears it.
155 | TOP/T [N]          : Go to top, list N tasks, and display the top task
156 | NEXT/N             : display the next task. Same as just hitting enter
157 | PREV/P             : display previous task
158 | GO/G N             : display task N
159 | LIST/L [filter]    : list tasks. Filter = context, project, priority, date
160 |                    : or word. Contexts begin with @ and projects with :p
161 |                    : Dates begin with :d, anything else is a search word.
162 |                    : Precede term with - to exclude e.g.  -@Computer
163 |                    : e.g LIST @computer or LIST #5
164 | @                  : sorted list by Context.
165 | :D                 : sorted list by Dates
166 | :P                 : sorted list by Projects
167 | LIST>/L> [filter]  : standard list sent to an HTML report
168 | @>                 : sorted list by Context sent to an HTML report
169 | :D>                : sorted list by Dates sent to an HTML report
170 | :P>                : sorted list by Projects sent to an HTML report
171 |                    : The HTML reports are sent to todoFilename.html
172 | 
173 | 174 | Advanced options 175 | ---------------- 176 |
177 | The SETEDxxx commands allow you to use an external editor.
178 | Note the editor you pick should be a simple text editor.  If you pick
179 | something that doesn't work, try the defaults again.
180 | Because some systems may have different editors installed, you can set
181 | more than one by separating the editors usng commas.  The program will
182 | use the first one it finds.
183 | For Windows the default is edit, which works quite well in the terminal
184 | but you could change it to notepad.
185 | For Linux, the default is nano,pico,vim,emacs.
186 | To use external editors you must switch on system calls using the SYS ON
187 | command
188 | SETEDNT command    : Set the external editor for Windows (NT).
189 | SETEDPOSIX command : Set the editor for posix systems.
190 |                    : e.g. SETEDNT edit
191 |                    :      SETEDPOSIX nano,vim
192 | SHORTCUT/SC ?      : list shortcuts
193 | SHORTCUT/SC N cmd  : Set shortcut N to command cmd
194 | =N                 : Run shortcut N
195 | ABBREV/AB @x @full : Create new abbreviation. @x expands to @full
196 | ABBREV/AB ?        : List context abbreviations.
197 | PAB :px :pfull     : Project abbreviation. :px expands to :pfull
198 | PAB ?              : List project abbreviations.
199 | 
200 | 201 | Contexts 202 | -------- 203 |
204 | Any word preceded by @ will be used as a context.  Contexts are like
205 | sub-categories or sub-lists.  There are a number of pre-defined
206 | abbreviations that you can use as well. The recognised abbreviations
207 | are:
208 | @A = @Anywhere (this is the default)
209 | @C = @Computer
210 | @D = @Desk
211 | @E = @Errands
212 | @H = @Home
213 | @I = @Internet
214 | @L = @Lunch
215 | @M = @Meeting
216 | @N = @Next
217 | @O = @Other
218 | @P = @Phone
219 | @PW= @Password
220 | @S = @Someday/maybe
221 | @W4= @Waiting_for
222 | @W = @Work
223 | 
224 | 225 | Entering dates 226 | -------------- 227 |
228 | An @Date context is created if you embed a date in the task.
229 | Dates are embedded using the :dDATE format.
230 | Valid DATE formats are yyyy-mm-dd, mm-dd or dd
231 | You can also use : or / as the separators.  So, for example:
232 | :d2006/12/22 or :d2006-11-7 or :d9/28 are all valid entries.
233 | 
234 | If you set a date, then until that date is reached, the task is given
235 | an effective priority of 0.  Once the date is reached, the task's
236 | priority is increased by 11, moving it to the of the list.
237 | 
238 | A date entry of :d0 can be used to clear a date entry.
239 | A date entry of :d+X can be used to create a date entry of today + X days.
240 | So :d+1 is tomorrow and :d+0 is today.
241 | 
242 | -------------------------------------------------------------------------------- /ikog.css: -------------------------------------------------------------------------------- 1 | /* Example CSS Document for ikog v1.0 2007-03-25*/ 2 | .header { 3 | border: thin solid; 4 | text-align:center; 5 | } 6 | .hTitle { 7 | font-family: sans-serif; 8 | font-size: 12pt; 9 | font-weight: bold; 10 | color: Black; 11 | } 12 | .hSubTitle { 13 | font-family: sans-serif; 14 | font-size: 10pt; 15 | font-weight: bold; 16 | color: Black; 17 | } 18 | .hAction, .hProject, .hDate { 19 | font-family: sans-serif; 20 | font-size: 10pt; 21 | font-weight: bold; 22 | color: #43196F; 23 | } 24 | .hFilter { 25 | font-family: sans-serif; 26 | font-size: 10pt; 27 | font-weight: bold; 28 | color: #3CB371; 29 | } 30 | .taskArea { 31 | padding: 10px; 32 | } 33 | 34 | .itemGroup { 35 | border: none; 36 | background-color: #F0F8FF; 37 | } 38 | 39 | .evenTask { 40 | font-family: sans-serif; 41 | font-size: 10pt; 42 | font-weight: normal; 43 | color: #191970; 44 | } 45 | .oddTask { 46 | font-family: sans-serif; 47 | font-size: 10pt; 48 | font-weight: normal; 49 | color: #6F196F; 50 | } 51 | .footer { 52 | border: thin solid; 53 | text-align:center; 54 | font-size: 8pt; 55 | font-weight: normal; 56 | color:black; 57 | } 58 | -------------------------------------------------------------------------------- /ikog.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janosgyerik/gtd-cli-py/ba9859d8fb05ca5997b203e3213024f3ee1e8dce/ikog.pdf -------------------------------------------------------------------------------- /ikog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | # Run the script for details of the licence 5 | # or refer to the notice section later in the file. 6 | #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | #!<^DATA 8 | #!<^CONFIG 9 | cfgColor = 0 10 | cfgAutoSave = True 11 | cfgReviewMode = True 12 | cfgSysCalls = False 13 | cfgEditorNt = "edit" 14 | cfgEditorPosix = "nano,pico,vim,emacs" 15 | cfgShortcuts = ['', '', '', '', '', '', '', '', '', ''] 16 | cfgAbbreviations = {} 17 | cfgPAbbreviations = {} 18 | #!<^CODE 19 | import sys 20 | import os 21 | import re 22 | from datetime import date 23 | from datetime import timedelta 24 | import platform 25 | import urllib 26 | import getpass 27 | from md5 import md5 28 | import struct 29 | import tempfile 30 | from threading import Timer 31 | import stat 32 | 33 | supportAes = True 34 | try: 35 | import pyRijndael 36 | except: 37 | supportAes = False 38 | 39 | try: 40 | import readline 41 | except: 42 | pass 43 | 44 | usePlugin = True 45 | try: 46 | import ikogPlugin 47 | except: 48 | usePlugin = False 49 | 50 | notice = [ 51 | "ikog.py v 1.90 2008-11-14", 52 | "Copyright (C) 2006-2008 S. J. Butler", 53 | "Visit http://www.henspace.co.uk for more information.", 54 | "This program is free software; you can redistribute it and/or modify", 55 | "it under the terms of the GNU General Public Licence as published by", 56 | "the Free Software Foundation; either version 2 of the License, or", 57 | "(at your option) any later version.", 58 | "", 59 | "This program is distributed in the hope that it will be useful,", 60 | "but WITHOUT ANY WARRANTY; without even the implied warranty of", 61 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", 62 | "GNU General Public License for more details. The license is available", 63 | "from http://www.gnu.org/licenses/gpl.txt" 64 | ] 65 | 66 | banner = [ 67 | " _ _ ", 68 | " (_) | | __ ___ __ _", 69 | " | | | |/ / / _ \ / _` |", 70 | " | | | < | (_) | | (_| |", 71 | " |_| |_|\_\ \___/ \__, |", 72 | " _ _ _ |___/", 73 | " (_) | |_ | | __ ___ ___ _ __ ___ ___ _ __", 74 | " | | | __| | |/ / / _ \ / _ \ | '_ \ / __| / _ \ | '_ \ ", 75 | " | | | |_ | < | __/ | __/ | |_) | \__ \ | (_) | | | | |", 76 | " |_| \__| |_|\_\ \___| \___| | .__/ |___/ \___/ |_| |_|", 77 | " |_| _", 78 | " __ _ _ __ ___ __ __ (_) _ __ __ _ ", 79 | " / _` | | '__| / _ \ \ \ /\ / / | | | '_ \ / _` |", 80 | " | (_| | | | | (_) | \ V V / | | | | | | | (_| | _", 81 | " \__, | |_| \___/ \_/\_/ |_| |_| |_| \__, | (_)", 82 | " |___/ |___/", 83 | ] 84 | 85 | 86 | 87 | magicTag = "#!<^" 88 | gMaxLen = 80 89 | try: 90 | ruler = "~".ljust(gMaxLen - 1, "~") 91 | divider = "_".ljust(gMaxLen - 1, "_") 92 | except Exception: 93 | print "Error found. Probably wrong version of Python" 94 | 95 | gReqPythonMajor = 2 96 | gReqPythonMinor = 4 97 | 98 | 99 | def safeRawInput(prompt): 100 | try: 101 | entry = raw_input(prompt) 102 | except: 103 | print "\n" 104 | entry = "" 105 | return entry 106 | 107 | ### global compare function 108 | def compareTodo(a, b): 109 | return cmp(a.getEffectivePriority(), b.getEffectivePriority()) 110 | 111 | def printError(msg): 112 | print gColor.code("error") + "ERROR: " + msg + gColor.code("normal") 113 | 114 | 115 | def clearScreen(useSys = False): 116 | if useSys: 117 | if os.name == "posix": 118 | os.system("clear") 119 | elif os.name in ("dos", "ce", "nt"): 120 | os.system("cls") 121 | print "\n"*25 122 | for l in banner: 123 | print l 124 | 125 | ### XTEA algorithm public domain 126 | class Xtea: 127 | def __init__(self): 128 | pass 129 | 130 | def crypt(self, key,data,iv='\00\00\00\00\00\00\00\00',n=32): 131 | def keygen(key,iv,n): 132 | while True: 133 | iv = self.xtea_encrypt(key,iv,n) 134 | for k in iv: 135 | yield ord(k) 136 | xor = [ chr(x^y) for (x,y) in zip(map(ord,data),keygen(key,iv,n)) ] 137 | return "".join(xor) 138 | 139 | def xtea_encrypt(self, key,block,n=32): 140 | v0,v1 = struct.unpack("!2L",block) 141 | k = struct.unpack("!4L",key) 142 | sum,delta,mask = 0L,0x9e3779b9L,0xffffffffL 143 | for round in range(n): 144 | v0 = (v0 + (((v1<<4 ^ v1>>5) + v1) ^ (sum + k[sum & 3]))) & mask 145 | sum = (sum + delta) & mask 146 | v1 = (v1 + (((v0<<4 ^ v0>>5) + v0) ^ (sum + k[sum>>11 & 3]))) & mask 147 | return struct.pack("!2L",v0,v1) 148 | 149 | class WordWrapper: 150 | def __init__(self, width): 151 | self.width = width 152 | self.nLines = 0 153 | self.pos = 0 154 | 155 | def addLine(self, pos): 156 | self.pos = pos 157 | self.nLines = self.nLines + 1 158 | 159 | def getNLines(self): 160 | return self.nLines 161 | 162 | def intelliLen(self, text): 163 | return len(gColor.stripCodes(text)) 164 | 165 | def wrap(self, text): 166 | self.nLines = 0 167 | formatted = text.replace("
", "\n").replace("
", "\n") 168 | lines = formatted.splitlines() 169 | out = "" 170 | self.pos = 0 171 | for thisline in lines: 172 | newline = True 173 | words = thisline.split() 174 | if self.pos != 0: 175 | out = out + "\n" 176 | self.addLine(0) 177 | for w in words: 178 | wlen = self.intelliLen(w) + 1 179 | if (self.pos + wlen) == self.width: 180 | out = out + " " + w 181 | self.addLine(0) 182 | elif (self.pos + wlen) < self.width: 183 | if newline: 184 | out = out + w 185 | self.pos = wlen 186 | else: 187 | out = out + " " + w 188 | self.pos = self.pos + wlen + 1 189 | else: 190 | out = out + "\n" + w 191 | self.addLine(wlen) 192 | newline = False 193 | return out 194 | 195 | ### Color code class for handling color text output 196 | class ColorCoder: 197 | NONE = -1 198 | ANSI = 0 199 | codes = [{"normal":"\x1b[0;37;40m", 200 | "title":"\x1b[1;32;40m", 201 | "heading":"\x1b[1;35;40m", 202 | "bold":"\x1b[1;35;40m", 203 | "important":"\x1b[1;31;40m", 204 | "error":"\x1b[1;31;40m", 205 | "reverse":"\x1b[0;7m", 206 | "row0":"\x1b[0;35;40m", 207 | "row1":"\x1b[0;36;40m"}, 208 | {"normal":"\x1b[0;37m", 209 | "title":"\x1b[1;32m", 210 | "heading":"\x1b[1;35m", 211 | "bold":"\x1b[1;35m", 212 | "important":"\x1b[1;31m", 213 | "error":"\x1b[1;31m", 214 | "reverse":"\x1b[0;7m", 215 | "row0":"\x1b[0;35m", 216 | "row1":"\x1b[0;36m"}] 217 | 218 | def __init__(self, set): 219 | self.codeSet = self.NONE 220 | self.setCodeSet(set) 221 | 222 | def stripCodes(self, text): 223 | # strip out the ansi codes 224 | ex = re.compile("\x1b\[[0-9;]*m") 225 | return ex.sub("", text) 226 | 227 | def setCodeSet(self, set): 228 | old = self.codeSet 229 | if set < 0: 230 | self.codeSet = self.NONE 231 | elif set < len(self.codes): 232 | self.codeSet = set 233 | return (old != self.codeSet) 234 | 235 | def isValidSet(self, myset): 236 | if myset < len(self.codes): 237 | return True 238 | else: 239 | return False 240 | 241 | def colorSupported(self): 242 | return (os.name == "posix" or os.name == "mac") 243 | 244 | def usingColor(self): 245 | return (self.codeSet <> self.NONE and self.colorSupported()) 246 | 247 | def code(self, type): 248 | if self.codeSet == self.NONE or not self.colorSupported(): 249 | return "" 250 | else: 251 | return self.codes[self.codeSet][type] 252 | 253 | def printCode(self, type): 254 | if self.codeSet != self.NONE: 255 | print self.code(type), 256 | 257 | def getCodeSet(self): 258 | return self.codeSet 259 | 260 | ### Viewer class for paging through multiple lines 261 | class ListViewer: 262 | def __init__(self, maxlines): 263 | self.maxlines = maxlines 264 | 265 | def show(self, list, pause): 266 | count = 0 267 | for line in list: 268 | if count >= self.maxlines or line == pause: 269 | io = safeRawInput("--- Press enter for more. Enter s to skip ---").strip() 270 | print "" 271 | if len(io) > 0 and io.upper()[0] == "S": 272 | break 273 | count = 0 274 | if line != pause: 275 | print line 276 | count = count + 1 277 | 278 | ### Handler for encryption 279 | class Encryptor: 280 | TYPE_OBSCURED = "xtea_" 281 | TYPE_AES = "aes_" 282 | SALT_64 = "1hJ8*gpQ" 283 | 284 | def __init__(self): 285 | self.key = "" 286 | self.encryptionType = self.TYPE_OBSCURED 287 | 288 | def setType(self, codeType): 289 | if codeType == self.TYPE_AES and supportAes == False: 290 | self.encryptionType = self.TYPE_OBSCURED 291 | else: 292 | self.encryptionType = codeType 293 | return self.encryptionType 294 | 295 | def setKey(self, key): 296 | self.key = key 297 | 298 | def getKey(self): 299 | return self.key 300 | 301 | def enterKey(self, prompt1, prompt2): 302 | done = False 303 | while not done: 304 | input1 = getpass.getpass(prompt1 + " >>>") 305 | if prompt2 != "": 306 | input2 = getpass.getpass(prompt2 + " >>>") 307 | if input1 != input2: 308 | print "You must enter the same password. Start again" 309 | else: 310 | done = True 311 | else: 312 | done = True 313 | self.key = input1 314 | return input1 315 | 316 | def complexKey(self): 317 | return md5(self.key).digest() 318 | 319 | def getSecurityClass(self, encrypted): 320 | if encrypted.startswith(self.TYPE_OBSCURED): 321 | return "private xtea" 322 | if encrypted.startswith(self.TYPE_AES): 323 | return "secret aes" 324 | return "unknown" 325 | 326 | def obscure(self, plainText): 327 | key = self.complexKey() 328 | obscured = Xtea().crypt(key, plainText, self.SALT_64) 329 | return self.TYPE_OBSCURED + obscured.encode('hex_codec') 330 | 331 | def unobscure(self, obscured): 332 | plain = "" 333 | data = obscured[len(self.TYPE_OBSCURED):] 334 | data = data.decode('hex_codec') 335 | key = self.complexKey() 336 | plain = Xtea().crypt(key, data, self.SALT_64) 337 | return plain 338 | 339 | def encryptAes(self, plainText): 340 | if len(self.key) < 16: 341 | key = self.complexKey() 342 | else: 343 | key = self.key 344 | obscured = pyRijndael.EncryptData(key, plainText) 345 | return self.TYPE_AES + obscured.encode('hex_codec') 346 | 347 | def decryptAes(self, encrypted): 348 | plain = "" 349 | data = encrypted[len(self.TYPE_AES):] 350 | data = data.decode('hex_codec') 351 | if len(self.key) < 16: 352 | key = self.complexKey() 353 | else: 354 | key = self.key 355 | plain = pyRijndael.DecryptData(key, data) 356 | return plain 357 | 358 | def enterKeyAndEncrypt(self, plainText): 359 | self.enterKey("Enter the master password.", "Re-enter the master password") 360 | return self.encrypt(plainText) 361 | 362 | def encrypt(self, plainText): 363 | if self.encryptionType == self.TYPE_AES: 364 | return self.encryptAes(plainText) 365 | else: 366 | return self.obscure(plainText) 367 | 368 | def enterKeyAndDecrypt(self, encryptedText): 369 | self.enterKey("Enter your master password", "") 370 | return self.decrypt(encryptedText) 371 | 372 | def decrypt(self, encryptedText): 373 | if encryptedText.startswith(self.TYPE_AES): 374 | if not supportAes: 375 | return "You do not have the pyRinjdael module so the text cannot be decrypted." 376 | else: 377 | return self.decryptAes(encryptedText) 378 | else: 379 | return self.unobscure(encryptedText) 380 | 381 | ### Handler for user input 382 | class InputParser: 383 | def __init__(self, prompt): 384 | self.prompt = prompt 385 | 386 | def read(self, entry = ""): 387 | if entry == "": 388 | entry = safeRawInput(self.prompt) 389 | entry = entry.strip() 390 | if entry == "": 391 | command = "" 392 | line = "" 393 | else: 394 | if usePlugin: 395 | entry = ikogPlugin.modifyUserInput(entry) 396 | if entry.find(magicTag) == 0: 397 | printError("You cannot begin lines with the sequence " + magicTag) 398 | command = "" 399 | line = "" 400 | elif entry.find(TodoItem.ENCRYPTION_MARKER) >= 0: 401 | printError ("You cannot use the special sequence " + TodoItem.ENCRYPTION_MARKER) 402 | command = "" 403 | line = "" 404 | else: 405 | n = entry.find(" ") 406 | if n >= 0: 407 | command = entry[:n] 408 | line = entry[n + 1:] 409 | else: 410 | command = entry 411 | line = "" 412 | 413 | return (command, line) 414 | 415 | class EditorLauncher: 416 | WARNING_TEXT = "# Do not enter secret or private information!" 417 | def __init__(self): 418 | pass 419 | 420 | def edit(self, text): 421 | ed = "" 422 | terminator = "\n" 423 | if os.name == "posix": 424 | ed = cfgEditorPosix 425 | elif os.name == "nt": 426 | ed = cfgEditorNt 427 | terminator = "\r\n" 428 | if ed == "": 429 | printError("Sorry, but external editing not supported on " + os.name.upper()) 430 | success = False 431 | else: 432 | fname = self.makeFile(text, terminator) 433 | if fname == "": 434 | printError("Unable to create temporary file.") 435 | else: 436 | success = self.run(ed, fname) 437 | if success: 438 | (success, text) = self.readFile(fname) 439 | if text == self.orgText: 440 | print("No changes made."); 441 | success = False 442 | self.scrubFile(fname) 443 | if success: 444 | return text 445 | else: 446 | return "" 447 | 448 | def scrubFile(self, fname): 449 | try: 450 | os.remove(fname) 451 | except Exception, e: 452 | printError("Failed to remove file " + fname + ". If you entered any private data you should delete this file yourself.") 453 | 454 | def readFile(self, fname): 455 | success = False 456 | try: 457 | fh = open(fname, "rt") 458 | line = fh.readline() 459 | text = "" 460 | first = True 461 | while line != "": 462 | thisLine = self.safeString(line) 463 | if thisLine != self.WARNING_TEXT: 464 | if not first: 465 | text = text + "
" 466 | text = text + thisLine 467 | first = False 468 | line = fh.readline() 469 | fh.close() 470 | success = True 471 | except Exception, e: 472 | printError("Error reading the edited text. " + str(e)) 473 | return (success, text) 474 | 475 | def safeString(self, text): 476 | return text.replace("\r","").replace("\n","") 477 | 478 | def makeFile(self, text, terminator): 479 | fname = "" 480 | (fh, fname) = tempfile.mkstemp(".tmpikog","ikog") 481 | fout = os.fdopen(fh,"wt") 482 | text = text.replace("
", "
") 483 | self.orgText = text 484 | lines = text.split("
") 485 | fout.write(self.WARNING_TEXT + terminator) 486 | for thisline in lines: 487 | fout.write(self.safeString(thisline) + terminator) 488 | fout.close() 489 | return fname 490 | 491 | def run(self, program, file): 492 | progs = program.split(",") 493 | for prog in progs: 494 | success = self.runProgram(prog.strip(), file) 495 | if success: 496 | break; 497 | return success 498 | 499 | def runProgram(self, program, file): 500 | success = False 501 | if os.name == "posix": 502 | try: 503 | progarg = program 504 | os.spawnlp(os.P_WAIT, program, progarg, file) 505 | success = True 506 | except os.error: 507 | pass 508 | except Exception, e: 509 | printError(str(e)) 510 | elif os.name == "nt": 511 | if file.find(" ") >= 0: 512 | file = "\"" + file + "\"" 513 | for path in os.environ["PATH"].split(os.pathsep): 514 | try: 515 | prog = os.path.join(path, program) 516 | if prog.find(" ") >= 0: 517 | progarg = "\"" + prog + "\"" 518 | else: 519 | progarg = prog 520 | os.spawnl(os.P_WAIT, prog, progarg, file) 521 | success = True 522 | if success: 523 | break 524 | except os.error: 525 | pass 526 | except Exception, e: 527 | printError(str(e)) 528 | return success 529 | 530 | 531 | ### The main todo list 532 | class TodoList: 533 | quickCard = ["Quick reference card:", 534 | "? ADD/A/+ text FILTER/FI [filter]", 535 | "HELP/H IMMEDIATE/I/++ text TOP/T [N]", 536 | "COLOR/COLOUR/C [N] KILL/K/X/- N NEXT/N", 537 | "MONOCHROME/MONO CLEAR PREV/P", 538 | "EXPORT REP/R N [text] GO/G N", 539 | "IMPORT file MOD/M N [text] LIST/L [filter]", 540 | "REVIEW/REV ON/OFF EXTEND/E N [text] LIST>/L> [filter]", 541 | "V0 EDIT/ED [N] @", 542 | "V1 SUB/SU N /s1/s2/ :D", 543 | "WEB FIRST/F N :P>", 544 | "SAVE/S DOWN/D N @>", 545 | "AUTOSAVE/AS ON|OFF UP/U N :D>", 546 | "VER/VERSION NOTE/NOTES text :P>", 547 | "CLEARSCREEN/CLS O/OPEN file SHOW N", 548 | "SYS ON|OFF NEW file SETEDxx editor", 549 | "!CMD command 2 ABBREV/AB @x @full", 550 | "ABBREV/AB ? PAB ? PAB :px :pfull", 551 | "SHORTCUT/SC N cmd SHORTCUT/SC ? =N", 552 | "ARCHIVE/DONE N [text]", 553 | ] 554 | 555 | help = [ "", 556 | "Introduction", 557 | "------------", 558 | "The program is designed to help manage tasks using techniques", 559 | "such as Getting Things Done by David Allen. Check out", 560 | "http://www.henspace.co.uk for more information and detailed help.", 561 | "To use the program, simply enter the task at the prompt.", 562 | "All of the commands are displayed in the next section.", 563 | "!PAUSE!", 564 | "COMMANDS", 565 | "--------", 566 | "Commands that have more than one method of entry are shown separated by /", 567 | "e.g HELP/H means that you can enter either HELP or an H.", 568 | "All commands can be entered in upper or lower case.", 569 | "Items shown in square brackets are optional.", 570 | "Items shown separated by the | symbol are alternatives. e.g ON|OFF means", 571 | "you should type either ON or OFF.", 572 | "Note that some commands refer to adding tasks to the top or bottom of the", 573 | "list. However the task's position in the list is also determined by its.", 574 | "priority. So, for example, adding a task to the top will still not allow", 575 | "it to precede tasks that have been assigned a higher priority number. ", 576 | "!PAUSE!", 577 | "GENERAL COMMANDS", 578 | "----------------", 579 | "? : displays a quick reference card", 580 | "HELP/H : displays this help.", 581 | "VERSION/VER : display the version.", 582 | "WEB : Go to the website for more information", 583 | "CLEARSCREEN/CLS : Clear the screen", 584 | "COLOR/COLOUR/C [N] : Use colour display (not Windows) N=1 for no background", 585 | "MONOCHROME/MONO : Use monochrome display", 586 | "EXPORT : Export the tasks only to filename.tasks.txt", 587 | "IMPORT file : Import tasks from the file", 588 | "REVIEW/REV ON|OFF : If on, hitting enter moves to the next task", 589 | " : If off, enter re-displays the current task", 590 | "V0 : Same as REVIEW OFF", 591 | "V1 : Same as REVIEW ON", 592 | "SAVE/S : Save the tasks", 593 | "O/OPEN file : Open a new data file.", 594 | "NEW file : Create a new data file.", 595 | "AUTOSAVE/AS ON|OFF : Switch autosave on or off", 596 | "SYS ON|OFF : Allow the program to use system calls.", 597 | "!CMD command : Run a system command.", 598 | "2 : Start a two minute timer (for GTD)", 599 | "QUIT/Q : quit the program", 600 | "!PAUSE!", 601 | "TASK ENTRY AND EDITING COMMANDS", 602 | "-------------------------------", 603 | "For the editing commands that require a task number, you can", 604 | "replace N by '^' or 'this' to refer to the current task.", 605 | "ADD/A/+ the task : add a task to the bottom of the list.", 606 | " : Entering any line that does not begin with", 607 | " : a valid command and which is greater than 10", 608 | " : characters long is also assumed to be an addition.", 609 | "EDIT/ED [N] : Create task, or edit task N, using external editor.", 610 | "SUB/SU N /s1/s2/ : Replace text s1 with s2 in task N. Use \/ if you", 611 | " : need to include the / character.", 612 | "NOTE/NOTES text : shorthand for ADD #0 @Notes text", 613 | "IMMEDIATE/I/++ : add a task to the top of the list to do today.", 614 | "REP/R N [text] : replace task N", 615 | "MOD/M N [text] : modify task N.", 616 | "EXTEND/E N [text] : add more text to task N", 617 | "FIRST/F N : move task N to the top.", 618 | "DOWN/D/ N : move task N down the queue", 619 | "UP/U/ N : move task N up the queue", 620 | "!PAUSE!", 621 | "TASK REMOVAL COMMANDS", 622 | "---------------------", 623 | "KILL/K/X/- N : kill (delete) task N. You must define N", 624 | "DONE N [text] : Remove task N and move to an archive file", 625 | "ARCHIVE N [text] : Same as DONE", 626 | "CLEAR : Remove all tasks", 627 | "!PAUSE!", 628 | "DISPLAY COMMANDS", 629 | "----------------", 630 | "SHOW N : display encrypted text for task N", 631 | "FILTER/FI [filter] : set a filter. Applies to all displays", 632 | " : See list for details of the filter", 633 | " : Setting the filter to nothing clears it.", 634 | "TOP/T [N] : Go to top, list N tasks, and display the top task", 635 | "NEXT/N : display the next task. Same as just hitting enter", 636 | "PREV/P : display previous task", 637 | "GO/G N : display task N", 638 | "LIST/L [filter] : list tasks. Filter = context, project, priority, date", 639 | " : or word. Contexts begin with @ and projects with :p", 640 | " : Dates begin with :d, anything else is a search word.", 641 | " : Precede term with - to exclude e.g. -@Computer", 642 | " : e.g LIST @computer or LIST #5", 643 | "@ : sorted list by Context.", 644 | ":D : sorted list by Dates", 645 | ":P : sorted list by Projects", 646 | "LIST>/L> [filter] : standard list sent to an HTML report", 647 | "@> : sorted list by Context sent to an HTML report", 648 | ":D> : sorted list by Dates sent to an HTML report", 649 | ":P> : sorted list by Projects sent to an HTML report", 650 | " : The HTML reports are sent to todoFilename.html", 651 | "!PAUSE!", 652 | "ADVANCED OPTIONS", 653 | "----------------", 654 | "The SETEDxxx commands allow you to use an external editor.", 655 | "Note the editor you pick should be a simple text editor. If you pick", 656 | "something that doesn't work, try the defaults again.", 657 | "Because some systems may have different editors installed, you can set", 658 | "more than one by separating the editors usng commas. The program will", 659 | "use the first one it finds.", 660 | "For Windows the default is edit, which works quite well in the terminal", 661 | "but you could change it to notepad.", 662 | "For Linux, the default is nano,pico,vim,emacs.", 663 | "To use external editors you must switch on system calls using the SYS ON", 664 | "command", 665 | "SETEDNT command : Set the external editor for Windows (NT).", 666 | "SETEDPOSIX command : Set the editor for posix systems.", 667 | " : e.g. SETEDNT edit", 668 | " : SETEDPOSIX nano,vim", 669 | "SHORTCUT/SC ? : list shortcuts", 670 | "SHORTCUT/SC N cmd : Set shortcut N to command cmd", 671 | "=N : Run shortcut N", 672 | "!PAUSE!", 673 | "ABBREV/AB @x @full : Create new abbreviation. @x expands to @full", 674 | "ABBREV/AB ? : List context abbreviations.", 675 | "PAB :px :pfull : Project abbreviation. :px expands to :pfull", 676 | "PAB ? : List project abbreviations.", 677 | "!PAUSE!", 678 | "ENTERING TASKS", 679 | "--------------", 680 | "When you enter a task, you can embed any number of contexts in the task.", 681 | "You can also embed a project description by preceding it with :p", 682 | "You can assign a priority by preceding a number by #. e.g. #9.", 683 | "If you don't enter a number, a default of 5 is used. The higher the ", 684 | "number the more important it is. Priorities range from 1 to 10.", 685 | "Only the first # is used for the priority so you can use # as", 686 | "a normal character as long as you precede it with a priority number.", 687 | "You can define a date when the task must be done by preceding the date", 688 | "with :d, i.e :dYYYY/MM/DD or :dMM/DD or :dDD. If you omit the year/month", 689 | "they default to the current date. Adding a date automatically creates an", 690 | "@Date context for the task.", 691 | "So, for example, to add a new task to e-mail Joe, we could enter:", 692 | "+ e-mail joe @computer", 693 | "or to add a task to the decorating project, we could enter:", 694 | "+ buy wallpaper :pdecorating", 695 | "to enter a task with an importance of 9 we could enter:", 696 | "+ book that holiday #9 @Internet", 697 | "!PAUSE!", 698 | "MODIFYING AND EXTENDING TASKS", 699 | "-----------------------------", 700 | "The modify command allows you to change part of an existing task.", 701 | "So for example, imagine you have a task:", 702 | "[05] Buy some food #9 @Internet Projects:Shopping", 703 | "Enter the command M 5 and then type:", 704 | "@C", 705 | "Because the only element we have entered is a new context, only", 706 | "that part is modified, so we get.", 707 | "[05] Buy some food #9 @Computer Projects:Shopping", 708 | "Likewise, had we entered:", 709 | "Buy some tea :pEating", 710 | "We would have got", 711 | "[05] Buy some tea #9 @Internet Projects:Eating", 712 | "The extend command is similar but it appends the entry. So had", 713 | "we used the command E 5 instead of M 5 the result would have been", 714 | "[05] Buy some food ... Buy some tea #9 @Internet Projects:Eating", 715 | "!PAUSE!", 716 | "CONTEXTS", 717 | "--------", 718 | "Any word preceded by @ will be used as a context. Contexts are like", 719 | "sub-categories or sub-lists. There are a number of pre-defined", 720 | "abbreviations that you can use as well. The recognised abbreviations", 721 | "are:", 722 | "@A = @Anywhere (this is the default)", 723 | "@C = @Computer", 724 | "@D = @Desk", 725 | "@E = @Errands", 726 | "@H = @Home", 727 | "@I = @Internet", 728 | "@L = @Lunch", 729 | "@M = @Meeting", 730 | "@N = @Next", 731 | "@O = @Other", 732 | "@P = @Phone", 733 | "@PW= @Password", 734 | "@S = @Someday/maybe", 735 | "@W4= @Waiting_for", 736 | "@W = @Work", 737 | "!PAUSE!", 738 | "ENTERING DATES", 739 | "--------------", 740 | "An @Date context is created if you embed a date in the task.", 741 | "Dates are embedded using the :dDATE format.", 742 | "Valid DATE formats are yyyy-mm-dd, mm-dd or dd", 743 | "You can also use : or / as the separators. So, for example:", 744 | ":d2006/12/22 or :d2006-11-7 or :d9/28 are all valid entries.", 745 | "", 746 | "If you set a date, then until that date is reached, the task is given", 747 | "an effective priority of 0. Once the date is reached, the task's", 748 | "priority is increased by 11, moving it to the of the list.", 749 | "", 750 | "A date entry of :d0 can be used to clear a date entry.", 751 | "A date entry of :d+X can be used to create a date entry of today + X days.", 752 | "So :d+1 is tomorrow and :d+0 is today.", 753 | "!PAUSE!", 754 | "ENCRYPTING TEXT", 755 | "---------------", 756 | "If you want to encrypt text you can use the or tags or", 757 | "their abbreviations

and .", 758 | "These tags will result in all text following the tag to be encrypted.", 759 | "Note that any special commands, @contexts for example, are treated as plain", 760 | "text in the encrypted portion.", 761 | "To display the text you will need to use the SHOW command.", 762 | "", 763 | "The tag uses the inbuilt XTEA algorithm. This is supposedly a", 764 | "relatively secure method but probably not suitable for very sensitive data.", 765 | "", 766 | "The tag can only be used if you have the pyRijndael.py module.", 767 | "This uses a 256 bit Rinjdael cipher. The module can be downloaded from ", 768 | "http://jclement.ca/software/pyrijndael/", 769 | "You can install this in your Python path or just place it alongside your", 770 | "ikog file.", 771 | "Note you cannot use the extend command with encrypted text.", 772 | "", 773 | "!PAUSE!", 774 | "MARKING TASKS AS COMPLETE", 775 | "-------------------------", 776 | "The normal way to mark a task as complete is just to remove it using the", 777 | "KILL command. If you want to keep track of tasks you have finished, you", 778 | "can use the ARCHIVE or DONE command. This gives the task an @Archived", 779 | "context, changes the date to today and then moves it from the current", 780 | "file to a file with archive.dat appended. The archive file is a valid", 781 | "ikog file so you can use the OPEN command to view it, edit it and run", 782 | "reports in the normal way. So assuming your current script is ikog.py,", 783 | "to archive the current task you could enter:", 784 | "", 785 | "ARCHIVE ^ I have finished this", 786 | "", 787 | "This would move the task to a file called ikog.py.archive.dat", 788 | "", 789 | "!PAUSE!", 790 | "USING EXTERNAL DATA", 791 | "-------------------", 792 | "Normally the tasks are embedded in the main program file so all you have", 793 | "to carry around with you is the ikog.py file. The advantage is that you", 794 | "only have one file to look after; the disadvantage is that every time you", 795 | "save a task you have to save the program as well. If you want, you can", 796 | "keep your tasks in a separate file.", 797 | "To do this, use the EXPORT function to create a file ikog.py.tasks.txt", 798 | "Use the CLEAR command to remove the tasks from your main ikog.py program.", 799 | "Rename the exported file from ikog.py.tasks.txt to ikog.py.dat", 800 | "Ikog will now use this file for storing your tasks.", 801 | "", 802 | "!PAUSE!", 803 | "PASSING TASKS VIA THE COMMAND LINE", 804 | "----------------------------------", 805 | "It is possible to add tasks via the command line. The general format of", 806 | "the command line is:", 807 | " ikog.py filename commands", 808 | "The filename is the name of the data file containing your tasks. You", 809 | "can use . to represent the default internal tasks.", 810 | "Commands is a set of normal ikog commands separated by the / ", 811 | "character. Note there must be a space either side of the /.", 812 | "So to add a task and then exit the program we could just enter:", 813 | " ikog.py . + here is my task / QUIT", 814 | "Note that we added the quit command to exit ikog.", 815 | "You must make sure that you do not use any commands that require user", 816 | "input. Deleting tasks via the command line is more complicated as you", 817 | "need to find the task automatically. If you do try to delete this way,", 818 | "use the filter command to find some unique text and then delete it. eg.", 819 | " ikog.py . FI my_unique_text / KILL THIS / QUIT", 820 | "Use THIS instead of ^ as a caret has a special meaning in Windows.", 821 | "If you do intend automating ikog from the command line, you should add", 822 | "a unique reference to each task so you can find it later using FILTER. eg.", 823 | "+ this is my task ref_1256", 824 | "!PAUSE!"] 825 | 826 | MOVE_DOWN = 0 827 | MOVE_UP = 1 828 | MOVE_TOP = 2 829 | MAX_SHORTCUTS = 10 830 | 831 | def __init__(self, todoFile, externalDataFile): 832 | self.setShortcuts() 833 | self.dirty = False 834 | self.code = [] 835 | self.todo = [] 836 | self.autoSave = True 837 | self.review = True 838 | self.sysCalls = False 839 | self.currentTask = 0 840 | self.globalFilterText = "" 841 | self.globalFilters = [] 842 | self.localFilterText = "" 843 | self.localFilters = [] 844 | # split the file into the source code and the todo list 845 | self.filename = todoFile 846 | try: 847 | self.filename = os.readlink(todoFile) 848 | except Exception: 849 | pass # probably windows 850 | externalDataFile = self.makeFilename(externalDataFile) 851 | self.externalData = self.findDataSource(externalDataFile) 852 | if self.externalData: 853 | self.filename = externalDataFile 854 | else: 855 | self.splitFile(self.filename, False) 856 | self.exactPriority = False 857 | self.htmlFile = "" 858 | 859 | def setPAbbreviation(self, line): 860 | save = False 861 | elements = line.split(" ", 1) 862 | if not elements[0].lower().startswith(":p"): 863 | self.showError("Project abbreviations must begin with :p") 864 | elif len(elements) > 1: 865 | if not elements[1].lower().startswith(":p"): 866 | abb = ":p" + elements[1].title() 867 | else: 868 | abb = ":p" +elements[1][2:].title() 869 | globalPAbbr.addAbbreviation(elements[0], abb) 870 | save = True 871 | else: 872 | if not globalPAbbr.removeAbbreviation(elements[0]): 873 | self.showError("Could not find project abbreviation " + line) 874 | else: 875 | print "Project abbreviation ", line, " removed." 876 | save = True 877 | return save 878 | 879 | def showPAbbreviations(self): 880 | print globalPAbbr.toStringVerbose() 881 | 882 | def setAbbreviation(self, line): 883 | save = False 884 | elements = line.split(" ", 1) 885 | if not elements[0].startswith("@"): 886 | self.showError("Abbreviations must begin with @") 887 | elif len(elements) > 1: 888 | if not elements[1].startswith("@"): 889 | abb = "@" + elements[1].title() 890 | else: 891 | abb = "@" +elements[1][1:].title() 892 | globalAbbr.addAbbreviation(elements[0], abb) 893 | save = True 894 | else: 895 | if not globalAbbr.removeAbbreviation(elements[0]): 896 | self.showError("Could not find abbreviation " + line) 897 | else: 898 | print "Abbreviation ", line, " removed." 899 | save = True 900 | return save 901 | 902 | def showAbbreviations(self): 903 | print globalAbbr.toStringVerbose() 904 | 905 | def setShortcut(self, line, force = False): 906 | elements = line.split(" ", 1) 907 | try: 908 | index = int(elements[0]) 909 | if len(elements) > 1: 910 | command = elements[1] 911 | else: 912 | command = "" 913 | except Exception, e: 914 | self.showError("Did not understand the command. Format should be SHORTCUT N my command.") 915 | return False 916 | 917 | if index < 0 or index > len(self.shortcuts): 918 | self.showError("The maximum number of shortcuts is " + str(len(self.shortcuts)) + ". Shortcuts ignored.") 919 | return False 920 | else: 921 | if self.shortcuts[index] != "" and not force: 922 | if safeRawInput("Do you want to change the current command '" + self.shortcuts[index] + "'? Enter Yes to overwrite. >>>").upper() != "YES": 923 | return False 924 | self.shortcuts[index] = command 925 | return True 926 | 927 | 928 | def showShortcuts(self): 929 | index = 0 930 | for s in self.shortcuts: 931 | if s == "": 932 | msg = "unused" 933 | else: 934 | msg = s 935 | print "=%1d %s" %(index, msg) 936 | index = index + 1 937 | 938 | def setShortcuts(self, settings = []): 939 | if len(settings) > self.MAX_SHORTCUTS: 940 | self.showError("The maximum number of shortcuts is " + str(self.MAX_SHORTCUTS) + ". Shortcuts ignored.") 941 | self.shortcuts = ["" for n in range(self.MAX_SHORTCUTS)] 942 | if len(settings) > 0: 943 | self.shortcuts[0:len(settings)] = settings 944 | 945 | def getShortcutIndex(self, command): 946 | if len(command) == 2 and command[0:1].upper() == "=": 947 | index = ord(command[1]) - ord("0") 948 | if index >= self.MAX_SHORTCUTS: 949 | index = -1 950 | else: 951 | index = -1 952 | return index 953 | 954 | def getShortcut(self, command): 955 | index = self.getShortcutIndex(command) 956 | if index >= 0: 957 | return self.shortcuts[index] 958 | else: 959 | return "" 960 | 961 | def safeSystemCall(self, line): 962 | words = line.split() 963 | if len(words) == 0: 964 | self.showError("Nothing to do.") 965 | elif words[0].upper() == "RM" or words[0].upper() == "RMDIR" or words[0].upper() == "DEL": 966 | self.showError("Sorry, but deletion commands are not permitted.") 967 | else: 968 | os.system(line) 969 | self.pause() 970 | 971 | def processCfgLine(self, line): 972 | params = line.split("=") 973 | if len(params) < 2: 974 | return 975 | cmd = params[0].strip() 976 | if cmd == "cfgEditorNt": 977 | global cfgEditorNt 978 | cfgEditorNt = params[1].replace("\"", "").strip() 979 | elif cmd == "cfgEditorPosix": 980 | global cfgEditorPosix 981 | cfgEditorPosix = params[1].replace("\"", "").strip() 982 | elif cmd == "cfgShortcuts": 983 | elements = params[1].strip()[1:-1].split(",") 984 | index = 0 985 | for e in elements: 986 | self.setShortcut(str(index) + " " + e.strip()[1:-1], True) 987 | index = index + 1 988 | elif cmd == "cfgAutoSave": 989 | if params[1].upper().strip() == "TRUE": 990 | asave = True 991 | else: 992 | asave = False 993 | self.setAutoSave(asave, False) 994 | elif cmd == "cfgReviewMode": 995 | if params[1].upper().strip() == "TRUE": 996 | self.setReview("ON") 997 | else: 998 | self.setReview("OFF") 999 | elif cmd == "cfgSysCalls": 1000 | if params[1].upper().strip() == "TRUE": 1001 | self.setSysCalls("ON") 1002 | else: 1003 | self.setSysCalls("OFF") 1004 | elif cmd == "cfgColor": 1005 | gColor.setCodeSet(int(params[1].strip())) 1006 | elif cmd == "cfgAbbreviations": 1007 | abbrs = eval(params[1].strip()) 1008 | globalAbbr.setAbbreviations(abbrs) 1009 | elif cmd == "cfgPAbbreviations": 1010 | abbrs = eval(params[1].strip()) 1011 | globalPAbbr.setAbbreviations(abbrs) 1012 | else: 1013 | self.showError("Unrecognised command " + cmd) 1014 | 1015 | def makeFilename(self, name): 1016 | (root, ext) = os.path.splitext(name) 1017 | if ext.upper() != ".DAT": 1018 | name = name + ".dat" 1019 | try: 1020 | name = os.path.expanduser(name) 1021 | except Exception, e: 1022 | self.showError("Failed to expand path. " + str(e)) 1023 | return name 1024 | 1025 | def findDataSource(self, filename): 1026 | success = False 1027 | 1028 | try: 1029 | self.splitFile(filename, False) 1030 | print "Using external data file ", filename 1031 | success = True 1032 | except IOError: 1033 | print "No external data file ", filename, ", so using internal tasks." 1034 | return success 1035 | 1036 | def setSysCalls(self, mode): 1037 | oldCalls = self.sysCalls 1038 | mode = mode.strip().upper() 1039 | if mode == "ON": 1040 | self.sysCalls = True 1041 | print "Using system calls for clear screen" 1042 | elif mode == "OFF": 1043 | self.sysCalls = False 1044 | print "No system calls for clear screen" 1045 | else: 1046 | self.showError("Could not understand the sys command. Use SYS ON or OFF.") 1047 | return (self.sysCalls != oldCalls) 1048 | 1049 | def setAutoSave(self, asave, save): 1050 | if asave: 1051 | if self.autoSave == False: 1052 | self.autoSave = True 1053 | if save: 1054 | self.save("") 1055 | elif self.autoSave == True: 1056 | self.autoSave = False 1057 | if save: 1058 | self.save("") 1059 | if self.autoSave: 1060 | print "Autosave is on." 1061 | else: 1062 | print "Autosave is off." 1063 | 1064 | 1065 | def showError(self, msg): 1066 | printError(msg) 1067 | 1068 | def pause(self, prompt = "Press enter to continue."): 1069 | if safeRawInput(prompt).strip() != "": 1070 | print "Entry ignored!" 1071 | 1072 | def setReview(self, mode): 1073 | oldReview = self.review 1074 | mode = mode.strip().upper() 1075 | if mode == "ON": 1076 | self.review = True 1077 | print "In review mode. Enter advances to the next task" 1078 | elif mode == "OFF": 1079 | self.review = False 1080 | print "Review mode off. Enter re-displays the current task" 1081 | else: 1082 | self.showError("Could not understand the review command. Use REVIEW ON or OFF.") 1083 | return (self.review != oldReview) 1084 | 1085 | def sortByPriority(self): 1086 | self.todo.sort(key=TodoItem.getEffectivePriority, reverse = True) 1087 | 1088 | 1089 | def run(self, commandList): 1090 | if not supportAes: 1091 | print "AES encryption not available." 1092 | print("\nEnter HELP for instructions.") 1093 | 1094 | done = False 1095 | printCurrent = True 1096 | self.sortByPriority() 1097 | reopen = "" 1098 | enteredLine = "" 1099 | truncateTask = False 1100 | while not done: 1101 | self.checkCurrentTask() 1102 | if printCurrent: 1103 | self.moveToVisible() 1104 | print ruler 1105 | if truncateTask: 1106 | self.printItemTruncated(self.currentTask, "Current: ") 1107 | else: 1108 | self.printItemVerbose(self.currentTask) 1109 | print ruler 1110 | printCurrent= True 1111 | truncateTask = False 1112 | if self.dirty: 1113 | prompt = "!>>" 1114 | else: 1115 | prompt = ">>>" 1116 | if len(commandList) >= 1: 1117 | enteredLine = commandList[0] 1118 | commandList = commandList[1:] 1119 | print enteredLine 1120 | (rawcommand, line) = InputParser(prompt).read(enteredLine) 1121 | enteredLine = "" 1122 | command = rawcommand.upper() 1123 | if self.getShortcutIndex(command) >= 0: 1124 | sc = self.getShortcut(command) 1125 | if sc != "": 1126 | (rawcommand, line) = InputParser("").read(self.getShortcut(command)) 1127 | else: 1128 | rawcommand = "" 1129 | line = "" 1130 | continue 1131 | print "Shortcut: ", rawcommand, " ", line 1132 | command = rawcommand.upper() 1133 | if command == "": 1134 | if self.review: 1135 | self.incTaskLoop() 1136 | elif command == "PAB": 1137 | if line.strip() == "?": 1138 | self.showPAbbreviations() 1139 | elif self.setPAbbreviation(line): 1140 | self.save("") 1141 | elif command == "ABBREV" or command == "AB": 1142 | if line.strip() == "?": 1143 | self.showAbbreviations() 1144 | elif self.setAbbreviation(line): 1145 | self.save("") 1146 | elif command == "SHORTCUT" or command == "SC": 1147 | if line.strip() == "?": 1148 | self.showShortcuts() 1149 | else: 1150 | if self.setShortcut(line): 1151 | self.save("") 1152 | printCurrent = False 1153 | elif command == "2": 1154 | enteredLine = self.runTimer(2) 1155 | printCurrent = False 1156 | elif command == "CLS" or command == "CLEARSCREEN": 1157 | clearScreen(self.sysCalls) 1158 | elif command == "SETEDNT": 1159 | global cfgEditorNt 1160 | cfgEditorNt = line 1161 | self.save("") 1162 | elif command == "SETEDPOSIX": 1163 | global cfgEditorPosix 1164 | cfgEditorPosix = line 1165 | self.save("") 1166 | elif command == "SYS": 1167 | if self.setSysCalls(line): 1168 | self.save("") 1169 | elif command == "!CMD": 1170 | if self.sysCalls: 1171 | self.safeSystemCall(line) 1172 | else: 1173 | self.showError("System calls are not allowed. Use SYS ON to enable them.") 1174 | elif command == "SHOW" or command == "SH": 1175 | self.decrypt(line) 1176 | self.pause("Press enter to clear screen and continue. ") 1177 | clearScreen(self.sysCalls) 1178 | elif command == "VERSION" or command == "VER": 1179 | print notice[0] 1180 | elif command == "SAVE" or command == "S": 1181 | if not self.dirty: 1182 | print "There's no need to save now. If the prompt shows >>> " 1183 | print "then there is nothing to save. You only need to save if the prompt " 1184 | print "shows !>>" 1185 | else: 1186 | self.forceSave("") 1187 | elif command == "NEW": 1188 | filename = self.makeFilename(line) 1189 | if self.createFile(filename): 1190 | reopen = filename 1191 | if self.dirty: 1192 | self.forceSave("") 1193 | done = True 1194 | printCurrent = False 1195 | elif command == "OPEN" or command == "O": 1196 | filename = self.makeFilename(line) 1197 | reopen = filename 1198 | if self.dirty: 1199 | self.forceSave("") 1200 | done = True 1201 | printCurrent = False 1202 | elif command == "AUTOSAVE" or command == "AS": 1203 | if line== "": 1204 | self.showError("You must enter ON or OFF for the autosave command") 1205 | else: 1206 | self.setAutoSave(line.upper() == "ON", True) 1207 | elif command == "REVIEW" or command == "REV": 1208 | if self.setReview(line): 1209 | self.save("") 1210 | elif command == "V0": 1211 | if self.setReview("OFF"): 1212 | self.save("") 1213 | elif command == "V1": 1214 | if self.setReview("ON"): 1215 | self.save("") 1216 | elif command == "?": 1217 | self.printHelp(self.quickCard) 1218 | elif command == "HELP" or command == "H": 1219 | self.printHelp(self.help) 1220 | elif command == "QUIT" or command == "Q": 1221 | if self.dirty: 1222 | self.forceSave("") 1223 | done = True 1224 | printCurrent = False 1225 | elif command == "WEB": 1226 | try: 1227 | webbrowser.open("http://www.henspace.co.uk") 1228 | except Exception, e: 1229 | self.showError("Unable to launch browser. " + str(e)) 1230 | elif command == "COLOR" or command == "COLOUR" or command == "C": 1231 | try: 1232 | set = int(line, 10) 1233 | except ValueError: 1234 | set = gColor.ANSI 1235 | if not gColor.isValidSet(set): 1236 | self.showError("Invalid colour set ignored.") 1237 | elif gColor.setCodeSet(set): 1238 | self.save("") 1239 | elif command == "MONOCHROME" or command == "MONO": 1240 | if gColor.setCodeSet(gColor.NONE): 1241 | self.save("") 1242 | elif command == "EXPORT": 1243 | self.exportTasks() 1244 | elif command == "IMPORT": 1245 | if self.importTasks(line): 1246 | self.save("") 1247 | elif command == "CLEAR" and line == "": 1248 | if self.clear(): 1249 | self.save("") 1250 | elif command == "FILTER" or command == "FI" or command == "=": 1251 | self.setFilterArray(False, line) 1252 | elif command == "NEXT" or command == "N": 1253 | self.incTaskLoop() 1254 | elif command == "PREV" or command == "P": 1255 | self.decTaskLoop() 1256 | elif command == "TOP" or command == "T" or command == "0": 1257 | self.currentTask = 0 1258 | if line != "": 1259 | self.setFilterArray(True, "") 1260 | self.showLocalFilter() 1261 | self.printShortList(line) 1262 | truncateTask = True 1263 | elif command == "GO" or command == "G": 1264 | self.moveTo(line) 1265 | elif command == "IMMEDIATE" or command == "I" or command == "++": 1266 | newItem = self.createItem(":d+0 " + line) 1267 | if newItem.hasHiddenTask(): 1268 | clearScreen(self.sysCalls) 1269 | if newItem.hasError(): 1270 | print "Errors were found:" 1271 | print newItem.getError() 1272 | print "The task was not added." 1273 | printCurrent = False 1274 | else: 1275 | self.todo.insert(0, newItem) 1276 | self.currentTask = 0 1277 | self.sortByPriority() 1278 | self.save("") 1279 | elif command == "KILL" or command == "K" or command == "-" or command == "X": 1280 | if self.removeTask(line): 1281 | self.save("") 1282 | elif command == "ARCHIVE" or command == "DONE": 1283 | if self.archiveTask(line): 1284 | self.save("") 1285 | elif command == "REP" or command =="R": 1286 | if self.modifyTask(line, TodoItem.REPLACE): 1287 | self.sortByPriority() 1288 | self.save("") 1289 | else: 1290 | printCurrent = False 1291 | elif command == "SUB" or command == "SU": 1292 | if self.substituteText(line): 1293 | self.sortByPriority() 1294 | self.save("") 1295 | elif command == "EDIT" or command == "ED": 1296 | if not self.sysCalls: 1297 | self.showError("External editing needs to use system calls. Use SYS ON to enable them.") 1298 | elif line == "": 1299 | self.addTaskExternal() 1300 | elif self.modifyTask(line, TodoItem.MODIFY, externalEditor = True): 1301 | self.sortByPriority() 1302 | self.save("") 1303 | else: 1304 | printCurrent = False 1305 | elif command == "MOD" or command == "M": 1306 | if self.modifyTask(line, TodoItem.MODIFY): 1307 | self.sortByPriority() 1308 | self.save("") 1309 | else: 1310 | printCurrent = False 1311 | elif command == "EXTEND" or command == "E": 1312 | if self.modifyTask(line, TodoItem.APPEND): 1313 | self.sortByPriority() 1314 | self.save("") 1315 | else: 1316 | printCurrent = False 1317 | elif command == "FIRST" or command == "F": 1318 | if self.moveTask(line, self.MOVE_TOP): 1319 | self.sortByPriority() 1320 | self.save("") 1321 | self.currentTask = 0 1322 | elif command == "DOWN" or command == "D": 1323 | if self.moveTask(line, self.MOVE_DOWN): 1324 | self.sortByPriority() 1325 | self.save("") 1326 | elif command == "UP" or command == "U": 1327 | if self.moveTask(line, self.MOVE_UP): 1328 | self.sortByPriority() 1329 | self.save("") 1330 | elif command == "LIST" or command == "L": 1331 | print ruler 1332 | self.setFilterArray(True, line) 1333 | self.showLocalFilter() 1334 | self.printList(False, "", "") 1335 | self.clearFilterArray(True) 1336 | print ruler 1337 | truncateTask = True 1338 | elif command == "LIST>" or command == "L>": 1339 | self.startHtml("") 1340 | self.setFilterArray(True, line) 1341 | self.showLocalFilter() 1342 | self.printList(False, "", "") 1343 | self.clearFilterArray(True) 1344 | self.endHtml() 1345 | elif command == "@": 1346 | self.listByAction() 1347 | truncateTask = True 1348 | elif command == ":P": 1349 | self.listByProject() 1350 | truncateTask = True 1351 | elif command == ":D": 1352 | self.listByDate() 1353 | truncateTask = True 1354 | elif command == "@>": 1355 | self.startHtml("Report by Context") 1356 | self.listByAction() 1357 | self.endHtml() 1358 | elif command == ":P>": 1359 | self.startHtml("Report by Project") 1360 | self.listByProject() 1361 | self.endHtml() 1362 | elif command == ":D>": 1363 | self.startHtml("Report by Date") 1364 | self.listByDate() 1365 | self.endHtml() 1366 | elif command == "ADD" or command == "A" or command == "+": 1367 | self.addTask(line) 1368 | elif command == "NOTE" or command == "NOTES": 1369 | self.addTask("#0 @Notes " + line) 1370 | elif (len(command) + len(line)) > 10: 1371 | self.addTask(rawcommand + " " + line) 1372 | elif len(command) > 0: 1373 | self.showError("Didn't understand. (Make sure you have a space after the command or your entry is longer than 10 characters)") 1374 | printCurrent = False 1375 | return reopen 1376 | 1377 | def timeout(self): 1378 | self.timerActive = False 1379 | clearScreen() 1380 | print "\n\x07Timer\x07 complete.\x07\n\x07Press enter to continue.\x07" 1381 | 1382 | def runTimer(self, delay): 1383 | self.timerActive = True 1384 | t = Timer(delay * 60 , self.timeout) 1385 | t.start() 1386 | s = raw_input(str(delay) + " minute timer running.\nAny entry will cancel the timer:\n>>>") 1387 | if self.timerActive: 1388 | t.cancel() 1389 | print "Timer cancelled." 1390 | elif s != "": 1391 | s = "" 1392 | print "Input discarded as timer has finished." 1393 | return s.strip() 1394 | 1395 | def addTaskExternal(self): 1396 | exEdit = EditorLauncher() 1397 | entry = exEdit.edit("") 1398 | if entry != "": 1399 | self.addTask(entry) 1400 | else: 1401 | self.showError("Nothing to add") 1402 | 1403 | def addTask(self, line): 1404 | newItem = self.createItem(line) 1405 | if newItem.hasError(): 1406 | print "Errors were found:" 1407 | print newItem.getError() 1408 | print "The task was not added." 1409 | printCurrent = False 1410 | else: 1411 | if newItem.hasHiddenTask(): 1412 | clearScreen(self.sysCalls) 1413 | self.todo.append(newItem) 1414 | self.sortByPriority() 1415 | self.save("") 1416 | 1417 | def checkCurrentTask(self): 1418 | if self.currentTask > len(self.todo) - 1: 1419 | self.currentTask = len(self.todo) - 1 1420 | if self.currentTask < 0: 1421 | self.currentTask = 0 1422 | 1423 | def writeArchive(self, item): 1424 | success = False 1425 | filename = self.filename + ".archive.dat" 1426 | try: 1427 | if not os.path.exists(filename): 1428 | f = open(filename,"wb") 1429 | f.write("# " + notice[0] + "\n") 1430 | f.write(magicTag + "DATA\n") 1431 | else: 1432 | f = open(filename,"a+b") 1433 | 1434 | f.write(item.toString()) 1435 | f.write("\n") 1436 | f.close() 1437 | print "Tasks archived to " + filename 1438 | success = True 1439 | except Exception, e: 1440 | self.showError("Error trying to archive the tasks.\n" + str(e)) 1441 | return success 1442 | 1443 | def exportTasks(self): 1444 | filename = self.filename + ".tasks.txt" 1445 | try: 1446 | f = open(filename,"wb") 1447 | f.write("# " + notice[0] + "\n") 1448 | f.write(magicTag + "DATA\n") 1449 | for item in self.todo: 1450 | f.write(item.toString()) 1451 | f.write("\n") 1452 | f.close() 1453 | print "Tasks exported to " + filename 1454 | except Exception, e: 1455 | self.showError("Error trying to export the file.\n" + str(e)) 1456 | 1457 | def importTasks(self, filename): 1458 | success = False 1459 | orgNTasks = len(self.todo) 1460 | if filename == "": 1461 | self.showError("You must supply the name of the file to import.") 1462 | return success 1463 | 1464 | try: 1465 | self.splitFile(filename, True) 1466 | if len(self.todo) == orgNTasks: 1467 | self.showError("Failed to find any tasks to import.") 1468 | else: 1469 | success = True 1470 | except Exception, e: 1471 | self.showError("Error importing tasks. " + str(e)) 1472 | return success 1473 | 1474 | def createFile(self, filename): 1475 | success = False 1476 | if os.path.exists(filename): 1477 | self.showError("Sorry but " + filename + " already exists.") 1478 | else: 1479 | try: 1480 | f = open(filename, "wb") 1481 | f.write("#!/usr/bin/env python\n") 1482 | f.write("#" + ruler + "\n") 1483 | f.close() 1484 | success = True 1485 | except Exception, e: 1486 | self.showError("Error trying to create the file " + filename + ". " + str(e)) 1487 | return success 1488 | 1489 | def save(self, filename): 1490 | if filename != "" or self.autoSave: 1491 | self.forceSave(filename) 1492 | else: 1493 | self.dirty = True 1494 | print "Autosave is off, so changes not saved yet." 1495 | 1496 | def forceSave(self, filename): 1497 | if filename == "": 1498 | filename = self.filename 1499 | tmpFilename = filename + ".tmp" 1500 | backupFilename = filename + ".bak" 1501 | success = False 1502 | try: 1503 | f = open(tmpFilename,"wb") 1504 | f.write("#!/usr/bin/env python\n") 1505 | f.write("# -*- coding: utf-8 -*-\n") 1506 | f.write("#" + ruler + "\n") 1507 | f.write("# Run the script for details of the licence\n") 1508 | f.write("# or refer to the notice section later in the file.\n") 1509 | f.write("#" + ruler + "\n") 1510 | f.write(magicTag + "DATA\n") 1511 | for item in self.todo: 1512 | f.write(item.toString()) 1513 | f.write("\n") 1514 | f.write(magicTag + "CONFIG\n") 1515 | f.write("cfgColor = " + str(gColor.getCodeSet()) + "\n") 1516 | f.write("cfgAutoSave = " + str(self.autoSave) + "\n") 1517 | f.write("cfgReviewMode = " + str(self.review) + "\n") 1518 | f.write("cfgSysCalls = " + str(self.sysCalls) + "\n") 1519 | f.write("cfgEditorNt = \"" + cfgEditorNt + "\"\n") 1520 | f.write("cfgEditorPosix = \"" + cfgEditorPosix + "\"\n") 1521 | f.write("cfgShortcuts = " + str(self.shortcuts) + "\n") 1522 | f.write("cfgAbbreviations = " +str(globalAbbr.toString()) +"\n") 1523 | f.write("cfgPAbbreviations = " +str(globalPAbbr.toString()) +"\n") 1524 | f.write(magicTag + "CODE\n") 1525 | for codeline in self.code: 1526 | f.write(codeline.rstrip()) 1527 | f.write("\n") 1528 | f.close() 1529 | success = True 1530 | 1531 | except Exception, e: 1532 | self.showError("Error trying to save the file.\n" + str(e)) 1533 | if success: 1534 | try: 1535 | os.remove(backupFilename) 1536 | except Exception: 1537 | pass 1538 | try: 1539 | oldstat = os.stat(filename) 1540 | os.rename(filename, backupFilename) 1541 | os.rename(tmpFilename, filename) 1542 | os.chmod(filename, stat.S_IMODE(oldstat.st_mode)) # ensure permissions carried over 1543 | self.filename = filename 1544 | self.dirty = False 1545 | print "Tasks saved." 1546 | except Exception, e: 1547 | self.showError("Error trying to rename the backups.\n" + str(e)) 1548 | 1549 | def moveTo(self, indexStr): 1550 | try: 1551 | index = int(indexStr, 10) 1552 | if index < 0 or index > len(self.todo) - 1: 1553 | self.showError("Sorry but there is no task " + indexStr) 1554 | else: 1555 | if not self.isViewable(self.todo[index]): 1556 | print "Switching off your filter so that the task can be displayed." 1557 | self.clearFilterArray(False) 1558 | self.currentTask = index 1559 | except ValueError: 1560 | self.showError("Unable to understand the task " + indexStr + " you want to show.") 1561 | 1562 | 1563 | def moveToVisible(self): 1564 | start = self.currentTask 1565 | find = True 1566 | if start < 0 or start >= len(self.todo): 1567 | return 1568 | while not self.isViewable(self.todo[self.currentTask]): 1569 | self.incTaskLoop() 1570 | if self.currentTask == start: 1571 | print "Nothing matched your filter. Removing your filter so that the current task can be displayed." 1572 | self.clearFilterArray(False) 1573 | break 1574 | 1575 | def decrypt(self, indexStr): 1576 | index = self.getRequiredTask(indexStr) 1577 | if index < 0 or index > len(self.todo) - 1: 1578 | self.showError("Sorry but there is no task " + indexStr + " to show.") 1579 | elif self.todo[index].hasHiddenTask(): 1580 | ec = Encryptor() 1581 | print WordWrapper(gMaxLen).wrap(ec.enterKeyAndDecrypt(self.todo[index].getHiddenTask())) 1582 | else: 1583 | print "Task ", index, " has no encrypted data." 1584 | 1585 | def moveTask(self, indexStr, where): 1586 | success = False 1587 | if indexStr == "": 1588 | print "You must supply the number of the task to move." 1589 | return False 1590 | try: 1591 | index = self.getRequiredTask(indexStr) 1592 | if index < 0 or index > len(self.todo) - 1: 1593 | self.showError("Sorry but there is no task " + indexStr + " to move.") 1594 | elif where == self.MOVE_DOWN: 1595 | if index <= len(self.todo) - 2: 1596 | item = self.todo[index] 1597 | self.todo[index] = self.todo[index + 1] 1598 | self.todo[index + 1] = item 1599 | print "Task ", index, " moved down." 1600 | success = True 1601 | else: 1602 | self.showError("Task " + str(index) + " is already at the bottom.") 1603 | else: 1604 | if index > 0: 1605 | if where == self.MOVE_TOP: 1606 | self.todo.insert(0, self.todo.pop(index)) 1607 | else: 1608 | dest = index - 1 1609 | item = self.todo[dest] 1610 | self.todo[dest] = self.todo[index] 1611 | self.todo[index] = item 1612 | print "Task ", index, " moved up." 1613 | success = True 1614 | else: 1615 | self.showError("Task " + str(index) + " is already at the top.") 1616 | 1617 | 1618 | except ValueError: 1619 | self.showError("Unable to understand the task " + indexStr + " you want to move.") 1620 | 1621 | return success 1622 | 1623 | def clear(self): 1624 | cleared = False 1625 | if safeRawInput("Are you really sure you want to remove everything? Yes or No? >>>").upper() != "YES": 1626 | print("Nothing has been removed.") 1627 | else: 1628 | del self.todo[0:] 1629 | self.currentTask = 0 1630 | cleared = True 1631 | return cleared 1632 | 1633 | def getRequiredTask(self, indexStr): 1634 | if indexStr == "^" or indexStr.upper() == "THIS": 1635 | index = self.currentTask 1636 | else: 1637 | try: 1638 | index = int(indexStr, 10) 1639 | except ValueError: 1640 | index = -1 1641 | return index 1642 | 1643 | def archiveTask(self, indexStr): 1644 | doit = False 1645 | line = indexStr.split(" ", 1) 1646 | if len(line) > 1: 1647 | indexStr = line[0] 1648 | entry = line[1] 1649 | else: 1650 | entry = "" 1651 | index = self.getRequiredTask(indexStr) 1652 | if index < 0 or index > len(self.todo) - 1: 1653 | self.showError("Sorry but there is no task " + indexStr + " to mark as done and archive.") 1654 | else: 1655 | if indexStr == "^" or indexStr.upper() == "THIS": 1656 | doit = True 1657 | else: 1658 | print "Are you sure you want to archive: ' " + self.todo[index].toStringSimple() + "'" 1659 | if safeRawInput("Enter Yes to archive this task? >>>").upper() == "YES": 1660 | doit = True 1661 | if doit: 1662 | newItem = self.createItem(":d+0") 1663 | self.todo[index].copy(newItem, TodoItem.MODIFY) 1664 | newItem = self.createItem(entry + " @Archived") 1665 | self.todo[index].copy(newItem, TodoItem.APPEND) 1666 | if self.writeArchive(self.todo[index]): 1667 | self.todo[index:index + 1] = [] 1668 | print "Task ", index, " has been archived." 1669 | else: 1670 | doit = False 1671 | print "Task ", index, " marked as archived but not removed." 1672 | else: 1673 | print "Task ", index, " has not been archived." 1674 | return doit 1675 | 1676 | def removeTask(self, indexStr): 1677 | doit = False 1678 | index = self.getRequiredTask(indexStr) 1679 | if index < 0 or index > len(self.todo) - 1: 1680 | self.showError("Sorry but there is no task " + indexStr + " to delete.") 1681 | else: 1682 | if indexStr == "^" or indexStr.upper() == "THIS": 1683 | doit = True 1684 | else: 1685 | print "Are you sure you want to remove ' " + self.todo[index].toStringSimple() + "'" 1686 | if safeRawInput("Enter Yes to delete this task? >>>").upper() == "YES": 1687 | doit = True 1688 | if doit: 1689 | self.todo[index:index + 1] = [] 1690 | print "Task ", index, " has been removed." 1691 | else: 1692 | print "Task ", index, " has not been removed." 1693 | return doit 1694 | 1695 | def substituteText(self, indexStr): 1696 | line = indexStr.split(" ", 1) 1697 | if len(line) > 1: 1698 | indexStr = line[0] 1699 | entry = line[1] 1700 | else: 1701 | self.showError("You need to define the task and substitution phrases. e.g SUB 0 /old/new/") 1702 | return False 1703 | 1704 | 1705 | success = False 1706 | if indexStr == "": 1707 | print "You must supply the number of the task to change." 1708 | return False 1709 | 1710 | index = self.getRequiredTask(indexStr) 1711 | 1712 | if index < 0 or index > len(self.todo) - 1: 1713 | self.showError("Sorry but there is no task " + indexStr) 1714 | else: 1715 | text = entry.replace("/", "\n") 1716 | text = text.replace("\\\n","/") 1717 | phrases = text.split("\n") 1718 | if len(phrases) != 4: 1719 | self.showError("The format of the command is incorrect. The substitution phrases should be /s1/s2/ ") 1720 | return False 1721 | oldText = self.todo[index].getTask() 1722 | newText = oldText.replace(phrases[1], phrases[2]) 1723 | if newText == oldText: 1724 | self.showError("Nothing has changed.") 1725 | return False 1726 | newItem = self.createItem(newText) 1727 | if newItem.hasError(): 1728 | print "With the substitution the task had errors:" 1729 | print newItem.getError() 1730 | print "Task ", index, " is unchanged." 1731 | else: 1732 | if newItem.hasHiddenTask(): 1733 | clearScreen(self.sysCalls) 1734 | self.showError("It isn't possible to create private or secret data by using the substitition command.") 1735 | else: 1736 | self.todo[index].copy(newItem, TodoItem.MODIFY) 1737 | print "Task ", index, " has been changed." 1738 | success = True 1739 | return success 1740 | 1741 | 1742 | def modifyTask(self, indexStr, replace, externalEditor = False): 1743 | line = indexStr.split(" ", 1) 1744 | if len(line) > 1: 1745 | indexStr = line[0] 1746 | entry = line[1] 1747 | else: 1748 | entry = "" 1749 | 1750 | success = False 1751 | if indexStr == "": 1752 | print "You must supply the number of the task to change." 1753 | return 1754 | 1755 | index = self.getRequiredTask(indexStr) 1756 | 1757 | if index < 0 or index > len(self.todo) - 1: 1758 | self.showError("Sorry but there is no task " + indexStr) 1759 | else: 1760 | if entry == "": 1761 | if externalEditor: 1762 | exEdit = EditorLauncher() 1763 | (key, entry) = self.todo[index].toStringEditable() 1764 | entry = exEdit.edit(entry) 1765 | else: 1766 | if replace == TodoItem.REPLACE: 1767 | print "This task will completely replace the existing entry," 1768 | print "including any projects and actions." 1769 | elif replace == TodoItem.MODIFY: 1770 | print "Only the elements you add will be replaced. So, for example," 1771 | print "if you don't enter any projects the original projects will remain." 1772 | else: 1773 | print "Elements you enter will be appended to the current task" 1774 | entry = safeRawInput("Enter new details >>>") 1775 | if entry != "": 1776 | if replace == TodoItem.APPEND: 1777 | newItem = self.createItem(entry, password="unused") # we will discard the encrypted part on extend 1778 | elif externalEditor: 1779 | newItem = self.createItem(entry, password = key) 1780 | else: 1781 | newItem = self.createItem(entry) 1782 | if newItem.hasHiddenTask(): 1783 | clearScreen(self.sysCalls) 1784 | if newItem.hasError(): 1785 | print "The task had errors:" 1786 | print newItem.getError() 1787 | print "Task ", index, " is unchanged." 1788 | else: 1789 | if newItem.hasHiddenTask() and replace == TodoItem.APPEND: 1790 | self.showError("It isn't possible to extend the encrypted part of a task.\nThis part is ignored.") 1791 | self.todo[index].copy(newItem, replace) 1792 | print "Task ", index, " has been changed." 1793 | success = True 1794 | else: 1795 | print "Task ", index, " has not been touched." 1796 | return success 1797 | 1798 | def incTask(self): 1799 | if self.currentTask < len(self.todo) - 1: 1800 | self.currentTask = self.currentTask + 1 1801 | 1802 | def incTaskLoop(self): 1803 | if self.currentTask < len(self.todo) - 1: 1804 | self.currentTask = self.currentTask + 1 1805 | else: 1806 | self.currentTask = 0 1807 | def decTask(self): 1808 | if self.currentTask > 0: 1809 | self.currentTask = self.currentTask - 1 1810 | 1811 | def decTaskLoop(self): 1812 | if self.currentTask > 0: 1813 | self.currentTask = self.currentTask - 1 1814 | else: 1815 | self.currentTask = len(self.todo) - 1 1816 | 1817 | def printItemTruncated(self, index, leader): 1818 | if len(self.todo) < 1: 1819 | print leader, "no tasks" 1820 | else: 1821 | scrnline = leader + "[%02d] %s" % (index, self.todo[index].toStringSimple()) 1822 | if usePlugin: 1823 | print ikogPlugin.modifyShortOutput(scrnline) 1824 | elif len(scrnline) > gMaxLen: 1825 | print scrnline[0:gMaxLen - 3] + "..." 1826 | else: 1827 | print scrnline 1828 | 1829 | 1830 | def printItem(self, index, colorType): 1831 | if len(self.todo) < 1: 1832 | self.output("There are no tasks to be done.\n", 0) 1833 | nlines = 1 1834 | else: 1835 | wrapper = WordWrapper(gMaxLen) 1836 | scrnline = wrapper.wrap("[%02d] %s" % (index, self.todo[index].toStringSimple())) 1837 | if colorType == "row0": 1838 | style = "class=\"evenTask\"" 1839 | else: 1840 | style = "class=\"oddTask\"" 1841 | self.output("

[%02d] %s
\n" % (style, index, self.todo[index].toStringSimple()), 1842 | gColor.code(colorType) + scrnline + gColor.code("normal") + "\n" ) 1843 | nlines = wrapper.getNLines() 1844 | return nlines 1845 | 1846 | def printItemVerbose(self, index): 1847 | if len(self.todo) < 1: 1848 | print "There are no tasks to be done." 1849 | else: 1850 | self.showFilter() 1851 | wrapper = WordWrapper(gMaxLen) 1852 | scrnline = wrapper.wrap("[%02d] %s" % (index, self.todo[index].toStringVerbose())) 1853 | if usePlugin: 1854 | print ikogPlugin.modifyVerboseOutput(scrnline) 1855 | else: 1856 | print scrnline 1857 | 1858 | def clearFilterArray(self, local): 1859 | if local: 1860 | self.localFilters = [] 1861 | self.localFilterText = "" 1862 | else: 1863 | self.globalFilters = [] 1864 | self.globalFilterText = "" 1865 | 1866 | def setFilterArray(self, local, requiredFilter): 1867 | filters = requiredFilter.split() 1868 | if local: 1869 | destination = self.localFilters 1870 | else: 1871 | destination = self.globalFilters 1872 | destination[:] = [] 1873 | humanVersion = "" 1874 | for word in filters: 1875 | if word[0:1] == "-": 1876 | invert = True 1877 | word = word[1:] 1878 | else: 1879 | invert = False 1880 | if word[0:2].upper() == ":D" and len(word) > 2: 1881 | filter = ":D" + TodoItem("").parseDate(word[2:].strip(), False) 1882 | elif word[0:2].lower() == ":p": 1883 | filter = globalPAbbr.expandProject(word) 1884 | else: 1885 | filter = globalAbbr.expandAction(word) 1886 | if invert: 1887 | filter = "-" + filter 1888 | destination.append(filter) 1889 | if humanVersion != "": 1890 | humanVersion = humanVersion + " " + filter 1891 | else: 1892 | humanVersion = filter 1893 | if local: 1894 | for filter in self.globalFilters: 1895 | destination.append(filter) 1896 | if humanVersion != "": 1897 | humanVersion = humanVersion + " " + filter 1898 | else: 1899 | humanVersion = filter 1900 | if local: 1901 | self.localFilterText = humanVersion 1902 | else: 1903 | self.globalFilterText = humanVersion 1904 | 1905 | def isViewable(self, item): 1906 | if len(self.globalFilters) == 0 and len(self.localFilters) == 0: 1907 | return True 1908 | overallView = True 1909 | ored = False 1910 | if len(self.localFilters) > 0: 1911 | filterArray = self.localFilters 1912 | else: 1913 | filterArray = self.globalFilters 1914 | if "or" in filterArray or "OR" in filterArray: 1915 | fast = False 1916 | else: 1917 | fast = True 1918 | for filter in filterArray: 1919 | if filter.upper() == "OR": 1920 | ored = True 1921 | continue 1922 | view = False 1923 | usePriority = False 1924 | mustHave = False 1925 | if filter[0:1] == "+": 1926 | filter = filter[1:] 1927 | mustHave = True 1928 | if filter[0:1] == "-": 1929 | invert = True 1930 | filter = filter[1:] 1931 | else: 1932 | invert = False 1933 | try: 1934 | if filter[0:1] == "#": 1935 | priority = int(filter[1:], 10) 1936 | usePriority = True 1937 | except ValueError: 1938 | priority = 0 1939 | if usePriority: 1940 | if self.exactPriority: 1941 | if item.hasPriority(priority): 1942 | view = True 1943 | elif item.hasPriorityOrAbove(priority): 1944 | view = True 1945 | elif filter[0:2].upper() == ":D": 1946 | if item.hasDate(filter[2:]): 1947 | view = True 1948 | elif filter[0:2].upper() == ":P": 1949 | view = item.hasProject(filter) 1950 | elif filter[0:1].upper() == "@": 1951 | view = item.hasAction(filter) 1952 | elif item.hasWord(filter): 1953 | view = True 1954 | if invert: 1955 | view = (view != True) 1956 | if ored: 1957 | if view == True: 1958 | overallView = True 1959 | break 1960 | else: 1961 | if view == False: 1962 | overallView = False 1963 | if fast or mustHave: 1964 | break 1965 | ored = False 1966 | return overallView 1967 | 1968 | def listByAction(self): 1969 | index = SearchIndex() 1970 | for item in self.todo: 1971 | index.addCollection(item.getActions()) 1972 | index.sort() 1973 | (n, value) = index.getFirstItem() 1974 | print ruler 1975 | self.showFilter() 1976 | while n >= 0: 1977 | if not gColor.usingColor() and n > 0: 1978 | div = True 1979 | else: 1980 | div = False 1981 | self.setFilterArray(True, "+" + value) 1982 | self.printList(div, "

" + value + "

\n", gColor.code("title") + "\n" + value + "\n" + gColor.code("title")) 1983 | self.clearFilterArray(True) 1984 | (n, value) = index.getNextItem(n) 1985 | print ruler 1986 | 1987 | def listByProject(self): 1988 | index = SearchIndex() 1989 | for item in self.todo: 1990 | index.addCollection(item.getProjects()) 1991 | index.sort() 1992 | (n, value) = index.getFirstItem() 1993 | print ruler 1994 | self.showFilter() 1995 | while n >= 0: 1996 | if not gColor.usingColor() and n > 0: 1997 | div = True 1998 | else: 1999 | div = False 2000 | self.setFilterArray(True, "+:p" + value) 2001 | self.printList(div, "

Project: " + value + "

\n", gColor.code("title") + "\nProject: " + value + "\n" + gColor.code("normal")) 2002 | self.clearFilterArray(True) 2003 | (n, value) = index.getNextItem(n) 2004 | print ruler 2005 | 2006 | def listByDate(self): 2007 | index = SearchIndex() 2008 | for item in self.todo: 2009 | index.add(item.getDate()) 2010 | index.sort() 2011 | (n, value) = index.getFirstItem() 2012 | print ruler 2013 | self.showFilter() 2014 | while n >= 0: 2015 | if not gColor.usingColor() and n > 0: 2016 | div = True 2017 | else: 2018 | div = False 2019 | self.setFilterArray(True, "+:D" + value) 2020 | self.printList(div, "

Date: " + value + "

\n", gColor.code("title") + "\nDate: " + value + "\n" + gColor.code("normal")) 2021 | self.clearFilterArray(True) 2022 | (n, value) = index.getNextItem(n) 2023 | print ruler 2024 | 2025 | 2026 | def showFilter(self): 2027 | if self.globalFilterText != "": 2028 | self.output("

Filter = " + self.globalFilterText + "

\n", 2029 | gColor.code("bold") + "Filter = " + self.globalFilterText + "\n" + gColor.code("normal")) 2030 | 2031 | def showLocalFilter(self): 2032 | if self.localFilterText != "": 2033 | self.output("

Filter = " + self.localFilterText + "

\n", 2034 | gColor.code("bold") + "Filter = " + self.localFilterText + "\n" + gColor.code("normal")) 2035 | 2036 | def printList(self, div, outHtml, outStd): 2037 | self.doPrintList(-1, div, outHtml, outStd) 2038 | 2039 | def printShortList(self, line): 2040 | count = 0 2041 | try: 2042 | count = int(line, 10) 2043 | except ValueError: 2044 | self.showError("Didn't understand the number of tasks you wanted listed.") 2045 | self.doPrintList(count, False, "", "") 2046 | 2047 | def doPrintList(self, limitItems, div, outHtml, outStd): 2048 | n = 0 2049 | displayed = 0 2050 | count = 0 2051 | color = "row0" 2052 | first = True 2053 | maxlines = 20 2054 | if outHtml != "": 2055 | self.outputHtml("
\n") 2056 | for item in self.todo: 2057 | if self.isViewable(item): 2058 | if first: 2059 | if div: 2060 | print divider 2061 | self.output(outHtml, outStd) 2062 | if not gColor.usingColor() and not first: 2063 | print divider 2064 | count = count + 1 2065 | count = count + self.printItem(n, color) 2066 | first = False 2067 | if color == "row0": 2068 | color = "row1" 2069 | else: 2070 | color = "row0" 2071 | displayed = displayed + 1 2072 | n = n + 1 2073 | if limitItems >= 0 and displayed >= limitItems: 2074 | break 2075 | if count >= maxlines: 2076 | if self.htmlFile == "": 2077 | msg = safeRawInput("---press Enter for more. Enter s to skip: ") 2078 | if len(msg) > 0 and msg.strip().upper()[0] == "S": 2079 | break; 2080 | count = 0 2081 | if outHtml != "": 2082 | self.outputHtml("
\n") 2083 | 2084 | def printHelp(self, lines): 2085 | ListViewer(24).show(lines,"!PAUSE!") 2086 | 2087 | def splitFile(self, filename, dataOnly): 2088 | inData = False 2089 | inCode = False 2090 | inCfg = False 2091 | f = open(filename, 'r') 2092 | line = f.readline() 2093 | if line[0:2] == "#!": 2094 | line = f.readline() 2095 | while line != "": 2096 | if line.find(magicTag + "DATA") == 0: 2097 | inData = True 2098 | inCode = False 2099 | inCfg = False 2100 | elif line.find(magicTag + "CONFIG") == 0: 2101 | inData = False 2102 | inCode = False 2103 | inCfg = True 2104 | elif line.find(magicTag + "CODE") == 0: 2105 | inCode = True 2106 | inData = False 2107 | inCfg = False 2108 | if dataOnly: 2109 | break 2110 | elif inCode: 2111 | self.code.append(line) 2112 | elif inCfg: 2113 | self.processCfgLine(line) 2114 | elif inData: 2115 | line = line.strip() 2116 | if len(line) > 0 and line[0] == "#": 2117 | line = line[1:].strip() 2118 | if len(line) > 0: 2119 | newItem = self.createItem(line) 2120 | newItem.getError() 2121 | self.todo.append(newItem) 2122 | 2123 | line = f.readline() 2124 | f.close() 2125 | 2126 | def createItem(self, line, password = ""): 2127 | item = TodoItem(line, password) 2128 | return item 2129 | 2130 | def outputHtml(self, html): 2131 | if self.htmlFile != "": 2132 | if usePlugin: 2133 | self.htmlFile.write(ikogPlugin.modifyFileOutputHtml(html)) 2134 | else: 2135 | self.htmlFile.write(html) 2136 | 2137 | def output(self, html, stdout): 2138 | if self.htmlFile != "": 2139 | #self.htmlFile.write(html.replace("\n", "
\n")) 2140 | if usePlugin: 2141 | self.htmlFile.write(ikogPlugin.modifyFileOutput(html)) 2142 | else: 2143 | self.htmlFile.write(html) 2144 | if stdout == 0: 2145 | if usePlugin: 2146 | print ikogPlugin.modifyOutput(html), 2147 | else: 2148 | print html, 2149 | else: 2150 | if usePlugin: 2151 | print ikogPlugin.modifyOutput(stdout), 2152 | else: 2153 | print stdout, 2154 | 2155 | def startHtml(self, title): 2156 | htmlFilename = self.filename + ".html" 2157 | try: 2158 | printHeader = True 2159 | self.htmlFile = open(htmlFilename, "w") 2160 | if usePlugin: 2161 | printHeader = ikogPlugin.showHeader() 2162 | if printHeader: 2163 | self.htmlFile.write("\n") 2164 | self.htmlFile.write("\n") 2165 | self.htmlFile.write("\n\n") 2166 | self.htmlFile.write("\n") 2169 | self.htmlFile.write("\n") 2170 | self.htmlFile.write("\n\n") 2171 | self.htmlFile.write("
\n") 2172 | self.htmlFile.write("

iKog Todo List

\n") 2173 | self.htmlFile.write("

" + title + " printed " + date.today().isoformat() + "

\n") 2174 | self.htmlFile.write("
\n") 2175 | self.htmlFile.write("
\n") 2176 | if usePlugin: 2177 | self.htmlFile.write(ikogPlugin.postHtmlHeader()) 2178 | except Exception: 2179 | print "Failed to create output file:", htmlFilename 2180 | self.htmlFile = "" 2181 | 2182 | def endHtml(self): 2183 | name = self.htmlFile.name 2184 | success = False 2185 | try: 2186 | printFooter = True 2187 | if usePlugin: 2188 | self.htmlFile.write(ikogPlugin.preHtmlFooter()) 2189 | printFooter = ikogPlugin.showFooter() 2190 | if printFooter: 2191 | self.htmlFile.write("
\n") 2192 | self.htmlFile.write("
\n") 2193 | self.htmlFile.write("--- end of todo list ---
\n") 2194 | self.htmlFile.write("Created using " + notice[0] + "\n
" + notice[1] + "
\n") 2195 | self.htmlFile.write("
\n") 2196 | 2197 | self.htmlFile.write("\n\n") 2198 | self.htmlFile.close() 2199 | self.htmlFile = "" 2200 | print "HTML file " + name + " created." 2201 | success = True 2202 | except Exception, e: 2203 | self.showError("Error writing to file. " + str(e)) 2204 | 2205 | if success: 2206 | try: 2207 | safeName = os.path.abspath(name).replace("\\","/") 2208 | safeName = "file://" + urllib.quote(safeName," /:") 2209 | webbrowser.open(safeName) 2210 | except Exception, e: 2211 | self.showError("Unable to launch html output. " + str(e)) 2212 | 2213 | class Abbreviations: 2214 | def __init__(self, project = False): 2215 | self.default(project) 2216 | 2217 | def default(self,project): 2218 | if project: 2219 | self.abbrevs = {} 2220 | else: 2221 | self.abbrevs = {"@A":"@Anywhere","@C":"@Computer", 2222 | "@D":"@Desk", "@E": "@Errands", 2223 | "@H":"@Home", "@I":"@Internet","@L":"@Lunch", "@M":"@Meeting", "@N":"@Next", 2224 | "@P":"@Phone", "@Pw":"@Password", "@S":"@Someday/Maybe", 2225 | "@O":"@Other", "@W4":"@Waiting_For", "@W":"@Work"} 2226 | 2227 | 2228 | def setAbbreviations(self, abbr): 2229 | self.abbrevs.update(abbr) 2230 | 2231 | def addAbbreviation(self, key, word): 2232 | self.abbrevs.update({key.title():word}) 2233 | 2234 | def removeAbbreviation(self, key): 2235 | key = key.title() 2236 | if self.abbrevs.has_key(key): 2237 | del self.abbrevs[key] 2238 | return True 2239 | return False 2240 | 2241 | def expandAction(self, action): 2242 | if action[0:1] != "@": 2243 | return action 2244 | 2245 | action = action.title() 2246 | if self.abbrevs.has_key(action): 2247 | return self.abbrevs[action] 2248 | return action 2249 | 2250 | def expandProject(self, project): 2251 | if not project.lower().startswith(":p"): 2252 | return project 2253 | project = project.title() 2254 | if self.abbrevs.has_key(project): 2255 | return self.abbrevs[project] 2256 | return project 2257 | 2258 | def toString(self): 2259 | return str(self.abbrevs) 2260 | 2261 | def toStringVerbose(self): 2262 | output = "" 2263 | index = 0 2264 | for key in self.abbrevs: 2265 | output = output + key.ljust(5) + " = " + self.abbrevs[key].ljust(30) 2266 | index = index + 1 2267 | if index % 2 == 0: 2268 | output = output + "\n" 2269 | if index % 2 != 0: 2270 | output = output + "\n" 2271 | return output 2272 | 2273 | class SearchIndex: 2274 | def __init__(self): 2275 | self.items = [] 2276 | 2277 | def add(self, ent): 2278 | if ent != "" and not ent in self.items: 2279 | self.items.append(ent) 2280 | 2281 | def addCollection(self, collection): 2282 | for ent in collection: 2283 | if ent != "" and not ent in self.items: 2284 | self.items.append(ent) 2285 | def sort(self): 2286 | self.items.sort() 2287 | 2288 | def getFirstItem(self): 2289 | if len(self.items) > 0: 2290 | return (0, self.items[0]) 2291 | else: 2292 | return (-1, "") 2293 | 2294 | def getNextItem(self, count): 2295 | count = count + 1 2296 | if count > len(self.items) - 1: 2297 | return (-1, "") 2298 | else: 2299 | return (count, self.items[count]) 2300 | return 2301 | 2302 | class TodoItem: 2303 | ENCRYPTION_MARKER = "{}--xx" 2304 | REPLACE = 0 2305 | MODIFY = 1 2306 | APPEND = 2 2307 | NOT_DUE_PRIORITY = 0 2308 | DEFAULT_PRIORITY = 5 2309 | OVERDUE_PRIORITY = 11 2310 | MEETING_PRIORITY = 10 2311 | def __init__(self,line, password = ""): 2312 | self.actions = [] 2313 | self.task = "" 2314 | self.hiddenTask = "" 2315 | self.projects = [] 2316 | self.priority = -1 2317 | self.when = "" 2318 | self.created = date.today().isoformat() 2319 | self.error = "" 2320 | self.autoAction = False 2321 | self.autoProject = False 2322 | self.nullDate = False 2323 | self.parse(line, password) 2324 | 2325 | def makeSafeDate(self, year, month, day): 2326 | done = False 2327 | newDate = "" 2328 | while not done: 2329 | if day < 1: 2330 | done = True 2331 | else: 2332 | try: 2333 | newDate = date(year, month, day) 2334 | done = True 2335 | except ValueError: 2336 | day = day - 1 2337 | newDate = "" 2338 | return newDate 2339 | 2340 | def parseDate(self, dateStr, quiet): 2341 | dateStr = dateStr.replace("/","-") 2342 | dateStr = dateStr.replace(":","-") 2343 | entry = dateStr.split("-") 2344 | n = len(entry) 2345 | if n < 1 or n > 3: 2346 | fail = True 2347 | elif dateStr == "0": 2348 | self.nullDate = True 2349 | return "" 2350 | else: 2351 | try: 2352 | now = date.today() 2353 | if dateStr[0:1] == "+": 2354 | days = int(dateStr[1:].strip(), 10) 2355 | when = now + timedelta(days) 2356 | else: 2357 | if n == 3: 2358 | year = int(entry[0], 10) 2359 | month = int(entry[1], 10) 2360 | day = int(entry[2], 10) 2361 | elif n == 2: 2362 | year = now.year 2363 | month = int(entry[0], 10) 2364 | day = int(entry[1], 10) 2365 | else: 2366 | year = now.year 2367 | month = now.month 2368 | day = int(entry[0], 10) 2369 | if day < now.day: 2370 | month = month + 1 2371 | if month > 12: 2372 | month = 1 2373 | year = year + 1 2374 | if year < 1000: 2375 | year = year + 2000 2376 | when = self.makeSafeDate(year, month, day) 2377 | if when == "": 2378 | fail = True 2379 | else: 2380 | fail = False 2381 | self.nullDate = False 2382 | except ValueError: 2383 | fail = True 2384 | except: 2385 | fail = True 2386 | if fail: 2387 | self.addError("Could not decode the date. Use :dYYYY/MM/DD") 2388 | return "" 2389 | else: 2390 | return when.isoformat() 2391 | 2392 | def parse(self, line, password): 2393 | self.error = "" 2394 | words = line.split(" ") 2395 | taskToHide = "" 2396 | encrypt = "" 2397 | start = 0 2398 | ecmLen = len(self.ENCRYPTION_MARKER) 2399 | for word in words[start:]: 2400 | wordUC = word.strip().upper() 2401 | if len(word) > 0: 2402 | if encrypt != "": 2403 | taskToHide = taskToHide + word.strip() + " " 2404 | elif word[0:ecmLen] == self.ENCRYPTION_MARKER: 2405 | self.hiddenTask = word[ecmLen:] 2406 | elif wordUC.startswith("") or wordUC.startswith("") or wordUC.startswith("") or wordUC.startswith("

"): 2407 | encrypt = wordUC[1] 2408 | try: 2409 | pos = word.index(">") 2410 | taskToHide = taskToHide + word[pos + 1:].strip() + " " 2411 | except ValueError: 2412 | pass 2413 | elif word[0] == "@" and len(word) > 1: 2414 | if wordUC == "@DATE": 2415 | self.addError("@Date contexts should not be entered. Use :dYYYY-MM-DD") 2416 | else: 2417 | act = globalAbbr.expandAction(word.strip()) 2418 | if not act in self.actions: 2419 | self.actions.append(act) 2420 | elif word[0:1] == "#" and len(word) > 1 and self.priority == -1: 2421 | try: 2422 | self.priority = int(word[1:].strip(), 10) 2423 | if self.priority < 1: 2424 | self.priority = 0 2425 | elif self.priority > 10: 2426 | self.priority = 10 2427 | except ValueError: 2428 | self.addError("Did not understand priority.") 2429 | self.priority = -1 2430 | elif wordUC[0:2] == ":P" and len(word) > 2: 2431 | proj = globalPAbbr.expandProject(word.strip())[2:].title() 2432 | if not proj in self.projects: 2433 | self.projects.append(proj) 2434 | elif wordUC[0:8] == ":CREATED" and len(word) > 8: 2435 | self.created = word[8:].strip() 2436 | elif wordUC[0:2] == ":D" and len(word) > 2: 2437 | self.when = self.parseDate(word[2:].strip(), False) 2438 | else: 2439 | self.task = self.task + word.strip() + " " 2440 | if taskToHide != "": 2441 | ec = Encryptor() 2442 | if encrypt == "S": 2443 | if ec.setType(ec.TYPE_AES) != ec.TYPE_AES: 2444 | self.addError("AES encryption is not available.") 2445 | taskToHide = "" 2446 | else: 2447 | ec.setType(ec.TYPE_OBSCURED) 2448 | if taskToHide != "": 2449 | if password == "": 2450 | self.hiddenTask = ec.enterKeyAndEncrypt(taskToHide) 2451 | else: 2452 | ec.setKey(password) 2453 | self.hiddenTask = ec.encrypt(taskToHide) 2454 | 2455 | if len(self.actions) == 0: 2456 | self.actions.append("@Anywhere") 2457 | self.autoAction = True 2458 | if len(self.projects) == 0: 2459 | self.projects.append("None") 2460 | self.autoProject = True 2461 | 2462 | def addError(self, err): 2463 | if len(self.error) > 0: 2464 | self.error = self.error + "\n" 2465 | self.error = self.error + err 2466 | 2467 | def hasError(self): 2468 | return self.error != "" 2469 | 2470 | def getError(self): 2471 | tmp = self.error 2472 | self.error = "" 2473 | return tmp 2474 | 2475 | def hasWord(self, word): 2476 | return (self.task.upper().find(word.upper()) >= 0) 2477 | 2478 | def hasAction(self, loc): 2479 | if self.when != "" and loc.upper() == "@DATE": 2480 | return True 2481 | else: 2482 | return loc.title() in self.actions 2483 | 2484 | def copy(self, todoItem, replace): 2485 | if replace == TodoItem.REPLACE or len(todoItem.task.strip()) > 0: 2486 | if replace == TodoItem.APPEND: 2487 | self.task = self.task + " ..." + todoItem.task 2488 | else: 2489 | self.task = todoItem.task 2490 | if replace == TodoItem.REPLACE or todoItem.autoAction == False: 2491 | if replace != TodoItem.APPEND: 2492 | self.actions = [] 2493 | for loc in todoItem.actions: 2494 | if not loc in self.actions: 2495 | self.actions.append(loc) 2496 | if replace == TodoItem.REPLACE or todoItem.autoProject == False: 2497 | if replace != TodoItem.APPEND: 2498 | self.projects = [] 2499 | for proj in todoItem.projects: 2500 | if not proj in self.projects: 2501 | self.projects.append(proj) 2502 | if replace == TodoItem.REPLACE or (todoItem.when != "" or todoItem.nullDate == True): 2503 | self.when = todoItem.when 2504 | if todoItem.priority >= 0: 2505 | self.priority = todoItem.priority 2506 | 2507 | if replace == TodoItem.REPLACE or len(todoItem.hiddenTask.strip()) > 0: 2508 | if replace == TodoItem.APPEND: 2509 | pass 2510 | else: 2511 | self.hiddenTask = todoItem.hiddenTask 2512 | 2513 | def hasHiddenTask(self): 2514 | return self.hiddenTask != "" 2515 | 2516 | def hasTask(self): 2517 | return len(self.task.strip()) > 0 2518 | 2519 | def hasProject(self, proj): 2520 | if proj[0:2].upper() == ":P": 2521 | proj = proj[2:] 2522 | return proj.title() in self.projects 2523 | 2524 | def hasDate(self, dt): 2525 | dt = self.parseDate(dt, True) 2526 | if dt == "": 2527 | return False 2528 | else: 2529 | return self.when == dt 2530 | 2531 | def hasPriorityOrAbove(self, priority): 2532 | return (self.getEffectivePriority() >= priority) 2533 | 2534 | def hasPriority(self, priority): 2535 | return (self.getEffectivePriority() == priority) 2536 | 2537 | def getHiddenTask(self): 2538 | return self.hiddenTask 2539 | 2540 | def getTask(self): 2541 | return self.task 2542 | 2543 | def getActions(self): 2544 | if self.when == "": 2545 | return self.actions 2546 | else: 2547 | return self.actions + ["@Date"] 2548 | 2549 | def getProjects(self): 2550 | return self.projects 2551 | 2552 | def getDate(self): 2553 | return self.when 2554 | 2555 | def getPriority(self): 2556 | if self.priority < 0: 2557 | return self.DEFAULT_PRIORITY 2558 | else: 2559 | return self.priority 2560 | 2561 | def getEffectivePriority(self): 2562 | userP = self.getPriority() 2563 | if self.when != "": 2564 | if self.when <= date.today().isoformat(): 2565 | userP = self.OVERDUE_PRIORITY + userP 2566 | if self.hasAction("@Meeting"): 2567 | userP = userP + self.MEETING_PRIORITY 2568 | else: 2569 | userP = self.NOT_DUE_PRIORITY 2570 | return userP 2571 | 2572 | 2573 | def toString(self): 2574 | entry = "#" 2575 | entry = entry + " " + self.task 2576 | for action in self.actions: 2577 | entry = entry + " " + action 2578 | for project in self.projects: 2579 | entry = entry + " :p" + project 2580 | entry = entry + " :created" + self.created 2581 | if self.when != "": 2582 | entry = entry + " :d" + self.when 2583 | if self.priority >= 0: 2584 | entry = entry + " #" + str(self.priority) 2585 | if self.hiddenTask != "": 2586 | entry = entry + " " + self.ENCRYPTION_MARKER + self.hiddenTask 2587 | return entry 2588 | 2589 | def toStringEditable(self, includeHidden = False): 2590 | password = "" 2591 | entry = "" 2592 | if self.when != "": 2593 | entry = entry + ":d" + self.when + " " 2594 | entry = entry + "%s #%d" % (self.task, self.getPriority()) 2595 | if len(self.actions) > 0: 2596 | for action in self.actions: 2597 | entry = entry + " " + action 2598 | if len(self.projects) > 0: 2599 | for project in self.projects: 2600 | # skip the none tag 2601 | if project != "None": 2602 | entry = entry + " :p" + project 2603 | if self.hiddenTask != "" and includeHidden: 2604 | ec = Encryptor() 2605 | entry = entry + " <" + Encryptor().getSecurityClass(self.hiddenTask)[0:1] + ">" 2606 | entry = entry + ec.enterKeyAndDecrypt(self.hiddenTask) 2607 | password = ec.getKey() 2608 | return (password, entry.strip()) 2609 | 2610 | def toStringSimple(self): 2611 | entry = "" 2612 | if self.when != "": 2613 | entry = entry + "@Date " + self.when + " " 2614 | entry = entry + "%s #%d" % (self.task, self.getPriority()) 2615 | if self.hiddenTask != "": 2616 | entry = entry + " <*** " + Encryptor().getSecurityClass(self.hiddenTask) + " ***> " 2617 | if len(self.actions) > 0: 2618 | for action in self.actions: 2619 | entry = entry + " " + action 2620 | if len(self.projects) > 0: 2621 | first = True 2622 | for project in self.projects: 2623 | # skip the none tag 2624 | if project != "None": 2625 | if first: 2626 | entry = entry + " Projects: " + project 2627 | first = False 2628 | else: 2629 | entry = entry + ", " + project 2630 | entry = entry + " [" + self.created + "]" 2631 | return entry 2632 | 2633 | def toStringVerbose(self): 2634 | entry = gColor.code("title") + self.task 2635 | if self.hiddenTask != "": 2636 | entry = entry + " <*** " + Encryptor().getSecurityClass(self.hiddenTask) + " ***> " 2637 | entry = entry + gColor.code("bold") + "\nPriority: %02d" % (self.getPriority()) 2638 | if len(self.actions) or self.when != "" > 0: 2639 | entry = entry + gColor.code("heading") + "\nContext: " 2640 | if self.when != "": 2641 | entry = entry + gColor.code("important") + "@Date " + self.when 2642 | entry = entry + gColor.code("normal") 2643 | for action in self.actions: 2644 | entry = entry + " " + action; 2645 | if len(self.projects) > 0: 2646 | first = True 2647 | for project in self.projects: 2648 | if project != "None": 2649 | if first: 2650 | entry = entry + gColor.code("heading") + "\nProjects: " + gColor.code("normal"); 2651 | entry = entry + project 2652 | first = False 2653 | else: 2654 | entry = entry + ", " + project 2655 | entry = entry + gColor.code("normal") + "\nCreated: [" + self.created + "]" 2656 | return entry 2657 | 2658 | ### Entry point 2659 | for line in notice: 2660 | print line 2661 | 2662 | pythonVer = platform.python_version() 2663 | ver = pythonVer.split(".") 2664 | if int(ver[0]) < gReqPythonMajor or (int(ver[0]) == gReqPythonMajor and int(ver[1]) < gReqPythonMinor): 2665 | print "\nSorry but this program requires Python ", \ 2666 | str(gReqPythonMajor) + "." + str(gReqPythonMinor), \ 2667 | "\nYour current version is ", \ 2668 | str(ver[0]) + "." + str(ver[1]), \ 2669 | "\nTo run the program you will need to install the current version of Python." 2670 | else: 2671 | import webbrowser 2672 | # signal.signal(signal.SIGINT, signalHandler) 2673 | gColor = ColorCoder(cfgColor) 2674 | globalAbbr = Abbreviations() 2675 | globalPAbbr = Abbreviations(project=True) 2676 | commandList = [] 2677 | if len(sys.argv) > 2: 2678 | command = "" 2679 | reopen = sys.argv[1] 2680 | if reopen == ".": 2681 | reopen = sys.argv[0] + ".dat" 2682 | for word in sys.argv[2:]: 2683 | if word == "/": 2684 | commandList.append(command) 2685 | command = "" 2686 | else: 2687 | command = command + word + " " 2688 | commandList.append(command) 2689 | elif len(sys.argv) > 1: 2690 | reopen = sys.argv[1] 2691 | else: 2692 | reopen = sys.argv[0] + ".dat" 2693 | if usePlugin: 2694 | ruler = ikogPlugin.getRuler() 2695 | divider = ikogPlugin.getDivider() 2696 | while reopen != "": 2697 | print commandList 2698 | todoList = TodoList(sys.argv[0], reopen) 2699 | reopen = todoList.run(commandList) 2700 | commandList = [] 2701 | print "Goodbye" 2702 | 2703 | --------------------------------------------------------------------------------