plotlyshare 1.0.8__tar.gz → 1.0.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plotlyshare
3
- Version: 1.0.8
3
+ Version: 1.0.10
4
4
  Summary: Link-based sharing of `plotly` plots with a private web app
5
5
  Keywords: plotly,interactive,plot
6
6
  Author-email: plutonium239 <plutonium.239.811@gmail.com>
@@ -2,7 +2,7 @@ from plotlyshare.custom_plotly_renderer import PlotlyShareRenderer
2
2
  import json
3
3
  import os, sys
4
4
 
5
- dir_path = os.path.dirname(os.path.realpath(__file__))
5
+ dir_path = os.path.expanduser('~/.config/plotlyshare')
6
6
  config_file_path = f'{dir_path}/config.json'
7
7
 
8
8
  found_config = os.path.exists(config_file_path)
@@ -3,12 +3,13 @@ import time
3
3
  from rich import console, pretty
4
4
  from plotlyshare.custom_plotly_renderer import test_connection
5
5
 
6
- allowed_commands = ['setup', 'test']
6
+ allowed_commands = ['setup', 'test', 'show_config']
7
7
  assert len(sys.argv) == 2, f'Please give only one argument out of {allowed_commands}'
8
8
  command = sys.argv[1]
9
9
  assert command in allowed_commands, f'Given command not in {allowed_commands}'
10
10
 
11
- dir_path = os.path.dirname(os.path.realpath(__file__))
11
+ dir_path = os.path.expanduser('~/.config/plotlyshare')
12
+ os.makedirs(dir_path, exist_ok=True)
12
13
  config_file_path = f'{dir_path}/config.json'
13
14
 
14
15
  if os.path.exists(config_file_path):
@@ -22,10 +23,6 @@ if command == 'setup':
22
23
  print('Previous setup detected, printing and resetting.')
23
24
  pretty.pprint(old_config)
24
25
 
25
- old_config['setup_done'] = False
26
- with open(config_file_path, 'w') as f:
27
- json.dump(old_config, f, indent=4)
28
-
29
26
  config = {}
30
27
 
31
28
  c = console.Console()
@@ -45,7 +42,10 @@ if command == 'setup':
45
42
  Read the instructions there and enter the values for 'DETA_APP_URL' and 'DETA_PROJECT_KEY' one by one:
46
43
  ''')
47
44
  time.sleep(0.5)
48
- config['DETA_APP_URL'] = c.input('[bold #FF84AC] DETA_APP_URL: [/bold #FF84AC]')
45
+ base_url = c.input('[bold #FF84AC] DETA_APP_URL: [/bold #FF84AC]')
46
+ if base_url.endswith('/'):
47
+ base_url = base_url.rstrip('/')
48
+ config['DETA_APP_URL'] = base_url
49
49
  config['DETA_PROJECT_KEY'] = c.input('[bold #FF84AC] DETA_PROJECT_KEY: [/bold #FF84AC]')
50
50
  pref_open_browser = c.input(r'[italic #FF84AC] Would you like to open the plot in a browser after plotting? (default: yes) (\[y]/n) [/italic #FF84AC]')
51
51
  print(pref_open_browser)
@@ -64,11 +64,12 @@ if command == 'setup':
64
64
  json.dump(config, f, indent=4)
65
65
 
66
66
  c.print('[bold green]Setup completed!🚀[/bold green]')
67
+ c.print(f'Your config has been saved to {config_file_path}')
67
68
  else:
68
69
  c.print('[bold red]Setup failed:[/bold red]\n'+display)
69
70
  elif command == 'test':
71
+ c = console.Console()
70
72
  if old_config['setup_done']:
71
- c = console.Console()
72
73
  with c.status('Testing credentials...', spinner='shark'):
73
74
  passed, display = test_connection(old_config['DETA_APP_URL'], old_config['DETA_PROJECT_KEY'])
74
75
 
@@ -76,4 +77,9 @@ elif command == 'test':
76
77
  old_config['setup_done'] = True
77
78
  c.print('[bold green]It works!🚀[/bold green]')
78
79
  else:
79
- c.print('[bold red]There was an error:[/bold red]\n'+display)
80
+ c.print('[bold red]There was an error:[/bold red]\n'+display)
81
+ else:
82
+ c.print('Please run [bold white on deep_pink3]python -m plotlyshare setup[/] first')
83
+ elif command == 'show_config':
84
+ print(f'plotlyshare config saved at {config_file_path}:')
85
+ pretty.pprint(old_config)
@@ -4,7 +4,7 @@ requires = ["flit_core >=3.2,<4"]
4
4
 
5
5
  [project]
6
6
  name = "plotlyshare"
7
- version = "1.0.8"
7
+ version = "1.0.10"
8
8
  authors = [{name="plutonium239", email="plutonium.239.811@gmail.com"}]
9
9
  description = "Link-based sharing of `plotly` plots with a private web app"
10
10
  readme = "README.md"
@@ -25,3 +25,6 @@ keywords = ["plotly", "interactive", "plot"]
25
25
  [project.urls]
26
26
  Homepage = "https://github.com/plutonium-239/plotlyshare"
27
27
  Issues = "https://github.com/plutonium-239/plotlyshare/issues"
28
+
29
+ [tool.flit.sdist]
30
+ exclude = ["*/config.json"]
@@ -1,6 +0,0 @@
1
- {
2
- "DETA_APP_URL": "https://plotlyshare-1-r8742502.deta.app",
3
- "DETA_PROJECT_KEY": "d0jtJXqwnHjE_ncFAJpX61B6FQi8acs6EHwRtvCgFHi1E",
4
- "open_browser_after_upload": true,
5
- "setup_done": true
6
- }
File without changes