diff --git a/M2/Macaulay2/m2/packages.m2 b/M2/Macaulay2/m2/packages.m2 index a7b4991437..b31b5e2483 100644 --- a/M2/Macaulay2/m2/packages.m2 +++ b/M2/Macaulay2/m2/packages.m2 @@ -97,6 +97,15 @@ isPackageLoaded := pkgname -> PackageDictionary#?pkgname and instance(value Pack checkPackageName = title -> ( if not match("^[[:alnum:]]+$", title) then error("package title not alphanumeric: ", format title)) +checkPackageAuthors = authors -> ( + if authors === null or #authors == 0 then ( warning "newPackage: no authors provided"; return ); + if any(authors = nonnull authors, author -> ( + if not isOptionList author then error("newPackage: expected Authors to be a list of lists of options"); + author = new OptionTable from author; + author.?Name and match_{"(C|c)ontribut", "(M|m)aintain", "(A|a)uthor", "(T|t)hank"} author.Name)) + then error("newPackage: use the Contributors or Acknowledgement keywords to acknowledge contributors of " | pkgname); + authors) + closePackage = pkg -> if pkg#?rawKeyDB then (db -> if isOpen db then close db) pkg#rawKeyDB ----------------------------------------------------------------------------- @@ -241,12 +250,8 @@ newPackage String := opts -> pkgname -> ( -- TODO: add a general type checking mechanism scan({Certification, Configuration}, name -> if opts#name =!= null and not isOptionList opts#name then error("newPackage: expected ", toString name, " option to be a list of options")); - if opts.Authors =!= null and any(opts.Authors, author -> not isOptionList author) - then error("newPackage: expected Authors option to be a list of zero or more lists of options"); - if opts.Authors =!= null and any(opts.Authors, author -> ( - author = new OptionTable from author; - author.?Name and match_{"(C|c)ontribut", "(M|m)aintain", "(A|a)uthor", "(T|t)hank"} author.Name)) - then error("newPackage: use the Contributors or Acknowledgement keywords to acknowledge contributors of " | pkgname); + -- checks for errors and issues warnings if necessary + opts = opts ++ { Authors => checkPackageAuthors opts.Authors }; -- optional package values scan({ (Date, String),