Skip to content

Commit ec8b9ed

Browse files
authored
Merge pull request #1071 from compas-dev/black
Most (of my) PRs are cluttered with changes from black...
2 parents f3fafd1 + 295c7ab commit ec8b9ed

File tree

404 files changed

+11167
-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.

404 files changed

+11167
-8140
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ universal = 1
44
[flake8]
55
max-line-length = 180
66
exclude = */migrations/*
7+
extend-ignore = E203
78

89
[doc8]
910
max-line-length = 180

src/compas/__init__.py

Lines changed: 71 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+
)
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,49 @@
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+
"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+
171199
def 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

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

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)