1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-07-13 01:20:24 +02:00

fix error on empty directory

This commit is contained in:
Kelly Brazil
2020-06-10 05:51:12 -07:00
parent 12a80e7db0
commit c8e72805cf

View File

@ -149,7 +149,7 @@ import jc.utils
class info(): class info():
version = '1.4' version = '1.5'
description = 'ls command parser' description = 'ls command parser'
author = 'Kelly Brazil' author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com' author_email = 'kellyjonbrazil@gmail.com'
@ -226,20 +226,19 @@ def parse(data, raw=False, quiet=False):
linedata = data.splitlines() linedata = data.splitlines()
# Delete first line if it starts with 'total 1234'
if linedata: if linedata:
# Delete first line if it starts with 'total 1234'
if re.match(r'total [0-9]+', linedata[0]): if re.match(r'total [0-9]+', linedata[0]):
linedata.pop(0) linedata.pop(0)
# Look for parent line if glob or -R is used # Look for parent line if glob or -R is used
if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \ if not re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]) \
and linedata[0].endswith(':'): and linedata[0].endswith(':'):
parent = linedata.pop(0)[:-1] parent = linedata.pop(0)[:-1]
# Pop following total line if it exists # Pop following total line if it exists
if re.match(r'total [0-9]+', linedata[0]): if re.match(r'total [0-9]+', linedata[0]):
linedata.pop(0) linedata.pop(0)
if linedata:
# Check if -l was used to parse extra data # Check if -l was used to parse extra data
if re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]): if re.match(r'[-dclpsbDCMnP?]([-r][-w][-xsS]){2}([-r][-w][-xtT])[+]?', linedata[0]):
for entry in linedata: for entry in linedata: