Skip to content

Commit 4dc827b

Browse files
committed
move python files to sub-directory #5
1 parent a064d84 commit 4dc827b

File tree

4 files changed

+55
-46
lines changed

4 files changed

+55
-46
lines changed

manager.py

+2-46
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,7 @@
11
#!/Users/aviaryan/miniconda3/bin/python
22

3-
'''
4-
Sublime Notebook Manager
5-
v0.2.1
6-
'''
7-
8-
import os
9-
from sys import exit
10-
from cryptlib import get_file_list, encode, update_file, get_key, decode
11-
12-
FLAG = 'FLAG_FILE'
13-
14-
15-
def createFlagFile():
16-
fptr = open(FLAG, 'w')
17-
fptr.write('')
18-
fptr.close()
3+
from sublime_notebook import sublime_notebook
194

205

216
if __name__ == '__main__':
22-
23-
if not os.path.exists(FLAG):
24-
# new case
25-
# or decrypted state in power fail
26-
print('Not encrypted, encrypting....')
27-
key = get_key()
28-
print('Re-enter key')
29-
key2 = get_key()
30-
if key != key2:
31-
print('Keys don\'t match, exiting')
32-
exit(1)
33-
update_file(encode, get_file_list(), key2)
34-
createFlagFile()
35-
else:
36-
# encrypted already
37-
print('Encrypted, give key to unlock')
38-
key = get_key()
39-
failStatus = update_file(decode, get_file_list(), key)
40-
if failStatus:
41-
print('You entered wrong key. FO')
42-
exit(2)
43-
os.remove(FLAG)
44-
# decoded, wait to close
45-
print('Notes have been decrypted')
46-
ans = ''
47-
while ans != 'e':
48-
ans = input('Press e to encrypt again > ')
49-
# encrypt
50-
update_file(encode, get_file_list(), key)
51-
createFlagFile()
7+
sublime_notebook.main()

sublime_notebook/__init__.py

Whitespace-only changes.
File renamed without changes.

sublime_notebook/sublime_notebook.py

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/Users/aviaryan/miniconda3/bin/python
2+
3+
"""
4+
Sublime Notebook Manager
5+
v0.2.1
6+
"""
7+
8+
import os
9+
from sys import exit
10+
from .cryptlib import get_file_list, encode, update_file, get_key, decode
11+
12+
FLAG = 'sublime_notebook/FLAG_FILE'
13+
14+
15+
def createFlagFile():
16+
fptr = open(FLAG, 'w')
17+
fptr.write('')
18+
fptr.close()
19+
20+
21+
def main():
22+
"""
23+
Executes Sublime Notebook
24+
"""
25+
if not os.path.exists(FLAG):
26+
# new case
27+
# or decrypted state in power fail
28+
print('Not encrypted, encrypting....')
29+
key = get_key()
30+
print('Re-enter key')
31+
key2 = get_key()
32+
if key != key2:
33+
print('Keys don\'t match, exiting')
34+
exit(1)
35+
update_file(encode, get_file_list(), key2)
36+
createFlagFile()
37+
else:
38+
# encrypted already
39+
print('Encrypted, give key to unlock')
40+
key = get_key()
41+
failStatus = update_file(decode, get_file_list(), key)
42+
if failStatus:
43+
print('You entered wrong key. FO')
44+
exit(2)
45+
os.remove(FLAG)
46+
# decoded, wait to close
47+
print('Notes have been decrypted')
48+
ans = ''
49+
while ans != 'e':
50+
ans = input('Press e to encrypt again > ')
51+
# encrypt
52+
update_file(encode, get_file_list(), key)
53+
createFlagFile()

0 commit comments

Comments
 (0)