-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file_status: allow several paths, new format #1369
Changes from 1 commit
3054842
1909b9e
bced76b
eec5c31
1b4c212
d1e5567
e7fd61e
5933dde
4484da1
d76b49d
ef9825e
08b7481
24a5160
c96a435
8fa66b0
e15eedc
fb4c723
67e26e6
b84fda9
fb82b53
0bfe17a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,15 +57,14 @@ | |
from os.path import basename, expanduser | ||
|
||
STRING_NO_PATH = 'missing path' | ||
DEFAULT_FORMAT = u'\?color=paths [\?if=paths \u25cf|\u25a0]' | ||
|
||
|
||
class Py3status: | ||
""" | ||
""" | ||
# available configuration parameters | ||
cache_timeout = 10 | ||
format = DEFAULT_FORMAT | ||
format = u'\?color=paths [\?if=paths \u25cf|\u25a0]' | ||
format_path = u'{basename}' | ||
format_path_separator = u' ' | ||
path = None | ||
|
@@ -91,16 +90,11 @@ def post_config_hook(self): | |
if not self.path: | ||
raise Exception(STRING_NO_PATH) | ||
|
||
# deprecation | ||
self.on = getattr(self, 'icon_available', None) | ||
self.off = getattr(self, 'icon_unavailable', None) | ||
if self.format == DEFAULT_FORMAT and (self.on or self.off): | ||
self.format = u'\?if=paths {}|{}'.format(self.on or u'\u25cf', self.off or u'\u25a0') | ||
new_format = u'\?color=paths [\?if=paths {}|{}]' | ||
self.format = new_format.format(self.on or u'\u25cf', self.off or u'\u25a0') | ||
msg = 'DEPRECATION: you are using old style configuration ' | ||
msg += 'parameters you should update to use the new format.' | ||
self.py3.log(msg) | ||
# icon deprecation | ||
on = getattr(self, 'icon_available', None) | ||
off = getattr(self, 'icon_unavailable', None) | ||
new_icon = u'\?color=paths [\?if=paths {}|{}]'.format(on, off) | ||
self.format = self.format.replace('{icon}', new_icon) | ||
|
||
# convert str to list + expand path | ||
if not isinstance(self.path, list): | ||
|
@@ -109,27 +103,22 @@ def post_config_hook(self): | |
|
||
self.init = {'format_path': []} | ||
if self.py3.format_contains(self.format, 'format_path'): | ||
self.init['format_path'] = self.py3.get_placeholders_list(self.format_path) | ||
self.init['format_path'] = self.py3.get_placeholders_list( | ||
self.format_path | ||
) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep this so we can do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a doubt about this, refresh is for example when I There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not understand this sorry, could you rephrase? "I'd clear this with the fam first." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have a discussion with tobes and/or ultrabug. They our fam. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sorry, fam = familly >_> |
||
def file_status(self): | ||
# init datas | ||
paths = sorted([files for path in self.path for files in glob(path)]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of this, we don't need |
||
count_path = len(paths) | ||
format_path = None | ||
icon = None | ||
|
||
# format icon | ||
if self.py3.format_contains(self.format, 'icon'): | ||
if count_path > 0: | ||
icon = self.on | ||
else: | ||
icon = self.off | ||
|
||
# format paths | ||
if self.init['format_path']: | ||
new_data = [] | ||
format_path_separator = self.py3.safe_format( | ||
self.format_path_separator) | ||
self.format_path_separator | ||
) | ||
|
||
for pathname in paths: | ||
path = {} | ||
|
@@ -156,8 +145,7 @@ def file_status(self): | |
'full_text': self.py3.safe_format( | ||
self.format, { | ||
'paths': count_path, | ||
'format_path': format_path, | ||
'icon': icon | ||
'format_path': format_path | ||
} | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not same from diff I gave you.
{icon}
display None instead of\u...
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups. 😜