-
Notifications
You must be signed in to change notification settings - Fork 0
/
dosyaBack.py
71 lines (63 loc) · 2.37 KB
/
dosyaBack.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
import glob
import os
import re
from pathlib import Path
class Dosya(Path):
def __init__(self,fileName):
self.fileName=fileName
self.fileStrings=fileName.split(".")
self.SecondNameFlag=False
self.fileExtension=False
if len(self.fileStrings)==3:
self.SecondNameFlag=True
self.fileExtension=True
self.fileFirstName=self.fileStrings[0]
self.fileSecondName=self.fileStrings[1]
self.fileExtension=self.fileStrings[2]
if len(self.fileStrings)==2:
self.fileExtension=True
self.fileFirstName=self.fileStrings[0]
self.fileExtension=self.fileStrings[1]
if len(self.fileStrings)==1:
self.fileFirstName=self.fileStrings[0]
print (self.fileStrings)
print (len(self.fileStrings))
def uzantiDegistir(self,extension):
self.fileExtension=extension
def isimDegistir(self,fileName):
self.fileName=fileName
self.fileStrings=fileName.split(".")
self.SecondNameFlag=False
self.fileExtension=False
if len(self.fileStrings)==3:
self.SecondNameFlag=True
self.fileExtension=True
self.fileFirstName=self.fileStrings[0]
self.fileSecondName=self.fileStrings[1]
self.fileExtension=self.fileStrings[2]
if len(self.fileStrings)==2:
self.fileExtension=True
self.fileFirstName=self.fileStrings[0]
self.fileExtension=self.fileStrings[1]
if len(self.fileStrings)==1:
self.fileFirstName=self.fileStrings[0]
def __str__(self):
s=self.fileName
return s
def __repr__(self):
return "Dosya Nesnesi: {}".format(self.fileName)
class Klasor:
def __init__(self,path):
self.path=Path(path)
self.dosyaListesi=self.dosyaListesi()
self.klasorListesi=self.altKlasor()
def dosyaListesi(self):
# dosyaListesi=[]
dosyaListesi=[Dosya(str(dosya).split("/")[-1]) for dosya in self.path.iterdir() if dosya.is_file()]
# for file in self.path.glob('*'):
# dosyaListesi.append(Dosya(str(file)))
return dosyaListesi
def altKlasor(self):
klasorListesi=[altKlasor for altKlasor in self.path.iterdir() if altKlasor.is_dir()]
return klasorListesi