read me update and tests
This commit is contained in:
parent
36bed09dde
commit
d15be6deff
3 changed files with 20 additions and 13 deletions
|
@ -43,6 +43,11 @@ balance = m.get_balance()
|
||||||
```python
|
```python
|
||||||
quota = m.get_quota()
|
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
|
### Get account files
|
||||||
```python
|
```python
|
||||||
files = m.get_files()
|
files = m.get_files()
|
||||||
|
|
|
@ -305,11 +305,11 @@ class Mega(object):
|
||||||
raise ValueError("Only one unit prefix can be specified")
|
raise ValueError("Only one unit prefix can be specified")
|
||||||
unit_coef = 1
|
unit_coef = 1
|
||||||
if kilo:
|
if kilo:
|
||||||
unit_coef = 1024.
|
unit_coef = 1024
|
||||||
if mega:
|
if mega:
|
||||||
unit_coef = 1048576.
|
unit_coef = 1048576
|
||||||
if giga:
|
if giga:
|
||||||
unit_coef = 1073741824.
|
unit_coef = 1073741824
|
||||||
json_resp = self.api_request({'a': 'uq', 'xfer': 1, 'strg': 1})
|
json_resp = self.api_request({'a': 'uq', 'xfer': 1, 'strg': 1})
|
||||||
return {
|
return {
|
||||||
'used': json_resp['cstrg'] / unit_coef,
|
'used': json_resp['cstrg'] / unit_coef,
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -27,6 +27,8 @@ def test():
|
||||||
|
|
||||||
# get account disk quota in MB
|
# get account disk quota in MB
|
||||||
print(m.get_quota())
|
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:
|
for file in files:
|
||||||
|
|
Loading…
Reference in a new issue