~tdelaet/cimple/old-codebase

« back to all changes in this revision

Viewing changes to src/cimple/core/storage/cache.py

  • Committer: Thomas Delaet
  • Date: 2010-01-07 14:14:32 UTC
  • Revision ID: thomas@cole-20100107141432-yhker27v3pmn62uo
first phase of rewrite with focus on storage

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
import shutil
 
3
 
 
4
class Cache:
 
5
        
 
6
        def __init__(self):
 
7
                pass
 
8
        
 
9
        def has(self, data_identifier):
 
10
                """
 
11
                @return: bool
 
12
                """
 
13
                
 
14
        def add(self, data_identifier, file_location, remove):
 
15
                """
 
16
                @return: None
 
17
                """
 
18
                if remove:
 
19
                        os.rename(file_location, self.path(data_identifier))
 
20
                else:
 
21
                        shutil.copyfile(file_location, self.path(data_identifier))
 
22
                os.chmod(self.path(data_identifier), 0600)
 
23
 
 
24
        def touch(self, data_identifier):
 
25
                """
 
26
                @return: None
 
27
                """
 
28
                
 
29
        def path(self, data_identifier):
 
30
                """
 
31
                @return: str
 
32
                """
 
 
b'\\ No newline at end of file'