Format code to PEP8 standards
This commit is contained in:
@ -50,6 +50,7 @@ from clutch.core import Client
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
|
|
||||||
|
|
||||||
def open_config_file():
|
def open_config_file():
|
||||||
"""Reads configuration from config.json file"""
|
"""Reads configuration from config.json file"""
|
||||||
|
|
||||||
@ -91,10 +92,15 @@ def filter_updatable_torrents():
|
|||||||
|
|
||||||
for torrent, data in list(torrents.items()):
|
for torrent, data in list(torrents.items()):
|
||||||
keys_to_check = {'local-version', 'remote-version', 'transmission-id'}
|
keys_to_check = {'local-version', 'remote-version', 'transmission-id'}
|
||||||
if not ( keys_to_check.issubset(data.keys())
|
if not (
|
||||||
and data['local-version'] < data['remote-version']):
|
keys_to_check.issubset(data.keys())
|
||||||
|
and
|
||||||
|
data['local-version'] < data['remote-version']
|
||||||
|
):
|
||||||
del torrents[torrent]
|
del torrents[torrent]
|
||||||
logging.info('The following torrents can be updated: %s', pformat(torrents))
|
logging.info(
|
||||||
|
'The following torrents can be updated: %s', pformat(torrents)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def prompt_for_update():
|
def prompt_for_update():
|
||||||
@ -173,10 +179,16 @@ def update_torrents():
|
|||||||
"""
|
"""
|
||||||
logging.info('Updating torrents')
|
logging.info('Updating torrents')
|
||||||
for torrent in torrents.values():
|
for torrent in torrents.values():
|
||||||
old_name = os.path.join(config['mame-directory'], torrent['local-name'])
|
old_name = os.path.join(
|
||||||
new_name = os.path.join(config['mame-directory'], torrent['remote-name'])
|
config['mame-directory'],
|
||||||
|
torrent['local-name']
|
||||||
|
)
|
||||||
|
new_name = os.path.join(
|
||||||
|
config['mame-directory'],
|
||||||
|
torrent['remote-name']
|
||||||
|
)
|
||||||
|
|
||||||
client.torrent.remove(torrent['transmission-id']);
|
client.torrent.remove(torrent['transmission-id'])
|
||||||
os.rename(old_name, new_name)
|
os.rename(old_name, new_name)
|
||||||
client.torrent.add(
|
client.torrent.add(
|
||||||
filename=torrent['remote-link'],
|
filename=torrent['remote-link'],
|
||||||
@ -198,7 +210,7 @@ if __name__ == '__main__':
|
|||||||
print('{}\r'.format(i), end=''),
|
print('{}\r'.format(i), end=''),
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
re_mame_version = re.compile('MAME 0.(\d+) (.*)')
|
re_mame_version = re.compile(r'MAME 0.(\d+) (.*)')
|
||||||
config = open_config_file()
|
config = open_config_file()
|
||||||
torrents = defaultdict(dict)
|
torrents = defaultdict(dict)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user