本文整理汇总了Python中workflow.Workflow.stored_data方法的典型用法代码示例。如果您正苦于以下问题:Python Workflow.stored_data方法的具体用法?Python Workflow.stored_data怎么用?Python Workflow.stored_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类workflow.Workflow
的用法示例。
在下文中一共展示了Workflow.stored_data方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RatesCurrencyTest
# 需要导入模块: from workflow import Workflow [as 别名]
# 或者: from workflow.Workflow import stored_data [as 别名]
class RatesCurrencyTest(unittest.TestCase):
def setUp(self):
self.wf = Workflow()
self.wf.clear_settings()
self.wf.clear_data()
self.wf.clear_cache()
rates.log = self.wf.logger
def tearDown(self):
pass
def testLoadCurrencyInfo(self):
currency_info = rates.get_currencies()
# Checks if all itens have all info that is used by the script
for currency, info in currency_info.iteritems():
self.assertIn('Id', info, 'No ID for currency {}'.format(info))
self.assertTrue(info['Id'], 'None ID specified for currency {}'.format(info))
self.assertIn('Name', info, 'No Name for currency {}'.format(info))
self.assertTrue(info['Name'], 'No Name for currency {}'.format(info))
self.assertIn('Code', info, 'No Code for currency {}'.format(info))
self.assertTrue(info['Code'], 'No Code for currency {}'.format(info))
self.assertIn('Simbol', info, 'No Simbol for currency {}'.format(info))
self.assertTrue(info['Simbol'], 'No Simbol for currency {}'.format(info))
self.assertIn('Country', info, 'No Country for currency {}'.format(info))
self.assertTrue(info['Country'], 'No Country for currency {}'.format(info))
self.assertIn('Flag', info, 'No Flag for currency {}'.format(info))
def test_is_float(self):
tests = [(1, True),
('asd', False),
(1.5, True),
('1', True),
('1', True)]
for test in tests:
self.assertEqual(rates.is_float(test[0]), test[1])
def test_validate_currencies(self):
currencies = rates.get_currencies()
self.assertTrue(rates.validate_currencies([], 'BRL', 'USD', currencies, self.wf))
self.assertFalse(rates.validate_currencies([], 'BRL', 'USDD', currencies, self.wf))
self.assertFalse(rates.validate_currencies([], 'BRLL', 'USD', currencies, self.wf))
def test_clear_caches(self):
self.wf.cache_data('test_cache', 'testing cache')
self.wf.store_data('test_store', 'testing store')
with patch.object(sys, 'argv', 'program --clear'.split()):
rates.main(self.wf)
self.assertEqual(len(self.wf._items), 1)
self.assertEqual(self.wf._items[0].title, 'Caches cleared!')
self.assertIsNone(self.wf.stored_data('test_store'))
self.assertIsNone(self.wf.cached_data('test_cache'))
def test_evaluate_math(self):
tests = [
(['100*3', '100'], ['300', '100']),
(['135.3*2', '234.5-5'], ['270.6', '229.5']),
(['123/2', '61.5*50'], ['61.5', '3075.0']),
(['123.5*2.5'], ['308.75']),
# (['123', '/2', '61.5*50'], ['61.5', '3075.0']),
# (['123', '/', '2', '61.5*50'], ['61.5', '3075.0']),
# (['123', '/2', '/', '2', '61.5*50'], ['30.75', '3075.0']),
# (['123', '/2', '/', '2', '61.5*50', '/3', '*2'], ['30.75', '2050.0'])
# (['123*', '2'], ['246'])
# (['100*2', 'usd', 'brl'], ['200', 'usd', 'brl'])
]
for t in tests:
result = rates.evaluate_math(t[0])
self.assertEqual(result, t[1])
def test_fmt_number(self):
tests = [
('100.00', '.', '100.00'),
('100.00', ',', '100,00'),
('1.000,00', '.', '1,000.00'),
('100', None, '100')
]
for t in tests:
result = rates.fmt_number(t[0], t[1])
self.assertEqual(result, t[2])
示例2: Workflow
# 需要导入模块: from workflow import Workflow [as 别名]
# 或者: from workflow.Workflow import stored_data [as 别名]
TABLENAME = "unit_alfred_workflow"
INIT_TABLE = {("MB", "B"): 1024 * 1024,
("MB", "KB"): 1024,
("MB", "GB"): 1/1024,
("B", "KB"): 1/1024,
("B", "MB"): 1/1024 * 1/1024,
("B", "GB"): 1/1024 * 1/1024 * 1/1024,
("KB", "B"): 1024,
("KB", "MB"): 1/1024,
("KB", "GB"): 1/1024 * 1/1024,
("GB", "B"): 1/1024 * 1/1024 * 1/1024,
("GB", "KB"): 1/1024 * 1/1024,
("GB", "MB"): 1/1024}
wf = Workflow()
if wf.stored_data(TABLENAME) is None:
wf.store_data(TABLENAME, INIT_TABLE)
TABLE = wf.stored_data(TABLENAME)
ACTION_PATTERN = r'^(?P<number>\d+(\.\d+)*)(?P<type>[a-zA-Z]+)$'
def next_action(query):
matched = re.match(ACTION_PATTERN, query)
if matched is None:
return 0, "***"
typo = matched.group("type").upper()
if typo in [f for (f, _) in TABLE.keys()]:
return float(matched.group("number")), typo
return float(matched.group("number")), "***"
示例3: yt_title
# 需要导入模块: from workflow import Workflow [as 别名]
# 或者: from workflow.Workflow import stored_data [as 别名]
else:
wf.store_data(params[0], params[1])
print "Saved %s sucesfully!" % yt_title(params[0])
sys.exit()
if params[1] == '':
wf.add_item('Please enter your YouTrack %s' % yt_title(params[0]),subtitle=u'Cannot be empty!', icon=ICON_SETTINGS)
else:
wf.add_item('Set your YouTrack %s to \'%s\'' % (yt_title(params[0]),params[1]),
subtitle=u'Hit enter to set.',
icon=ICON_SETTINGS,
arg=wf.pargs.set + SEPARATOR,
valid=True)
wf.send_feedback()
settings = {}
settings['yt_url'] = wf.stored_data('yt_url')
settings['yt_username'] = wf.stored_data('yt_username')
try:
settings['yt_password'] = wf.get_password(u'yt_password')
except:
settings['yt_password'] = None
missing_settings = {key: value for (key, value) in settings.iteritems() if not value}
if len(missing_settings.keys()):
for k in missing_settings:
wf.add_item(u'Youtrack %s not set.' % yt_title(k),
subtitle='Set your Youtrack %s' % yt_title(k),
modifier_subtitles={'cmd':'Please don\' press cmd on the settings option, there be dragons'},
arg='%s' % k.lower(),
valid=True,
icon=ICON_SETTINGS)
wf.send_feedback()
示例4: wrapped
# 需要导入模块: from workflow import Workflow [as 别名]
# 或者: from workflow.Workflow import stored_data [as 别名]
def wrapped(*args, **kwargs):
wf = Workflow()
yt_conn = Connection(wf.stored_data('yt_url'), wf.stored_data('yt_username'), wf.get_password(u'yt_password'))
r = f(*args, yt_conn = yt_conn, **kwargs)
return r
示例5: Workflow
# 需要导入模块: from workflow import Workflow [as 别名]
# 或者: from workflow.Workflow import stored_data [as 别名]
#!/usr/bin/python
# encoding: utf-8
import sys
from workflow import Workflow
from peewee import *
from glob import iglob
import json
import os
from playhouse.sqlite_ext import SqliteExtDatabase, SearchField, FTSModel
import datetime
wf = Workflow()
libpath = wf.stored_data('library_location')
db = SqliteExtDatabase("quiver.db")
if os.path.exists("quiver.db"):
os.remove("quiver.db")
# Create the database
class Note(Model):
uuid = CharField()
title = CharField(index = True)
notebook = CharField(index = True)
last_modified = DateTimeField()
class Meta:
database = db
class NoteIndex(FTSModel):
uuid = CharField()