Repository navigation
Expand file tree
/
Copy pathnews.py
More file actions
72 lines (70 loc) · 1.58 KB
/
Copy pathnews.py
File metadata and controls
72 lines (70 loc) · 1.58 KB
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
70
71
72
from resources.utils import clearConsole,sleep
class New():
def __init__(self,title: str, day: int, month: int ,year: int = 2021, files = ["README.md"]):
self.title=title
if day<10:
newday="0"+str(day)
else:
newday=str(day)
if month<10:
newmonth="0"+str(month)
else:
newmonth=str(month)
self.date=newmonth+"/"+newday+"/"+str(year)
self.place="Santiago, Chile"
self.text=""
self.tags=[]
self.files=files
def tag(self, text: str):
try:
self.tags.append(text)
except:
print("A tagging bug was happen")
def format(self):
t="\n### "+self.title+"\n#### "+self.date+" "+self.place
t+="\n##### Tags: "
try:
for i in self.tags:
t+="["+i+"](https://github.com/topics/"+i+")"
except:
pass
t+="\n"+self.text+"\n"
return t
def add(self):
try:
T=self.format()
try:
for i in self.files:
f=open(i,"a")
f.write(T)
print("Writting the new in "+i)
sleep(100)
f.close()
print("New added succesfully")
print("Title: "+self.title)
print("Date: "+self.date)
print("Content: "+preview(self.text.split()))
except:
print("A writting bug was happen")
except:
print("A formatting bug was happen")
def preview(string: str):
preview=""
try:
preview+=string[0]
except:
pass
try:
preview+=" "+string[1]
except:
pass
try:
preview+=" "+string[2]
except:
pass
try:
preview+=" "+string[3]
except:
pass
preview+="..."
return preview