comparison Sphinx/source/plugins/python.rst @ 372:cb1d9a5bb043

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Apr 2020 17:39:48 +0200
parents 5cb37e6b014b 181b02cea7ab
children f5bbdabb04d9
comparison
equal deleted inserted replaced
371:5cb37e6b014b 372:cb1d9a5bb043
358 output.SendMethodNotAllowed('GET') 358 output.SendMethodNotAllowed('GET')
359 359
360 orthanc.RegisterRestCallback('/pydicom/(.*)', DecodeInstance) # (*) 360 orthanc.RegisterRestCallback('/pydicom/(.*)', DecodeInstance) # (*)
361 361
362 362
363 .. _python-introspection:
364
365 Inspecting the available API
366 ............................
367
368 .. highlight:: python
369
370 Thanks to Python's introspection primitives, it is possible to inspect
371 the API of the ``orthanc`` module in order to dump all the available
372 features::
373
374 import inspect
375 import numbers
376 import orthanc
377
378 # Loop over the members of the "orthanc" module
379 for (name, obj) in inspect.getmembers(orthanc):
380 if inspect.isroutine(obj):
381 print('Function %s():\n Documentation: %s\n' % (name, inspect.getdoc(obj)))
382
383 elif inspect.isclass(obj):
384 print('Class %s:\n Documentation: %s' % (name, inspect.getdoc(obj)))
385
386 # Loop over the members of the class
387 for (subname, subobj) in inspect.getmembers(obj):
388 if isinstance(subobj, numbers.Number):
389 print(' - Enumeration value %s: %s' % (subname, subobj))
390 elif (not subname.startswith('_') and
391 inspect.ismethoddescriptor(subobj)):
392 print(' - Method %s(): %s' % (subname, inspect.getdoc(subobj)))
393 print('')
394
395
396
397
398
363 Performance and concurrency 399 Performance and concurrency
364 --------------------------- 400 ---------------------------
365 401
366 .. highlight:: python 402 .. highlight:: python
367 403