Skip to content

Commit

Permalink
Apple MacOS version added
Browse files Browse the repository at this point in the history
  • Loading branch information
twkrol committed Oct 23, 2020
1 parent 0e8d944 commit b8d7f52
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 48 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ requests = "==2.20.0"
six = "==1.11.0"
urllib3 = ">=1.24.2"
webencodings = "==0.5.1"
unidecode = "*"

[dev-packages]
pylint = "*"
Expand Down
106 changes: 61 additions & 45 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions clients/macos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
# Copyright (c) Tomasz Krol [email protected]
"""
Module to grab actual editions & versions of MacOS
"""
from copy import copy
import urllib.request
import re
from datetime import datetime, date
from bs4 import BeautifulSoup
from unidecode import unidecode

product = "Apple Mac"

def getEditions(template):
result = []

template.product = product
template.released = date.min
template.ends = date.max
template.stable = True
template.latest = False
maxver = None

# Looking for releases, source at https://docs.microsoft.com/en-us/windows/windows-10/release-information
body = urllib.request.urlopen("https://support.apple.com/pl-pl/HT201260").read()
soup = BeautifulSoup(body, "html5lib")
table = soup.find('div',{"id":"tableWraper"}).find_next('table')
rows = table.find_all('tr')[1:]

for index, row in enumerate(rows, start=0): # Python indexes start at zero

# copy of Softver object
item = copy(template) # copy of Softver object

# find elements to parse
cols = row.find_all('td')

# find product name
# item.edition = cols[0].get_text().strip().replace('\u00a0', ' ')
item.edition = unidecode(cols[0].get_text().strip())

# find version
item.version = cols[1].get_text().strip()

# mark the latest version
if maxver is None:
maxver = item.version
item.latest = True

result.append(item)
return result

# if __name__ == "__main__":
# print(getEditions(Softver()))
6 changes: 3 additions & 3 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from datetime import datetime, date
import vergrabber

__version__ = '3.4.3'
__version__ = '3.5.0'
__author__ = 'Tomasz Krol'
__author_email__ = '[email protected]'

debug = False
debug_module = None
# debug = True
# debug_module = 'windows'
# debug_module = 'macos'

def dumper(obj):
if isinstance(obj, date) or isinstance(obj, datetime):
Expand Down Expand Up @@ -53,7 +53,7 @@ def applyLatest(result, branch, vergrabber):
if __name__ == "__main__":

print("Vergrabber, a software version grabber", __version__)
print("(C) 2017-2019 by", __author__, __author_email__, "\n")
print("(C) 2017-2020 by", __author__, __author_email__, "\n")
started = datetime.now()
print("* STARTED @ %s" % started)
print("- loading configuration from config.yaml")
Expand Down

0 comments on commit b8d7f52

Please sign in to comment.