Commit fc6e04cd authored by onny's avatar onny
Browse files

add AUR package support

parent bbfcc019
import requests
from bs4 import BeautifulSoup
import re
import decimal
from progressbar import AnimatedMarker, Bar, BouncingBar, Counter, ETA, \
FileTransferSpeed, FormatLabel, Percentage, \
ProgressBar, ReverseBar, RotatingMarker, \
SimpleProgress, Timer, AdaptiveETA, AbsoluteETA, AdaptiveTransferSpeed
widgets = ['', Percentage(), ' ', SimpleProgress(format='(%(value)d of %(max_value)d)'), ' ', Bar(), ' ', Timer(), ' ', AdaptiveETA()]
class AUR:
def __init__(self):
self.start=0
self.page=0
self.page_total=0
self.perpage="250"
self.aur_packages = []
self.response_all_tr = ['']
def get_page_count(self):
webpath="https://aur.archlinux.org/packages/?O=" + str(self.start) + "&C=0&SeB=nd&SB=n&SO=a&PP=" + self.perpage + "&do_Search=Go"
response = requests.get(webpath)
self.page_total = re.search(r'(\d+) packages found',response.text).group(1)
page_total_decimal = decimal.Decimal(int(self.page_total) / 250)
self.page_total = round(page_total_decimal,0)
def scrape_packages(self):
self.get_page_count()
widgets[0] = 'Scraping AUR packages : '
bar = ProgressBar(widgets=widgets, max_value=self.page_total)
for self.page in range(0, int(self.page_total)):
webpath="https://aur.archlinux.org/packages/?O=" + str(self.start) + "&C=0&SeB=nd&SB=n&SO=a&PP=" + self.perpage + "&do_Search=Go"
response = requests.get(webpath)
response_soup = BeautifulSoup(response.text, "lxml")
response_table = response_soup.find("table", {"class" : "results"})
response_tbody = response_table.find('tbody')
response_all_tr = response_tbody.findAll("tr")
for response_row in response_all_tr:
package = {}
package['name'] = response_row.findAll("td")[0].text
package['version'] = response_row.findAll("td")[1].text
package['version'] = package['version'].split('-')[0]
self.aur_packages.append(package)
self.start += 250
bar.update(self.page)
bar.update(self.page_total)
print("")
return self.aur_packages
......@@ -7,6 +7,7 @@ from lib.download import Download
from lib.database import Database
from lib.versioncheck import Versioncheck
from lib.template import Template
from lib.aur import AUR
PATH = os.path.dirname(os.path.abspath(__file__))
......@@ -20,10 +21,14 @@ def load_config(config):
if __name__ == '__main__':
config = load_config('config/config.json')
package_database = Download(config).get_databases()
packages = Database(package_database, config).load_database()
packages = packages[0:50]
aur_packages = AUR().scrape_packages()
packages = packages + aur_packages
packages_notlisted, packages_outdated, packages_uptodate = Versioncheck(packages).compare_upstream()
packages_outdated = Versioncheck(packages).get_repository_status(packages_outdated)
Template(PATH, packages_notlisted, packages_outdated, packages_uptodate).write()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment