Replaced the Cached column with a Fetch one
[zeroinstall.git] / zeroinstall / 0launch-gui / utils.py
blob52e8a152054be14cd025afac6cacfba976c8534a
1 # Copyright (C) 2008, Thomas Leonard
2 # See the README file for details, or visit http://0install.net.
4 from zeroinstall import support
6 def get_fetch_info(policy, impl):
7 """Get the text for a Fetch column."""
8 if impl is None:
9 return ""
10 elif policy.get_cached(impl):
11 if impl.id.startswith('/'):
12 return '(local)'
13 elif impl.id.startswith('package:'):
14 return '(package)'
15 else:
16 return '(cached)'
17 else:
18 src = policy.fetcher.get_best_source(impl)
19 if src:
20 return support.pretty_size(src.size)
21 else:
22 return '(unavailable)'