diff options
| author | Sebastian Heinlein <sebi@sebi-pc> | 2006-09-29 17:59:09 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@sebi-pc> | 2006-09-29 17:59:09 +0200 |
| commit | 7afafc629b7c5b408972aafc46ef5d1887544aac (patch) | |
| tree | 05d20b738ad00a5952a60c95732b3f883731461d /UpdateManager/Common | |
| parent | 90a9b9f0faf09a401693f7cfcbd362ff62559929 (diff) | |
| parent | 44bb7423ea89e0174fd33108bc1112677283114e (diff) | |
| download | python-apt-7afafc629b7c5b408972aafc46ef5d1887544aac.tar.gz | |
* merge with mvo
Diffstat (limited to 'UpdateManager/Common')
| -rw-r--r-- | UpdateManager/Common/aptsources.py | 16 | ||||
| -rw-r--r-- | UpdateManager/Common/utils.py | 19 |
2 files changed, 32 insertions, 3 deletions
diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py index 836b8fae..06d83e01 100644 --- a/UpdateManager/Common/aptsources.py +++ b/UpdateManager/Common/aptsources.py @@ -619,6 +619,8 @@ class Distribution: # e.g. "dapper", "dapper-updates") comps_per_dist = {} for s in sources: + if s.type != "deb": + continue if not comps_per_dist.has_key(s.dist): comps_per_dist[s.dist] = set() map(comps_per_dist[s.dist].add, s.comps) @@ -631,10 +633,18 @@ class Distribution: for source in sources: add_component_only_once(source, comps_per_dist) + # now do the same for source dists if self.get_source_code == True: - for source in self.source_code_sources: - if comp not in source.comps: - add_component_only_once(source, comps_per_dist) + comps_per_dist = {} + for s in self.source_code_sources: + if s.type != "deb-src": + continue + if not comps_per_dist.has_key(s.dist): + comps_per_dist[s.dist] = set() + map(comps_per_dist[s.dist].add, s.comps) + for source in self.source_code_sources: + if comp not in source.comps: + add_component_only_once(source, comps_per_dist) def disable_component(self, sourceslist, comp): diff --git a/UpdateManager/Common/utils.py b/UpdateManager/Common/utils.py index 099cbfed..1fcd022f 100644 --- a/UpdateManager/Common/utils.py +++ b/UpdateManager/Common/utils.py @@ -1,4 +1,6 @@ import gtk +from gettext import gettext as _ +import locale def str_to_bool(str): if str == "0" or str.upper() == "FALSE": @@ -21,3 +23,20 @@ def error(parent, summary, message): res = d.run() d.destroy() return + +def humanize_size(bytes): + """ + Convert a given size in bytes to a nicer better readable unit + """ + if bytes == 0: + # TRANSLATORS: download size is 0 + return _("None") + elif bytes < 1024: + # TRANSLATORS: download size of very small updates + return _("1 KB") + elif bytes < 1024 * 1024: + # TRANSLATORS: download size of small updates, e.g. "250 KB" + return locale.format(_("%.0f KB"), bytes/1024) + else: + # TRANSLATORS: download size of updates, e.g. "2.3 MB" + return locale.format(_("%.1f MB"), bytes / 1024 / 1024) |
