efj-parser 0.9.4__tar.gz → 1.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.
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: efj-parser
3
- Version: 0.9.4
3
+ Version: 1.0
4
4
  Summary: Parse an electronic Flight Journal file
5
5
  Home-page: https://github.com/JonHurst/efj_parser
6
6
  Author: Jon Hurst
7
7
  Author-email: jon.a@hursts.org.uk
8
8
  Project-URL: docs, https://hursts.org.uk/efjdocs/
9
- Classifier: Development Status :: 4 - Beta
9
+ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
12
  Classifier: Operating System :: OS Independent
@@ -19,6 +19,7 @@ Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
21
21
  Dynamic: home-page
22
+ Dynamic: license-file
22
23
  Dynamic: project-url
23
24
  Dynamic: requires-python
24
25
  Dynamic: summary
@@ -101,7 +101,7 @@ class _VE(Exception):
101
101
  Code.BAD_SYNTAX: "Invalid syntax",
102
102
  Code.BAD_TIME: "Invalid time format",
103
103
  Code.MISSING_AIRCRAFT: "Prior aircraft specifier required",
104
- Code.MISSING_AIRCRAFT: "No Captain specified",
104
+ Code.MISSING_CAPTAIN: "No Captain specified",
105
105
  Code.MISSING_DATE: "Prior date specifier required",
106
106
  Code.MISSING_DEST: "No destination airfield specified",
107
107
  Code.MISSING_ORIGIN: "No origin airfield specified",
@@ -235,11 +235,10 @@ class Parser():
235
235
  ) -> tuple[Conditions, Roles, Landings, Flags]:
236
236
  conditions, unused_flags = _process_conditions(flags, duration)
237
237
  roles, unused_flags = _process_roles(unused_flags, duration)
238
+ landings, unused_flags = _process_landings(unused_flags, duration,
239
+ conditions.night)
238
240
  if roles.p2 == duration:
239
241
  landings = Landings()
240
- else:
241
- landings, unused_flags = _process_landings(unused_flags, duration,
242
- conditions.night)
243
242
  return conditions, roles, landings, unused_flags
244
243
 
245
244
  def __captain(self, roles, duration) -> str:
@@ -363,21 +362,23 @@ def _process_landings(
363
362
  night: int
364
363
  ) -> tuple[Landings, Flags]:
365
364
  night_ldg, day_ldg = 0, 0
366
- found_landing_flag = False
365
+ m_flag, ldg_flag = False, False
367
366
  unused: list[Flag] = []
368
367
  for f in flags:
369
368
  match f[0]:
370
369
  case "m":
371
- found_landing_flag = True
370
+ m_flag = True
372
371
  case "ld":
373
- day_ldg += 1 if f[1] is None else f[1]
374
- found_landing_flag = True
372
+ day_ldg += (1 if f[1] is None else f[1])
373
+ ldg_flag = True
375
374
  case "ln":
376
- night_ldg += 1 if f[1] is None else f[1]
377
- found_landing_flag = True
375
+ night_ldg += (1 if f[1] is None else f[1])
376
+ ldg_flag = True
378
377
  case _:
379
378
  unused.append(f)
380
- if not found_landing_flag:
379
+ if m_flag: # m flag is like p2 flag for captains
380
+ night_ldg, day_ldg = 0, 0
381
+ elif not ldg_flag:
381
382
  if duration == night:
382
383
  night_ldg = 1
383
384
  else:
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: efj-parser
3
- Version: 0.9.4
3
+ Version: 1.0
4
4
  Summary: Parse an electronic Flight Journal file
5
5
  Home-page: https://github.com/JonHurst/efj_parser
6
6
  Author: Jon Hurst
7
7
  Author-email: jon.a@hursts.org.uk
8
8
  Project-URL: docs, https://hursts.org.uk/efjdocs/
9
- Classifier: Development Status :: 4 - Beta
9
+ Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
12
  Classifier: Operating System :: OS Independent
