Skip to content

Commit 4841027

Browse files
committed
display whats new
1 parent a97098d commit 4841027

File tree

5 files changed

+75
-15
lines changed

5 files changed

+75
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ v0.7.0
88
- [x] Added option for smooth scroll
99
- [x] Preferences are now saved when updating the app
1010
- [x] Validators for smooth_scroll and preview_format
11-
- [ ] Display a "What's New" Popup when app is run after an update
11+
- [x] Display a "What's New" Popup when app is run after an update
12+
13+
- - -
1214

1315
v0.6.2
1416
------

clid/NEW.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
v0.7.0
2+
------
3+
4+
- Vi keybindings
5+
- Added option for smooth scroll
6+
- Preferences are now saved when updating the app
7+
- Validators for smooth_scroll and preview_format
8+
- Display a "What's New" Popup when app is run after an update
9+

clid/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from . import database
1414
from . import editmeta
1515

16+
CONFIG_DIR = os.path.expanduser('~/.config/clid/')
1617

1718
class MainActionController(base.ClidActionController):
1819
"""Object that recieves recieves inpout in command line
@@ -175,6 +176,18 @@ def __init__(self, *args, **kwargs):
175176
self.after_search_now_filter_view = False
176177
# used to revert screen(ESC) to standard view after a search(see class ClidMultiline)
177178

179+
with open(CONFIG_DIR + 'first', 'r') as file:
180+
first = file.read()
181+
182+
if first == 'true':
183+
# if app is run for first time or after an update, display a what's new message
184+
with open(CONFIG_DIR + 'NEW') as new:
185+
display = new.read()
186+
npy.notify_confirm(message=display, title='What\'s New', editw=1, wide=True)
187+
with open(CONFIG_DIR + 'first', 'w') as file:
188+
file.write('false')
189+
190+
178191
# change to `load_pref`
179192
def load_files(self):
180193
"""Set the mp3 files that will be displayed"""
@@ -193,7 +206,7 @@ class ClidApp(npy.NPSAppManaged):
193206
def __init__(self, *args, **kwargs):
194207
super().__init__(*args, **kwargs)
195208
self.current_file = None # changed when a file is selected in main screen
196-
self.settings = configobj.ConfigObj(os.path.expanduser('~/.clid.ini'))
209+
self.settings = configobj.ConfigObj(CONFIG_DIR + 'clid.ini')
197210

198211
def onStart(self):
199212
npy.setTheme(npy.Themes.ElegantTheme)

gen_whats_new.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env python3
2+
3+
"""Script for generating a what's file in ./clid/"""
4+
5+
with open('CHANGELOG.md', 'r') as log:
6+
lines = log.readlines()
7+
new = lines[lines.index('\n') + 1: lines.index('- - -\n')]
8+
9+
temp = []
10+
for line in new:
11+
if line.startswith('- '):
12+
temp.append('- ' + line[6:])
13+
else:
14+
temp.append(line)
15+
16+
with open('clid/NEW.txt', 'w') as file:
17+
file.writelines(temp)

setup.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
home = os.path.expanduser('~')
1414
here = os.path.dirname(os.path.abspath(__file__))
15+
config_dir = home + '/.config/clid'
1516

1617
long_des = """Clid is a command line app written in Python3 to manage your mp3 files' ID3 tags.
1718
Unlike other tools, clid provides a graphical interface in the terminal to edit
@@ -21,21 +22,39 @@
2122
See the `homepage <https://github.com/GokulSoumya/clid>`_ for more details.
2223
"""
2324

25+
def set_up_pref_file():
26+
import configobj
27+
try:
28+
os.makedirs(config_dir)
29+
except FileExistsError:
30+
pass
31+
32+
default = configobj.ConfigObj(here + '/clid/config.ini') # get the ini file with default settings
33+
try:
34+
# get user's config file if app is already installed
35+
user = configobj.ConfigObj(config_dir + '/clid.ini', file_error=True)
36+
except OSError:
37+
# expand `~/Music` if app is being installed for the first time
38+
user = configobj.ConfigObj(config_dir + '/clid.ini')
39+
user['music_dir'] = home + '/Music/'
40+
41+
default.update(user) # save user's settings and add new settings options
42+
default.write(outfile=open(config_dir + '/clid.ini', 'wb')) # will raise error if outfile is filename
43+
44+
def make_whats_new():
45+
with open(here + '/clid/NEW.txt', 'r') as file:
46+
to_write = file.read()
47+
with open(config_dir +'/NEW', 'w') as file:
48+
file.write(to_write)
49+
50+
2451
class PostInstall(install):
2552
def run(self):
26-
import configobj
27-
28-
default = configobj.ConfigObj(here + '/clid/config.ini') # get the ini file with default settings
29-
try:
30-
# get user's config file if app is already installed
31-
user = configobj.ConfigObj(home + '/.clid.ini', file_error=True)
32-
except OSError:
33-
# expand `~/Music` if app is being installed for the first time
34-
user = configobj.ConfigObj(home + '/.clid.ini')
35-
user['music_dir'] = home + '/Music/'
36-
37-
default.update(user) # save user's settings and add new settings options
38-
default.write(outfile=open(home + '/.clid.ini', 'wb')) # will raise error if outfile is filename
53+
set_up_pref_file()
54+
make_whats_new()
55+
with open(config_dir + '/first', 'w') as file:
56+
# used to display What's New popup(if true)
57+
file.write('true')
3958

4059
install.run(self)
4160

0 commit comments

Comments
 (0)