Browse Source

results from pyflakes

adam j hartz 2 months ago
parent
commit
7707ab99cb
9 changed files with 10 additions and 35 deletions
  1. 2
    2
      catsoop/check.py
  2. 5
    11
      catsoop/cslog.py
  3. 0
    1
      catsoop/language.py
  4. 0
    2
      catsoop/loader.py
  5. 0
    4
      catsoop/lti.py
  6. 0
    5
      catsoop/process.py
  7. 2
    3
      catsoop/session.py
  8. 1
    4
      catsoop/tutor.py
  9. 0
    3
      setup.py

+ 2
- 2
catsoop/check.py View File

@@ -22,11 +22,11 @@ def equal():
22 22
 
23 23
 
24 24
 def number_close(threshold=1e-6):
25
-    return lambda sub, soln: abs(sub - soln) <= thereshold
25
+    return lambda sub, soln: abs(sub - soln) <= threshold
26 26
 
27 27
 
28 28
 def evaled(f):
29
-    return lambda sub, soln: f(ast.literal_eval(x), ast.literal_eval(y))
29
+    return lambda sub, soln: f(ast.literal_eval(sub), ast.literal_eval(soln))
30 30
 
31 31
 
32 32
 def list_all(cmp_func=None):

+ 5
- 11
catsoop/cslog.py View File

@@ -32,16 +32,11 @@ add new Python objects to a log.
32 32
 """
33 33
 
34 34
 import os
35
-import re
36 35
 import ast
37
-import sys
38 36
 import lzma
39 37
 import base64
40 38
 import pprint
41
-import random
42
-import struct
43 39
 import hashlib
44
-import binascii
45 40
 import importlib
46 41
 import contextlib
47 42
 
@@ -223,7 +218,7 @@ def update_log(db_name, path, logname, new, lock=True):
223 218
     # get an exclusive lock on this file before making changes
224 219
     # look up the separator and the data
225 220
     cm = log_lock([db_name] + path + [logname]) if lock else passthrough()
226
-    with cm as lock:
221
+    with cm:
227 222
         _update_log(fname, new)
228 223
 
229 224
 
@@ -254,7 +249,7 @@ def overwrite_log(db_name, path, logname, new, lock=True):
254 249
     # get an exclusive lock on this file before making changes
255 250
     fname = get_log_filename(db_name, path, logname)
256 251
     cm = log_lock([db_name] + path + [logname]) if lock else passthrough()
257
-    with cm as l:
252
+    with cm:
258 253
         _overwrite_log(fname, new)
259 254
 
260 255
 
@@ -262,7 +257,7 @@ def _read_log(db_name, path, logname, lock=True):
262 257
     fname = get_log_filename(db_name, path, logname)
263 258
     # get an exclusive lock on this file before reading it
264 259
     cm = log_lock([db_name] + path + [logname]) if lock else passthrough()
265
-    with cm as lock:
260
+    with cm:
266 261
         try:
267 262
             f = open(fname, "rb")
268 263
             for i in f.read().split(sep):
@@ -325,7 +320,7 @@ def most_recent(db_name, path, logname, default=None, lock=True):
325 320
         return default
326 321
     # get an exclusive lock on this file before reading it
327 322
     cm = log_lock([db_name] + path + [logname]) if lock else passthrough()
328
-    with cm as lock:
323
+    with cm:
329 324
         with open(fname, "rb") as f:
330 325
             return unprep(f.read().rsplit(sep, 2)[-2])
331 326
 
@@ -339,9 +334,8 @@ def modify_most_recent(
339 334
     method="update",
340 335
     lock=True,
341 336
 ):
342
-    fname = get_log_filename(db_name, path, logname)
343 337
     cm = log_lock([db_name] + path + [logname]) if lock else passthrough()
344
-    with cm as lock:
338
+    with cm:
345 339
         old_val = most_recent(db_name, path, logname, default, lock=False)
346 340
         new_val = transform_func(old_val)
347 341
         assert can_log(new_val), "Can't log: %r" % (new_val,)

+ 0
- 1
catsoop/language.py View File

@@ -709,7 +709,6 @@ def handle_custom_tags(context, text):
709 709
     for ix, i in enumerate(tree.find_all("tableofcontents")):
710 710
         o_toc_dom = toc_dom = tree.new_tag("ul")
711 711
         last_handled_len = 0
712
-        first_section = None
713 712
         for (num, ref, elt) in toc_sections:
714 713
             n = len(num.strip().split("."))  # number of layers deep
715 714
             if n > last_handled_len and last_handled_len != 0:

+ 0
- 2
catsoop/loader.py View File

@@ -26,7 +26,6 @@ import re
26 26
 import sys
27 27
 import shutil
28 28
 import random
29
-import marshal
30 29
 import importlib
31 30
 import traceback
32 31
 
@@ -401,7 +400,6 @@ def cs_compile(fname, pre_code="", post_code=""):
401 400
     **Returns:** a bytestring containing the compiled code
402 401
     """
403 402
     base_fname = fname.rsplit(".", 1)[0]
404
-    cache_tag = sys.implementation.cache_tag
405 403
     fdirs = os.path.dirname(fname).split(os.sep)
406 404
     if fdirs and fdirs[0] == "":
407 405
         fdirs.pop(0)

+ 0
- 4
catsoop/lti.py View File

@@ -18,12 +18,8 @@
18 18
 LTI Tool Provider interface
19 19
 """
20 20
 
21
-import os
22 21
 import uuid
23
-import string
24 22
 import urllib
25
-import random
26
-import hashlib
27 23
 import pylti.common
28 24
 
29 25
 from lxml import etree

+ 0
- 5
catsoop/process.py View File

@@ -17,13 +17,8 @@
17 17
 Tools for controlling processes
18 18
 """
19 19
 
20
-import os
21
-import time
22 20
 import ctypes
23 21
 import signal
24
-import threading
25
-import subprocess
26
-import multiprocessing
27 22
 
28 23
 _nodoc = {"i"}
29 24
 

+ 2
- 3
catsoop/session.py View File

@@ -20,7 +20,6 @@ Simple session handling.
20 20
 import os
21 21
 import re
22 22
 import time
23
-import json
24 23
 import uuid
25 24
 import traceback
26 25
 import importlib
@@ -136,7 +135,7 @@ def get_session_data(context, sid):
136 135
     """
137 136
     make_session_dir()
138 137
     fname = os.path.join(SESSION_DIR, sid)
139
-    with cslog.log_lock(["_sessions", sid]) as lock:
138
+    with cslog.log_lock(["_sessions", sid]):
140 139
         try:
141 140
             with open(fname, "rb") as f:
142 141
                 out = cslog.unprep(f.read())
@@ -159,6 +158,6 @@ def set_session_data(context, sid, data):
159 158
     """
160 159
     make_session_dir()
161 160
     fname = os.path.join(SESSION_DIR, sid)
162
-    with cslog.log_lock(["_sessions", sid]) as lock:
161
+    with cslog.log_lock(["_sessions", sid]):
163 162
         with open(fname, "wb") as f:
164 163
             f.write(cslog.prep(data))

+ 1
- 4
catsoop/tutor.py View File

@@ -18,11 +18,8 @@ Utilities for managing courses (questions, handlers, statistics, etc)
18 18
 """
19 19
 
20 20
 import os
21
-import re
22
-import json
23 21
 import random
24 22
 import string
25
-import sqlite3
26 23
 import importlib
27 24
 import collections
28 25
 
@@ -511,7 +508,7 @@ def get_due_date(context, do_extensions=False):
511 508
         if do_extensions:
512 509
             extensions = context["cs_user_info"].get("extensions", [])
513 510
             for ex in extensions:
514
-                if all(i == j for i, j in zip(e[0], path)):
511
+                if all(i == j for i, j in zip(ex[0], context['cs_path_info'][1:])):
515 512
                     due += timedelta(days=ex[1])
516 513
     except:
517 514
         pass

+ 0
- 3
setup.py View File

@@ -23,9 +23,6 @@ import sys
23 23
 import subprocess
24 24
 
25 25
 from setuptools import setup
26
-from setuptools.command.sdist import sdist
27
-from setuptools.command.install import install
28
-from setuptools.command.develop import develop
29 26
 
30 27
 from catsoop import __version__ as CS_VERSION
31 28
 

Loading…
Cancel
Save