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