icalreporting 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Jérémie GRESSIER
3
+ Copyright (c) 2023 Jérémie GRESSIER
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: icalreporting
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Reporting tools from ical files
5
5
  Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
6
6
  License: MIT License
7
7
 
8
- Copyright (c) 2022 Jérémie GRESSIER
8
+ Copyright (c) 2023 Jérémie GRESSIER
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
11
  of this software and associated documentation files (the "Software"), to deal
@@ -61,13 +61,29 @@ icalreporting
61
61
 
62
62
  ### Features
63
63
 
64
+ - able to load ical files and fill a pandas database
65
+ - parse the pandas database to identify project and creates a worksheet tables
66
+ - export to open document XLSX file
64
67
 
65
- ### Installation and usage
68
+ ### Installation
66
69
 
67
70
  ```bash
68
71
  pip install --upgrade icalreporting
69
72
  ```
73
+ This automatic installation will get needed dependencies.
70
74
 
71
75
  ### Requirements
72
76
 
73
77
  see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
78
+
79
+ ### Usage
80
+
81
+ When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
82
+
83
+ ```python
84
+ from icalreporting.reporting import Project
85
+ prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
86
+ prj.load_ics() # read files
87
+ wb = prj.workbook() # create workbook
88
+ wb.save("projectA.xlsx") # save it to file
89
+ ```
@@ -13,13 +13,29 @@ icalreporting
13
13
 
14
14
  ### Features
15
15
 
16
+ - able to load ical files and fill a pandas database
17
+ - parse the pandas database to identify project and creates a worksheet tables
18
+ - export to open document XLSX file
16
19
 
17
- ### Installation and usage
20
+ ### Installation
18
21
 
19
22
  ```bash
20
23
  pip install --upgrade icalreporting
21
24
  ```
25
+ This automatic installation will get needed dependencies.
22
26
 
23
27
  ### Requirements
24
28
 
25
- see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
29
+ see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
30
+
31
+ ### Usage
32
+
33
+ When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
34
+
35
+ ```python
36
+ from icalreporting.reporting import Project
37
+ prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
38
+ prj.load_ics() # read files
39
+ wb = prj.workbook() # create workbook
40
+ wb.save("projectA.xlsx") # save it to file
41
+ ```
@@ -0,0 +1 @@
1
+ __version__ = "0.1.2"
@@ -20,8 +20,21 @@ from pathlib import Path
20
20
  import openpyxl as xl
21
21
  from openpyxl.utils.dataframe import dataframe_to_rows
22
22
 
23
+ _default_startdate = "2020-01-01"
24
+ _default_enddate = "2030-01-01"
23
25
 
24
26
  def ical_to_dframe(filename: Path, startdate: datetime, enddate: datetime):
27
+ """read a file in ICAL format and create events between 2 dates
28
+ can handle recurrent events
29
+
30
+ Args:
31
+ filename (Path): path name of ICAL file
32
+ startdate (datetime): starting date for events
33
+ enddate (datetime): ending date (included) for events
34
+
35
+ Returns:
36
+ DataFrame: as member of the class (date, year, month, h_begin, duration, name, description, begin) properties
37
+ """
25
38
  with filename.open() as ics_file:
26
39
  calendar = IcsCalendarStream.calendar_from_ics(ics_file.read())
27
40
  return pd.DataFrame(
@@ -41,9 +54,11 @@ def ical_to_dframe(filename: Path, startdate: datetime, enddate: datetime):
41
54
  )
42
55
 
43
56
 
44
- class Project:
57
+ class Project():
58
+ """Class Project, can read ICAL file, define tags and create worksheet
59
+ """
45
60
  def __init__(
46
- self, name: str, folder=None, start: str = "2020-01-01", end: str = "2030-01-01", default_WP="No_WP"
61
+ self, name: str, folder=None, start: str = _default_startdate, end: str = _default_enddate, default_WP="No_WP"
47
62
  ):
48
63
  self._name = name
49
64
  self._folder = name if folder is None else folder
@@ -52,24 +67,27 @@ class Project:
52
67
  self._default_WP = default_WP
53
68
  print(self._end)
54
69
  print(f"> init project {self._name} in folder {self._folder}")
55
- print(f" will include {self._start.date()} to {self._end.date()}")
70
+ print(f" will include {self._start.date()} to {self._end.date()} (not included)")
56
71
 
57
72
  def load_ics(self):
58
73
  framedict = {}
59
- # print(Path(self._folder), Path(self._folder).exists(), Path(self._folder).is_dir())
60
- # print(list(Path(self._folder).glob("*.ics")))
61
- for filename in list(Path(self._folder).glob("*.ics")):
74
+ filelist = list(Path(self._folder).glob("*.ics"))
75
+ for filename in filelist:
62
76
  print(f"- reading {filename}")
63
77
  framedict[filename.stem] = ical_to_dframe(filename, self._start, self._end)
