cleanup: pep8

This commit is contained in:
2014-11-21 20:58:44 +01:00
parent 47a6eaa936
commit aac29c824d
12 changed files with 57 additions and 77 deletions

View File

@@ -189,7 +189,6 @@ class bam_session:
os.path.join(session_rootdir, ".bam_tmp.zip"),
}
with open(os.path.join(session_rootdir, ".bam_paths_uuid.json")) as f:
import json
paths_uuid = json.load(f)
@@ -293,7 +292,6 @@ class bam_commands:
print("Project %r initialized" % proj_dirname)
@staticmethod
def create(session_name):
import os
@@ -404,7 +402,6 @@ class bam_commands:
@staticmethod
def commit(paths, message):
import sys
import os
import requests
@@ -439,11 +436,9 @@ class bam_commands:
with open(os.path.join(session_rootdir, ".bam_paths_uuid.json")) as f:
paths_uuid = json.load(f)
with open(os.path.join(session_rootdir, ".bam_deps_remap.json")) as f:
deps_remap = json.load(f)
paths_add = {}
paths_modified = {}
paths_remove = {}
@@ -458,7 +453,6 @@ class bam_commands:
print("Nothing to commit!")
return
for fn_rel, fn_abs in list(paths_modified.items()):
# we may want to be more clever here
deps = deps_remap.get(fn_rel)
@@ -555,7 +549,6 @@ class bam_commands:
# TODO(cam)
# if all goes well, rewrite sha1's
@staticmethod
def status(paths):
# TODO(cam) multiple paths
@@ -565,7 +558,6 @@ class bam_commands:
session_rootdir = bam_config.find_sessiondir(path, abort=True)
print(session_rootdir)
paths_add = {}
paths_modified = {}
paths_remove = {}
@@ -623,7 +615,6 @@ class bam_commands:
if file_type != "dir":
print(" %s" % name_short)
@staticmethod
def deps(paths, recursive=False):
import blendfile_path_walker

View File

@@ -7,7 +7,6 @@ import os
MODULE_DIR = os.path.dirname(__file__)
with open(os.path.join(MODULE_DIR, 'config.json'), 'r') as config:
import json
config = json.load(config)
@@ -63,4 +62,3 @@ r = requests.put(request_url('/file'),
files=files)
print(r.text)

View File

@@ -184,7 +184,8 @@ class Application(tk.Frame):
but.grid(row=row, column=0)
self.grid_members.append(but)
def fn(idname=name_short, but_path=but_path): exec_path_dir(idname, but_path)
def fn(idname=name_short, but_path=but_path):
exec_path_dir(idname, but_path)
but = tk.Button(self.frame, text=name_short + "/", fg="green", command=fn)
but.grid(row=row, column=1, sticky="nw")
@@ -213,7 +214,9 @@ class Application(tk.Frame):
if item_type == "file":
but = tk.Label(self.frame, text="(b)", width=3, borderwidth="1", relief="solid")
but.grid(row=row, column=0)
def fn(idname=name_short): exec_path_blendfile(idname)
def fn(idname=name_short):
exec_path_blendfile(idname)
self.grid_members.append(but)
but = tk.Button(self.frame, text=name_short, fg="blue", command=fn)
@@ -231,4 +234,3 @@ root = tk.Tk()
app = Application(root).pack(side="top", fill="both", expand=True)
root.title("BAM")
root.mainloop()

View File

@@ -55,4 +55,3 @@ def sha1_from_file(fn, block_size=1 << 20):
break
sha1.update(data)
return sha1.hexdigest()

View File

@@ -245,7 +245,6 @@ def pack(blendfile_src, blendfile_dst, mode='FILE',
zip_handle.write(src.decode('utf-8'),
arcname=os.path.relpath(dst, base_dir_dst).decode('utf-8'))
yield report(" %s: %r\n" % (colorize("written", color='green'), blendfile_dst))
else:
raise Exception("%s not a known mode" % mode)
@@ -331,4 +330,3 @@ def main():
if __name__ == "__main__":
main()

View File

@@ -56,7 +56,7 @@ def create_from_files(deps):
for f_abs in iter_files_blend(dirname):
if f_abs.endswith(".png"):
f_rel = bpy.path.relpath(f_abs)
image = bpy.data.images.load(f)
image = bpy.data.images.load(f_rel)
image.use_fake_user = True
deps.append(f_abs)
@@ -96,4 +96,3 @@ if __name__ == "__main__":
import sys
sys.exit(returncode)

View File

@@ -247,7 +247,6 @@ def bam_run(argv, cwd=None):
import shlex
sys.stdout.write("bam %s\n" % " ".join([shlex.quote(c) for c in argv]))
# input('press_key!:')
with StdIO() as fakeio:
@@ -299,8 +298,8 @@ def blendfile_template_create(blendfile, create_id, deps):
returncode_test = 123
blendfile_deps_json = os.path.join(TEMP_LOCAL, "blend_template_deps.json")
os.makedirs(os.path.dirname(blendfile), exist_ok=True)
stdout, stderr, returncode = run(
("blender",
cmd = (
"blender",
"--background",
"--factory-startup",
"-noaudio",
@@ -311,7 +310,8 @@ def blendfile_template_create(blendfile, create_id, deps):
blendfile_deps_json,
create_id,
str(returncode_test),
))
)
stdout, stderr, returncode = run(cmd)
if os.path.exists(blendfile_deps_json):
import json
@@ -577,6 +577,7 @@ class BamListTest(BamSessionTestCase):
import json
ret = json.loads(stdout)
self.assertEqual(2, len(ret))
class BamCommitTest(BamSessionTestCase):
@@ -645,8 +646,7 @@ class BamBlendTest(BamSimpleTestCase):
yield filepath
for create_id, create_fn in blendfile_templates.__dict__.items():
if (create_id.startswith("create_") and
create_fn.__class__.__name__ == "function"):
if (create_id.startswith("create_") and create_fn.__class__.__name__ == "function"):
os.makedirs(TEMP_SESSION)
@@ -694,7 +694,6 @@ class BamDeleteTest(BamSessionTestCase):
def test_delete(self):
session_name = "mysession"
file_name = "testfile.blend"
file_data = b"hello world!\n"
proj_path, session_path = self.init_session(session_name)
# now do a real commit
@@ -717,7 +716,6 @@ class BamDeleteTest(BamSessionTestCase):
stdout, stderr = bam_run(["checkout", file_name, "--output", "new_out"], proj_path)
self.assertEqual("", stderr)
# now delete the file we just checked out
session_path = os.path.join(proj_path, "new_out")
os.remove(os.path.join(session_path, file_name))
@@ -740,4 +738,3 @@ if __name__ == '__main__':
data = global_setup()
unittest.main(exit=False)
global_teardown(data)

View File

@@ -117,7 +117,6 @@ class DirectoryAPI(Resource):
path_root_abs = os.path.join(path_root_abs, path)
parent_path = os.pardir
if not os.path.isdir(path_root_abs):
return jsonify(message="Path is not a directory %r" % path_root_abs)
@@ -218,7 +217,6 @@ class FileAPI(Resource):
yield report("%s: %r\n" % (colorize("failed to extract", color='red'), filepath))
return
with open(filepath_zip, 'rb') as f:
f.seek(0, os.SEEK_END)
f_size = f.tell()
@@ -246,8 +244,12 @@ class FileAPI(Resource):
file = request.files['file']
# Get the value of the first (and only) result for the specified project setting
svn_password = next((setting.value for setting in project.settings if setting.name == 'svn_password'))
svn_default_user = next((setting.value for setting in project.settings if setting.name == 'svn_default_user'))
svn_password = next((setting.value
for setting in project.settings
if setting.name == 'svn_password'))
svn_default_user = next((setting.value
for setting in project.settings
if setting.name == 'svn_default_user'))
# We get the actual username from the http headers
svn_user = auth.username()
@@ -324,7 +326,6 @@ class FileAPI(Resource):
result = local_client.run_command('rm',
[file_path_abs, ])
# Commit command
result = local_client.run_command('commit',
[local_client.info()['entry_path'],
@@ -333,7 +334,6 @@ class FileAPI(Resource):
'--password', svn_password],
combine=True)
return jsonify(message=result)
else:
return jsonify(message='File not allowed')
@@ -405,8 +405,6 @@ class FileAPI(Resource):
del write_dict_as_json
# done writing json!
@staticmethod
def allowed_file(filename):
return '.' in filename and \
@@ -415,4 +413,3 @@ class FileAPI(Resource):
api.add_resource(DirectoryAPI, '/<project_name>/file_list', endpoint='file_list')
api.add_resource(FileAPI, '/<project_name>/file', endpoint='file')

View File

@@ -83,6 +83,7 @@ class CustomModelView(ModelView):
return True
# return login.current_user.has_role('admin')
class CustomBaseView(BaseView):
def is_accessible(self):
return True
@@ -108,8 +109,7 @@ class CustomAdminIndexView(admin.AdminIndexView):
# Create admin
backend = Admin(
app,
'BAM',
"BAM",
index_view=CustomAdminIndexView(),
base_template='admin/layout_admin.html'
base_template="admin/layout_admin.html"
)

View File

@@ -70,4 +70,3 @@ if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()