diff options
author | Hochikong <michellehzg@gmail.com> | 2016-05-24 01:05:26 +0800 |
---|---|---|
committer | Hochikong <michellehzg@gmail.com> | 2016-05-24 01:05:26 +0800 |
commit | 9eca534f9735c8c5e984ce5a3add7cbb9daa4345 (patch) | |
tree | 7f2555294adf102455f5a3f6d78c44aba3c72f8b /vyroute/DataIO.py | |
parent | 8e2f9aa509a5d90897844c196675836a10068237 (diff) | |
download | python-vyos-mgmt-9eca534f9735c8c5e984ce5a3add7cbb9daa4345.tar.gz python-vyos-mgmt-9eca534f9735c8c5e984ce5a3add7cbb9daa4345.zip |
too more changes,i donno what to say
Diffstat (limited to 'vyroute/DataIO.py')
-rw-r--r-- | vyroute/DataIO.py | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/vyroute/DataIO.py b/vyroute/DataIO.py deleted file mode 100644 index 979820e..0000000 --- a/vyroute/DataIO.py +++ /dev/null @@ -1,81 +0,0 @@ -# author=hochikong -import shelve - - -class IO(object): - - def post(self): - pass - - def put(self): - pass - - -class RawIO(IO): - # The router node record is in a python shelve object (.dat file). - def __init__(self, datafile): - """Initial member self.file. - - :param datafile: a string - """ - self.file = datafile - - def post(self, key, data): - """Create a new record in the shelve object. - - :param key: a string - :param data: a python dictionary - :return : a python dictionary - """ - temp = shelve.open(self.file) - temp[key] = data - temp.close() - return {"Result": "Create successfully."} - - def put(self, key, data): - """Update a record or delete a existing record. - - :param key: a string - :param data: a python dictionary - :return: different python dictionaries - """ - if data == {"content": "delete"}: - temp = shelve.open(self.file) - try: - del temp[key] - return {"Result": "Delete successfully."} - except KeyError: - return {"Result": "There is no key '%s'." % key} - finally: - temp.close() - else: - self.post(key, data) - return {"Result": "Update successfully."} - - def get(self, key="all"): - """Query a specific record or all records. - - :param key: 'none' or a vaild key - :param args: 'all' or 'none' - :return: different python dictionaries - """ - temp = shelve.open(self.file) - if key == "all": - print temp - temp.close() - else: - try: - print temp[key] - except KeyError: - return {"Result": "'There is no key '%s'." % key} - finally: - temp.close() - - - - - - - - - |