384
edits
Changes
→Overview: du Improved
An example of the finished code your script might produce is this:
<code><b>user@host ~ $ ./duim.py -H /usr/local/lib</b></code>
<pre>
61 % [============ ] 160.2 M 164028 /usr/local/lib/heroku 4 % [= ] 10.8 M 11072 /usr/local/lib/python2.7 34 % [======= ] 90.4 M 92608 /usr/local/lib/node_modules 0 % [ ] 8.0 K /usr/local/lib/python3.8Total: 261.4 M 267720 /usr/local/lib
</pre>
Notice that total size of the target directory (/usr/local/lib) is around 260 Megabytes. Of that 260 Megabytes, 160 Megabytes can be found in the heroku subdirectory.
The bar chart in this example is 20 characters long, but this must be dynamic. The 20 characters does <i>not</i> include the square brackets. The resolution of the bar chart must become more accurate as you increase the total size. For example, if the user specifies a length of 100 total characters, in this example 61 of those characters would be equal signs and 39 would be spaces.
The output of each subdirectory should include percentage, size in bytes (or Human readable if the user uses the -H option), the bar chart and the name of the subdirectory.
Specific formatting of the final output will be up to you, but should be formatted in such a way that the output is easy to read. (ie. use columns!)