Skip to content

Commit 26992bb

Browse files
committed
- Adding "\u" (show Unnamed Register) command
- Fixing some pep8 issues
1 parent e0a692b commit 26992bb

18 files changed

+1114
-944
lines changed

Changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
2020-12-06 s-n-g
22
* Starting 0.8.8-beta7
33
* Implementing "Create Playlist" (\n)
4+
* Addind \u (show Unnamed Register) command
45
* Revert to stations playlist if default one (set by
56
config) does not exist
67
* Second level config windows will not be displayed

README.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ <h2 id="copying-and-pasting---registers">Copying and pasting - Registers <span s
328328
<p>There are 36 named registers (name is <strong>a-z</strong>, <strong>0-9</strong>) and one unnamed register.</p>
329329
<ul>
330330
<li><strong>Named registers</strong> are actually files that contain stations and can be opened and edited as regular playlist files. There are some differences in handling them: they are accessible either individually or using a special window, they are automatically saved, and writing errors are ignored. The later means that registers should not be regarded as normal playlist files that can be safely saved and used forever; this is true as long as there’s no problem with writing to them; if a writing error occurs they may get overwritten or emptied. To permanently save a register, on would <strong>rename</strong> it to a normal playlist file.</p></li>
331-
<li>The <strong>unnamed register</strong> holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist.</p></li>
331+
<li>The <strong>unnamed register</strong> holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist. One can see its contents by pressing &quot;**&quot;.</p></li>
332332
</ul>
333333
<p>To <strong>copy</strong> a station to a register one would press “<strong>y</strong>” and:</p>
334334
<ul>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ There are 36 named registers (name is **a-z**, **0-9**) and one unnamed register
475475

476476
* **Named registers** are actually files that contain stations and can be opened and edited as regular playlist files. There are some differences in handling them: they are accessible either individually or using a special window, they are automatically saved, and writing errors are ignored. The later means that registers should not be regarded as normal playlist files that can be safely saved and used forever; this is true as long as there's no problem with writing to them; if a writing error occurs they may get overwritten or emptied. To permanently save a register, on would **rename** it to a normal playlist file.
477477

478-
* The **unnamed register** holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist.
478+
* The **unnamed register** holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist. One can see its contents by pressing "**\u**".
479479

480480
To **copy** a station to a register one would press "**y**" and:
481481

devel/get_countries

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ curl -L https://github.com/umpirsky/country-list/raw/master/data/en_US/country.j
1111
sed -e 's/,/,\n/g' \
1212
-e 's/{"/{\n"/' \
1313
-e 's/}/\n}/' countries-new.py | \
14-
sed -e 's/^"/ "/' > pyradio/countries.py
14+
sed -e 's/^"/ "/' -e 's/":"/": "/' > pyradio/countries.py
15+
echo >> pyradio/countries.py
1516
git add pyradio/countries.py
1617
} || {
1718
echo "

pyradio.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ There are 36 named registers (name is \fBa-z\fR, \fB0-9\fR) and one unnamed regi
551551
are actually files that contain stations and can be opened and edited as regular playlist files. There are some differences in handling them: they are accessible either individually or using a special window, they are automatically saved, and writing errors are ignored. The later means that registers should not be regarded as normal playlist files that can be safely saved and used forever; this is true as long as there's no problem with writing to them; if a writing error occurs they may get overwritten or emptied. To permanently save a register, on would \fBrename\fR it to a normal playlist file.
552552

553553
.IP The\ \fBunnamed\ register\fR
554-
holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist.
554+
holds just one station (the one that has been copied or added to a register or deleted from a playlist), and it is the one used when pasting to a register or a playlist. One can see its contents by pressing "\fB\\u\fR".
555+
555556

556557
.P
557558
To \fBcopy\fR a station to a register one would press "\fBy\fR" and:

pyradio/browser.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import threading
99
import logging
1010
from .cjkwrap import cjklen, PY3
11-
#from os import get_terminal_size
11+
# from os import get_terminal_size
1212

1313
import locale
1414
locale.setlocale(locale.LC_ALL, '') # set your locale
@@ -325,7 +325,7 @@ def search(self, data):
325325
self._last_search = post_data
326326
url = 'http://www.radio-browser.info/webservice/json/stations/search'
327327
try:
328-
#r = requests.get(url=url)
328+
# r = requests.get(url=url)
329329
r = requests.get(url=url, headers=self._open_headers, json=post_data, timeout=self._search_timeout)
330330
r.raise_for_status()
331331
self._raw_stations = self._extract_data(json.loads(r.text))
@@ -370,9 +370,9 @@ def format_station_line(self, id_in_list, pad, width):
370370
u' {0}{1}│{2}│{3}kb',
371371
u' {0}{1}│{2}│{3}kb│{4}',
372372
u' {0}{1}│{2}│{3}kb│{4}│{5}',
373-
)
373+
)
374374
self._get_output_format(width)
375-
#logger.error('DE self._output_format = {}'.format(self._output_format))
375+
# logger.error('DE self._output_format = {}'.format(self._output_format))
376376
out = ['{0}. '.format(str(id_in_list + 1).rjust(pad)), '', '']
377377

