diff --git a/.travis.yml b/.travis.yml index c00726b..33266d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,8 @@ before_script: script: - "flake8 $(find . -iname '*.py')" - - "nosetests --with-coverage --cover-package=mopidy_vkontakte" - - "coverage run --source=mopidy_vkontakte setup.py test" + - "nosetests --with-coverage --cover-package=mopidy.vkontakte" + - "coverage run --source=mopidy setup.py test" after_success: - "coveralls" diff --git a/MANIFEST.in b/MANIFEST.in index 3c41bbe..9e807ff 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,6 +2,6 @@ include .travis.yml include LICENSE include MANIFEST.in include README.rst -include mopidy_vkontakte/ext.conf +include mopidy/vkontakte/default.conf recursive-include tests *.py diff --git a/README.rst b/README.rst index 9a336f4..1962814 100644 --- a/README.rst +++ b/README.rst @@ -60,36 +60,37 @@ Project resources Changelog ========= -v0.3.1 (UNRELEASED) -------------------- +v0.3.1 +------ - Fixed the encoding issue -v0.3.0 (UNRELEASED) -------------------- +v0.3.0 +------ - Fixed a problem if a client requires folders instead of playlists - Added search functionality but only if you want to find something in vkontakte but not in you library - Fixed some small issues -v0.2.0 (UNRELEASED) -------------------- +v0.2.0 +------ - Require Mopidy >= 0.18. - Fixed: ``ext.conf`` was missing from the PyPI package, stopping Mopidy from working as long as Mopidy-VKontakte is installed. -v0.1.2 (2013-11-27) -------------------- +v0.1.2 +------ -- FIXED: In some cases your token can be expired and you needed to remove a db file manually. +- Released @ 2013-11-27 +- Fixed: In some cases your token can be expired and you needed to remove a db file manually. -v0.1.1 (UNRELEASED) -------------------- +v0.1.1 +------ - Code style fixed. Setup a test cover system. -v0.1.0 (UNRELEASED) -------------------- +v0.1.0 +------ - Initial release. diff --git a/mopidy/__init__.py b/mopidy/__init__.py new file mode 100644 index 0000000..7c68785 --- /dev/null +++ b/mopidy/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/mopidy_vkontakte/__init__.py b/mopidy/vkontakte/__init__.py similarity index 87% rename from mopidy_vkontakte/__init__.py rename to mopidy/vkontakte/__init__.py index 9b78906..4532ccd 100644 --- a/mopidy_vkontakte/__init__.py +++ b/mopidy/vkontakte/__init__.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from __future__ import unicode_literals import os @@ -18,7 +20,7 @@ class Extension(ext.Extension): version = __version__ def get_default_config(self): - conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf') + conf_file = os.path.join(os.path.dirname(__file__), 'default.conf') return config.read(conf_file) def get_config_schema(self): diff --git a/mopidy_vkontakte/actor.py b/mopidy/vkontakte/actor.py similarity index 96% rename from mopidy_vkontakte/actor.py rename to mopidy/vkontakte/actor.py index 5177113..5447b5d 100644 --- a/mopidy_vkontakte/actor.py +++ b/mopidy/vkontakte/actor.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + from __future__ import unicode_literals import logging diff --git a/mopidy_vkontakte/ext.conf b/mopidy/vkontakte/default.conf similarity index 100% rename from mopidy_vkontakte/ext.conf rename to mopidy/vkontakte/default.conf diff --git a/mopidy/vkontakte/form_parser.py b/mopidy/vkontakte/form_parser.py new file mode 100644 index 0000000..ddfb378 --- /dev/null +++ b/mopidy/vkontakte/form_parser.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +from HTMLParser import HTMLParser + + +class FormParser(HTMLParser): + def __init__(self): + HTMLParser.__init__(self) + self.url = None + self.params = {} + self.in_form = False + self.form_parsed = False + self.method = 'GET' + + def handle_starttag(self, tag, attrs): + tag = tag.lower() + if tag == 'form': + if self.form_parsed: + raise RuntimeError('Second form on page') + if self.in_form: + raise RuntimeError('Already in form') + self.in_form = True + if not self.in_form: + return + attrs = dict((name.lower(), value) for name, value in attrs) + if tag == 'form': + self.url = attrs['action'] + if 'method' in attrs: + self.method = attrs['method'].upper() + elif tag == 'input' and 'type' in attrs and 'name' in attrs: + if attrs['type'] in ['hidden', 'text', 'password']: + self.params[attrs['name']] = attrs['value'] if 'value' \ + in attrs else '' + + def handle_endtag(self, tag): + tag = tag.lower() + if tag == 'form': + if not self.in_form: + raise RuntimeError('Unexpected end of
') + self.in_form = False + self.form_parsed = True \ No newline at end of file diff --git a/mopidy_vkontakte/library.py b/mopidy/vkontakte/library.py similarity index 99% rename from mopidy_vkontakte/library.py rename to mopidy/vkontakte/library.py index 072d60f..34d3d70 100644 --- a/mopidy_vkontakte/library.py +++ b/mopidy/vkontakte/library.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + from __future__ import unicode_literals import logging diff --git a/mopidy_vkontakte/playlists.py b/mopidy/vkontakte/playlists.py similarity index 98% rename from mopidy_vkontakte/playlists.py rename to mopidy/vkontakte/playlists.py index ce6135e..860d698 100644 --- a/mopidy_vkontakte/playlists.py +++ b/mopidy/vkontakte/playlists.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + from __future__ import unicode_literals import logging @@ -6,6 +7,7 @@ from mopidy import backend from mopidy.models import Playlist, Track, Artist from urllib import unquote + logger = logging.getLogger(__name__) @@ -19,7 +21,7 @@ def __init__(self, *args, **kwargs): self.refresh() def create(self, name): - print('Playlist create') + logger.debug('Playlist create') pass diff --git a/mopidy_vkontakte/session.py b/mopidy/vkontakte/session.py similarity index 77% rename from mopidy_vkontakte/session.py rename to mopidy/vkontakte/session.py index 143b3c5..228c1bb 100644 --- a/mopidy_vkontakte/session.py +++ b/mopidy/vkontakte/session.py @@ -1,59 +1,22 @@ # -*- coding: utf-8 -*- + from __future__ import unicode_literals import logging - -import os import json import time import shelve import urllib import urllib2 import cookielib - from urllib import urlencode from urlparse import urlparse -from HTMLParser import HTMLParser -logger = logging.getLogger(__name__) +from mopidy.vkontakte.form_parser import FormParser +import os -class FormParser(HTMLParser): - def __init__(self): - HTMLParser.__init__(self) - self.url = None - self.params = {} - self.in_form = False - self.form_parsed = False - self.method = 'GET' - - def handle_starttag(self, tag, attrs): - tag = tag.lower() - if tag == 'form': - if self.form_parsed: - raise RuntimeError('Second form on page') - if self.in_form: - raise RuntimeError('Already in form') - self.in_form = True - if not self.in_form: - return - attrs = dict((name.lower(), value) for name, value in attrs) - if tag == 'form': - self.url = attrs['action'] - if 'method' in attrs: - self.method = attrs['method'].upper() - elif tag == 'input' and 'type' in attrs and 'name' in attrs: - if attrs['type'] in ['hidden', 'text', 'password']: - self.params[attrs['name']] = attrs['value'] if 'value' \ - in attrs else '' - - def handle_endtag(self, tag): - tag = tag.lower() - if tag == 'form': - if not self.in_form: - raise RuntimeError('Unexpected end of ') - self.in_form = False - self.form_parsed = True +logger = logging.getLogger(__name__) class VKSession(object): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..659d051 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +setuptools +mopidy >= 0.18 +pykka >= 1.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 976a564..27f7dd7 100644 --- a/setup.py +++ b/setup.py @@ -10,9 +10,18 @@ def get_version(filename): return metadata['version'] +def get_requirements(): + with open('requirements.txt', 'r') as f: + return [l.rstrip() for l in f.readlines()] + + +def get_test_requirements(): + with open('test-requirements.txt', 'r') as f: + return [l.rstrip() for l in f.readlines()] + setup( name='Mopidy-VKontakte', - version=get_version('mopidy_vkontakte/__init__.py'), + version=get_version('mopidy/vkontakte/__init__.py'), url='https://github.com/sibuser/mopidy-vkontakte', license='Apache License, Version 2.0', author='Alexey Ulyanov', @@ -23,19 +32,12 @@ def get_version(filename): packages=find_packages(exclude=['tests', 'tests.*']), zip_safe=False, include_package_data=True, - install_requires=[ - 'setuptools', - 'Mopidy >= 0.18', - 'Pykka >= 1.1', - ], + install_requires=get_requirements(), test_suite='nose.collector', - tests_require=[ - 'nose', - 'mock >= 1.0', - ], + tests_require=get_test_requirements(), entry_points={ 'mopidy.ext': [ - 'vkontakte = mopidy_vkontakte:Extension', + 'vkontakte = mopidy.vkontakte:Extension', ], }, classifiers=[ diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..5043141 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +nose +mock >= 1.0 \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py index e69de29..7c68785 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/tests/test_extension.py b/tests/test_extension.py index 21cf41e..21fed52 100644 --- a/tests/test_extension.py +++ b/tests/test_extension.py @@ -1,9 +1,11 @@ +# -*- coding: utf-8 -*- + from __future__ import unicode_literals import mock import unittest -from mopidy_vkontakte import Extension, actor as backend_lib +from mopidy.vkontakte import Extension, actor as backend_lib class ExtensionTest(unittest.TestCase):