def test_list(self): self.assertEqual( prose.read(((), "1", '"hi"', "x")), { "underlying": ({ 'underlying': (), 'display': "()", "scope": {} }, { "underlying": 1, "display": "1", "scope": {} }, { "underlying": "hi", "display": '"hi"', "scope": {} }, { "underlying": "x", "display": "x", "scope": {} }), "display": '(() 1 "hi" x)', "scope": {} })
def test_int(self): self.assertEqual(prose.read(INT), { "underlying": int(INT), "display": INT, "scope": {} })
#!/usr/bin/env python3 import unittest from doctest import testmod import __init__ as prose INT = "1" STR = '"hi"' VAR = "x" LIST = (prose.read(()), INT, STR, VAR) class Test_entry_is_int(unittest.TestCase): def test_empty_list(self): self.assertFalse(prose.entry_is_int(())) def test_int(self): self.assertTrue(prose.entry_is_int(INT)) def test_str(self): self.assertFalse(prose.entry_is_int(STR)) def test_var(self): self.assertFalse(prose.entry_is_int(VAR)) def test_list(self): self.assertFalse(prose.entry_is_int(LIST)) class Test_entry_is_str(unittest.TestCase): def test_empty_list(self):
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["version"] path = os.path.join(REPO, "version.txt") if os.path.exists(path) and os.path.isfile(path): version = read(path) else: if __name__ == "__main__": print("%s NOT EXISTS" % path) if "VERSION" in os.environ: version = os.environ["VERSION"] if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["url"] path = os.path.join(REPO, "url.txt") if os.path.exists(path) and os.path.isfile(path): url = read(path) else: if __name__ == "__main__": print("SKIP: %s NOT EXISTS" % path) if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))
help="full path for python modules import path.") parser.add_argument( "--list_imppath", type=list, help='list "a b c" of full path for python modules import path.') args = parser.parse_args() usage = 'Usage: python {} [config_file_path]'.format(__file__) # config file if args.config: configfilepath = args.config else: configfilepath = os.getcwd() + '/config.toml' # additional import path if args.imppath: sys.path.append(args.imppath) if args.list_imppath: for path in list_imppath: sys.path.append(args.imppath) ''' if len(sys.argv) > 1: configfilepath = sys.argv[1] else: configfilepath = os.getcwd()+'/config.toml' ''' sensorhandler.read(configfilepath)
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["keywords"] path = os.path.join(REPO, "keywords.txt") # separated by " " space if os.path.exists(path) and os.path.isfile(path): keywords = read(path) else: if __name__ == "__main__": print("SKIP: %s NOT EXISTS" % path) if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))
def test_str(self): self.assertTrue(prose.value_is_str(prose.read(STR)))
def test_var(self): self.assertFalse(prose.value_is_str(prose.read(VAR)))
def test_empty_list(self): self.assertFalse(prose.value_is_str(prose.read(())))
def test_int(self): self.assertFalse(prose.value_is_str(prose.read(INT)))
def test_str(self): self.assertFalse(prose.value_is_int(prose.read(STR)))
def test_int(self): self.assertTrue(prose.value_is_int(prose.read(INT)))
def test_list(self): self.assertTrue(prose.value_is_list(prose.read(LIST)))
def test_str(self): self.assertEqual(prose.read(STR), { "underlying": eval(STR), "display": STR, "scope": {} })
def test_list(self): self.assertFalse(prose.value_is_str(prose.read(LIST)))
def test_var(self): self.assertEqual(prose.read(VAR), { "underlying": VAR, "display": VAR, "scope": {} })
def test_empty_list(self): self.assertEqual(prose.evaluate(prose.read(())), prose.read(()))
def test_empty_list(self): self.assertTrue(prose.value_is_list(prose.read(())))
def test_int(self): self.assertEqual(prose.evaluate(prose.read(INT)), prose.read(INT))
# -*- coding: utf-8 -*- # original: https://raw.githubusercontent.com/UedaTakeyuki/slider/master/mh_z19.py # # © Takeyuki UEDA 2015 - import __init__ as mh_z19 value = mh_z19.read() print (value)
def test_var(self): prose.variables[VAR] = prose.evaluate(prose.read(INT)) self.assertEqual(prose.evaluate(prose.read(VAR)), prose.read(INT)) del prose.variables[VAR]
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["description"] description = None filenames = ["description", "description.txt"] # ./description, ./description.txt for filename in filenames: path = os.path.join(REPO, filename) if os.path.exists(path) and os.path.isfile(path): description = read(path) if description is None and __name__ == "__main__": print("SKIP: %s NOT EXISTS" % ", ".join(filenames)) if not description and "DESCRIPTION" in os.environ: description = os.environ["DESCRIPTION"] if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))
def test_str(self): self.assertEqual(prose.evaluate(prose.read(STR)), prose.read(STR))
''' # additional import path ''' if args.imppath: sys.path.append(args.imppath) ''' if args.imppaths: for imppath in args.imppaths: sys.path.append(imppath) ''' if len(sys.argv) > 1: configfilepath = sys.argv[1] else: configfilepath = os.getcwd()+'/config.toml' ''' if args.interval: while True: now = datetime.datetime.now() pondslider.read(args.config) pondslider.read2(args.sensor_handlers, args.value_handlers) now_after = datetime.datetime.now() elapsed = (now_after - now).seconds + float( (now_after - now).microseconds) / 1000000 if (elapsed < args.interval * 60): time.sleep(args.interval * 60 - elapsed) else: pondslider.read(args.config) pondslider.read2(args.sensor_handlers, args.value_handlers)
def test_empty_list(self): self.assertEqual(prose.read(()), { "underlying": (), "display": "()", "scope": {} })
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["long_description"] for name in ["README.rst", "README", "README.txt"]: fullpath = os.path.join(REPO, name) if not os.path.exists(fullpath): continue if not os.path.isfile(fullpath): continue long_description = read(fullpath) break if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))
#!/usr/bin/env python # -*- coding: utf-8 -*- import os from __init__ import REPO, read __all__ = ["platforms"] path = os.path.join(REPO, "platforms.txt") if os.path.exists(path) and os.path.isfile(path): platforms = read(path) else: if __name__ == "__main__": print("SKIP: %s NOT EXISTS" % path) if __name__ == "__main__": for k in __all__: if k in globals(): print("%s: %s" % (k, globals()[k]))