xlwings-utils 25.0.7.post1__py3-none-any.whl → 25.0.10__py3-none-any.whl
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.
Potentially problematic release.
This version of xlwings-utils might be problematic. Click here for more details.
- xlwings_utils/xlwings_utils.py +49 -45
- {xlwings_utils-25.0.7.post1.dist-info → xlwings_utils-25.0.10.dist-info}/METADATA +7 -3
- xlwings_utils-25.0.10.dist-info/RECORD +6 -0
- xlwings_utils-25.0.7.post1.dist-info/RECORD +0 -6
- {xlwings_utils-25.0.7.post1.dist-info → xlwings_utils-25.0.10.dist-info}/WHEEL +0 -0
- {xlwings_utils-25.0.7.post1.dist-info → xlwings_utils-25.0.10.dist-info}/top_level.txt +0 -0
xlwings_utils/xlwings_utils.py
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# /_/\_\|_| \_/\_/ |_||_| |_| \__, ||___/ _____ \__,_| \__||_||_||___/
|
|
6
6
|
# |___/ |_____|
|
|
7
7
|
|
|
8
|
-
__version__ = "25.0.
|
|
8
|
+
__version__ = "25.0.10"
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
import dropbox
|
|
@@ -20,6 +20,8 @@ Pythonista = sys.platform == "ios"
|
|
|
20
20
|
try:
|
|
21
21
|
import xlwings
|
|
22
22
|
|
|
23
|
+
xlwings = True
|
|
24
|
+
|
|
23
25
|
except ImportError:
|
|
24
26
|
xlwings = False
|
|
25
27
|
|
|
@@ -32,8 +34,8 @@ def dropbox_init(refresh_token=missing, app_key=missing, app_secret=missing, **k
|
|
|
32
34
|
|
|
33
35
|
This function may to be called prior to using any dropbox function
|
|
34
36
|
to specify the request token, app key and app secret.
|
|
35
|
-
If these are specified as REFRESH_TOKEN, APP_KEY and APP_SECRET
|
|
36
|
-
environment variables, it is
|
|
37
|
+
If these are specified as DROPBOX.REFRESH_TOKEN, DROPBOX.APP_KEY and DROPBOX.APP_SECRET
|
|
38
|
+
environment variables, it is not necessary to call dropbox_init().
|
|
37
39
|
|
|
38
40
|
Parameters
|
|
39
41
|
----------
|
|
@@ -55,47 +57,38 @@ def dropbox_init(refresh_token=missing, app_key=missing, app_secret=missing, **k
|
|
|
55
57
|
|
|
56
58
|
Returns
|
|
57
59
|
-------
|
|
58
|
-
|
|
60
|
+
dropbox object
|
|
59
61
|
"""
|
|
60
62
|
global dbx
|
|
61
63
|
|
|
62
|
-
if Pythonista:
|
|
63
|
-
# under Pythonista, the environ is updated from the .environ.toml file, if present
|
|
64
|
-
environ_file = Path(os.environ["HOME"]) / "Documents" / ".environ.toml"
|
|
65
|
-
|
|
66
|
-
if environ_file.is_file():
|
|
67
|
-
with open(environ_file, "r") as f:
|
|
68
|
-
import toml
|
|
69
|
-
|
|
70
|
-
d = toml.load(f)
|
|
71
|
-
os.environ.update(d)
|
|
72
|
-
|
|
73
64
|
if refresh_token is missing:
|
|
74
|
-
if "REFRESH_TOKEN" in os.environ:
|
|
75
|
-
refresh_token = os.environ["REFRESH_TOKEN"]
|
|
65
|
+
if "DROPBOX.REFRESH_TOKEN" in os.environ:
|
|
66
|
+
refresh_token = os.environ["DROPBOX.REFRESH_TOKEN"]
|
|
76
67
|
else:
|
|
77
|
-
raise ValueError("no REFRESH_TOKEN found in environment.")
|
|
68
|
+
raise ValueError("no DROPBOX.REFRESH_TOKEN found in environment.")
|
|
78
69
|
if app_key is missing:
|
|
79
|
-
if "APP_KEY" in os.environ:
|
|
80
|
-
app_key = os.environ["APP_KEY"]
|
|
70
|
+
if "DROPBOX.APP_KEY" in os.environ:
|
|
71
|
+
app_key = os.environ["DROPBOX.APP_KEY"]
|
|
81
72
|
else:
|
|
82
|
-
raise ValueError("no APP_KEY found in environment.")
|
|
73
|
+
raise ValueError("no DROPBOX.APP_KEY found in environment.")
|
|
83
74
|
if app_secret is missing:
|
|
84
|
-
if "APP_SECRET" in os.environ:
|
|
85
|
-
app_secret = os.environ["APP_SECRET"]
|
|
75
|
+
if "DROPBOX.APP_SECRET" in os.environ:
|
|
76
|
+
app_secret = os.environ["DROPBOX.APP_SECRET"]
|
|
86
77
|
else:
|
|
87
|
-
raise ValueError("no APP_SECRET found in environment.")
|
|
78
|
+
raise ValueError("no DROPBOX.APP_SECRET found in environment.")
|
|
88
79
|
|
|
89
|
-
|
|
80
|
+
_dbx = dropbox.Dropbox(oauth2_refresh_token=refresh_token, app_key=app_key, app_secret=app_secret, **kwargs)
|
|
90
81
|
try:
|
|
91
|
-
|
|
82
|
+
_dbx.files_list_folder(path="") # just to test proper credentials
|
|
92
83
|
except dropbox.exceptions.AuthError:
|
|
93
84
|
raise ValueError("invalid dropbox credentials")
|
|
85
|
+
return _dbx
|
|
94
86
|
|
|
95
87
|
|
|
96
88
|
def _login_dbx():
|
|
89
|
+
global dbx
|
|
97
90
|
if dbx is None:
|
|
98
|
-
dropbox_init() # use environment
|
|
91
|
+
dbx = dropbox_init() # use environment
|
|
99
92
|
|
|
100
93
|
|
|
101
94
|
def list_dropbox(path="", recursive=False, show_files=True, show_folders=False):
|
|
@@ -110,7 +103,7 @@ def list_dropbox(path="", recursive=False, show_files=True, show_folders=False):
|
|
|
110
103
|
path from which to list all files (default: '')
|
|
111
104
|
|
|
112
105
|
recursive : bool
|
|
113
|
-
if True, recursively list files. if False (default) no recursion
|
|
106
|
+
if True, recursively list files and folders. if False (default) no recursion
|
|
114
107
|
|
|
115
108
|
show_files : bool
|
|
116
109
|
if True (default), show file entries
|
|
@@ -124,10 +117,6 @@ def list_dropbox(path="", recursive=False, show_files=True, show_folders=False):
|
|
|
124
117
|
-------
|
|
125
118
|
files : list
|
|
126
119
|
|
|
127
|
-
Note
|
|
128
|
-
----
|
|
129
|
-
Directory entries are never returned
|
|
130
|
-
|
|
131
120
|
Note
|
|
132
121
|
----
|
|
133
122
|
If REFRESH_TOKEN, APP_KEY and APP_SECRET environment variables are specified,
|
|
@@ -289,8 +278,10 @@ class block:
|
|
|
289
278
|
self.dict = {}
|
|
290
279
|
self.number_of_rows = number_of_rows
|
|
291
280
|
self.number_of_columns = number_of_columns
|
|
281
|
+
self._highest_used_row_number = None
|
|
282
|
+
self._highest_used_column_number = None
|
|
292
283
|
|
|
293
|
-
def __eq__(self,other):
|
|
284
|
+
def __eq__(self, other):
|
|
294
285
|
if isinstance(other, block):
|
|
295
286
|
return self.value == other.value
|
|
296
287
|
return False
|
|
@@ -469,10 +460,16 @@ class block:
|
|
|
469
460
|
if column < 1 or column > self.number_of_columns:
|
|
470
461
|
raise IndexError(f"column must be between 1 and {self.number_of_columns} not {column}")
|
|
471
462
|
if value is None:
|
|
472
|
-
if (row,column) in self.dict:
|
|
473
|
-
del self.dict[row,column]
|
|
463
|
+
if (row, column) in self.dict:
|
|
464
|
+
del self.dict[row, column]
|
|
465
|
+
self._highest_used_row_number = None # invalidate cached value
|
|
466
|
+
self._highest_used_column_number = None # invalidate cached value
|
|
474
467
|
else:
|
|
475
468
|
self.dict[row, column] = value
|
|
469
|
+
if self._highest_used_row_number:
|
|
470
|
+
self._highest_used_row_number = max(self._highest_used_row_number, row)
|
|
471
|
+
if self._highest_used_column_number:
|
|
472
|
+
self._highest_used_column_number = max(self._highest_used_column_number, column)
|
|
476
473
|
|
|
477
474
|
def __getitem__(self, row_column):
|
|
478
475
|
row, column = row_column
|
|
@@ -499,6 +496,7 @@ class block:
|
|
|
499
496
|
def number_of_rows(self, value):
|
|
500
497
|
if value < 1:
|
|
501
498
|
raise ValueError(f"number_of_rows should be >=1, not {value}")
|
|
499
|
+
self._highest_used_row_number = None
|
|
502
500
|
self._number_of_rows = value
|
|
503
501
|
for row, column in list(self.dict):
|
|
504
502
|
if row > self._number_of_rows:
|
|
@@ -512,6 +510,7 @@ class block:
|
|
|
512
510
|
def number_of_columns(self, value):
|
|
513
511
|
if value < 1:
|
|
514
512
|
raise ValueError(f"number_of_columns should be >=1, not {value}")
|
|
513
|
+
self._highest_used_column_number = None
|
|
515
514
|
self._number_of_columns = value
|
|
516
515
|
for row, column in list(self.dict):
|
|
517
516
|
if column > self._number_of_columns:
|
|
@@ -519,17 +518,22 @@ class block:
|
|
|
519
518
|
|
|
520
519
|
@property
|
|
521
520
|
def highest_used_row_number(self):
|
|
522
|
-
if self.
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
521
|
+
if not self._highest_used_row_number:
|
|
522
|
+
if self.dict:
|
|
523
|
+
self._highest_used_row_number = max(row for (row, column) in self.dict)
|
|
524
|
+
else:
|
|
525
|
+
self._highest_used_row_number = 1
|
|
526
|
+
return self._highest_used_row_number
|
|
526
527
|
|
|
527
528
|
@property
|
|
528
529
|
def highest_used_column_number(self):
|
|
529
|
-
if self.
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
530
|
+
if not self._highest_used_column_number:
|
|
531
|
+
if self.dict:
|
|
532
|
+
self._highest_used_column_number = max(column for (row, column) in self.dict)
|
|
533
|
+
else:
|
|
534
|
+
self._highest_used_column_number = 1
|
|
535
|
+
|
|
536
|
+
return self._highest_used_column_number
|
|
533
537
|
|
|
534
538
|
def __repr__(self):
|
|
535
539
|
return f"block({self.value})"
|
|
@@ -812,12 +816,12 @@ class block:
|
|
|
812
816
|
def decode_to_files(self):
|
|
813
817
|
"""
|
|
814
818
|
decode the block with encoded file(s) to individual pyoidide file(s)
|
|
815
|
-
|
|
819
|
+
|
|
816
820
|
Returns
|
|
817
821
|
-------
|
|
818
822
|
count : int
|
|
819
823
|
number of files decoded
|
|
820
|
-
|
|
824
|
+
|
|
821
825
|
Note
|
|
822
826
|
----
|
|
823
827
|
if the block does not contain an encode file, the method just returns 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: xlwings_utils
|
|
3
|
-
Version: 25.0.
|
|
3
|
+
Version: 25.0.10
|
|
4
4
|
Summary: xlwings_utils
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/xlwings_utils
|
|
@@ -51,7 +51,9 @@ The xlwings lite system does not provide access to the local file system. With t
|
|
|
51
51
|
|
|
52
52
|
Currently, it is only possible to use full-access Dropbox apps.
|
|
53
53
|
|
|
54
|
-
The easiest way to use the Dropbox functionality is to add the credentials to the environment variables. Add REFRESH_TOKEN,
|
|
54
|
+
The easiest way to use the Dropbox functionality is to add the credentials to the environment variables. Add DROPBOX.REFRESH_TOKEN,
|
|
55
|
+
DROPBOX.APP_KEY and DROPBOX.APP_SECRET with their corresponding values to the environment variables.
|
|
56
|
+
Instructions on how to get these variables can be found here.
|
|
55
57
|
|
|
56
58
|
In order to make a Dropbox app, and get the required environment variables, just execute this line from the command line (shell).
|
|
57
59
|
|
|
@@ -59,8 +61,10 @@ In order to make a Dropbox app, and get the required environment variables, just
|
|
|
59
61
|
python -c "exec(__import__('requests').get('https://salabim.org/dropbox setup.py').text)"
|
|
60
62
|
```
|
|
61
63
|
|
|
64
|
+
The file `dropbox setup.py` can also be found in the repo of xlwings_lite .
|
|
65
|
+
|
|
62
66
|
Then, it is possible to list all files in a specified folder using the list_dropbox function.
|
|
63
|
-
It is also possible to get
|
|
67
|
+
It is also possible to get at all folders and to access all underlying folders.
|
|
64
68
|
|
|
65
69
|
The `read_dropbox` function can be used to read the contents (bytes) of a Dropbox file. As reading from Dropbox under pyodide is rather unreliable, xlwings_utils automatically retries several times (by default 100 times). The actual number of retries can be found with `read_dropbox.retries`.
|
|
66
70
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
|
|
2
|
+
xlwings_utils/xlwings_utils.py,sha256=d4qgsb-65sSLifCallOuAtSHsYhBZx5rCfC5hsvCAgw,28891
|
|
3
|
+
xlwings_utils-25.0.10.dist-info/METADATA,sha256=8n4lu4bgA1E-6sI0sWCY3Z8aaoq-UH-IarF7nQXdgkg,12527
|
|
4
|
+
xlwings_utils-25.0.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
xlwings_utils-25.0.10.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
|
|
6
|
+
xlwings_utils-25.0.10.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
xlwings_utils/__init__.py,sha256=FdaRztevSu5akGL7KBUBRzqwLMRTdvVUuS2Kfp2f1Uc,68
|
|
2
|
-
xlwings_utils/xlwings_utils.py,sha256=6uy2FTJH96N6I5LNzY_ZRMmCU239v6hdD9wEvtapeIU,28199
|
|
3
|
-
xlwings_utils-25.0.7.post1.dist-info/METADATA,sha256=o94CnW04WADOZdVqgikjP9EqLWXKpOTveMKJER2UnNg,12424
|
|
4
|
-
xlwings_utils-25.0.7.post1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
-
xlwings_utils-25.0.7.post1.dist-info/top_level.txt,sha256=kf5SEv0gZiRObPhUoYcc1O_iX_wwTOPeUIYvzyYeAM4,14
|
|
6
|
-
xlwings_utils-25.0.7.post1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|