Skip to content

Commit 689ae10

Browse files
committed
* Added GPFile.get_name()
* Added GPJob.get_file()
1 parent 4364414 commit 689ae10

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

gp.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
# Imports requiring compatibility between Python 2 and Python 3
2020
if sys.version_info.major == 2:
2121
import urllib2
22+
import urllib as parse
2223
elif sys.version_info.major == 3:
2324
from urllib import request as urllib2
25+
import urllib.parse as parse
2426

2527

2628
class GPServer(object):
@@ -247,6 +249,12 @@ def get_url(self):
247249
"""
248250
return self.uri
249251

252+
def get_name(self):
253+
"""
254+
Returns the file name of the output file
255+
"""
256+
return parse.unquote(self.get_url().split('/')[-1])
257+
250258

251259
class GPJob(GPResource):
252260
"""
@@ -440,6 +448,17 @@ def get_output_files(self):
440448
else:
441449
return []
442450

451+
def get_file(self, name):
452+
"""
453+
Returns the output file with the specified name, if no output files
454+
match, returns None.
455+
"""
456+
files = self.get_output_files()
457+
for f in files:
458+
if f.get_name() == name:
459+
return f
460+
return None
461+
443462
def wait_until_done(self):
444463
"""
445464
This method will not return until the job is either complete or has

0 commit comments

Comments
 (0)