Operator: JJMC89 ( talk · contribs · SUL · edit count · logs · page moves · block log · rights log · ANI search)
Time filed: 22:40, Monday, September 5, 2016 ( UTC)
Automatic, Supervised, or Manual: Automatic
Programming language(s): C# (
Custom AWB module) Python
Source code available: Partial:
AWB
infobox-coords-migrator.py on
GitHub
Function overview: Migrate infobox coordinates parameters to {{ Coord}}
Links to relevant discussions (where appropriate):
Edit period(s): One run per infobox
Estimated number of pages affected: Up to the number of articles transcluding each infobox (6–10 edits/min)
Exclusion compliant (Yes/No): Yes
Already has a bot flag (Yes/No): Yes
Function details: Migrate infobox coordinates parameters to {{ Coord}} using a template wrapper substitution.
{{
Infobox park}} will be used for the bot trial with {{
subst:Infobox coord/sandbox}} as the wrapper to convert the coordinates parameters to |coords={{Coord}}
.
{{Infobox park}} configuration #1 |
---|
private static readonly string targetTemplate = "Infobox park";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex(new List<string>("Infobox park,Infobox Park,Infobox Nature reserve,Infobox garden,Infobox desert".Split(',')));
private static readonly Dictionary<string, string> parametersDict = new Dictionary<string, string>
{
{ "lat_d", "lat_d" },
{ "lat_m", "lat_m" },
{ "lat_s", "lat_s" },
{ "lat_NS", "lat_NS" },
{ "long_d", "long_d" },
{ "long_m", "long_m" },
{ "long_s", "long_s" },
{ "long_EW", "long_EW" },
{ "coords_type", "type" },
{ "region", "region" },
{ "dim", "dim" },
{ "scale", "scale" },
{ "source", "source" },
{ "display", "display" },
{ "format", "format" }
};
private static readonly string replacementParameter = "coords";
private static readonly string initialReplacementTemplate = "subst:Infobox coord/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
Migrate {{Infobox park}} coordinates parameters to coords={{Coord}}, see
Help:Coordinates in infoboxes
. —
JJMC89 (
T·
C) 04:23, 6 September 2016 (UTC)
reply
{{
Infobox school}} parameters
| ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Jc86035 ( talk • contribs) Use {{ re|Jc86035}} to reply to me 16:19, 6 September 2016 (UTC) reply
{{{latitude|{{{latd|}}}}}}
→ "latitude,latd"
.{{Infobox park}} configuration #2 |
---|
private static readonly string targetTemplate = "Infobox park";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox park,Infobox Park,Infobox Nature reserve,Infobox garden,Infobox desert".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "lat_d", "lat_d".Split(',').ToList() },
{ "lat_m", "lat_m".Split(',').ToList() },
{ "lat_s", "lat_s".Split(',').ToList() },
{ "lat_NS", "lat_NS".Split(',').ToList() },
{ "long_d", "long_d".Split(',').ToList() },
{ "long_m", "long_m".Split(',').ToList() },
{ "long_s", "long_s".Split(',').ToList() },
{ "long_EW", "long_EW".Split(',').ToList() },
{ "coords_type", "type".Split(',').ToList() },
{ "region", "region".Split(',').ToList() },
{ "dim", "dim".Split(',').ToList() },
{ "scale", "scale".Split(',').ToList() },
{ "source", "source".Split(',').ToList() },
{ "display", "display".Split(',').ToList() },
{ "format", "format".Split(',').ToList() }
};
private static readonly string replacementParameter = "coords";
private static readonly string initialReplacementTemplate = "subst:Infobox coord/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
{{Infobox school}} configuration |
---|
private static readonly string targetTemplate = "Infobox school";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox school,School,Infobox HighSchool,Infobox OtherEducation,Infobox Private School,Infobox School2,Infobox high school,Infobox middle school,Infobox education in Canada,Infobox private school,School infobox,Infobox New Zealand school,Infobox Public School,Infobox secondary school,Infobox School3,Infobox US school,Infobox School UK,Infobox Education in the United States,Infobox boarding school,Infobox Malaysia School,Infobox Malaysia school,Infobox Secondary School,Infobox K-12 School,Infobox scottish primary, secondary and nursery school,Infobox scottish primary school,Infobox High School,High school,Infobox School IN,Infobox Education in Canada,Infobox Secondary school,Infobox School,Infobox education in the United States,Infobox NZ school,Infobox Hochschule,Infobox cadet college,Infobox yeshiva,Infobox education in canada".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "1", "latitude,latd".Split(',').ToList() },
{ "2", "latm".Split(',').ToList() },
{ "3", "lats".Split(',').ToList() },
{ "4", "latNS".Split(',').ToList() },
{ "5", "longitude,longd".Split(',').ToList() },
{ "6", "longm".Split(',').ToList() },
{ "7", "longs".Split(',').ToList() },
{ "8", "longEW".Split(',').ToList() },
{ "title", "coordinates_display".Split(',').ToList() },
{ "dms", "dms".Split(',').ToList() }, // Geobox coor: format
{ "region", "iso_region".Split(',').ToList() }
};
private static readonly string replacementParameter = "coordinates";
private static readonly string initialReplacementTemplate = "subst:Geobox coor/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
{{Infobox station}} configuration |
---|
private static readonly string targetTemplate = "Infobox station";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox station,Infobox Austria station,Infobox China station,Infobox English bus stations,Infobox GB bus station,Infobox HK Bus Station,Infobox HK Bus station,Infobox Ireland disused station,Infobox Ireland station,Infobox Italy station,Infobox Japan station,Infobox MTR,Infobox MTR station,Infobox NI station,Infobox NS-station,Infobox Oslo Tramway station,Infobox Railway Station,Infobox Slovakia station,Infobox Slovenia station,Infobox Station,Infobox Switzerland station,Infobox Taiwan station,Infobox bus station,Infobox china station,Infobox japan station,London Tram stations,MTR Infobox,MTR infobox,TP Train Station".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "1", "latitude,latd".Split(',').ToList() },
{ "2", "latm".Split(',').ToList() },
{ "3", "lats".Split(',').ToList() },
{ "4", "latNS".Split(',').ToList() },
{ "5", "longitude,longd".Split(',').ToList() },
{ "6", "longm".Split(',').ToList() },
{ "7", "longs".Split(',').ToList() },
{ "8", "longEW".Split(',').ToList() },
{ "title", "coordinates_display".Split(',').ToList() },
{ "format", "coordinates_format".Split(',').ToList() },
{ "region", "iso_region".Split(',').ToList() }
};
private static readonly string replacementParameter = "coordinates";
private static readonly string initialReplacementTemplate = "subst:Geobox coor/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
—
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 13:03, 8 September 2016 (UTC)
reply
{{ BAG assistance needed}} Any questions or comments? — JJMC89 ( T· C) 02:22, 13 September 2016 (UTC) reply
<maplink/>
(which
Yurik might want {{
Coord}} to be based on), so that would involve some more pages.
Jc86035 (
talk) Use {{
re|Jc86035}} | parameter_name = value
) of the other infobox parameters so that the |coords=
parameter matches them? Thanks,
Jc86035 (
talk) Use {{
re|Jc86035}}
Tools.SetTemplateParameterValue("{{Infobox park|...}}", replacementParameter, "{{subst:Infobox coord/sandbox|...}}", true)
to set the parameter value. If the replacementParameter
is already in the template, it will update the value in place (
example). In this case, any spacing is maintained. Otherwise, the replacementParameter
is appended to the end. In that case, it attempts to match the spacing around the |
but not the =
. If either of those is important, it would be easier for me to rewrite this in Python than to implement them in the module. —
JJMC89 (
T·
C) 05:40, 24 October 2016 (UTC)
reply
Template:Infobox park/config
) or a single page can be recycled for all templates (e.g. User:JJMC89 bot/config/InfoboxCoordinatesParametersMigrator
).
Example JSON configurations
|
---|
{
"template": "Infobox park",
"replacementParameter": "coords",
"initialReplacementTemplate": "subst:Infobox coord/sandbox",
"editSummary": null,
"parametersMap": {
"lat_d": "lat_d",
"lat_m": "lat_m",
"lat_s": "lat_s",
"lat_NS": "lat_NS",
"long_d": "long_d",
"long_m": "long_m",
"long_s": "long_s",
"long_EW": "long_EW",
"type": "coords_type",
"region": "region",
"dim": "dim",
"scale": "scale",
"source": "source",
"display": "display",
"format": "format"
}
}
{
"template": "Infobox school",
"replacementParameter": "coordinates",
"initialReplacementTemplate": "subst:Geobox coor/sandbox",
"parametersMap": {
"1": "latitude", "latd"],
"2": "latm",
"3": "lats",
"4": "latNS",
"5": "longitude", "longd"],
"6": "longm",
"7": "longs",
"8": "longEW",
"title": "coordinates_display",
"dms": "dms",
"region": "iso_region"
}
}
|
|coords=
due to one of the deprecated parameters being separated from the others and
one with extra spacing due to the spacing in the embedded {{Infobox zoo}}
. Configurations can be found
here. —
JJMC89 (
T·
C) 03:52, 1 November 2016 (UTC)
reply
|replacementParameter=
is now before the first parameter in the ordered parametersMap
that is found in template
. (parametersMap
was previously unordered.) —
JJMC89 (
T·
C) 05:02, 6 November 2016 (UTC)
reply
Operator: JJMC89 ( talk · contribs · SUL · edit count · logs · page moves · block log · rights log · ANI search)
Time filed: 22:40, Monday, September 5, 2016 ( UTC)
Automatic, Supervised, or Manual: Automatic
Programming language(s): C# (
Custom AWB module) Python
Source code available: Partial:
AWB
infobox-coords-migrator.py on
GitHub
Function overview: Migrate infobox coordinates parameters to {{ Coord}}
Links to relevant discussions (where appropriate):
Edit period(s): One run per infobox
Estimated number of pages affected: Up to the number of articles transcluding each infobox (6–10 edits/min)
Exclusion compliant (Yes/No): Yes
Already has a bot flag (Yes/No): Yes
Function details: Migrate infobox coordinates parameters to {{ Coord}} using a template wrapper substitution.
{{
Infobox park}} will be used for the bot trial with {{
subst:Infobox coord/sandbox}} as the wrapper to convert the coordinates parameters to |coords={{Coord}}
.
{{Infobox park}} configuration #1 |
---|
private static readonly string targetTemplate = "Infobox park";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex(new List<string>("Infobox park,Infobox Park,Infobox Nature reserve,Infobox garden,Infobox desert".Split(',')));
private static readonly Dictionary<string, string> parametersDict = new Dictionary<string, string>
{
{ "lat_d", "lat_d" },
{ "lat_m", "lat_m" },
{ "lat_s", "lat_s" },
{ "lat_NS", "lat_NS" },
{ "long_d", "long_d" },
{ "long_m", "long_m" },
{ "long_s", "long_s" },
{ "long_EW", "long_EW" },
{ "coords_type", "type" },
{ "region", "region" },
{ "dim", "dim" },
{ "scale", "scale" },
{ "source", "source" },
{ "display", "display" },
{ "format", "format" }
};
private static readonly string replacementParameter = "coords";
private static readonly string initialReplacementTemplate = "subst:Infobox coord/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
Migrate {{Infobox park}} coordinates parameters to coords={{Coord}}, see
Help:Coordinates in infoboxes
. —
JJMC89 (
T·
C) 04:23, 6 September 2016 (UTC)
reply
{{
Infobox school}} parameters
| ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Jc86035 ( talk • contribs) Use {{ re|Jc86035}} to reply to me 16:19, 6 September 2016 (UTC) reply
{{{latitude|{{{latd|}}}}}}
→ "latitude,latd"
.{{Infobox park}} configuration #2 |
---|
private static readonly string targetTemplate = "Infobox park";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox park,Infobox Park,Infobox Nature reserve,Infobox garden,Infobox desert".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "lat_d", "lat_d".Split(',').ToList() },
{ "lat_m", "lat_m".Split(',').ToList() },
{ "lat_s", "lat_s".Split(',').ToList() },
{ "lat_NS", "lat_NS".Split(',').ToList() },
{ "long_d", "long_d".Split(',').ToList() },
{ "long_m", "long_m".Split(',').ToList() },
{ "long_s", "long_s".Split(',').ToList() },
{ "long_EW", "long_EW".Split(',').ToList() },
{ "coords_type", "type".Split(',').ToList() },
{ "region", "region".Split(',').ToList() },
{ "dim", "dim".Split(',').ToList() },
{ "scale", "scale".Split(',').ToList() },
{ "source", "source".Split(',').ToList() },
{ "display", "display".Split(',').ToList() },
{ "format", "format".Split(',').ToList() }
};
private static readonly string replacementParameter = "coords";
private static readonly string initialReplacementTemplate = "subst:Infobox coord/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
{{Infobox school}} configuration |
---|
private static readonly string targetTemplate = "Infobox school";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox school,School,Infobox HighSchool,Infobox OtherEducation,Infobox Private School,Infobox School2,Infobox high school,Infobox middle school,Infobox education in Canada,Infobox private school,School infobox,Infobox New Zealand school,Infobox Public School,Infobox secondary school,Infobox School3,Infobox US school,Infobox School UK,Infobox Education in the United States,Infobox boarding school,Infobox Malaysia School,Infobox Malaysia school,Infobox Secondary School,Infobox K-12 School,Infobox scottish primary, secondary and nursery school,Infobox scottish primary school,Infobox High School,High school,Infobox School IN,Infobox Education in Canada,Infobox Secondary school,Infobox School,Infobox education in the United States,Infobox NZ school,Infobox Hochschule,Infobox cadet college,Infobox yeshiva,Infobox education in canada".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "1", "latitude,latd".Split(',').ToList() },
{ "2", "latm".Split(',').ToList() },
{ "3", "lats".Split(',').ToList() },
{ "4", "latNS".Split(',').ToList() },
{ "5", "longitude,longd".Split(',').ToList() },
{ "6", "longm".Split(',').ToList() },
{ "7", "longs".Split(',').ToList() },
{ "8", "longEW".Split(',').ToList() },
{ "title", "coordinates_display".Split(',').ToList() },
{ "dms", "dms".Split(',').ToList() }, // Geobox coor: format
{ "region", "iso_region".Split(',').ToList() }
};
private static readonly string replacementParameter = "coordinates";
private static readonly string initialReplacementTemplate = "subst:Geobox coor/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
{{Infobox station}} configuration |
---|
private static readonly string targetTemplate = "Infobox station";
private static readonly Regex regexTargetTemplate = Tools.NestedTemplateRegex("Infobox station,Infobox Austria station,Infobox China station,Infobox English bus stations,Infobox GB bus station,Infobox HK Bus Station,Infobox HK Bus station,Infobox Ireland disused station,Infobox Ireland station,Infobox Italy station,Infobox Japan station,Infobox MTR,Infobox MTR station,Infobox NI station,Infobox NS-station,Infobox Oslo Tramway station,Infobox Railway Station,Infobox Slovakia station,Infobox Slovenia station,Infobox Station,Infobox Switzerland station,Infobox Taiwan station,Infobox bus station,Infobox china station,Infobox japan station,London Tram stations,MTR Infobox,MTR infobox,TP Train Station".Split(',').ToList());
private static readonly Dictionary<string, List<string>> parametersDict = new Dictionary<string, List<string>>
{
{ "1", "latitude,latd".Split(',').ToList() },
{ "2", "latm".Split(',').ToList() },
{ "3", "lats".Split(',').ToList() },
{ "4", "latNS".Split(',').ToList() },
{ "5", "longitude,longd".Split(',').ToList() },
{ "6", "longm".Split(',').ToList() },
{ "7", "longs".Split(',').ToList() },
{ "8", "longEW".Split(',').ToList() },
{ "title", "coordinates_display".Split(',').ToList() },
{ "format", "coordinates_format".Split(',').ToList() },
{ "region", "iso_region".Split(',').ToList() }
};
private static readonly string replacementParameter = "coordinates";
private static readonly string initialReplacementTemplate = "subst:Geobox coor/sandbox";
private static readonly string editSummary = "Migrate {{" + targetTemplate + "}} coordinates parameters to " + replacementParameter + "={{Coord}}, see [[Help:Coordinates in infoboxes]]";
|
—
Jc86035 (
talk) Use {{
re|Jc86035}}
to reply to me 13:03, 8 September 2016 (UTC)
reply
{{ BAG assistance needed}} Any questions or comments? — JJMC89 ( T· C) 02:22, 13 September 2016 (UTC) reply
<maplink/>
(which
Yurik might want {{
Coord}} to be based on), so that would involve some more pages.
Jc86035 (
talk) Use {{
re|Jc86035}} | parameter_name = value
) of the other infobox parameters so that the |coords=
parameter matches them? Thanks,
Jc86035 (
talk) Use {{
re|Jc86035}}
Tools.SetTemplateParameterValue("{{Infobox park|...}}", replacementParameter, "{{subst:Infobox coord/sandbox|...}}", true)
to set the parameter value. If the replacementParameter
is already in the template, it will update the value in place (
example). In this case, any spacing is maintained. Otherwise, the replacementParameter
is appended to the end. In that case, it attempts to match the spacing around the |
but not the =
. If either of those is important, it would be easier for me to rewrite this in Python than to implement them in the module. —
JJMC89 (
T·
C) 05:40, 24 October 2016 (UTC)
reply
Template:Infobox park/config
) or a single page can be recycled for all templates (e.g. User:JJMC89 bot/config/InfoboxCoordinatesParametersMigrator
).
Example JSON configurations
|
---|
{
"template": "Infobox park",
"replacementParameter": "coords",
"initialReplacementTemplate": "subst:Infobox coord/sandbox",
"editSummary": null,
"parametersMap": {
"lat_d": "lat_d",
"lat_m": "lat_m",
"lat_s": "lat_s",
"lat_NS": "lat_NS",
"long_d": "long_d",
"long_m": "long_m",
"long_s": "long_s",
"long_EW": "long_EW",
"type": "coords_type",
"region": "region",
"dim": "dim",
"scale": "scale",
"source": "source",
"display": "display",
"format": "format"
}
}
{
"template": "Infobox school",
"replacementParameter": "coordinates",
"initialReplacementTemplate": "subst:Geobox coor/sandbox",
"parametersMap": {
"1": "latitude", "latd"],
"2": "latm",
"3": "lats",
"4": "latNS",
"5": "longitude", "longd"],
"6": "longm",
"7": "longs",
"8": "longEW",
"title": "coordinates_display",
"dms": "dms",
"region": "iso_region"
}
}
|
|coords=
due to one of the deprecated parameters being separated from the others and
one with extra spacing due to the spacing in the embedded {{Infobox zoo}}
. Configurations can be found
here. —
JJMC89 (
T·
C) 03:52, 1 November 2016 (UTC)
reply
|replacementParameter=
is now before the first parameter in the ordered parametersMap
that is found in template
. (parametersMap
was previously unordered.) —
JJMC89 (
T·
C) 05:02, 6 November 2016 (UTC)
reply