diff options
| author | André Glüpker <git@wgmd.de> | 2022-10-08 20:40:02 +0200 | 
|---|---|---|
| committer | André Glüpker <git@wgmd.de> | 2022-10-08 20:42:27 +0200 | 
| commit | 75d015d3389c7a7f105c77a68291f293b5cdd4a0 (patch) | |
| tree | a90f1ca1055fce340a88220bc7a76c73c3dec6d8 /Caching.py | |
| parent | 12b10b204c59ef16ca7dd793ee7724f93e8136d3 (diff) | |
| download | steam-75d015d3389c7a7f105c77a68291f293b5cdd4a0.tar.gz steam-75d015d3389c7a7f105c77a68291f293b5cdd4a0.tar.bz2 steam-75d015d3389c7a7f105c77a68291f293b5cdd4a0.zip  | |
Format with black
Diffstat (limited to 'Caching.py')
| -rw-r--r-- | Caching.py | 16 | 
1 files changed, 9 insertions, 7 deletions
@@ -2,14 +2,15 @@  import os  import time +  THIS_DIR = os.path.dirname(os.path.abspath(__file__)) -CACHE_DIR = os.path.join(THIS_DIR, 'cache') +CACHE_DIR = os.path.join(THIS_DIR, "cache") -class Caching(): +class Caching:      def readCache(profile, steamid, timetolife):          filepath = os.path.join(CACHE_DIR, profile) -        filename = str(steamid)+'.tmp' +        filename = str(steamid) + ".tmp"          complete = os.path.join(filepath, filename)          try:              fileinfo = os.stat(complete) @@ -18,24 +19,25 @@ class Caching():          if fileinfo.st_mtime < (time.time() - timetolife):              return False -        with open(complete, 'rt') as cachefile: +        with open(complete, "rt") as cachefile:              content = cachefile.read()          return content      def writeCache(profile, steamid, content):          filepath = os.path.join(CACHE_DIR, profile) -        filename = str(steamid)+'.tmp' +        filename = str(steamid) + ".tmp"          complete = os.path.join(filepath, filename)          try:              os.makedirs(filepath, exist_ok=True) -            with open(complete, 'wt') as cachefile: +            with open(complete, "wt") as cachefile:                  cachefile.write(content)          except:              print('Could not create cache file/dir "%s".' % complete)              return False          return True +  if __name__ == "__main__":      # TODO(andre): Maybe run tests here? -    print('This is a module.') +    print("This is a module.")  | 
