def _skin_timer(self): status = self.sender().isChecked() if status: self.skin_timer.start(20000) else: self.skin_timer.stop() om.write(self.local_profile_folder, "random_skin", status)
def change_skin(self): item = self.currentItem() if item: skin_path = item.path.replace("\\", '/') om.write(self.software_gui.local_profile_folder, 'skin', skin_path) self.software_gui.set_background_image_css(skin_path)
def write(ctx, path, value, root): """Write metadata. \b Usage: $ openmetadata write my_variable --value="Hello World" $ openmetadata write another_var --value=5 """ root = os.path.abspath(root) or os.getcwd() openmetadata.write(path=root, metapath=path, value=value) if ctx.obj.get('verbose'): sys.stdout.write("Success")
def write(ctx, path, value, root): """Write metadata. \b Usage: $ openmetadata write my_variable --value="Hello World" $ openmetadata write another_var --value=5 """ try: root = os.path.abspath(root) except (AttributeError, TypeError): root = os.getcwd() openmetadata.write(path=root, metapath=path, value=value) if ctx.obj.get('verbose'): sys.stdout.write("Success")
def test_integration(self): """Test a combination of features""" entry = om.Entry('test.string', value="Hello", parent=self.root) child = om.Entry('child.int', value=1, parent=entry) self.assertEquals(entry.type, 'dict') om.flush(entry) self.assertTrue(os.path.exists(entry.path.as_str)) om.pull(entry) self.assertEquals(entry.type, 'dict') entry.value = "Hello" self.assertEquals(entry.type, 'string') self.assertEquals(entry.value, "Hello") om.flush(entry) om.pull(entry) self.assertFalse(os.path.exists(child.path.as_str)) child = om.Entry('child.int', value=1, parent=entry) om.flush(entry) self.assertEquals(om.read(self.root_path, 'test/child'), 1) om.write(self.root_path, '/test/child', 2) self.assertEquals(om.read(self.root_path, 'test/child'), 2) om.write(self.root_path, '/root/test/another', 10) self.assertEquals(om.read(self.root_path, 'root/test/another'), 10)
raise NotImplementedError import os import time import openmetadata as om om.setup_log() # Starting-point path = os.path.expanduser(r'~/om') # Add and modify data, with 1.2 seconds inbetween changes. # *note: History is stored in seconds. Any changes occuring within # 1 second will be overwritten. Not what you want? Let us know. # https://groups.google.com/forum/#!forum/open-metadata om.write(path, 'girlfriend', 'Lucy Lui') print "Sleeping for 1.2 seconds.." time.sleep(1.2) om.write(path, 'girlfriend', 'Sandra Bullock') assert om.read(path, 'girlfriend') == 'Sandra Bullock' # To get the history, we must first get an # instance of the Dataset 'girlfriend' dataset = om.read(path, 'girlfriend', convert=False) imprint = next(om.history(dataset)) om.restore(imprint, removehistory=False) assert om.read(path, 'girlfriend') == 'Lucy Lui'
metadata where requirements in functionality and performance are low; such as in debugging or one-off reading/writing. """ import shutil import tempfile import openmetadata as om om.setup_log('openmetadata') # Starting-point root = tempfile.mkdtemp() try: om.write(root, 'status', True) om.write(root, 'story', 'There once was a boy') om.write(root, 'age', 27) data = { 'firstname': 'Marcus', 'lastname': 'Ottosson', 'email': '*****@*****.**' } for key, value in data.iteritems(): om.write(root, key, value) # Write deeply nested data om.write(root, '/root/group/amazing', True)
import os import shutil import tempfile import openmetadata as om # om.setup_log() # <-- Uncomment this line to get debug information try: root = tempfile.mkdtemp() level1 = root level2 = os.path.join(level1, 'level2') level3 = os.path.join(level2, 'level3') om.write(level1, '/address/street', value='Code Street 5') om.write(level1, '/address/postcode', value='Level 1 postcode') om.write(level2, '/address/city', value='Code City') om.write(level2, '/address/postcode', value='Level 2 postcode') assert os.path.exists(os.path.join(level1, '.meta')) assert os.path.exists(os.path.join(level2, '.meta')) # Now that we have written a hierarchy of values, # let's try and reach `street` from level2, even # though `street` resides in level1 location = om.Location(level2) om.pull(location) address = location['address'] om.pull(address)
def test_write_simple(self): om.write(self.root_path, 'simple', 'value') self.assertEquals(om.read(self.root_path, 'simple'), 'value')
def test_write_invalidgroup(self): om.write(self.root_path, '/deep/data.string/key', 'value') self.assertEquals(om.read(self.root_path, '/deep/data/key'), 'value')
def save_current_project(self): project_name = self.comboBox_project_list.currentText() om.write(self.local_profile_folder, 'project', project_name)
def set_background_image_action(self): skin_path = self.sender().data() om.write(self.local_profile_folder, 'skin', skin_path) self.set_background_image_css(skin_path.replace("\\", '/'))
def save_current_name(self, value): om.write(self.parent.local_profile_folder, '%s_%s' % (self.app.project_name, self.app.name), value)
def test_write_deep(self): om.write(self.root_path, '/deep/data/key', 'value') self.assertEquals(om.read(self.root_path, '/deep/data/key'), 'value')
"""Wrap Open Metadata""" import logging import openmetadata log = logging.getLogger('openmetadata') log.setLevel(logging.CRITICAL) write = lambda path, key, value: openmetadata.write(path, key, value) read = lambda path, key: openmetadata.read(path, key)