Closed elfring closed 1 year ago
Sorry, not really a regexp wizard.. even after fixing your command like this
python-holidays$ perl -p -i.orig -0777 -e 's/^(?<indentation>\s+)(?<target>\S+)\s*=\s*\k<target>[ \t]*(?<operator>[+\-%&|^@]|\*\*?|\/\/?|<<|>>)/$+{indentation}$+{target} $+{operator}=/gm' $(find . -name '*.py')
it still seems to fail for this reason:
-bash: /usr/local/bin/perl: Argument list too long
Any ideas?
How do you think about the generation of update candidates like the following? :thinking:
Markus_Elfring@Sonne:/home/altes_Heim3/Markus_Elfring/Projekte/python-holidays/lokal> perl -p -i.orig -0777 -e 's/^(?<indentation>\s+)(?<target>\S+)\s*=\s*\k<target>[ \t]*(?<operator>[+\-%&|^@]|\*\*?|\/\/?|<<|>>)/$+{indentation}$+{target} $+{operator}=/gm' $(find . -name '*.py') && git diff > ../change_possibilities-20220723.diff
diff --git a/holidays/countries/angola.py b/holidays/countries/angola.py
index 9cdf2da..60e09be 100644
--- a/holidays/countries/angola.py
+++ b/holidays/countries/angola.py
@@ -54,7 +54,7 @@ class Angola(HolidayBase):
# which is 40 days before easter excluding sundays
carnival = e - rd(days=46)
while carnival.weekday() != TUE:
- carnival = carnival - rd(days=1)
+ carnival -= rd(days=1)
self[carnival] = "Carnaval"
self[date(year, FEB, 4)] = "Dia do Início da Luta Armada"
diff --git a/holidays/countries/aruba.py b/holidays/countries/aruba.py
index 00cac4a..3443bf5 100644
--- a/holidays/countries/aruba.py
+++ b/holidays/countries/aruba.py
@@ -59,7 +59,7 @@ class Aruba(HolidayBase):
if year >= 2014:
kings_day = date(year, APR, 27)
if kings_day.weekday() == 6:
- kings_day = kings_day - rd(days=1)
+ kings_day -= rd(days=1)
self[kings_day] = "Aña di Rey [King's Day]"
@@ -71,9 +71,9 @@ class Aruba(HolidayBase):
if queens_day.weekday() == 6:
if year < 1980:
- queens_day = queens_day + rd(days=1)
+ queens_day += rd(days=1)
else:
- queens_day = queens_day - rd(days=1)
+ queens_day -= rd(days=1)
self[queens_day] = "Aña di La Reina [Queen's Day]"
diff --git a/holidays/countries/botswana.py b/holidays/countries/botswana.py
index 42eadd6..5e56689 100644
--- a/holidays/countries/botswana.py
+++ b/holidays/countries/botswana.py
@@ -56,7 +56,7 @@ class Botswana(HolidayBase):
# for the given year
d = date(year, 7, 15)
while d.isoweekday() != 1 and (15 <= d.day <= 21):
- d = d + rd(days=1)
+ d += rd(days=1)
self[d] = "President's Day"
self[d + rd(days=1)] = "President's Day Holiday"
diff --git a/holidays/countries/canada.py b/holidays/countries/canada.py
index 156f858..21c01d3 100644
--- a/holidays/countries/canada.py
+++ b/holidays/countries/canada.py
@@ -246,7 +246,7 @@ class Canada(HolidayBase):
elif self.subdiv in ("NS", "NL", "NT", "PE", "SK") and year >= 1931:
self[date(year, NOV, 11)] = name
if self.observed and date(year, NOV, 11).weekday() == SUN:
- name = name + " (Observed)"
+ name += " (Observed)"
self[date(year, NOV, 11) + rd(weekday=MO)] = name
# Christmas Day
diff --git a/holidays/countries/curacao.py b/holidays/countries/curacao.py
index f031123..24171c8 100644
--- a/holidays/countries/curacao.py
+++ b/holidays/countries/curacao.py
@@ -49,7 +49,7 @@ class Curacao(HolidayBase):
if year >= 2014:
kings_day = date(year, APR, 27)
if kings_day.weekday() == 6:
- kings_day = kings_day - rd(days=1)
+ kings_day -= rd(days=1)
self[kings_day] = "Koningsdag [King's Day]"
@@ -61,16 +61,16 @@ class Curacao(HolidayBase):
if queens_day.weekday() == 6:
if year < 1980:
- queens_day = queens_day + rd(days=1)
+ queens_day += rd(days=1)
else:
- queens_day = queens_day - rd(days=1)
+ queens_day -= rd(days=1)
self[queens_day] = "Anja di La Reina [Queen's Day]"
# Labour Day
labour_day = date(year, MAY, 1)
if labour_day.weekday() == 6:
- labour_day = labour_day + rd(days=1)
+ labour_day += rd(days=1)
self[labour_day] = "Dia di Obrero [Labour Day]"
# Ascension Day
diff --git a/holidays/countries/hongkong.py b/holidays/countries/hongkong.py
index dd68029..bc9debb 100644
--- a/holidays/countries/hongkong.py
+++ b/holidays/countries/hongkong.py
@@ -43,7 +43,7 @@ class HongKong(HolidayBase):
self[
first_date + rd(days=+1)
] = day_following + self.first_lower(name)
- first_date = first_date + rd(days=+1)
+ first_date += rd(days=+1)
else:
self[first_date] = name
else:
@@ -96,7 +96,7 @@ class HongKong(HolidayBase):
if self.observed:
if ching_ming_date.weekday() == SUN:
self[ching_ming_date + rd(days=+1)] = day_following + name
- ching_ming_date = ching_ming_date + rd(days=+1)
+ ching_ming_date += rd(days=+1)
else:
self[ching_ming_date] = name
else:
@@ -189,7 +189,7 @@ class HongKong(HolidayBase):
self[mid_autumn_date + rd(days=+1)] = (
day_following + "the " + name
)
- mid_autumn_date = mid_autumn_date + rd(days=+1)
+ mid_autumn_date += rd(days=+1)
else:
self[mid_autumn_date] = name
diff --git a/holidays/countries/korea.py b/holidays/countries/korea.py
index a9c2fe7..b3b030a 100644
--- a/holidays/countries/korea.py
+++ b/holidays/countries/korea.py
@@ -273,7 +273,7 @@ class Korea(HolidayBase):
) or ( # if it's weekend(may include sat or not)
cur in self and name != self[cur]
): # if it's already another holiday
- cur = cur + rd(days=1)
+ cur += rd(days=1)
is_alt = True
continue
return is_alt, cur
diff --git a/holidays/countries/mozambique.py b/holidays/countries/mozambique.py
index ca2d598..200586d 100644
--- a/holidays/countries/mozambique.py
+++ b/holidays/countries/mozambique.py
@@ -38,7 +38,7 @@ class Mozambique(HolidayBase):
# which is 40 days before easter excluding sundays
carnival = e - rd(days=46)
while carnival.weekday() != TUE:
- carnival = carnival - rd(days=1)
+ carnival -= rd(days=1)
self[carnival] = "Carnaval"
self[date(year, FEB, 3)] = "Dia dos Heróis Moçambicanos"
diff --git a/holidays/countries/netherlands.py b/holidays/countries/netherlands.py
index ddbbba9..5aeae44 100644
--- a/holidays/countries/netherlands.py
+++ b/holidays/countries/netherlands.py
@@ -64,7 +64,7 @@ class Netherlands(HolidayBase):
if year >= 2014:
kings_day = date(year, APR, 27)
if kings_day.weekday() == SUN:
- kings_day = kings_day - rd(days=1)
+ kings_day -= rd(days=1)
self[kings_day] = "Koningsdag"
@@ -76,9 +76,9 @@ class Netherlands(HolidayBase):
if queens_day.weekday() == SUN:
if year < 1980:
- queens_day = queens_day + rd(days=1)
+ queens_day += rd(days=1)
else:
- queens_day = queens_day - rd(days=1)
+ queens_day -= rd(days=1)
self[queens_day] = "Koninginnedag"
diff --git a/holidays/countries/united_states.py b/holidays/countries/united_states.py
index 6064016..e59e9c8 100644
--- a/holidays/countries/united_states.py
+++ b/holidays/countries/united_states.py
@@ -576,7 +576,7 @@ class UnitedStates(HolidayBase):
):
name = "Christmas Eve"
self[date(year, DEC, 24)] = name
- name = name + " (Observed)"
+ name += " (Observed)"
# If on Friday, observed on Thursday
if self.observed and date(year, DEC, 24).weekday() == FRI:
self[date(year, DEC, 24) + rd(days=-1)] = name
@@ -597,7 +597,7 @@ class UnitedStates(HolidayBase):
if self.subdiv == "NC" and year >= 2013:
name = "Day After Christmas"
self[date(year, DEC, 26)] = name
- name = name + " (Observed)"
+ name += " (Observed)"
# If on Saturday or Sunday, observed on Monday
if self.observed and date(year, DEC, 26).weekday() in WEEKEND:
self[date(year, DEC, 26) + rd(weekday=MO)] = name
diff --git a/holidays/countries/zambia.py b/holidays/countries/zambia.py
index c15604a..b529508 100644
--- a/holidays/countries/zambia.py
+++ b/holidays/countries/zambia.py
@@ -51,7 +51,7 @@ class Zambia(HolidayBase):
# for the given year and month
d1 = date(year, JUL, 7)
offset = -d1.weekday() # weekday = 0 means monday
- d1 = d1 + rd(days=offset)
+ d1 += rd(days=offset)
self[d1] = "Heroes' Day"
self[d1 + rd(days=1)] = "Unity Day"
@@ -59,7 +59,7 @@ class Zambia(HolidayBase):
# 1st Monday of Aug = "Farmers' Day"
d2 = date(year, AUG, 7)
offset = -d2.weekday()
- d2 = d2 + rd(days=offset)
+ d2 += rd(days=offset)
self[d2] = "Farmers' Day"
diff --git a/holidays/countries/zimbabwe.py b/holidays/countries/zimbabwe.py
index 8ffff1d..c1807a0 100644
--- a/holidays/countries/zimbabwe.py
+++ b/holidays/countries/zimbabwe.py
@@ -57,7 +57,7 @@ class Zimbabwe(HolidayBase):
while zimbabwe_heroes_day.isoweekday() != MON and (
8 <= zimbabwe_heroes_day.day <= 14
):
- zimbabwe_heroes_day = zimbabwe_heroes_day + rd(days=1)
+ zimbabwe_heroes_day += rd(days=1)
self[zimbabwe_heroes_day] = "Zimbabwe Heroes' Day"
@@ -68,7 +68,7 @@ class Zimbabwe(HolidayBase):
while defence_forces_day.isoweekday() != TUE and (
8 <= defence_forces_day.day <= 14
):
- defence_forces_day = defence_forces_day + rd(days=1)
+ defence_forces_day += rd(days=1)
self[defence_forces_day] = "Defense Forces Day"
Hi @elfring thank you for your clear explanation.. sorry but due to a different perl version, I cannot really get to your results, due to the previously reported issue. This given, although I don't feel your optimizations as really high priority, I'm definitely interested in including them in our code: if you are available to develop a PR, I will surely merge it. Thank you very much for your support, cheers! 👍
Which Perl versions would hinder adjustments (which can generally be generated by the mentioned source code search and replacement approach)?
:thought_balloon: Would any other contributor be quicker with the integration of the shown change possibilities?
@elfring, @dr-prodigy thank you both! The issue is resolved and can be closed now.
:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of augmented assignment statements accordingly.
Would you like to integrate anything from a transformation result which can be generated by a command like the following? (:point_right: Please check also for questionable change suggestions because of an evolving search pattern.)
How do you think about to improve 24 source code places? :thinking: