-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from bellingcat/refactor
Refactor
- Loading branch information
Showing
27 changed files
with
671 additions
and
1,300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
# Data directory | ||
data/ | ||
build/ | ||
*.egg-info/ | ||
dist/ | ||
|
||
# Miscellaneous files | ||
**/.DS_Store | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[pytest] | ||
minversion = | ||
7.0.0 | ||
testpaths = | ||
tests/ | ||
python_files = | ||
*.py | ||
addopts = | ||
-vvv | ||
--cov='tiktok_hashtag_analysis' | ||
--cov-report html:reports/coverage | ||
--html='reports/tests.html' | ||
--self-contained-html | ||
filterwarnings = | ||
ignore:Glyph (.*) missing from current font |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
matplotlib | ||
seaborn | ||
seaborn==0.12.2 | ||
matplotlib==3.7.2 | ||
yt-dlp==2023.7.6 | ||
TikTokApi==6.1.1 | ||
requests==2.31.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,64 @@ | ||
from setuptools import setup, find_packages | ||
from tiktok_hashtag_analysis.version import __version__ | ||
from setuptools import setup | ||
|
||
|
||
def read_requirements(filename: str): | ||
with open(filename) as requirements_file: | ||
import re | ||
|
||
def fix_url_dependencies(req: str) -> str: | ||
"""Pip and setuptools disagree about how URL dependencies should be handled.""" | ||
m = re.match( | ||
r"^(git\+)?(https|ssh)://(git@)?github\.com/([\w-]+)/(?P<name>[\w-]+)\.git", | ||
req, | ||
) | ||
if m is None: | ||
return req | ||
else: | ||
return f"{m.group('name')} @ {req}" | ||
|
||
requirements = [] | ||
for line in requirements_file: | ||
line = line.strip() | ||
if line.startswith("#") or len(line) <= 0: | ||
continue | ||
requirements.append(fix_url_dependencies(line)) | ||
return requirements | ||
|
||
|
||
with open("README.md", "r", encoding="utf-8") as file: | ||
long_description = file.read() | ||
|
||
# version.py defines the VERSION and VERSION_SHORT variables. | ||
# We use exec here so we don't import cached_path whilst setting up. | ||
VERSION = {} # type: ignore | ||
with open("tiktok_hashtag_analysis/version.py", "r") as version_file: | ||
exec(version_file.read(), VERSION) | ||
|
||
setup( | ||
name="tiktok-hashtag-analysis", | ||
version=__version__, | ||
version=VERSION["VERSION"], | ||
author="Bellingcat", | ||
author_email="[email protected]", | ||
packages=["tiktok_hashtag_analysis"], | ||
package_data={ | ||
"tiktok_hashtag_analysis": [ | ||
"logging.config", | ||
] | ||
}, | ||
description="Analyze hashtags within posts scraped from TikTok", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/bellingcat/tiktok-hashtag-analysis", | ||
license="MIT License", | ||
install_requires=["seaborn", "matplotlib"], | ||
# install_requires=read_requirements("requirements.txt"), | ||
# extras_require={"dev": read_requirements("dev-requirements.txt")}, | ||
install_requires=["seaborn", "matplotlib", "TikTokApi", "requests", "yt_dlp"], | ||
extras_require={"test": ["pytest", "pytest-cov", "pytest-html", "pytest-metadata"]}, | ||
classifiers=[ | ||
'Development Status :: 5 - Production/Stable', | ||
'Intended Audience :: Information Technology', | ||
'License :: OSI Approved :: MIT License', | ||
'Natural Language :: English', | ||
'Programming Language :: Python :: 3' | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Information Technology", | ||
"License :: OSI Approved :: MIT License", | ||
"Natural Language :: English", | ||
"Programming Language :: Python :: 3", | ||
], | ||
entry_points={ | ||
"console_scripts": [ | ||
"tiktok-hashtag-analysis=tiktok_hashtag_analysis.__main__:main", | ||
"tiktok-hashtag-analysis=tiktok_hashtag_analysis.cli:main", | ||
] | ||
}, | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
|
||
from tiktok_hashtag_analysis.auth import Authorization | ||
|
||
MS_TOKEN = "thisisafakemstokenfortiktok" | ||
|
||
|
||
def test_auth_input(tmp_path, monkeypatch): | ||
config_file = tmp_path / ".tiktok" | ||
monkeypatch.setattr("builtins.input", lambda _: MS_TOKEN) | ||
auth = Authorization(config_file=config_file) | ||
auth.get_token() | ||
|
||
assert auth.ms_token == MS_TOKEN | ||
|
||
|
||
def test_auth(tmp_path): | ||
config_file = tmp_path / ".tiktok" | ||
auth = Authorization(config_file=config_file) | ||
|
||
auth.dump_token(ms_token=MS_TOKEN) | ||
auth.get_token() | ||
|
||
assert auth.ms_token == MS_TOKEN |
Oops, something went wrong.