3232from distutils .version import LooseVersion
3333
3434import compas ._os
35- from compas ._os import is_windows , is_linux , is_osx , is_mono , is_ironpython , is_rhino , is_blender , is_grasshopper # noqa: F401
35+ from compas ._os import (
36+ is_windows ,
37+ is_linux ,
38+ is_osx ,
39+ is_mono ,
40+ is_ironpython ,
41+ is_rhino ,
42+ is_blender ,
43+ is_grasshopper ,
44+ ) # noqa: F401
3645from compas .data import json_dump , json_dumps , json_load , json_loads
3746
3847
39- __author__ = ' Tom Van Mele and many others (see AUTHORS.md)'
40- __copyright__ = ' Copyright 2014-2019 - Block Research Group, ETH Zurich'
41- __license__ = ' MIT License'
42- 48+ __author__ = " Tom Van Mele and many others (see AUTHORS.md)"
49+ __copyright__ = " Copyright 2014-2019 - Block Research Group, ETH Zurich"
50+ __license__ = " MIT License"
51+ 4352
44- __version__ = ' 1.16.0'
53+ __version__ = " 1.16.0"
4554
4655version = LooseVersion (compas .__version__ )
47- versionstring = version .vstring .split ('-' )[0 ]
56+ versionstring = version .vstring .split ("-" )[0 ]
4857
4958HERE = compas ._os .realpath (os .path .dirname (__file__ ))
5059"""str: Path to the location of the compas package."""
5160
52- HOME = compas ._os .absjoin (HERE , ' ../..' )
61+ HOME = compas ._os .absjoin (HERE , " ../.." )
5362"""str: Path to the root of the local installation."""
5463
55- DATA = compas ._os .absjoin (HERE , ' data' , ' samples' )
64+ DATA = compas ._os .absjoin (HERE , " data" , " samples" )
5665"""str: Path to the data folder of the local installation."""
5766
58- TEMP = compas ._os .absjoin (HERE , ' ../../temp' )
67+ TEMP = compas ._os .absjoin (HERE , " ../../temp" )
5968"""str: Path to the temp folder of the local installation."""
6069
61- APPDATA = compas ._os .user_data_dir (' COMPAS' , ' compas-dev' , roaming = True )
70+ APPDATA = compas ._os .user_data_dir (" COMPAS" , " compas-dev" , roaming = True )
6271"""str: Path to the COMPAS directory in APPDATA."""
6372
64- APPTEMP = compas ._os .absjoin (APPDATA , ' temp' )
73+ APPTEMP = compas ._os .absjoin (APPDATA , " temp" )
6574"""str: Path to a temp folder in the COMPAS directory in APPDATA."""
6675
67- PRECISION = '3f'
76+ PRECISION = "3f"
6877"""str:
6978The precision used by COMPAS for generation of geometric keys,
7079for the comparison of point locations,
107116# Check if COMPAS is installed from git
108117# If that's the case, try to append the current head's hash to __version__
109118try :
110- git_head_file = compas ._os .absjoin (HOME , ' .git' , ' HEAD' )
119+ git_head_file = compas ._os .absjoin (HOME , " .git" , " HEAD" )
111120
112121 if os .path .exists (git_head_file ):
113122 # git head file contains one line that looks like this:
114123 # ref: refs/heads/main
115- with open (git_head_file , 'r' ) as git_head :
116- _ , ref_path = git_head .read ().strip ().split (' ' )
117- ref_path = ref_path .split ('/' )
124+ with open (git_head_file , "r" ) as git_head :
125+ _ , ref_path = git_head .read ().strip ().split (" " )
126+ ref_path = ref_path .split ("/" )
118127
119- git_head_refs_file = compas ._os .absjoin (HOME , ' .git' , * ref_path )
128+ git_head_refs_file = compas ._os .absjoin (HOME , " .git" , * ref_path )
120129
121130 if os .path .exists (git_head_refs_file ):
122- with open (git_head_refs_file , 'r' ) as git_head_ref :
131+ with open (git_head_refs_file , "r" ) as git_head_ref :
123132 git_commit = git_head_ref .read ().strip ()
124- __version__ += '-' + git_commit [:8 ]
133+ __version__ += "-" + git_commit [:8 ]
125134except Exception :
126135 pass
127136
128137
129138__all__ = [
130- 'WINDOWS' , 'LINUX' , 'OSX' , 'MONO' , 'IPY' , 'RHINO' , 'BLENDER' , 'PY2' , 'PY3' ,
131- 'is_windows' , 'is_linux' , 'is_osx' , 'is_mono' , 'is_ironpython' , 'is_rhino' , 'is_blender' ,
132- 'set_precision' ,
133- 'get' ,
134- 'json_dump' , 'json_load' , 'json_dumps' , 'json_loads' ,
139+ "WINDOWS" ,
140+ "LINUX" ,
141+ "OSX" ,
142+ "MONO" ,
143+ "IPY" ,
144+ "RHINO" ,
145+ "BLENDER" ,
146+ "PY2" ,
147+ "PY3" ,
148+ "is_windows" ,
149+ "is_linux" ,
150+ "is_osx" ,
151+ "is_mono" ,
152+ "is_ironpython" ,
153+ "is_rhino" ,
154+ "is_blender" ,
155+ "set_precision" ,
156+ "get" ,
157+ "json_dump" ,
158+ "json_load" ,
159+ "json_dumps" ,
160+ "json_loads" ,
135161]
136162
137163
@@ -160,14 +186,15 @@ def set_precision(precision):
160186 precision = str (precision )
161187 d = decimal .Decimal (precision ).as_tuple ()
162188 if d .exponent < 0 :
163- e = - d .exponent
189+ e = - d .exponent
164190 PRECISION = "{}f" .format (e )
165191
166192
167193# ==============================================================================
168194# data
169195# ==============================================================================
170196
197+
171198def get (filename ):
172199 """Get the full path to one of the sample data files.
173200
@@ -202,17 +229,19 @@ def get(filename):
202229 mesh = Mesh.from_obj(compas.get('faces.obj'))
203230
204231 """
205- filename = filename .strip ('/' )
232+ filename = filename .strip ("/" )
206233
207- if filename .endswith (' bunny.ply' ):
234+ if filename .endswith (" bunny.ply" ):
208235 return get_bunny ()
209236
210237 localpath = compas ._os .absjoin (DATA , filename )
211238
212239 if os .path .exists (localpath ):
213240 return localpath
214241 else :
215- return "https://raw.githubusercontent.com/compas-dev/compas/main/src/compas/data/samples/{}" .format (filename )
242+ return "https://raw.githubusercontent.com/compas-dev/compas/main/src/compas/data/samples/{}" .format (
243+ filename
244+ )
216245
217246
218247def get_bunny (localstorage = None ):
@@ -258,19 +287,23 @@ def get_bunny(localstorage=None):
258287 os .makedirs (localstorage )
259288
260289 if not os .path .isdir (localstorage ):
261- raise Exception ('Local storage location does not exist: {}' .format (localstorage ))
290+ raise Exception (
291+ "Local storage location does not exist: {}" .format (localstorage )
292+ )
262293
263294 if not os .access (localstorage , os .W_OK ):
264- raise Exception ('Local storage location is not writable: {}' .format (localstorage ))
295+ raise Exception (
296+ "Local storage location is not writable: {}" .format (localstorage )
297+ )
265298
266- bunny = compas ._os .absjoin (localstorage , ' bunny/reconstruction/bun_zipper.ply' )
267- destination = compas ._os .absjoin (localstorage , ' bunny.tar.gz' )
299+ bunny = compas ._os .absjoin (localstorage , " bunny/reconstruction/bun_zipper.ply" )
300+ destination = compas ._os .absjoin (localstorage , " bunny.tar.gz" )
268301
269302 if not os .path .exists (bunny ):
270- url = ' http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz'
303+ url = " http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz"
271304
272- print (' Getting the bunny from {} ...' .format (url ))
273- print (' This will take a few seconds...' )
305+ print (" Getting the bunny from {} ..." .format (url ))
306+ print (" This will take a few seconds..." )
274307
275308 urlretrieve (url , destination )
276309
@@ -279,6 +312,6 @@ def get_bunny(localstorage=None):
279312
280313 os .remove (destination )
281314
282- print (' Got it!\n ' )
315+ print (" Got it!\n " )
283316
284317 return bunny
0 commit comments