<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AFishRef%2Futilities</id>
	<title>Module:FishRef/utilities - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AFishRef%2Futilities"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:FishRef/utilities&amp;action=history"/>
	<updated>2026-06-14T00:22:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:FishRef/utilities&amp;diff=471724&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:FishRef/utilities&amp;diff=471724&amp;oldid=prev"/>
		<updated>2021-07-15T21:39:44Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
p.format_species_list = function(frame, taxa)&lt;br /&gt;
&lt;br /&gt;
  local list = frame.args[1] or frame:getParent().args[1] or taxa&lt;br /&gt;
  local expand = frame.args['expand'] or frame:getParent().args['expand'] -- want to subst template code&lt;br /&gt;
  local compare = frame.args['compare'] or frame:getParent().args['compare'] &lt;br /&gt;
  local mode = frame.args['mode'] or frame:getParent().args['mode'] &lt;br /&gt;
  local nolink =  frame.args['nolink'] or frame:getParent().args['nolink'] &lt;br /&gt;
  &lt;br /&gt;
  list = mw.text.trim( list )&lt;br /&gt;
  &lt;br /&gt;
	local names = mw.text.split( list, &amp;quot;\n&amp;quot; )   -- could use plain option&lt;br /&gt;
	--local genus, species, authority&lt;br /&gt;
	local output = { }            -- table of species names for output&lt;br /&gt;
&lt;br /&gt;
	local i = 1&lt;br /&gt;
	while names[i] do&lt;br /&gt;
		&lt;br /&gt;
		local name, match, skip&lt;br /&gt;
		local sep = &amp;quot; &amp;quot;                                               -- space between genus and species&lt;br /&gt;
		local infrasep = &amp;quot;&amp;quot;  &lt;br /&gt;
		local italics = &amp;quot;''&amp;quot;&lt;br /&gt;
		local genus, species, subspecies, authority&lt;br /&gt;
        --local subspecies = &amp;quot;&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        if compare and not names[i]:find(&amp;quot;^&amp;quot; .. compare) then skip = true end -- only consider lines beginning with compare text (=genus)                                                          &lt;br /&gt;
                                                                              -- TODO try &amp;quot;(%S+)([%s×]+)(%S+) (.*)&amp;quot; &lt;br /&gt;
        if mode == &amp;quot;genus&amp;quot; or mode == &amp;quot;taxon&amp;quot; then               -- assume form taxon authority&lt;br /&gt;
 				for g, a in string.gmatch(names[i], &amp;quot;(%S+) (.*)&amp;quot; )  do -- match: genus × species authority&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = &amp;quot;&amp;quot;&lt;br /&gt;
				    sep = &amp;quot;&amp;quot;&lt;br /&gt;
					if a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
					match = true                                               -- we have a match &lt;br /&gt;
					if mode == &amp;quot;taxon&amp;quot; then italics = &amp;quot;&amp;quot; end&lt;br /&gt;
				end&lt;br /&gt;
      	&lt;br /&gt;
        else                                  -- match species list (various forms w/wo authority, hybrid)&lt;br /&gt;
