minor: english variable names

This commit is contained in:
boyska 2018-02-13 20:28:01 +01:00
parent aeb59a8dc0
commit 1633ce703d

30
feed
View file

@ -42,17 +42,17 @@ def weighted_choice(values, weights):
class Audio(object): class Audio(object):
def __init__(self, url, durata=None): def __init__(self, url, duration=None):
self.url = url self.url = url
if durata is None: if duration is None:
durata = get_duration(url.encode('utf-8')) duration = get_duration(url.encode('utf-8'))
self.durata = durata self.duration = duration
def __str__(self): def __str__(self):
return self.url return self.url
def __repr__(self): def __repr__(self):
return '<Audio {} ({})>'.format(self.url, self.durata) return '<Audio {} ({})>'.format(self.url, self.duration)
@property @property
def urls(self): def urls(self):
@ -75,12 +75,12 @@ class AudioGroup(list):
def __repr__(self): def __repr__(self):
return '<AudioGroup "{}" ({})\n{} >'.\ return '<AudioGroup "{}" ({})\n{} >'.\
format(self.description, self.durata, format(self.description, self.duration,
'\n'.join(' ' + repr(a) for a in self.audios)) '\n'.join(' ' + repr(a) for a in self.audios))
@property @property
def durata(self): def duration(self):
return sum(a.durata for a in self.audios if a.durata is not None) return sum(a.duration for a in self.audios if a.duration is not None)
@property @property
def urls(self): def urls(self):
@ -103,10 +103,10 @@ def get_audio_from_description(text):
for line in text.split('\n') for line in text.split('\n')
if line.strip()] if line.strip()]
url = lines[0] url = lines[0]
durata = None duration = None
if len(lines) > 1: if len(lines) > 1:
durata = int(re.findall(r'\d+', lines[1].split('=')[1].strip())[0]) duration = int(re.findall(r'\d+', lines[1].split('=')[1].strip())[0])
return Audio(unquote(url), durata) return Audio(unquote(url), duration)
# copied from larigira.fsutils # copied from larigira.fsutils
@ -224,12 +224,12 @@ def main():
# get audio urls, removing those that are too long # get audio urls, removing those that are too long
audios += [audio for audio in get_urls(tree) audios += [audio for audio in get_urls(tree)
if args.max_len == 0 or if args.max_len == 0 or
audio.durata <= args.max_len] audio.duration <= args.max_len]
else: else:
groups = get_grouped_urls(tree) groups = get_grouped_urls(tree)
audios += [groups[g] for g in groups.keys() audios += [groups[g] for g in groups.keys()
if args.max_len == 0 or if args.max_len == 0 or
groups[g].durata <= args.max_len groups[g].duration <= args.max_len
] ]
elif os.path.isdir(url): elif os.path.isdir(url):
audiodir = get_audio_from_dir(url) audiodir = get_audio_from_dir(url)
@ -258,7 +258,7 @@ def main():
else: else:
put(audio, args.copy) put(audio, args.copy)
if args.slotsize is not None: if args.slotsize is not None:
duration = audio.durata duration = audio.duration
if duration < args.slotsize: if duration < args.slotsize:
print('## musica per {} secondi' print('## musica per {} secondi'
.format(args.slotsize - duration)) .format(args.slotsize - duration))
@ -270,7 +270,7 @@ def main():
# else: # grouping; TODO: support slotsize # else: # grouping; TODO: support slotsize
# for item in groups: # for item in groups:
# if args.debug: # if args.debug:
# print('#', item, groups[item].durata) # print('#', item, groups[item].duration)
# print(groups[item]) # print(groups[item])