Skip to content

shadowmint/python-nark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Helpful python utils.

enum

value = enum("X", "Y")
x = value.X
y = value.Y

bitflags

value = bitflags("X", "Y")
compound = value.X | value.Y

Logging

log = Logging.get()
log.info("Common logging format for all files")

Factory

factory = Factory()
factory.load("blah.py")
try:
  value = factory.prop("module_property")
except Exception:
  e = exception()  # python2.x and python3.x supported

Assets

assets = Assets("basepath/static")
if assets.exists("dir", "dir", "file"):
  path = assets.resolve("dir", "dir", "file")

implements, resolve, Scope

class IType(object):
  prop1 = None
  def call(self):
    pass

@implements(IType)
class ImplType(object):
  prop1 = "Value"
  def call(self):
    pass

scope = Scope()
scope.register(ImplType)

@resolve(scope)
class UsesType(object):
  def __init__(self, t=IType):
    self.t = t

i = UsesType()
i.t.call()

Dynamic

d = Dynamic()
d.x.y.value = "Hello World"
as_dict = dict(iter(d))
d2 = Dynamic(as_dict)

run

run("ls", "-al")

Running tests...

Use:

python tests/nark/dynamic_tests.py

or:

tests/runner

About

Helpful python toolkit supporting python2.x, python3.x and pypy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published