autopep8 --in-place --recursive  --max-line-length=200 ifcopenshell
This commit is contained in:
thorade
2017-11-06 09:10:28 +01:00
committed by Thomas Krijnen
parent c357ab2c69
commit 80360c278d
9 changed files with 285 additions and 211 deletions
@@ -37,8 +37,8 @@ else:
python_version_tuple = tuple(sys.version.split(' ')[0].split('.'))
python_distribution = os.path.join(platform_system,
platform_architecture,
'python%s.%s' % python_version_tuple[:2])
platform_architecture,
'python%s.%s' % python_version_tuple[:2])
sys.path.append(os.path.abspath(os.path.join(
os.path.dirname(__file__),
'lib', python_distribution)))
@@ -57,15 +57,18 @@ from . import guid
from .file import file
from .entity_instance import entity_instance
def open(fn=None):
return file(ifcopenshell_wrapper.open(os.path.abspath(fn))) if fn else file()
def create_entity(type,*args,**kwargs):
def create_entity(type, *args, **kwargs):
e = entity_instance(type)
attrs = list(enumerate(args)) + \
[(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
for idx, arg in attrs: e[idx] = arg
for idx, arg in attrs:
e[idx] = arg
return e
from .main import *
@@ -62,14 +62,16 @@ class entity_instance(object):
@staticmethod
def wrap_value(v):
wrap = lambda e: entity_instance(e)
is_instance = lambda e: isinstance(e, ifcopenshell_wrapper.entity_instance)
def wrap(e): return entity_instance(e)
def is_instance(e): return isinstance(e, ifcopenshell_wrapper.entity_instance)
return entity_instance.walk(is_instance, wrap, v)
@staticmethod
def unwrap_value(v):
unwrap = lambda e: e.wrapped_data
is_instance = lambda e: isinstance(e, entity_instance)
def unwrap(e): return e.wrapped_data
def is_instance(e): return isinstance(e, entity_instance)
return entity_instance.walk(is_instance, unwrap, v)
def attribute_type(self, attr):
@@ -95,7 +97,8 @@ class entity_instance(object):
attr_type = attr_type.replace('Binary', 'String')
attr_type = attr_type.replace('Enumeration', 'String')
try:
if isinstance(value, unicode): value = value.encode("utf-8")
if isinstance(value, unicode):
value = value.encode("utf-8")
except:
pass
try:
@@ -117,7 +120,8 @@ class entity_instance(object):
return self.wrapped_data.id()
def __eq__(self, other):
if type(self) != type(other): return False
if type(self) != type(other):
return False
return self.wrapped_data == other.wrapped_data
def __hash__(self):
@@ -144,17 +148,18 @@ class entity_instance(object):
continue
attr_value = self[i]
if recursive:
is_instance = lambda e: isinstance(e, entity_instance)
def is_instance(e): return isinstance(e, entity_instance)
def get_info_(inst):
# for ty in ignore:
# if inst.is_a(ty):
# return None
return entity_instance.get_info(inst,
include_identifier=include_identifier,
recursive=recursive,
return_type=return_type,
ignore=ignore
)
include_identifier=include_identifier,
recursive=recursive,
return_type=return_type,
ignore=ignore
)
attr_value = entity_instance.walk(is_instance, get_info_, attr_value)
yield self.attribute_name(i), attr_value
except:
+20 -4
View File
@@ -34,42 +34,58 @@ except NameError:
# Python 3 or newer
basestring = (str, bytes)
class file(object):
def __init__(self, f=None):
self.wrapped_data = f or ifcopenshell_wrapper.file()
def create_entity(self,type,*args,**kwargs):
def create_entity(self, type, *args, **kwargs):
e = entity_instance(type)
self.wrapped_data.add(e.wrapped_data)
e.wrapped_data.this.disown()
attrs = list(enumerate(args)) + \
[(e.wrapped_data.get_argument_index(name), arg) for name, arg in kwargs.items()]
for idx, arg in attrs: e[idx] = arg
for idx, arg in attrs:
e[idx] = arg
return e
def __getattr__(self, attr):
if attr[0:6] == 'create': return functools.partial(self.create_entity,attr[6:])
else: return getattr(self.wrapped_data, attr)
if attr[0:6] == 'create':
return functools.partial(self.create_entity, attr[6:])
else:
return getattr(self.wrapped_data, attr)
def __getitem__(self, key):
if isinstance(key, numbers.Integral):
return entity_instance(self.wrapped_data.by_id(key))
elif isinstance(key, basestring):
return entity_instance(self.wrapped_data.by_guid(str(key)))
def by_id(self, id): return self[id]
def by_guid(self, guid): return self[guid]
def add(self, inst):
inst.wrapped_data.this.disown()
return entity_instance(self.wrapped_data.add(inst.wrapped_data))
def by_type(self, type):
return [entity_instance(e) for e in self.wrapped_data.by_type(type)]
def traverse(self, inst, max_levels=None):
if max_levels is None:
max_levels = -1
return [entity_instance(e) for e in self.wrapped_data.traverse(inst.wrapped_data, max_levels)]
def get_inverse(self, inst):
return [entity_instance(e) for e in self.wrapped_data.get_inverse(inst.wrapped_data)]
def remove(self, inst):
return self.wrapped_data.remove(inst.wrapped_data)
def __iter__(self):
return iter(self[id] for id in self.wrapped_data.entity_names())
@staticmethod
def from_string(s):
return file(ifcopenshell_wrapper.read(s))
@@ -15,21 +15,27 @@ from collections import defaultdict, Iterable, OrderedDict
os.environ['QT_API'] = 'pyqt4'
try:
from pyqode.qt import QtCore
except: pass
except:
pass
from PyQt4 import QtGui, QtCore
from .code_editor_pane import code_edit
try: from OCC.Display.pyqt4Display import qtViewer3d
try:
from OCC.Display.pyqt4Display import qtViewer3d
except:
import OCC.Display
try: import OCC.Display.backend
except: pass
try:
import OCC.Display.backend
except:
pass
try: OCC.Display.backend.get_backend("qt-pyqt4")
except: OCC.Display.backend.load_backend("qt-pyqt4")
try:
OCC.Display.backend.get_backend("qt-pyqt4")
except:
OCC.Display.backend.load_backend("qt-pyqt4")
from OCC.Display.qtDisplay import qtViewer3d
@@ -46,6 +52,7 @@ try:
except ImportError:
QString = str
class configuration(object):
def __init__(self):
try:
@@ -53,7 +60,8 @@ class configuration(object):
Cfg = ConfigParser.RawConfigParser
except:
import configparser
Cfg = lambda: configparser.ConfigParser(interpolation=None)
def Cfg(): return configparser.ConfigParser(interpolation=None)
conf_file = os.path.expanduser(os.path.join("~", ".ifcopenshell", "app", "snippets.conf"))
if conf_file.startswith("~"):
@@ -155,8 +163,9 @@ class application(QtGui.QApplication):
def select(self, product):
itm = self.product_to_item.get(product)
if itm is None: return
self.selectionModel().setCurrentIndex(itm, QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows);
if itm is None:
return
self.selectionModel().setCurrentIndex(itm, QtGui.QItemSelectionModel.SelectCurrent | QtGui.QItemSelectionModel.Rows)
class decomposition_treeview(abstract_treeview):
@@ -217,8 +226,9 @@ class application(QtGui.QApplication):
for t in types:
def add(t):
s = get_supertype(t)
if s: add(s)
s2, t2 = map(QString, (s,t))
if s:
add(s)
s2, t2 = map(QString, (s, t))
if t2 not in items:
itm = items[t2] = QtGui.QTreeWidgetItem(items.get(s2, self), [t2])
itm.setData(0, QtCore.Qt.UserRole, t2)
@@ -235,13 +245,11 @@ class application(QtGui.QApplication):
self.connect(self, QtCore.SIGNAL("clicked(const QModelIndex &)"), self.clicked)
self.expandAll()
class property_table(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.layout= QtGui.QVBoxLayout(self)
self.layout = QtGui.QVBoxLayout(self)
self.setLayout(self.layout)
self.scroll = QtGui.QScrollArea(self)
self.layout.addWidget(self.scroll)
@@ -252,7 +260,7 @@ class application(QtGui.QApplication):
self.scroll.setWidget(self.scrollContent)
self.prop_dict = {}
#triggered by selection event in either component of parent
# triggered by selection event in either component of parent
def select(self, product):
# Clear the old contents if any
@@ -268,7 +276,7 @@ class application(QtGui.QApplication):
prop_sets = self.prop_dict.get(str(product))
if prop_sets is not None:
for k,v in prop_sets:
for k, v in prop_sets:
group_box = QtGui.QGroupBox()
group_box.setTitle(k)
@@ -299,10 +307,9 @@ class application(QtGui.QApplication):
self.scrollLayout.addStretch()
else:
label = QtGui.QLabel("No IfcPropertySets asscociated with selected entity instance" )
label = QtGui.QLabel("No IfcPropertySets asscociated with selected entity instance")
self.scrollLayout.addWidget(label)
def load_file(self, f, **kwargs):
for p in f.by_type("IfcProduct"):
propsets = []
@@ -314,16 +321,16 @@ class application(QtGui.QApplication):
if prop_def.is_a("IfcElementQuantity"):
for q in prop_def.Quantities:
if q.is_a("IfcPhysicalSimpleQuantity"):
props[q.Name]=q[3]
props[q.Name] = q[3]
elif prop_def.is_a("IfcPropertySet"):
for prop in prop_def.HasProperties:
if prop.is_a("IfcPropertySingleValue"):
props[prop.Name]=prop.NominalValue
props[prop.Name] = prop.NominalValue
else:
# Entity introduced in IFC4
# prop_def.is_a("IfcPreDefinedPropertySet"):
for prop in range(4, len(prop_def)):
props[prop_def.attribute_name(prop)]=prop_def[prop]
props[prop_def.attribute_name(prop)] = prop_def[prop]
return prop_set_name, props
try:
@@ -332,7 +339,8 @@ class application(QtGui.QApplication):
propsets.append(process_pset(is_def_by.RelatingPropertyDefinition))
elif is_def_by.is_a("IfcRelDefinesByType"):
type_psets = is_def_by.RelatingType.HasPropertySets
if type_psets is None: continue
if type_psets is None:
continue
for propset in type_psets:
propsets.append(process_pset(propset))
except Exception as e:
@@ -343,7 +351,7 @@ class application(QtGui.QApplication):
if len(propsets):
self.prop_dict[str(p)] = propsets
print ("property set dictionary has {} entries".format(len(self.prop_dict)))
print("property set dictionary has {} entries".format(len(self.prop_dict)))
class viewer(qtViewer3d):
@@ -357,17 +365,20 @@ class application(QtGui.QApplication):
yield ais.Shape()
return
shp = OCC.AIS.Handle_AIS_Shape.DownCast(ais_handle)
if not shp.IsNull(): yield shp.Shape()
if not shp.IsNull():
yield shp.Shape()
return
mult = ais_handle
if mult.IsNull():
shp = OCC.AIS.Handle_AIS_Shape.DownCast(ais_handle)
if not shp.IsNull(): yield shp
if not shp.IsNull():
yield shp
else:
li = mult.GetObject().ConnectedTo()
for i in range(li.Length()):
shp = OCC.AIS.Handle_AIS_Shape.DownCast(li.Value(i+1))
if not shp.IsNull(): yield shp
shp = OCC.AIS.Handle_AIS_Shape.DownCast(li.Value(i + 1))
if not shp.IsNull():
yield shp
return tuple(shp.HashCode(1 << 24) for shp in yield_shapes())
def __init__(self, widget):
@@ -390,7 +401,8 @@ class application(QtGui.QApplication):
v = self._display
t = {0: time.time()}
def update(dt = None):
def update(dt=None):
t1 = time.time()
if t1 - t[0] > (dt or -1):
v.FitAll()
@@ -408,7 +420,8 @@ class application(QtGui.QApplication):
old_progress = -1
while True:
if terminate[0]: break
if terminate[0]:
break
shape = it.get()
product = f[shape.data.id]
ais = display_shape(shape, viewer_handle=v)
@@ -427,13 +440,14 @@ class application(QtGui.QApplication):
break
update(0.2)
print("\rOpened file in %.2f seconds%s" % (time.time() - t0, " "*25))
print("\rOpened file in %.2f seconds%s" % (time.time() - t0, " " * 25))
update()
def select(self, product):
ais = self.product_to_ais.get(product)
if ais is None: return
if ais is None:
return
v = self._display.Context
v.ClearSelected(False)
v.SetSelected(ais, True)
@@ -509,7 +523,6 @@ class application(QtGui.QApplication):
a.triggered.connect(callback)
m.addAction(a)
def makeSelectionHandler(self, component):
def handler(inst):
for c in self.components:
@@ -536,8 +549,8 @@ class application(QtGui.QApplication):
self.editor = code_edit(self.canvas, configuration().options('snippets'))
splitter2.addWidget(self.editor)
splitter.addWidget(splitter2)
splitter.setSizes([200,600])
splitter2.setSizes([400,200])
splitter.setSizes([200, 600])
splitter2.setSizes([400, 200])
self.window.setCentralWidget(splitter)
self.canvas.initialize()
self.components = [self.tree, self.tree2, self.canvas, self.propview, self.editor]
@@ -569,7 +582,7 @@ class application(QtGui.QApplication):
sys.exit(self.exec_())
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)
def clear(self):
@@ -578,11 +591,13 @@ class application(QtGui.QApplication):
self.files.clear()
def load(self, fn):
if fn in self.files: return
if fn in self.files:
return
f = open_ifc_file(str(fn))
self.files[fn] = f
for c in self.components:
c.load_file(f, setting=self.settings)
if __name__ == "__main__":
application().start()
@@ -35,10 +35,10 @@ class StdoutRedirector(object):
'''A class for redirecting stdout to this Text widget.'''
def __init__(self, widget):
self.widget=widget
self.isError = False
self.widget = widget
self.isError = False
def write(self,str):
def write(self, str):
self.widget.moveCursor(QtGui.QTextCursor.End)
if self.isError:
self.widget.setTextColor(QtCore.Qt.red)
@@ -60,7 +60,7 @@ class code_edit(QtGui.QWidget):
def runCode(self):
sys.stdout = StdoutRedirector(self.output)
sys.stderr = StdoutRedirector(self.output)
sys.stderr.isError=True
sys.stderr.isError = True
if not self.model:
print("please load a model first", file=sys.stderr)
@@ -70,15 +70,15 @@ class code_edit(QtGui.QWidget):
sys.stdout = sys.__stdout__
sys.stderr = sys.__stderr__
def select(self,product):
self.c = self.Console({'model':self.model, 'viewer':self.viewer, 'selection':product})
def select(self, product):
self.c = self.Console({'model': self.model, 'viewer': self.viewer, 'selection': product})
def __init__(self,viewer,snippets=None):
def __init__(self, viewer, snippets=None):
self.model=None
self.model = None
self.viewer = viewer
QtGui.QWidget.__init__(self)
self.layout= QtGui.QVBoxLayout(self)
self.layout = QtGui.QVBoxLayout(self)
self.setLayout(self.layout)
self.c = None
@@ -150,5 +150,5 @@ class code_edit(QtGui.QWidget):
output = []
sys.stdout = StdoutRedirector(self.output)
self.model = f
self.c = self.Console({'model':self.model, 'selection':None, 'viewer':self.viewer})
self.c = self.Console({'model': self.model, 'selection': None, 'viewer': self.viewer})
sys.stdout = sys.__stdout__
@@ -28,23 +28,34 @@ from .. import ifcopenshell_wrapper
from ..file import file
from ..entity_instance import entity_instance
def has_occ():
try: import OCC.BRepTools
except: return False
try:
import OCC.BRepTools
except:
return False
return True
has_occ = has_occ()
wrap_shape_creation = lambda settings, shape: shape
def wrap_shape_creation(settings, shape): return shape
if has_occ:
from . import occ_utils as utils
wrap_shape_creation = lambda settings, shape: 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
# setting to enable pythonOCC when available
class settings(ifcopenshell_wrapper.settings):
if has_occ:
USE_PYTHON_OPENCASCADE = -1
def set(self, *args):
setting, value = args
if setting == settings.USE_PYTHON_OPENCASCADE:
@@ -55,6 +66,7 @@ class settings(ifcopenshell_wrapper.settings):
else:
ifcopenshell_wrapper.settings.set(self, *args)
# Hide templating precision to the user by choosing based on Python's
# internal float type. This is probably always going to be a double.
for ty in (ifcopenshell_wrapper.iterator_single_precision, ifcopenshell_wrapper.iterator_double_precision):
@@ -127,7 +139,7 @@ def create_shape(settings, inst, repr=None):
settings,
inst.wrapped_data,
repr.wrapped_data if repr is not None else None
))
))
def iterate(settings, filename):
@@ -135,12 +147,15 @@ def iterate(settings, filename):
if it.initialize():
while True:
yield it.get()
if not it.next(): break
if not it.next():
break
def make_shape_function(fn):
entity_instance_or_none = lambda e: 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:
import OCC.TopoDS
def _(string_or_shape, *args):
if isinstance(string_or_shape, OCC.TopoDS.TopoDS_Shape):
string_or_shape = utils.serialize_shape(string_or_shape)
@@ -150,5 +165,6 @@ def make_shape_function(fn):
return entity_instance_or_none(fn(string, *args))
return _
serialise = make_shape_function(ifcopenshell_wrapper.serialise)
tesselate = make_shape_function(ifcopenshell_wrapper.tesselate)
@@ -30,20 +30,21 @@ shape_tuple = namedtuple('shape_tuple', ('data', 'geometry', 'styles'))
handle, main_loop, add_menu, add_function_to_menu = None, None, None, None
DEFAULT_STYLES = {
"DEFAULT" : (.7 , .7, .7 ),
"IfcWall" : (.8 , .8, .8 ),
"IfcSite" : (.75, .8, .65 ),
"IfcSlab" : (.4 , .4, .4 ),
"IfcWallStandardCase": (.9 , .9, .9 ),
"IfcWall" : (.9 , .9, .9 ),
"IfcWindow" : (.75, .8, .75, .3),
"IfcDoor" : (.55, .3, .15 ),
"IfcBeam" : (.75, .7, .7 ),
"IfcRailing" : (.65, .6, .6 ),
"IfcMember" : (.65, .6, .6 ),
"IfcPlate" : (.8 , .8, .8 )
"DEFAULT": (.7, .7, .7),
"IfcWall": (.8, .8, .8),
"IfcSite": (.75, .8, .65),
"IfcSlab": (.4, .4, .4),
"IfcWallStandardCase": (.9, .9, .9),
"IfcWall": (.9, .9, .9),
"IfcWindow": (.75, .8, .75, .3),
"IfcDoor": (.55, .3, .15),
"IfcBeam": (.75, .7, .7),
"IfcRailing": (.65, .6, .6),
"IfcMember": (.65, .6, .6),
"IfcPlate": (.8, .8, .8)
}
def initialize_display():
import OCC.V3d
import OCC.Display.SimpleGui
@@ -58,8 +59,10 @@ def initialize_display():
def lights():
viewer.InitActiveLights()
while True:
try: active_light = viewer.ActiveLight()
except: break
try:
active_light = viewer.ActiveLight()
except:
break
yield active_light
viewer.NextActiveLights()
@@ -67,7 +70,7 @@ def initialize_display():
for l in lights:
viewer.DelLight(l)
for dir in [(3,2,1), (-1,-2,-3)]:
for dir in [(3, 2, 1), (-1, -2, -3)]:
light = OCC.V3d.V3d_DirectionalLight(viewer_handle)
light.SetDirection(*dir)
viewer.SetLightOn(light.GetHandle())
@@ -75,6 +78,7 @@ def initialize_display():
setup()
return handle
def yield_subshapes(shape):
import OCC.TopoDS
@@ -83,16 +87,19 @@ def yield_subshapes(shape):
yield it.Value()
it.Next()
def display_shape(shape, clr=None, viewer_handle=None):
import OCC.gp
import OCC.AIS
import OCC.Quantity
if viewer_handle is None: viewer_handle = handle
if viewer_handle is None:
viewer_handle = handle
if isinstance(shape, shape_tuple):
shape, representation = shape.geometry, shape
else: representation = None
else:
representation = None
material = OCC.Graphic3d.Graphic3d_MaterialAspect(OCC.Graphic3d.Graphic3d_NOM_PLASTER)
material.SetDiffuse(1)
@@ -150,7 +157,8 @@ def display_shape(shape, clr=None, viewer_handle=None):
# in order for transparency to be rendered on the subshape.
applied_styles = representation.styles
if default_style_applied:
if len(default_style_applied) == 3: default_style_applied += (1.,)
if len(default_style_applied) == 3:
default_style_applied += (1.,)
applied_styles += (default_style_applied,)
if len(applied_styles):
@@ -163,7 +171,7 @@ def display_shape(shape, clr=None, viewer_handle=None):
ais = OCC.AIS.AIS_Shape(shape)
ais.SetMaterial(material)
r = lambda: 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)
ais.SetColor(clr)
@@ -180,9 +188,10 @@ def set_shape_transparency(ais, t):
def get_bounding_box_center(bbox):
import OCC.gp
bbmin = [0.]*3; bbmax = [0.]*3
bbmin = [0.] * 3
bbmax = [0.] * 3
bbmin[0], bbmin[1], bbmin[2], bbmax[0], bbmax[1], bbmax[2] = bbox.Get()
return OCC.gp.gp_Pnt(*map(lambda xy: (xy[0]+xy[1])/2., zip(bbmin, bbmax)))
return OCC.gp.gp_Pnt(*map(lambda xy: (xy[0] + xy[1]) / 2., zip(bbmin, bbmax)))
def serialize_shape(shape):
@@ -192,6 +201,7 @@ def serialize_shape(shape):
shapes.Add(shape)
return shapes.WriteToString()
def create_shape_from_serialization(brep_object):
import OCC.BRepTools
@@ -206,20 +216,22 @@ def create_shape_from_serialization(brep_object):
brep_data = brep_object.brep_data
styles = brep_object.surface_styles
is_product_shape = False
except: pass
except:
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))
if not brep_data: return shape_tuple(brep_object, None, styles)
if not brep_data:
return shape_tuple(brep_object, None, styles)
try:
ss = OCC.BRepTools.BRepTools_ShapeSet()
ss.ReadFromString(brep_data)
occ_shape = ss.Shape(ss.NbShapes())
except: pass
except:
pass
if is_product_shape:
return shape_tuple(brep_object, occ_shape, styles)
else:
return occ_shape
+12 -7
View File
@@ -28,23 +28,28 @@ from functools import reduce
chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + '_$'
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):
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([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)])
def expand(g):
def b64(v):
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
bs = [b64(g[0:2])]
for i in range(5):
d = b64(g[2+4*i:6+4*i])
bs += [(d >> (8*(2-j)))%256 for j in range(3)]
return ''.join(['%02x'%b for b in bs])
d = b64(g[2 + 4 * i:6 + 4 * i])
bs += [(d >> (8 * (2 - j))) % 256 for j in range(3)]
return ''.join(['%02x' % b for b in bs])
def split(g):
return '{%s-%s-%s-%s-%s}'%(g[:8], g[8:12], g[12:16], g[16:20], g[20:])
return '{%s-%s-%s-%s-%s}' % (g[:8], g[8:12], g[12:16], g[16:20], g[20:])
def new():
return compress(uuid.uuid4().hex)
@@ -70,11 +70,13 @@ DEFAULTS = {
"timestring": lambda d: time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(d.get('timestamp') or time.time()))
}
def create(filename=None, timestring=None, organization=None, creator=None,\
schema_identifier=None, application_version=None, timestamp=None,\
def create(filename=None, timestring=None, organization=None, creator=None,
schema_identifier=None, application_version=None, timestamp=None,
application=None, project_globalid=None, project_name=None):
d = dict(locals())
def _():
for var, value in d.items():
if value is None: