├── test ├── resources │ └── .gitkeep └── helpful_loader │ └── edn_test.clj ├── .gitignore ├── project.clj ├── src └── helpful_loader │ └── edn.clj ├── README.md └── LICENSE /test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /pom.xml 3 | /pom.xml.asc 4 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject helpful-loader "0.1.1" 2 | :description "Load resources with helpful error messages." 3 | :url "http://github.com/magnars/helpful-loader" 4 | :license {:name "GNU General Public License v3" 5 | :url "http://www.gnu.org/licenses/"} 6 | :dependencies [[org.clojure/clojure "1.6.0"]] 7 | :profiles {:dev {:dependencies [[expectations "2.1.0"] 8 | [test-with-files "0.1.0"]] 9 | :plugins [[lein-expectations "0.0.7"] 10 | [lein-autoexpect "1.4.0"]] 11 | :resource-paths ["test/resources"]}}) 12 | -------------------------------------------------------------------------------- /test/helpful_loader/edn_test.clj: -------------------------------------------------------------------------------- 1 | (ns helpful-loader.edn-test 2 | (:require [helpful-loader.edn :refer :all] 3 | [expectations :refer :all] 4 | [test-with-files.core :refer :all])) 5 | 6 | (expect {:a 4} (with-files [["/map.edn" "{:a 4}"]] 7 | (load-one (str public-dir "/map.edn")))) 8 | 9 | (expect (str "Unable to load " public-dir "/map.edn, no such file on classpath.") 10 | (try (load-one (str public-dir "/map.edn")) 11 | (catch Exception e (.getMessage e)))) 12 | 13 | (expect (str "Error in " public-dir "/broken.edn: Unmatched delimiter: ]") 14 | (with-files [["/broken.edn" "{:a 4"]] 15 | (try (load-one (str public-dir "/broken.edn")) 16 | (catch Exception e (.getMessage e))))) 17 | 18 | (expect (str public-dir "/several.edn should contain only a single form, but had 2 forms.") 19 | (with-files [["/several.edn" "{:a 4} :wq"]] 20 | (try (load-one (str public-dir "/several.edn")) 21 | (catch Exception e (.getMessage e))))) 22 | 23 | (expect [1 2 3] (with-files [["/numbers.edn" "[1 2 3]"]] 24 | (load-one-or-nil (str public-dir "/numbers.edn")))) 25 | 26 | (expect nil? (load-one-or-nil "unknown.edn")) 27 | -------------------------------------------------------------------------------- /src/helpful_loader/edn.clj: -------------------------------------------------------------------------------- 1 | (ns helpful-loader.edn 2 | (:require [clojure.edn] 3 | [clojure.java.io :as io] 4 | [clojure.string :as str])) 5 | 6 | (defn- validate-resource-existence [file] 7 | (if (nil? (io/resource file)) 8 | (throw (Exception. (str "Unable to load " file ", no such file on classpath."))))) 9 | 10 | (defn- load-one-str [content file-name] 11 | (let [forms (try 12 | (clojure.edn/read-string (str "[" content "]")) 13 | (catch Exception e 14 | (throw (Exception. (str "Error in " file-name ": " (.getMessage e))))))] 15 | (when (> (count forms) 1) 16 | (throw (Exception. (str file-name " should contain only a single form, but had " (count forms) " forms.")))) 17 | (first forms))) 18 | 19 | (defn load-one 20 | "Read a single edn data structure from the classpath. The path 21 | should be relative to the resources directory, e.g. (load-edn 22 | 'config.edn') to read resources/config.edn" 23 | [file] 24 | (validate-resource-existence file) 25 | (load-one-str (slurp (io/resource file)) file)) 26 | 27 | (defn load-one-or-nil 28 | "Read a single edn data structure from the classpath if it exists." 29 | [file] 30 | (when-let [resource (io/resource file)] 31 | (load-one-str (slurp resource) file))) 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # helpful-loader 2 | 3 | A Clojure library to load resources with helpful error messages. 4 | 5 | ## Install 6 | 7 | Add `[helpful-loader "0.1.1"]` to `:dependencies` in your `project.clj`. 8 | 9 | ## Usage 10 | 11 | Load one form worth of edn content from a file on the classpath: 12 | 13 | ```clj 14 | (ns example 15 | (:require [helpful-loader.edn :as edn-loader])) 16 | 17 | (edn-loader/load-one "my-config.edn") 18 | ``` 19 | 20 | So, with `resources/` on the class path, this would pick up 21 | `resources/my-config.edn` and load the edn form contained within. 22 | 23 | It works pretty much like this: 24 | 25 | ```clj 26 | (clojure.edn/read-string (slurp (clojure.java.io/resource "my-config.edn"))) 27 | ``` 28 | 29 | ### So, how is this better than just doing it myself? 30 | 31 | Three reasons: 32 | 33 | - If the file doesn't exist, you'd normally see this: 34 | 35 | ``` 36 | No implementation of method: :make-reader of protocol: 37 | #'clojure.java.io/IOFactory found for class: nil 38 | ``` 39 | 40 | With helpful-loader you see: 41 | 42 | ``` 43 | Unable to load my-config.edn, no such file on classpath. 44 | ``` 45 | 46 | - If the file is malformed, you'd normally see this: 47 | 48 | ``` 49 | EOF while reading 50 | ``` 51 | 52 | With helpful-loader you see: 53 | 54 | ``` 55 | Error in my-config.edn: EOF while reading 56 | ``` 57 | 58 | - If the file has multiple forms, the superflous ones would normally just be 59 | ignored by the reader. And you would be left scratching your head wondering 60 | why your changes didn't show up at all. 61 | 62 | With helpful-loader you see: 63 | 64 | ``` 65 | my-config.edn should contain only a single form, but had 2 forms. 66 | ``` 67 | 68 | ## More stuff 69 | 70 | ``` 71 | (edn-loader/load-one-or-nil "my-config.edn") 72 | ``` 73 | 74 | This one will just return `nil` if the file doesn't exist, but will still brook 75 | no nonsense for existing files, like above. 76 | 77 | ## Development 78 | 79 | Run tests with 80 | 81 | lein expectations 82 | 83 | Run tests automatically on changes with 84 | 85 | lein autoexpect 86 | 87 | ## License 88 | 89 | Copyright © 2015 Magnar Sveen & Christian Johansen 90 | 91 | This program is free software; you can redistribute it and/or modify 92 | it under the terms of the GNU General Public License as published by 93 | the Free Software Foundation, either version 3 of the License, or 94 | (at your option) any later version. 95 | 96 | This program is distributed in the hope that it will be useful, 97 | but WITHOUT ANY WARRANTY; without even the implied warranty of 98 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 99 | GNU General Public License for more details. 100 | 101 | You should have received a copy of the GNU General Public License 102 | along with this program. If not, see . 103 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | 3 | Version 3, 29 June 2007 4 | 5 | Copyright © 2007 Free Software Foundation, Inc. 6 | 7 | Everyone is permitted to copy and distribute verbatim copies of this license 8 | document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The GNU General Public License is a free, copyleft license for software and 13 | other kinds of works. 14 | 15 | The licenses for most software and other practical works are designed to take 16 | away your freedom to share and change the works. By contrast, the GNU General 17 | Public License is intended to guarantee your freedom to share and change all 18 | versions of a program--to make sure it remains free software for all its users. 19 | We, the Free Software Foundation, use the GNU General Public License for most of 20 | our software; it applies also to any other work released this way by its 21 | authors. You can apply it to your programs, too. 22 | 23 | When we speak of free software, we are referring to freedom, not price. Our 24 | General Public Licenses are designed to make sure that you have the freedom to 25 | distribute copies of free software (and charge for them if you wish), that you 26 | receive source code or can get it if you want it, that you can change the 27 | software or use pieces of it in new free programs, and that you know you can do 28 | these things. 29 | 30 | To protect your rights, we need to prevent others from denying you these rights 31 | or asking you to surrender the rights. Therefore, you have certain 32 | responsibilities if you distribute copies of the software, or if you modify it: 33 | responsibilities to respect the freedom of others. 34 | 35 | For example, if you distribute copies of such a program, whether gratis or for a 36 | fee, you must pass on to the recipients the same freedoms that you received. You 37 | must make sure that they, too, receive or can get the source code. And you must 38 | show them these terms so they know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: (1) assert 41 | copyright on the software, and (2) offer you this License giving you legal 42 | permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains that there 45 | is no warranty for this free software. For both users' and authors' sake, the 46 | GPL requires that modified versions be marked as changed, so that their problems 47 | will not be attributed erroneously to authors of previous versions. 48 | 49 | Some devices are designed to deny users access to install or run modified 50 | versions of the software inside them, although the manufacturer can do so. This 51 | is fundamentally incompatible with the aim of protecting users' freedom to 52 | change the software. The systematic pattern of such abuse occurs in the area of 53 | products for individuals to use, which is precisely where it is most 54 | unacceptable. Therefore, we have designed this version of the GPL to prohibit 55 | the practice for those products. If such problems arise substantially in other 56 | domains, we stand ready to extend this provision to those domains in future 57 | versions of the GPL, as needed to protect the freedom of users. 58 | 59 | Finally, every program is threatened constantly by software patents. States 60 | should not allow patents to restrict development and use of software on 61 | general-purpose computers, but in those that do, we wish to avoid the special 62 | danger that patents applied to a free program could make it effectively 63 | proprietary. To prevent this, the GPL assures that patents cannot be used to 64 | render the program non-free. 65 | 66 | The precise terms and conditions for copying, distribution and modification 67 | follow. 68 | 69 | TERMS AND CONDITIONS 70 | 71 | 0. Definitions. “This License” refers to version 3 of the GNU General Public 72 | License. 73 | 74 | “Copyright” also means copyright-like laws that apply to other kinds of works, 75 | such as semiconductor masks. 76 | 77 | “The Program” refers to any copyrightable work licensed under this License. Each 78 | licensee is addressed as “you”. “Licensees” and “recipients” may be individuals 79 | or organizations. 80 | 81 | To “modify” a work means to copy from or adapt all or part of the work in a 82 | fashion requiring copyright permission, other than the making of an exact copy. 83 | The resulting work is called a “modified version” of the earlier work or a work 84 | “based on” the earlier work. 85 | 86 | A “covered work” means either the unmodified Program or a work based on the 87 | Program. 88 | 89 | To “propagate” a work means to do anything with it that, without permission, 90 | would make you directly or secondarily liable for infringement under applicable 91 | copyright law, except executing it on a computer or modifying a private copy. 92 | Propagation includes copying, distribution (with or without modification), 93 | making available to the public, and in some countries other activities as well. 94 | 95 | To “convey” a work means any kind of propagation that enables other parties to 96 | make or receive copies. Mere interaction with a user through a computer network, 97 | with no transfer of a copy, is not conveying. 98 | 99 | An interactive user interface displays “Appropriate Legal Notices” to the extent 100 | that it includes a convenient and prominently visible feature that (1) displays 101 | an appropriate copyright notice, and (2) tells the user that there is no 102 | warranty for the work (except to the extent that warranties are provided), that 103 | licensees may convey the work under this License, and how to view a copy of this 104 | License. If the interface presents a list of user commands or options, such as a 105 | menu, a prominent item in the list meets this criterion. 106 | 107 | 1. Source Code. The “source code” for a work means the preferred form of the 108 | work for making modifications to it. “Object code” means any non-source form of 109 | a work. 110 | 111 | A “Standard Interface” means an interface that either is an official standard 112 | defined by a recognized standards body, or, in the case of interfaces specified 113 | for a particular programming language, one that is widely used among developers 114 | working in that language. 115 | 116 | The “System Libraries” of an executable work include anything, other than the 117 | work as a whole, that (a) is included in the normal form of packaging a Major 118 | Component, but which is not part of that Major Component, and (b) serves only to 119 | enable use of the work with that Major Component, or to implement a Standard 120 | Interface for which an implementation is available to the public in source code 121 | form. A “Major Component”, in this context, means a major essential component 122 | (kernel, window system, and so on) of the specific operating system (if any) on 123 | which the executable work runs, or a compiler used to produce the work, or an 124 | object code interpreter used to run it. 125 | 126 | The “Corresponding Source” for a work in object code form means all the source 127 | code needed to generate, install, and (for an executable work) run the object 128 | code and to modify the work, including scripts to control those activities. 129 | However, it does not include the work's System Libraries, or general-purpose 130 | tools or generally available free programs which are used unmodified in 131 | performing those activities but which are not part of the work. For example, 132 | Corresponding Source includes interface definition files associated with source 133 | files for the work, and the source code for shared libraries and dynamically 134 | linked subprograms that the work is specifically designed to require, such as by 135 | intimate data communication or control flow between those subprograms and other 136 | parts of the work. 137 | 138 | The Corresponding Source need not include anything that users can regenerate 139 | automatically from other parts of the Corresponding Source. 140 | 141 | The Corresponding Source for a work in source code form is that same work. 142 | 143 | 2. Basic Permissions. All rights granted under this License are granted for the 144 | term of copyright on the Program, and are irrevocable provided the stated 145 | conditions are met. This License explicitly affirms your unlimited permission to 146 | run the unmodified Program. The output from running a covered work is covered by 147 | this License only if the output, given its content, constitutes a covered work. 148 | This License acknowledges your rights of fair use or other equivalent, as 149 | provided by copyright law. 150 | 151 | You may make, run and propagate covered works that you do not convey, without 152 | conditions so long as your license otherwise remains in force. You may convey 153 | covered works to others for the sole purpose of having them make modifications 154 | exclusively for you, or provide you with facilities for running those works, 155 | provided that you comply with the terms of this License in conveying all 156 | material for which you do not control copyright. Those thus making or running 157 | the covered works for you must do so exclusively on your behalf, under your 158 | direction and control, on terms that prohibit them from making any copies of 159 | your copyrighted material outside their relationship with you. 160 | 161 | Conveying under any other circumstances is permitted solely under the conditions 162 | stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 163 | 164 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work 165 | shall be deemed part of an effective technological measure under any applicable 166 | law fulfilling obligations under article 11 of the WIPO copyright treaty adopted 167 | on 20 December 1996, or similar laws prohibiting or restricting circumvention of 168 | such measures. 169 | 170 | When you convey a covered work, you waive any legal power to forbid 171 | circumvention of technological measures to the extent such circumvention is 172 | effected by exercising rights under this License with respect to the covered 173 | work, and you disclaim any intention to limit operation or modification of the 174 | work as a means of enforcing, against the work's users, your or third parties' 175 | legal rights to forbid circumvention of technological measures. 176 | 177 | 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's 178 | source code as you receive it, in any medium, provided that you conspicuously 179 | and appropriately publish on each copy an appropriate copyright notice; keep 180 | intact all notices stating that this License and any non-permissive terms added 181 | in accord with section 7 apply to the code; keep intact all notices of the 182 | absence of any warranty; and give all recipients a copy of this License along 183 | with the Program. 184 | 185 | You may charge any price or no price for each copy that you convey, and you may 186 | offer support or warranty protection for a fee. 187 | 188 | 5. Conveying Modified Source Versions. You may convey a work based on the 189 | Program, or the modifications to produce it from the Program, in the form of 190 | source code under the terms of section 4, provided that you also meet all of 191 | these conditions: 192 | 193 | a) The work must carry prominent notices stating that you modified it, and 194 | giving a relevant date. b) The work must carry prominent notices stating that it 195 | is released under this License and any conditions added under section 7. This 196 | requirement modifies the requirement in section 4 to “keep intact all notices”. 197 | c) You must license the entire work, as a whole, under this License to anyone 198 | who comes into possession of a copy. This License will therefore apply, along 199 | with any applicable section 7 additional terms, to the whole of the work, and 200 | all its parts, regardless of how they are packaged. This License gives no 201 | permission to license the work in any other way, but it does not invalidate such 202 | permission if you have separately received it. d) If the work has interactive 203 | user interfaces, each must display Appropriate Legal Notices; however, if the 204 | Program has interactive interfaces that do not display Appropriate Legal 205 | Notices, your work need not make them do so. A compilation of a covered work 206 | with other separate and independent works, which are not by their nature 207 | extensions of the covered work, and which are not combined with it such as to 208 | form a larger program, in or on a volume of a storage or distribution medium, is 209 | called an “aggregate” if the compilation and its resulting copyright are not 210 | used to limit the access or legal rights of the compilation's users beyond what 211 | the individual works permit. Inclusion of a covered work in an aggregate does 212 | not cause this License to apply to the other parts of the aggregate. 213 | 214 | 6. Conveying Non-Source Forms. You may convey a covered work in object code form 215 | under the terms of sections 4 and 5, provided that you also convey the 216 | machine-readable Corresponding Source under the terms of this License, in one of 217 | these ways: 218 | 219 | a) Convey the object code in, or embodied in, a physical product (including a 220 | physical distribution medium), accompanied by the Corresponding Source fixed on 221 | a durable physical medium customarily used for software interchange. b) Convey 222 | the object code in, or embodied in, a physical product (including a physical 223 | distribution medium), accompanied by a written offer, valid for at least three 224 | years and valid for as long as you offer spare parts or customer support for 225 | that product model, to give anyone who possesses the object code either (1) a 226 | copy of the Corresponding Source for all the software in the product that is 227 | covered by this License, on a durable physical medium customarily used for 228 | software interchange, for a price no more than your reasonable cost of 229 | physically performing this conveying of source, or (2) access to copy the 230 | Corresponding Source from a network server at no charge. c) Convey individual 231 | copies of the object code with a copy of the written offer to provide the 232 | Corresponding Source. This alternative is allowed only occasionally and 233 | noncommercially, and only if you received the object code with such an offer, in 234 | accord with subsection 6b. d) Convey the object code by offering access from a 235 | designated place (gratis or for a charge), and offer equivalent access to the 236 | Corresponding Source in the same way through the same place at no further 237 | charge. You need not require recipients to copy the Corresponding Source along 238 | with the object code. If the place to copy the object code is a network server, 239 | the Corresponding Source may be on a different server (operated by you or a 240 | third party) that supports equivalent copying facilities, provided you maintain 241 | clear directions next to the object code saying where to find the Corresponding 242 | Source. Regardless of what server hosts the Corresponding Source, you remain 243 | obligated to ensure that it is available for as long as needed to satisfy these 244 | requirements. e) Convey the object code using peer-to-peer transmission, 245 | provided you inform other peers where the object code and Corresponding Source 246 | of the work are being offered to the general public at no charge under 247 | subsection 6d. A separable portion of the object code, whose source code is 248 | excluded from the Corresponding Source as a System Library, need not be included 249 | in conveying the object code work. 250 | 251 | A “User Product” is either (1) a “consumer product”, which means any tangible 252 | personal property which is normally used for personal, family, or household 253 | purposes, or (2) anything designed or sold for incorporation into a dwelling. In 254 | determining whether a product is a consumer product, doubtful cases shall be 255 | resolved in favor of coverage. For a particular product received by a particular 256 | user, “normally used” refers to a typical or common use of that class of 257 | product, regardless of the status of the particular user or of the way in which 258 | the particular user actually uses, or expects or is expected to use, the 259 | product. A product is a consumer product regardless of whether the product has 260 | substantial commercial, industrial or non-consumer uses, unless such uses 261 | represent the only significant mode of use of the product. 262 | 263 | “Installation Information” for a User Product means any methods, procedures, 264 | authorization keys, or other information required to install and execute 265 | modified versions of a covered work in that User Product from a modified version 266 | of its Corresponding Source. The information must suffice to ensure that the 267 | continued functioning of the modified object code is in no case prevented or 268 | interfered with solely because modification has been made. 269 | 270 | If you convey an object code work under this section in, or with, or 271 | specifically for use in, a User Product, and the conveying occurs as part of a 272 | transaction in which the right of possession and use of the User Product is 273 | transferred to the recipient in perpetuity or for a fixed term (regardless of 274 | how the transaction is characterized), the Corresponding Source conveyed under 275 | this section must be accompanied by the Installation Information. But this 276 | requirement does not apply if neither you nor any third party retains the 277 | ability to install modified object code on the User Product (for example, the 278 | work has been installed in ROM). 279 | 280 | The requirement to provide Installation Information does not include a 281 | requirement to continue to provide support service, warranty, or updates for a 282 | work that has been modified or installed by the recipient, or for the User 283 | Product in which it has been modified or installed. Access to a network may be 284 | denied when the modification itself materially and adversely affects the 285 | operation of the network or violates the rules and protocols for communication 286 | across the network. 287 | 288 | Corresponding Source conveyed, and Installation Information provided, in accord 289 | with this section must be in a format that is publicly documented (and with an 290 | implementation available to the public in source code form), and must require no 291 | special password or key for unpacking, reading or copying. 292 | 293 | 7. Additional Terms. “Additional permissions” are terms that supplement the 294 | terms of this License by making exceptions from one or more of its conditions. 295 | Additional permissions that are applicable to the entire Program shall be 296 | treated as though they were included in this License, to the extent that they 297 | are valid under applicable law. If additional permissions apply only to part of 298 | the Program, that part may be used separately under those permissions, but the 299 | entire Program remains governed by this License without regard to the additional 300 | permissions. 301 | 302 | When you convey a copy of a covered work, you may at your option remove any 303 | additional permissions from that copy, or from any part of it. (Additional 304 | permissions may be written to require their own removal in certain cases when 305 | you modify the work.) You may place additional permissions on material, added by 306 | you to a covered work, for which you have or can give appropriate copyright 307 | permission. 308 | 309 | Notwithstanding any other provision of this License, for material you add to a 310 | covered work, you may (if authorized by the copyright holders of that material) 311 | supplement the terms of this License with terms: 312 | 313 | a) Disclaiming warranty or limiting liability differently from the terms of 314 | sections 15 and 16 of this License; or b) Requiring preservation of specified 315 | reasonable legal notices or author attributions in that material or in the 316 | Appropriate Legal Notices displayed by works containing it; or c) Prohibiting 317 | misrepresentation of the origin of that material, or requiring that modified 318 | versions of such material be marked in reasonable ways as different from the 319 | original version; or d) Limiting the use for publicity purposes of names of 320 | licensors or authors of the material; or e) Declining to grant rights under 321 | trademark law for use of some trade names, trademarks, or service marks; or f) 322 | Requiring indemnification of licensors and authors of that material by anyone 323 | who conveys the material (or modified versions of it) with contractual 324 | assumptions of liability to the recipient, for any liability that these 325 | contractual assumptions directly impose on those licensors and authors. All 326 | other non-permissive additional terms are considered “further restrictions” 327 | within the meaning of section 10. If the Program as you received it, or any part 328 | of it, contains a notice stating that it is governed by this License along with 329 | a term that is a further restriction, you may remove that term. If a license 330 | document contains a further restriction but permits relicensing or conveying 331 | under this License, you may add to a covered work material governed by the terms 332 | of that license document, provided that the further restriction does not survive 333 | such relicensing or conveying. 334 | 335 | If you add terms to a covered work in accord with this section, you must place, 336 | in the relevant source files, a statement of the additional terms that apply to 337 | those files, or a notice indicating where to find the applicable terms. 338 | 339 | Additional terms, permissive or non-permissive, may be stated in the form of a 340 | separately written license, or stated as exceptions; the above requirements 341 | apply either way. 342 | 343 | 8. Termination. You may not propagate or modify a covered work except as 344 | expressly provided under this License. Any attempt otherwise to propagate or 345 | modify it is void, and will automatically terminate your rights under this 346 | License (including any patent licenses granted under the third paragraph of 347 | section 11). 348 | 349 | However, if you cease all violation of this License, then your license from a 350 | particular copyright holder is reinstated (a) provisionally, unless and until 351 | the copyright holder explicitly and finally terminates your license, and (b) 352 | permanently, if the copyright holder fails to notify you of the violation by 353 | some reasonable means prior to 60 days after the cessation. 354 | 355 | Moreover, your license from a particular copyright holder is reinstated 356 | permanently if the copyright holder notifies you of the violation by some 357 | reasonable means, this is the first time you have received notice of violation 358 | of this License (for any work) from that copyright holder, and you cure the 359 | violation prior to 30 days after your receipt of the notice. 360 | 361 | Termination of your rights under this section does not terminate the licenses of 362 | parties who have received copies or rights from you under this License. If your 363 | rights have been terminated and not permanently reinstated, you do not qualify 364 | to receive new licenses for the same material under section 10. 365 | 366 | 9. Acceptance Not Required for Having Copies. You are not required to accept 367 | this License in order to receive or run a copy of the Program. Ancillary 368 | propagation of a covered work occurring solely as a consequence of using 369 | peer-to-peer transmission to receive a copy likewise does not require 370 | acceptance. However, nothing other than this License grants you permission to 371 | propagate or modify any covered work. These actions infringe copyright if you do 372 | not accept this License. Therefore, by modifying or propagating a covered work, 373 | you indicate your acceptance of this License to do so. 374 | 375 | 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered 376 | work, the recipient automatically receives a license from the original 377 | licensors, to run, modify and propagate that work, subject to this License. You 378 | are not responsible for enforcing compliance by third parties with this License. 379 | 380 | An “entity transaction” is a transaction transferring control of an 381 | organization, or substantially all assets of one, or subdividing an 382 | organization, or merging organizations. If propagation of a covered work results 383 | from an entity transaction, each party to that transaction who receives a copy 384 | of the work also receives whatever licenses to the work the party's predecessor 385 | in interest had or could give under the previous paragraph, plus a right to 386 | possession of the Corresponding Source of the work from the predecessor in 387 | interest, if the predecessor has it or can get it with reasonable efforts. 388 | 389 | You may not impose any further restrictions on the exercise of the rights 390 | granted or affirmed under this License. For example, you may not impose a 391 | license fee, royalty, or other charge for exercise of rights granted under this 392 | License, and you may not initiate litigation (including a cross-claim or 393 | counterclaim in a lawsuit) alleging that any patent claim is infringed by 394 | making, using, selling, offering for sale, or importing the Program or any 395 | portion of it. 396 | 397 | 11. Patents. A “contributor” is a copyright holder who authorizes use under this 398 | License of the Program or a work on which the Program is based. The work thus 399 | licensed is called the contributor's “contributor version”. 400 | 401 | A contributor's “essential patent claims” are all patent claims owned or 402 | controlled by the contributor, whether already acquired or hereafter acquired, 403 | that would be infringed by some manner, permitted by this License, of making, 404 | using, or selling its contributor version, but do not include claims that would 405 | be infringed only as a consequence of further modification of the contributor 406 | version. For purposes of this definition, “control” includes the right to grant 407 | patent sublicenses in a manner consistent with the requirements of this License. 408 | 409 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent 410 | license under the contributor's essential patent claims, to make, use, sell, 411 | offer for sale, import and otherwise run, modify and propagate the contents of 412 | its contributor version. 413 | 414 | In the following three paragraphs, a “patent license” is any express agreement 415 | or commitment, however denominated, not to enforce a patent (such as an express 416 | permission to practice a patent or covenant not to sue for patent infringement). 417 | To “grant” such a patent license to a party means to make such an agreement or 418 | commitment not to enforce a patent against the party. 419 | 420 | If you convey a covered work, knowingly relying on a patent license, and the 421 | Corresponding Source of the work is not available for anyone to copy, free of 422 | charge and under the terms of this License, through a publicly available network 423 | server or other readily accessible means, then you must either (1) cause the 424 | Corresponding Source to be so available, or (2) arrange to deprive yourself of 425 | the benefit of the patent license for this particular work, or (3) arrange, in a 426 | manner consistent with the requirements of this License, to extend the patent 427 | license to downstream recipients. “Knowingly relying” means you have actual 428 | knowledge that, but for the patent license, your conveying the covered work in a 429 | country, or your recipient's use of the covered work in a country, would 430 | infringe one or more identifiable patents in that country that you have reason 431 | to believe are valid. 432 | 433 | If, pursuant to or in connection with a single transaction or arrangement, you 434 | convey, or propagate by procuring conveyance of, a covered work, and grant a 435 | patent license to some of the parties receiving the covered work authorizing 436 | them to use, propagate, modify or convey a specific copy of the covered work, 437 | then the patent license you grant is automatically extended to all recipients of 438 | the covered work and works based on it. 439 | 440 | A patent license is “discriminatory” if it does not include within the scope of 441 | its coverage, prohibits the exercise of, or is conditioned on the non-exercise 442 | of one or more of the rights that are specifically granted under this License. 443 | You may not convey a covered work if you are a party to an arrangement with a 444 | third party that is in the business of distributing software, under which you 445 | make payment to the third party based on the extent of your activity of 446 | conveying the work, and under which the third party grants, to any of the 447 | parties who would receive the covered work from you, a discriminatory patent 448 | license (a) in connection with copies of the covered work conveyed by you (or 449 | copies made from those copies), or (b) primarily for and in connection with 450 | specific products or compilations that contain the covered work, unless you 451 | entered into that arrangement, or that patent license was granted, prior to 28 452 | March 2007. 453 | 454 | Nothing in this License shall be construed as excluding or limiting any implied 455 | license or other defenses to infringement that may otherwise be available to you 456 | under applicable patent law. 457 | 458 | 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether 459 | by court order, agreement or otherwise) that contradict the conditions of this 460 | License, they do not excuse you from the conditions of this License. If you 461 | cannot convey a covered work so as to satisfy simultaneously your obligations 462 | under this License and any other pertinent obligations, then as a consequence 463 | you may not convey it at all. For example, if you agree to terms that obligate 464 | you to collect a royalty for further conveying from those to whom you convey the 465 | Program, the only way you could satisfy both those terms and this License would 466 | be to refrain entirely from conveying the Program. 467 | 468 | 13. Use with the GNU Affero General Public License. Notwithstanding any other 469 | provision of this License, you have permission to link or combine any covered 470 | work with a work licensed under version 3 of the GNU Affero General Public 471 | License into a single combined work, and to convey the resulting work. The terms 472 | of this License will continue to apply to the part which is the covered work, 473 | but the special requirements of the GNU Affero General Public License, section 474 | 13, concerning interaction through a network will apply to the combination as 475 | such. 476 | 477 | 14. Revised Versions of this License. The Free Software Foundation may publish 478 | revised and/or new versions of the GNU General Public License from time to time. 479 | Such new versions will be similar in spirit to the present version, but may 480 | differ in detail to address new problems or concerns. 481 | 482 | Each version is given a distinguishing version number. If the Program specifies 483 | that a certain numbered version of the GNU General Public License “or any later 484 | version” applies to it, you have the option of following the terms and 485 | conditions either of that numbered version or of any later version published by 486 | the Free Software Foundation. If the Program does not specify a version number 487 | of the GNU General Public License, you may choose any version ever published by 488 | the Free Software Foundation. 489 | 490 | If the Program specifies that a proxy can decide which future versions of the 491 | GNU General Public License can be used, that proxy's public statement of 492 | acceptance of a version permanently authorizes you to choose that version for 493 | the Program. 494 | 495 | Later license versions may give you additional or different permissions. 496 | However, no additional obligations are imposed on any author or copyright holder 497 | as a result of your choosing to follow a later version. 498 | 499 | 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT 500 | PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE 501 | COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT 502 | WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED 503 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 504 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS 505 | WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL 506 | NECESSARY SERVICING, REPAIR OR CORRECTION. 507 | 508 | 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR 509 | AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES 510 | AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 511 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT 512 | OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 513 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 514 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF 515 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 516 | 517 | 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and 518 | limitation of liability provided above cannot be given local legal effect 519 | according to their terms, reviewing courts shall apply local law that most 520 | closely approximates an absolute waiver of all civil liability in connection 521 | with the Program, unless a warranty or assumption of liability accompanies a 522 | copy of the Program in return for a fee. 523 | 524 | END OF TERMS AND CONDITIONS 525 | 526 | How to Apply These Terms to Your New Programs 527 | 528 | If you develop a new program, and you want it to be of the greatest possible use 529 | to the public, the best way to achieve this is to make it free software which 530 | everyone can redistribute and change under these terms. 531 | 532 | To do so, attach the following notices to the program. It is safest to attach 533 | them to the start of each source file to most effectively state the exclusion of 534 | warranty; and each file should have at least the “copyright” line and a pointer 535 | to where the full notice is found. 536 | 537 | 538 | Copyright (C) 539 | 540 | This program is free software: you can redistribute it and/or modify it 541 | under the terms of the GNU General Public License as published by the Free 542 | Software Foundation, either version 3 of the License, or (at your option) 543 | any later version. 544 | 545 | This program is distributed in the hope that it will be useful, but WITHOUT 546 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 547 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 548 | more details. 549 | 550 | You should have received a copy of the GNU General Public License along with 551 | this program. If not, see . Also add 552 | information on how to contact you by electronic and paper mail. 553 | 554 | If the program does terminal interaction, make it output a short notice like 555 | this when it starts in an interactive mode: 556 | 557 | Copyright (C) This program comes with 558 | ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, 559 | and you are welcome to redistribute it under certain conditions; type `show 560 | c' for details. The hypothetical commands `show w' and `show c' should show 561 | the appropriate parts of the General Public License. Of course, your 562 | program's commands might be different; for a GUI interface, you would use an 563 | “about box”. 564 | 565 | You should also get your employer (if you work as a programmer) or school, if 566 | any, to sign a “copyright disclaimer” for the program, if necessary. For more 567 | information on this, and how to apply and follow the GNU GPL, see 568 | . 569 | 570 | The GNU General Public License does not permit incorporating your program into 571 | proprietary programs. If your program is a subroutine library, you may consider 572 | it more useful to permit linking proprietary applications with the library. If 573 | this is what you want to do, use the GNU Lesser General Public License instead 574 | of this License. But first, please read 575 | . 576 | --------------------------------------------------------------------------------