From d15be6deff966d094e4140629b554459eabd7f9a Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 28 Apr 2013 16:56:17 +0100 Subject: [PATCH] read me update and tests --- README.md | 5 +++++ mega/mega.py | 6 +++--- tests.py | 22 ++++++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9bf1be7..8902f99 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ balance = m.get_balance() ```python quota = m.get_quota() ``` +### Get account storage space +```python +# unit output kilo, mega, gig, otherwise bytes output +space = m.get_storage_space(kilo=True) +``` ### Get account files ```python files = m.get_files() diff --git a/mega/mega.py b/mega/mega.py index 75955cf..8f070cc 100644 --- a/mega/mega.py +++ b/mega/mega.py @@ -305,11 +305,11 @@ class Mega(object): raise ValueError("Only one unit prefix can be specified") unit_coef = 1 if kilo: - unit_coef = 1024. + unit_coef = 1024 if mega: - unit_coef = 1048576. + unit_coef = 1048576 if giga: - unit_coef = 1073741824. + unit_coef = 1073741824 json_resp = self.api_request({'a': 'uq', 'xfer': 1, 'strg': 1}) return { 'used': json_resp['cstrg'] / unit_coef, diff --git a/tests.py b/tests.py index 2401232..12897a3 100644 --- a/tests.py +++ b/tests.py @@ -15,35 +15,37 @@ def test(): mega = Mega() #mega = Mega({'verbose': True}) # verbose option for print output - #login + # login m = mega.login(email, password) - #get user details + # get user details details = m.get_user() print(details) - #get account files + # get account files files = m.get_files() - #get account disk quota in MB + # get account disk quota in MB print(m.get_quota()) + # get account storage space + print(m.get_storage_space()) - #example iterate over files + # example iterate over files for file in files: print(files[file]) - #upload file + # upload file print(m.upload('tests.py')) - #search for a file in account + # search for a file in account file = m.find('tests.py') if file: - #get public link + # get public link link = m.get_link(file) print(link) - #download file. by file object or url + # download file. by file object or url print m.download(file, '/tmp') #m.download_url(link) @@ -53,7 +55,7 @@ def test(): #print(m.delete_url(link)) #print(m.destroy_url(link)) - #empty trash + # empty trash print(m.empty_trash()) if __name__ == '__main__':