renfe-cli 4.2.1__tar.gz → 4.3.0__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.
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/CHANGELOG.md +5 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/Cargo.lock +1 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/Cargo.toml +1 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/PKG-INFO +4 -3
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/README.md +2 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/pyproject.toml +1 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/src/cli.rs +3 -1
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/src/timetable.rs +20 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/.github/workflows/CICD.yml +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/.gitignore +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/CODEOWNERS +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/LICENSE +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/src/lib.rs +0 -0
- {renfe_cli-4.2.1 → renfe_cli-4.3.0}/src/stations.rs +0 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v4.3.0 (2024-02-10)
|
|
4
|
+
|
|
5
|
+
* New feature for sorting timetables [#189](https://github.com/gerardcl/renfe-cli/issues/189)
|
|
6
|
+
|
|
3
7
|
## v4.2.1 (2024-02-02)
|
|
4
8
|
|
|
5
|
-
* Fix navigation with proper date handling [#
|
|
9
|
+
* Fix navigation with proper date handling [#187](https://github.com/gerardcl/renfe-cli/issues/187)
|
|
6
10
|
|
|
7
11
|
## v4.2.0 (2023-11-26)
|
|
8
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: renfe-cli
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -18,7 +18,7 @@ Classifier: Topic :: Terminals
|
|
|
18
18
|
Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Summary: Get faster Renfe Spanish Trains timetables in your terminal.
|
|
21
|
-
Keywords: timetables,trains,renfe,cli,rust
|
|
21
|
+
Keywords: timetables,trains,renfe,cli,rust,pyo3,maturin
|
|
22
22
|
Home-Page: https://github.com/gerardcl/renfe-cli
|
|
23
23
|
Author-email: Gerard Castillo Lasheras <gerardcl@gmail.com>
|
|
24
24
|
Maintainer-email: Gerard Castillo Lasheras <gerardcl@gmail.com>
|
|
@@ -65,7 +65,7 @@ The navigation through the site happens in the following steps:
|
|
|
65
65
|
4. Writes down and selects the month to search for
|
|
66
66
|
5. Writes down and selects the year to search for
|
|
67
67
|
6. Clicks on search button
|
|
68
|
-
7. Parses the HTML data and prints the timetable
|
|
68
|
+
7. Parses the HTML data, optionally sorts the connections and prints the timetable
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
$ renfe-cli -h
|
|
@@ -78,6 +78,7 @@ Options:
|
|
|
78
78
|
-m, --month MONTH Set Month to search timetable for (default: today's month)
|
|
79
79
|
-y, --year YEAR Set Year to search timetable for (default: today's year)
|
|
80
80
|
-w, --wait SECONDS Set Wait time in seconds for Renfe search result page (default: 2)
|
|
81
|
+
-s, --sort Option to sort the timetable by Duration
|
|
81
82
|
-h, --help Print this help menu
|
|
82
83
|
```
|
|
83
84
|
|
|
@@ -32,7 +32,7 @@ The navigation through the site happens in the following steps:
|
|
|
32
32
|
4. Writes down and selects the month to search for
|
|
33
33
|
5. Writes down and selects the year to search for
|
|
34
34
|
6. Clicks on search button
|
|
35
|
-
7. Parses the HTML data and prints the timetable
|
|
35
|
+
7. Parses the HTML data, optionally sorts the connections and prints the timetable
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
38
|
$ renfe-cli -h
|
|
@@ -45,6 +45,7 @@ Options:
|
|
|
45
45
|
-m, --month MONTH Set Month to search timetable for (default: today's month)
|
|
46
46
|
-y, --year YEAR Set Year to search timetable for (default: today's year)
|
|
47
47
|
-w, --wait SECONDS Set Wait time in seconds for Renfe search result page (default: 2)
|
|
48
|
+
-s, --sort Option to sort the timetable by Duration
|
|
48
49
|
-h, --help Print this help menu
|
|
49
50
|
```
|
|
50
51
|
|
|
@@ -14,7 +14,7 @@ maintainers = [
|
|
|
14
14
|
description = "Get faster Renfe Spanish Trains timetables in your terminal."
|
|
15
15
|
readme = "README.md"
|
|
16
16
|
license = {file = "LICENSE"}
|
|
17
|
-
keywords = ["timetables", "trains", "renfe", "cli", "rust"]
|
|
17
|
+
keywords = ["timetables", "trains", "renfe", "cli", "rust", "pyo3", "maturin"]
|
|
18
18
|
classifiers = [
|
|
19
19
|
"Programming Language :: Rust",
|
|
20
20
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
@@ -36,6 +36,7 @@ pub fn main() -> PyResult<()> {
|
|
|
36
36
|
.opt_str("w")
|
|
37
37
|
.unwrap_or(2.to_string())
|
|
38
38
|
.parse::<u64>()?;
|
|
39
|
+
let sorted: bool = matches.opt_present("s");
|
|
39
40
|
|
|
40
41
|
println!(
|
|
41
42
|
"Today is: {}-{}-{}",
|
|
@@ -45,7 +46,7 @@ pub fn main() -> PyResult<()> {
|
|
|
45
46
|
);
|
|
46
47
|
println!("Searching timetable for date: {}-{}-{}", year, month, day);
|
|
47
48
|
|
|
48
|
-
let timetable = search_timetable(origin, destination, day, month, year, wait)?;
|
|
49
|
+
let timetable = search_timetable(origin, destination, day, month, year, wait, sorted)?;
|
|
49
50
|
|
|
50
51
|
print_timetable(timetable);
|
|
51
52
|
Ok(())
|
|
@@ -92,6 +93,7 @@ fn set_opts() -> Options {
|
|
|
92
93
|
"Set Wait time in seconds for Renfe search result page (default: 2)",
|
|
93
94
|
"SECONDS",
|
|
94
95
|
);
|
|
96
|
+
opts.optflag("s", "sort", "Option to sort the timetable by Duration");
|
|
95
97
|
opts.optflag("h", "help", "Print this help menu");
|
|
96
98
|
|
|
97
99
|
opts
|
|
@@ -55,6 +55,17 @@ fn to_renfe_month(month: String) -> String {
|
|
|
55
55
|
months[month.as_str()].to_owned()
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
fn get_duration_from_renfe_string(s: &str) -> u16 {
|
|
59
|
+
let splits: Vec<&str> = s.split(' ').collect();
|
|
60
|
+
if s.contains('h') {
|
|
61
|
+
let hours = splits[0].parse::<u16>().unwrap();
|
|
62
|
+
let minutes = splits[2].parse::<u16>().unwrap();
|
|
63
|
+
hours * 60 + minutes
|
|
64
|
+
} else {
|
|
65
|
+
splits[0].parse::<u16>().unwrap()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
58
69
|
#[pyfunction]
|
|
59
70
|
pub fn search_timetable(
|
|
60
71
|
origin: String,
|
|
@@ -63,6 +74,7 @@ pub fn search_timetable(
|
|
|
63
74
|
month: String,
|
|
64
75
|
year: String,
|
|
65
76
|
wait: u64,
|
|
77
|
+
sorted: bool,
|
|
66
78
|
) -> PyResult<Vec<Vec<String>>> {
|
|
67
79
|
println!("loading headless chrome browser");
|
|
68
80
|
let browser = Browser::new(LaunchOptions {
|
|
@@ -188,6 +200,13 @@ pub fn search_timetable(
|
|
|
188
200
|
tracks.push(row);
|
|
189
201
|
}
|
|
190
202
|
|
|
203
|
+
if sorted {
|
|
204
|
+
println!("sorting timetable");
|
|
205
|
+
tracks.sort_by(|a, b| {
|
|
206
|
+
get_duration_from_renfe_string(&a[3]).cmp(&get_duration_from_renfe_string(&b[3]))
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
191
210
|
Ok(tracks)
|
|
192
211
|
}
|
|
193
212
|
|
|
@@ -225,6 +244,7 @@ mod tests {
|
|
|
225
244
|
now.month().to_string(),
|
|
226
245
|
now.year().to_string(),
|
|
227
246
|
15,
|
|
247
|
+
false,
|
|
228
248
|
)?);
|
|
229
249
|
|
|
230
250
|
Ok(())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|