Skip to content

Commit

Permalink
added checkPackageAuthors routine
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Aug 11, 2024
1 parent d40887f commit e444b2f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions M2/Macaulay2/m2/packages.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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

-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit e444b2f

Please sign in to comment.