Grammalecte  Check-in [9b3cc7f615]

Overview
Comment:[build] test if folders exist before moving content
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build
Files: files | file ages | folders
SHA3-256: 9b3cc7f6159e42538c8a89ba6ceb1e7a16924d9d0aed4e3a1cc9ccad70e0bfa1
User & Date: olr on 2020-04-05 10:00:56
Other Links: manifest | tags
Context
2020-04-05
10:37
[build] handle errors in helpers check-in: 583ae99a7b user: olr tags: trunk, build
10:00
[build] test if folders exist before moving content check-in: 9b3cc7f615 user: olr tags: trunk, build
09:54
[fr] ajustements check-in: 52430380b1 user: olr tags: trunk, fr
Changes

Modified helpers.py from [871d0d4238] to [d28c812f24].

72
73
74
75
76
77
78






79
80
81
82
83
84
85
        else:
            raise


def moveFolderContent (spSrc, spDst, sPrefix="", bLog=False):
    "move folder content from <spSrc> to <spDst>: if files already exist in <spDst>, they are replaced. (not recursive)"
    try:






        for sf in os.listdir(spSrc):
            spfSrc = os.path.join(spSrc, sf)
            if os.path.isfile(spfSrc):
                spfDst = os.path.join(spDst, sPrefix + sf)
                shutil.move(spfSrc, spfDst)
                if bLog:
                    print("file <" + spfSrc + "> moved to <"+spfDst+">")







>
>
>
>
>
>







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
        else:
            raise


def moveFolderContent (spSrc, spDst, sPrefix="", bLog=False):
    "move folder content from <spSrc> to <spDst>: if files already exist in <spDst>, they are replaced. (not recursive)"
    try:
        if not os.path.isdir(spSrc):
            print("Folder <"+spSrc+"> not found. Can’t move files.")
            return
        if not os.path.isdir(spDst)
            print("Folder <"+spDst+"> not found. Can’t move files.")
            return
        for sf in os.listdir(spSrc):
            spfSrc = os.path.join(spSrc, sf)
            if os.path.isfile(spfSrc):
                spfDst = os.path.join(spDst, sPrefix + sf)
                shutil.move(spfSrc, spfDst)
                if bLog:
                    print("file <" + spfSrc + "> moved to <"+spfDst+">")