45
45
__all__ = None
46
46
47
47
DEFAULT_PLOT_OPTIONS = {
48
- "filename" : "plot from API" ,
49
48
"world_readable" : files .FILE_CONTENT [files .CONFIG_FILE ]["world_readable" ],
50
49
"auto_open" : files .FILE_CONTENT [files .CONFIG_FILE ]["auto_open" ],
51
50
"validate" : True ,
@@ -97,7 +96,9 @@ def _plot_option_logic(plot_options_from_args):
97
96
user_plot_options .update (session_options )
98
97
user_plot_options .update (plot_options_from_args )
99
98
user_plot_options = {
100
- k : v for k , v in user_plot_options .items () if k in default_plot_options
99
+ k : v
100
+ for k , v in user_plot_options .items ()
101
+ if k in default_plot_options or k == "filename"
101
102
}
102
103
103
104
return user_plot_options
@@ -240,7 +241,7 @@ def plot(figure_or_data, validate=True, **plot_options):
240
241
filename = paths [- 1 ]
241
242
242
243
# Create parent directory
243
- if parent_path != "" :
244
+ if parent_path :
244
245
file_ops .ensure_dirs (parent_path )
245
246
payload ["parent_path" ] = parent_path
246
247
@@ -1065,6 +1066,8 @@ def upload(
1065
1066
if meta is not None :
1066
1067
grid_json ["metadata" ] = meta
1067
1068
1069
+ payload = {"data" : grid_json , "world_readable" : world_readable }
1070
+
1068
1071
# Make a folder path
1069
1072
if filename :
1070
1073
if filename [- 1 ] == "/" :
@@ -1076,23 +1079,10 @@ def upload(
1076
1079
1077
1080
if parent_path != "" :
1078
1081
file_ops .ensure_dirs (parent_path )
1079
- else :
1080
- # Create anonymous grid name
1081
- hash_val = hash (json .dumps (grid_json , sort_keys = True ))
1082
- id = base64 .urlsafe_b64encode (str (hash_val ).encode ("utf8" ))
1083
- id_str = id .decode (encoding = "utf8" ).replace ("=" , "" )
1084
- filename = "grid_" + id_str
1085
- # filename = 'grid_' + str(hash_val)
1086
- parent_path = ""
1087
-
1088
- payload = {
1089
- "filename" : filename ,
1090
- "data" : grid_json ,
1091
- "world_readable" : world_readable ,
1092
- }
1093
1082
1094
- if parent_path != "" :
1095
- payload ["parent_path" ] = parent_path
1083
+ payload ["filename" ] = filename
1084
+ if parent_path :
1085
+ payload ["parent_path" ] = parent_path
1096
1086
1097
1087
file_info = _create_or_overwrite_grid (payload )
1098
1088
0 commit comments