Skip to content

Commit

Permalink
Merge pull request #3 from sandnon/master
Browse files Browse the repository at this point in the history
Change import mode to make it more reusable
  • Loading branch information
konomae committed Jan 29, 2014
2 parents 40c1ae3 + e672287 commit 1037f85
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions lastpass/blob.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# coding: utf-8
import lastpass

import fetcher

class Blob(object):
def __init__(self, bytes, key_iteration_count):
self.bytes = bytes
self.key_iteration_count = key_iteration_count

def encryption_key(self, username, password):
return lastpass.Fetcher.make_key(username, password, self.key_iteration_count)
return fetcher.Fetcher.make_key(username, password, self.key_iteration_count)

def __eq__(self, other):
return self.bytes == other.bytes and self.key_iteration_count == other.key_iteration_count
8 changes: 4 additions & 4 deletions lastpass/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import requests
#from lxml import etree
from xml.etree import ElementTree as etree
from lastpass.blob import Blob
from lastpass.exceptions import (
import blob
from exceptions import (
NetworkError,
InvalidResponseError,
UnknownResponseSchemaError,
Expand All @@ -16,7 +16,7 @@
LastPassIncorrectYubikeyPasswordError,
LastPassUnknownError
)
from lastpass.session import Session
from session import Session


class Fetcher(object):
Expand All @@ -33,7 +33,7 @@ def fetch(cls, session, web_client=requests):
if response.status_code != httplib.OK:
raise NetworkError()

return Blob(cls.decode_blob(response.content), session.key_iteration_count)
return blob.Blob(cls.decode_blob(response.content), session.key_iteration_count)

@classmethod
def request_iteration_count(cls, username, web_client=requests):
Expand Down
2 changes: 1 addition & 1 deletion lastpass/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import struct

from Crypto.Cipher import AES
from lastpass.account import Account
from account import Account


class Parser(object):
Expand Down
8 changes: 4 additions & 4 deletions lastpass/vault.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
from lastpass import Parser, Fetcher
import parser, fetcher


class Vault(object):
Expand All @@ -22,9 +22,9 @@ def open(cls, blob, username, password):
# Just fetches the blob, could be used to store it locally
@classmethod
def fetch_blob(cls, username, password, multifactor_password=None):
return Fetcher.fetch(Fetcher.login(username, password, multifactor_password))
return fetcher.Fetcher.fetch(fetcher.Fetcher.login(username, password, multifactor_password))

# This more of an internal method, use one of the static constructors instead
def __init__(self, blob, encryption_key):
chunks = Parser.extract_chunks(blob)
self.accounts = [Parser.parse_account(i, encryption_key) for i in chunks['ACCT']]
chunks = parser.Parser.extract_chunks(blob)
self.accounts = [parser.Parser.parse_account(i, encryption_key) for i in chunks['ACCT']]

0 comments on commit 1037f85

Please sign in to comment.