mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
autopep8 aggressive
autopep8 --in-place --recursive --max-line-length=200 --aggressive --aggressive --aggressive ifcopenshell
This commit is contained in:
@@ -49,6 +49,7 @@ except Exception as e:
|
|||||||
if int(python_version_tuple[0]) == 2:
|
if int(python_version_tuple[0]) == 2:
|
||||||
# Only for py2, as py3 has exception chaining
|
# Only for py2, as py3 has exception chaining
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print('-' * 64)
|
print('-' * 64)
|
||||||
raise ImportError("IfcOpenShell not built for '%s'" % python_distribution)
|
raise ImportError("IfcOpenShell not built for '%s'" % python_distribution)
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class entity_instance(object):
|
|||||||
def wrap(e): return entity_instance(e)
|
def wrap(e): return entity_instance(e)
|
||||||
|
|
||||||
def is_instance(e): return isinstance(e, ifcopenshell_wrapper.entity_instance)
|
def is_instance(e): return isinstance(e, ifcopenshell_wrapper.entity_instance)
|
||||||
|
|
||||||
return entity_instance.walk(is_instance, wrap, v)
|
return entity_instance.walk(is_instance, wrap, v)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -72,6 +73,7 @@ class entity_instance(object):
|
|||||||
def unwrap(e): return e.wrapped_data
|
def unwrap(e): return e.wrapped_data
|
||||||
|
|
||||||
def is_instance(e): return isinstance(e, entity_instance)
|
def is_instance(e): return isinstance(e, entity_instance)
|
||||||
|
|
||||||
return entity_instance.walk(is_instance, unwrap, v)
|
return entity_instance.walk(is_instance, unwrap, v)
|
||||||
|
|
||||||
def attribute_type(self, attr):
|
def attribute_type(self, attr):
|
||||||
@@ -99,12 +101,13 @@ class entity_instance(object):
|
|||||||
try:
|
try:
|
||||||
if isinstance(value, unicode):
|
if isinstance(value, unicode):
|
||||||
value = value.encode("utf-8")
|
value = value.encode("utf-8")
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
|
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
|
||||||
except:
|
except BaseException:
|
||||||
raise ValueError("Expected %s for attribute %s.%s, got %r" % (real_attr_type, self.is_a(), self.attribute_name(idx), value))
|
raise ValueError("Expected %s for attribute %s.%s, got %r" % (
|
||||||
|
real_attr_type, self.is_a(), self.attribute_name(idx), value))
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
@@ -120,7 +123,7 @@ class entity_instance(object):
|
|||||||
return self.wrapped_data.id()
|
return self.wrapped_data.id()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if type(self) != type(other):
|
if not isinstance(self, type(other)):
|
||||||
return False
|
return False
|
||||||
return self.wrapped_data == other.wrapped_data
|
return self.wrapped_data == other.wrapped_data
|
||||||
|
|
||||||
@@ -140,7 +143,7 @@ class entity_instance(object):
|
|||||||
if include_identifier:
|
if include_identifier:
|
||||||
yield "id", self.id()
|
yield "id", self.id()
|
||||||
yield "type", self.is_a()
|
yield "type", self.is_a()
|
||||||
except:
|
except BaseException:
|
||||||
logging.exception("unhandled exception while getting id / type info on {}".format(self))
|
logging.exception("unhandled exception while getting id / type info on {}".format(self))
|
||||||
for i in range(len(self)):
|
for i in range(len(self)):
|
||||||
try:
|
try:
|
||||||
@@ -160,10 +163,12 @@ class entity_instance(object):
|
|||||||
return_type=return_type,
|
return_type=return_type,
|
||||||
ignore=ignore
|
ignore=ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
attr_value = entity_instance.walk(is_instance, get_info_, attr_value)
|
attr_value = entity_instance.walk(is_instance, get_info_, attr_value)
|
||||||
yield self.attribute_name(i), attr_value
|
yield self.attribute_name(i), attr_value
|
||||||
except:
|
except BaseException:
|
||||||
logging.exception("unhandled exception occured setting attribute name for {}".format(self))
|
logging.exception("unhandled exception occured setting attribute name for {}".format(self))
|
||||||
|
|
||||||
return return_type(_())
|
return return_type(_())
|
||||||
|
|
||||||
__dict__ = property(get_info)
|
__dict__ = property(get_info)
|
||||||
|
|||||||
@@ -61,9 +61,11 @@ class file(object):
|
|||||||
elif isinstance(key, basestring):
|
elif isinstance(key, basestring):
|
||||||
return entity_instance(self.wrapped_data.by_guid(str(key)))
|
return entity_instance(self.wrapped_data.by_guid(str(key)))
|
||||||
|
|
||||||
def by_id(self, id): return self[id]
|
def by_id(self, id):
|
||||||
|
return self[id]
|
||||||
|
|
||||||
def by_guid(self, guid): return self[guid]
|
def by_guid(self, guid):
|
||||||
|
return self[guid]
|
||||||
|
|
||||||
def add(self, inst):
|
def add(self, inst):
|
||||||
inst.wrapped_data.this.disown()
|
inst.wrapped_data.this.disown()
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from collections import defaultdict, Iterable, OrderedDict
|
|||||||
os.environ['QT_API'] = 'pyqt4'
|
os.environ['QT_API'] = 'pyqt4'
|
||||||
try:
|
try:
|
||||||
from pyqode.qt import QtCore
|
from pyqode.qt import QtCore
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from PyQt4 import QtGui, QtCore
|
from PyQt4 import QtGui, QtCore
|
||||||
@@ -24,22 +24,21 @@ from .code_editor_pane import code_edit
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from OCC.Display.pyqt4Display import qtViewer3d
|
from OCC.Display.pyqt4Display import qtViewer3d
|
||||||
except:
|
except BaseException:
|
||||||
import OCC.Display
|
import OCC.Display
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import OCC.Display.backend
|
import OCC.Display.backend
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
OCC.Display.backend.get_backend("qt-pyqt4")
|
OCC.Display.backend.get_backend("qt-pyqt4")
|
||||||
except:
|
except BaseException:
|
||||||
OCC.Display.backend.load_backend("qt-pyqt4")
|
OCC.Display.backend.load_backend("qt-pyqt4")
|
||||||
|
|
||||||
from OCC.Display.qtDisplay import qtViewer3d
|
from OCC.Display.qtDisplay import qtViewer3d
|
||||||
|
|
||||||
|
|
||||||
from .main import settings, iterator
|
from .main import settings, iterator
|
||||||
from .occ_utils import display_shape
|
from .occ_utils import display_shape
|
||||||
|
|
||||||
@@ -58,10 +57,11 @@ class configuration(object):
|
|||||||
try:
|
try:
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
Cfg = ConfigParser.RawConfigParser
|
Cfg = ConfigParser.RawConfigParser
|
||||||
except:
|
except BaseException:
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
def Cfg(): return configparser.ConfigParser(interpolation=None)
|
def Cfg():
|
||||||
|
return configparser.ConfigParser(interpolation=None)
|
||||||
|
|
||||||
conf_file = os.path.expanduser(os.path.join("~", ".ifcopenshell", "app", "snippets.conf"))
|
conf_file = os.path.expanduser(os.path.join("~", ".ifcopenshell", "app", "snippets.conf"))
|
||||||
if conf_file.startswith("~"):
|
if conf_file.startswith("~"):
|
||||||
@@ -114,7 +114,6 @@ if selection:
|
|||||||
|
|
||||||
|
|
||||||
class application(QtGui.QApplication):
|
class application(QtGui.QApplication):
|
||||||
|
|
||||||
"""A pythonOCC, PyQt based IfcOpenShell application
|
"""A pythonOCC, PyQt based IfcOpenShell application
|
||||||
with two tree views and a graphical 3d view"""
|
with two tree views and a graphical 3d view"""
|
||||||
|
|
||||||
@@ -165,7 +164,8 @@ class application(QtGui.QApplication):
|
|||||||
itm = self.product_to_item.get(product)
|
itm = self.product_to_item.get(product)
|
||||||
if itm is None:
|
if itm is None:
|
||||||
return
|
return
|
||||||
self.selectionModel().setCurrentIndex(itm, QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows)
|
self.selectionModel().setCurrentIndex(itm,
|
||||||
|
QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows)
|
||||||
|
|
||||||
class decomposition_treeview(abstract_treeview):
|
class decomposition_treeview(abstract_treeview):
|
||||||
|
|
||||||
@@ -233,6 +233,7 @@ class application(QtGui.QApplication):
|
|||||||
itm = items[t2] = QtGui.QTreeWidgetItem(items.get(s2, self), [t2])
|
itm = items[t2] = QtGui.QTreeWidgetItem(items.get(s2, self), [t2])
|
||||||
itm.setData(0, QtCore.Qt.UserRole, t2)
|
itm.setData(0, QtCore.Qt.UserRole, t2)
|
||||||
self.children[s2].append(t2)
|
self.children[s2].append(t2)
|
||||||
|
|
||||||
add(t)
|
add(t)
|
||||||
|
|
||||||
for p in products:
|
for p in products:
|
||||||
@@ -379,6 +380,7 @@ class application(QtGui.QApplication):
|
|||||||
shp = OCC.AIS.Handle_AIS_Shape.DownCast(li.Value(i + 1))
|
shp = OCC.AIS.Handle_AIS_Shape.DownCast(li.Value(i + 1))
|
||||||
if not shp.IsNull():
|
if not shp.IsNull():
|
||||||
yield shp
|
yield shp
|
||||||
|
|
||||||
return tuple(shp.HashCode(1 << 24) for shp in yield_shapes())
|
return tuple(shp.HashCode(1 << 24) for shp in yield_shapes())
|
||||||
|
|
||||||
def __init__(self, widget):
|
def __init__(self, widget):
|
||||||
@@ -528,6 +530,7 @@ class application(QtGui.QApplication):
|
|||||||
for c in self.components:
|
for c in self.components:
|
||||||
if c != component:
|
if c != component:
|
||||||
c.select(inst)
|
c.select(inst)
|
||||||
|
|
||||||
return handler
|
return handler
|
||||||
|
|
||||||
def __init__(self, settings=None):
|
def __init__(self, settings=None):
|
||||||
@@ -582,7 +585,8 @@ class application(QtGui.QApplication):
|
|||||||
sys.exit(self.exec_())
|
sys.exit(self.exec_())
|
||||||
|
|
||||||
def browse(self):
|
def browse(self):
|
||||||
filename = QtGui.QFileDialog.getOpenFileName(self.window, 'Open file', ".", "Industry Foundation Classes (*.ifc)")
|
filename = QtGui.QFileDialog.getOpenFileName(self.window, 'Open file', ".",
|
||||||
|
"Industry Foundation Classes (*.ifc)")
|
||||||
self.load(filename)
|
self.load(filename)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtWidgets
|
from PyQt4 import QtWidgets
|
||||||
except:
|
except BaseException:
|
||||||
QtWidgets = QtGui
|
QtWidgets = QtGui
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -24,14 +24,14 @@ try:
|
|||||||
from pyqode.python.backend import server
|
from pyqode.python.backend import server
|
||||||
from pyqode.python import modes as pymodes, panels as pypanels, widgets
|
from pyqode.python import modes as pymodes, panels as pypanels, widgets
|
||||||
from pyqode.python.widgets import PyInteractiveConsole
|
from pyqode.python.widgets import PyInteractiveConsole
|
||||||
|
|
||||||
has_pyqode = True
|
has_pyqode = True
|
||||||
except:
|
except BaseException:
|
||||||
has_pyqode = False
|
has_pyqode = False
|
||||||
CodeEdit = QtWidgets.QPlainTextEdit
|
CodeEdit = QtWidgets.QPlainTextEdit
|
||||||
|
|
||||||
|
|
||||||
class StdoutRedirector(object):
|
class StdoutRedirector(object):
|
||||||
|
|
||||||
'''A class for redirecting stdout to this Text widget.'''
|
'''A class for redirecting stdout to this Text widget.'''
|
||||||
|
|
||||||
def __init__(self, widget):
|
def __init__(self, widget):
|
||||||
@@ -49,7 +49,6 @@ class StdoutRedirector(object):
|
|||||||
|
|
||||||
|
|
||||||
class code_edit(QtGui.QWidget):
|
class code_edit(QtGui.QWidget):
|
||||||
|
|
||||||
class Console(InteractiveConsole):
|
class Console(InteractiveConsole):
|
||||||
def __init__(*args):
|
def __init__(*args):
|
||||||
InteractiveConsole.__init__(*args)
|
InteractiveConsole.__init__(*args)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from ..entity_instance import entity_instance
|
|||||||
def has_occ():
|
def has_occ():
|
||||||
try:
|
try:
|
||||||
import OCC.BRepTools
|
import OCC.BRepTools
|
||||||
except:
|
except BaseException:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -40,13 +40,17 @@ def has_occ():
|
|||||||
has_occ = has_occ()
|
has_occ = has_occ()
|
||||||
|
|
||||||
|
|
||||||
def wrap_shape_creation(settings, shape): return shape
|
def wrap_shape_creation(settings, shape):
|
||||||
|
return shape
|
||||||
|
|
||||||
|
|
||||||
if has_occ:
|
if has_occ:
|
||||||
from . import occ_utils as utils
|
from . import occ_utils as utils
|
||||||
|
|
||||||
def wrap_shape_creation(settings, shape): return utils.create_shape_from_serialization(shape) if getattr(settings, 'use_python_opencascade', False) else shape
|
def wrap_shape_creation(settings, shape): return utils.create_shape_from_serialization(shape) if getattr(settings,
|
||||||
|
'use_python_opencascade',
|
||||||
|
False) else shape
|
||||||
|
|
||||||
|
|
||||||
# Subclass the settings module to provide an additional
|
# Subclass the settings module to provide an additional
|
||||||
# setting to enable pythonOCC when available
|
# setting to enable pythonOCC when available
|
||||||
@@ -83,6 +87,7 @@ class iterator(_iterator):
|
|||||||
else:
|
else:
|
||||||
file_or_filename = os.path.abspath(file_or_filename)
|
file_or_filename = os.path.abspath(file_or_filename)
|
||||||
_iterator.__init__(self, settings, file_or_filename)
|
_iterator.__init__(self, settings, file_or_filename)
|
||||||
|
|
||||||
if has_occ:
|
if has_occ:
|
||||||
def get(self):
|
def get(self):
|
||||||
return wrap_shape_creation(self.settings, _iterator.get(self))
|
return wrap_shape_creation(self.settings, _iterator.get(self))
|
||||||
@@ -108,6 +113,7 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
elif all(map(lambda v: hasattr(value, v), "XYZ")):
|
elif all(map(lambda v: hasattr(value, v), "XYZ")):
|
||||||
return value.X(), value.Y(), value.Z()
|
return value.X(), value.Y(), value.Z()
|
||||||
return value
|
return value
|
||||||
|
|
||||||
args = [self, unwrap(value)]
|
args = [self, unwrap(value)]
|
||||||
if isinstance(value, entity_instance):
|
if isinstance(value, entity_instance):
|
||||||
args.append(kwargs.get("completely_within", False))
|
args.append(kwargs.get("completely_within", False))
|
||||||
@@ -124,6 +130,7 @@ class tree(ifcopenshell_wrapper.tree):
|
|||||||
elif hasattr(value, "Get"):
|
elif hasattr(value, "Get"):
|
||||||
return value.Get()[:3], value.Get()[3:]
|
return value.Get()[:3], value.Get()[3:]
|
||||||
return value
|
return value
|
||||||
|
|
||||||
args = [self, unwrap(value)]
|
args = [self, unwrap(value)]
|
||||||
if "extend" in kwargs or "completely_within" in kwargs:
|
if "extend" in kwargs or "completely_within" in kwargs:
|
||||||
args.append(kwargs.get("completely_within", False))
|
args.append(kwargs.get("completely_within", False))
|
||||||
@@ -152,7 +159,9 @@ def iterate(settings, filename):
|
|||||||
|
|
||||||
|
|
||||||
def make_shape_function(fn):
|
def make_shape_function(fn):
|
||||||
def entity_instance_or_none(e): return None if e is None else entity_instance(e)
|
def entity_instance_or_none(e):
|
||||||
|
return None if e is None else entity_instance(e)
|
||||||
|
|
||||||
if has_occ:
|
if has_occ:
|
||||||
import OCC.TopoDS
|
import OCC.TopoDS
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def initialize_display():
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
active_light = viewer.ActiveLight()
|
active_light = viewer.ActiveLight()
|
||||||
except:
|
except BaseException:
|
||||||
break
|
break
|
||||||
yield active_light
|
yield active_light
|
||||||
viewer.NextActiveLights()
|
viewer.NextActiveLights()
|
||||||
@@ -115,7 +115,8 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
|||||||
ais.SetMaterial(material)
|
ais.SetMaterial(material)
|
||||||
|
|
||||||
if isinstance(clr, str):
|
if isinstance(clr, str):
|
||||||
qclr = getattr(OCC.Quantity, "Quantity_NOC_%s" % clr.upper(), getattr(OCC.Quantity, "Quantity_NOC_%s1" % clr.upper(), None))
|
qclr = getattr(OCC.Quantity, "Quantity_NOC_%s" % clr.upper(),
|
||||||
|
getattr(OCC.Quantity, "Quantity_NOC_%s1" % clr.upper(), None))
|
||||||
if qclr is None:
|
if qclr is None:
|
||||||
raise Exception("No color named '%s'" % clr.upper())
|
raise Exception("No color named '%s'" % clr.upper())
|
||||||
elif isinstance(clr, Iterable):
|
elif isinstance(clr, Iterable):
|
||||||
@@ -146,7 +147,8 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
|||||||
for shp, stl in zip(subshapes, representation.styles):
|
for shp, stl in zip(subshapes, representation.styles):
|
||||||
subshape = OCC.AIS.AIS_Shape(shp)
|
subshape = OCC.AIS.AIS_Shape(shp)
|
||||||
if min(stl) < 0. or max(stl) > 1.:
|
if min(stl) < 0. or max(stl) > 1.:
|
||||||
default_style_applied = stl = DEFAULT_STYLES.get(representation.data.type, DEFAULT_STYLES["DEFAULT"])
|
default_style_applied = stl = DEFAULT_STYLES.get(representation.data.type,
|
||||||
|
DEFAULT_STYLES["DEFAULT"])
|
||||||
subshape.SetColor(OCC.Quantity.Quantity_Color(stl[0], stl[1], stl[2], OCC.Quantity.Quantity_TOC_RGB))
|
subshape.SetColor(OCC.Quantity.Quantity_Color(stl[0], stl[1], stl[2], OCC.Quantity.Quantity_TOC_RGB))
|
||||||
subshape.SetMaterial(material)
|
subshape.SetMaterial(material)
|
||||||
if len(stl) == 4 and stl[3] < 1.:
|
if len(stl) == 4 and stl[3] < 1.:
|
||||||
@@ -171,7 +173,9 @@ def display_shape(shape, clr=None, viewer_handle=None):
|
|||||||
ais = OCC.AIS.AIS_Shape(shape)
|
ais = OCC.AIS.AIS_Shape(shape)
|
||||||
ais.SetMaterial(material)
|
ais.SetMaterial(material)
|
||||||
|
|
||||||
def r(): return random.random() * 0.3 + 0.7
|
def r():
|
||||||
|
return random.random() * 0.3 + 0.7
|
||||||
|
|
||||||
clr = OCC.Quantity.Quantity_Color(r(), r(), r(), OCC.Quantity.Quantity_TOC_RGB)
|
clr = OCC.Quantity.Quantity_Color(r(), r(), r(), OCC.Quantity.Quantity_TOC_RGB)
|
||||||
ais.SetColor(clr)
|
ais.SetColor(clr)
|
||||||
|
|
||||||
@@ -211,12 +215,12 @@ def create_shape_from_serialization(brep_object):
|
|||||||
try:
|
try:
|
||||||
brep_data = brep_object.geometry.brep_data
|
brep_data = brep_object.geometry.brep_data
|
||||||
styles = brep_object.geometry.surface_styles
|
styles = brep_object.geometry.surface_styles
|
||||||
except:
|
except BaseException:
|
||||||
try:
|
try:
|
||||||
brep_data = brep_object.brep_data
|
brep_data = brep_object.brep_data
|
||||||
styles = brep_object.surface_styles
|
styles = brep_object.surface_styles
|
||||||
is_product_shape = False
|
is_product_shape = False
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
styles = tuple(styles[i:i + 4] for i in range(0, len(styles), 4))
|
styles = tuple(styles[i:i + 4] for i in range(0, len(styles), 4))
|
||||||
@@ -228,7 +232,7 @@ def create_shape_from_serialization(brep_object):
|
|||||||
ss = OCC.BRepTools.BRepTools_ShapeSet()
|
ss = OCC.BRepTools.BRepTools_ShapeSet()
|
||||||
ss.ReadFromString(brep_data)
|
ss.ReadFromString(brep_data)
|
||||||
occ_shape = ss.Shape(ss.NbShapes())
|
occ_shape = ss.Shape(ss.NbShapes())
|
||||||
except:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if is_product_shape:
|
if is_product_shape:
|
||||||
|
|||||||
@@ -33,13 +33,15 @@ def compress(g):
|
|||||||
bs = [int(g[i:i + 2], 16) for i in range(0, len(g), 2)]
|
bs = [int(g[i:i + 2], 16) for i in range(0, len(g), 2)]
|
||||||
|
|
||||||
def b64(v, l=4):
|
def b64(v, l=4):
|
||||||
return ''.join([chars[(v // (64**i)) % 64] for i in range(l)][::-1])
|
return ''.join([chars[(v // (64 ** i)) % 64] for i in range(l)][::-1])
|
||||||
|
|
||||||
return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
|
return ''.join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
|
||||||
|
|
||||||
|
|
||||||
def expand(g):
|
def expand(g):
|
||||||
def b64(v):
|
def b64(v):
|
||||||
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
|
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
|
||||||
|
|
||||||
bs = [b64(g[0:2])]
|
bs = [b64(g[0:2])]
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
d = b64(g[2 + 4 * i:6 + 4 * i])
|
d = b64(g[2 + 4 * i:6 + 4 * i])
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ DEFAULTS = {
|
|||||||
def create(filename=None, timestring=None, organization=None, creator=None,
|
def create(filename=None, timestring=None, organization=None, creator=None,
|
||||||
schema_identifier=None, application_version=None, timestamp=None,
|
schema_identifier=None, application_version=None, timestamp=None,
|
||||||
application=None, project_globalid=None, project_name=None):
|
application=None, project_globalid=None, project_name=None):
|
||||||
|
|
||||||
d = dict(locals())
|
d = dict(locals())
|
||||||
|
|
||||||
def _():
|
def _():
|
||||||
for var, value in d.items():
|
for var, value in d.items():
|
||||||
if value is None:
|
if value is None:
|
||||||
yield var, DEFAULTS.get(var, lambda *args: '')(d)
|
yield var, DEFAULTS.get(var, lambda *args: '')(d)
|
||||||
|
|
||||||
d.update(dict(_()))
|
d.update(dict(_()))
|
||||||
|
|
||||||
return file.from_string(TEMPLATE % d)
|
return file.from_string(TEMPLATE % d)
|
||||||
|
|||||||
Reference in New Issue
Block a user