CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
hippyaddtobaddatafiles.KeepWhileOpenFile Class Reference
Inheritance diagram for hippyaddtobaddatafiles.KeepWhileOpenFile:
hippyaddtobaddatafiles.OneAtATime

Public Member Functions

def __enter__ (self)
 
def __exit__ (self, *args)
 
def __init__ (self, name, message=None)
 
def __nonzero__ (self)
 
def wouldbevalid (self)
 

Public Attributes

 bool
 
 f
 
 fd
 
 filename
 
 pwd
 

Private Member Functions

def __open (self)
 

Private Attributes

 __message
 

Detailed Description

Definition at line 51 of file hippyaddtobaddatafiles.py.

Constructor & Destructor Documentation

◆ __init__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__init__ (   self,
  name,
  message = None 
)

Definition at line 52 of file hippyaddtobaddatafiles.py.

52  def __init__(self, name, message=None):
53  self.filename = name
54  self.__message = message
55  self.pwd = os.getcwd()
56  self.fd = self.f = None
57  self.bool = False
58 

Member Function Documentation

◆ __enter__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__enter__ (   self)

Reimplemented in hippyaddtobaddatafiles.OneAtATime.

Definition at line 68 of file hippyaddtobaddatafiles.py.

68  def __enter__(self):
69  with cd(self.pwd):
70  try:
71  self.__open()
72  except OSError:
73  return None
74 
75  self.f = os.fdopen(self.fd, 'w')
76 
77  try:
78  if self.__message is not None:
79  self.f.write(self.__message+"\n")
80  except IOError:
81  pass
82  try:
83  self.f.close()
84  except IOError:
85  pass
86  self.bool = True
87  return True
88 

References hippyaddtobaddatafiles.KeepWhileOpenFile.__message, hippyaddtobaddatafiles.KeepWhileOpenFile.__open(), hippyaddtobaddatafiles.KeepWhileOpenFile.bool, hippyaddtobaddatafiles.cd(), hippyaddtobaddatafiles.KeepWhileOpenFile.f, hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.pwd, and writeEcalDQMStatus.write.

◆ __exit__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__exit__ (   self,
args 
)

Definition at line 89 of file hippyaddtobaddatafiles.py.

89  def __exit__(self, *args):
90  if self:
91  try:
92  with cd(self.pwd):
93  os.remove(self.filename)
94  except OSError:
95  pass #ignore it
96  self.fd = self.f = None
97  self.bool = False
98 

References hippyaddtobaddatafiles.KeepWhileOpenFile.bool, hippyaddtobaddatafiles.cd(), hippyaddtobaddatafiles.KeepWhileOpenFile.f, hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.filename, dataset.DataFile.filename, and hippyaddtobaddatafiles.KeepWhileOpenFile.pwd.

◆ __nonzero__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__nonzero__ (   self)

Definition at line 99 of file hippyaddtobaddatafiles.py.

99  def __nonzero__(self):
100  return self.bool
101 

References hippyaddtobaddatafiles.KeepWhileOpenFile.bool.

Referenced by Types.bool.__bool__().

◆ __open()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__open (   self)
private

Definition at line 65 of file hippyaddtobaddatafiles.py.

65  def __open(self):
66  self.fd = os.open(self.filename, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
67 

References hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.filename, and dataset.DataFile.filename.

Referenced by hippyaddtobaddatafiles.KeepWhileOpenFile.__enter__().

◆ wouldbevalid()

def hippyaddtobaddatafiles.KeepWhileOpenFile.wouldbevalid (   self)

Definition at line 60 of file hippyaddtobaddatafiles.py.

60  def wouldbevalid(self):
61  if self: return True
62  with self:
63  return bool(self)
64 

References hippyaddtobaddatafiles.KeepWhileOpenFile.bool.

Member Data Documentation

◆ __message

hippyaddtobaddatafiles.KeepWhileOpenFile.__message
private

◆ bool

hippyaddtobaddatafiles.KeepWhileOpenFile.bool

◆ f

hippyaddtobaddatafiles.KeepWhileOpenFile.f

◆ fd

hippyaddtobaddatafiles.KeepWhileOpenFile.fd

◆ filename

hippyaddtobaddatafiles.KeepWhileOpenFile.filename

◆ pwd

hippyaddtobaddatafiles.KeepWhileOpenFile.pwd
electrons_cff.bool
bool
Definition: electrons_cff.py:393
CommonMethods.__nonzero__
__nonzero__
Definition: CommonMethods.py:139
writeEcalDQMStatus.write
write
Definition: writeEcalDQMStatus.py:48
hippyaddtobaddatafiles.cd
def cd(newdir)
Definition: hippyaddtobaddatafiles.py:40