Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """ Tablib - General Helpers.
  4. """
  5.  
  6. import sys
  7.  
  8.  
  9. class Struct(object):
  10. """Your attributes are belong to us."""
  11.  
  12. def __init__(self, **entries):
  13. self.__dict__.update(entries)
  14.  
  15. def __getitem__(self, key):
  16. return getattr(self, key, None)
  17.  
  18. def dictionary(self):
  19. """Returns dictionary representation of object."""
  20. return self.__dict__
  21.  
  22.  
  23. def items(self):
  24. """Returns items within object."""
  25. return self.__dict__.items()
  26.  
  27. def keys(self):
  28. """Returns keys within object."""
  29. return self.__dict__.keys()
  30.  
  31.  
  32. def piped():
  33. """Returns piped input via stdin, else False."""
  34. with sys.stdin as stdin:
  35. # TTY is only way to detect if stdin contains data
  36. return stdin.read() if not stdin.isatty() else None
Add Comment
Please, Sign In to add comment