1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Initial work on half-height RUs

This commit is contained in:
jeremystretch
2022-06-09 17:27:58 -04:00
parent ba12db3019
commit 84f0561712
11 changed files with 232 additions and 127 deletions

View File

@ -1,4 +1,5 @@
import datetime
import decimal
import json
from collections import OrderedDict
from decimal import Decimal
@ -226,6 +227,21 @@ def deepmerge(original, new):
return merged
def drange(start, end, step=decimal.Decimal(1)):
"""
Decimal-compatible implementation of Python's range()
"""
start, end, step = decimal.Decimal(start), decimal.Decimal(end), decimal.Decimal(step)
if start < end:
while start < end:
yield start
start += step
else:
while start > end:
yield start
start += step
def to_meters(length, unit):
"""
Convert the given length to meters.