@anonymous/

YummyJumpyDevices

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.3879122287086383","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aD1sYW1iZGEgdix1PTA6dj45OTkuNGFuZCBoKHYvMTAyNCx1KzIpb3IiJS4qZiVzQiIlKHUgYW5kKHY8MTApKyh2PDEwMCksdiwiS2lNaUdpIlt1LTI6dV0pCgp0ZXN0ID0gewogICAgMDogIjBCIiwKICAgIDE6ICIxQiIsCiAgICA0MjogIjQyQiIsCiAgICA5OTk6ICI5OTlCIiwKICAgIDEwMDA6ICIwLjk4S2lCIiwKICAgIDEwMjQ6ICIxLjAwS2lCIiwKICAgIDIwMTg6ICIxLjk3S2lCIiwKICAgIDEwMDg2OiAiOS44NUtpQiIsCiAgICAxMDAwMTA6ICI5Ny43S2lCIiwKICAgIDQ1Njc4OTogIjQ0NktpQiIsCiAgICAyMDA4MDcwNTogIjE5LjJNaUIiLAogICAgOTU0NDM3MTc3OiAiOTEwTWlCIiwKICAgIDEwODQ1ODc3MDE6ICIxLjAxR2lCIiwKICAgIDEyMDc5NTk1NTE6ICIxLjEyR2lCIiwKICAgIDIxNDc0ODM2NDc6ICIyLjAwR2lCIiwKICAgIDEwMjMwNzk6ICI5OTlLaUIiLAogICAgMTAyMzQ4ODogIjAuOThNaUIiLAogICAgMTA0MzMzMzogIjAuOTlNaUIiLAogICAgMTA0MzMzNDogIjEuMDBNaUIiLAp9Cgpmb3IgdiwgcyBpbiB0ZXN0Lml0ZW1zKCk6CiAgICBwcmludCgie30gLS0+IHt9Ii5mb3JtYXQodiwgaCh2KSkpCiAgICBhc3NlcnQgaCh2KSA9PSBz"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
h=lambda v,u=0:v>999.4and h(v/1024,u+2)or"%.*f%sB"%(u and(v<10)+(v<100),v,"KiMiGi"[u-2:u])

test = {
    0: "0B",
    1: "1B",
    42: "42B",
    999: "999B",
    1000: "0.98KiB",
    1024: "1.00KiB",
    2018: "1.97KiB",
    10086: "9.85KiB",
    100010: "97.7KiB",
    456789: "446KiB",
    20080705: "19.2MiB",
    954437177: "910MiB",
    1084587701: "1.01GiB",
    1207959551: "1.12GiB",
    2147483647: "2.00GiB",
    1023079: "999KiB",
    1023488: "0.98MiB",
    1043333: "0.99MiB",
    1043334: "1.00MiB",
}

for v, s in test.items():
    print("{} --> {}".format(v, h(v)))
    assert h(v) == s