A user has to type a path in the commandline on Win 10, so just a
string. This has to become a path / directory in the file system. Later
in the process subdirectories and files are 'appended' by the script. In
these files there are also paths, derived from the input path and they
have to use forward slashes. The tool that uses these files requires that.

# create structure:
# /---fullpath  <-- input() cmd
#     |
#     /--- data
#     /--- db
#     |    +--- basename.db3    <-- pathlib.Path(...).touch()
#     |    +--- basename.read   <-- forward slashes inside
#     /--- ddl
#     /--- doc
#     /--- sql
#     +--- basename.sublime-project <-- forward slashes inside (json)
#     +--- _FOSSIL_


And here the misery begins...

A short excerpt:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64
bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> inp = "c:\test\drive\this"
>>> import pathlib
>>> p=pathlib.PurePath(inp)
>>> p
PureWindowsPath('c:\test/drive\this')
>>> print(pathlib.PurePosixPath(p))
c:/ est/drive his
>>> inp
'c:\test\\drive\this'
>>> import os
>>> print(os.path.normpath(inp))
c:  est\drive his
>>> print(pathlib.Path(inp))
c:  est\drive his
>>>

how to go from a string to a path, how to append to a path (os.path.join
or / with Path), how to turn it into 'posix'

TIA,

Ingo
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to