&lt;br /&gt;
	        if not match then &lt;br /&gt;
				for g, s, f, ss, a in string.gmatch(names[i], &amp;quot;(%S+) (%S+)( subsp%. )(%S+) (.*)&amp;quot; ) do -- match: genus species subsp. subspecies authority&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s &lt;br /&gt;
					subspecies = ss&lt;br /&gt;
					infrasep = f --&amp;quot; subsp. &amp;quot;&lt;br /&gt;
					sep = &amp;quot; &amp;quot;&lt;br /&gt;
					if a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
					match = true                                               -- we have a match &lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not match then &lt;br /&gt;
				for g, s, f, ss in string.gmatch(names[i], &amp;quot;(%S+) (%S+)( subsp%. )(%S+)&amp;quot; ) do -- match: genus species subsp. subspecies&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s &lt;br /&gt;
					subspecies = ss&lt;br /&gt;
					infrasep = f -- &amp;quot; subsp. &amp;quot;&lt;br /&gt;
					sep = &amp;quot; &amp;quot;&lt;br /&gt;
					--if a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
					match = true                                               -- we have a match &lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
	        if not match then &lt;br /&gt;
				for g, s, a in string.gmatch(names[i], &amp;quot;(%S+) × (%S+) (.*)&amp;quot; ) do -- match: genus × species authority&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s &lt;br /&gt;
					sep = &amp;quot; × &amp;quot;&lt;br /&gt;
					if a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
					match = true                                               -- we have a match &lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
	&lt;br /&gt;
			if not match then &lt;br /&gt;
				for g, s in string.gmatch(names[i], &amp;quot;(%S+) × (%S+).*&amp;quot; ) do   --  match:  genus × species&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s&lt;br /&gt;
					sep = &amp;quot; × &amp;quot;&lt;br /&gt;
					if a ~= &amp;quot;&amp;quot; then authority = a end&lt;br /&gt;
					match = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
	        if not match then &lt;br /&gt;
				for g, s, a in string.gmatch(names[i], &amp;quot;(%S+) (%S+) (.*)&amp;quot; ) do -- match: genus species authority&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s &lt;br /&gt;
					if a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
					match = true                                               -- we have a match for genus, species, authority&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if not match then &lt;br /&gt;
				for g, s in string.gmatch(names[i], &amp;quot;(%S+) (%S+).*&amp;quot; ) do       -- match: genus species&lt;br /&gt;
					genus = g&lt;br /&gt;
					species = s &lt;br /&gt;
					match = true&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if match and not skip then&lt;br /&gt;
			local species_name = genus .. sep .. species  &lt;br /&gt;
			if subspecies then&lt;br /&gt;
				name = &amp;quot;''&amp;quot; .. species_name .. &amp;quot;''&amp;quot; .. infrasep .. &amp;quot;''&amp;quot;  .. subspecies ..&amp;quot;''&amp;quot;          &lt;br /&gt;
				if not nolink then &lt;br /&gt;
					name =  &amp;quot;[[&amp;quot; .. species_name .. infrasep .. subspecies   .. &amp;quot;|&amp;quot; .. name .. &amp;quot;]]&amp;quot;    -- wikilinked name with redirect&lt;br /&gt;
			    end&lt;br /&gt;
			else&lt;br /&gt;
				name = species_name&lt;br /&gt;
				if not nolink then name = &amp;quot;[[&amp;quot; .. name .. &amp;quot;]]&amp;quot; end       -- add wikilink&lt;br /&gt;
				name = italics .. name .. italics                        -- add italics &lt;br /&gt;
			end&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
			if authority  and expand then&lt;br /&gt;
			   name = name.. &amp;quot; &amp;quot; .. frame:expandTemplate{ title = 'small', args = { authority } }  --expand template&lt;br /&gt;
			elseif authority then&lt;br /&gt;
			   name = name .. &amp;quot; {{small|&amp;quot; .. authority ..&amp;quot;}}&amp;quot;                                 -- don't expand template&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
		end&lt;br /&gt;
	   	if name  then &lt;br /&gt;
	  		table.insert ( output , name )&lt;br /&gt;
	  	elseif not skip then &lt;br /&gt;
	  		table.insert ( output ,'&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;unsupported format: expects &amp;quot;genus species authority&amp;quot;&amp;lt;/span&amp;gt;' )&lt;br /&gt;
	  	end&lt;br /&gt;
	   &lt;br /&gt;
  	 &lt;br /&gt;
		i=i+1&lt;br /&gt;
	end&lt;br /&gt;
  &lt;br /&gt;
	return &amp;quot;*&amp;quot; .. table.concat(output, &amp;quot;\n*&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.format_taxon_list = function(frame)&lt;br /&gt;
&lt;br /&gt;
  local list = frame.args[1] or frame:getParent().args[1] &lt;br /&gt;
  local expand = frame.args['expand'] or frame:getParent().args['expand'] -- want to subst template code&lt;br /&gt;
  &lt;br /&gt;
  list = mw.text.trim( list )&lt;br /&gt;
  &lt;br /&gt;
	local names = mw.text.split( list, &amp;quot;\n&amp;quot;, plain )&lt;br /&gt;
	--local genus, species, authority&lt;br /&gt;
	local output = { }            -- table of species names for output&lt;br /&gt;
    local patterns = { &amp;quot;(%S+)( × )(%S+) (.*)&amp;quot;,           --     genus × species authority&lt;br /&gt;
    	              &amp;quot;(%S+)( × )(%S+).*&amp;quot;,              --     genus × species&lt;br /&gt;
    	               &amp;quot;(%S+)( )(%S+) (.*)&amp;quot;,            --     genus species authority&lt;br /&gt;
    	               &amp;quot;(%S+)( )(%S+).*&amp;quot;,               --     genus species &lt;br /&gt;
    	                                                -- taxon or genus authority&lt;br /&gt;
    }&lt;br /&gt;
	local i = 1&lt;br /&gt;
	while names[i] do&lt;br /&gt;
		local name, match&lt;br /&gt;
		--local sep = &amp;quot; &amp;quot;                                               -- space between genus and species&lt;br /&gt;
		local genus, separator, species, authority&lt;br /&gt;
                                                                     -- TODO try &amp;quot;(%S+)([%s×]+)(%S+) (.*)&amp;quot; &lt;br /&gt;
       for k, v in pairs (patterns) do &lt;br /&gt;
			for g, sep, s, a in string.gmatch(names[i], v ) do -- match: genus × species authority&lt;br /&gt;
				genus = g&lt;br /&gt;
				species = s &lt;br /&gt;
				separator = sep&lt;br /&gt;
				if a and a ~= &amp;quot;&amp;quot; then authority = a end                          -- no authority after space&lt;br /&gt;
				match = true                                               -- we have a match &lt;br /&gt;
			end&lt;br /&gt;
			if match then break end&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if match then&lt;br /&gt;
			name = &amp;quot;''[[&amp;quot; .. genus .. separator .. species .. &amp;quot;]]''&amp;quot;  &lt;br /&gt;
			if authority  and expand then&lt;br /&gt;
			   name = name .. frame:expandTemplate{ title = 'small', args = { authority } }  --expand template&lt;br /&gt;
			elseif authority then&lt;br /&gt;
			   name = name .. &amp;quot;{{small|&amp;quot; .. authority ..&amp;quot;}}&amp;quot;                                 -- don't expand template&lt;br /&gt;
			end&lt;br /&gt;
&lt;br /&gt;
		end&lt;br /&gt;
	   	if name  then &lt;br /&gt;
	  		table.insert ( output , name )&lt;br /&gt;
	  	else&lt;br /&gt;
	  		table.insert ( output ,'&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;unsupported format: expects &amp;quot;genus species authority&amp;quot;&amp;lt;/span&amp;gt;' )&lt;br /&gt;
	  	end&lt;br /&gt;
	   &lt;br /&gt;
  	 &lt;br /&gt;
		i=i+1&lt;br /&gt;
	end&lt;br /&gt;
  &lt;br /&gt;
	return &amp;quot;*&amp;quot; .. table.concat(output, &amp;quot;\n*&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
end&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>