Refactoring di determinato codice, vediamo se potrebbe funzionare.
This commit is contained in:
parent
5ce7f5cc07
commit
c88e10b2ac
2 changed files with 20 additions and 51 deletions
|
@ -2,7 +2,6 @@
|
|||
# encoding: utf-8
|
||||
|
||||
import click
|
||||
import yaml
|
||||
import loaih
|
||||
|
||||
@click.command()
|
||||
|
@ -21,56 +20,27 @@ def build(arch, language, offline, portable, updatable, download_path, repo_path
|
|||
arches = []
|
||||
if arch.lower() == 'all':
|
||||
# We need to build it twice.
|
||||
arches = [ 'x86', 'x86_64' ]
|
||||
arches = [ u'x86', u'x86_64' ]
|
||||
else:
|
||||
arches = [ arch.lower().decode('utf-8') ]
|
||||
arches = [ arch.lower() ]
|
||||
|
||||
if query.endswith('.yml') or query.endswith('.yaml'):
|
||||
# This is a buildfile. So we have to load the file and pass the build options ourselves.
|
||||
config = {}
|
||||
with open(query, 'r') as file:
|
||||
config = yaml.safe_load(file)
|
||||
obj = loaih.Build(query, arches)
|
||||
|
||||
# With the config file, we ignore all the command line options and set
|
||||
# generic default.
|
||||
for build in config['builds']:
|
||||
# Loop a run for each build.
|
||||
obj = loaih.Build(build['query'], arches)
|
||||
|
||||
obj.language = build['language']
|
||||
obj.offline_help = build['offline_help']
|
||||
obj.portable = build['portable']
|
||||
obj.updatable = True
|
||||
|
||||
if check:
|
||||
obj.check(config['data']['storage'])
|
||||
else:
|
||||
obj.storage_path = config['data']['storage']
|
||||
|
||||
obj.download(config['data']['download'])
|
||||
obj.build()
|
||||
obj.checksums()
|
||||
obj.publish()
|
||||
del obj
|
||||
obj.language = language
|
||||
obj.offline_help = offline
|
||||
obj.portable = portable
|
||||
obj.updatable = updatable
|
||||
|
||||
if check:
|
||||
obj.check(repo_path)
|
||||
else:
|
||||
obj = loaih.Build(query, arches)
|
||||
obj.storage_path = repo_path
|
||||
|
||||
obj.language = language
|
||||
obj.offline_help = offline
|
||||
obj.portable = portable
|
||||
obj.updatable = updatable
|
||||
|
||||
if check:
|
||||
obj.check(repo_path)
|
||||
else:
|
||||
obj.storage_path = repo_path
|
||||
|
||||
obj.download(download_path)
|
||||
obj.build()
|
||||
obj.checksums()
|
||||
obj.publish()
|
||||
del obj
|
||||
obj.download(download_path)
|
||||
obj.build()
|
||||
obj.checksums()
|
||||
obj.publish()
|
||||
del obj
|
||||
|
||||
if __name__ == '__main__':
|
||||
build()
|
||||
|
|
Reference in a new issue