From 53cbb0fa553a6eec33274707ff7076d27da57208 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Nov 2014 10:42:59 +0100 Subject: [PATCH] Cleanup: pep8 --- client/cli/bam.py | 10 ++++------ client/client/__init__.py | 7 ++++--- client/gui/browser.py | 2 -- packer/blendfile.py | 4 ---- packer/blendfile_path_walker.py | 3 ++- packer/packer.py | 5 +---- webservice/bam/application/__init__.py | 2 +- 7 files changed, 12 insertions(+), 21 deletions(-) diff --git a/client/cli/bam.py b/client/cli/bam.py index 806743c..d45ea27 100755 --- a/client/cli/bam.py +++ b/client/cli/bam.py @@ -40,6 +40,7 @@ del os, sys, path class bam_config: # fake module __slots__ = () + def __new__(cls, *args, **kwargs): raise RuntimeError("%s should not be instantiated" % cls) @@ -98,6 +99,7 @@ class bam_config: class bam_utils: # fake module __slots__ = () + def __new__(cls, *args, **kwargs): raise RuntimeError("%s should not be instantiated" % cls) @@ -187,9 +189,6 @@ class bam_utils: print("Expected a directory (%r)" % path) sys.exit(1) - - - # make a zipfile from session import json with open(os.path.join(path, ".bam_paths_uuid.json")) as f: @@ -285,9 +284,11 @@ class bam_utils: if file_type != "dir": print(" %s" % name_short) + def subcommand_checkout_cb(args): bam_utils.checkout(args.paths) + def subcommand_commit_cb(args): bam_utils.commit(args.paths, args.message) @@ -345,7 +346,6 @@ def create_argparse_revert(subparsers): subparse.set_defaults(func=subcommand_revert_cb) - def create_argparse_status(subparsers): subparse = subparsers.add_parser("status", aliases=("st",)) subparse.add_argument( @@ -362,8 +362,6 @@ def create_argparse_list(subparsers): subparse.set_defaults(func=subcommand_list_cb) - - def create_argparse(): import os import argparse diff --git a/client/client/__init__.py b/client/client/__init__.py index bcb3551..6b53edc 100755 --- a/client/client/__init__.py +++ b/client/client/__init__.py @@ -10,6 +10,7 @@ with open(os.path.join(MODULE_DIR, 'config.json'), 'r') as config: import json config = json.load(config) + def request_url(path): return ('%s%s' % (config['BAM_SERVER'], path)) @@ -45,12 +46,12 @@ def request_url(path): # ) args = { - 'message' : 'Adding test file.' + 'message': "Adding test file." } payload = { - 'command' : 'commit', - 'arguments' : json.dumps(args) + 'command': 'commit', + 'arguments': json.dumps(args) } files = {'file': open('buck.mp4', 'rb')} diff --git a/client/gui/browser.py b/client/gui/browser.py index e9f4d00..b02fd41 100755 --- a/client/gui/browser.py +++ b/client/gui/browser.py @@ -103,7 +103,6 @@ class Application(tk.Frame): menubar.add_command(label="Preferences", command=lambda: print("Preferences")) root.config(menu=menubar) - # local data self.item_list = [] @@ -224,7 +223,6 @@ class Application(tk.Frame): self.grid_members.append(but) row += 1 - def OnFrameConfigure(self, event): '''Reset the scroll region to encompass the inner frame''' self.canvas.configure(scrollregion=self.canvas.bbox("all")) diff --git a/packer/blendfile.py b/packer/blendfile.py index dcf8eab..5248b36 100644 --- a/packer/blendfile.py +++ b/packer/blendfile.py @@ -136,7 +136,6 @@ class BlendFile: # cache (could lazy init, incase we never use?) self.block_from_offset = {block.addr_old: block for block in self.blocks if block.code != b'ENDB'} - def find_blocks_from_code(self, code): assert(type(code) == bytes) if code not in self.code_index: @@ -243,7 +242,6 @@ class BlendFile: sdna_index_from_id[dna_struct.dna_type_id] = sdna_index structs.append(dna_struct) - fields_len = d[1] dna_offset = 0 @@ -394,7 +392,6 @@ class BlendFileBlock: else: return None - # ---------------------- # Python convenience API @@ -481,7 +478,6 @@ class BlendFileHeader: ))) - class DNAName: """ DNAName is a C-type name stored in the DNA diff --git a/packer/blendfile_path_walker.py b/packer/blendfile_path_walker.py index 9f74f9b..e385b90 100644 --- a/packer/blendfile_path_walker.py +++ b/packer/blendfile_path_walker.py @@ -21,8 +21,10 @@ VERBOSE = True TIMEIT = True + class C_defs: __slots__ = () + def __new__(cls, *args, **kwargs): raise RuntimeError("%s should not be instantiated" % cls) @@ -570,7 +572,6 @@ class ExpandID: yield block.get_pointer(b'group') - @staticmethod def expand_TE(block): # 'Tex' yield from ExpandID._expand_generic_animdata(block) diff --git a/packer/packer.py b/packer/packer.py index fc9897f..7121726 100755 --- a/packer/packer.py +++ b/packer/packer.py @@ -96,7 +96,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', path_temp_files.add(filepath_tmp) return filepath_tmp - # base_dir_src = os.path.dirname(blendfile_src) base_dir_dst = os.path.dirname(blendfile_dst) @@ -184,7 +183,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', del blendfile_dst_tmp del sha1_from_file - # -------------------- # Handle File Copy/Zip @@ -232,6 +230,7 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', if WRITE_JSON_REMAP: import json + def write_dict_as_json(fn, dct): zip.writestr( fn, @@ -250,7 +249,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE', del write_dict_as_json - yield report(" %s: %r\n" % (colorize("written", color='green'), blendfile_dst)) else: raise Exception("%s not a known mode" % mode) @@ -316,7 +314,6 @@ def main(): sort_keys=True, indent=4, separators=(',', ': '), ) - if deps_remap is not None: write_dict_as_json(args.deps_remap, deps_remap) diff --git a/webservice/bam/application/__init__.py b/webservice/bam/application/__init__.py index d6039ae..248c975 100644 --- a/webservice/bam/application/__init__.py +++ b/webservice/bam/application/__init__.py @@ -44,6 +44,7 @@ auth = HTTPBasicAuth() import config app.config.from_object(config.Development) + @api.representation('application/octet-stream') def output_file(data, code, headers=None): """Makes a Flask response to return a file.""" @@ -154,7 +155,6 @@ class FileAPI(Resource): elif command == 'checkout': filepath = os.path.join(app.config['STORAGE_PATH'], filepath) - if not os.path.exists(filepath): return jsonify(message="Path not found %r" % filepath) elif os.path.isdir(filepath):