diff options
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hobpages.py')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/hobpages.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobpages.py b/bitbake/lib/bb/ui/crumbs/hobpages.py index d8e59c44dc..5045ea2019 100755 --- a/bitbake/lib/bb/ui/crumbs/hobpages.py +++ b/bitbake/lib/bb/ui/crumbs/hobpages.py | |||
@@ -83,3 +83,42 @@ class HobPage (gtk.VBox): | |||
83 | tip_text = tip | 83 | tip_text = tip |
84 | button = toolbar.append_item(buttonname, tip, None, icon, cb) | 84 | button = toolbar.append_item(buttonname, tip, None, icon, cb) |
85 | return button | 85 | return button |
86 | |||
87 | @staticmethod | ||
88 | def _size_to_string(size): | ||
89 | try: | ||
90 | if not size: | ||
91 | size_str = "0 B" | ||
92 | else: | ||
93 | if len(str(int(size))) > 6: | ||
94 | size_str = '%.1f' % (size*1.0/(1024*1024)) + ' MB' | ||
95 | elif len(str(int(size))) > 3: | ||
96 | size_str = '%.1f' % (size*1.0/1024) + ' KB' | ||
97 | else: | ||
98 | size_str = str(size) + ' B' | ||
99 | except: | ||
100 | size_str = "0 B" | ||
101 | return size_str | ||
102 | |||
103 | @staticmethod | ||
104 | def _string_to_size(str_size): | ||
105 | try: | ||
106 | if not str_size: | ||
107 | size = 0 | ||
108 | else: | ||
109 | unit = str_size.split() | ||
110 | if len(unit) > 1: | ||
111 | if unit[1] == 'MB': | ||
112 | size = float(unit[0])*1024*1024 | ||
113 | elif unit[1] == 'KB': | ||
114 | size = float(unit[0])*1024 | ||
115 | elif unit[1] == 'B': | ||
116 | size = float(unit[0]) | ||
117 | else: | ||
118 | size = 0 | ||
119 | else: | ||
120 | size = float(unit[0]) | ||
121 | except: | ||
122 | size = 0 | ||
123 | return size | ||
124 | |||