64
78
  framedict[filename.stem]["Member"] = filename.stem # file name without path nor extension
79
+ if len(filelist) == 0:
80
+ raise FileNotFoundError("no *.ics file found")
65
81
  self._dframe = pd.concat(tuple(framedict.values()))
66
82
  self._set_wp(default=self._default_WP)
67
83
  self._clean_wp()
68
84
 
69
85
  def members(self):
86
+ """returns set (unordered list) of members"""
70
87
  return set(self._dframe["Member"])
71
88
 
72
89
  def work_packages(self):
90
+ """returns set (unordered list) of Work Packages"""
73
91
  return set(self._dframe["WP"])
74
92
 
75
93
  def _df_to_tab(self, wb: xl.Workbook, df, title=None):
@@ -95,6 +113,7 @@ class Project:
95
113
  return
96
114
 
97
115
  def filter(self, start: str, end: str):
116
+ """replace DataFrame with selected dates"""
98
117
  self._dframe = self._df_slot(start, end)
99
118
 
100
119
  def add_tabdetail_member(self, wb, member: str):
@@ -140,7 +159,7 @@ class Project:
140
159
 
141
160
 
142
161
  if __name__ == "__main__":
143
- prj = Project(name="mambo", folder="examples/projetA", start="2023-01-01", end="2024-01-01")
162
+ prj = Project(name="mambo", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
144
163
  prj.load_ics() # lecture des .ics
145
164
  # prj.filter(start="2023-01-01", end="2023-12-31") # filtre des dates
146
165
  wb = prj.workbook() # création du tableur
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: icalreporting
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Reporting tools from ical files
5
5
  Author-email: "J. Gressier" <jeremie.gressier@isae-supaero.fr>
6
6
  License: MIT License
7
7
 
8
- Copyright (c) 2022 Jérémie GRESSIER
8
+ Copyright (c) 2023 Jérémie GRESSIER
9
9
 
10
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
11
  of this software and associated documentation files (the "Software"), to deal
@@ -61,13 +61,29 @@ icalreporting
61
61
 
62
62
  ### Features
63
63
 
64
+ - able to load ical files and fill a pandas database
65
+ - parse the pandas database to identify project and creates a worksheet tables
66
+ - export to open document XLSX file
64
67
 
65
- ### Installation and usage
68
+ ### Installation
66
69
 
67
70
  ```bash
68
71
  pip install --upgrade icalreporting
69
72
  ```
73
+ This automatic installation will get needed dependencies.
70
74
 
71
75
  ### Requirements
72
76
 
73
77
  see [requirements.txt](https://github.com/jgressier/icalreporting/blob/master/requirements.txt)
78
+
79
+ ### Usage
80
+
81
+ When installed, you just need to put a set a ical files in a folder for a project. You will be able to create a reporting file with the following lines.
82
+
83
+ ```python
84
+ from icalreporting.reporting import Project
85
+ prj = Project(name="Big-Project", folder="examples/projectA", start="2023-01-01", end="2024-01-01")
86
+ prj.load_ics() # read files
87
+ wb = prj.workbook() # create workbook
88
+ wb.save("projectA.xlsx") # save it to file
89
+ ```
@@ -7,4 +7,5 @@ icalreporting.egg-info/PKG-INFO
7
7
  icalreporting.egg-info/SOURCES.txt
8
8
  icalreporting.egg-info/dependency_links.txt
9
9
  icalreporting.egg-info/requires.txt
10
- icalreporting.egg-info/top_level.txt
10
+ icalreporting.egg-info/top_level.txt
11
+ tests/test_icalimport.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "icalreporting"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Reporting tools from ical files"
5
5
  authors = [{name="J. Gressier", email="jeremie.gressier@isae-supaero.fr"}]
6
6
  readme = "README.md"
@@ -45,7 +45,7 @@ testpaths = [
45
45
  ]
46
46
 
47
47
  [tool.bumpver]
48
- current_version = "v0.1.1"
48
+ current_version = "v0.1.2"
49
49
  version_pattern = "vMAJOR.MINOR.PATCH"
50
50
  commit_message = "bump version {old_version} to {new_version}"
51
51
  commit = true
@@ -0,0 +1,16 @@
1
+ import icalreporting.reporting as ir
2
+ from datetime import datetime, timedelta
3
+
4
+ def test_open():
5
+ prjname = "my_original_name"
6
+ path = "example/ProjectA"
7
+ project = ir.Project(name=prjname, folder=path)
8
+ assert project._name == prjname
9
+ assert project._folder == path
10
+ for d in (project._start, project._end):
11
+ assert isinstance(d, datetime)
12
+ assert project._start.date().isoformat() == ir._default_startdate
13
+ assert (project._end-timedelta(days=1)).date().isoformat() == ir._default_enddate
14
+
15
+ def test_properties():
16
+ assert True
@@ -1 +0,0 @@
1
- __version__ = "0.1.1"
File without changes