Skip to content

Commit abb463b

Browse files
authored
Create mdmaker.py
1 parent 2d98fda commit abb463b

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# 디시콘 랭킹 표를 마크다운 문법에 맞춰 생성하는 스크립트
2+
# ./out 폴더에 저장된 디시콘 이미지들과 디시콘 사용횟수(Count)가 줄바꿈 문자로 구분된 텍스트 파일이 있어야 합니다.
3+
4+
import os.path
5+
6+
listfilename = input('Count 텍스트 파일?(.txt):')
7+
content = open(listfilename + '.txt', 'r').read()
8+
9+
c = content.split('\n')
10+
clist = []
11+
12+
for i in c:
13+
clist.append(i)
14+
15+
totalnum = 200 # 총 갯수
16+
width = 3 # 열 갯수
17+
prevnum = -1
18+
lastnum = -1
19+
20+
pg = '|순위|이미지|사용횟수' * width
21+
pg += '|\n'
22+
pg += '|-|-|-' * width
23+
pg += '|\n'
24+
25+
fname = []
26+
for i in range(1, totalnum + 1, 1):
27+
if os.path.isfile('out\\' + str(i) + '.png'):
28+
fname.append(str(i) + '.png')
29+
else:
30+
fname.append(str(i) + '.gif')
31+
32+
# pg += '|' + str(i) + '|' + '|' + str(i) + '|' +
33+
34+
35+
36+
for i in range(totalnum):
37+
nst = i+1
38+
39+
if (clist[i] == prevnum):
40+
nst = lastnum
41+
else:
42+
lastnum = nst
43+
44+
pg += '|**' + str(nst) + '**|![' + str(i+1) + '](img/'+ fname[i] + ')|' + clist[i]
45+
46+
prevnum = clist[i]
47+
48+
if ((i+1) % width == 0):
49+
pg += '|\n'
50+
51+
pg += '|'
52+
53+
print(pg)

0 commit comments

Comments
 (0)