Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup handling of empty lines

  • Loading branch information...
commit 7b52530fd5c36b955fc437e545f7cfedc027dff8 1 parent d3732aa
Erik Johansson authored
Showing with 9 additions and 16 deletions.
  1. +6 −9 svndump/record.py
  2. +3 −7 svndump/section.py
15 svndump/record.py
View
@@ -65,14 +65,13 @@ def write(self, stream):
self.headers[self.PROP_CONTENT_LENGTH] = prop_length
self.headers[self.CONTENT_LENGTH] = prop_length
- self.headers.write(stream)
+ Record.write(self, stream)
self.properties.write(stream)
stream.writeline()
@staticmethod
def read(headers, stream):
properties = PropertySection.read(stream)
- empty_line = stream.readline()
return RevisionRecord(headers, properties)
class NodeRecord(Record):
@@ -115,18 +114,19 @@ def write(self, stream):
text_length = len(self.content)
self.headers[self.TEXT_CONTENT_LENGTH] = text_length
- self.headers[self.CONTENT_LENGTH] = prop_length + text_length
- self.headers.write(stream)
+ if self.properties is not None or self.content is not None:
+ self.headers[self.CONTENT_LENGTH] = prop_length + text_length
+
+ Record.write(self, stream)
if self.properties is not None:
self.properties.write(stream)
if self.content is not None:
self.content.write(stream)
- else:
- stream.writeline()
stream.writeline()
+ stream.writeline()
@staticmethod
def read(headers, stream):
@@ -138,8 +138,5 @@ def read(headers, stream):
if NodeRecord.TEXT_CONTENT_LENGTH in headers:
content = Content.read(
stream, headers[NodeRecord.TEXT_CONTENT_LENGTH])
- else:
- empty_line = stream.readline()
- empty_line = stream.readline()
return NodeRecord(headers, properties, content)
10 svndump/section.py
View
@@ -39,8 +39,6 @@ def read(stream):
except EOFError:
if len(headers) != 0:
raise
- else:
- return None
if len(headers) == 0:
return None
return HeaderSection(headers)
@@ -109,7 +107,7 @@ def read(stream):
return None
if (line[0] != 'K' and line[0] != 'D'):
- stream.error("invalid property line")
+ stream.error("invalid property key line")
def read_segment(stream, line):
length = int(line[2:])
@@ -125,7 +123,7 @@ def read_segment(stream, line):
if line[0] == 'K':
line = stream.readline()
if line[0] != 'V':
- stream.error("line is not property value")
+ stream.error("invalid property value line")
value = read_segment(stream, line)
return Property(key, value)
@@ -144,7 +142,7 @@ def __len__(self):
return length
def __iter__(self):
- return self.properties.__iter__()
+ return iter(self.properties)
def __delitem__(self, key):
for property in self.properties:
@@ -191,7 +189,6 @@ def __next__(self):
data = self.stream.read(readSize, self)
self.length -= len(data)
if self.length == 0:
- empty_line = self.stream.readline(self)
self.stream.unblock(self)
if len(data) != readSize:
@@ -206,7 +203,6 @@ def discard(self):
def write(self, stream):
for data in self:
stream.write(data)
- stream.writeline()
@staticmethod
def read(stream, length):
Please sign in to comment.
Something went wrong with that request. Please try again.