mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 01:06:15 +01:00
Implement ordering of File objects
This commit is contained in:
parent
e56773bbaa
commit
55503e13ca
11
osc/core.py
11
osc/core.py
@ -248,6 +248,7 @@ def os_path_samefile(path1, path2):
|
|||||||
return os.path.realpath(path1) == os.path.realpath(path2)
|
return os.path.realpath(path1) == os.path.realpath(path2)
|
||||||
|
|
||||||
|
|
||||||
|
@total_ordering
|
||||||
class File:
|
class File:
|
||||||
"""represent a file, including its metadata"""
|
"""represent a file, including its metadata"""
|
||||||
|
|
||||||
@ -264,6 +265,16 @@ class File:
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
self_data = (self.name, self.md5, self.size, self.mtime, self.skipped)
|
||||||
|
other_data = (other.name, other.md5, other.size, other.mtime, other.skipped)
|
||||||
|
return self_data == other_data
|
||||||
|
|
||||||
|
def __lt__(self, other):
|
||||||
|
self_data = (self.name, self.md5, self.size, self.mtime, self.skipped)
|
||||||
|
other_data = (other.name, other.md5, other.size, other.mtime, other.skipped)
|
||||||
|
return self_data < other_data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_xml_node(cls, node):
|
def from_xml_node(cls, node):
|
||||||
assert node.tag == "entry"
|
assert node.tag == "entry"
|
||||||
|
Loading…
Reference in New Issue
Block a user