diff --git a/fb2cal/__main__.py b/fb2cal/__main__.py index 3cdbd24..4e1409b 100644 --- a/fb2cal/__main__.py +++ b/fb2cal/__main__.py @@ -27,14 +27,14 @@ from .facebook_browser import FacebookBrowser from .transformer import Transformer -from .__init__ import __version__, __status__, __website__, __license__ +from .__init__ import __version__, __status__, __github_short_url__, __license__ # Set CWD to script directory os.chdir(sys.path[0]) # Init logger logger = Logger('fb2cal').getLogger() -logger.info(f'Starting fb2cal v{__version__} ({__status__}) [{__website__}]') +logger.info(f'Starting fb2cal v{__version__} ({__status__}) [{__github_short_url__}]') logger.info(f'This project is released under the {__license__} license.') try: diff --git a/fb2cal/__meta__.py b/fb2cal/__meta__.py index ec0fd18..f776827 100644 --- a/fb2cal/__meta__.py +++ b/fb2cal/__meta__.py @@ -10,8 +10,11 @@ __version_info__ = (1, 3, 0) __version__ = '.'.join(map(str, __version_info__)) -__website__ = 'https://git.io/fjMwr' +__github_url__ = 'https://github.com/mobeigi/fb2cal' +__github_short_url__ = 'https://git.io/fjMwr' +__github_assets_absolute_url__ = 'https://raw.githubusercontent.com/mobeigi/fb2cal/master' __download_url__= f'https://github.com/mobeigi/fb2cal/archive/v{__version__}.tar.gz' + # Make metadata public to script -__all__ = ['__author__', '__copyright__', '__description__', '__email__', '__license__', '__maintainer__', '__status__', '__title__', '__version_info__', '__version__', '__website__', '__download_url__'] +__all__ = ['__author__', '__copyright__', '__description__', '__email__', '__license__', '__maintainer__', '__status__', '__title__', '__version_info__', '__version__', '__github_url__', '__github_short_url__', '__github_assets_absolute_url__', '__download_url__'] diff --git a/fb2cal/ics_writer.py b/fb2cal/ics_writer.py index e9aafe4..f57ec65 100644 --- a/fb2cal/ics_writer.py +++ b/fb2cal/ics_writer.py @@ -7,7 +7,7 @@ from .logger import Logger from .utils import generate_facebook_profile_url_permalink -from .__init__ import __version__, __status__, __website__ +from .__init__ import __version__, __status__, __github_short_url__ """ Write Birthdays to an ICS file """ class ICSWriter: @@ -20,7 +20,7 @@ def generate(self): c = Calendar() c.scale = 'GREGORIAN' c.method = 'PUBLISH' - c.creator = f'fb2cal v{__version__} ({__status__}) [{__website__}]' + c.creator = f'fb2cal v{__version__} ({__status__}) [{__github_short_url__}]' c.extra.append(ContentLine(name='X-WR-CALNAME', value='Facebook Birthdays (fb2cal)')) c.extra.append(ContentLine(name='X-PUBLISHED-TTL', value='PT12H')) c.extra.append(ContentLine(name='X-ORIGINAL-URL', value='/events/birthdays/')) diff --git a/setup.py b/setup.py index d1ef9f6..708b028 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,23 @@ +from os import path +import re from setuptools import setup, find_packages -from fb2cal.__meta__ import __title__, __version__, __description__, __license__, __author__, __email__, __website__, __download_url__, __keywords__ + +from fb2cal.__meta__ import __title__, __version__, __description__, __license__, __author__, __email__, __github_url__, __github_short_url__, __github_assets_absolute_url__, __download_url__, __keywords__ + +def read(fname, base_url, base_image_url): + """Read the content of a file.""" + with open(path.join(path.dirname(__file__), fname)) as fd: + readme = fd.read() + if hasattr(readme, 'decode'): + # In Python 3, turn bytes into str. + readme = readme.decode('utf8') + # turn relative links into absolute ones + readme = re.sub(r'`<([^>]*)>`__', + r'`\1 <' + base_url + r"/blob/master/\1>`__", + readme) + readme = re.sub(r"\.\. image:: /", ".. image:: " + base_image_url + "/", readme) + + return readme setup( name=__title__, @@ -9,7 +27,7 @@ license=__license__, author=__author__, author_email=__email__, - url=__website__, + url=__github_short_url__, download_url=__download_url__, keywords=__keywords__, python_requires='>3.9', @@ -19,6 +37,8 @@ 'requests', 'freezegun', ], + long_description=read('README.md', __github_url__, __github_assets_absolute_url__), + long_description_content_type='text/markdown', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Other Audience',