mapado / datection

Detect and normalize temporal expressions
0 stars 0 forks source link

fix badly formatted rrules #78

Closed jdeniau closed 4 years ago

jdeniau commented 6 years ago

Pull request :twisted_rightwards_arrows: created by @jnieuviarts on 2018-02-20 17:45 Last updated on 2018-02-21 12:29 Original Bitbucket pull request id: 78

Participants:

  • @jnieuviarts
  • @jdeniau (reviewer)
  • @RomainMapado (reviewer) :heavy_check_mark:
  • @dallegoet (reviewer)

Source: https://github.com/mapado/datection/commit/27d78897f728 on branch jn_fix_cleanup_badlyformatted_rrules Destination: https://github.com/mapado/datection/commit/d6ad41e2e85b on branch master Merge commit: https://github.com/mapado/datection/commit/835211edd415

State: MERGED

Le rrule du type : 'FREQ=DAILY;UNTIL=20220228T235959;BYMINUTE=;BYHOUR=' ne passent pas (il faut forcément une valeur après le BYHOUR Objectif de la PR, supprimer ce type de cas

Le code est un peu "sale" mais je vois pas bien comment faire mieux quand on regarde comment est structuré un rrule avec le code officiel http://dateutil.readthedocs.io/en/stable/_modules/dateutil/rrule.html

jdeniau commented 6 years ago

@RomainMapado commented on 2018-02-21 08:19

Une version un peu plus élégante avec le package re


# ces 2 lignes au niveau module pour pas compiler la regexp à chaque appel
rrule_keywords = ['BYHOUR', 'BYMINUTE', 'BYDAY']
regexp_keywords_equal_null = re.compile('|'.join(['%s=(;|$)' % keyword for keyword in rrule_keywords  ]))
# puis dans la méthode
rrule_str = re.sub(regexp_keywords_equal_null, '', rrule_str).strip(';')
jdeniau commented 6 years ago

@jnieuviarts commented on 2018-02-21 11:24

Remplacé. Thx

jdeniau commented 6 years ago

@RomainMapado approved :heavy_check_mark: the pull request on 2018-02-21 11:37