-
Notifications
You must be signed in to change notification settings - Fork 1
/
nameop.py
53 lines (45 loc) · 1.42 KB
/
nameop.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
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 29 19:08:19 2018
@author: robotics
"""
class NameOp:
def __init__(self, filepath):
self.original = self.getFilename(filepath)
self.ext = self.getExt(filepath)
self.desc = self.getDesc(filepath)
def getFilename(self, filepath):
pathlist = filepath.split('/')
size = len(pathlist)
filename = pathlist[size-1]
return filename
def getExt(self, filepath):
filename = self.getFilename(filepath)
namelist = filename.split('.')
size = len(namelist)
ext = namelist[size-1]
return ext
def getDesc(self, filepath):
filename = self.getFilename(filepath)
namelist = filename.split('.')
size = len(namelist)
namelist = namelist[0:size-1]
desc = '.'.join(namelist)
return desc
def addOperation(self, string):
if self.desc != None:
desc = self.desc.split('_')
desc.append(string)
self.desc = '_'.join(desc)
else:
self.desc = string
def readFileNum(self):
file_a = open("_log/counter.txt","r")
number = int(file_a.read()) + 1
file_a.close()
file_a = open("_log/counter.txt","w")
file_a.write(str(number))
file_a.close()
return number
if __name__ == "__main__":
pass