99from bioblend import toolshed
1010
1111DEFAULT_TOOL_SHED_URL = 'https://toolshed.g2.bx.psu.edu'
12+ FOUND_NEWER_MESSAGE = "Found newer revision of {owner}/{name} ({rev})"
13+ FETCHING_UPDATE_MESSAGE = "Fetching updates for {owner}/{name}"
14+ INIT_LOCKFILE_MESSAGE = "Lockfile doesn't exist yet, starting with source as base."
15+ NON_DEFAULT_TS_MESSAGE = 'Non-default Tool Shed URL for %s/%s: %s'
1216
1317
1418class ToolSheds (defaultdict ):
@@ -25,7 +29,7 @@ def __missing__(self, key):
2529def update_file (fn , owner = None , name = None , without = False ):
2630 locked_in_path = fn + ".lock"
2731 if not os .path .exists (locked_in_path ):
28- logging .info ("Lockfile doesn't exist yet, starting with source as base." )
32+ logging .info (INIT_LOCKFILE_MESSAGE )
2933 locked_in_path = fn
3034
3135 with open (locked_in_path , 'r' ) as handle :
@@ -48,10 +52,10 @@ def update_file(fn, owner=None, name=None, without=False):
4852
4953 ts_url = tool .get ('tool_shed_url' , DEFAULT_TOOL_SHED_URL )
5054 if ts_url != DEFAULT_TOOL_SHED_URL :
51- logging .warning ('Non-default Tool Shed URL for %s/%s: %s' , tool ['owner' ], tool ['name' ], ts_url )
55+ logging .warning (NON_DEFAULT_TS_MESSAGE , tool ['owner' ], tool ['name' ], ts_url )
5256 ts = tool_sheds [ts_url ]
5357
54- logging .info ("Fetching updates for {owner}/{name}" .format (** tool ))
58+ logging .info (FETCHING_UPDATE_MESSAGE .format (** tool ))
5559
5660 try :
5761 revs = ts .repositories .get_ordered_installable_revisions (tool ['name' ], tool ['owner' ])
@@ -65,7 +69,7 @@ def update_file(fn, owner=None, name=None, without=False):
6569 # The rev is already known, don't add again.
6670 continue
6771
68- logging .info ("Found newer revision of {owner}/{name} ({rev})" .format (rev = latest_rev , ** tool ))
72+ logging .info (FOUND_NEWER_MESSAGE .format (rev = latest_rev , ** tool ))
6973
7074 # Get latest rev, if not already added, add it.
7175 if 'revisions' not in tool :
@@ -81,11 +85,28 @@ def update_file(fn, owner=None, name=None, without=False):
8185
8286def main ():
8387 parser = argparse .ArgumentParser ()
84- parser .add_argument ('fn' , type = argparse .FileType ('r' ), help = "Tool.yaml file" )
85- parser .add_argument ('--owner' , action = 'append' , help = "Repository owner to filter on, anything matching this will be updated. Can be specified multiple times" )
86- parser .add_argument ('--name' , help = "Repository name to filter on, anything matching this will be updated" )
87- parser .add_argument ('--without' , action = 'store_true' , help = "If supplied will ignore any owner/name and just automatically add the latest hash for anything lacking one." )
88- parser .add_argument ('--log' , choices = ('critical' , 'error' , 'warning' , 'info' , 'debug' ), default = 'info' )
88+ parser .add_argument (
89+ 'fn' , type = argparse .FileType ('r' ), help = "Tool.yaml file"
90+ )
91+ parser .add_argument (
92+ '--owner' ,
93+ action = 'append' ,
94+ help = "Repository owner to filter on, anything matching this will be updated. Can be specified multiple times"
95+ )
96+ parser .add_argument (
97+ '--name' ,
98+ help = "Repository name to filter on, anything matching this will be updated"
99+ )
100+ parser .add_argument (
101+ '--without' ,
102+ action = 'store_true' ,
103+ help = "If supplied will ignore any owner/name and just automatically add the latest hash for anything lacking one."
104+ )
105+ parser .add_argument (
106+ '--log' ,
107+ choices = ('critical' , 'error' , 'warning' , 'info' , 'debug' ),
108+ default = 'info'
109+ )
89110 args = parser .parse_args ()
90111 logging .basicConfig (level = getattr (logging , args .log .upper ()))
91112 update_file (args .fn .name , owner = args .owner , name = args .name , without = args .without )
0 commit comments