Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] property strict_timestamp was added #14168

Merged
merged 7 commits into from
Jun 22, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions py/selenium/webdriver/firefox/firefox_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ def __init__(self, profile_directory=None):
This defaults to None and will create a new
directory when object is created.
"""
self._strict_timestamps = False
titusfortner marked this conversation as resolved.
Show resolved Hide resolved
self._desired_preferences = {}
if profile_directory:
newprof = os.path.join(tempfile.mkdtemp(), "webdriver-py-profilecopy")
self._profile_dir = os.path.join(tempfile.mkdtemp(), "webdriver-py-profilecopy")
shutil.copytree(
profile_directory, newprof, ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock")
profile_directory, self._profile_dir, ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock")
titusfortner marked this conversation as resolved.
Show resolved Hide resolved
)
self._profile_dir = newprof
os.chmod(self._profile_dir, 0o755)
else:
self._profile_dir = tempfile.mkdtemp()
Expand Down Expand Up @@ -93,6 +93,13 @@ def update_preferences(self):
f.write(f'user_pref("{key}", {json.dumps(value)});\n')

# Properties
@property
titusfortner marked this conversation as resolved.
Show resolved Hide resolved
def strict_timestamps(self) -> bool:
return self._strict_timestamps

@strict_timestamps.setter
def strict_timestamps(self, value: bool):
self._strict_timestamps = value

@property
def path(self):
Expand Down Expand Up @@ -152,7 +159,7 @@ def encoded(self) -> str:
if self._desired_preferences:
self.update_preferences()
fp = BytesIO()
with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED) as zipped:
with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED, strict_timestamps=self.strict_timestamps) as zipped:
path_root = len(self.path) + 1 # account for trailing slash
for base, _, files in os.walk(self.path):
for fyle in files:
Expand Down