Reformatting.

This commit is contained in:
Achim D. Brucker 2017-10-06 18:33:56 +01:00
parent c1750838f1
commit ac76c8c1e4
1 changed files with 21 additions and 10 deletions

View File

@ -165,25 +165,29 @@ def analyze_crx(conf, crx):
def analyze_tar(conf, tarfile):
last_crx_file = ''
# from_date
# latest_date
# from_date
# latest_date
match = False
extid = os.path.splitext(os.path.basename(tarfile))[0]
from_dateobj = None
latest_dateobj = None
if conf.from_date is not None:
from_dateobj = dateutil.parser.parse(conf.from_date)
if from_dateobj.tzinfo is None or from_dateobj.tzinfo.utcoffset(from_dateobj) is None:
if from_dateobj.tzinfo is None or from_dateobj.tzinfo.utcoffset(
from_dateobj) is None:
from_dateobj = from_dateobj.replace(tzinfo=datetime.timezone.utc)
if conf.latest_date is not None:
latest_dateobj = dateutil.parser.parse(conf.latest_date)
if latest_dateobj.tzinfo is None or latest_dateobj.tzinfo.utcoffset(latest_dateobj) is None:
latest_dateobj = latest_dateobj.replace(tzinfo=datetime.timezone.utc)
if latest_dateobj.tzinfo is None or latest_dateobj.tzinfo.utcoffset(
latest_dateobj) is None:
latest_dateobj = latest_dateobj.replace(
tzinfo=datetime.timezone.utc)
match = False
if from_dateobj is None:
last_crx_file = last_crx(os.path.join(conf.archive_dir, "data"), extid, latest_dateobj)
last_crx_file = last_crx(
os.path.join(conf.archive_dir, "data"), extid, latest_dateobj)
if last_crx_file == "" or last_crx_file is None:
logging.warning("No crx in " + extid)
else:
@ -193,7 +197,8 @@ def analyze_tar(conf, tarfile):
else:
if latest_dateobj is None:
# only from date is given
first_crx_file = first_crx(os.path.join(conf.archive_dir, "data"), extid, from_dateobj)
first_crx_file = first_crx(
os.path.join(conf.archive_dir, "data"), extid, from_dateobj)
if first_crx_file == "" or first_crx_file is None:
logging.warning("No crx in " + extid)
else:
@ -202,7 +207,8 @@ def analyze_tar(conf, tarfile):
match = analyze_crx(conf, crx)
else:
# both dates are given
all_crx_files = all_crx(os.path.join(conf.archive_dir, "data"), extid)
all_crx_files = all_crx(
os.path.join(conf.archive_dir, "data"), extid)
if all_crx_files == []:
logging.warning("No crx in " + extid)
else:
@ -211,6 +217,7 @@ def analyze_tar(conf, tarfile):
with archive.extractfile(crx_file) as crx:
match = analyze_crx(conf, crx) or match
def analyze_file(conf, filename):
with open(filename, 'rb') as fileobj:
data = fileobj.read()
@ -318,14 +325,18 @@ if __name__ == "__main__":
'--latest-date',
metavar='DATE',
type=str,
help='select latest crx from tar, released before DATE. Together with --from-date, specifies all crx released in specified date range.')
help=
'select latest crx from tar, released before DATE. Together with --from-date, specifies all crx released in specified date range.'
)
main_parser.add_argument(
'-d',
'--from-date',
metavar='DATE',
type=str,
help='select oldest crx from tar released after DATE. Together with --from-date, specifies all crx released in specified date range.')
help=
'select oldest crx from tar released after DATE. Together with --from-date, specifies all crx released in specified date range.'
)
main_parser.add_argument(
'-f',