Moving like methods near eachother.

This commit is contained in:
Roland 2022-11-03 16:52:14 -06:00
parent 72731f2cea
commit aef7f1162d
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -141,11 +141,6 @@ class Archive(Base, ModelHelper):
).order_by(Archive.archive_datetime))
return alternatives
@staticmethod
def find_by_path(path, session: Session) -> Optional[Base]:
archive = session.query(Archive).filter_by(singlefile_path=path).one_or_none()
return archive
def read_singlefile_data(self):
"""
Read the start of the singlefile (if any) and decode the Archive information.
@ -153,7 +148,7 @@ class Archive(Base, ModelHelper):
path = self.singlefile_file.path if self.singlefile_file else self.singlefile_path
if not path:
# Can't read contents of nothing.
return
raise ValueError('Cannot read singlefile data when this has no files')
with path.open('rt') as fh:
head = fh.read(500)
@ -221,6 +216,11 @@ class Archive(Base, ModelHelper):
except Exception as e:
logger.warning(f'Unable to validate {self}', exc_info=e)
@staticmethod
def find_by_path(path, session: Session) -> Optional[Base]:
archive = session.query(Archive).filter_by(singlefile_path=path).one_or_none()
return archive
@staticmethod
def find_by_paths(paths, session):
archives = list(session.query(Archive).filter(Archive.singlefile_path.in_(paths)))