diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2021-01-10 15:33:10 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2021-01-10 15:33:10 +0100 |
| commit | d5c0cd45ea8966416ebf0d62ae8320ce54fde501 (patch) | |
| tree | 2502ce25689d6c37e43639207dbd640b6ca78551 /src/philo | |
| parent | a28ed0f25620c6205516259609ad73d7d70b5ffd (diff) | |
| download | philosophers_test-d5c0cd45ea8966416ebf0d62ae8320ce54fde501.tar.gz philosophers_test-d5c0cd45ea8966416ebf0d62ae8320ce54fde501.tar.bz2 philosophers_test-d5c0cd45ea8966416ebf0d62ae8320ce54fde501.zip | |
Fixing timestamp parsing
Diffstat (limited to 'src/philo')
| -rw-r--r-- | src/philo/log.py | 9 | ||||
| -rw-r--r-- | src/philo/philo.py | 10 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/philo/log.py b/src/philo/log.py index a07b734..8094688 100644 --- a/src/philo/log.py +++ b/src/philo/log.py @@ -6,7 +6,7 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/10/01 10:51:39 by cacharle #+# #+# # -# Updated: 2020/10/05 13:52:51 by cacharle ### ########.fr # +# Updated: 2021/01/03 13:28:20 by cacharle ### ########.fr # # # # ############################################################################ # @@ -29,15 +29,14 @@ class Log: self._line = line self.id = self._parse_ranged_int(match.group("id"), 1, philo_num) - self.timestamp = self._parse_ranged_int( - match.group("timestamp"), start_time, end_time) + self.timestamp = self._parse_ranged_int(match.group("timestamp")) self.event = Event.from_string(match.group('event')) - def _parse_ranged_int(self, s, lo, hi): + def _parse_ranged_int(self, s, lo=None, hi=None): try: value = int(s) - if not (lo <= value <= hi): + if lo is not None and not (lo <= value <= hi): raise philo.error.Format( self._line, "{} should be between {} - {}".format(s, lo, hi) diff --git a/src/philo/philo.py b/src/philo/philo.py index 3319a0b..0e62e97 100644 --- a/src/philo/philo.py +++ b/src/philo/philo.py @@ -6,7 +6,7 @@ # By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/10/01 10:52:56 by cacharle #+# #+# # -# Updated: 2020/10/05 14:03:07 by cacharle ### ########.fr # +# Updated: 2021/01/03 13:31:54 by cacharle ### ########.fr # # # # ############################################################################ # @@ -56,10 +56,10 @@ class Philo: # check log event number grouped = [(e, list(g)) for e, g in itertools.groupby(self.logs, (lambda x: x.event))] for e, g in grouped[:-1]: - if e is Event.EAT: - if len(g) != self._meal_num: - self._raise("Should eat {} times".format(self._meal_num)) - elif e is Event.FORK: + # if e is Event.EAT: + # if len(g) != self._meal_num: + # self._raise("Should eat {} times".format(self._meal_num)) + if e is Event.FORK: if len(g) != 2: self._raise("Should take fork 2 times") elif len(g) != 1: |
