Skip to content

Commit

Permalink
small code formating
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jun 12, 2019
1 parent 2981ca7 commit 082fb09
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 97 deletions.
4 changes: 2 additions & 2 deletions backends/checker.py
Expand Up @@ -433,7 +433,7 @@ def __init__(self):

def populate(self,repo,dbs):
for std,cl,coll in repo.iterstandards(["standard","class","collection"]):
args = dict([ (p,"") for p in cl.parameters.parameters])
args = dict([(p,"") for p in cl.parameters.parameters])
try:
std.labeling.get_nice(args)
except:
Expand All @@ -445,7 +445,7 @@ def populate(self,repo,dbs):
self.rows.append(row)

for name,cl,coll in repo.iternames(["name","class","collection"]):
args = dict([ (p,"") for p in cl.parameters.parameters])
args = dict([(p,"") for p in cl.parameters.parameters])
try:
name.labeling.get_nice(args)
except:
Expand Down
10 changes: 9 additions & 1 deletion backends/freecad/init.py
Expand Up @@ -15,6 +15,7 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


import FreeCAD, FreeCADGui, Part
from os.path import join, exists, dirname
from os import listdir
Expand All @@ -23,6 +24,7 @@

USE_PYSIDE=True


try:
from PySide import QtCore
from FreeCADGui import getMainWindow
Expand All @@ -48,6 +50,7 @@ def getMainWindow():

widget = None


def show_widget():
global widget
if widget is None:
Expand All @@ -58,6 +61,7 @@ def show_widget():
else:
widget.show()


def make_drawing(scale,obj):
doc = FreeCAD.ActiveDocument
page = doc.addObject("Drawing::FeaturePage","Page")
Expand All @@ -78,13 +82,15 @@ def make_drawing(scale,obj):
view.Scale = scale
page.addObject(view)


def list_names(doc):
print("Label Name")
print("------------")
for part in doc.findObjects():
if isinstance(part,Part.Feature):
print("%s %s" % (part.Label, part.Name))


def add_name(id,in_params=None):
name = repo.names[id]
cl = repo.class_names.get_src(name)
Expand All @@ -99,6 +105,7 @@ def add_name(id,in_params=None):
coll = repo.collection_classes.get_src(cl)
boltsgui.add_part(coll,base,params,FreeCAD.ActiveDocument)


def add_standard(id,in_params=None):
standard = repo.standards[id]
cl = repo.class_standards.get_src(standard)
Expand All @@ -113,14 +120,15 @@ def add_standard(id,in_params=None):
coll = repo.collection_classes.get_src(cl)
boltsgui.add_part(coll,base,params,FreeCAD.ActiveDocument)


def get_free_in_params(cl):
base = freecad_db.base_classes.get_src(cl)
params = cl.parameters.union(base.parameters)
free_params = params.free

