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+ )
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+ "is_grasshopper" ,
156+ "set_precision" ,
157+ "get" ,
158+ "json_dump" ,
159+ "json_load" ,
160+ "json_dumps" ,
161+ "json_loads" ,
135162]
136163
137164
@@ -160,14 +187,15 @@ def set_precision(precision):
160187 precision = str (precision )
161188 d = decimal .Decimal (precision ).as_tuple ()
162189 if d .exponent < 0 :
163- e = - d .exponent
190+ e = - d .exponent
164191 PRECISION = "{}f" .format (e )
165192
166193
167194# ==============================================================================
168195# data
169196# ==============================================================================
170197
198+
171199def get (filename ):
172200 """Get the full path to one of the sample data files.
173201
@@ -202,17 +230,19 @@ def get(filename):
202230 mesh = Mesh.from_obj(compas.get('faces.obj'))
203231
204232 """
205- filename = filename .strip ('/' )
233+ filename = filename .strip ("/" )
206234
207- if filename .endswith (' bunny.ply' ):
235+ if filename .endswith (" bunny.ply" ):
208236 return get_bunny ()
209237
210238 localpath = compas ._os .absjoin (DATA , filename )
211239
212240 if os .path .exists (localpath ):
213241 return localpath
214242 else :
215- return "https://raw.githubusercontent.com/compas-dev/compas/main/src/compas/data/samples/{}" .format (filename )
243+ return "https://raw.githubusercontent.com/compas-dev/compas/main/src/compas/data/samples/{}" .format (
244+ filename
245+ )
216246
217247
218248def get_bunny (localstorage = None ):
@@ -258,19 +288,23 @@ def get_bunny(localstorage=None):
258288 os .makedirs (localstorage )
259289
260290 if not os .path .isdir (localstorage ):
261- raise Exception ('Local storage location does not exist: {}' .format (localstorage ))
291+ raise Exception (
292+ "Local storage location does not exist: {}" .format (localstorage )
293+ )
262294
263295 if not os .access (localstorage , os .W_OK ):
264- raise Exception ('Local storage location is not writable: {}' .format (localstorage ))
296+ raise Exception (
297+ "Local storage location is not writable: {}" .format (localstorage )
298+ )
265299
266- bunny = compas ._os .absjoin (localstorage , ' bunny/reconstruction/bun_zipper.ply' )
267- destination = compas ._os .absjoin (localstorage , ' bunny.tar.gz' )
300+ bunny = compas ._os .absjoin (localstorage , " bunny/reconstruction/bun_zipper.ply" )
301+ destination = compas ._os .absjoin (localstorage , " bunny.tar.gz" )
268302
269303 if not os .path .exists (bunny ):
270- url = ' http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz'
304+ url = " http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz"
271305
272- print (' Getting the bunny from {} ...' .format (url ))
273- print (' This will take a few seconds...' )
306+ print (" Getting the bunny from {} ..." .format (url ))
307+ print (" This will take a few seconds..." )
274308
275309 urlretrieve (url , destination )
276310
@@ -279,6 +313,6 @@ def get_bunny(localstorage=None):
279313
280314 os .remove (destination )
281315
282- print (' Got it!\n ' )
316+ print (" Got it!\n " )
283317
284318 return bunny
0 commit comments