-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha04_rn.py~
54 lines (41 loc) · 1.37 KB
/
a04_rn.py~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Renamer.py
# class defining Renamer objects, as used by rn.py
class Renamer(fileList = (), nameMask = {}, nameMaskString = "", renamingMask = "", nameMaskVariableSeparator = "||")
def __init__(self):
self.fileList = fileList
self.nameMask = nameMask
self.nameMaskString = nameMaskString
self.renamingMask = renamingMask
self.NAME_MASK_VARIABLE_SEPARATOR = nameMaskVariableSeparator
def parseNameMaskString(self, nameMaskString):
if not(nameMaskString):
print("ERROR: Must supply naming mask string")
else:
parselist = nameMaskString.split(self.NAME_MASK_VARIABLE_SEPARATOR)
for varstring in parselist:
var, regex = varstring.split("=")
var = var.strip()
regex = regex.strip()
self.nameMask[var] = regex
def printNamingMask(self):
for key in self.nameMask.keys():
print self.nameMask[key]
def setNameMaskString(self, nameMaskString):
self.nameMaskString = nameMaskString
self.parseNameMaskString(nameMaskString)
def getNameMaskString():
return self.nameMaskString
def setNameMask(self, nameMask):
self.nameMask = nameMask
def getNameMask():
return self.nameMask
def setRenamingMask(self, renamingMask):
self.renamingMask = renamingMask
def getRenamingMask():
return self.renamingMask
def setFileList(self, fileList):
self.fileList = fileList
def getFileList():
return self.fileList
def renameFiles(self):
pass