Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Data mostly for the first year. 

4""" 

5import os 

6from pyquickhelper.loghelper import noLOG 

7from pyensae.filehelper.decompress_helper import decompress_zip 

8 

9 

10def anyzip(filename, local=True, cache_folder=".", fLOG=noLOG, **kwargs): 

11 """ 

12 Any zip. 

13 

14 @param filename filename 

15 @param local local data or web 

16 @param cache_folder where to cache the data if downloaded a second time 

17 @param fLOG logging function 

18 @param kwargs downloading arguments 

19 @return filename (str) 

20 """ 

21 if local: 

22 this = os.path.abspath(os.path.dirname(__file__)) 

23 this = os.path.join(this, "zips", filename) 

24 if not os.path.exists(this): 

25 raise FileNotFoundError(this) 

26 res = decompress_zip(this, whereTo=cache_folder, fLOG=fLOG) 

27 if cache_folder is not None: 

28 res = [os.path.join(cache_folder, _) for _ in res] 

29 else: 

30 import pyensae.datasource 

31 this = pyensae.datasource.download_data( 

32 filename, whereTo=cache_folder, fLOG=fLOG, **kwargs) 

33 if cache_folder is not None: 

34 res = [os.path.join(cache_folder, _) for _ in this] 

35 else: 

36 res = this 

37 if isinstance(res, list): 

38 res = res[0] 

39 return res 

40 

41 

42def besancon_df(local=True, cache_folder=".", fLOG=noLOG): 

43 """ 

44 Retrieves ``Besancon.df.zip``. 

45 

46 @param local local data or web 

47 @param cache_folder where to cache the data if downloaded a second time 

48 @param fLOG logging function 

49 @return filename (str) 

50 """ 

51 return anyzip("besancon.df.txt.zip", local=local, cache_folder=cache_folder, 

52 fLOG=fLOG, website="xdtd") 

53 

54 

55def added(local=True, cache_folder=".", fLOG=noLOG): 

56 """ 

57 Retrieves ``added.zip``. 

58 

59 @param local local data or web 

60 @param cache_folder where to cache the data if downloaded a second time 

61 @param fLOG logging function 

62 @return filename (str) 

63 """ 

64 return anyzip("added.zip", local=local, cache_folder=cache_folder, fLOG=fLOG)