378378
# format info field
@@ -535,12 +535,12 @@ def _populate_columns_separators(self, a_tuple, width):
535535
return ret
536536

537537
def get_columns_separators(self,
538-
width,
539-
use_old_output_format=False,
540-
adjust=0,
541-
adjust_for_body=False,
542-
adjust_for_header=False,
543-
):
538+
width,
539+
use_old_output_format=False,
540+
adjust=0,
541+
adjust_for_body=False,
542+
adjust_for_header=False,
543+
):
544544
"""Calculates columns separators for a given width
545545
based on self._output_format.
546546

pyradio/cjkwrap.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
8585
reversed_chunks[-1] = chunk_end
8686
elif not cur_line:
8787
cur_line.append(reversed_chunks.pop())
88+
8889
def _wrap_chunks(self, chunks):
8990
lines = []
9091
if self.width <= 0:
@@ -96,24 +97,34 @@ def _wrap_chunks(self, chunks):
9697
while chunks:
9798
cur_line = []
9899
cur_len = 0
100+
99101
if lines:
100102
indent = self.subsequent_indent
101103
else:
102104
indent = self.initial_indent
103105
width = self.width - len(indent)
104-
if self.drop_whitespace and chunks[-1].strip() == '' and lines:
106+
107+
if self.drop_whitespace and \
108+
chunks[-1].strip() == '' and \
109+
lines:
105110
del chunks[-1]
111+
106112
while chunks:
107-
l = cjklen(chunks[-1])
108-
if cur_len + l <= width:
113+
chunk = cjklen(chunks[-1])
114+
if cur_len + chunk <= width:
109115
cur_line.append(chunks.pop())
110-
cur_len += l
116+
cur_len += chunk
111117
else:
112118
break
119+
113120
if chunks and cjklen(chunks[-1]) > width:
114121
self._handle_long_word(chunks, cur_line, cur_len, width)
115-
if self.drop_whitespace and cur_line and cur_line[-1].strip() == '':
122+
123+
if self.drop_whitespace and \
124+
cur_line and \
125+
cur_line[-1].strip() == '':
116126
del cur_line[-1]
127+
117128
if cur_line:
118129
lines.append(indent + ''.join(cur_line))
119130
return lines

pyradio/common.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
""" Theming constants """
44
def FOREGROUND(): return 0
55
def BACKGROUND(): return 1
6+
67
# for pop up window
78
CAPTION = 2
89
BORDER = 3
@@ -14,14 +15,16 @@ def BACKGROUND(): return 1
1415
If > 0, get color from list item referred to by number
1516
Same for the background
1617
"""
17-
THEME_ITEMS = ( ('PyRadio URL', 2, 0, 3),
18-
('Messages Border', 3, 0 ,3),
19-
('Status Bar', 7, 0, 0),
20-
('Stations', 5, 0 ,0),
21-
('Active Station', 4, 0, 3),
22-
('Normal Cursor', 6, 0, 0),
23-
('Active Cursor', 9, 0, 0),
24-
('Edit Cursor', 8, 0, 0 ) )
18+
THEME_ITEMS = (
19+
('PyRadio URL', 2, 0, 3),
20+
('Messages Border', 3, 0, 3),
21+
('Status Bar', 7, 0, 0),
22+
('Stations', 5, 0, 0),
23+
('Active Station', 4, 0, 3),
24+
('Normal Cursor', 6, 0, 0),
25+
('Active Cursor', 9, 0, 0),
26+
('Edit Cursor', 8, 0, 0)
27+
)
2528

2629
""" Messages to display when player starts / stops
2730
Used in log to stop runaway threads from printing

pyradio/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def paste_station_to_named_playlist(self, a_station, a_playlist):
719719
-5: Error writing file
720720
-6: Error renaming file
721721
"""
722-
if path.exists(self, a_station, a_playlist):
722+
if path.exists(a_playlist):
723723
m_station = a_station[:]
724724
ch = (' ', ',')
725725
for a_ch in ch:

0 commit comments

Comments
 (0)