hypertext,msys
This commit is contained in:
parent
c79ec30078
commit
4a106b9c7d
4 changed files with 19 additions and 12 deletions
20
hypertext.py
20
hypertext.py
|
@ -1,7 +1,7 @@
|
|||
import html.parser
|
||||
import requests
|
||||
|
||||
CHARSET = 'u8'
|
||||
import msys
|
||||
|
||||
|
||||
class Parser(html.parser.HTMLParser):
|
||||
|
@ -15,8 +15,16 @@ class Parser(html.parser.HTMLParser):
|
|||
[v for k, v in attributes if k == 'href'])
|
||||
|
||||
|
||||
def get_links(location):
|
||||
hypertext = requests.get(location).content.decode(CHARSET)
|
||||
parser = Parser()
|
||||
parser.feed(hypertext)
|
||||
return parser.links
|
||||
class HyperText:
|
||||
def __init__(self, location):
|
||||
self.location = location
|
||||
self.load()
|
||||
|
||||
def load(self):
|
||||
hypertext = requests.get(self.location).content.decode(msys.CHARSET)
|
||||
parser = Parser()
|
||||
parser.feed(hypertext)
|
||||
self.links = parser.links
|
||||
self.archives = [link for link in self.links
|
||||
if link.endswith(msys.ARCHIVE)]
|
||||
self.archive = sorted(self.archives)[-1]
|
||||
|
|
2
msys.py
Normal file
2
msys.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
ARCHIVE = '.tar.xz'
|
||||
CHARSET = 'u8'
|
|
@ -6,7 +6,6 @@ import catalog
|
|||
import hypertext
|
||||
|
||||
|
||||
ARCHIVE = '.tar.xz'
|
||||
ARCHITECTURES = ['x86_64', 'i686']
|
||||
ARCHITECTURES_BITS = {
|
||||
'x86_64': 64,
|
||||
|
@ -36,10 +35,7 @@ class Remote:
|
|||
c = {}
|
||||
for architecture in self.architectures:
|
||||
location = os.path.join(self.location, DISTRIBUTION, architecture)
|
||||
links = sorted(hypertext.get_links(location))
|
||||
archives = [link for link in links
|
||||
if link.endswith(ARCHIVE)]
|
||||
archive = archives[-1]
|
||||
archive = hypertext.HyperText(location).archive
|
||||
a[architecture] = archive
|
||||
#
|
||||
c[architecture] = {}
|
||||
|
|
|
@ -2,6 +2,7 @@ import arguments
|
|||
import datetime
|
||||
import os
|
||||
|
||||
import msys
|
||||
import remote
|
||||
|
||||
|
||||
|
@ -21,7 +22,7 @@ class Repository:
|
|||
directory = os.path.join(distribution, architecture)
|
||||
_, _, files = next(os.walk(directory))
|
||||
archives = sorted([file for file in files
|
||||
if file.endswith(remote.ARCHIVE)])
|
||||
if file.endswith(msys.ARCHIVE)])
|
||||
archive = archives[-1]
|
||||
d[architecture] = archive
|
||||
self.archives = d
|
||||
|
|
Loading…
Reference in a new issue