From 4128609e5dd0c1a1d1403b80c39d9c913bd13b9e Mon Sep 17 00:00:00 2001 From: "richard@richard.do" Date: Mon, 18 Feb 2013 22:35:57 +0000 Subject: [PATCH] get_files() updated to check each file has a name, thanks jlejeune --- mega/mega.py | 5 ++++- tests.py | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mega/mega.py b/mega/mega.py index d46b434..c21e432 100644 --- a/mega/mega.py +++ b/mega/mega.py @@ -92,7 +92,10 @@ class Mega(object): files = self.api_request({'a': 'f', 'c': 1}) files_dict = {} for file in files['f']: - files_dict[file['h']] = self.process_file(file) + processed_file = self.process_file(file) + #ensure each file has a name before returning + if processed_file['a']: + files_dict[file['h']] = processed_file return files_dict def get_upload_link(self, file): diff --git a/tests.py b/tests.py index d8a4bb6..e8f2491 100644 --- a/tests.py +++ b/tests.py @@ -18,8 +18,7 @@ def test(): files = m.get_files() #example iterate over files for file in files: - if files[file]['a'] != False: - print files[file] + print files[file] ##upload file print(m.upload('tests.py'))