in_params = {}
for p in free_params:
p_type = params.types[p]
# p_type = params.types[p] # not used
default_value = params.defaults[p]
in_params[p] = default_value
return in_params
6 changes: 4 additions & 2 deletions backends/openscad.py
Expand Up @@ -323,9 +323,11 @@ def write_classfile(self,fid,cl,module):
if std.status == "withdrawn":
fid.write('\tBOLTS_warning("The standard %s is withdrawn.' % std.get_id())
if std.replacedby is not None:
fid.write('Although withdrawn standards are often still in use.' +
fid.write(
'Although withdrawn standards are often still in use.'
'it might be better to use its successor %s instead"' %
(std.standard.get_nice(),std.replacedby))
(std.standard.get_nice(),std.replacedby)
)
fid.write('");\n')
for pname in params.free:
fid.write('\tBOLTS_check_parameter_type("%s","%s",%s,"%s");\n' %
Expand Down
4 changes: 2 additions & 2 deletions backends/website/__init__.py
Expand Up @@ -32,7 +32,7 @@
app.jinja_env.filters['markdown_docs'] = cms.markdown_docs
app.jinja_env.filters['markdown_blog'] = cms.markdown_blog
app.jinja_env.globals['gettext_parts'] = translation.gettext_parts
app.jinja_env.globals['gettext_docs'] = translation.gettext_docs
app.jinja_env.globals['gettext_docs'] = translation.gettext_docs

@babel.localeselector
def get_locale():
Expand Down Expand Up @@ -63,7 +63,7 @@ def error_500(e):
@app.route("/")
@app.route("/index.html")
def index():
page = {"title" : gettext("Home")}
# page = {"title" : gettext("Home")} # not used
return render_template("redirect.html", url = url_for("main.index", lang_code=get_locale()))

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion backends/website/parts/__init__.py
Expand Up @@ -51,7 +51,7 @@ def format_author_prop(author_list):
@parts.route('/index.html')
def index():
collections = [{'id' : coll.id, 'name' : coll.name} for coll, in repo.itercollections()]
bodies = [ body.body for body, in repo.iterbodies()]
bodies = [body.body for body, in repo.iterbodies()]
page = {"title" : "Part list"}
return render_template("parts/index.html",page=page,collections=collections,bodies=bodies)

Expand Down
2 changes: 1 addition & 1 deletion backends/website/utils.py
Expand Up @@ -66,7 +66,7 @@ def __init__(self,path):

self.audiences.add(header["audience"])

doc["content"] = [ p.replace("%","%%") for p in content.split('\n\n')]
doc["content"] = [p.replace("%","%%") for p in content.split('\n\n')]
self.documents.append(doc)

self.categories = list(self.categories)
Expand Down
2 changes: 1 addition & 1 deletion bolttools/common.py
Expand Up @@ -618,7 +618,7 @@ def _normalize_and_check_types(self,types):
for char in key:
if char in '\\/?*:|"\'<>\t\n\r':
raise MalformedTableIndexError(key)
res_type = types[self.result]
# res_type = types[self.result] # not used
for key in self.data:
#check key
for char in key:
Expand Down
2 changes: 1 addition & 1 deletion bolttools/drawings.py
Expand Up @@ -164,7 +164,7 @@ def iterdimdrawings(self,items=["dimdrawing"],**kwargs):

for draw in self.dimdrawings:
its = {"dimdrawing" : draw}
its["collection"] = self.collection_dimdrawings.get_src(draw);
its["collection"] = self.collection_dimdrawings.get_src(draw)
its["classes"] = self.dimdrawing_classes.get_dsts(draw)

if filter_iterator_items(its,kwargs):
Expand Down
2 changes: 1 addition & 1 deletion bolttools/openscad.py
Expand Up @@ -85,7 +85,7 @@ def __init__(self,repo):
#skip directory that is no collection
continue
try:
base = list(yaml.load_all( open(basefilename,"r","utf8"), Loader=yaml.SafeLoader))
base = list(yaml.load_all(open(basefilename,"r","utf8"), Loader=yaml.SafeLoader))
# SafeLoader is not implemented in pyyaml < 5.1
except AttributeError:
# this is deprecated for newer pyyaml versions
Expand Down
101 changes: 51 additions & 50 deletions freecad/extrusions/profiles.py
Expand Up @@ -17,10 +17,11 @@


import math

import Part
import Arch
from FreeCAD import Vector
from Part import makeCircle, makeLine
import Part
import Arch
from DraftGeomUtils import fillet as draft_fillet


Expand All @@ -39,10 +40,10 @@ def vslot20x20(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = 8*[vslot_outline]
Expand Down Expand Up @@ -79,12 +80,12 @@ def vslot20x40(
(-w,0,True, True ,False,False),
(-w,0,False,True ,True ,False),
(-w,0,True, False,True ,False),
(-w,0,False, False,True ,True ),
(-w,0,True, True ,True ,True ),
(-w,0,False, True ,False,True ),
(0,0,True, True ,True ,True ),
(0,0,False, True ,False,True ),
(0,0,True, False,False,True ),
(-w,0,False, False,True ,True),
(-w,0,True, True ,True ,True),
(-w,0,False, True ,False,True),
(0,0,True, True ,True ,True),
(0,0,False, True ,False,True),
(0,0,True, False,False,True),
]

vertices = 12*[vslot_outline]
Expand Down Expand Up @@ -124,14 +125,14 @@ def vslot20x60(
(-2*w,0,True, True ,False,False),
(-2*w,0,False, True ,True ,False),
(-2*w,0,True, False,True ,False),
(-2*w,0,False, False,True ,True ),
(-2*w,0,True, True ,True ,True ),
(-2*w,0,False, True ,False,True ),
(-w,0,True, True ,True ,True ),
(-w,0,False, True ,False,True ),
(0,0,True, True ,True ,True ),
(0,0,False, True ,False,True ),
(0,0,True, False,False,True ),
(-2*w,0,False, False,True ,True),
(-2*w,0,True, True ,True ,True),
(-2*w,0,False, True ,False,True),
(-w,0,True, True ,True ,True),
(-w,0,False, True ,False,True),
(0,0,True, True ,True ,True),
(0,0,False, True ,False,True),
(0,0,True, False,False,True),
]

vertices = 16*[vslot_outline]
Expand Down Expand Up @@ -174,16 +175,16 @@ def vslot20x80(
(-3*w,0,True, True ,False,False),
(-3*w,0,False, True ,True ,False),
(-3*w,0,True, False,True ,False),
(-3*w,0,False, False,True ,True ),
(-3*w,0,True, True ,True ,True ),
(-3*w,0,False, True ,False,True ),
(-2*w,0,True, True ,True ,True ),
(-2*w,0,False, True ,False,True ),
(-w,0,True, True ,True ,True ),
(-w,0,False, True ,False,True ),
(0,0,True, True ,True ,True ),
(0,0,False, True ,False,True ),
(0,0,True, False,False,True ),
(-3*w,0,False, False,True ,True),
(-3*w,0,True, True ,True ,True),
(-3*w,0,False, True ,False,True),
(-2*w,0,True, True ,True ,True),
(-2*w,0,False, True ,False,True),
(-w,0,True, True ,True ,True),
(-w,0,False, True ,False,True),
(0,0,True, True ,True ,True),
(0,0,False, True ,False,True),
(0,0,True, False,False,True),
]

vertices = 20*[vslot_outline]
Expand Down Expand Up @@ -220,10 +221,10 @@ def tslot20x20(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = 8*[tslot_outline]
Expand Down Expand Up @@ -254,10 +255,10 @@ def tslot20x20_three_slot(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = [tslot_outline] + 2*[tslot_closed] + 5*[tslot_outline]
Expand Down Expand Up @@ -294,10 +295,10 @@ def tslot20x20_two_slot(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = [tslot_outline] + 4*[tslot_closed] + 3*[tslot_outline]
Expand Down Expand Up @@ -335,10 +336,10 @@ def tslot20x20_two_slot_opp(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = [tslot_outline] + 2*[tslot_closed] + 2*[tslot_outline]+ 2*[tslot_closed] + [tslot_outline]
Expand Down Expand Up @@ -376,10 +377,10 @@ def tslot20x20_one_slot(
(0,0,True, True ,False,False),
(0,0,False,True ,True ,False),
(0,0,True, False,True ,False),
(0,0,False,False,True ,True ),
(0,0,True, True ,True ,True ),
(0,0,False,True ,False,True ),
(0,0,True, False,False,True ),
(0,0,False,False,True ,True),
(0,0,True, True ,True ,True),
(0,0,False,True ,False,True),
(0,0,True, False,False,True),
]

vertices = [tslot_outline] + 6*[tslot_closed] + [tslot_outline]
Expand Down
6 changes: 3 additions & 3 deletions freecad/extrusions/wheels.py
Expand Up @@ -67,7 +67,7 @@ def dualvwheel(params,document):
part = document.addObject("Part::Feature","BOLTS_part")
part.Label = name

part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()
part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()


def solidvwheel(params,document):
Expand Down Expand Up @@ -113,7 +113,7 @@ def solidvwheel(params,document):
part = document.addObject("Part::Feature","BOLTS_part")
part.Label = name

part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()
part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()


def minivwheel(params,document):
Expand Down Expand Up @@ -159,4 +159,4 @@ def minivwheel(params,document):
part = document.addObject("Part::Feature","BOLTS_part")
part.Label = name

part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()
part.Shape = Part.Face(Part.Wire(lines)).revolve(Vector(0,0,0),Vector(1,0,0),360).removeSplitter()
6 changes: 3 additions & 3 deletions freecad/hex/hex.py
Expand Up @@ -39,7 +39,7 @@ def color_face(part,n):


def hex1(params,document):
key = params['key']
# key = params['key'] # not used
d1 = params['d1']
k = params['k']
s = params['s']
Expand Down Expand Up @@ -75,15 +75,15 @@ def hex1(params,document):


def hex2(params,document):
key = params['key']
# key = params['key'] # not used
d1 = params['d1']
k = params['k']
s = params['s']
b1 = params['b1']
b2 = params['b2']
b3 = params['b3']
l = params['l']
b = b3;
b = b3
if l < 125:
b = b1
elif l < 200:
Expand Down

0 comments on commit 082fb09

Please sign in to comment.