Grammalecte  Check-in [dad850cc6c]

Overview
Comment:[build] code cleaning (pylint)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | build
Files: files | file ages | folders
SHA3-256: dad850cc6c3cca669b139bc869b3978de4911428b163b7df8d82483db5071287
User & Date: olr on 2019-05-11 10:55:42
Original Comment: [server] code cleaning (pylint)
Other Links: manifest | tags
Context
2019-05-11
11:07
[build] code cleaning (pylint) check-in: f335e01188 user: olr tags: trunk, build
10:55
[build] code cleaning (pylint) check-in: dad850cc6c user: olr tags: trunk, build
10:48
[server] code cleaning (pylint) check-in: 0c8e86b8c7 user: olr tags: trunk, server
Changes

Modified helpers.py from [ee70e577f1] to [334a9e053b].

8
9
10
11
12
13
14

15
16
17
18
19
20
21
from string import Template


class cd:
    "Context manager for changing the current working directory"
    def __init__ (self, newPath):
        self.newPath = os.path.expanduser(newPath)


    def __enter__ (self):
        self.savedPath = os.getcwd()
        os.chdir(self.newPath)

    def __exit__ (self, etype, value, traceback):
        os.chdir(self.savedPath)







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from string import Template


class cd:
    "Context manager for changing the current working directory"
    def __init__ (self, newPath):
        self.newPath = os.path.expanduser(newPath)
        self.savedPath = ""

    def __enter__ (self):
        self.savedPath = os.getcwd()
        os.chdir(self.newPath)

    def __exit__ (self, etype, value, traceback):
        os.chdir(self.savedPath)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    for sf in os.listdir(sp):
        spf = os.path.join(sp, sf)
        try:
            if os.path.isfile(spf):
                os.unlink(spf)
            elif os.path.isdir(spf):
                shutil.rmtree(spf)
        except Exception as e:
            print(e)


def createCleanFolder (sp):
    "make an empty folder or erase its content if not empty"
    if not os.path.exists(sp):
        os.makedirs(sp, exist_ok=True)







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    for sf in os.listdir(sp):
        spf = os.path.join(sp, sf)
        try:
            if os.path.isfile(spf):
                os.unlink(spf)
            elif os.path.isdir(spf):
                shutil.rmtree(spf)
        except (OSError, shutil.Error) as e:
            print(e)


def createCleanFolder (sp):
    "make an empty folder or erase its content if not empty"
    if not os.path.exists(sp):
        os.makedirs(sp, exist_ok=True)