Skip to content

Commit

Permalink
Renamed b_uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-serdyuk committed Jul 20, 2015
1 parent 0b1ceb4 commit 8c5e083
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions blocks/log/log.py
Expand Up @@ -64,7 +64,7 @@ def __init__(self, uuid=None):
})

@property
def b_uuid(self):
def h_uuid(self):
"""Return a hexadecimal version of the UUID bytes.
This is necessary to store ids in an SQLite database.
Expand All @@ -79,7 +79,7 @@ def resume(self):
copies the status of the old log into the new log.
"""
old_uuid = self.b_uuid
old_uuid = self.h_uuid
old_status = dict(self.status)
self.uuid = uuid4()
self.status.update(old_status)
Expand Down
24 changes: 12 additions & 12 deletions blocks/log/sqlite.py
Expand Up @@ -167,13 +167,13 @@ def __getitem__(self, time):
def __iter__(self):
return map(itemgetter(0), self.conn.execute(
ANCESTORS_QUERY + "SELECT DISTINCT time FROM entries "
"WHERE uuid IN ancestors ORDER BY time ASC", (self.b_uuid,)
"WHERE uuid IN ancestors ORDER BY time ASC", (self.h_uuid,)
))

def __len__(self):
return self.conn.execute(
ANCESTORS_QUERY + "SELECT COUNT(DISTINCT time) FROM entries "
"WHERE uuid IN ancestors ORDER BY time ASC", (self.b_uuid,)
"WHERE uuid IN ancestors ORDER BY time ASC", (self.h_uuid,)
).fetchone()[0]


Expand All @@ -184,7 +184,7 @@ def __init__(self, log):
def __getitem__(self, key):
row = self.log.conn.execute(
"SELECT value FROM status WHERE uuid = ? AND key = ?",
(self.log.b_uuid, key)
(self.log.h_uuid, key)
).fetchone()
return _get_row(row, key)

Expand All @@ -193,25 +193,25 @@ def __setitem__(self, key, value):
with self.log.conn:
self.log.conn.execute(
"INSERT OR REPLACE INTO status VALUES (?, ?, ?)",
(self.log.b_uuid, key, value)
(self.log.h_uuid, key, value)
)

def __delitem__(self, key):
with self.log.conn:
self.log.conn.execute(
"DELETE FROM status WHERE uuid = ? AND key = ?",
(self.log.b_uuid, key)
(self.log.h_uuid, key)
)

def __len__(self):
return self.log.conn.execute(
"SELECT COUNT(*) FROM status WHERE uuid = ?",
(self.log.b_uuid,)
(self.log.h_uuid,)
).fetchone()[0]

def __iter__(self):
return map(itemgetter(0), self.log.conn.execute(
"SELECT key FROM status WHERE uuid = ?", (self.log.b_uuid,)
"SELECT key FROM status WHERE uuid = ?", (self.log.h_uuid,)
))


Expand All @@ -237,7 +237,7 @@ def __getitem__(self, key):
# JOIN statement should sort things so that the latest is returned
"JOIN ancestors ON entries.uuid = ancestors.parent "
"WHERE uuid IN ancestors AND time = ? AND key = ?",
(self.log.b_uuid, self.time, key)
(self.log.h_uuid, self.time, key)
).fetchone()
return _get_row(row, key)

Expand All @@ -246,26 +246,26 @@ def __setitem__(self, key, value):
with self.log.conn:
self.log.conn.execute(
"INSERT OR REPLACE INTO entries VALUES (?, ?, ?, ?)",
(self.log.b_uuid, self.time, key, value)
(self.log.h_uuid, self.time, key, value)
)

def __delitem__(self, key):
with self.log.conn:
self.log.conn.execute(
"DELETE FROM entries WHERE uuid = ? AND time = ? AND key = ?",
(self.log.b_uuid, self.time, key)
(self.log.h_uuid, self.time, key)
)

def __len__(self):
return self.log.conn.execute(
ANCESTORS_QUERY + "SELECT COUNT(*) FROM entries "
"WHERE uuid IN ancestors AND time = ?",
(self.log.b_uuid, self.time,)
(self.log.h_uuid, self.time,)
).fetchone()[0]

def __iter__(self):
return map(itemgetter(0), self.log.conn.execute(
ANCESTORS_QUERY + "SELECT key FROM entries "
"WHERE uuid IN ancestors AND time = ?",
(self.log.b_uuid, self.time,)
(self.log.h_uuid, self.time,)
))

0 comments on commit 8c5e083

Please sign in to comment.