Skip to content

Commit a7f62f9

Browse files
authored
Merge pull request #31 from abo3skr2019/main
Adds Data / Bytes Conversion
2 parents 6b6e8e4 + 4b4d24e commit a7f62f9

File tree

3 files changed

+184
-3
lines changed

3 files changed

+184
-3
lines changed

README.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
2+
23
# General Converter (Flow.Launcher.GenConvert)
34

45
General weight, volume, distance, area, temperature, speed and energy converter for the [Flow Launcher](https://github.com/Flow-Launcher/Flow.Launcher)
@@ -25,8 +26,8 @@ Currently English and Chinese language supported. Edit the .env file to change t
2526

2627
### Usage
2728

28-
| Keyword | Description |
29-
| ------------------------------------------------------------- | -------------------------------------------------- |
29+
| Keyword | Description |
30+
| ------------------------------------------------------------- | --------------------------------------------------- |
3031
| `gc <amount> <from unit abbreviation> <to unit abbreviation>` | Convert the amount of the from unit to the to unit. |
3132

3233
The from and to unit are case sensitive.
@@ -35,6 +36,7 @@ Just entering the keyword will give you the full list of units to choose from in
3536
results when you simply start entering a number then go to the Plugin settings and turn this helper text off.
3637

3738
Entering the keyword, amount and from unit will give you a subset list of units the from unit can be converted to
39+
3840
#### Units
3941

4042
The following units and their abbreviations can be used (each table can only convert among its' own units):
@@ -359,6 +361,66 @@ The following units and their abbreviations can be used (each table can only con
359361
<td>British thermal units</td>
360362
<td>BTU</td>
361363
</tr>
364+
<table>
365+
<tr>
366+
<th>Subject</th>
367+
<th>Unit</th>
368+
<th>Abbreviation</th>
369+
<th rowspan="13" align="center"><img src="assets/Data.ico" alt="Data Logo"></th>
370+
</tr>
371+
<tr>
372+
<td rowspan = "13" align="center">Data</td>
373+
<td>Bytes</td>
374+
<td>B</td>
375+
</tr>
376+
<tr>
377+
<td>KiloBytes</td>
378+
<td>KB</td>
379+
</tr>
380+
<tr>
381+
<td>GigaBytes</td>
382+
<td>GB</td>
383+
</tr>
384+
<tr>
385+
<td>PetaBytes</td>
386+
<td>PB</td>
387+
</tr>
388+
<tr>
389+
<td>Kibibytes</td>
390+
<td>KiB</td>
391+
</tr>
392+
<tr>
393+
<td>Gibibytes</td>
394+
<td>GiB</td>
395+
</tr>
396+
<tr>
397+
<td>Pebibytes</td>
398+
<td>PiB</td>
399+
</tr>
400+
<tr>
401+
<td>bits</td>
402+
<td>b</td>
403+
</tr>
404+
<tr>
405+
<td>Kilobits</td>
406+
<td>Kb</td>
407+
</tr>
408+
<tr>
409+
<td>Megabits</td>
410+
<td>Mb</td>
411+
</tr>
412+
<tr>
413+
<td>Gigabits</td>
414+
<td>Gb</td>
415+
</tr>
416+
<tr>
417+
<td>Terabits</td>
418+
<td>Tb</td>
419+
</tr>
420+
<tr>
421+
<td>Pebibytes</td>
422+
<td>PiB</td>
423+
</tr>
362424
</table>
363425

364426
### Problems, errors and feature requests

assets/data.ico

167 KB
Binary file not shown.

plugin/units.py

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
_("Distance"): [
2121
# Base
2222
["m", _("metre"), _("metres"), "x * 1", "x * 1"],
23-
# All below convert to/from base
23+
# All below convert to / from base
2424
["dm", _("decimetre"), _("decimetres"), "x / 10", "x * 10"],
2525
["mm", _("millimetre"), _("millimetres"), "x / 1000", "x * 1000"],
2626
["cm", _("centimetre"), _("centimetres"), "x / 100", "x * 100"],
@@ -328,4 +328,123 @@
328328
"x * 0.0009478171",
329329
],
330330
],
331+
"data": [
332+
# byte is the base
333+
["B", _("byte"), _("bytes"), "x / 1", "x * 1"],
334+
["KB", _("kilobyte"), _("kilobytes"), "x / 0.001", "x * 0.001"], # 10^3,
335+
["MB", _("megabyte"), _("megabytes"), "x / 0.000001", "x * 0.000001"], # 10^6,
336+
[
337+
"GB",
338+
_("gigabyte"),
339+
_("gigabytes"),
340+
"x / 0.000000001",
341+
"x * 0.000000001",
342+
], # 10^9,
343+
[
344+
"TB",
345+
_("terabyte"),
346+
_("terabytes"),
347+
"x / 0.000000000001",
348+
"x * 0.000000000001",
349+
], # 10^12,
350+
[
351+
"PB",
352+
_("petabyte"),
353+
_("petabytes"),
354+
"x / 0.000000000000001",
355+
"x * 0.000000000000001",
356+
], # 10^15,
357+
# bits
358+
["b", _("bit"), _("bits"), "x / 8", "x * 8"], # 1 byte = 8 bits
359+
["Kb", _("kilobit"), _("kilobits"), "x / 0.008 ", "x * 0.008"],
360+
["Mb", _("megabit"), _("megabits"), "x / 0.000008", "x * 0.000008"],
361+
["Gb", _("gigabit"), _("gigabits"), "x / 0.000000008", "x * 0.000000008"],
362+
[
363+
"Tb",
364+
_("terabit"),
365+
_("terabits"),
366+
"x / 0.000000000008",
367+
"x * 0.000000000008",
368+
],
369+
[
370+
"Pb",
371+
_("petabit"),
372+
_("petabits"),
373+
"x / 0.000000000000008",
374+
"x * 0.000000000000008",
375+
],
376+
# IEC units
377+
# bytes
378+
[
379+
"KiB",
380+
_("kibibyte"),
381+
_("kibibytes"),
382+
"x / 0.0009765625",
383+
"x * 0.0009765625",
384+
], # 2^10
385+
[
386+
"MiB",
387+
_("mebibyte"),
388+
_("mebibytes"),
389+
"x / 0.00000095367431640625",
390+
"x * 0.00000095367431640625",
391+
], # 2^20
392+
[
393+
"GiB",
394+
_("gibibyte"),
395+
_("gibibytes"),
396+
"x / 0.000000000931322574615478515625",
397+
"x * 0.000000000931322574615478515625",
398+
], # 2^30
399+
[
400+
"TiB",
401+
_("tebibyte"),
402+
_("tebibytes"),
403+
"x / 0.0000000000009094947017729282379150390625",
404+
"x * 0.0000000000009094947017729282379150390625",
405+
], # 2^40
406+
[
407+
"PiB",
408+
_("pebibyte"),
409+
_("pebibytes"),
410+
"x / 0.00000000000000088817841970012523233890533447265625",
411+
"x * 0.00000000000000088817841970012523233890533447265625",
412+
], # 2^50
413+
# bits each is 1024 of the previous
414+
[
415+
"Kib",
416+
_("kibibit"),
417+
_("kibibits"),
418+
"x / 0.0078125",
419+
"x * 0.0078125",
420+
], # 2^10
421+
[
422+
"Mib",
423+
_("mebibit"),
424+
_("mebibits"),
425+
"x / 0.00000762939453125",
426+
"x * 0.00000762939453125",
427+
], # 2^20
428+
[
429+
"Gib",
430+
_("gibibit"),
431+
_("gibibits"),
432+
"x / 0.000000007450581",
433+
"x * 0.000000007450581",
434+
], # 2^30
435+
[
436+
"Tib",
437+
_("tebibit"),
438+
_("tebibits"),
439+
"x / 0.0000000000007275958",
440+
"x * 0.0000000000007275958",
441+
], # 2^40
442+
[
443+
"Pib",
444+
_("pebibit"),
445+
_("pebibits"),
446+
"x / 0.00000000000000000710542735760100185871124267578125",
447+
"x * 0.00000000000000000710542735760100185871124267578125",
448+
], # 2^50
449+
],
331450
}

0 commit comments

Comments
 (0)