fix chrome tasks (#230)
* fix chrome * fix: fix proxy setup * feat&fix: add proxy support in setup and remove hardcoded proxy from example * fix tasks * fix chrome finished * fix * clean chrome_fix code * clean chrome_fix code --------- Co-authored-by: adlsdztony <zzl0712@connect.hku.hk>
This commit is contained in:
@@ -71,7 +71,10 @@ relativeTime_to_IntDay = {
|
||||
"this Sunday": "special",
|
||||
"next Monday": "special",
|
||||
"next Friday": "special",
|
||||
"first monday four months later": "special"
|
||||
"first monday four months later": "special",
|
||||
"first monday eight months later": "special",
|
||||
"next Monday split": "special",
|
||||
"next Friday split": "special"
|
||||
}
|
||||
|
||||
def get_rule(env, config: Dict[str, R]) -> R:
|
||||
@@ -125,6 +128,12 @@ def get_rule_relativeTime(env, config: Dict[str, R]) -> R:
|
||||
# get the first monday of the next_month
|
||||
temp_date = datetime(next_year, next_month, 1)
|
||||
absoluteDay = temp_date + timedelta(days=((6-temp_date.weekday())+1)%7)
|
||||
elif start_relative_time == "first monday eight months later":
|
||||
next_year = now.year + 1 if now.month >= 5 else now.year
|
||||
next_month = (now.month + 8)%12
|
||||
# get the first monday of the next_month
|
||||
temp_date = datetime(next_year, next_month, 1)
|
||||
absoluteDay = temp_date + timedelta(days=((6-temp_date.weekday())+1)%7)
|
||||
regular_time = apply_rules_to_timeFormat(relativeRules["expected"]["time"], absoluteDay)
|
||||
config["rules"]["expected"]["time"] = regular_time
|
||||
|
||||
@@ -144,12 +153,20 @@ def get_rule_relativeTime(env, config: Dict[str, R]) -> R:
|
||||
next_month = now.month + 1 if now.month < 12 else 1
|
||||
next_day = 10
|
||||
from_absoluteDay = datetime(next_year, next_month, next_day)
|
||||
elif from_time == "next Monday":
|
||||
elif from_time == "next Monday" or from_time == "next Monday split":
|
||||
from_absoluteDay = now + timedelta(days=((6-now.weekday())+1))
|
||||
else:
|
||||
pass # more rules here
|
||||
regular_from_time = apply_rules_to_timeFormat(relativeRules["expected"]["from"], from_absoluteDay)
|
||||
config["rules"]["expected"]["from"] = regular_from_time
|
||||
if from_time == "next Monday split":
|
||||
puday = apply_rules_to_timeFormat(relativeRules["expected"]["puDay"], from_absoluteDay)
|
||||
config["rules"]["expected"]["puDay"] = puday
|
||||
pumonth = apply_rules_to_timeFormat(relativeRules["expected"]["puMonth"], from_absoluteDay)
|
||||
config["rules"]["expected"]["puMonth"] = pumonth
|
||||
puyear = apply_rules_to_timeFormat(relativeRules["expected"]["puYear"], from_absoluteDay)
|
||||
config["rules"]["expected"]["puYear"] = puyear
|
||||
else:
|
||||
regular_from_time = apply_rules_to_timeFormat(relativeRules["expected"]["from"], from_absoluteDay)
|
||||
config["rules"]["expected"]["from"] = regular_from_time
|
||||
|
||||
# deal with to_time
|
||||
if relativeTime_to_IntDay[to_time] != "special":
|
||||
@@ -164,15 +181,23 @@ def get_rule_relativeTime(env, config: Dict[str, R]) -> R:
|
||||
next_month = now.month + 1 if now.month < 12 else 1
|
||||
next_day = 11
|
||||
to_absoluteDay = datetime(next_year, next_month, next_day)
|
||||
elif to_time == "next Friday":
|
||||
elif to_time == "next Friday" or to_time == "next Friday split":
|
||||
if now.weekday() < 4 and from_time in ["next Monday"]:
|
||||
to_absoluteDay = now + timedelta(days=((4-now.weekday())+7))
|
||||
else:
|
||||
to_absoluteDay = now + timedelta(days=((4-now.weekday()) if now.weekday() < 4 else (6-now.weekday()) + 5))
|
||||
else:
|
||||
pass # more rules here
|
||||
regular_to_time = apply_rules_to_timeFormat(relativeRules["expected"]["to"], to_absoluteDay)
|
||||
config["rules"]["expected"]["to"] = regular_to_time
|
||||
if to_time == "next Friday split":
|
||||
to_day = apply_rules_to_timeFormat(relativeRules["expected"]["doDay"], to_absoluteDay)
|
||||
config["rules"]["expected"]["doDay"] = to_day
|
||||
to_month = apply_rules_to_timeFormat(relativeRules["expected"]["doMonth"], to_absoluteDay)
|
||||
config["rules"]["expected"]["doMonth"] = to_month
|
||||
to_year = apply_rules_to_timeFormat(relativeRules["expected"]["doYear"], to_absoluteDay)
|
||||
config["rules"]["expected"]["doYear"] = to_year
|
||||
else:
|
||||
regular_to_time = apply_rules_to_timeFormat(relativeRules["expected"]["to"], to_absoluteDay)
|
||||
config["rules"]["expected"]["to"] = regular_to_time
|
||||
|
||||
return config["rules"]
|
||||
|
||||
@@ -186,6 +211,7 @@ def apply_rules_to_timeFormat(timeFormat: str, absoluteDay: datetime):
|
||||
timeFormat = timeFormat.replace("{month}", month_mapping_full[absoluteDay.month], 1)
|
||||
timeFormat = timeFormat.replace("{MonthFull}", Month_Mapping_Full[absoluteDay.month], 1)
|
||||
timeFormat = timeFormat.replace("{Day0D}", "0"+str(absoluteDay.day) if absoluteDay.day < 10 else str(absoluteDay.day), 1)
|
||||
timeFormat = timeFormat.replace("{MonthD}", str(absoluteDay.month), 1)
|
||||
# you can add other replace rules here
|
||||
|
||||
return timeFormat
|
||||
|
||||
Reference in New Issue
Block a user