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) |