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

Function inch

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

Source from the content-addressed store, hash-verified

1331# Inch
1332
1333def inch(v, *args, **kwargs):
1334 u = None
1335 if args: # If there are more arguments, bind them together in a list.
1336 v = [v]+list(args)
1337 if isinstance(v, (tuple, list)):
1338 u = []
1339 for uv in v:
1340 u.append(inch(uv))
1341 u = tuple(u)
1342 elif isinstance(v, (int, float)):
1343 return Inch(v)
1344 elif isUnit(v):
1345 u = Inch() # New Inch and convert via pt
1346 u.pt = v.pt
1347 elif isinstance(v, str):
1348 v = v.strip().lower()
1349 if v.endswith(Inch.UNITC): # "-character
1350 v = asNumberOrNone(v[:-1])
1351 if v is not None:
1352 u = Inch(v)
1353 elif v.endswith(Inch.UNIT):
1354 v = asNumberOrNone(v[:-4])
1355 if v is not None:
1356 u = Inch(v)
1357 else: # Something else, recursively try again.
1358 u = inch(units(v))
1359 return u
1360
1361class Inch(Unit):
1362 """Inch 72 * the base unit size of all PageBot measures.

Callers 2

constants.pyFile · 0.90
_get_inchMethod · 0.85

Calls 5

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

Tested by

no test coverage detected