@@ -19,6 +19,7 @@ Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
21
21
  Dynamic: home-page
22
+ Dynamic: license-file
22
23
  Dynamic: project-url
23
24
  Dynamic: requires-python
24
25
  Dynamic: summary
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="efj-parser",
8
- version="0.9.4",
8
+ version="1.0",
9
9
  author="Jon Hurst",
10
10
  author_email="jon.a@hursts.org.uk",
11
11
  description="Parse an electronic Flight Journal file",
@@ -15,7 +15,7 @@ setuptools.setup(
15
15
  packages=['efj_parser'],
16
16
  package_data={"efj_parser": ["py.typed"]},
17
17
  classifiers=[
18
- "Development Status :: 4 - Beta",
18
+ "Development Status :: 5 - Production/Stable",
19
19
  "Programming Language :: Python :: 3",
20
20
  "License :: OSI Approved :: "
21
21
  "GNU General Public License v3 or later (GPLv3+)",
@@ -149,6 +149,7 @@ N2:320
149
149
  OB-T-1274:A-321
150
150
  /NCE 1100/1300 ld:3
151
151
  / 1340/1540 v:30 n:10 ln
152
+ / 1700/1800 n ln:2 m
152
153
 
153
154
  ++
154
155
  0600/1200 r:60 test # ESBY
@@ -204,6 +205,14 @@ OB-T-1274:A-321
204
205
  efj.Landings(night=1),
205
206
  efj.Aircraft("OB-T-1274", "A-321", ""),
206
207
  efj.Airports("NCE", "BRS"),
208
+ "Self", (), "", ()),
209
+ efj.Sector(
210
+ dt.datetime(2024, 1, 22, 17, 0), 60,
211
+ efj.Roles(p1=60),
212
+ efj.Conditions(night=60, ifr=60),
213
+ efj.Landings(day=0, night=0),
214
+ efj.Aircraft("OB-T-1274", "A-321", ""),
215
+ efj.Airports("BRS", "NCE"),
207
216
  "Self", (), "", ()))
208
217
  self.assertEqual(
209
218
  efj.Parser().parse(data),
@@ -217,7 +226,7 @@ G-ABCD:320
217
226
  {CP:Bloggs Joe}
218
227
  # A general comment about something
219
228
  BRS/BFS 1100/1200 p1s #belfast
220
- / 1300/1400 p2
229
+ / 1300/1400 p2 ld:2
221
230
 
222
231
  +++
223
232
  1000/1610 # Comment
@@ -413,6 +422,13 @@ BRS/BFS 1100/1200 v n:30
413
422
  str(e.exception),
414
423
  "Line 2: [Invalid syntax] 2200-2400")
415
424
 
425
+ def test_missing_captain(self):
426
+ with self.assertRaises(efj.ValidationError) as e:
427
+ efj.Parser().parse("2024-01-21\nG-ABCD:320\nBRS/BFS 1100/1200 p2")
428
+ self.assertEqual(
429
+ str(e.exception),
430
+ "Line 3: [No Captain specified] BRS/BFS 1100/1200 p2")
431
+
416
432
 
417
433
  class TestSectorFlags (unittest.TestCase):
418
434
 
@@ -470,6 +486,11 @@ class TestSectorFlags (unittest.TestCase):
470
486
  self.assertEqual(
471
487
  efj._process_landings((("ld", None),), 2, 2),
472
488
  (efj.Landings(day=1, night=0), ()))
489
+ with self.subTest("Night landing, PM"):
490
+ # m overrides ln flag
491
+ self.assertEqual(
492
+ efj._process_landings((("ln", None), ("m", None)), 2, 1),
493
+ (efj.Landings(day=0, night=0), ()))
473
494
 
474
495
  def test_roles(self):
475
496
  with self.subTest("All p1"):
File without changes
File without changes
File without changes
File without changes
File without changes