Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: chrome/test/mini_installer/file.py

Issue 2747023002: Cleanup machine based on the state in configuration file for mini installer test.
Patch Set: refactor to use visitor pattern Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/mini_installer/entry.py ('k') | chrome/test/mini_installer/file_verifier.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/mini_installer/file.py
diff --git a/chrome/test/mini_installer/file.py b/chrome/test/mini_installer/file.py
new file mode 100644
index 0000000000000000000000000000000000000000..eb9af6f43a9a8cde89e8c258600c7851a6007eae
--- /dev/null
+++ b/chrome/test/mini_installer/file.py
@@ -0,0 +1,31 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+
+import entry
+
+class File(entry.Entry):
+ """ Handle file property in state.
+ """
+ def __init__(self, variable_expander, visitor):
+ super(File, self).__init__(variable_expander, visitor)
+ self.file_path = None
+ self.is_file_existed = None
+ self.should_file_exist = None
+
+ def Check(self, entry_name, entry_value):
+ """ Check whether a file is existed or not.
+
+ Args:
+ 'entry_name' - A string represents the path to the file being
+ verified.
+ 'entry_value' - A dictionary with the following key and value:
+ 'exists': a boolean indicating whether the file should
+ exist.
+ """
+ self.file_path = self._variable_expander.Expand(entry_name)
+ self.is_file_existed = os.path.exists(self.file_path)
+ self.should_file_exist = entry_value['exists']
+ self._visitor.VisitFile(self)
« no previous file with comments | « chrome/test/mini_installer/entry.py ('k') | chrome/test/mini_installer/file_verifier.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698