mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-17 04:03:43 +08:00
rtemstoolkit/path : Add listdir function
This commit is contained in:

committed by
Chris Johns

parent
925448a452
commit
9f197dea76
@@ -157,6 +157,33 @@ def expanduser(path):
|
|||||||
path = os.path.expanduser(path)
|
path = os.path.expanduser(path)
|
||||||
return shell(path)
|
return shell(path)
|
||||||
|
|
||||||
|
def listdir(path):
|
||||||
|
path = host(path)
|
||||||
|
files = []
|
||||||
|
if not exists(path):
|
||||||
|
raise error.general('path does not exist : %s' % (path))
|
||||||
|
elif not isdir(path):
|
||||||
|
raise error.general('path is not a directory: %s' % (path))
|
||||||
|
else:
|
||||||
|
if windows:
|
||||||
|
try:
|
||||||
|
files = os.listdir(host(path))
|
||||||
|
except IOError:
|
||||||
|
raise error.general('Could not list files: %s' % (path))
|
||||||
|
except OSError as e:
|
||||||
|
raise error.general('Could not list files: %s: %s' % (path, str(e)))
|
||||||
|
except WindowsError as e:
|
||||||
|
raise error.general('Could not list files: %s: %s' % (path, str(e)))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
files = os.listdir(host(path))
|
||||||
|
except IOError:
|
||||||
|
raise error.general('Could not list files: %s' % (path))
|
||||||
|
except OSError as e:
|
||||||
|
raise error.general('Could not list files: %s: %s' % (path, str(e)))
|
||||||
|
|
||||||
|
return files
|
||||||
|
|
||||||
def collect_files(path_):
|
def collect_files(path_):
|
||||||
#
|
#
|
||||||
# Convert to shell paths and return shell paths.
|
# Convert to shell paths and return shell paths.
|
||||||
@@ -184,7 +211,7 @@ def copy_tree(src, dst):
|
|||||||
hdst = host(dst)
|
hdst = host(dst)
|
||||||
|
|
||||||
if os.path.exists(src) and os.path.isdir(src):
|
if os.path.exists(src) and os.path.isdir(src):
|
||||||
names = os.listdir(src)
|
names = listdir(src)
|
||||||
else:
|
else:
|
||||||
names = [basename(src)]
|
names = [basename(src)]
|
||||||
src = dirname(src)
|
src = dirname(src)
|
||||||
|
@@ -215,7 +215,7 @@ class report_gen_html:
|
|||||||
for symbol_set in self.symbol_sets:
|
for symbol_set in self.symbol_sets:
|
||||||
symbol_set_dir = path.join(self.build_dir,
|
symbol_set_dir = path.join(self.build_dir,
|
||||||
self.bsp + '-coverage', symbol_set)
|
self.bsp + '-coverage', symbol_set)
|
||||||
html_files = os.listdir(symbol_set_dir)
|
html_files = path.listdir(symbol_set_dir)
|
||||||
for html_file in html_files:
|
for html_file in html_files:
|
||||||
html_file = path.join(symbol_set_dir, html_file)
|
html_file = path.join(symbol_set_dir, html_file)
|
||||||
if path.exists(html_file) and 'html' in html_file:
|
if path.exists(html_file) and 'html' in html_file:
|
||||||
@@ -291,7 +291,7 @@ class symbol_parser(object):
|
|||||||
config.add_section('symbol-sets')
|
config.add_section('symbol-sets')
|
||||||
config.set('symbol-sets', 'sets', sset)
|
config.set('symbol-sets', 'sets', sset)
|
||||||
config.add_section(sset)
|
config.add_section(sset)
|
||||||
object_files = [o for o in os.listdir(self.symbol_sets[sset]) if o[-1] == 'o']
|
object_files = [o for o in path.listdir(self.symbol_sets[sset]) if o[-1] == 'o']
|
||||||
object_paths = []
|
object_paths = []
|
||||||
for o in object_files:
|
for o in object_files:
|
||||||
object_paths.append(path.join(self.symbol_sets[sset], o))
|
object_paths.append(path.join(self.symbol_sets[sset], o))
|
||||||
|
Reference in New Issue
Block a user