LEFT | RIGHT |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """The location-based path specification implementation.""" | 2 """The location-based path specification implementation.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 from dfvfs.path import path_spec | 6 from dfvfs.path import path_spec |
7 | 7 |
8 | 8 |
9 class LocationPathSpec(path_spec.PathSpec): | 9 class LocationPathSpec(path_spec.PathSpec): |
10 """Base class for location-based path specifications. | 10 """Base class for location-based path specifications. |
11 | 11 |
12 Attributes: | 12 Attributes: |
13 location (str): location. | 13 location (str): location. |
14 """ | 14 """ |
15 | 15 |
16 def __init__(self, location=None, parent=None, **kwargs): | 16 def __init__(self, location=None, parent=None, **kwargs): |
17 """Initializes the path specification. | 17 """Initializes a path specification. |
18 | 18 |
19 Args: | 19 Args: |
20 location (Optional[str]): location. | 20 location (Optional[str]): location. |
21 parent (Optional[PathSpec]): parent path specification. | 21 parent (Optional[PathSpec]): parent path specification. |
22 | 22 |
23 Raises: | 23 Raises: |
24 ValueError: when location is not set. | 24 ValueError: when location is not set. |
25 """ | 25 """ |
26 if not location: | 26 if not location: |
27 raise ValueError('Missing location value.') | 27 raise ValueError('Missing location value.') |
28 | 28 |
29 super(LocationPathSpec, self).__init__(parent=parent, **kwargs) | 29 super(LocationPathSpec, self).__init__(parent=parent, **kwargs) |
30 self.location = location | 30 self.location = location |
31 | 31 |
32 @property | 32 @property |
33 def comparable(self): | 33 def comparable(self): |
34 """str: comparable representation of the path specification.""" | 34 """str: comparable representation of the path specification.""" |
35 sub_comparable_string = 'location: {0:s}'.format(self.location) | 35 sub_comparable_string = 'location: {0:s}'.format(self.location) |
36 return self._GetComparable(sub_comparable_string=sub_comparable_string) | 36 return self._GetComparable(sub_comparable_string=sub_comparable_string) |
LEFT | RIGHT |