Coverage for src/code_beatrix/__init__.py: 83%

23 statements  

« prev     ^ index     » next       coverage.py v7.1.0, created at 2023-04-29 13:45 +0200

1# -*- coding: utf-8 -*- 

2""" 

3@file 

4@brief Module *code_beatrix*. 

5 

6.. faqref:: 

7 :title: Pourquoi Python? 

8 

9 `Python <https://www.python.org/>`_ 

10 est un langage de programmation très répandu aujourd'hui 

11 qui fut choisi à l'`ENSAE <http://www.ensae.fr/ensae/fr/>`_ en 

12 2005 pour remplacer le `C++ <https://fr.wikipedia.org/wiki/C%2B%2B>`_. 

13 Dès la première année, il est apparu que ce nouveau langage permettait 

14 aux étudiants de mettre leurs idées plus rapidement en forme. 

15 Les opinions ont commencé alors un peu à changer à propos de la programmation. 

16 Il est très rare maintenant qu'un étudiant quitte une grande école 

17 d'ingénieurs sans programmer. 

18 Il a été choisi pour trois raisons. La première est sa syntaxe 

19 car il oblige les dévelopeurs à aligner leurs instructions 

20 ce qui rend les programmes plus lisibles. 

21 La seconde parce que sa `grammaire <https://docs.python.org/3/reference/grammar.html>`_ 

22 est une des plus courte (voir aussi 

23 `The Python Language Reference <https://docs.python.org/3/reference/>`_). 

24 Enfin, beaucoup de librairies existantes mais codées en C++ étaient déjà 

25 disponibles à l'époque. 10 ans plus tard, le langage est quasi incontournable 

26 dès qu'on touche au traitement de données. 

27""" 

28import os 

29 

30__version__ = "0.6.674" 

31__author__ = "Xavier Dupré" 

32__github__ = "https://github.com/sdpython/code_beatrix" 

33__url__ = "http://www.xavierdupre.fr/app/code_beatrix/helpsphinx/" 

34__license__ = "MIT License" 

35__blog__ = os.path.abspath( 

36 os.path.join(os.path.dirname(__file__), "rss_blog_list.xml")) 

37 

38 

39def _setup_hook(add_print=False, unit_test=False): 

40 """ 

41 if this function is added to the module, 

42 the help automation and unit tests call it first before 

43 anything goes on as an initialization step. 

44 It should be run in a separate process. 

45 

46 @param add_print print *Success: _setup_hook* 

47 @param unit_test used only for unit testing purpose 

48 """ 

49 # we can check many things, needed module 

50 # any others things before unit tests are started 

51 if add_print: 

52 print("Success: _setup_hook") 

53 

54 

55def check(log=False, kind=None, fLOG=None): 

56 """ 

57 Checks the library is working. 

58 It raises an exception. 

59 

60 @param log if True, display information, otherwise 

61 @param kind None or ``'scratch'`` or ``'video'`` 

62 @param fLOG logging function 

63 @return 0 or exception 

64 """ 

65 r = True 

66 if kind is None or kind == "scratch": 

67 from .scratchs import check as check_sc 

68 r &= check_sc() 

69 if kind is None or kind == "video": 

70 from .art.video import check as check_vid 

71 r &= check_vid(fLOG=fLOG) 

72 return r 

73 

74 

75def load_ipython_extension(ip): 

76 """ 

77 to allow the call ``%load_ext code_beatrix`` 

78 

79 @param ip from ``get_ipython()`` 

80 """ 

81 from .ipythonhelper.magic_scratch import register_scratch_magics 

82 register_scratch_magics(ip)