MCPcopy Index your code
hub / github.com/USArmyResearchLab/Dshell / _increment_filename

Method _increment_filename

dshell/output/output.py:116–131  ·  view source on GitHub ↗

Used with the noclobber argument. Creates a distinct filename by appending a sequence number.

(self, filename)

Source from the content-addressed store, hash-verified

114 self.format = fmt
115
116 def _increment_filename(self, filename):
117 """
118 Used with the noclobber argument.
119 Creates a distinct filename by appending a sequence number.
120 """
121 try:
122 while os.stat(filename):
123 p = filename.rsplit('-', 1)
124 try:
125 p, n = p[0], int(p[1])
126 except ValueError:
127 n = 0
128 filename = '-'.join(p + ['%04d' % (int(n) + 1)])
129 except OSError:
130 pass # file not found
131 return filename
132
133 def setup(self):
134 """

Callers 2

__init__Method · 0.95
reset_fhMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected