torchbox / wagtail-wordpress-import

A package for Wagtail CMS to import WordPress blog content from an XML file into Wagtail
MIT License
44 stars 16 forks source link

Support slash in file path in reduce command #129

Closed fabienheureux closed 2 years ago

fabienheureux commented 2 years ago

Reduce commands fails when using a nested xml file path

I am using a docker setup locally, and have my xml file located in /app/dump.xml in the docker container.
I am using the reduce command as : python manage.py reduce_xml /app/dump.xml This causes the command to fail when writing the stats file as the command tries to write f = open(f"stats-{file_path}.json", "w") resulting in 'stats-/app/dump.xml.json'

Here is the full stacktrace ```python Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/usr/local/lib/python3.8/site-packages/wagtail_wordpress_import/management/commands/reduce_xml.py", line 109, in handle f = open(f"stats-{file_path}.json", "w") FileNotFoundError: [Errno 2] No such file or directory: 'stats-/app/dump.xml.json' ```

codecov-commenter commented 2 years ago

Codecov Report

Merging #129 (a61b072) into main (3c27330) will increase coverage by 0.19%. The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   65.38%   65.57%   +0.18%     
==========================================
  Files          32       32              
  Lines        1251     1255       +4     
  Branches      222      222              
==========================================
+ Hits          818      823       +5     
+ Misses        392      391       -1     
  Partials       41       41              
Impacted Files Coverage Δ
...wordpress_import/management/commands/reduce_xml.py 32.30% <83.33%> (+6.07%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3c27330...a61b072. Read the comment docs.

nickmoreton commented 2 years ago

@fabienheureux Thank you for the PR. The tests are now passing :)