Skip to content

Commit d9e465e

Browse files
committed
let's just get it over with
1 parent f3fafd1 commit d9e465e

File tree

403 files changed

+11164
-8140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

403 files changed

+11164
-8140
lines changed

src/compas/__init__.py

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,39 +32,48 @@
3232
from distutils.version import LooseVersion
3333

3434
import 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
3645
from 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-
__email__ = '[email protected]'
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+
__email__ = "[email protected]"
4352

44-
__version__ = '1.16.0'
53+
__version__ = "1.16.0"
4554

4655
version = LooseVersion(compas.__version__)
47-
versionstring = version.vstring.split('-')[0]
56+
versionstring = version.vstring.split("-")[0]
4857

4958
HERE = 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:
6978
The precision used by COMPAS for generation of geometric keys,
7079
for the comparison of point locations,
@@ -107,31 +116,48 @@
107116
# Check if COMPAS is installed from git
108117
# If that's the case, try to append the current head's hash to __version__
109118
try:
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]
125134
except 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+
171198
def 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

218247
def 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

src/compas/__main__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import compas
1212

13-
if __name__ == '__main__':
13+
if __name__ == "__main__":
1414

1515
# c = 'DCDHDCACDHDCAEDEACDHDCAEDEACDHDCAEDCDEACDHDCADCACDEADHDCAEDADEACDHDADADADHDCACDCAEDEACDCACDHDCAEDEACDCAEDEACDCAEDBACDHDAEDEACDADADCAEDBADHDAGDEACDADEADCAEDEADHDBADEDCAEDEACDEDAGDHDADCAEDACDCADADADHDAGDADEACAEDADBADHDAGDCADEAEDEACDBADHDAGDCAEDADEACDBADHDBADADADADAGDHDAGDCADEDADBADHDBADADAGDHDEADEAEDEAEDADHDEADEDADEDADHDEACDADCAEDHDACDADCADHDEACDADCAEDHDEACDADCAEDHDEACDADCAEDHDEAFCDADCAEDHDEAEDHDEDH' # noqa: E501
1616
# r = 'fGfB]DSD]BYBHEIEHCXBUCFBYBFCUBSBEBOEOBEBSBQBEPBGBPBEQBOBDBRIRBDBOBNEUGUENBLBECRBCBCBCBRCEBLBKBDBBBDBNBCBEBCBNBDBBBDBKBKDBFCDBIDIDIBDCFBDKBJDBKCCCDDKBCDCCCKBDJBIBDPCBBCBMBCBBCPDBIBIERBCBBBCGCBCDREIBIDBQDEBDCDBEDQBDIBIDBOBDIBCBIBCBOBDIBIDBNBCBKCKBCBNBDIBIBDMDMCMDMDBIBJDBHBFNCNGHBDJBJBDGkGDBJBKBDFBGB[BGBFEKBLBDHCPCPCHELBMBDBWCWBDBMBOEBUCUBEOBPBEBSCSBEBPBRBEBQCQBEBRBUBECMCMCECTBXBFBDGCGDGCWB[DXC[BbObB' # noqa: E501
@@ -20,15 +20,19 @@
2020
# print((ord(n) - 65) * maps[ord(o) - 65], end='')
2121

2222
print()
23-
print('Yay! COMPAS is installed correctly!')
23+
print("Yay! COMPAS is installed correctly!")
2424
print()
25-
print('COMPAS: {}'.format(compas.__version__))
26-
print('Python: {} ({})'.format(platform.python_version(), platform.python_implementation()))
25+
print("COMPAS: {}".format(compas.__version__))
26+
print(
27+
"Python: {} ({})".format(
28+
platform.python_version(), platform.python_implementation()
29+
)
30+
)
2731

2832
if pkg_resources:
2933
working_set = pkg_resources.working_set
30-
packages = set([p.project_name for p in working_set]) - set(['COMPAS'])
31-
compas_pkgs = [p for p in packages if p.lower().startswith('compas')]
34+
packages = set([p.project_name for p in working_set]) - set(["COMPAS"])
35+
compas_pkgs = [p for p in packages if p.lower().startswith("compas")]
3236

3337
if compas_pkgs:
34-
print('Extensions: {}'.format([p for p in compas_pkgs]))
38+
print("Extensions: {}".format([p for p in compas_pkgs]))

src/compas/_iotools.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
@contextmanager
12-
def open_file(file_or_filename, mode='r'):
12+
def open_file(file_or_filename, mode="r"):
1313
"""Context-manager to open a file, path or URL and return a corresponding file object.
1414
1515
If the argument is a path-like object, it will open it,
@@ -39,12 +39,12 @@ def open_file(file_or_filename, mode='r'):
3939
file = file_or_filename
4040
close_source = False
4141

42-
if not hasattr(file, 'read'):
42+
if not hasattr(file, "read"):
4343
# If it's a URL, open and read its response into an in-memory stream
44-
if hasattr(file, 'startswith') and file.startswith('http'):
44+
if hasattr(file, "startswith") and file.startswith("http"):
4545
# support all read modes (r, r+, rb, etc)
46-
if not mode.startswith('r'):
47-
raise ValueError('URLs can only be opened in read mode.')
46+
if not mode.startswith("r"):
47+
raise ValueError("URLs can only be opened in read mode.")
4848
response = urlopen(file)
4949
file = io.BytesIO(response.read())
5050
else:

0 commit comments

Comments
 (0)