synchronization
This commit is contained in:
parent
47120adeb5
commit
4397a20bfd
4 changed files with 33 additions and 17 deletions
24
__init__.py
24
__init__.py
|
@ -3,12 +3,11 @@
|
|||
import sys
|
||||
|
||||
import arguments
|
||||
import remote
|
||||
import repository
|
||||
import synchronization
|
||||
|
||||
|
||||
def build(repository, arguments):
|
||||
print('Build:')
|
||||
def build(args):
|
||||
# TODO identify
|
||||
print('TODO identify')
|
||||
# TODO extract
|
||||
|
@ -19,8 +18,7 @@ def build(repository, arguments):
|
|||
print('TODO archive')
|
||||
|
||||
|
||||
def check(repository, arguments):
|
||||
print('Check:')
|
||||
def check(args):
|
||||
# TODO prepare threads
|
||||
print('TODO prepare threads')
|
||||
# TODO run threads
|
||||
|
@ -29,14 +27,13 @@ def check(repository, arguments):
|
|||
print('TODO watch threads')
|
||||
|
||||
|
||||
def info(repository, arguments):
|
||||
print(repository)
|
||||
def info(args):
|
||||
print(repository.Repository(args))
|
||||
|
||||
|
||||
def sync(repository, args):
|
||||
print('Sync:')
|
||||
r = remote.Remote(args)
|
||||
print(r)
|
||||
def sync(args):
|
||||
sync = synchronization.Synchronization(args)
|
||||
print(sync)
|
||||
# TODO prepare temporary directory
|
||||
print('prepare…')
|
||||
# TODO fetch
|
||||
|
@ -49,9 +46,8 @@ def sync(repository, args):
|
|||
|
||||
def main():
|
||||
args = arguments.parse()
|
||||
repo = repository.Repository(args)
|
||||
func = getattr(sys.modules[__name__], args[arguments.ACTION])
|
||||
func(repo, args)
|
||||
function = getattr(sys.modules[__name__], args[arguments.ACTION])
|
||||
function(args)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -16,11 +16,12 @@ SUBSYSTEMS = ['msys', 'mingw']
|
|||
class Remote:
|
||||
def __init__(self, args):
|
||||
self.location = args[arguments.REMOTE]
|
||||
self.architectures = args[arguments.ARCHITECTURES]
|
||||
self.load()
|
||||
|
||||
def load(self):
|
||||
d = {}
|
||||
for architecture in ARCHITECTURES:
|
||||
for architecture in self.architectures:
|
||||
url = os.path.join(self.location, DISTRIBUTION, architecture)
|
||||
html = requests.get(url).content.decode(CHARSET)
|
||||
links = sorted(hypertext.get_links(html))
|
||||
|
|
|
@ -26,7 +26,7 @@ class Repository:
|
|||
d[architecture] = archive
|
||||
self.archives = d
|
||||
|
||||
def get_temporary():
|
||||
def get_temporary(self):
|
||||
return os.path.join(self.temporary,
|
||||
datetime.datetime.now()
|
||||
.strftime('%Y%m%d%H%M%S'))
|
||||
|
@ -35,7 +35,7 @@ class Repository:
|
|||
lines = [
|
||||
f'Directory: {self.directory}',
|
||||
f' → {os.path.realpath(self.directory)}',
|
||||
f'Archives:',
|
||||
'Archives:',
|
||||
]
|
||||
for architecture, archive in reversed(sorted(self.archives.items())):
|
||||
lines.append(f'{architecture} → {archive}')
|
||||
|
|
19
synchronization.py
Normal file
19
synchronization.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import os
|
||||
|
||||
import remote
|
||||
import repository
|
||||
|
||||
|
||||
class Synchronization:
|
||||
def __init__(self, args):
|
||||
self.remote = remote.Remote(args)
|
||||
self.repository = repository.Repository(args)
|
||||
self.temporary = self.repository.get_temporary()
|
||||
|
||||
def __str__(self):
|
||||
lines = [
|
||||
str(self.remote), str(),
|
||||
str(self.repository), str(),
|
||||
f'Temporary: {self.temporary}',
|
||||
]
|
||||
return os.linesep.join(lines)
|
Loading…
Reference in a new issue