コード例 #1
0
ファイル: main.py プロジェクト: GrandLoong/software_manager
 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)
コード例 #2
0
ファイル: skin.py プロジェクト: tws0002/software_manager
 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)
コード例 #3
0
 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)
コード例 #4
0
ファイル: cli.py プロジェクト: EriLee/openmetadata
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")
コード例 #5
0
ファイル: cli.py プロジェクト: lepy/openmetadata
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")
コード例 #6
0
    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)
コード例 #7
0
ファイル: test_entry_write.py プロジェクト: lepy/openmetadata
    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)
コード例 #8
0
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'
コード例 #9
0
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)
コード例 #10
0
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)
コード例 #11
0
 def test_write_simple(self):
     om.write(self.root_path, 'simple', 'value')
     self.assertEquals(om.read(self.root_path, 'simple'), 'value')
コード例 #12
0
 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')
コード例 #13
0
 def save_current_project(self):
     project_name = self.comboBox_project_list.currentText()
     om.write(self.local_profile_folder, 'project', project_name)
コード例 #14
0
 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("\\", '/'))
コード例 #15
0
ファイル: item.py プロジェクト: GrandLoong/software_manager
 def save_current_name(self, value):
     om.write(self.parent.local_profile_folder,
              '%s_%s' % (self.app.project_name, self.app.name), value)
コード例 #16
0
ファイル: main.py プロジェクト: GrandLoong/software_manager
 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("\\", '/'))
コード例 #17
0
ファイル: main.py プロジェクト: GrandLoong/software_manager
 def save_current_project(self):
     project_name = self.comboBox_project_list.currentText()
     om.write(self.local_profile_folder, 'project', project_name)
コード例 #18
0
 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')
コード例 #19
0
ファイル: metadata.py プロジェクト: pyblish/pyblish-napoleon
"""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)
コード例 #20
0
ファイル: metadata.py プロジェクト: pyblish/pyblish-napoleon
"""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)