Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on TouristiceEventParser when capacity is really an int #3573

Closed
numahell opened this issue Apr 19, 2023 · 2 comments
Closed

Error on TouristiceEventParser when capacity is really an int #3573

numahell opened this issue Apr 19, 2023 · 2 comments

Comments

@numahell
Copy link
Contributor

It often occurs that capacity is a string in SIT APIs.

An error occurs when this value is an int 👍

AttributeError: 'int' object has no attribute 'isnumeric'
  File "geotrek", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "geotrek/common/management/commands/import.py", line 55, in handle
    parser.parse(options['filename'], limit=limit)
  File "geotrek/common/parsers.py", line 538, in parse
    self.parse_row(row)
  File "geotrek/common/parsers.py", line 400, in parse_row
    self.parse_obj(row, operation)
  File "geotrek/common/parsers.py", line 322, in parse_obj
    update_fields = self.parse_fields(row, self.fields)
  File "geotrek/common/parsers.py", line 311, in parse_fields
    self.parse_field(row, dst, src, updated, non_field)
  File "geotrek/common/parsers.py", line 300, in parse_field
    modified = self.parse_real_field(dst, src, val)
  File "geotrek/common/parsers.py", line 224, in parse_real_field
    val = getattr(self, 'filter_{0}'.format(dst))(src, val)
  File "geotrek/tourism/parsers.py", line 341, in filter_capacity
    if val.isnumeric():
@camillemonchicourt
Copy link
Member

Oui on avait identifié ce soucis potentiel lors de l'évolution du module EVENEMENTS TOURISTIQUES (#3237).
Voici ce que l'on avait indiqué sur le sujet :

On pourrait quand même vérifier si le string renvoyé est un chiffre et auquel cas le convertir en entier et l'intégrer dans "capacity" ?

@marcantoinedupre
Copy link
Contributor

On pourrait quand même vérifier si le string renvoyé est un chiffre et auquel cas le convertir en entier et l'intégrer dans "capacity" ?

C'est bien ce qui est fait actuellement dans le parser TouristicEventApidaeParser. Mais le cas où la valeur importée est un entier n'était pas ou plus supporté. Ma PR #3599 le corrige.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants