Merge pull request #465 from carpedm20/drop-python-2

Drop Python 2 support
This commit is contained in:
Mads Marquart
2019-08-28 22:01:10 +02:00
committed by GitHub
44 changed files with 28 additions and 192 deletions

View File

@@ -11,17 +11,9 @@ script: pytest -m offline
jobs:
include:
- python: 2.7
before_install:
- sudo apt-get -y install python3-pip python3-setuptools
- sudo pip3 install flit
install: flit install --python python --deps production --extras test
- python: 3.4
- python: 3.5
- python: 3.6
- python: 3.7
dist: xenial
sudo: required
- python: pypy3.5
- name: Lint

View File

@@ -1,23 +1,27 @@
``fbchat``: Facebook Chat (Messenger) for Python
================================================
.. image:: https://img.shields.io/badge/license-BSD-blue.svg
.. image:: https://badgen.net/pypi/license/fbchat
:target: https://github.com/carpedm20/fbchat/tree/master/LICENSE
:alt: License: BSD 3-Clause
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6%203.7%20pypy-blue.svg
.. image:: https://badgen.net/badge/python/3.5,3.6,3.7,3.8,pypy?list=|
:target: https://pypi.python.org/pypi/fbchat
:alt: Supported python versions: 2.7, 3.4, 3.5, 3.6, 3.7 and pypy
:alt: Supported python versions: 3.5, 3.6, 3.7, 3.8 and pypy
.. image:: https://readthedocs.org/projects/fbchat/badge/?version=latest
.. image:: https://badgen.net/pypi/v/fbchat
:target: https://pypi.python.org/pypi/fbchat
:alt: Project version
.. image:: https://readthedocs.org/projects/fbchat/badge/?version=stable
:target: https://fbchat.readthedocs.io
:alt: Documentation
.. image:: https://travis-ci.org/carpedm20/fbchat.svg?branch=master
.. image:: https://badgen.net/travis/carpedm20/fbchat
:target: https://travis-ci.org/carpedm20/fbchat
:alt: Travis CI
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
.. image:: https://badgen.net/badge/code%20style/black/black
:target: https://github.com/ambv/black
:alt: Code style

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="80" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="80" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h47v20H0z"/><path fill="#007ec6" d="M47 0h33v20H47z"/><path fill="url(#b)" d="M0 0h80v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="23.5" y="15" fill="#010101" fill-opacity=".3">license</text><text x="23.5" y="14">license</text><text x="62.5" y="15" fill="#010101" fill-opacity=".3">BSD</text><text x="62.5" y="14">BSD</text></g></svg>

Before

Width:  |  Height:  |  Size: 791 B

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="154" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="154" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h49v20H0z"/><path fill="#007ec6" d="M49 0h105v20H49z"/><path fill="url(#b)" d="M0 0h154v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="24.5" y="15" fill="#010101" fill-opacity=".3">python</text><text x="24.5" y="14">python</text><text x="100.5" y="15" fill="#010101" fill-opacity=".3">2.7, 3.4, 3.5, 3.6</text><text x="100.5" y="14">2.7, 3.4, 3.5, 3.6</text></g></svg>

Before

Width:  |  Height:  |  Size: 825 B

View File

@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a

View File

@@ -11,24 +11,12 @@
Release v\ |version|. (:ref:`install`)
.. generated with: https://img.shields.io/badge/license-BSD-blue.svg
.. image:: /_static/license.svg
:target: https://github.com/carpedm20/fbchat/blob/master/LICENSE.txt
:alt: License: BSD
.. generated with: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6-blue.svg
.. image:: /_static/python-versions.svg
:target: https://pypi.python.org/pypi/fbchat
:alt: Supported python versions: 2.7, 3.4, 3.5 and 3.6
Facebook Chat (`Messenger <https://www.facebook.com/messages/>`_) for Python.
This project was inspired by `facebook-chat-api <https://github.com/Schmavery/facebook-chat-api>`_.
**No XMPP or API key is needed**. Just use your email and password.
Currently ``fbchat`` support Python 2.7, 3.4, 3.5 and 3.6:
Currently ``fbchat`` support Python 3.5, 3.6, 3.7 and 3.8:
``fbchat`` works by emulating the browser.
This means doing the exact same GET/POST requests and tricking Facebook into thinking it's accessing the website normally.

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from fbchat import Client
from fbchat.models import *

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from fbchat import log, Client
# Subclass fbchat.Client and override required methods

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from itertools import islice
from fbchat import Client
from fbchat.models import *

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from fbchat import Client
from fbchat.models import *

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from fbchat import log, Client
from fbchat.models import *

View File

@@ -1,5 +1,3 @@
# -*- coding: UTF-8 -*-
from fbchat import log, Client
from fbchat.models import *

View File

@@ -1,10 +1,8 @@
# -*- coding: UTF-8 -*-
"""Facebook Chat (Messenger) for Python
:copyright: (c) 2015 - 2019 by Taehoon Kim
:license: BSD 3-Clause, see LICENSE for more details.
"""
from __future__ import unicode_literals
# These imports are far too general, but they're needed for backwards compatbility.
from .models import *

View File

@@ -1,12 +1,9 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from . import _util
@attr.s(cmp=False)
class Attachment(object):
class Attachment:
"""Represents a Facebook attachment."""
#: The attachment ID

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import requests
import urllib
from uuid import uuid1
@@ -15,11 +12,6 @@ from ._state import State
import time
import json
try:
from urllib.parse import urlparse, parse_qs
except ImportError:
from urlparse import urlparse, parse_qs
ACONTEXT = {
"action_history": [
@@ -28,7 +20,7 @@ ACONTEXT = {
}
class Client(object):
class Client:
"""A client for the Facebook Chat (Messenger).
This is the main class of ``fbchat``, which contains all the methods you use to

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import logging
import aenum

View File

@@ -1,7 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
class FBchatException(Exception):
"""Custom exception thrown by ``fbchat``.

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._attachment import Attachment

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import json
import re
from . import _util

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from . import _plan
from ._thread import ThreadType, Thread

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._attachment import Attachment
from . import _util

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
import json
from string import Formatter
@@ -46,7 +43,7 @@ class MessageReaction(Enum):
@attr.s(cmp=False)
class Mention(object):
class Mention:
"""Represents a ``@mention``."""
#: The thread ID the mention is pointing at
@@ -58,7 +55,7 @@ class Mention(object):
@attr.s(cmp=False)
class Message(object):
class Message:
"""Represents a Facebook message."""
#: The actual message

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from . import _plan
from ._thread import ThreadType, Thread

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
import json
from ._core import Enum
@@ -13,7 +10,7 @@ class GuestStatus(Enum):
@attr.s(cmp=False)
class Plan(object):
class Plan:
"""Represents a plan."""
#: ID of the plan

View File

@@ -1,11 +1,8 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
@attr.s(cmp=False)
class Poll(object):
class Poll:
"""Represents a poll."""
#: Title of the poll
@@ -28,7 +25,7 @@ class Poll(object):
@attr.s(cmp=False)
class PollOption(object):
class PollOption:
"""Represents a poll option."""
#: Text of the poll option

View File

@@ -1,12 +1,9 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._attachment import Attachment
@attr.s(cmp=False)
class QuickReply(object):
class QuickReply:
"""Represents a quick reply."""
#: Payload of the quick reply

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
import bs4
import re
@@ -100,7 +97,7 @@ def _2fa_helper(session, code, r):
@attr.s(slots=True) # TODO i Python 3: Add kw_only=True
class State(object):
class State:
"""Stores and manages state required for most Facebook requests."""
user_id = attr.ib()

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._attachment import Attachment

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._core import Enum
@@ -73,7 +70,7 @@ class ThreadColor(Enum):
@attr.s(cmp=False, init=False)
class Thread(object):
class Thread:
"""Represents a Facebook thread."""
#: The unique identifier of the thread. Can be used a ``thread_id``. See :ref:`intro_threads` for more info

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._core import Enum
from . import _plan
@@ -183,7 +180,7 @@ class User(Thread):
@attr.s(cmp=False)
class ActiveStatus(object):
class ActiveStatus:
#: Whether the user is active now
active = attr.ib(None)
#: Timestamp when the user was last active

View File

@@ -1,6 +1,3 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import re
import json
from time import time
@@ -8,6 +5,7 @@ from random import random
from contextlib import contextmanager
from mimetypes import guess_type
from os.path import basename
from urllib.parse import parse_qs, urlparse
import warnings
import logging
import requests
@@ -19,22 +17,6 @@ from ._exception import (
FBchatPleaseRefresh,
)
try:
from urllib.parse import urlencode, parse_qs, urlparse
basestring = (str, bytes)
except ImportError:
from urllib import urlencode
from urlparse import parse_qs, urlparse
basestring = basestring
# Python 2's `input` executes the input, whereas `raw_input` just returns the input
try:
input = raw_input
except NameError:
pass
# Log settings
log = logging.getLogger("client")
log.setLevel(logging.DEBUG)

View File

@@ -1,11 +1,9 @@
# -*- coding: UTF-8 -*-
"""This file is here to maintain backwards compatability, and to re-export our models
into the global module (see `__init__.py`).
A common pattern was to use `from fbchat.models import *`, hence we need this while
transitioning to a better code structure.
"""
from __future__ import unicode_literals
from ._core import Enum
from ._exception import FBchatException, FBchatFacebookError, FBchatUserError

View File

@@ -27,12 +27,12 @@ classifiers = [
"Operating System :: OS Independent",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Communications :: Chat",
@@ -41,7 +41,7 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4.0"
requires-python = ">=3.5, <4.0"
keywords = "Facebook FB Messenger Library Chat Api Bot"
license = "BSD 3-Clause"
@@ -52,7 +52,6 @@ Repository = "https://github.com/carpedm20/fbchat/"
[tool.flit.metadata.requires-extra]
test = [
"pytest~=4.0",
"six~=1.0",
]
docs = [
"sphinx~=2.0",

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
import json

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
import py_compile

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from os import path

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from fbchat.models import Message, MessageReaction

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from fbchat.models import Plan, FBchatFacebookError, ThreadType

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from fbchat.models import Poll, PollOption, ThreadType

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from fbchat.models import ThreadType

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from os import path

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytest
from fbchat.models import (

View File

@@ -1,16 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import threading
import logging
import six
import pytest
from os import environ
from random import randrange
from contextlib import contextmanager
from six import viewitems
from fbchat import Client
from fbchat.models import ThreadType, EmojiSize, FBchatFacebookError, Sticker
@@ -63,13 +57,7 @@ class ClientThread(threading.Thread):
self.client.stopListening()
if six.PY2:
event_class = threading._Event
else:
event_class = threading.Event
class CaughtValue(event_class):
class CaughtValue(threading.Event):
def set(self, res):
self.res = res
super(CaughtValue, self).set()
@@ -85,7 +73,7 @@ def random_hex(length=20):
def subset(a, **b):
print(a)
print(b)
return viewitems(b) <= viewitems(a)
return b.items() <= a.items()
def load_variable(name, cache):