From c9134f0e7ea294e092ebb5aa7e1a7b642aee6073 Mon Sep 17 00:00:00 2001 From: Zepmanbc Date: Tue, 23 Mar 2021 14:04:05 +0100 Subject: [PATCH 1/3] bugfix for default active_file --- creopyson/bom.py | 4 +-- creopyson/dimension.py | 35 +++++++----------------- creopyson/familytable.py | 40 +++++++++++---------------- creopyson/feature.py | 24 ++++++++--------- creopyson/file.py | 58 ++++++++++++++++++++-------------------- creopyson/geometry.py | 9 +++---- creopyson/interface.py | 14 +++++----- creopyson/layer.py | 8 +++--- creopyson/note.py | 21 +++++---------- creopyson/parameter.py | 12 ++++----- creopyson/view.py | 8 +++--- creopyson/windchill.py | 35 +++++++----------------- 12 files changed, 109 insertions(+), 159 deletions(-) diff --git a/creopyson/bom.py b/creopyson/bom.py index a39d7d7..e9726b6 100644 --- a/creopyson/bom.py +++ b/creopyson/bom.py @@ -8,7 +8,7 @@ def get_paths( skeletons=None, top_level=None, get_transforms=None, - exclude_inactive=None + exclude_inactive=None, ): """Get a hierarchy of components within an assembly. @@ -57,7 +57,7 @@ def get_paths( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if paths: data["paths"] = paths diff --git a/creopyson/dimension.py b/creopyson/dimension.py index 8dacf22..f4a1bc0 100755 --- a/creopyson/dimension.py +++ b/creopyson/dimension.py @@ -20,29 +20,19 @@ def copy(client, name, to_name, file_=None, to_file=None): None """ - data = { - "name": name, - "to_name": to_name - } + data = {"name": name, "to_name": to_name} if file_ is not None: data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if to_file: data["to_file"] = to_file return client._creoson_post("dimension", "copy", data) -def list_( - client, - name=None, - file_=None, - dim_type=None, - encoded=None, - select=False -): +def list_(client, name=None, file_=None, dim_type=None, encoded=None, select=False): """Get a list of dimensions from a model. If select is true, then the current selection in Creo will be cleared even @@ -84,7 +74,7 @@ def list_( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -101,12 +91,7 @@ def list_( def list_detail( - client, - name=None, - file_=None, - dim_type=None, - encoded=None, - select=False + client, name=None, file_=None, dim_type=None, encoded=None, select=False ): """Get a list of dimension details from a model. @@ -173,7 +158,7 @@ def list_detail( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -227,7 +212,7 @@ def set_(client, name, value, file_=None, encoded=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if encoded: data["encoded"] = encoded @@ -261,7 +246,7 @@ def set_text(client, name, file_=None, text=None, encoded=False): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if text: data["text"] = text @@ -295,7 +280,7 @@ def show(client, name, file_=None, assembly=None, path=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if assembly: data["assembly"] = assembly @@ -338,7 +323,7 @@ def user_select(client, file_=None, maxi=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if maxi: data["max"] = maxi diff --git a/creopyson/familytable.py b/creopyson/familytable.py index 4f8a506..2eb704f 100755 --- a/creopyson/familytable.py +++ b/creopyson/familytable.py @@ -23,7 +23,7 @@ def add_inst(client, instance, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "add_inst", data) @@ -48,7 +48,7 @@ def create_inst(client, instance, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "create_inst", data, "name") @@ -73,7 +73,7 @@ def delete_inst(client, instance, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "delete_inst", data) @@ -97,7 +97,7 @@ def delete(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "delete", data) @@ -124,7 +124,7 @@ def exists(client, instance, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "exists", data, "exists") @@ -156,15 +156,12 @@ def get_cell(client, instance, colid, file_=None): Column Type; a string corresponding to the Creo column type. """ - data = { - "instance": instance, - "colid": colid - } + data = {"instance": instance, "colid": colid} if file_ is not None: data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "get_cell", data) @@ -196,7 +193,7 @@ def get_header(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "get_header", data, "columns") @@ -222,7 +219,7 @@ def get_parents(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "get_parents", data, "parents") @@ -255,7 +252,7 @@ def get_row(client, instance, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "get_row", data, "columns") @@ -281,7 +278,7 @@ def list_(client, file_=None, instance=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if instance: data["instance"] = instance @@ -320,21 +317,14 @@ def list_tree(client, file_=None, erase=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if erase: data["erase"] = erase return client._creoson_post("familytable", "list_tree", data, "children") -def replace( - client, - cur_model, - new_inst, - file_=None, - cur_inst=None, - path=None -): +def replace(client, cur_model, new_inst, file_=None, cur_inst=None, path=None): """Replace a model in an assembly with another inst in the same family table. You must specify either cur_inst or path. @@ -366,7 +356,7 @@ def replace( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if cur_inst: data["cur_inst"] = cur_inst @@ -405,6 +395,6 @@ def set_cell(client, instance, colid, value, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("familytable", "set_cell", data) diff --git a/creopyson/feature.py b/creopyson/feature.py index db2a7f4..c4f3a58 100755 --- a/creopyson/feature.py +++ b/creopyson/feature.py @@ -47,7 +47,7 @@ def delete(client, name=None, file_=None, status=None, type_=None, clip=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -89,7 +89,7 @@ def delete_param(client, name=None, file_=None, param=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -172,7 +172,7 @@ def list_( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -267,7 +267,7 @@ def list_params( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(param, (str)): @@ -319,7 +319,7 @@ def list_group_features(client, group_name, type_=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if type_: data["type"] = type_ @@ -351,7 +351,7 @@ def list_pattern_features(client, patter_name, type_=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if type_: data["type"] = type_ @@ -412,7 +412,7 @@ def param_exists(client, file_=None, name=None, param=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -447,7 +447,7 @@ def rename(client, name, new_name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if isinstance(name, (str)): data["name"] = name @@ -500,7 +500,7 @@ def resume(client, file_=None, name=None, status=None, type_=None, with_children data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (int)): @@ -571,7 +571,7 @@ def set_param( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -643,7 +643,7 @@ def suppress( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (int)): @@ -707,7 +707,7 @@ def user_select_csys(client, file_=None, max_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if max_: data["max"] = max_ diff --git a/creopyson/file.py b/creopyson/file.py index caaf536..d58e8da 100755 --- a/creopyson/file.py +++ b/creopyson/file.py @@ -120,7 +120,7 @@ def backup(client, target_dir, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "backup", data) @@ -143,7 +143,7 @@ def close_window(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "close_window", data) @@ -169,7 +169,7 @@ def delete_material(client, material, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "delete_material", data) @@ -276,7 +276,7 @@ def get_accuracy(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "get_accuracy", data) @@ -321,7 +321,7 @@ def get_cur_material(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "get_cur_material", data, "material") @@ -352,7 +352,7 @@ def get_cur_material_wildcard(client, file_=None, include_non_matching_parts=Fal data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if include_non_matching_parts: data["include_non_matching_parts"] = True @@ -384,7 +384,7 @@ def get_fileinfo(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "get_fileinfo", data) @@ -407,7 +407,7 @@ def get_length_units(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "get_length_units", data, "units") @@ -430,7 +430,7 @@ def get_mass_units(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "get_mass_units", data, "units") @@ -483,7 +483,7 @@ def has_instances(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "has_instances", data, "exists") @@ -546,7 +546,7 @@ def list_instances(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "list_instances", data) @@ -573,7 +573,7 @@ def list_materials(client, file_=None, material=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if material: data["material"] = material @@ -609,7 +609,7 @@ def list_materials_wildcard( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if material: data["material"] = material @@ -641,7 +641,7 @@ def list_simp_reps(client, file_=None, rep=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if rep: data["rep"] = rep @@ -678,7 +678,7 @@ def load_material_file(client, material, dirname=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "load_material_file", data, "files") @@ -723,7 +723,7 @@ def massprops(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "massprops", data) @@ -816,7 +816,7 @@ def open_errors(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "open_errors", data, "errors") @@ -839,7 +839,7 @@ def postregen_relations_get(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "postregen_relations_get", data, "relations") @@ -865,7 +865,7 @@ def postregen_relations_set(client, file_=None, relations=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if relations: data["relations"] = relations @@ -890,7 +890,7 @@ def refresh(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "refresh", data) @@ -919,7 +919,7 @@ def regenerate(client, file_=None, display=None): data["files"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if display: data["display"] = display @@ -944,7 +944,7 @@ def relations_get(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "relations_get", data, "relations") @@ -970,7 +970,7 @@ def relations_set(client, file_=None, relations=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if relations: data["relations"] = relations @@ -999,7 +999,7 @@ def rename(client, new_name, file_=None, onlysession=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if onlysession: data["onlysession"] = onlysession @@ -1024,7 +1024,7 @@ def repaint(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "repaint", data) @@ -1051,7 +1051,7 @@ def save(client, file_=None): data["files"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "save", data) @@ -1078,7 +1078,7 @@ def set_cur_material(client, material, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("file", "set_cur_material", data, "files") @@ -1114,7 +1114,7 @@ def set_length_units(client, units, file_=None, convert=None): data["files"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if convert: data["convert"] = convert @@ -1152,7 +1152,7 @@ def set_mass_units(client, units, file_=None, convert=None): data["files"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if convert: data["convert"] = convert diff --git a/creopyson/geometry.py b/creopyson/geometry.py index 2e2f6ef..86c0fd5 100755 --- a/creopyson/geometry.py +++ b/creopyson/geometry.py @@ -26,7 +26,7 @@ def bound_box(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("geometry", "bound_box", data) @@ -78,7 +78,7 @@ def get_edges(client, surface_ids, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("geometry", "get_edges", data, "contourlist") @@ -122,7 +122,6 @@ def get_surfaces(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] - return client._creoson_post( - "geometry", "get_surfaces", data, "surflist") + return client._creoson_post("geometry", "get_surfaces", data, "surflist") diff --git a/creopyson/interface.py b/creopyson/interface.py index 7fbfc17..f836688 100755 --- a/creopyson/interface.py +++ b/creopyson/interface.py @@ -57,7 +57,7 @@ def export_3dpdf( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if filename: data["filename"] = filename @@ -128,7 +128,7 @@ def export_file( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if filename: data["filename"] = filename @@ -186,7 +186,7 @@ def export_image( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if filename: data["filename"] = filename @@ -255,7 +255,7 @@ def export_pdf( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if filename: data["filename"] = filename @@ -292,7 +292,7 @@ def export_program(client, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("interface", "export_program", data) @@ -390,7 +390,7 @@ def import_program(client, file_=None, filename=None, dirname=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if filename: data["filename"] = filename @@ -449,7 +449,7 @@ def plot(client, file_=None, dirname=None, driver=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if dirname: data["dirname"] = dirname diff --git a/creopyson/layer.py b/creopyson/layer.py index e20d0d9..420cf27 100755 --- a/creopyson/layer.py +++ b/creopyson/layer.py @@ -23,7 +23,7 @@ def delete(client, name=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -52,7 +52,7 @@ def exists(client, name=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -87,7 +87,7 @@ def list_(client, name=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name @@ -119,7 +119,7 @@ def show(client, name=None, file_=None, show_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: data["name"] = name diff --git a/creopyson/note.py b/creopyson/note.py index 5e3e865..1520f90 100755 --- a/creopyson/note.py +++ b/creopyson/note.py @@ -30,7 +30,7 @@ def copy(client, name, to_name=None, file_=None, to_file=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if to_file: data["to_file"] = to_file @@ -58,7 +58,7 @@ def delete(client, name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("note", "delete", data) @@ -84,7 +84,7 @@ def exists(client, file_=None, name=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -128,19 +128,12 @@ def get(client, name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("note", "get", data) -def list_( - client, - file_=None, - name=None, - value=None, - get_expanded=None, - select=False -): +def list_(client, file_=None, name=None, value=None, get_expanded=None, select=False): """Get a list of notes from one or more models. Values will automatically be returned Base64-encoded if they are strings @@ -179,7 +172,7 @@ def list_( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -227,7 +220,7 @@ def set_(client, name, file_=None, encoded=None, value=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if encoded: data["encoded"] = encoded diff --git a/creopyson/parameter.py b/creopyson/parameter.py index a6c228e..ffc749b 100755 --- a/creopyson/parameter.py +++ b/creopyson/parameter.py @@ -32,7 +32,7 @@ def copy(client, name, to_name, file_=None, to_file=None, designate=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if to_file: data["to_file"] = to_file @@ -61,7 +61,7 @@ def delete(client, name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("parameter", "delete", data) @@ -87,7 +87,7 @@ def exists(client, name=None, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -129,7 +129,7 @@ def list_(client, name=None, file_=None, encoded=None, value=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name: if isinstance(name, (str)): @@ -190,7 +190,7 @@ def set_( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if type_: data["type"] = type_ @@ -237,6 +237,6 @@ def set_designated( data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("parameter", "set_designated", data) diff --git a/creopyson/view.py b/creopyson/view.py index 4fc11bc..ebdae69 100755 --- a/creopyson/view.py +++ b/creopyson/view.py @@ -21,7 +21,7 @@ def activate(client, name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("view", "activate", data) @@ -49,7 +49,7 @@ def list_exploded(client, file_=None, name=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("view", "list_exploded", data, "viewlist") @@ -75,7 +75,7 @@ def list_(client, file_=None, name=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] if name is not None: data["name"] = name @@ -102,6 +102,6 @@ def save(client, name, file_=None): data["file"] = file_ else: active_file = client.file_get_active() - if active_file is not None: + if active_file: data["file"] = active_file["file"] return client._creoson_post("view", "save", data) diff --git a/creopyson/windchill.py b/creopyson/windchill.py index 4d058bb..b331462 100644 --- a/creopyson/windchill.py +++ b/creopyson/windchill.py @@ -18,10 +18,7 @@ def authorize(client, user, password): None """ - data = { - "user": user, - "password": password - } + data = {"user": user, "password": password} return client._creoson_post("windchill", "authorize", data) @@ -62,10 +59,7 @@ def create_workspace(client, workspace, context_name): None """ - data = { - "workspace": workspace, - "context": context_name - } + data = {"workspace": workspace, "context": context_name} return client._creoson_post("windchill", "create_workspace", data) @@ -100,14 +94,10 @@ def file_checked_out(client, filename, workspace=None): """ active_workspace = client.windchill_get_workspace() - data = { - "workspace": active_workspace, - "filename": filename - } + data = {"workspace": active_workspace, "filename": filename} if workspace: data["workspace"] = workspace - return client._creoson_post( - "windchill", "file_checked_out", data, "checked_out") + return client._creoson_post("windchill", "file_checked_out", data, "checked_out") def get_workspace(client): @@ -120,8 +110,7 @@ def get_workspace(client): str: Active Workspace name. """ - return client._creoson_post( - "windchill", "get_workspace", key_data="workspace") + return client._creoson_post("windchill", "get_workspace", key_data="workspace") def list_workspace_files(client, workspace=None, filename=None): @@ -141,16 +130,12 @@ def list_workspace_files(client, workspace=None, filename=None): """ active_workspace = client.windchill_get_workspace() - data = { - "workspace": active_workspace, - "filename": "*" - } + data = {"workspace": active_workspace, "filename": "*"} if workspace: data["workspace"] = workspace if filename: data["filename"] = filename - return client._creoson_post( - "windchill", "list_workspace_files", data, "filelist") + return client._creoson_post("windchill", "list_workspace_files", data, "filelist") def list_workspaces(client): @@ -163,8 +148,7 @@ def list_workspaces(client): list: List of workspaces """ - return client._creoson_post( - "windchill", "list_workspaces", key_data="workspaces") + return client._creoson_post("windchill", "list_workspaces", key_data="workspaces") def server_exists(client, server_url): @@ -224,5 +208,4 @@ def workspace_exists(client, workspace): """ data = {"workspace": workspace} - return client._creoson_post( - "windchill", "workspace_exists", data, "exists") + return client._creoson_post("windchill", "workspace_exists", data, "exists") From afd66baceabf266cba6c552054ac498eaef29818 Mon Sep 17 00:00:00 2001 From: Zepmanbc Date: Tue, 23 Mar 2021 14:11:24 +0100 Subject: [PATCH 2/3] Changelog for upcoming release 0.7.1 --- HISTORY.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index e61f3c2..9fbbc1e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,12 @@ History ======= +0.7.1 (2021-03-23) +------------------ + +* BugFix: + * `file_get_active` returns `{}` instead of `None` with Creoson 2.8.0 + 0.7.0 (2021-03-22) ------------------ From 3d019a3d908044a8810a85a7716b5b5863a8619a Mon Sep 17 00:00:00 2001 From: Zepmanbc Date: Tue, 23 Mar 2021 14:11:35 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Bump=20version:=200.7.0=20=E2=86=92=200.7.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- creopyson/__init__.py | 2 +- setup.cfg | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/creopyson/__init__.py b/creopyson/__init__.py index 958df01..9056c67 100644 --- a/creopyson/__init__.py +++ b/creopyson/__init__.py @@ -4,7 +4,7 @@ __author__ = """Benjamin C.""" __email__ = "zepman@gmail.com" -__version__ = "__version__ = '0.7.0'" +__version__ = "__version__ = '0.7.1'" from creopyson.connection import Client from creopyson.objects import jlpoint diff --git a/setup.cfg b/setup.cfg index 6762e4a..00485b5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.7.0 +current_version = 0.7.1 commit = True tag = False diff --git a/setup.py b/setup.py index 44ca642..3e0d1a8 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/Zepmanbc/creopyson', - version='0.7.0', + version='0.7.1', zip_safe=False, )