tdep-developers / tdep-tutorials

TDEP Tutorials
Creative Commons Zero v1.0 Universal
18 stars 18 forks source link

Python 3.8.10 error when calling shutil.py when calling canonical_configuration #30

Closed jpabatista closed 1 year ago

jpabatista commented 1 year ago

https://github.com/tdep-developers/tdep-tutorials/blob/ee5acca640f15113403670adb64e87ef83c9b28a/01_sampling/example_materials/MgO/README.md?plain=1#L20

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /home/jpabatista/Work/tdep-tutorials/venv/lib/python3.8/site-packages/tdepto │
│ ols/scripts/tdep_create_sample_folders.py:41 in main                         │
│                                                                              │
│   38 │   │   atoms.write(fol / outfile, format=format)                       │
│   39 │   │                                                                   │
│   40 │   │   # move original file as well for reference                      │
│ ❱ 41 │   │   shutil.move(file, fol)                                          │
│   42 │   │                                                                   │
│   43 │   │   if files_control is not None:                                   │
│   44 │   │   │   for file in files_control:                                  │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │            _a = 'contcar_conf0001'                                       │ │
│ │            _b = 'vasp'                                                   │ │
│ │            _c = 'aims'                                                   │ │
│ │            _d = 'samples/sample.00001/geometry.in'                       │ │
│ │         atoms = Atoms(symbols='Mg108O108', pbc=True,                     │ │
│ │                 cell=[12.67727773641, 12.67727773641, 12.67727773641])   │ │
│ │   base_folder = 'samples'                                                │ │
│ │          file = PosixPath('contcar_conf0001')                            │ │
│ │         files = [                                                        │ │
│ │                 │   PosixPath('contcar_conf0001'),                       │ │
│ │                 │   PosixPath('contcar_conf0002'),                       │ │
│ │                 │   PosixPath('contcar_conf0003'),                       │ │
│ │                 │   PosixPath('contcar_conf0004')                        │ │
│ │                 ]                                                        │ │
│ │ files_control = []                                                       │ │
│ │           fol = PosixPath('samples/sample.00001')                        │ │
│ │        folder = 'sample'                                                 │ │
│ │         force = False                                                    │ │
│ │        format = 'aims'                                                   │ │
│ │     format_in = 'vasp'                                                   │ │
│ │            ii = 0                                                        │ │
│ │       outfile = 'geometry.in'                                            │ │

│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/lib/python3.8/shutil.py:787 in move                                     │
│                                                                              │
│    784 │   │   │   os.rename(src, dst)                                       │
│    785 │   │   │   return                                                    │
│    786 │   │                                                                 │
│ ❱  787 │   │   real_dst = os.path.join(dst, _basename(src))                  │
│    788 │   │   if os.path.exists(real_dst):                                  │
│    789 │   │   │   raise Error("Destination path '%s' already exists" % real │
│    790 │   try:                                                              │
│                                                                              │
│ ╭────────────────────── locals ──────────────────────╮                       │
│ │ copy_function = <function copy2 at 0x7fa2309fba60> │                       │
│ │           dst = PosixPath('samples/sample.00001')  │                       │
│ │      real_dst = PosixPath('samples/sample.00001')  │                       │
│ │           src = PosixPath('contcar_conf0001')      │                       │
│ ╰────────────────────────────────────────────────────╯                       │
│                                                                              │
│ /usr/lib/python3.8/shutil.py:750 in _basename                                │
│                                                                              │
│    747 │   # A basename() variant which first strips the trailing slash, if  │
│    748 │   # Thus we always get the last component of the path, even for dir │
│    749 │   sep = os.path.sep + (os.path.altsep or '')                        │
│ ❱  750 │   return os.path.basename(path.rstrip(sep))                         │
│    751                                                                       │
│    752 def move(src, dst, copy_function=copy2):                              │
│    753 │   """Recursively move a file or directory to another location. This │
│                                                                              │
│ ╭─────────────── locals ───────────────╮                                     │
│ │ path = PosixPath('contcar_conf0001') │                                     │
│ │  sep = '/'                           │                                     │
│ ╰──────────────────────────────────────╯                                     │
╰──────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'PosixPath' object has no attribute 'rstrip'
flokno commented 1 year ago

fixed in https://github.com/flokno/tools.tdep/commit/6e76fabfcedb8007f7ce0e01727598e1b1ab648d

thanks!