2 Commits
1.2.1 ... 1.2.3

Author SHA1 Message Date
FoxMaSk
e30e5393f0 fix #8 + upd API 2018-05-27 12:13:08 +02:00
FoxMaSk
825efab0f7 v1.2.2 due to pypi error 2018-04-18 11:17:50 +02:00
4 changed files with 35 additions and 30 deletions

View File

@@ -14,7 +14,7 @@ setup(
description=desc,
long_description=long_desc,
author='FoxMaSk',
author_email='foxmask@trigger-happy.eu',
author_email='foxmaskhome@gmail.com',
url='https://github.com/push-things/wallabag_api',
download_url="https://github.com/push-things/wallabag_api/archive/wallabag_api-" + version + ".zip",
packages=find_packages(),

View File

@@ -1,2 +1,2 @@
VERSION = (1, 2, 1) # PEP 386
VERSION = (1, 2, 3) # PEP 386
__version__ = ".".join([str(x) for x in VERSION])

View File

@@ -150,8 +150,6 @@ class Wallabag(object):
"""
# default values
params = dict({'access_token': self.token,
'archive': 0,
'star': 0,
'delete': 0,
'sort': 'created',
'order': 'desc',
@@ -160,23 +158,14 @@ class Wallabag(object):
'tags': '',
'since': 0})
params['archive'] = self.__get_attr(what='archive',
type_attr=int,
value_attr=(0, 1),
**params)
params['star'] = self.__get_attr(what='star',
type_attr=int,
value_attr=(0, 1),
**params)
params['delete'] = self.__get_attr(what='delete',
type_attr=int,
value_attr=(0, 1),
**params)
params['order'] = self.__get_attr(what='order',
type_attr=str,
value_attr=('asc', 'desc'),
**params)
if 'archive' in kwargs and int(kwargs['archive']) in (0, 1):
params['archive'] = int(kwargs['archive'])
if 'star' in kwargs and int(kwargs['star']) in (0, 1):
params['star'] = int(kwargs['star'])
if 'delete' in kwargs and int(kwargs['delete']) in (0, 1):
params['delete'] = int(kwargs['delete'])
if 'order' in kwargs and kwargs['order'] in ('asc', 'desc'):
params['order'] = kwargs['order']
if 'page' in kwargs and isinstance(kwargs['page'], int):
params['page'] = kwargs['page']
if 'perPage' in kwargs and isinstance(kwargs['perPage'], int):
@@ -190,7 +179,8 @@ class Wallabag(object):
return await self.query(path, "get", **params)
async def post_entries(self, url, title='', tags='', starred=0, archive=0):
async def post_entries(self, url, title='', tags='', starred=0, archive=0, content='', language='', published_at='',
authors='', public=1, original_url=''):
"""
POST /api/entries.{_format}
@@ -201,12 +191,20 @@ class Wallabag(object):
:param tags: tag1,tag2,tag3 a comma-separated list of tags.
:param starred entry already starred
:param archive entry already archived
:param content additionnal html content
:param language
:param published_at
:param authors
:param public
:param original_url
:return result
"""
params = {'access_token': self.token, 'url': url, 'title': title,
'tags': tags, 'starred': starred, 'archive': archive}
if len(tags) > 0 and ',' in tags:
params['tags'] = tags.split(',')
'tags': tags, 'starred': starred, 'archive': archive,
'content': content, 'language': language, 'published_at': published_at,
'authors': authors, 'public': public, 'original_url': original_url}
if len(tags) > 0 and isinstance(tags, list):
params['tags'] = ', '.join(tags)
path = '/api/entries.{ext}'.format(ext=self.format)
return await self.query(path, "post", **params)

View File

@@ -1,4 +1,5 @@
# coding: utf-8
import datetime
import unittest
from wallabag import Wallabag
@@ -33,17 +34,23 @@ class TestWallabag(unittest.TestCase):
def create_entry(self):
title = 'foobar title'
url = 'https://smcomm.trigger-happy.eu/'
url = 'https://somwhere.over.the.raibow.com/'
tags = ['foo', 'bar']
starred = 0
archive = 0
data = self.w.post_entries(url, title, tags, starred, archive)
content = '<p>Additional content</p>'
language = 'FR'
published_at = datetime.datetime.now()
authors = 'John Doe'
public = 0
original_url = 'http://localhost'
data = self.w.post_entries(url, title, tags, starred, archive, content, language, published_at, authors,
public, original_url)
return data
def test_get_entries(self):
params = {'archive': 0,
'star': 0,
'delete': 0,
params = {'delete': 0,
'sort': 'created',
'order': 'desc',
'page': 1,