-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
127 additions
and
128 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,6 +1,6 @@ | ||
""" | ||
This program will allow you to be notified of Github new releases | ||
""" | ||
from .parser import * | ||
from .webhook import * | ||
from .notifier import * | ||
|
||
__all__ = ['parser', 'webhook', 'notifier'] | ||
__version__ = '0.2.3' |
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
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,41 +1,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# coding: utf-8 | ||
|
||
import sys, feedparser, re, requests | ||
import feedparser | ||
import re | ||
import requests | ||
from typing import List | ||
|
||
__all__ = ['parse', 'get_package'] | ||
|
||
|
||
def parse(package): | ||
def parse(package: str) -> List[dict]: | ||
package_name = get_package(package) | ||
url = 'https://github.com/%s/releases.atom' % package_name | ||
feed = feedparser.parse(url) | ||
entries = [] | ||
for item in feed['entries']: | ||
entries.append({ | ||
"author": item['authors'][0]['name'] if 'authors' in item and item['authors'] and item['authors'][0] and item['authors'][0]['name'] else None, | ||
current_dict = { | ||
'author': None, | ||
"content": None, | ||
"media": None, | ||
"date": item['updated_parsed'], | ||
"title": item['title_detail']['value'], | ||
"content": item['content'][0]['value'] if 'content' in item and item['content'] and item['content'][0] and item['content'][0]['value'] else None, | ||
"version": re.search('(?<=Repository/)[0-9]+/(.+)', item['id']).group(1), | ||
"media": item['media_thumbnail'][0]['url'] if 'media_thumbnail' in item and item['media_thumbnail'] and item['media_thumbnail'][0] and item['media_thumbnail'][0]['url'] else None, | ||
"package_name": package_name, | ||
}) | ||
} | ||
if 'authors' in item and item['authors'].get(0) is not None and 'name' in item['authors'][0]: | ||
current_dict['author'] = item['authors'][0]['name'] | ||
if 'content' in item and item['content'].get(0) is not None and 'value' in item['content'][0]: | ||
current_dict['content'] = item['content'][0]['value'] | ||
if ( | ||
'media_thumbnail' in item and | ||
item['media_thumbnail'].get(0) is not None | ||
and 'url' in item['media_thumbnail'][0] | ||
): | ||
current_dict['media'] = item['media_thumbnail'][0]['url'] | ||
entries.append(current_dict) | ||
return entries | ||
|
||
|
||
def get_package(entry): | ||
def get_package(entry: str) -> str: | ||
if 'github' in entry: | ||
entry = re.search('(?<=github.com/)[^/]+/[^/]+', entry).group(0) | ||
request = requests.get('https://github.com/%s/tags.atom' % entry) | ||
if request.status_code != 200: | ||
raise NameError('%s is not a valid github url/package' % entry) | ||
return entry | ||
|
||
|
||
def main(): | ||
print(parse(sys.argv[1])) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,33 @@ | ||
[metadata] | ||
name = github_release_notifier | ||
version = attr: github_release_notifier.__version__ | ||
description = Get notified when a specific package got a new release on Github | ||
long_description = file: README.rst | ||
author = Jay MOULIN | ||
author_email = [email protected] | ||
url = https://github.com/femtopixel/github-release-notifier/ | ||
license = MIT | ||
classifiers = | ||
Development Status :: 5 - Production/Stable | ||
Programming Language :: Python | ||
License :: OSI Approved :: MIT License | ||
Natural Language :: English | ||
Operating System :: OS Independent | ||
Programming Language :: Python :: 3 | ||
Topic :: Communications | ||
Topic :: Internet | ||
Topic :: Software Development :: Pre-processors | ||
Intended Audience :: Developers | ||
Topic :: Software Development :: Build Tools | ||
|
||
[options] | ||
include_package_data = True | ||
packages = find: | ||
install_requires = | ||
feedparser | ||
requests | ||
python_requires = >=3 | ||
|
||
[options.entry_points] | ||
console_scripts = | ||
github-release-notifier = github_release_notifier.cli:main |
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,39 +1,5 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# coding: utf-8 | ||
|
||
from setuptools import setup, find_packages | ||
from setuptools import setup | ||
|
||
__version__ = '0.2.2' | ||
|
||
setup( | ||
name='github_release_notifier', | ||
python_requires=">=3", | ||
version=__version__, | ||
packages=find_packages(), | ||
author="Jay MOULIN", | ||
author_email="[email protected]", | ||
description="Github Notifier", | ||
long_description=open('README.rst').read(), | ||
install_requires=["feedparser", "requests"], | ||
include_package_data=True, | ||
url='http://github.com/femtopixel/github-release-notifier/', | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Programming Language :: Python", | ||
"License :: OSI Approved :: MIT License", | ||
"Natural Language :: English", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Communications", | ||
"Topic :: Internet", | ||
"Topic :: Software Development :: Pre-processors", | ||
"Intended Audience :: Developers", | ||
"Topic :: Software Development :: Build Tools", | ||
], | ||
entry_points={ | ||
'console_scripts': [ | ||
'github-release-notifier = github_release_notifier.cli:main', | ||
], | ||
}, | ||
license="MIT", | ||
) | ||
setup() |