polarsteps-data-parser 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

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,71 +1,71 @@
1
- import json
2
- from datetime import datetime
3
- from pathlib import Path
4
-
5
- import click
6
-
7
-
8
- def load_json_from_file(path: Path) -> dict:
9
- """Load content from file and convert to JSON object.
10
-
11
- Args:
12
- path: path to file
13
-
14
- Returns:
15
- dict: parsed JSON
16
- """
17
- with open(path, "r") as file:
18
- return json.load(file)
19
-
20
-
21
- def parse_date(date: str) -> datetime:
22
- """Convert a string containing a timestamp to a datetime object.
23
-
24
- Args:
25
- date: unix timestamp
26
-
27
- Returns:
28
- datetime: timestamp parsed to a datetime object
29
-
30
- """
31
- timestamp = float(date)
32
- date_time = datetime.fromtimestamp(timestamp)
33
- return date_time
34
-
35
-
36
- def find_folder_by_id(folder_id: str) -> Path | None:
37
- """Finds and returns the path of a folder within the base_directory that matches the given folder_id.
38
-
39
- Args:
40
- folder_id (str): The ID to search for in the folder names.
41
-
42
- Returns:
43
- Path or None: The path of the matching folder, or None if no matching folder is found.
44
- """
45
- base_path = Path(click.get_current_context().params["input_folder"])
46
-
47
- for folder in base_path.iterdir():
48
- if folder.is_dir() and folder.name.endswith(f"_{folder_id}"):
49
- return folder
50
- return None
51
-
52
-
53
- def list_files_in_folder(folder_path: Path, dir_has_to_exist: bool = True) -> list[Path]:
54
- """List all files in the given folder.
55
-
56
- Args:
57
- folder_path (str or Path): The path of the folder to list files from.
58
- dir_has_to_exist (bool): raise exception if path does not exist.
59
-
60
- Returns:
61
- List[Path]: A list of Path objects representing the files in the folder.
62
-
63
- """
64
- folder = Path(folder_path)
65
-
66
- if not folder.is_dir():
67
- if dir_has_to_exist:
68
- raise NotADirectoryError(f"{folder_path} is not a valid directory")
69
- return []
70
-
71
- return [file for file in folder.iterdir() if file.is_file()]
1
+ import json
2
+ from datetime import datetime
3
+ from pathlib import Path
4
+
5
+ import click
6
+
7
+
8
+ def load_json_from_file(path: Path) -> dict:
9
+ """Load content from file and convert to JSON object.
10
+
11
+ Args:
12
+ path: path to file
13
+
14
+ Returns:
15
+ dict: parsed JSON
16
+ """
17
+ with open(path, "r") as file:
18
+ return json.load(file)
19
+
20
+
21
+ def parse_date(date: str) -> datetime:
22
+ """Convert a string containing a timestamp to a datetime object.
23
+
24
+ Args:
25
+ date: unix timestamp
26
+
27
+ Returns:
28
+ datetime: timestamp parsed to a datetime object
29
+
30
+ """
31
+ timestamp = float(date)
32
+ date_time = datetime.fromtimestamp(timestamp)
33
+ return date_time
34
+
35
+
36
+ def find_folder_by_id(folder_id: str) -> Path | None:
37
+ """Finds and returns the path of a folder within the base_directory that matches the given folder_id.
38
+
39
+ Args:
40
+ folder_id (str): The ID to search for in the folder names.
41
+
42
+ Returns:
43
+ Path or None: The path of the matching folder, or None if no matching folder is found.
44
+ """
45
+ base_path = Path(click.get_current_context().params["input_folder"])
46
+
47
+ for folder in base_path.iterdir():
48
+ if folder.is_dir() and folder.name.endswith(f"_{folder_id}"):
49
+ return folder
50
+ return None
51
+
52
+
53
+ def list_files_in_folder(folder_path: Path, dir_has_to_exist: bool = True) -> list[Path]:
54
+ """List all files in the given folder.
55
+
56
+ Args:
57
+ folder_path (str or Path): The path of the folder to list files from.
58
+ dir_has_to_exist (bool): raise exception if path does not exist.
59
+
60
+ Returns:
61
+ List[Path]: A list of Path objects representing the files in the folder.
62
+
63
+ """
64
+ folder = Path(folder_path)
65
+
66
+ if not folder.is_dir():
67
+ if dir_has_to_exist:
68
+ raise NotADirectoryError(f"{folder_path} is not a valid directory")
69
+ return []
70
+
71
+ return [file for file in folder.iterdir() if file.is_file()]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polarsteps-data-parser
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: Parse and extract data from the data export of travel tracking app Polarsteps.
5
5
  Author-email: Niek van Leeuwen <ik@niekvanleeuwen.nl>
6
6
  License-Expression: MIT
