-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenname.py
43 lines (35 loc) · 885 Bytes
/
genname.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
#!/usr/bin/python
#-*- coding: UTF-8 -*-
import sys
import os
args = sys.argv
argc = len(args)
directory = ''
extension = ''
filename = ''
file_type = args[argc - 1]
if file_type == 'cpp':
directory = 'algorithm/'
extension = '.cpp'
elif file_type == 'db':
directory = 'database/'
extension = '.sql'
elif file_type == 'sh':
directory = 'shell/'
extension = '.sh'
if directory != '':
filename = args[1]
for i in range(2, argc - 1):
word = args[i]
if word is str:
filename += word
else:
filename += '{}'.format(word)
if i < argc - 1:
filename += '_'
filename += extension
print(filename)
filepath = directory + filename
if not os.path.exists(filepath):
with open(filepath, 'w') as fd:
fd.close()