Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Windows: path related issue #1

Open
ghost opened this issue Oct 10, 2020 · 8 comments
Open

Windows: path related issue #1

ghost opened this issue Oct 10, 2020 · 8 comments

Comments

@ghost
Copy link

ghost commented Oct 10, 2020

platform: windows

........F
======================================================================
FAIL: test_static_links (test_tag_converter.TagConverterTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\Him\Documents\bootstrap-studio-to-django-template\test\test_tag_converter.py", line 111, in test_static_links
    self.compare_file("static_links", "link_conversion")
  File "C:\Users\Him\Documents\bootstrap-studio-to-django-template\test\test_tag_converter.py", line 57, in compare_file
    self.compare_file_content(copy_file, django_file)
  File "C:\Users\Him\Documents\bootstrap-studio-to-django-template\test\test_tag_converter.py", line 83, in compare_file_content
    self.assertEqual(reference_content, result_content)
AssertionError: '{% load static %}\n<img alt="" src=\'{% static "home\\img\\logo.png" %}\'/>' != '{% load static %}\n<img alt="" src=\'{% static "home/img/logo.png" %}\'/>'
  {% load static %}
- <img alt="" src='{% static "home\img\logo.png" %}'/>?                                 ^   ^
+ <img alt="" src='{% static "home/img/logo.png" %}'/>?                                 ^   ^


----------------------------------------------------------------------
Ran 9 tests in 1.553s

FAILED (failures=1)
@AbcSxyZ
Copy link
Owner

AbcSxyZ commented Oct 11, 2020

Path are actually not adapted to Windows platform, I was only using Unix OS.

Something to do in TagConverter._convert_bss_link.

It will also miss Hard Drive letter (C:, D:, etc.). [Not sure about it]

I do not have access to windows, are you able to create a fix for windows, to make it working on your computer ? If you PR, I could create a portable fix later.

@AbcSxyZ AbcSxyZ changed the title Seems like some path related issue Windows: path related issue Oct 11, 2020
@patriciy1
Copy link

Windows 10, the same situation. Is the problem still not resolved?

@ghost
Copy link
Author

ghost commented Nov 20, 2020 via email

@AbcSxyZ
Copy link
Owner

AbcSxyZ commented Nov 20, 2020

Actually, does the software work or it is just a test failure ?

@hp7017 Do you have a fix to share ?

@patriciy1 I've no access to a windows OS, need contribution of someone else. It would be a great improvement.

Depending on of the situation, the beginning of the fix could be :

if os.name == "nt":
    #Do stuff for windows
    new_path = #Path creation
else:
    #Do stuff for posix systems
    new_path = PurePath(app_name) / file_type / "/".join(path.parts[3:])

But I'm actually not understanding the problem.

@patriciy1
Copy link

@hp7017 It would be great if you share the fix with us.

@ghost
Copy link
Author

ghost commented Nov 20, 2020 via email

@AbcSxyZ
Copy link
Owner

AbcSxyZ commented Nov 20, 2020

Actually, does the software work or it is just a test failure ?
Because the diff show :

- <img alt="" src='{% static "home\img\logo.png" %}'/>? 
+ <img alt="" src='{% static "home/img/logo.png" %}'/>? 

I don't know what static path look like on windows inside django template, but it's just changing slash to trailing slash.
So, do you use slash or trailing slash inside django's templates ?

EDIT:
If it's the case (just a slash side error), does changing the return of TagConverter._convert_bss_link
from return str(new_path) to return new_path.as_posix() fix the error ?

@SushantGautam
Copy link

SushantGautam commented Aug 9, 2021

Bash Script
@echo off

SET SCRIPT_DIR=%~dp0
SET %BSS_DIR%=%1


cd %1

python36 %SCRIPT_DIR%converter.py "%1"

I tried this for django_script.bat

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

No branches or pull requests

3 participants