argsloader.units.resource

TimeScale

enum argsloader.units.resource.TimeScale(value)[source]
Overview:

Duration unit enum.

Member Type

int

Valid values are as follows:

NANOSECOND = <TimeScale.NANOSECOND: 1e-09>

Nano second, 1 second = 1,000,000,000 nano seconds

MICROSECOND = <TimeScale.MICROSECOND: 1e-06>

Micro second, 1 second = 1,000,000 micro seconds

MILLISECOND = <TimeScale.MILLISECOND: 0.001>

Milli second, 1 second = 1,000 milli seconds

SECOND = <TimeScale.SECOND: 1.0>

Second, 1 second = 1 second

MINUTE = <TimeScale.MINUTE: 60.0>

Minute, 1 minute = 60 seconds

HOUR = <TimeScale.HOUR: 3600.0>

Hour, 1 hour = 60 * 60 seconds

DAY = <TimeScale.DAY: 86400.0>

Day, 1 day = 24 * 60 * 60 seconds

TimespanUnit

class argsloader.units.resource.TimespanUnit(scale)[source]
Overview:

Unit for parsing timespan data.

__init__(scale)[source]

Constructor of TimespanUnit.

Parameters

scale – Scale for the result.

timespan

argsloader.units.resource.timespan()[source]
Overview:

Timespan data parsing.

Returns

A timespan parsing unit.

Examples::
  • Simple usage

>>> from argsloader.units import timespan
>>> u = timespan()
>>> u('5h43min8s')
20588.0
>>> u('7day 5minutes ')
605100.0
  • Get the timespan in minutes

>>> u = timespan.minutes()
>>> u('5h43min8s')
343.1333333333333
>>> u('7day 5minutes ')
10085.0
  • Get the timespan in hours

>>> u = timespan.hours()
>>> u('5h43min8s')
5.7188888888888885
>>> u('7day 5minutes ')
168.08333333333334

Note

Supported scales:

  • timespan.nano, which means the parsed result will be in nanoseconds.

  • timespan.micro, which means the parsed result will be in microseconds.

  • timespan.milli, which means the parsed result will be in milliseconds.

  • timespan.seconds, which is the same as simple timespan.

  • timespan.minutes, which means the parsed result will be in minutes.

  • timespan.hours, which means the parsed result will be in hours.

  • timespan.days, which means the parsed result will be in days.

MemoryScale

enum argsloader.units.resource.MemoryScale(value)[source]
Overview:

Memory size unit enum.

Member Type

int

Valid values are as follows:

B = <MemoryScale.B: 1>

Byte, 1 byte = 1 byte.

KiB = <MemoryScale.KiB: 1024>

KiB, 1 KiB = 1024 bytes.

KB = <MemoryScale.KB: 1000>

KB, 1 KB = 1000 bytes.

MiB = <MemoryScale.MiB: 1048576>

MiB, 1 MiB = 1024 * 1024 bytes.

MB = <MemoryScale.MB: 1000000>

MB, 1 MB = 1000 * 1000 bytes.

GiB = <MemoryScale.GiB: 1073741824>

GiB, 1 GiB = 1024 * 1024 * 1024 bytes.

GB = <MemoryScale.GB: 1000000000>

GB, 1 GB = 1000 * 1000 * 1000 bytes.

TiB = <MemoryScale.TiB: 1099511627776>

TiB, 1 TiB = 1024 * 1024 * 1024 * 1024 bytes.

TB = <MemoryScale.TB: 1000000000000>

TB, 1 TB = 1000 * 1000 * 1000 * 1000 bytes.

MemoryUnit

class argsloader.units.resource.MemoryUnit(scale: argsloader.units.resource.MemoryScale)[source]
Overview:

Unit for parsing memory size data.

__init__(scale: argsloader.units.resource.MemoryScale)[source]

Constructor of MemoryUnit.

Parameters

scale – Scale for the result.

memory_

argsloader.units.resource.memory_()argsloader.units.resource.MemoryUnit[source]
Overview:

Memory size data parsing.

Returns

A memory size parsing unit.

Examples::
  • Simple usage

>>> from argsloader.units import memory_
>>> u = memory_()
>>> u('5M')
5000000
>>> u('238.4 Gi')
255980050842
  • Get the memory in MiB

>>> u = memory_.MiB()
>>> u('5M')
4.76837158203125
>>> u('238.4 Gi')
244121.60000038147
  • Get the memory in KB

>>> u = memory_.KB()
>>> u('5M')
5000.0
>>> u('238.4 Gi')
255980050.842

Note

Supported scales:

  • memory_.B, which means the parsed result will be in bytes.

  • memory_.bytes, alias for memory_.B.

  • memory_.KiB, which means the parsed result will be in KiB.

  • memory_.KB, which means the parsed result will be in KB.

  • memory_.MiB, which means the parsed result will be in MiB.

  • memory_.MB, which means the parsed result will be in MB.

  • memory_.GiB, which means the parsed result will be in GiB.

  • memory_.GB, which means the parsed result will be in GB.

  • memory_.TiB, which means the parsed result will be in TiB.

  • memory_.TB, which means the parsed result will be in TB.