MCPcopy Create free account
hub / github.com/PageBot/PageBot / mm

Function mm

Lib/pagebot/toolbox/units.py:1000–1022  ·  view source on GitHub ↗
(v, *args, **kwargs)

Source from the content-addressed store, hash-verified

998# Mm
999
1000def mm(v, *args, **kwargs):
1001 u = None
1002 if args: # If there are more arguments, bind them together in a list.
1003 v = [v]+list(args)
1004 if isinstance(v, (tuple, list)):
1005 u = []
1006 for uv in v:
1007 u.append(mm(uv))
1008 u = tuple(u)
1009 elif isinstance(v, (int, float)):
1010 u = Mm(v)
1011 elif isUnit(v):
1012 u = Mm() # New Mm and convert via pt
1013 u.pt = v.pt
1014 elif isinstance(v, str):
1015 v = v.strip().lower()
1016 if v.endswith(Mm.UNIT):
1017 v = asNumberOrNone(v[:-2])
1018 if v is not None:
1019 u = Mm(v)
1020 else: # Something else, try again.
1021 u = mm(units(v))
1022 return u
1023
1024class Mm(Unit):
1025 """Answers the millimetre instance.

Callers 2

constants.pyFile · 0.90
_get_mmMethod · 0.85

Calls 5

asNumberOrNoneFunction · 0.90
MmClass · 0.85
isUnitFunction · 0.85
unitsFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected