Prepare for publishing in PyPi

This commit is contained in:
KnugiHK
2021-05-10 15:51:30 +08:00
parent 3ee40ecda4
commit 322281a8ec
7 changed files with 216 additions and 161 deletions

View File

@@ -0,0 +1 @@
__version__ = "0.5"

View File

@@ -7,6 +7,7 @@ import os
import requests import requests
import shutil import shutil
import re import re
import pkgutil
from datetime import datetime from datetime import datetime
from mimetypes import MimeTypes from mimetypes import MimeTypes
@@ -254,7 +255,7 @@ def vcard(db, data):
def create_html(data, output_folder): def create_html(data, output_folder):
templateLoader = jinja2.FileSystemLoader(searchpath="./") templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__))
templateEnv = jinja2.Environment(loader=templateLoader) templateEnv = jinja2.Environment(loader=templateLoader)
templateEnv.globals.update(determine_day=determine_day) templateEnv.globals.update(determine_day=determine_day)
TEMPLATE_FILE = "whatsapp.html" TEMPLATE_FILE = "whatsapp.html"

View File

@@ -6,6 +6,7 @@ import jinja2
import os import os
import requests import requests
import shutil import shutil
import pkgutil
from datetime import datetime from datetime import datetime
from mimetypes import MimeTypes from mimetypes import MimeTypes
@@ -206,7 +207,7 @@ def vcard(db, data):
def create_html(data, output_folder): def create_html(data, output_folder):
templateLoader = jinja2.FileSystemLoader(searchpath="./") templateLoader = jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__))
templateEnv = jinja2.Environment(loader=templateLoader) templateEnv = jinja2.Environment(loader=templateLoader)
templateEnv.globals.update(determine_day=determine_day) templateEnv.globals.update(determine_day=determine_day)
TEMPLATE_FILE = "whatsapp.html" TEMPLATE_FILE = "whatsapp.html"

View File

@@ -73,11 +73,17 @@ def extract_media(base_dir):
if not support_encrypted: if not support_encrypted:
print("You don't have the dependencies to handle encrypted backup.") print("You don't have the dependencies to handle encrypted backup.")
print("Read more about how to deal with encrypted backup:") print("Read more about how to deal with encrypted backup:")
print("https://github.com/KnugiHK/Whatsapp-Chat-Exporter/blob/main/README.md#encrypted-iphone-backup") print("https://github.com/KnugiHK/Whatsapp-Chat-Exporter/blob/main/README.md#usage")
return False return False
password = getpass.getpass("Enter the password:") password = getpass.getpass("Enter the password:")
extract_encrypted(base_dir, password) extract_encrypted(base_dir, password)
else: else:
wts_db = os.path.join(base_dir, "7c/7c7fba66680ef796b916b067077cc246adacf01d")
if not os.path.isfile(wts_db):
print("WhatsApp database not found.")
sys.exit(1)
else:
shutil.copyfile(wts_db, "7c7fba66680ef796b916b067077cc246adacf01d")
with sqlite3.connect(f"{base_dir}/Manifest.db") as manifest: with sqlite3.connect(f"{base_dir}/Manifest.db") as manifest:
c = manifest.cursor() c = manifest.cursor()
c.execute("""SELECT count() c.execute("""SELECT count()

BIN
group.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

46
setup.py Normal file
View File

@@ -0,0 +1,46 @@
import setuptools
from re import search
with open("README.md", "r") as fh:
long_description = fh.read()
with open("Whatsapp_Chat_Exporter/__init__.py", encoding="utf8") as f:
version = search(r'__version__ = "(.*?)"', f.read()).group(1)
setuptools.setup(
name="whatsapp-chat-exporter",
version=version,
author="KnugiHK",
author_email="info@knugi.com",
description="A Whatsapp database parser that will give you the history of your Whatsapp conversations in HTML and JSON.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/KnugiHK/Whatsapp-Chat-Exporter",
packages=setuptools.find_packages(),
package_data = {
'': ['whatsapp.html']
},
classifiers=[
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: Beta",
"Environment :: Console",
"Intended Audience :: End Users/Desktop"
"Topic :: Communications :: Chat",
"Topic :: Utilities",
"Topic :: Database"
],
python_requires='>=3.7',
install_requires=[
'jinja2'
],
entry_points={
"console_scripts": [
"wtsexporter = Whatsapp_Chat_Exporter.__main__:main"
]
}
)