@@ -21,47 +21,50 @@ Tool designed to parse and extract data from the travel tracking app [Polarsteps
21
21
  1. **Data backup**: The data export does not support viewing your data in any useful way. To preserve the data (who knows if Polarsteps still exists in 20 years), the tool combines the data and generates a PDF document.
22
22
  2. **Data analysis & visualization**: The parsed data can also be leveraged for in-depth analysis, enabling users to gain insights into their travel patterns, destinations visited, duration of stays, distances traveled, and more. This opens up possibilities for statistical analysis, trend identification, and visualization of the trip data.
23
23
 
24
+ ## Detailed Usage Guide
25
+
26
+ If you’re new to Python or command-line tools, I’ve created a step-by-step usage guide to help you install and run polarsteps-data-parser (no programming experience required).
27
+
28
+ 👉 Read the guide here: [Usage guide](https://github.com/niekvleeuwen/polarsteps-data-parser/blob/main/USAGE_GUIDE.md)
29
+
24
30
  ## Getting started
25
31
 
26
- ### Installation
27
- To set up the project, ensure you have Python 3.11+ installed. Follow these steps:
28
32
 
29
- Clone the repository:
33
+ 1. Clone the repository and navigate to the project root:
30
34
 
31
35
  ```shell
32
36
  git clone https://github.com/niekvleeuwen/polarsteps-data-parser.git
33
- cd polarsteps-trip-analyzer
37
+ cd polarsteps-data-parser
34
38
  ```
35
39
 
36
- Ensure poetry is available, e.g. on Ubuntu/Debian you can run the following:
40
+ 2. Install dependencies using [uv](https://docs.astral.sh/uv/).
41
+ Make sure `uv` is installed on your system before proceeding.
37
42
 
38
43
  ```shell
39
- apt-get install python3 poetry
44
+ uv sync
40
45
  ```
41
46
 
42
- Install dependencies using Poetry:
47
+ ### Usage
48
+ To get the following output, run `uv run polarsteps-data-parser --help`.
43
49
 
44
50
  ```shell
45
- poetry install
46
- ```
51
+ Usage: polarsteps-data-parser [OPTIONS] INPUT_FOLDER
47
52
 
48
- Then enter the created virtual environment:
53
+ Parse the data from a Polarsteps trip export.
49
54
 
50
- ```shell
51
- poetry shell
52
- ```
55
+ INPUT_FOLDER should contain the Polarsteps data export of one (!) trip. Make
56
+ sure the folder contains a `trip.json` and `locations.json`.
53
57
 
54
- ### Usage
55
- To run the project, use the following command:
56
-
57
- ```shell
58
- polarsteps-data-parser [OPTIONS]
58
+ Options:
59
+ --output TEXT Output PDF file name [default: Trip report.pdf]
60
+ --enrich-with-comments Whether to enrich the trip with comments or not.
61
+ --help Show this message and exit.
59
62
  ```
60
63
 
61
64
  For example, to load and analyse a trip with the data located in the `./data/trip1` folder and enrich the trip with comments, use the following command:
62
65
 
63
66
  ```shell
64
- polarsteps-data-parser --input-folder ./data/trip1 --enrich-comments
67
+ uv run polarsteps-data-parser ./data/trip1 --enrich-with-comments
65
68
  ```
66
69
 
67
70
  ## Disclaimer
@@ -0,0 +1,10 @@
1
+ polarsteps_data_parser/__main__.py,sha256=rn-Yz_5KAXsCrsu5LjQLHFFEqc4sKxhSpcHgvnjlNxk,2419
2
+ polarsteps_data_parser/model.py,sha256=v8hSCWRs82_Hur5EnsSETcQCv06LPx0lOgFo478CwrU,3704
3
+ polarsteps_data_parser/pdf_generator.py,sha256=JZoJaQ1LtpNYOwQpgrbsf7xd992AU7_Hlh0OQoAtwv8,5465
4
+ polarsteps_data_parser/retrieve_step_comments.py,sha256=AVcgZ_0iG91CKCHwgLjX7YfeVpa4P2XZ0GchPTbzZGs,3970
5
+ polarsteps_data_parser/utils.py,sha256=_PKy-5VFEEtPXQtNyxogs1GZqPr_16cpLMtfTc75skM,1901
6
+ polarsteps_data_parser-0.1.2.dist-info/METADATA,sha256=1nb1Q7pNYeFNibOYMGNVXGeuuGa_RXPQ8Cgzok7THzA,3130
7
+ polarsteps_data_parser-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ polarsteps_data_parser-0.1.2.dist-info/entry_points.txt,sha256=UyGRCnpI13JtHPVilcSVgUSDNEYyv8-EQWgiJm-_ABg,79
9
+ polarsteps_data_parser-0.1.2.dist-info/licenses/LICENSE,sha256=hxqP9qEfnLOSMQQMvUWQ4g-GOG6pny7O0_9AExvE-xU,1072
10
+ polarsteps_data_parser-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Niek van Leeuwen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,10 +0,0 @@
1
- polarsteps_data_parser/__main__.py,sha256=LgDdFfqviXCKd9ytERb3cGxgyNJ5hY6pYg1Y20SUIJA,2493
2
- polarsteps_data_parser/model.py,sha256=8-ekrANj-SV_AafWwS_kmPqNoFTMZXpj7Mb1X-kpXwA,3851
3
- polarsteps_data_parser/pdf_generator.py,sha256=WX50wR5lPNaAHz9830zqxkqlBIaBZ3YkzKNRZ4VMXxc,5665
4
- polarsteps_data_parser/retrieve_step_comments.py,sha256=oTaAT05vl-bFrICE5TId0OV2gCKQH3iLkrKFCiSpk7g,4105
5
- polarsteps_data_parser/utils.py,sha256=K5TYZIZEMEv4p332h6zDLA5rdpslARbHw7bCJ9Os45k,1972
6
- polarsteps_data_parser-0.1.0.dist-info/METADATA,sha256=2OUrp2m30N2X41TXintN0GTR8aOVo61cS_f-q1Jt1FI,2527
7
- polarsteps_data_parser-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
- polarsteps_data_parser-0.1.0.dist-info/entry_points.txt,sha256=UyGRCnpI13JtHPVilcSVgUSDNEYyv8-EQWgiJm-_ABg,79
9
- polarsteps_data_parser-0.1.0.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
10
- polarsteps_data_parser-0.1.0.dist-info/RECORD,,