OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The Volume Shadow Snapshots (VSS) path specification implementation.""" | 2 """The Volume Shadow Snapshots (VSS) path specification implementation.""" |
3 | 3 |
| 4 from __future__ import unicode_literals |
| 5 |
4 from dfvfs.lib import definitions | 6 from dfvfs.lib import definitions |
5 from dfvfs.path import factory | 7 from dfvfs.path import factory |
6 from dfvfs.path import path_spec | 8 from dfvfs.path import path_spec |
7 | 9 |
8 | 10 |
9 class VShadowPathSpec(path_spec.PathSpec): | 11 class VShadowPathSpec(path_spec.PathSpec): |
10 """Class that implements the VSS path specification. | 12 """Volume Shadow Snapshots (VSS) path specification. |
11 | 13 |
12 Attributes: | 14 Attributes: |
13 location (str): location. | 15 location (str): location. |
14 store_index (int): store index. | 16 store_index (int): store index. |
15 """ | 17 """ |
16 | 18 |
17 TYPE_INDICATOR = definitions.TYPE_INDICATOR_VSHADOW | 19 TYPE_INDICATOR = definitions.TYPE_INDICATOR_VSHADOW |
18 | 20 |
19 def __init__(self, location=None, parent=None, store_index=None, **kwargs): | 21 def __init__(self, location=None, parent=None, store_index=None, **kwargs): |
20 """Initializes the path specification. | 22 """Initializes a path specification. |
21 | 23 |
22 Note that the VSS path specification must have a parent. | 24 Note that the VSS path specification must have a parent. |
23 | 25 |
24 Args: | 26 Args: |
25 location (Optional[str]): location. | 27 location (Optional[str]): location. |
26 parent (Optional[PathSpec]): parent path specification. | 28 parent (Optional[PathSpec]): parent path specification. |
27 store_index (Optional[int]): store index. | 29 store_index (Optional[int]): store index. |
28 | 30 |
29 Raises: | 31 Raises: |
30 ValueError: when parent is not set. | 32 ValueError: when parent is not set. |
31 """ | 33 """ |
32 if not parent: | 34 if not parent: |
33 raise ValueError(u'Missing parent value.') | 35 raise ValueError('Missing parent value.') |
34 | 36 |
35 super(VShadowPathSpec, self).__init__(parent=parent, **kwargs) | 37 super(VShadowPathSpec, self).__init__(parent=parent, **kwargs) |
36 self.location = location | 38 self.location = location |
37 self.store_index = store_index | 39 self.store_index = store_index |
38 | 40 |
39 @property | 41 @property |
40 def comparable(self): | 42 def comparable(self): |
41 """str: comparable representation of the path specification.""" | 43 """str: comparable representation of the path specification.""" |
42 string_parts = [] | 44 string_parts = [] |
43 | 45 |
44 if self.location is not None: | 46 if self.location is not None: |
45 string_parts.append(u'location: {0:s}'.format(self.location)) | 47 string_parts.append('location: {0:s}'.format(self.location)) |
46 if self.store_index is not None: | 48 if self.store_index is not None: |
47 string_parts.append(u'store index: {0:d}'.format(self.store_index)) | 49 string_parts.append('store index: {0:d}'.format(self.store_index)) |
48 | 50 |
49 return self._GetComparable(sub_comparable_string=u', '.join(string_parts)) | 51 return self._GetComparable(sub_comparable_string=', '.join(string_parts)) |
50 | 52 |
51 | 53 |
52 factory.Factory.RegisterPathSpec(VShadowPathSpec) | 54 factory.Factory.RegisterPathSpec(VShadowPathSpec) |
OLD | NEW |