1- import webbrowser
2- import requests
31import json
4- import ee
2+ import webbrowser
53
4+ import ee
5+ import requests
66from box import Box
77from bs4 import BeautifulSoup
88from ee_extra .Apps .core import apps as extra_apps
99
1010from .extending import extend
1111
12+
1213@extend (ee )
13- class App () :
14+ class App :
1415 """Google Earth Engine App Manager and Descriptor.
1516
1617 Inspect, open and download Google Earth Engine apps.
@@ -36,7 +37,9 @@ def __init__(self, url):
3637 if "users.earthengine.app" not in url :
3738 raise Exception ("Not a valid Earth Engine App! Check the url again!" )
3839 if "users.earthengine.app/view/" not in url :
39- raise Exception ("This seems to be an Earth Engine App Collection! Please use the url of an app!" )
40+ raise Exception (
41+ "This seems to be an Earth Engine App Collection! Please use the url of an app!"
42+ )
4043
4144 self .url = url
4245 """URL of the App."""
@@ -68,7 +71,7 @@ def open(self):
6871 """
6972 webbrowser .open (self .url )
7073
71- def download (self , file = None ):
74+ def download (self , file = None ):
7275 """Downloads the current app to a JS file.
7376
7477 Parameters
@@ -89,7 +92,7 @@ def download(self, file = None):
8992 r = requests .get (self .url )
9093 r = BeautifulSoup (r .text )
9194 r = r .find_all ("main" )[0 ].find ("script" ).string
92- app_url = re .findall (r' init\((.*?)\)' , r )[0 ].replace ('"' ,'' ).replace ("'" ,"" )
95+ app_url = re .findall (r" init\((.*?)\)" , r )[0 ].replace ('"' , "" ).replace ("'" , "" )
9396 r = requests .get (app_url ).json ()
9497 path = r ["path" ]
9598 r = r ["dependencies" ][path ]
@@ -100,13 +103,13 @@ def download(self, file = None):
100103
101104
102105@extend (ee )
103- def listApps (online = False ):
106+ def listApps (online = False ):
104107 """Gets the dictionary of available Google Earth Engine Apps from ee-appshot [1]_.
105108
106109 Parameters
107110 ----------
108111 online : boolean
109- Whether to retrieve the most recent list of apps directly from the GitHub
112+ Whether to retrieve the most recent list of apps directly from the GitHub
110113 repository and not from the local copy.
111114
112115 Returns
@@ -144,5 +147,5 @@ def __repr__(self):
144147 if "users.earthengine.app/view/" in app :
145148 the_app = App (app )
146149 apps_extra [user ][the_app .name ] = the_app
147-
148- return GoogleEarthEngineApps (apps_extra ,frozen_box = True )
150+
151+ return GoogleEarthEngineApps (apps_extra , frozen_box = True )
0 commit comments