Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/shiny:running:12:shiny##v2.0.8
/manager:running:0:/usr/share/tomcat8-admin/manager
/shiny:running:15:shiny##v2.0.7
"""
sorted_apps = """/:running:0:ROOT
/contacts:running:8:running
/contacts:running:3:running##4.1
/manager:running:0:/usr/share/tomcat8-admin/manager
/shiny:running:15:shiny##v2.0.7
/shiny:running:12:shiny##v2.0.8
/host-manager:stopped:0:/usr/share/tomcat8-admin/host-manager
/shiny:stopped:0:shiny##v2.0.5
/shiny:stopped:17:shiny##v2.0.6
"""
apps = parse_apps(raw_apps)
apps.sort(key=tm.models.TomcatApplication.sort_by_state_by_path_by_version)
result = ''
strapps = map(str, apps)
result = '\n'.join(strapps) + '\n'
assert result == sorted_apps
We rely on the `TomcatApplication` object to determine the sort order.
:return: a list of `TomcatApplication` objects
"""
rtn = []
# select the apps that should be included
if args.state:
rtn = filter(lambda app: app.state == args.state, apps)
else:
rtn = apps
# now sort them
if args.by == 'path':
rtn = sorted(rtn, key=tm.models.TomcatApplication.sort_by_path_by_version_by_state)
else:
rtn = sorted(rtn, key=tm.models.TomcatApplication.sort_by_state_by_path_by_version)
return rtn