OLD | NEW |
(Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import os |
| 6 |
| 7 import entry |
| 8 |
| 9 class File(entry.Entry): |
| 10 """ Handle file property in state. |
| 11 """ |
| 12 def __init__(self, variable_expander, visitor): |
| 13 super(File, self).__init__(variable_expander, visitor) |
| 14 self.file_path = None |
| 15 self.is_file_existed = None |
| 16 self.should_file_exist = None |
| 17 |
| 18 def Check(self, entry_name, entry_value): |
| 19 """ Check whether a file is existed or not. |
| 20 |
| 21 Args: |
| 22 'entry_name' - A string represents the path to the file being |
| 23 verified. |
| 24 'entry_value' - A dictionary with the following key and value: |
| 25 'exists': a boolean indicating whether the file should |
| 26 exist. |
| 27 """ |
| 28 self.file_path = self._variable_expander.Expand(entry_name) |
| 29 self.is_file_existed = os.path.exists(self.file_path) |
| 30 self.should_file_exist = entry_value['exists'] |
| 31 self._visitor.VisitFile(self) |
OLD | NEW |